Static scan of tools/ and web/tools/ (1691 files, no tool execution):
purpose/usage/env extraction with provenance badges, family folding
(67 families covering 953 files), 16 directory records, 42 hand-written
chapters plus 4 environment contracts, and a 1996-entry search index.
- tools/tools-manual/{config,scan,extract,chapters,render,verify}.mjs
- tools/build-tools-manual.mjs (--check/--verify/--stats)
- tools/check-tools-manual.mjs (Playwright, desktop + mobile)
- docs/current/tools-manual/index.html (1.08 MB, self-contained)
- web/package.json: manual:tools, check:tools-manual
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
734 lines
45 KiB
JavaScript
734 lines
45 KiB
JavaScript
/**
|
||
* Hand-written Chinese chapters for the ~40 core tools.
|
||
*
|
||
* These carry no inference badge: every command below was either declared in
|
||
* the tool's own header/argparse or is the exact command in
|
||
* web/package.json. Commands use `<repo>` for the workspace root
|
||
* (/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD);
|
||
* the page renders the literal path next to the overview, and every path
|
||
* contains a space, so it must stay quoted in a shell.
|
||
*/
|
||
|
||
const REPO_NOTE = "工作区根目录绝对路径含空格(`Elements SE`):shell 中整体加双引号,或用 `cd \"<绝对路径>\" && …`。";
|
||
|
||
function chapter(chapter) {
|
||
return { repoNote: REPO_NOTE, ...chapter };
|
||
}
|
||
|
||
export const CHAPTERS = [
|
||
/* --- 构建与产物 ------------------------------------------------------ */
|
||
chapter({
|
||
id: "tool-build-web-frontend",
|
||
title: "build_web_frontend.py — 前端交付构建",
|
||
path: "tools/build_web_frontend.py",
|
||
categoryId: "build",
|
||
summary: "从固定工作目录构建 operator 前端。不做 npm 生命周期钩子、独立类型检查、测试或原生构建,只执行交付构建。",
|
||
when: "改完前端源码、确认无其他待验证改动后,作为交付步骤执行。",
|
||
usage: [{ cmd: "cd <repo>/web && python3 ../tools/build_web_frontend.py", note: "工作目录由脚本自身固定,不要在其他目录调用。" }],
|
||
inputs: ["web/ 下已就绪的源码与依赖"],
|
||
outputs: ["前端构建产物(dist)"],
|
||
env: [],
|
||
notes: ["脚本刻意不跑 `tsc --noEmit` 与测试:类型检查请单独执行。", "改前端后若需完整发布,用 `npm run build-and-publish`。"],
|
||
related: ["tool-build-and-publish", "tool-sync-assets"],
|
||
}),
|
||
chapter({
|
||
id: "tool-build-web-module-artifacts",
|
||
title: "build_web_module_artifacts.py — WASM 模块产物构建",
|
||
path: "tools/build_web_module_artifacts.py",
|
||
categoryId: "build",
|
||
summary: "按配置构建 Web 端 WASM 模块产物;支持只构建指定 target,或构建全部 target。",
|
||
when: "内核/探针改动后需要重建模块产物时;发布前用 `--all` 做完整构建。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && python3 tools/build_web_module_artifacts.py --target <name>", note: "只构建指定 target,可重复传入。" },
|
||
{ cmd: "cd <repo> && python3 tools/build_web_module_artifacts.py --all", note: "构建全部已配置 target(发布/CI 用)。" },
|
||
{ cmd: "cd <repo> && python3 tools/build_web_module_artifacts.py --dry-run", note: "只打印将构建哪些 target。" },
|
||
],
|
||
params: [
|
||
{ flag: "--target <name>", note: "只构建该 target,可重复。" },
|
||
{ flag: "--all", note: "构建全部 target。" },
|
||
{ flag: "--dry-run", note: "打印选择结果,不执行构建。" },
|
||
{ flag: "--jobs <n>", note: "并行度,默认 `FREECAD_BUILD_JOBS` 或 CPU 数。" },
|
||
{ flag: "--timeout <s>", note: "单 target 超时,默认 1800 秒。" },
|
||
],
|
||
env: ["FREECAD_BUILD_JOBS"],
|
||
notes: ["WASM 编译必须使用项目预置环境:`EM_CONFIG` / `EM_CACHE` 指向 `freecad-source/build-web/` 下的绝对路径。", "npm 入口:`npm run build:wasm-modules`。"],
|
||
related: ["tool-generate-web-module-registry", "tool-sync-assets"],
|
||
}),
|
||
chapter({
|
||
id: "tool-rebuild-occt-rapidjson",
|
||
title: "rebuild-occt-rwgltf-rapidjson.sh — 恢复 glTF/GLB 导出能力",
|
||
path: "tools/rebuild-occt-rwgltf-rapidjson.sh",
|
||
categoryId: "build",
|
||
summary: "以 `-DHAVE_RAPIDJSON` 单点重编 4 个 `RWGltf` 编译单元、替换 3 份 `libTKRWMesh.a`,再重链 `FreeCADWebDocumentProbe`、同步资产并重建 dist。OCCT 默认以 `USE_RAPIDJSON=OFF` 构建,缺此步 glTF/GLB 导出会报 “glTF writer is unavailable”。",
|
||
when: "任何一次完整 OCCT 重建之后。否则 glTF/GLB 导出静默失效。",
|
||
usage: [{ cmd: "cd <repo> && bash tools/rebuild-occt-rwgltf-rapidjson.sh", note: "需要已存在的 OCCT 构建目录与 RapidJSON 源码(`build-web/rapidjson/`)。" }],
|
||
inputs: ["`build-web/` 下的 OCCT 构建树", "RapidJSON 1.1.0 源码"],
|
||
outputs: ["替换后的 `libTKRWMesh.a`", "重链的 `FreeCADWebDocumentProbe`", "同步后的 kernel 资产与 dist"],
|
||
env: [],
|
||
notes: ["这是唯一能恢复 glTF/GLB 的路径;不要改为给整个 OCCT 打开 RapidJSON 后全量重建。", "脚本结束后按提示重建 dist。"],
|
||
related: ["tool-sync-assets", "tool-build-web-module-artifacts"],
|
||
}),
|
||
chapter({
|
||
id: "tool-build-and-publish",
|
||
title: "build-and-publish.mjs — 站点构建与发布",
|
||
path: "web/tools/build-and-publish.mjs",
|
||
categoryId: "build",
|
||
summary: "Web 站点的构建/发布编排脚本;支持 `--help` 打印用法。",
|
||
when: "需要一次完整发布时。",
|
||
usage: [
|
||
{ cmd: "cd <repo>/web && npm run build-and-publish", note: "package.json 中的正式入口。" },
|
||
{ cmd: "cd <repo>/web && node tools/build-and-publish.mjs --help", note: "打印用法后退出(少数支持 --help 的工具之一)。" },
|
||
],
|
||
env: [],
|
||
notes: ["依赖构建产物存在;先跑 `npm run build` 更稳。"],
|
||
related: ["tool-build-web-frontend", "tool-sync-assets"],
|
||
}),
|
||
chapter({
|
||
id: "tool-sync-assets",
|
||
title: "sync-assets.mjs — 内核产物同步",
|
||
path: "web/tools/sync-assets.mjs",
|
||
categoryId: "build",
|
||
summary: "把内核 WASM 产物同步到 `web/public/kernel` 与 `web/dist/kernel`。按 mtime 择新,写入内容指纹清单,仅在变化时复制;处理 pthread sidecar 与缺失产物对。",
|
||
when: "每次内核产物重建后、跑测试或构建 dist 之前。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run sync-kernel", note: "等价于 `node tools/sync-assets.mjs`。" }],
|
||
inputs: ["`freecad-source/build-web/` 下的探针产物"],
|
||
outputs: ["`web/public/kernel/*`", "`web/dist/kernel/*`", "资产清单 JSON"],
|
||
env: [],
|
||
notes: ["曾因固定从旧目录复制 Fem 探针导致 `memory access out of bounds`;现行实现按 mtime 择新,勿改回固定路径。", "同目录的 `artifact-assets.mjs` 提供原子复制与清单写入。"],
|
||
related: ["tool-rebuild-occt-rapidjson", "tool-build-web-module-artifacts"],
|
||
}),
|
||
|
||
/* --- 代码生成 -------------------------------------------------------- */
|
||
chapter({
|
||
id: "tool-generate-web-module-registry",
|
||
title: "generate_web_module_registry.py — 模块路由表生成",
|
||
path: "tools/generate_web_module_registry.py",
|
||
categoryId: "codegen",
|
||
summary: "从 `docs/web-parity-matrix.json` 生成 React/Worker 的模块路由表(`module-registry.generated.ts`、`module-metadata.generated.ts`)。生成产物禁止手改。",
|
||
when: "改动 parity matrix、新增/删除工作台模块之后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run sync-module-registry", note: "等价于 `python3 ../tools/generate_web_module_registry.py`。" }],
|
||
inputs: ["`docs/web-parity-matrix.json`"],
|
||
outputs: ["`web/src/module-registry.generated.ts`", "`web/src/module-metadata.generated.ts`"],
|
||
env: [],
|
||
notes: ["OpenSCAD 已整体移除;生成结果不得再含 OpenSCAD 行,也不得手改生成文件。"],
|
||
related: ["tool-generate-release-manifest", "tool-generate-api-index"],
|
||
}),
|
||
chapter({
|
||
id: "tool-generate-api-index",
|
||
title: "generate_python_api_runtime_index.py — Python API 运行时索引",
|
||
path: "tools/generate_python_api_runtime_index.py",
|
||
categoryId: "codegen",
|
||
summary: "为生成的 Python API 分发器生成紧凑运行时索引(带哈希)。同族还有 object/format/viewprovider/property/geometry/document-graph/capability 等索引生成器,用法一致。",
|
||
when: "Python API 清单或分发器变化后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run sync-api-index", note: "同族:`sync-object-index`、`sync-format-index`、`sync-viewprovider-index`、`sync-property-index`、`sync-geometry-index`、`sync-document-graph-index`、`sync-capability-index`。" }],
|
||
inputs: ["生成的 Python API 清单"],
|
||
outputs: ["运行时索引 JSON(含内容哈希)"],
|
||
env: [],
|
||
notes: ["`npm run build` 会按顺序串起全部索引生成器,手工只需跑单个。"],
|
||
related: ["tool-generate-web-module-registry", "tool-generate-release-manifest"],
|
||
}),
|
||
chapter({
|
||
id: "tool-generate-adapter-manifest",
|
||
title: "generate_python_family_adapter_manifest.py — 适配层清单生成",
|
||
path: "tools/generate_python_family_adapter_manifest.py",
|
||
categoryId: "codegen",
|
||
summary: "按模块与 tier 生成 Python 家族适配层清单。位置参数 `module`、`tier`,可选 `--output`。PartDesign/Sketcher/TechDraw/Import/Mesh/Material 等都有对应 npm 脚本。",
|
||
when: "新增或调整某模块的 Python 适配层之后。",
|
||
usage: [
|
||
{ cmd: "cd <repo>/web && npm run sync-partdesign-tier2-adapter", note: "PartDesign + tier-2-pure。" },
|
||
{ cmd: "cd <repo>/web && python3 ../tools/generate_python_family_adapter_manifest.py Mesh tier-2-pure --output docs/p6/mesh-tier2-adapter-manifest.json", note: "直接调用形式。" },
|
||
],
|
||
params: [
|
||
{ flag: "<module>", note: "模块名,如 PartDesign、Sketcher、Mesh。" },
|
||
{ flag: "<tier>", note: "适配层级,如 `tier-2-pure`、`tier-1-readonly`。" },
|
||
{ flag: "--output <path>", note: "清单输出路径。" },
|
||
],
|
||
env: [],
|
||
notes: ["其余 tier2 模块用 `npm run sync-tier2-remainder` 一次生成。"],
|
||
related: ["tool-generate-api-index", "tool-generate-web-module-registry"],
|
||
}),
|
||
chapter({
|
||
id: "tool-generate-release-manifest",
|
||
title: "generate_web_release_manifest.py — 发布清单",
|
||
path: "tools/generate_web_release_manifest.py",
|
||
categoryId: "codegen",
|
||
summary: "为 Web 源码/生成产物/运行时资产生成确定性清单(含哈希),用于发布核对。",
|
||
when: "发布前,`npm run build` 的最后一步会自动调用。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run sync-release-manifest", note: "等价于 `python3 ../tools/generate_web_release_manifest.py`。" }],
|
||
inputs: ["构建后的 web 资产"],
|
||
outputs: ["发布清单 JSON"],
|
||
env: [],
|
||
notes: ["清单是确定性的:相同输入产生相同字节,可作为发布比对基线。"],
|
||
related: ["tool-generate-web-module-registry", "tool-sync-assets"],
|
||
}),
|
||
|
||
/* --- 测试与验收 ------------------------------------------------------ */
|
||
chapter({
|
||
id: "tool-functional-suite",
|
||
title: "web-freecad-functional-suite.mjs — 浏览器功能测试套件",
|
||
path: "tools/web-freecad-functional-suite.mjs",
|
||
categoryId: "test",
|
||
summary: "P0–P4 五层有头浏览器功能套件:壳层隔离、手册章节场景、31 个模块、交叉能力(导出/OPFS/回开/错误恢复/布局)、旧手册 53 例。每次运行产出一个带报告的证据目录。",
|
||
when: "改动共享壳层、任务面板、导出或 OPFS 之后做回归;提交前跑对应层。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && DISPLAY=:1 node tools/web-freecad-functional-suite.mjs --only X-panel-scroll --force", note: "单个用例。" },
|
||
{ cmd: "cd <repo> && DISPLAY=:1 node tools/web-freecad-functional-suite.mjs --priority P1 --force", note: "整层(P1 = 29 个章节用例)。" },
|
||
{ cmd: "cd <repo> && DISPLAY=:1 node tools/web-freecad-functional-suite.mjs --module PartDesign --headless", note: "按模块筛选,无头运行。" },
|
||
{ cmd: "cd <repo> && node tools/web-freecad-functional-suite.mjs --resume", note: "断点续跑。" },
|
||
],
|
||
params: [
|
||
{ flag: "--only <ids>", note: "逗号分隔的用例 id,如 `SHELL-01,X-panel-scroll`。" },
|
||
{ flag: "--priority <P0,P1,…>", note: "按层选择。" },
|
||
{ flag: "--module <name>", note: "按模块筛选 P2 用例。" },
|
||
{ flag: "--resume", note: "从上次断点继续。" },
|
||
{ flag: "--force", note: "忽略断点,强制重跑。" },
|
||
{ flag: "--headless", note: "无头模式。" },
|
||
{ flag: "--slow <ms>", note: "每步慢放,便于人工观察。" },
|
||
{ flag: "--highlight", note: "高亮操作目标。" },
|
||
{ flag: "--screenshots", note: "每步截图。" },
|
||
{ flag: "--jobs <n>", note: "并行度。" },
|
||
{ flag: "--out <dir>", note: "自定义输出目录。" },
|
||
{ flag: "--prune <n>", note: "只保留最近 n 个 run 目录。" },
|
||
{ flag: "--legacy-ids", note: "列出旧套件 53 个 id。" },
|
||
{ flag: "--timeout-scale <x>", note: "整体超时倍数。" },
|
||
],
|
||
outputs: ["`docs/current/web-functional-suite/run-<ISO>/`:`report.md`、`junit.xml`、`index.html`、`results.json`、`gaps.ndjson`、`cases/<id>/result.json`、失败截图"],
|
||
env: ["DISPLAY", "FREECAD_CHROME", "HEADLESS"],
|
||
notes: ["前置顺序:host/端口 → fixture → 文档对象 → 命令状态 → viewport → 产品断言。前置不满足记为 blocked,不记产品回归。", "没有 `--id-prefix` 参数;按前缀筛选用 `--only` 手列。"],
|
||
related: ["tool-functional-cli", "tool-functional-runtime", "tool-functional-report"],
|
||
}),
|
||
chapter({
|
||
id: "tool-functional-cli",
|
||
title: "functional-suite/cli.mjs — 套件 CLI 与参数解析",
|
||
path: "tools/functional-suite/cli.mjs",
|
||
categoryId: "test",
|
||
summary: "导出 `USAGE` 与 `parseArgs`,是套件唯一声明参数表的地方;新增参数先改这里。",
|
||
when: "给套件加/改参数时。",
|
||
usage: [{ cmd: "import { USAGE, parseArgs } from \"./functional-suite/cli.mjs\"", note: "库用法;命令行入口是 `tools/web-freecad-functional-suite.mjs`。" }],
|
||
env: [],
|
||
notes: ["参数解析与帮助文本同源,避免帮助与实现漂移。"],
|
||
related: ["tool-functional-suite"],
|
||
}),
|
||
chapter({
|
||
id: "tool-functional-runtime",
|
||
title: "functional-suite/runtime.mjs — 浏览器运行层",
|
||
path: "tools/functional-suite/runtime.mjs",
|
||
categoryId: "test",
|
||
summary: "套件的运行层:启动 Chrome、打开入口、用例间 `resetState` 隔离(回 about:blank、清空 OPFS、重进页面)、错误清零与断言辅助。",
|
||
when: "新增用例或排查“上个用例污染下个用例”时。",
|
||
usage: [{ cmd: "import { … } from \"./functional-suite/runtime.mjs\"", note: "库用法,被 cases/* 使用。" }],
|
||
env: ["DISPLAY", "FREECAD_CHROME"],
|
||
notes: ["viewport 固定 1440×1000;系统 Chrome 固定 flags:`--no-sandbox --disable-dev-shm-usage --use-angle=swiftshader --enable-unsafe-swiftshader`。", "静态服务用 `tools/static-host.mjs` 的临时端口(带 COOP/COEP),不要占用固定端口。"],
|
||
related: ["tool-functional-suite", "tool-static-host"],
|
||
}),
|
||
chapter({
|
||
id: "tool-functional-report",
|
||
title: "functional-suite/report.mjs — 报告与断点",
|
||
path: "tools/functional-suite/report.mjs",
|
||
categoryId: "test",
|
||
summary: "输出 `report.md`、`junit.xml`、`index.html`、`results.json`、`checkpoint.json`,并实现 run 目录创建与 `--prune` 清理。",
|
||
when: "接入 CI 或调整证据格式时。",
|
||
usage: [{ cmd: "import { newRunDir, persist, finalize, pruneRuns } from \"./functional-suite/report.mjs\"", note: "库用法。" }],
|
||
outputs: ["`docs/current/web-functional-suite/run-<ISO>/`"],
|
||
env: [],
|
||
notes: ["`index.html` 是极简浅色页,仅供跳转;不要与手册页的深色风格混用。"],
|
||
related: ["tool-functional-suite"],
|
||
}),
|
||
chapter({
|
||
id: "tool-functional-cases",
|
||
title: "functional-suite/cases/index.mjs — 用例注册表",
|
||
path: "tools/functional-suite/cases/index.mjs",
|
||
categoryId: "test",
|
||
summary: "汇总 shell / chapters / handwritten / modules / crosscut 五个用例模块,输出完整用例清单。",
|
||
when: "新增用例文件或调整用例排序时。",
|
||
usage: [{ cmd: "import { … } from \"./functional-suite/cases/index.mjs\"", note: "库用法。" }],
|
||
env: [],
|
||
notes: ["P1 章节用例由 `web/manual/scenarios/*.json` 驱动,新增章节先加场景 JSON。", "`X-panel-scroll` 在 `cases/crosscut.mjs`。"],
|
||
related: ["tool-functional-suite", "tool-manual-capture"],
|
||
}),
|
||
chapter({
|
||
id: "tool-full-parity-gate",
|
||
title: "run_full_parity_gate.py — 全量一致性门禁",
|
||
path: "tools/run_full_parity_gate.py",
|
||
categoryId: "test",
|
||
summary: "聚合 source-backed 的 P6 门禁,只校验覆盖度与一致性,不把 boundary 升级成 parity;详细对象/格式/Python/工作台/视图/文档/质量产物仍是权威。",
|
||
when: "发布前或大范围改动后做总门禁。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run full-parity:gate", note: "等价于 `python3 ../tools/run_full_parity_gate.py`。" }],
|
||
inputs: ["各分项门禁产物"],
|
||
outputs: ["汇总结果;非零退出表示不达标"],
|
||
env: [],
|
||
notes: ["失败时先看它指向的分项产物,不要直接改本脚本。"],
|
||
related: ["tool-format-coverage-gate"],
|
||
}),
|
||
chapter({
|
||
id: "tool-format-coverage-gate",
|
||
title: "run_p6_format_coverage_gate.mjs — 格式覆盖门禁",
|
||
path: "tools/run_p6_format_coverage_gate.mjs",
|
||
categoryId: "test",
|
||
summary: "以记录级处置关闭格式卡:同一扩展名的两个源码处理器刻意保持为不同 inventory 行。",
|
||
when: "调整导入/导出格式支持后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run format:coverage", note: "等价于 `node ../tools/run_p6_format_coverage_gate.mjs`。" }],
|
||
env: [],
|
||
notes: ["扩展名白名单在 `web/src/export-service.ts` 的 `EXTENSIONS`,新增格式要同时改白名单与门禁数据。"],
|
||
related: ["tool-full-parity-gate"],
|
||
}),
|
||
chapter({
|
||
id: "tool-auto-resume-official-case",
|
||
title: "auto-resume-official-case.mjs — 官方用例自动续跑",
|
||
path: "tools/auto-resume-official-case.mjs",
|
||
categoryId: "test",
|
||
summary: "读取官方用例账本,挑选下一个可执行的叶子用例续跑;`--json` 输出机器可读结果。",
|
||
when: "无人值守推进官方用例时;也作为 `check:official-continuation` 的第一步。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run check:official-continuation", note: "先跑本脚本 `--json`,再跑 `check-official-case-continuation.mjs --json`。" }],
|
||
env: [],
|
||
notes: ["恢复点以账本 `currentCase`/`resumeCase` 为准,不要自行猜测下一个用例。"],
|
||
related: ["tool-check-official-continuation"],
|
||
}),
|
||
chapter({
|
||
id: "tool-check-official-continuation",
|
||
title: "check-official-case-continuation.mjs — 续跑一致性检查",
|
||
path: "tools/check-official-case-continuation.mjs",
|
||
categoryId: "test",
|
||
summary: "校验官方用例的续跑状态与账本是否一致,`--json` 输出结果。",
|
||
when: "每个阶段开始与断流恢复时。",
|
||
usage: [{ cmd: "cd <repo> && node tools/check-official-case-continuation.mjs --json", note: "只读检查。" }],
|
||
env: [],
|
||
notes: ["发现不一致时先修账本/证据,再继续跑用例。"],
|
||
related: ["tool-auto-resume-official-case"],
|
||
}),
|
||
|
||
/* --- 浏览器与界面 ---------------------------------------------------- */
|
||
chapter({
|
||
id: "tool-static-host",
|
||
title: "static-host.mjs — 静态服务与 Chrome 发现",
|
||
path: "tools/static-host.mjs",
|
||
categoryId: "runtime",
|
||
summary: "共享静态服务模块,也可直接当 CLI 用。服务构建好的 dist,带 COOP/COEP 隔离头,默认监听临时端口。另导出 `findChrome()` 与 `ISOLATION_HEADERS`。",
|
||
when: "任何需要给浏览器提供 web/dist 的脚本或人工核对。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && node tools/static-host.mjs --root web/dist", note: "打印 `ORIGIN=…` 后常驻,Ctrl-C 退出。" },
|
||
{ cmd: "cd <repo> && node tools/static-host.mjs --root web/dist --port 5199 --document workbench.html", note: "固定端口与默认文档。" },
|
||
{ cmd: "import { startStaticHost } from \"./tools/static-host.mjs\"; const { origin, close } = await startStaticHost(distRoot);", note: "模块用法:返回 `{ server, origin, root, close }`。" },
|
||
],
|
||
params: [
|
||
{ flag: "--root <dir>", note: "dist 目录,支持相对路径(内部 `path.resolve`)。" },
|
||
{ flag: "--port <n>", note: "端口,默认 0(临时端口)。" },
|
||
{ flag: "--document <file>", note: "默认文档,默认 `index.html`。" },
|
||
],
|
||
env: ["FREECAD_CHROME"],
|
||
notes: ["`--root` 曾是相对路径陷阱:不 resolve 会让路径守卫对所有请求返回 403;现已修复。", "MIME 表必须显式列出 `.svg` 等类型,否则 Chrome 不渲染图标。", "GLB/GLTF 等二进制以 `application/octet-stream` 提供。"],
|
||
related: ["tool-layout-probe", "tool-functional-runtime"],
|
||
}),
|
||
chapter({
|
||
id: "tool-layout-probe",
|
||
title: "layout-probe.mjs — 三栏布局与面板滚动探针",
|
||
path: "tools/layout-probe.mjs",
|
||
categoryId: "browser",
|
||
summary: "逐页断言:锁定页整页不可滚动、左右面板都在视口内、每个面板拥有真正可滚动的 `.pane-scroll`、注入内容与滚动画布两侧面板后中央舞台位移 ≤1px。",
|
||
when: "改动壳层布局、任务面板、面板 CSS 之后;也可用于人工核对。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && node tools/layout-probe.mjs", note: "默认 5 页:project、partdesign、Part、Robot、Mesh。" },
|
||
{ cmd: "cd <repo> && node tools/layout-probe.mjs --url /partdesign.html --json /tmp/layout.json", note: "单页 + 完整报告。" },
|
||
{ cmd: "cd <repo> && node tools/layout-probe.mjs --headed --pause", note: "有头打开并停住,人工拖左右面板滚动条。" },
|
||
{ cmd: "cd <repo> && node tools/layout-probe.mjs --origin http://127.0.0.1:PORT", note: "复用已启动的 host。" },
|
||
],
|
||
params: [
|
||
{ flag: "--url <path>", note: "可重复;默认 5 个代表页。" },
|
||
{ flag: "--root <dir>", note: "dist 根,默认 `<repo>/web/dist`。" },
|
||
{ flag: "--origin <url>", note: "复用已有 host。" },
|
||
{ flag: "--wait-for <sel>", note: "就绪选择器,默认 `.layout, .design-layout, .pane-scroll`。" },
|
||
{ flag: "--wait-ms <n>", note: "就绪后等待,默认 1500。" },
|
||
{ flag: "--viewport <WxH>", note: "默认 1440x1000。" },
|
||
{ flag: "--headed / --slow <ms> / --pause", note: "人工观察。" },
|
||
{ flag: "--inject <px>", note: "占位块高度,默认 2000;0 关闭。" },
|
||
{ flag: "--scroll-test <px>", note: "面板滚动距离,默认 400。" },
|
||
{ flag: "--screenshot <path>", note: "每页截图,`{page}` 替换为页名。" },
|
||
{ flag: "--json <path>", note: "完整报告输出。" },
|
||
{ flag: "--no-assert", note: "永远退出 0。" },
|
||
],
|
||
outputs: ["每页一行摘要;`--json` 时为完整报告"],
|
||
env: ["DISPLAY", "FREECAD_CHROME"],
|
||
notes: ["退出码:0 通过,1 有失败,2 前置缺失(无 Chrome 或无 dist)。", "窄屏(<721px)页面本就不锁定,探针会标记 skip/失败,属预期回退。"],
|
||
related: ["tool-static-host", "tool-functional-suite"],
|
||
}),
|
||
chapter({
|
||
id: "tool-mcp-browser-session",
|
||
title: "mcp/browser-session.mjs — MCP 浏览器会话",
|
||
path: "tools/mcp/browser-session.mjs",
|
||
categoryId: "browser",
|
||
summary: "MCP 服务的浏览器通道:静态 host + Chromium + `mcp.html` 桥接;导出 `McpBrowserSession` 与 `PrerequisiteError`。",
|
||
when: "通过 MCP 让外部代理驱动 Web FreeCAD 时。",
|
||
usage: [{ cmd: "import { McpBrowserSession, PrerequisiteError, distRoot } from \"./tools/mcp/browser-session.mjs\"", note: "库用法;会话由 MCP 服务创建。" }],
|
||
env: ["HEADLESS", "FREECAD_CHROME", "FREECAD_MCP_READY_TIMEOUT_MS", "FREECAD_MCP_CALL_TIMEOUT_MS"],
|
||
notes: ["`HEADLESS=0` 切有头。", "就绪/调用超时默认 300000 ms;长构建场景再调大。"],
|
||
related: ["tool-static-host", "tool-fcweb-capture"],
|
||
}),
|
||
chapter({
|
||
id: "tool-fcweb-capture",
|
||
title: "fcweb/capture.mjs — 浏览器封装与页面检查",
|
||
path: "tools/fcweb/capture.mjs",
|
||
categoryId: "browser",
|
||
summary: "复用型浏览器工具:`launchBrowser`、`openPage`、`screenshot`、`pageCheck`、`writeArtifact`。`pageCheck` 一次断言 HTTP 200、0 pageerror/console error、0 失败请求、0 坏图、0 横向溢出与锚点存在。",
|
||
when: "写新的页面检查脚本时优先复用,不要另起 Playwright 封装。",
|
||
usage: [
|
||
{ cmd: "import { launchBrowser, openPage, pageCheck } from \"./tools/fcweb/capture.mjs\"", note: "库用法。" },
|
||
{ cmd: "await pageCheck(browser, url, { viewports: [{ width: 1440, height: 900 }], expect: { anchorIds: [\"overview\"] } })", note: "最小调用示例。" },
|
||
],
|
||
env: ["DISPLAY", "FREECAD_CHROME"],
|
||
notes: ["`--headed` 由调用方传入;默认无头。"],
|
||
related: ["tool-tools-manual-check", "tool-ui-capture"],
|
||
}),
|
||
chapter({
|
||
id: "tool-fcweb-ui-capture",
|
||
title: "fcweb/ui-capture.mjs — 工作台截图",
|
||
path: "tools/fcweb/ui-capture.mjs",
|
||
categoryId: "browser",
|
||
summary: "为每个工作台抓一张运行中界面截图;截图清单由 inventory 决定,复用 `capture.mjs` 的浏览器启动与截图能力。",
|
||
when: "更新界面文档配图时。",
|
||
usage: [{ cmd: "cd <repo> && node tools/fcweb/ui-capture.mjs", note: "输出到 `tools/fcweb/out/ui-shots/`,供 `build-ui-doc.mjs` 使用。" }],
|
||
outputs: ["`tools/fcweb/out/ui-shots/*.png`"],
|
||
env: ["DISPLAY"],
|
||
notes: ["必须先构建 dist 并同步 kernel 资产。"],
|
||
related: ["tool-fcweb-ui-inventory", "tool-build-ui-doc"],
|
||
}),
|
||
chapter({
|
||
id: "tool-fcweb-ui-inventory",
|
||
title: "fcweb/ui-inventory.mjs — 界面清单采集",
|
||
path: "tools/fcweb/ui-inventory.mjs",
|
||
categoryId: "browser",
|
||
summary: "采集工作台、面板、命令等界面结构,输出 `out/ui-inventory.json`,是界面文档与审计的数据源。",
|
||
when: "界面结构变化后重建文档前。",
|
||
usage: [{ cmd: "cd <repo> && node tools/fcweb/ui-inventory.mjs", note: "输出 `tools/fcweb/out/ui-inventory.json`。" }],
|
||
outputs: ["`tools/fcweb/out/ui-inventory.json`"],
|
||
env: ["DISPLAY"],
|
||
notes: ["采集结果是后续 `build-ui-doc.mjs` 的唯一输入,不要手改 JSON。"],
|
||
related: ["tool-fcweb-ui-capture", "tool-build-ui-doc"],
|
||
}),
|
||
chapter({
|
||
id: "tool-ui-surface-audit",
|
||
title: "ui-workbench-surface-audit.mjs — 工作台界面审计",
|
||
path: "tools/ui-workbench-surface-audit.mjs",
|
||
categoryId: "audit",
|
||
summary: "逐个工作台抓取模块名并审计界面表面(菜单/工具栏/坞/状态栏),记录数 = 模块数 × viewport 数,不是常数。",
|
||
when: "壳层或工作台布局改动后。",
|
||
usage: [{ cmd: "cd <repo> && DISPLAY=:1 node tools/ui-workbench-surface-audit.mjs", note: "需要已构建的 dist 与可用的 Chrome。" }],
|
||
env: ["DISPLAY", "HEADLESS", "FREECAD_CHROME"],
|
||
notes: ["覆盖规则由 `tools/audit64.mjs` 提供,两者配合使用。"],
|
||
related: ["tool-audit64"],
|
||
}),
|
||
|
||
/* --- 审计与上下文 ---------------------------------------------------- */
|
||
chapter({
|
||
id: "tool-audit64",
|
||
title: "audit64.mjs — 界面覆盖规则共享模块",
|
||
path: "tools/audit64.mjs",
|
||
categoryId: "audit",
|
||
summary: "工作台界面审计覆盖规则的共享 owner:记录数 = 模块数 × viewport 数,由 `ui-workbench-surface-audit.mjs` 提供模块名。被 60+ 脚本导入。",
|
||
when: "修改审计覆盖口径时(只改这一处)。",
|
||
usage: [{ cmd: "import { … } from \"./tools/audit64.mjs\"", note: "库用法。" }],
|
||
env: [],
|
||
notes: ["行数不是常量,不要写死 64。"],
|
||
related: ["tool-ui-surface-audit"],
|
||
}),
|
||
chapter({
|
||
id: "tool-parity-extract",
|
||
title: "parity/extract-desktop-gui.mjs — 桌面 GUI 元数据提取",
|
||
path: "tools/parity/extract-desktop-gui.mjs",
|
||
categoryId: "audit",
|
||
summary: "从桌面 FreeCAD 提取工作台菜单/工具栏/坞/命令元数据,并与 Web 命令矩阵连接。输出 `web/public/api/desktop-gui-manifest.json` 与 `web/docs/current/desktop-parity-matrix.json`。",
|
||
when: "需要刷新桌面基线时(要求本机可运行桌面 FreeCAD)。",
|
||
usage: [{ cmd: "cd <repo> && node tools/parity/extract-desktop-gui.mjs", note: "桌面侧提取,生成两份 JSON。" }],
|
||
outputs: ["`web/public/api/desktop-gui-manifest.json`", "`web/docs/current/desktop-parity-matrix.json`"],
|
||
env: [],
|
||
notes: ["产物是其他 parity 脚本的基线;更新后要重跑相关审计。"],
|
||
related: ["tool-parity-audit", "tool-parity-mount-inventory"],
|
||
}),
|
||
chapter({
|
||
id: "tool-parity-audit",
|
||
title: "parity/audit-web-gui.mjs — 单工作台 GUI 审计",
|
||
path: "tools/parity/audit-web-gui.mjs",
|
||
categoryId: "audit",
|
||
summary: "对单个工作台做 Web GUI 基线审计:菜单/工具栏/坞/状态栏、pageerror 与溢出,并与 `desktop-gui-manifest.json` 对比。",
|
||
when: "某工作台界面改动后。",
|
||
usage: [{ cmd: "cd <repo> && DISPLAY=:1 node tools/parity/audit-web-gui.mjs <workbench>", note: "工作台名作为位置参数。" }],
|
||
env: ["DISPLAY", "FREECAD_CHROME"],
|
||
notes: ["依赖桌面清单存在;缺失时先跑 `extract-desktop-gui.mjs`。"],
|
||
related: ["tool-parity-extract", "tool-parity-mount-inventory"],
|
||
}),
|
||
chapter({
|
||
id: "tool-parity-mount-inventory",
|
||
title: "parity/build-ui-mount-inventory.mjs — 挂载清单",
|
||
path: "tools/parity/build-ui-mount-inventory.mjs",
|
||
categoryId: "audit",
|
||
summary: "把桌面 GUI 清单、Web 命令路由、命令矩阵与已发布壳层的挂载状态连接起来,回答“桌面有 X / Web 实现了什么”。",
|
||
when: "生成或刷新 parity 报告前。",
|
||
usage: [{ cmd: "cd <repo> && node tools/parity/build-ui-mount-inventory.mjs", note: "输出挂载清单 JSON。" }],
|
||
env: [],
|
||
notes: ["三个输入必须同批刷新,否则结论会互相矛盾。"],
|
||
related: ["tool-parity-extract", "tool-parity-audit"],
|
||
}),
|
||
chapter({
|
||
id: "tool-validate-web-context",
|
||
title: "validate_web_context.py — 上下文一致性校验",
|
||
path: "tools/validate_web_context.py",
|
||
categoryId: "audit",
|
||
summary: "校验有界任务上下文与跨文档状态是否一致(continuation、账本、政策文件之间)。",
|
||
when: "交接前后、发现文档状态互相矛盾时。",
|
||
usage: [{ cmd: "cd <repo> && python3 tools/validate_web_context.py", note: "只读校验,非零退出表示不一致。" }],
|
||
env: [],
|
||
notes: ["与 `prepare_web_task_context.py` 配对:一个准备上下文,一个校验。"],
|
||
related: ["tool-prepare-web-context"],
|
||
}),
|
||
chapter({
|
||
id: "tool-prepare-web-context",
|
||
title: "prepare_web_task_context.py — 任务上下文准备",
|
||
path: "tools/prepare_web_task_context.py",
|
||
categoryId: "audit",
|
||
summary: "按任务卡 id 准备有界上下文清单;`task_id` 位置参数缺省为 `active_task`,`--output` 指定清单路径。",
|
||
when: "开始一个新任务卡前。",
|
||
usage: [{ cmd: "cd <repo> && python3 tools/prepare_web_task_context.py <task_id> --output /tmp/context.json", note: "输出上下文清单。" }],
|
||
params: [
|
||
{ flag: "<task_id>", note: "可省略,默认 `active_task`。" },
|
||
{ flag: "--output <path>", note: "清单输出路径。" },
|
||
],
|
||
env: [],
|
||
notes: ["清单只收录有界窗口,避免把整个仓库读进上下文。"],
|
||
related: ["tool-validate-web-context"],
|
||
}),
|
||
chapter({
|
||
id: "tool-check-link-closure",
|
||
title: "check_web_link_closure.py — 链接闭合检查",
|
||
path: "tools/check_web_link_closure.py",
|
||
categoryId: "audit",
|
||
summary: "检查构建产物里的链接是否闭合:位置参数 `build_dir` 与 `target`,`--json` 输出机器可读结果。",
|
||
when: "发布前、批量改路由或文档后。",
|
||
usage: [{ cmd: "cd <repo> && python3 tools/check_web_link_closure.py web/dist index.html --json", note: "检查 dist 的入口链接闭合。" }],
|
||
params: [
|
||
{ flag: "<build_dir>", note: "构建目录。" },
|
||
{ flag: "<target>", note: "入口文件。" },
|
||
{ flag: "--json", note: "JSON 输出。" },
|
||
],
|
||
env: [],
|
||
notes: ["必须在构建完成后运行。"],
|
||
related: ["tool-build-and-publish"],
|
||
}),
|
||
|
||
/* --- 文档生成 -------------------------------------------------------- */
|
||
chapter({
|
||
id: "tool-build-manual",
|
||
title: "manual/build-manual.mjs — 应用手册构建",
|
||
path: "web/tools/manual/build-manual.mjs",
|
||
categoryId: "docs",
|
||
summary: "把 `web/manual/content/*.md`(带 front matter 的章节)与 `web/manual/data/manual-features.json` 渲染成自包含 HTML:`web/teaching/manual.html` + `manual-assets/`。",
|
||
when: "修改手册章节或功能清单后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run build:manual", note: "输出 `web/teaching/manual.html`。" }],
|
||
inputs: ["`web/manual/content/*.md`", "`web/manual/data/manual-features.json`", "`web/tools/manual/template.html`"],
|
||
outputs: ["`web/teaching/manual.html`", "`web/teaching/manual-assets/`"],
|
||
env: [],
|
||
notes: ["模板里已有搜索、侧栏 TOC、进度勾选、图片灯箱、打印样式;新文档应复用同一套 CSS 令牌。", "同族构建器:`build-parts-manual.mjs`、`build-reducer-manual.mjs`、`build-fcweb-toolkit.mjs`。"],
|
||
related: ["tool-manual-features", "tool-manual-capture", "tool-manual-check"],
|
||
}),
|
||
chapter({
|
||
id: "tool-manual-features",
|
||
title: "manual/generate-features.mjs — 手册功能清单生成",
|
||
path: "web/tools/manual/generate-features.mjs",
|
||
categoryId: "docs",
|
||
summary: "生成手册用的功能/清单 JSON:`manual-features.json`、`inventory-snapshot.json`(路径+sha256)、`coverage-audit.json`。",
|
||
when: "手册构建的第一步;界面或文档输入变化后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run manual:features", note: "刷新三份 JSON。" }],
|
||
outputs: ["`web/manual/data/manual-features.json`", "`web/manual/data/inventory-snapshot.json`", "`web/manual/data/coverage-audit.json`"],
|
||
env: [],
|
||
notes: ["顺序:本脚本 → `capture.mjs` 截图 → `build-manual.mjs` → `check-page.mjs`。"],
|
||
related: ["tool-build-manual", "tool-manual-capture"],
|
||
}),
|
||
chapter({
|
||
id: "tool-manual-capture",
|
||
title: "manual/capture.mjs — 手册场景执行与截图",
|
||
path: "web/tools/manual/capture.mjs",
|
||
categoryId: "docs",
|
||
summary: "在真实应用里执行手册场景 JSON(18 种动作),断言界面状态并截图。与功能套件的章节用例共用 `lib/actions.mjs` 动作解释器。",
|
||
when: "手册章节或界面变化后重拍截图。",
|
||
usage: [
|
||
{ cmd: "cd <repo>/web && DISPLAY=:1 node tools/manual/capture.mjs --scenario manual/scenarios/ch01-ui.json --origin <ORIGIN>", note: "指定已启动的 host。" },
|
||
{ cmd: "cd <repo>/web && DISPLAY=:1 node tools/manual/capture.mjs --scenario manual/scenarios/ch01-ui.json --headed", note: "有头观察。" },
|
||
],
|
||
params: [
|
||
{ flag: "--scenario <json>", note: "场景文件路径。" },
|
||
{ flag: "--origin <url>", note: "静态服务地址,默认 `http://127.0.0.1:5181`。" },
|
||
{ flag: "--headed", note: "有头模式。" },
|
||
],
|
||
outputs: ["场景截图(`shots` 计数见 stdout JSON)"],
|
||
env: ["DISPLAY"],
|
||
notes: ["`--origin` 可用 `node tools/static-host.mjs --root web/dist` 输出的地址。", "ch01 场景是冒烟基线:应输出 `{\"ok\":true,…,\"shots\":7}`。"],
|
||
related: ["tool-static-host", "tool-manual-check", "tool-build-manual"],
|
||
}),
|
||
chapter({
|
||
id: "tool-manual-check",
|
||
title: "manual/check-page.mjs — 手册页面检查",
|
||
path: "web/tools/manual/check-page.mjs",
|
||
categoryId: "docs",
|
||
summary: "用 Playwright 在 1440×900 与 390×844 下检查手册页面:0 pageerror、0 坏图、0 横向溢出、章节与锚点数量、搜索命中。",
|
||
when: "构建手册之后。",
|
||
usage: [{ cmd: "cd <repo>/web && npm run check:manual", note: "检查 `web/teaching/manual.html`。" }],
|
||
env: ["DISPLAY", "MANUAL_URL"],
|
||
notes: ["同族:`check-parts-manual.mjs`、`check-reducer-manual.mjs`、`check-fcweb-toolkit.mjs`、`check-ui-design-doc.mjs`。"],
|
||
related: ["tool-build-manual", "tool-tools-manual-check"],
|
||
}),
|
||
chapter({
|
||
id: "tool-build-ui-doc",
|
||
title: "fcweb/build-ui-doc.mjs — 界面文档生成",
|
||
path: "tools/fcweb/build-ui-doc.mjs",
|
||
categoryId: "docs",
|
||
summary: "把 `out/ui-inventory.json` 与手写章节 `docs/current/ui-design/source.html` 渲染成 `docs/current/web-freecad-ui-layout-and-functions.html`。支持 `--seed` 与 `--check`(字节级幂等)。",
|
||
when: "界面结构变化、需要刷新界面文档时。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && node tools/fcweb/build-ui-doc.mjs", note: "生成界面文档。" },
|
||
{ cmd: "cd <repo> && node tools/fcweb/build-ui-doc.mjs --check", note: "只校验是否最新,过期则 exit 1。" },
|
||
],
|
||
params: [
|
||
{ flag: "--seed", note: "用清单初始化手写模板骨架。" },
|
||
{ flag: "--check", note: "幂等检查。" },
|
||
],
|
||
inputs: ["`tools/fcweb/out/ui-inventory.json`", "`docs/current/ui-design/source.html`"],
|
||
outputs: ["`docs/current/web-freecad-ui-layout-and-functions.html`", "`docs/current/web-freecad-ui-assets/`"],
|
||
env: ["DISPLAY"],
|
||
notes: ["合并后会从最终 `<h2 id>` 重新生成 TOC;手写 prose 只改 `source.html`。"],
|
||
related: ["tool-fcweb-ui-inventory", "tool-fcweb-ui-capture"],
|
||
}),
|
||
|
||
/* --- 调度与性能 ------------------------------------------------------ */
|
||
chapter({
|
||
id: "tool-scheduler",
|
||
title: "run_freecad_web_scheduler.py — 无人值守调度器",
|
||
path: "tools/run_freecad_web_scheduler.py",
|
||
categoryId: "scheduler",
|
||
summary: "无人值守循环:按账本挑下一个任务、交给 Codex 轮次执行,直到收到 TERMINATE。",
|
||
when: "长时间无人值守推进时(需用户明确授权)。",
|
||
usage: [{ cmd: "cd <repo> && python3 tools/run_freecad_web_scheduler.py --max-cycles 5 --log-dir /tmp/fcweb-logs", note: "先小步试跑。" }],
|
||
params: [
|
||
{ flag: "--max-cycles <n>", note: "跑 N 轮后停止;0 表示直到 TERMINATE。" },
|
||
{ flag: "--idle-delay <s>", note: "无任务时的重试间隔,默认 30。" },
|
||
{ flag: "--timeout <s>", note: "单轮上限,默认 1800。" },
|
||
{ flag: "--stream-retry-delay <s>", note: "流断开后的退避,默认 20。" },
|
||
{ flag: "--model <name>", note: "可选模型覆盖。" },
|
||
{ flag: "--log-dir <dir>", note: "日志目录。" },
|
||
],
|
||
outputs: ["`<log-dir>` 下的轮次日志"],
|
||
env: [],
|
||
notes: ["启动/断流恢复前先跑 `npm run check:official-continuation`。", "`tools/scheduler-bin/` 提供 git/python/rg 的 PATH 垫片。"],
|
||
related: ["tool-scheduler-context", "tool-analyze-scheduler"],
|
||
}),
|
||
chapter({
|
||
id: "tool-scheduler-context",
|
||
title: "scheduler_context.py — 调度上下文",
|
||
path: "tools/scheduler_context.py",
|
||
categoryId: "scheduler",
|
||
summary: "为无人值守轮次提供有界、结构化的上下文与源码标识(哈希)。",
|
||
when: "调度器内部使用;排查上下文来源时阅读。",
|
||
usage: [{ cmd: "import scheduler_context", note: "Python 库用法,无独立 CLI。" }],
|
||
env: [],
|
||
notes: ["不做全仓库扫描,只读取登记过的文件。"],
|
||
related: ["tool-scheduler"],
|
||
}),
|
||
chapter({
|
||
id: "tool-analyze-scheduler",
|
||
title: "analyze_scheduler_timings.py — 调度计时分析",
|
||
path: "tools/analyze_scheduler_timings.py",
|
||
categoryId: "scheduler",
|
||
summary: "汇总调度轮次耗时,输出统计与可选的 JSON/Markdown 报告。",
|
||
when: "排查“任务变慢/超时”时。",
|
||
usage: [{ cmd: "cd <repo> && python3 tools/analyze_scheduler_timings.py --cycles 20 --json", note: "读滚动缓存。" }],
|
||
params: [
|
||
{ flag: "--cycles <n>", note: "统计轮数,默认 20。" },
|
||
{ flag: "--log-dir <dir>", note: "日志目录。" },
|
||
{ flag: "--json", note: "JSON 输出。" },
|
||
{ flag: "--from-logs", note: "读有界原始轮次日志,而非滚动缓存。" },
|
||
{ flag: "--report-prefix <path>", note: "写详细 JSON 与 Markdown 报告。" },
|
||
],
|
||
env: [],
|
||
notes: ["先用 `--from-logs` 核对原始日志,再信缓存统计。"],
|
||
related: ["tool-scheduler"],
|
||
}),
|
||
|
||
/* --- 本手册自身 ------------------------------------------------------ */
|
||
chapter({
|
||
id: "tool-tools-manual",
|
||
title: "build-tools-manual.mjs — 本手册生成器",
|
||
path: "tools/build-tools-manual.mjs",
|
||
categoryId: "docs",
|
||
summary: "扫描 `tools/` 与 `web/tools/`,静态提取用途/用法/环境变量,合并 40 个手写章节,生成自包含的 `docs/current/tools-manual/index.html`。不执行任何工具。",
|
||
when: "新增/重命名工具,或改了手写章节之后。",
|
||
usage: [
|
||
{ cmd: "cd <repo> && node tools/build-tools-manual.mjs", note: "重新生成手册。" },
|
||
{ cmd: "cd <repo> && node tools/build-tools-manual.mjs --check", note: "只校验是否最新。" },
|
||
{ cmd: "cd <repo> && node tools/build-tools-manual.mjs --stats", note: "打印扫描/分类/族统计。" },
|
||
{ cmd: "cd <repo> && node tools/build-tools-manual.mjs --verify", note: "路径/锚点/自包含/体积断言。" },
|
||
],
|
||
params: [
|
||
{ flag: "--check", note: "字节级幂等检查,过期 exit 1。" },
|
||
{ flag: "--verify", note: "静态完整性断言。" },
|
||
{ flag: "--stats", note: "打印统计后退出。" },
|
||
{ flag: "--root <dir>", note: "仓库根,默认脚本上两级。" },
|
||
{ flag: "--out <path>", note: "输出路径,默认 `docs/current/tools-manual/index.html`。" },
|
||
],
|
||
outputs: ["`docs/current/tools-manual/index.html`"],
|
||
env: [],
|
||
notes: ["模块拆分在 `tools/tools-manual/`:config/scan/extract/chapters/render/verify。"],
|
||
related: ["tool-tools-manual-check"],
|
||
}),
|
||
chapter({
|
||
id: "tool-tools-manual-check",
|
||
title: "check-tools-manual.mjs — 本手册页面检查",
|
||
path: "tools/check-tools-manual.mjs",
|
||
categoryId: "docs",
|
||
summary: "用 Playwright 在桌面与移动视口检查手册页面:0 pageerror、无横向溢出、锚点可跳转、搜索与过滤可用。",
|
||
when: "生成手册之后。",
|
||
usage: [{ cmd: "cd <repo>/web && DISPLAY=:1 node ../tools/check-tools-manual.mjs", note: "或 `npm run check:tools-manual`。" }],
|
||
env: ["DISPLAY", "FREECAD_CHROME"],
|
||
notes: ["复用 `tools/fcweb/capture.mjs` 的 `pageCheck`。"],
|
||
related: ["tool-tools-manual"],
|
||
}),
|
||
];
|
||
|
||
/** The environment contract chapter, rendered before the tool chapters. */
|
||
export const CONTRACT_CHAPTERS = [
|
||
{
|
||
id: "contract-paths",
|
||
title: "路径与工作目录",
|
||
body: [
|
||
"工作区根目录是 `/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD`,含空格:shell 里一律引用绝对路径并整体加双引号,例如 `cd \"/media/mes123456/Elements SE/.../FreeCAD\" && …`。",
|
||
"前端相关命令大多要求工作目录 `<repo>/web`(`npm run …`),仓库级脚本要求 `<repo>`。本手册的命令都标明了 `cd` 到哪。",
|
||
"脚本自身用 `import.meta.url` / `Path(__file__)` 解析仓库根,因此从别处调用也能找到文件,但 npm 脚本仍按 `web/` 约定编写。",
|
||
],
|
||
},
|
||
{
|
||
id: "contract-wasm",
|
||
title: "WASM 编译环境(绝对路径)",
|
||
body: [
|
||
"所有 WASM 编译必须使用项目预置环境,不允许改用系统 Emscripten 或用户级 cache:",
|
||
"`EM_CONFIG=<repo>/freecad-source/build-web/emscripten-config.py`",
|
||
"`EM_CACHE=<repo>/freecad-source/build-web/emscripten-cache`(bzip2 已编译在内,不得重编)",
|
||
"构建目录:`<repo>/freecad-source/build-web/configure`",
|
||
"模板:`export EM_CONFIG=… EM_CACHE=…` 后 `cmake --build \"<build dir>\" --target <Target> -j 8`。判定成功看日志里的 `error:` 与退出码,不要用 `| tail` 的返回码。",
|
||
],
|
||
},
|
||
{
|
||
id: "contract-browser",
|
||
title: "浏览器与显示",
|
||
body: [
|
||
"浏览器套件用系统 Chrome(`/usr/bin/google-chrome`),`FREECAD_CHROME` 可覆盖;无头为默认,`HEADLESS=0` 切有头。",
|
||
"有头运行与截图需要 `DISPLAY=:1`(本机 X 显示)。",
|
||
"静态服务一律用 `tools/static-host.mjs` 的临时端口(带 COOP/COEP);5180 可能挂着旧 dev server,勿用它做验证。",
|
||
],
|
||
},
|
||
{
|
||
id: "contract-opfs",
|
||
title: "OPFS 目录契约",
|
||
body: [
|
||
"文档与导出只落 OPFS,只有用户点“下载到本地”才触发浏览器下载;任何自动下载都算缺口。",
|
||
"FCStd 文档在 `freecad-documents`;几何导出在 `freecad-exports`;参数在 `freecad-parameters`。用例必须按目录分别轮询/回读,禁止跨目录假设。",
|
||
"Node 侧教学脚本用 `opfs-store.mjs` 镜像同名目录 `out/opfs/freecad-exports`,按裸文件名寻址。",
|
||
],
|
||
},
|
||
];
|