mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 12:19:29 +01:00
* 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
13 lines
1005 B
JavaScript
13 lines
1005 B
JavaScript
#!/usr/bin/env node
|
|
/** Self-test for the pure part of sync-agent-rules.mjs. No network. */
|
|
import { plan } from './sync-agent-rules.mjs';
|
|
import { CLAUDE_POINTER, ruleBlock, withBlock } from '../ci/agent-rules.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++));
|
|
const block = ruleBlock('Rule.\n');
|
|
eq(plan({ agents: null, claude: null }, block), { 'AGENTS.md': `# Agents\n\n${block}`, 'CLAUDE.md': CLAUDE_POINTER }, 'a repo with neither file gets both');
|
|
eq(plan({ agents: '# A\n\nmine\n', claude: 'a very long essay\n'.repeat(100) }, block), { 'AGENTS.md': `# A\n\n${block}\nmine\n` }, 'an existing CLAUDE.md is never rewritten; AGENTS.md keeps its notes');
|
|
eq(plan({ agents: withBlock('# A\n', block), claude: CLAUDE_POINTER }, block), null, 'a current repo needs nothing');
|
|
console.log(`\n${pass} passed, ${fail} failed`);
|
|
process.exit(fail ? 1 : 0);
|