ReviewOS

also looking at this

craft-native/craft

Brief agents on the environment a fresh checkout cannot infer

#319
Merged glennmichael123 wants to merge fix/agents-environment-briefing into main
4 files +126 -0
scripts/agents-guidelines.test.tsadded+37-0
Changes to scripts/agents-guidelines.test.ts
@@ -0,0 +1,37 @@
1import { expect, test } from 'bun:test'
2import { readFileSync } from 'node:fs'
3import { join } from 'node:path'
4import { checkAgentsGuidelines } from './agents-guidelines'
5
6const root = join(import.meta.dir, '..')
7const read = (name: string): string => readFileSync(join(root, name), 'utf8')
8
9const rules = 'Use pickier, never eslint. buddy-bot handles updates. Use conventional commit messages.'
10const 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
16test('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
20test('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
25test('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
34test('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})