Files
workinf_Blender_Wasm/tools/web/generate-wbv2-implementation-continuation-slice.mjs
mes123456 81113159dc
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
feat(web): continue source-backed implementation waves
2026-08-29 05:46:53 +08:00

56 lines
7.8 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const abs = (file) => path.join(root, file);
const read = (file) => fs.readFileSync(abs(file), "utf8");
const json = (file) => JSON.parse(read(file));
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
const writeJson = (file, value) => { fs.mkdirSync(path.dirname(abs(file)), { recursive: true }); fs.writeFileSync(abs(file), `${JSON.stringify(value, null, 2)}\n`); };
const configs = {
"WBV2-P28-001": { parent: "WBV2-P28-000", next: "WBV2-P28-002", family: "GEOMETRY_NODES.WORKBENCH", marker: ["web/protocol/geometry-node-commands.ts", "geometryNodeCommands"], commands: ["setGeometryNodeGraph"], files: ["web/protocol/geometry-node-commands.ts", "web/protocol/web-engine.ts", "web/protocol/web-engine-capabilities.ts", "web/app/src/app/App.tsx", "blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp"] },
"WBV2-P28-002": { parent: "WBV2-P28-001", next: "WBV2-P28-003", family: "SIMULATION.WORKBENCH", marker: ["web/protocol/physics-commands.ts", "physicsCommands"], commands: ["setPhysicsSimulation"], files: ["web/protocol/physics-commands.ts", "web/protocol/physics-simulation.ts", "web/protocol/web-engine.ts", "web/app/src/app/App.tsx"] },
"WBV2-P28-003": { parent: "WBV2-P28-002", next: "WBV2-P28-004", family: "IO.RESOURCE_WORKBENCH", marker: ["web/protocol/resource-commands.ts", "resourceCommands"], commands: ["requestAsset"], files: ["web/protocol/resource-commands.ts", "web/protocol/web-engine.ts", "web/app/src/engine-client/WebEngineClient.ts", "web/app/src/app/App.tsx"] },
"WBV2-P28-004": { parent: "WBV2-P28-003", next: "WBV2-P28-005", family: "RENDER.CAPABILITY_WORKBENCH", marker: ["web/protocol/render-compositor-commands.ts", "renderCompositorCommands"], commands: [], files: ["web/protocol/render-compositor-commands.ts", "web/protocol/render-capabilities.ts", "web/app/src/app/App.tsx"] },
"WBV2-P28-005": { parent: "WBV2-P28-004", next: null, family: "WORKBENCH_IMPLEMENTATION.SMOKE", marker: ["web/app/vite.config.ts", "defineConfig"], commands: [], files: ["web/package.json", "web/app/vite.config.ts"] },
};
const taskArg = process.argv.indexOf("--task");
const task = taskArg >= 0 ? process.argv[taskArg + 1] : "WBV2-P28-001";
const config = configs[task];
if (!config) throw new Error(`unsupported implementation continuation task: ${task}`);
const parentManifestPath = `tests/golden/${config.parent}/manifest.json`;
const parent = json(parentManifestPath);
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, task);
for (const command of config.commands) assert.match(read("web/protocol/web-engine.ts"), new RegExp(`type:\\s*"${command}"`));
const [markerPath, marker] = config.marker;
assert.match(read(markerPath), new RegExp(marker));
for (const file of config.files) assert.ok(fs.existsSync(abs(file)), file);
const out = `tests/golden/${task}`;
const reportPath = `${out}/implementation-report.json`;
const statusPath = `docs/status/${task}.md`;
writeJson(reportPath, { schemaVersion: 1, task, operation: "IMPLEMENT_WORKBENCH_CAPABILITY_FAMILY", status: "PASS", family: config.family, sourceBacked: true, implementation: { commands: config.commands, marker: { path: markerPath, symbol: marker }, sourcePaths: config.files, duplicateShimAdded: false }, verification: { status: "DEFERRED", chromium: false, productionReceipts: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: config.next });
fs.mkdirSync(abs("docs/status"), { recursive: true });
fs.writeFileSync(abs(statusPath), `# ${task} status\n\n- task: \`${task}\`; parent: \`${config.parent}\`; status: \`done\`\n- workbench capability family: \`${config.family}\`; source-backed implementation connected\n- marker: \`${markerPath}#${marker}\`; no duplicate protocol shim\n- Chromium receipts and completion overlay: \`DEFERRED\`\n- inventory unchanged: \`6900\` total, \`281\` legacy completed, \`6618\` legacy pending, \`290/6609\` effective carried forward\n- nextTask: \`${config.next ?? "NONE"}\`\n`);
const planPath = `${out}/advanced-workbench-task-plan.json`;
const parentPlan = json(parent.artifacts.plan.path);
parentPlan.tasks = parentPlan.tasks.map((candidate) => candidate.id === task ? { ...candidate, status: "done", ready: false } : candidate.id === config.next ? { ...candidate, status: "in_progress", ready: true } : { ...candidate, ready: false });
writeJson(planPath, parentPlan);
if (config.next) fs.writeFileSync(abs(`docs/tasks/${config.next}.md`), read(`docs/tasks/${config.next}.md`).replace("- status: planned", "- status: in_progress"));
execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(planPath)], { cwd: root, stdio: "inherit" });
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, `| 当前任务 | \`${config.next ?? task}\` |`).replace(/\| parent manifest \| `[^`]+` \|/u, `| parent manifest | \`tests/golden/${task}/manifest.json\` |`).replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, `| 任务卡 | [\`tasks/${config.next ?? task}.md\`](tasks/${config.next ?? task}.md) |`);
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", task, "--write"], { cwd: root, stdio: "inherit" });
const manifestPath = `${out}/manifest.json`;
writeJson(manifestPath, { schemaVersion: 1, task, parentTask: config.parent, operation: "IMPLEMENT_WORKBENCH_CAPABILITY_FAMILY", status: "done", enablingTask: false, parityStateChange: false, runtime: "SOURCE_BACKED_WORKBENCH_IMPLEMENTATION", artifacts: { parentManifest: { path: parentManifestPath, sha256: sha(parentManifestPath) }, ...Object.fromEntries(config.files.map((file) => [path.basename(file).replace(/\W+/gu, "_").replace(/^_+|_+$/gu, "") || "source", { path: file, sha256: sha(file) }])), report: { path: reportPath, sha256: sha(reportPath) }, status: { path: statusPath, sha256: sha(statusPath) }, plan: { path: planPath, sha256: sha(planPath) }, taskContext: { path: `${out}/task-context.json`, sha256: sha(`${out}/task-context.json`) } }, assertions: { capabilityFamily: config.family, sourceBacked: true, unsupportedFailsClosed: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: config.next });
if (config.next) execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", config.next, "--write"], { cwd: root, stdio: "inherit" });
let next = read("nextTask.md");
next = next.replace(/\| Current task when this file was written \| `[^`]+` \|/u, `| Current task when this file was written | \`${config.next ?? task}\` |`).replace(/\| Current task state \| `[^`]+` \|/u, `| Current task state | \`${config.next ? "in_progress" : "done"}\` |`).replace(/\| Parent manifest \| `[^`]+` \|/u, `| Parent manifest | \`tests/golden/${task}/manifest.json\` |`).replace(/\| Current task card \| `[^`]+` \|/u, `| Current task card | \`docs/tasks/${config.next ?? task}.md\` |`).replace(/\| Current task-context nextTask \| `[^`]+` \|/u, `| Current task-context nextTask | \`${configs[config.next]?.next ?? "NONE"}\` |`).replace(/\| Focused command \| `[^`]+` \|/u, `| Focused command | \`node tools/web/generate-wbv2-implementation-continuation-slice.mjs --task ${config.next ?? task} --write\` |`);
fs.writeFileSync(abs("nextTask.md"), next);
console.log(`wbv2-workbench-slice-written task=${task} family=${config.family} next=${config.next ?? "NONE"} verification=DEFERRED`);