23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
import { readFileSync } from "node:fs";
|
|
import { createHash } from "node:crypto";
|
|
const D2 = "/mnt/storage/scratch/sage-r64/d2", LAND = "/mnt/storage/scratch/sage-r64/land";
|
|
const want = JSON.parse(readFileSync(`${LAND}/roles/coder.json`, "utf8")).skills;
|
|
for (const h of ["claude-code", "pi"]) {
|
|
const raw = readFileSync(`${D2}/manifest-${h}.json`);
|
|
const m = JSON.parse(raw);
|
|
const prompt = readFileSync(`${D2}/prompt-${h}.md`, "utf8");
|
|
const names = (m.skills ?? []).map((s) => s.name);
|
|
let files = 0, bad = 0, inPrompt = 0;
|
|
for (const s of m.skills) for (const [path, sha256] of Object.entries(s.files)) { const f = { path, sha256 };
|
|
files++;
|
|
const src = readFileSync(`${LAND}/skills/${s.name}/${f.path}`);
|
|
if (createHash("sha256").update(src).digest("hex") !== f.sha256) bad++;
|
|
const open = `<skill-file skill="${s.name}" path="${f.path}">\n`;
|
|
if (prompt.includes(open + src.toString("utf8"))) inPrompt++;
|
|
}
|
|
const markers = (prompt.match(/^<skill-file /gm) ?? []).length;
|
|
console.log(h, "manifest sha256", createHash("sha256").update(raw).digest("hex"), "skills", names.join(","),
|
|
"matchesRole", JSON.stringify(names) === JSON.stringify(want), "files", files, "digestMismatch", bad, "inPrompt", inPrompt, "markers", markers,
|
|
"skillsHeading", /^## Skills$/m.test(prompt));
|
|
}
|