Files
reverse-engineering-anything/scripts/verify-documentation-routes.mjs
T
a67525cdf1 docs: organize canonical documentation layout and verify new pages (#2791)
* docs: organize canonical documentation layout (URGENTE)

Group all existing authored guides by domain and ownership, expose complete navigation, and preserve their public routes. Update physical path consumers and release configuration while retaining historical records. Document domain-based specs and ADR slugs without global numbering.

Co-Authored-By: Codex <noreply@openai.com>

* fix(docs): honor home layout in all-page route verification

* style: format reviewed source changes

* fix(docs): preserve routes and navigation cache inputs

* fix: repair the static-check failures on the default branch (#2895)

* fix: repair the static-check failures on the default branch

The default branch fails its own required `Static checks` job three ways, so
every pull request reports that job as failed regardless of its own change.

- `npm run format:check` reports `src/domain/functionComparison.test.ts` and
  `src/ida/IdaOperationRunner.ts`.
- `npm run lint` reports a duplicate `import { join } from "node:path"` in
  `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17).
- `npm run typecheck` reports `format: "devin"` missing from the client format
  union in `src/application/SupportedClients.ts`, and an unchecked index in
  `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is
  inferred as `string[][]`.

Apply the pinned formatter, drop the duplicate import, list the `"devin"` format
that its own definition already uses, and mark the pair array `as const`.

Validation: `npm run check:fast` and `npm run format:check` pass.

* fix(setup): keep Devin on the JSON configuration dialect

---------

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>

* fix(docs): update links after guide relocation

* docs: correct verified documentation route counts

* fix(docs): update browser capture guide link after move (#2820)

Refresh gettext protected-link comments alongside the authored href.

Co-authored-by: Codex <noreply@openai.com>

* fix(docs): include http3 lab in stable routes

* fix(docs): preserve historical release evidence and links

* fix(ghidra): restore Windows verifier identity import

* docs(wakaru): preserve pinned upstream policy link

* docs(index): retain recently added guide links

* docs(mcp): preserve parent retention clarification

* fix(cli): preserve standalone import guidance

* fix(test): preserve translated guide link drift coverage

---------

Co-authored-by: Matheus Breguêz <matbrgz@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: morluto <17176810+morluto@users.noreply.github.com>
Co-authored-by: 吴佳浩Alben <35291372+XiaoBinGan@users.noreply.github.com>
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-08 01:42:28 +08:00

131 lines
5.3 KiB
JavaScript

import assert from "node:assert/strict";
import { readFile, readdir, stat } from "node:fs/promises";
import { basename, resolve, sep } from "node:path";
import { fileURLToPath } from "node:url";
// Public route baseline before categorization, including upstream signal recordings.
// This fixture is independent of the navigation/rewrite implementation.
const routes = `
adb-device-analysis android-analysis apktool-resource-analysis apple-application-analysis
binary-diagnostics browser-observation browser-scenario-contract cli client-configuration
client-verification electron-observation evm-bytecode firmware-analysis flutter-analysis
frida-instrumentation ghidra-dos ghidra-mips ghidra-nativeaot ghidra-provider ghidra-psp
ghidra-riscv go-binaries harmony-analysis http3-capture-lab ida-provider installation
javascript-application-graph javascript-application-workflows javascript-artifact-reconstruction
javascript-recovery javascript-runtime-observation javascript-runtime-reconciliation
jeb-analysis managed-code-analysis mcp-contracts mcp-prompts migration-6.2
native-investigation packet-captures pcap-analysis process-capture raw-binary reconstruction-obligation-ledgers
reconstruction-readiness recorded-crashes releasing roadmap signal-recordings sqlite-databases
testing tool-design wasm-artifacts web-network-captures web-runtime web-source-location
website-module-trace website-script-export windows-ghidra-p0
binary-hardening desktop-application-capture desktop-application-export desktop-application-state
desktop-application-tasks desktop-build-computer desktop-build-witness ines-containers
design/limits-and-recovery
`
.trim()
.split(/\s+/u);
assert.equal(routes.length, 67);
assert.equal(new Set(routes).size, routes.length);
const documentation = resolve(
fileURLToPath(new URL("../docs/", import.meta.url)),
);
const output = resolve(documentation, ".vitepress/dist");
const origin = "https://documentation.invalid";
const checked = new Set();
let internalTargets = 0;
let sourceLinks = 0;
// Legacy public routes remain an independent baseline; all generated pages also
// participate so newly authored directories/specifications cannot escape checks.
for (const route of routes) {
const html = await readFile(resolve(output, route + ".html"), "utf8");
const edit = physicalEditSource(html, route);
assert.equal(basename(edit), basename(route) + ".md");
}
const htmlPages = [];
const directories = [output];
while (directories.length > 0) {
const directory = directories.pop();
for (const entry of await readdir(directory, { withFileTypes: true })) {
const path = resolve(directory, entry.name);
if (entry.isDirectory()) directories.push(path);
else if (entry.isFile() && entry.name.endsWith(".html"))
htmlPages.push(path);
}
}
for (const page of htmlPages.sort()) {
const route = page
.slice(output.length + 1)
.split(sep)
.join("/");
const html = await readFile(page, "utf8");
// The configured home layout and generated 404 render no edit action.
// Their outgoing links still participate in the same all-page scan.
if (route !== "404.html" && route !== "index.html") {
const source = physicalEditSource(html, route);
assert.ok(
(await stat(source)).isFile(),
route + ": edit link source is missing",
);
sourceLinks++;
}
for (const match of html.matchAll(
/<(?:a|img)\b[^>]*\b(?:href|src)="([^"]+)"/gu,
)) {
const destination = match[1].replaceAll("&amp;", "&");
const url = new URL(destination, origin + "/rea/" + route);
if (url.origin !== origin) continue;
assert.ok(
url.pathname.startsWith("/rea/"),
route + ": local link escaped site base " + destination,
);
const key = url.pathname + url.hash;
if (checked.has(key)) continue;
checked.add(key);
let target = decodeURIComponent(url.pathname.slice("/rea/".length));
if (!target || target.endsWith("/")) target += "index.html";
else if (!basename(target).includes(".")) target += ".html";
const physical = resolve(output, target);
assert.ok(
physical.startsWith(output + sep),
destination + ": published path escaped site output",
);
assert.ok(
(await stat(physical)).isFile(),
route + ": broken rendered target " + destination,
);
if (url.hash && target.endsWith(".html")) {
const fragment = decodeURIComponent(url.hash.slice(1));
const page = await readFile(physical, "utf8");
assert.ok(
page.includes('id="' + fragment + '"'),
route + ": missing rendered anchor " + destination,
);
}
internalTargets++;
}
}
function physicalEditSource(html, route) {
const edit = html.match(
/href="https:\/\/github\.com\/morluto\/rea\/edit\/main\/docs\/([^"]+)"/u,
);
assert.ok(edit, route + ": missing physical-source edit link");
const source = resolve(documentation, decodeURIComponent(edit[1]));
assert.ok(
source.startsWith(documentation + sep),
route + ": source escaped documentation root",
);
return source;
}
console.log(
JSON.stringify({
ok: true,
published_routes: routes.length,
html_pages: htmlPages.length,
physical_edit_links: sourceLinks,
distinct_internal_targets_and_anchors: internalTargets,
scope:
"actual generated HTML, local guide routes/edit sources/images and anchors; external network links are not fetched",
}),
);