Finalize manual verified status and gap ledger

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-13 13:09:50 +08:00
parent 158e9ddfdc
commit 579d6d20c8
11 changed files with 820 additions and 94 deletions

View File

@@ -0,0 +1,121 @@
#!/usr/bin/env node
// Backfills verified workflows/screenshots from capture reports, writes the gap
// ledger, and refreshes coverage-audit.json. Run after captures and before build.
import fs from "node:fs";
import path from "node:path";
import { createHash } from "node:crypto";
import { fileURLToPath } from "node:url";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
const dataDir = path.join(webRoot, "manual", "data");
const features = JSON.parse(fs.readFileSync(path.join(dataDir, "manual-features.json"), "utf8"));
const captureDir = path.join(dataDir, "capture");
const verifiedCommands = {
ch01: ["Part_Box"],
ch02: ["Part_Box", "Part_Cylinder", "Part_Cut", "Part_CheckGeometry"],
ch03: ["Sketcher_NewSketch", "Sketcher_CreateRectangle"],
ch04: ["PartDesign_Body", "PartDesign_NewSketch", "PartDesign_Pad"],
ch05: ["Assembly_CreateAssembly", "Assembly_InsertLink"],
ch06: ["Spreadsheet_CreateSheet"],
};
const commandIndex = new Map(features.commands.map(item => [`${item.module}:${item.command}`, item]));
const sha256 = file => createHash("sha256").update(fs.readFileSync(file)).digest("hex");
const workflows = [];
const screenshots = [];
for (const name of fs.readdirSync(captureDir).filter(file => file.endsWith(".json")).sort()) {
const report = JSON.parse(fs.readFileSync(path.join(captureDir, name), "utf8"));
if (!report.ok) continue;
const workflowId = `${report.chapter}-${report.workflow}`;
const commands = (verifiedCommands[report.chapter] ?? []).filter(command =>
features.commands.some(item => item.command === command));
for (const shot of report.shots ?? []) {
screenshots.push({ id: shot.id, file: shot.file, chapterId: report.chapter,
workflowId, bytes: shot.bytes, sha256: shot.sha256, fullPage: shot.fullPage });
}
const screenshotId = report.shots?.[0]?.id ?? null;
for (const command of commands) {
const item = features.commands.find(entry => entry.command === command
&& entry.chapterId === report.chapter);
if (!item) continue;
item.status = "verified";
item.workflowId = workflowId;
item.screenshotId = screenshotId;
}
workflows.push({ id: workflowId, chapterId: report.chapter, title: report.workflow,
commands, screenshots: (report.shots ?? []).map(shot => shot.id), status: "verified" });
}
features.workflows = workflows;
features.screenshots = screenshots;
features.stats.workflows = workflows.length;
features.stats.screenshots = screenshots.length;
features.stats.verified = features.commands.filter(item => item.status === "verified").length;
const moduleGaps = [
{ id: "b-techdraw-worker", module: "TechDraw", title: "TechDraw 跨 Worker 文档桥",
detail: "页面 Worker 未持有目标文档,TechDraw_PageDefault 报 Document does not exist;SVG 回退不是 TechDraw 输出。",
desktopRefs: ["freecad-source/src/Mod/TechDraw/App/DrawPage.cpp", "freecad-source/src/Mod/TechDraw/App/DrawViewPart.cpp"],
status: "boundary", evidence: "web/tools/manual/evidence/ch11" },
{ id: "b-fem-native", module: "Fem", title: "FEM 原生结果对象",
detail: "FemMeshObject/FemResultObject 未随包发布,结果停留在 Worker;VTK 显示为 three.js 近似。",
desktopRefs: ["freecad-source/src/Mod/Fem/App/FemMeshObject.cpp", "web/docs/current/web-freecad-gaps-fem.md"],
status: "boundary", evidence: "web/tools/manual/evidence/ch12" },
{ id: "b-cam-opencamlib", module: "CAM", title: "CAM OpenCAMLib 路径",
detail: "Adaptive/Surface/Waterline 依赖 OpenCAMLib 与完整 ToolBit/G-code 栈,WASM 包未提供。",
desktopRefs: ["freecad-source/src/Mod/CAM/App/AppPath.cpp", "web/docs/current/cam-teaching-gap.md"],
status: "boundary", evidence: "web/tools/manual/evidence/ch10" },
{ id: "b-gltf-native", module: "Import", title: "glTF 原生导入/导出",
detail: "OCCT WASM 构建 USE_RAPIDJSON=OFF,RWGltf 无法读写;当前仅 three.js 查看。",
desktopRefs: ["freecad-source/src/Mod/Import/App/ReaderGltf.cpp", "freecad-source/src/Mod/Import/App/WriterGltf.cpp"],
status: "boundary", evidence: "web/manual/content/ch07-import-export.md" },
{ id: "b-cloud-remote", module: "Cloud", title: "Cloud 远程存储",
detail: "Save/Restore 需要远程 S3 凭据与服务;本地 OPFS 不受影响。",
desktopRefs: ["web/src/cloud.worker.ts"], status: "boundary", evidence: "web/manual/content/ch13-specialists.md" },
{ id: "b-material-sparse", module: "Material", title: "Material 原生库兼容",
detail: "Material 原生 API 对稀疏数组/单位处理不完整,部分命令为边界。",
desktopRefs: ["freecad-source/src/Mod/Material/App/MaterialManager.cpp"], status: "boundary",
evidence: "web/docs/current/freecad-official-case-ledger.json" },
{ id: "b-openscad-recompile", module: "OpenSCAD", title: "OpenSCAD 二次编译崩溃",
detail: "同一实例连续编译可能崩溃;逐次保存并重启实例。",
desktopRefs: ["freecad-source/src/Mod/OpenSCAD/App/OpenSCADUtils.cpp"], status: "boundary",
evidence: "web/manual/content/ch13-specialists.md" },
];
const gapLedger = {
schema: "freecad-web-manual/gaps/v1",
generatedAt: new Date().toISOString(),
verified: features.commands.filter(item => item.status === "verified").length,
fixNeeded: [],
boundaries: moduleGaps,
notes: [
"草图编辑器当前嵌在属性栏,面板窄且需滚动;属布局边界,可用 React 移到主舞台。",
"项目页 Part 文档切换 PartDesign 需要 ownership handoff;教程改用 partdesign.html。",
"Mesh/BIM/TechDraw/FEM 模块页显示 boundary/no-worker,教程按模块页实际任务与边界编写。",
],
};
fs.writeFileSync(path.join(dataDir, "manual-features.json"), `${JSON.stringify(features, null, 2)}\n`);
fs.writeFileSync(path.join(dataDir, "gap-ledger.json"), `${JSON.stringify(gapLedger, null, 2)}\n`);
const coverage = JSON.parse(fs.readFileSync(path.join(dataDir, "coverage-audit.json"), "utf8"));
coverage.verified = features.stats.verified;
coverage.workflows = features.stats.workflows;
coverage.screenshots = features.stats.screenshots;
coverage.byStatus = Object.fromEntries(["verified", "detailed", "overview", "boundary"].map(status =>
[status, features.commands.filter(item => item.status === status).length]));
coverage.ok = coverage.unknownModules.length === 0;
fs.writeFileSync(path.join(dataDir, "coverage-audit.json"), `${JSON.stringify(coverage, null, 2)}\n`);
const lines = [
"# Web FreeCAD 教案缺口台账", "",
`生成时间:${gapLedger.generatedAt}`, "",
`已验证命令:${gapLedger.verified};待修:${gapLedger.fixNeeded.length};边界:${gapLedger.boundaries.length}`, "",
"| 模块 | 边界 | 原因 | 桌面源码入口 |", "|---|---|---|---|",
...moduleGaps.map(gap => `| ${gap.module} | ${gap.title} | ${gap.detail} | ${gap.desktopRefs.join("<br>")} |`),
"", "## 布局/流程说明", "", ...gapLedger.notes.map(note => `- ${note}`),
];
const docDir = path.join(webRoot, "docs", "current");
fs.mkdirSync(docDir, { recursive: true });
fs.writeFileSync(path.join(docDir, "web-freecad-manual-gaps.md"), `${lines.join("\n")}\n`);
console.log(JSON.stringify({ ok: true, verified: features.stats.verified, workflows: workflows.length,
screenshots: screenshots.length, boundaries: moduleGaps.length }));