Files
pbakaus_impeccable/tests/skill-workflow/source-hash.mjs
T
Paul BakausandGitHub 6496f49a1e Fix skill workflow regression coverage (#783)
Clarify launcher fallback and completed documentation handoffs; separate bounded protocol checkpoints from opt-in browser-backed completion diagnostics. Correct fixture containment, target syntax, and artifact assertions. AI assistance: Codex, under maintainer direction.
2026-09-08 08:41:54 -07:00

23 lines
976 B
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import crypto from 'node:crypto';
// Include local styles/scripts/assets too: an unchanged HTML file is not
// evidence of a current capture when an external stylesheet changed.
export function sourceHash(root) {
const hash = crypto.createHash('sha256');
function visit(directory, prefix = '') {
for (const entry of fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
const relative = `${prefix}${entry.name}`;
const file = path.join(directory, entry.name);
if (entry.isDirectory()) visit(file, `${relative}/`);
else if (entry.isFile() && /\.(html?|css|m?js|svg|png|jpe?g|webp|woff2?)$/i.test(entry.name)) {
hash.update(relative).update('\0').update(fs.readFileSync(file)).update('\0');
}
}
}
visit(root);
return hash.digest('hex');
}