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>
166 lines
9.8 KiB
JavaScript
166 lines
9.8 KiB
JavaScript
/**
|
||
* Static configuration for tools/build-tools-manual.mjs.
|
||
*
|
||
* Categories are ordered: the first rule whose `test` returns true wins, so
|
||
* path-based rules (docs pipeline, compat shims, data) must sit above the
|
||
* filename-based ones.
|
||
*/
|
||
|
||
export const REPO_ROOT = new URL("../../", import.meta.url).pathname;
|
||
|
||
export const SCAN_ROOTS = [
|
||
{ relPath: "tools", recursive: true },
|
||
{ relPath: "web/tools", recursive: false },
|
||
{ relPath: "web/tools/manual", recursive: true },
|
||
];
|
||
|
||
/** Directory names skipped anywhere in the walk. */
|
||
export const SKIP_DIRS = new Set(["__pycache__", "node_modules", ".git", "out", "dist", "assets"]);
|
||
|
||
/** Files skipped by basename pattern. */
|
||
export const SKIP_FILE = /(\.pyc$|\.bak$|\.inc\.mjs$|^batch-.*\.json$|\.lock$|^\.)/;
|
||
|
||
/** Extensions that are read for purpose/usage/env extraction. */
|
||
export const READ_EXTS = new Set([".mjs", ".js", ".ts", ".tsx", ".py", ".sh", ".ps1", ".json", ".cmake"]);
|
||
|
||
/** How many bytes of each file are read. */
|
||
export const HEAD_BYTES = 16 * 1024;
|
||
|
||
/**
|
||
* Summary-only directories: one inventory row per directory instead of one per
|
||
* file, because they are generated tables/fixtures with no individual CLI.
|
||
*/
|
||
export const DIRECTORY_SUMMARIES = [
|
||
{ relPath: "tools/generated-contracts", label: "生成契约表", category: "data", note: "由生成器产出的模块/路由契约表,供运行时与校验脚本读取,不直接执行。" },
|
||
{ relPath: "tools/fixtures", label: "测试夹具", category: "data", note: "IFC 等二进制/文本夹具,被验收脚本读取。" },
|
||
{ relPath: "tools/scheduler-bin", label: "调度 PATH 垫片", category: "compat", note: "git/python/rg 的 PATH 垫片,由调度器注入。" },
|
||
{ relPath: "tools/emcc-compat-bin", label: "emcc 兼容垫片", category: "compat", note: "emcc/em++ 包装脚本,转发到系统 emcc;每次调用会追加日志。" },
|
||
{ relPath: "tools/emscripten-compat", label: "Emscripten 启动钩子", category: "compat", note: "sitecustomize.py,在 Python 解释器启动时自动导入。" },
|
||
{ relPath: "web/tools/carrier-course", label: "内容工程:carrier", category: "docs", note: "课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/abb120-course", label: "内容工程:abb120", category: "docs", note: "课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/delta-course", label: "内容工程:delta", category: "docs", note: "课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/line-course", label: "内容工程:生产线", category: "docs", note: "生产线课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/reducer-course", label: "内容工程:减速器", category: "docs", note: "减速器课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/reducer-parts-course", label: "内容工程:减速器零件", category: "docs", note: "减速器零件课程媒体生成脚本与素材。" },
|
||
{ relPath: "web/tools/line-manual", label: "内容工程:生产线手册", category: "docs", note: "生产线手册构建脚本与素材。" },
|
||
{ relPath: "web/tools/bim-workshop-video", label: "内容工程:BIM 工作坊视频", category: "docs", note: "BIM 工作坊录屏与合成脚本。" },
|
||
{ relPath: "web/tools/carrier-video", label: "内容工程:carrier 视频", category: "docs", note: "carrier 视频合成脚本。" },
|
||
{ relPath: "web/tools/cad-ui-rebuild", label: "内容工程:CAD UI 重建", category: "docs", note: "CAD 界面重建截图脚本。" },
|
||
{ relPath: "web/tools/reducer-ui-rebuild", label: "内容工程:减速器 UI 重建", category: "docs", note: "减速器界面重建截图脚本。" },
|
||
];
|
||
|
||
/** Ordered category rules. */
|
||
export const CATEGORIES = [
|
||
{
|
||
id: "docs",
|
||
label: "文档生成与页面检查",
|
||
hint: "手册、界面文档、截图与页面校验",
|
||
test: (p, n) => p.startsWith("web/tools/manual/") || p.startsWith("web/tools/line-manual/")
|
||
|| /^(build-ui-doc|build-fcweb-toolkit|build-manual|build-parts-manual|build-reducer-manual|generate-gaps-doc|generate-panel-index|generate-features|generate-final-status|check-page|check-ui-design-doc|check-fcweb-toolkit|check-parts-manual|check-reducer-manual)\.mjs$/.test(n),
|
||
},
|
||
{
|
||
id: "compat",
|
||
label: "兼容垫片与外部工具",
|
||
hint: "emcc、Emscripten、调度 PATH 垫片",
|
||
test: (p) => p.startsWith("tools/emcc-compat-bin/") || p.startsWith("tools/emscripten-compat/") || p.startsWith("tools/scheduler-bin/"),
|
||
},
|
||
{
|
||
id: "data",
|
||
label: "数据、契约与夹具",
|
||
hint: "JSON、生成契约表、二进制夹具",
|
||
test: (p, n) => p.endsWith(".json") || p.startsWith("tools/generated-contracts/") || p.startsWith("tools/fixtures/"),
|
||
},
|
||
{
|
||
id: "runtime",
|
||
label: "静态宿主与运行环境",
|
||
hint: "静态服务、Chrome 发现",
|
||
test: (p, n) => /^(static-host|artifact-assets|wasm-probe-runtime)\.mjs$/.test(n),
|
||
},
|
||
{
|
||
id: "cases",
|
||
label: "用例与业务场景表",
|
||
hint: "可被 smoke/gate 导入的场景数据",
|
||
test: (p, n) => /-business-cases/.test(n),
|
||
},
|
||
{
|
||
id: "browser",
|
||
label: "浏览器自动化与界面探测",
|
||
hint: "Playwright 驱动、UI 一致性、截图、布局探针",
|
||
test: (p, n) => /^ui-/.test(n) || /^(capture|ui-capture|ui-inventory|browser-session|page-check|case-replay|probe-run-case|diagnose-bridge|mcp)/.test(n)
|
||
|| /probe|-probe|replay-|layout-probe|audit-web-gui|ui-parity-preflight|ui-workbench-surface-audit/.test(n),
|
||
},
|
||
{
|
||
id: "test",
|
||
label: "测试与验收",
|
||
hint: "冒烟、门禁、功能套件、官方用例续跑",
|
||
test: (p, n) => p.startsWith("tools/functional-suite/") || /^run[_-]/.test(n) || /smoke|gate|worker|parity|official-case|functional-suite/.test(n),
|
||
},
|
||
{
|
||
id: "codegen",
|
||
label: "同步与代码生成",
|
||
hint: "生成注册表、运行时索引、清单",
|
||
test: (p, n) => /^generate/.test(n) || /^sync[-_]/.test(n) || /^generate_/.test(n),
|
||
},
|
||
{
|
||
id: "build",
|
||
label: "构建与打包",
|
||
hint: "前端构建、内核产物、离线包",
|
||
test: (p, n) => /^(build[-_]|rebuild)/.test(n) || /^assemble_/.test(n) || n === "build-and-publish.mjs",
|
||
},
|
||
{
|
||
id: "audit",
|
||
label: "审计与上下文校验",
|
||
hint: "界面覆盖审计、上下文一致性、链接闭合",
|
||
test: (p, n) => /^(audit|validate|check)/.test(n) || p.startsWith("tools/parity/"),
|
||
},
|
||
{
|
||
id: "scheduler",
|
||
label: "调度与性能",
|
||
hint: "无人值守调度器、计时分析、基准",
|
||
test: (p, n) => /scheduler|benchmark|analyze_|timing/.test(n),
|
||
},
|
||
{ id: "other", label: "其他", hint: "未归类的脚本", test: () => true },
|
||
];
|
||
|
||
export const CATEGORY_BY_ID = new Map(CATEGORIES.map((c) => [c.id, c]));
|
||
|
||
/** Trailing tokens that mark a variant of a family rather than a distinct tool. */
|
||
export const VARIANT_TOKENS = new Set([
|
||
"smoke", "chrome", "headless", "gate", "probe", "worker", "batch", "summary", "receipt",
|
||
"recovery", "persistence", "kernel", "native", "boundary", "runtime", "test", "tests",
|
||
"check", "capture", "audit", "build", "v2", "node", "web", "shell", "case", "cases",
|
||
]);
|
||
|
||
/** Known environment variables with Chinese descriptions. */
|
||
export const ENV_DOCS = {
|
||
HEADLESS: "设为 0 时以有头模式启动浏览器(默认无头)。",
|
||
FREECAD_CHROME: "Chrome/Chromium 可执行文件绝对路径,覆盖默认候选。",
|
||
FREECAD_BROWSER_ORIGIN: "复用已启动的静态服务地址,跳过自建 host。",
|
||
FREECAD_BROWSER_EXECUTABLE: "浏览器可执行文件路径(部分工具用法)。",
|
||
FREECAD_PARITY_ENTRY: "桌面/Web 一致性检查的入口页面或数据文件。",
|
||
FREECAD_CAM_CASE: "CAM 用例筛选 id。",
|
||
FREECAD_BUSINESS_IDS: "业务用例 id 列表(逗号分隔)。",
|
||
FREECAD_BUILD_JOBS: "构建并行度(默认取 CPU 数)。",
|
||
FREECAD_CCACHE_RAM: "ccache 可用内存上限,用于编译调度。",
|
||
FREECAD_MCP_READY_TIMEOUT_MS: "MCP 浏览器会话就绪超时(毫秒)。",
|
||
FREECAD_MCP_CALL_TIMEOUT_MS: "MCP 单次调用超时(毫秒)。",
|
||
MANUAL_URL: "手册页面地址,供页面检查脚本使用。",
|
||
EM_CONFIG: "Emscripten 配置文件绝对路径(WASM 编译铁律)。",
|
||
EM_CACHE: "Emscripten 缓存目录绝对路径(WASM 编译铁律)。",
|
||
DISPLAY: "X11 显示号;有头浏览与截图需要(如 :1)。",
|
||
};
|
||
|
||
/** Ten commands worth putting on the first screen. */
|
||
export const QUICKSTART = [
|
||
{ cmd: "npx tsc --noEmit && npx vite build", cwd: "<repo>/web", note: "前端类型检查 + 构建 dist(改过 web/src 后必跑)。" },
|
||
{ cmd: "python3 ../tools/build_web_frontend.py", cwd: "<repo>/web", note: "生成式前端交付构建(固定工作目录,不跑测试)。" },
|
||
{ cmd: "node ../tools/sync-assets.mjs", cwd: "<repo>/web", note: "同步内核产物到 public/kernel 与 dist/kernel(按 mtime 择新)。" },
|
||
{ cmd: "DISPLAY=:1 node tools/web-freecad-functional-suite.mjs --only X-panel-scroll --force", cwd: "<repo>", note: "跑单个功能用例。" },
|
||
{ cmd: "DISPLAY=:1 node tools/web-freecad-functional-suite.mjs --priority P1 --force", cwd: "<repo>", note: "跑整层手册章节用例。" },
|
||
{ cmd: "node tools/layout-probe.mjs --url /partdesign.html", cwd: "<repo>", note: "检查三栏布局与左右面板独立滚动。" },
|
||
{ cmd: "node tools/static-host.mjs --root web/dist", cwd: "<repo>", note: "起一个带 COOP/COEP 的临时静态服务并打印 ORIGIN。" },
|
||
{ cmd: "DISPLAY=:1 node tools/manual/capture.mjs --scenario manual/scenarios/ch01-ui.json --origin <ORIGIN>", cwd: "<repo>/web", note: "跑手册场景并截图。" },
|
||
{ cmd: "node ../tools/build-tools-manual.mjs --check", cwd: "<repo>/web", note: "校验本手册是否为最新(幂等检查)。" },
|
||
{ cmd: "DISPLAY=:1 node ../tools/check-tools-manual.mjs", cwd: "<repo>/web", note: "Playwright 检查本手册页面与交互。" },
|
||
];
|