also looking at this
Brief agents on the environment a fresh checkout cannot infer
#319
4 files
+126
-0
| @@ -0,0 +1,37 @@ | ||
| 1 | import { expect, test } from 'bun:test' | |
| 2 | import { readFileSync } from 'node:fs' | |
| 3 | import { join } from 'node:path' | |
| 4 | import { checkAgentsGuidelines } from './agents-guidelines' | |
| 5 | ||
| 6 | const root = join(import.meta.dir, '..') | |
| 7 | const read = (name: string): string => readFileSync(join(root, name), 'utf8') | |
| 8 | ||
| 9 | const rules = 'Use pickier, never eslint. buddy-bot handles updates. Use conventional commit messages.' | |
| 10 | const briefed = [ | |
| 11 | 'Set CRAFT_ZIG to the executable pantry.lock pins.', | |
| 12 | 'Zig needs the sibling Libraries/zig-js checkout at the SHA in pins.env.', | |
| 13 | 'The SDK suite is bun run test:sdk.', | |
| 14 | ].join('\n') | |
| 15 | ||
| 16 | test('the repository AGENTS.md briefs the environment and keeps the house rules', () => { | |
| 17 | expect(() => checkAgentsGuidelines(read('AGENTS.md'), read('CLAUDE.md'))).not.toThrow() | |
| 18 | }) | |
| 19 | ||
| 20 | test('rejects an AGENTS.md that only repeats CLAUDE.md', () => { | |
| 21 | expect(() => checkAgentsGuidelines(`# Codex Guidelines\n\n${rules}`, `# Claude Code Guidelines\n\n${rules}`)) | |
| 22 | .toThrow('repeats CLAUDE.md') | |
| 23 | }) | |
| 24 | ||
| 25 | test('names the briefing an AGENTS.md leaves out', () => { | |
| 26 | expect(() => checkAgentsGuidelines(`# Codex\n\n${rules}\n${briefed.replace('pantry.lock', 'the lockfile')}`, `# Claude\n\n${rules}`)) | |
| 27 | .toThrow('pinned Zig toolchain') | |
| 28 | expect(() => checkAgentsGuidelines(`# Codex\n\n${rules}\n${briefed.replace('pins.env', 'a pin file')}`, `# Claude\n\n${rules}`)) | |
| 29 | .toThrow('sibling first-party checkouts') | |
| 30 | expect(() => checkAgentsGuidelines(`# Codex\n\n${rules}\n${briefed.replace('bun run test:sdk', 'bun test')}`, `# Claude\n\n${rules}`)) | |
| 31 | .toThrow('which suite each test script runs') | |
| 32 | }) | |
| 33 | ||
| 34 | test('refuses to let a rewrite drop a shared house rule', () => { | |
| 35 | expect(() => checkAgentsGuidelines(`# Codex\n\n${rules.replace('buddy-bot', 'the bot')}\n${briefed}`, `# Claude\n\n${rules}`)) | |
| 36 | .toThrow('buddy-bot') | |
| 37 | }) | |