Files
fleet/scripts/ci/test-agent-files-audit.mjs
Cato 9a57486a37 feat(agents): one org-rules block in every repo's AGENTS.md, generated here, plus an audit (#315)
* feat(agents): one org-rules block in every repo's AGENTS.md, generated here, with an audit that fails a repo that starts without it

Problem: the org rules were restated by hand in CLAUDE.md essays (aoz-begleitung 1,850 lines), AGENTS.md intros and three differently worded starter templates; the starter said accounts are the app's own above a rule saying accountkit owns them. Nothing checked any of it, and 18 agent files import a personal ~/.claude file.

Change: templates/agent-rules.md is the only place the rules are written. sync-agent-rules.mjs opens one pull request per code repo putting it between fleet:rules markers (and a CLAUDE.md pointer where there is no CLAUDE.md; an existing CLAUDE.md is never rewritten). agent-files-audit.mjs fails on a finding not in agent-files.baseline; a baselined finding that has been fixed, or a block that is merely out of date, never fails it (the org-drift ratchet went red twice on 26 Oct because a file in another repo improved). All three templates carry the block and a test pins that. Own workflow, so a finding in another repo cannot hold this repo's merges.

Validation: 27 + 4 + 3 self-tests pass; the audit read 46 repositories and found 77 findings, all baselined; docs-truth-audit reports the same result on solon, petvity, aoz-begleitung and skif with and without the block.

* fix(agents): blank lines around the markers so prettier-checked repos accept the block
2026-10-28 02:43:34 +01:00

12 lines
843 B
JavaScript

#!/usr/bin/env node
/** Self-test for the pure parts of agent-files-audit.mjs. No network. */
import { diff, lines } from './agent-files-audit.mjs';
let pass = 0, fail = 0;
const eq = (a, b, m) => (JSON.stringify(a) === JSON.stringify(b) ? (console.log(` ✓ ${m}`), pass++) : (console.log(` ✗ ${m} — got ${JSON.stringify(a)}`), fail++));
eq(lines('# c\n\nx/y # why\n z/w\n'), ['x/y', 'z/w'], 'baseline lines drop comments and blanks');
eq(diff(['a/r', 'b/r'], ['a/r']), { fresh: ['b/r'], fixed: [] }, 'a finding that is not baselined is new');
eq(diff(['a/r'], ['a/r', 'b/r']), { fresh: [], fixed: ['b/r'] }, 'a baselined finding that is gone is fixed, and is not a failure');
eq(diff([], []), { fresh: [], fixed: [] }, 'nothing found, nothing baselined');
console.log(`\n${pass} passed, ${fail} failed`);
process.exit(fail ? 1 : 0);