chore: 收敛模板证据哈希并接入提交钩子

This commit is contained in:
que01 committed 2026-10-21 14:41:23 +08:00
1 parent ec0cf78d69
commit 669d4a7de6
7 files changed
+146 -15

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
import { sourceTreeHash } from "./lib/template-doctor.mjs";
const REGISTRY = path.join(
".codex-tasks",
"template-audit-execution",
"raw",
"completion-evidence.json",
);
const shouldStage = process.argv.includes("--stage");
if (!fs.existsSync(REGISTRY)) {
console.log(`template evidence: ${REGISTRY} 不存在,跳过`);
process.exit(0);
}
const registry = JSON.parse(fs.readFileSync(REGISTRY, "utf8"));
const nextHash = sourceTreeHash(process.cwd(), { staged: shouldStage });
if (registry.sourceTreeHash === nextHash) {
console.log("template evidence: 源码哈希已是最新");
process.exit(0);
}
registry.sourceTreeHash = nextHash;
registry.generatedAt = new Date().toISOString();
fs.writeFileSync(REGISTRY, JSON.stringify(registry, null, 2) + "\n");
console.log(`template evidence: sourceTreeHash 更新为 ${nextHash}`);
if (shouldStage) execFileSync("git", ["add", "-f", REGISTRY], { stdio: "inherit" });