Part of #1367 (Phase 2 — AI Review Parity).
Goal
The configuration surface that makes AI review adoptable in real teams — CodeRabbit's most-used config features (path instructions, config reference):
- Path filters: glob include/exclude for what gets reviewed (
!dist/**,!**/*.lock) — defaults should exclude lockfiles, generated dirs (reusesrc/utils/package-paths.tsgenerated-dir knowledge), and vendored code - Path instructions: glob → natural-language guidance applied when reviewing matching files (e.g.
src/security/**→ "flag any new network calls"), with a sane total-size cap - Code-guidelines ingestion: auto-detect and feed the repo's existing agent/style files into review context:
CLAUDE.md,.cursorrules,AGENTS.md,.github/copilot-instructions.md,CONTRIBUTING.md(CodeRabbit auto-detects exactly these) - Tone/instructions: global
instructionsstring (theirtone_instructions) + per-repo review language - Config generation command:
buddy-bot ai init— inspects the repo and emits a commented starteraiconfig block (CodeRabbit'sgenerate configuration)
Design
Extend the ai.review config (from #1375):
ai.review?: {
// ...I08 fields
pathFilters?: string[] // gitignore-style, ! = exclude
pathInstructions?: { path: string, instructions: string }[]
guidelineFiles?: string[] | false // override auto-detect; false disables
instructions?: string // global tone/guidance, ~250 char soft cap
language?: string // review output language (BCP 47)
}- Matching via Bun
Glob(already used insrc/buddy.ts:1381for groups) — one shared matcher util insrc/utils/globs.tsto unify group patterns,ignorePaths, and review filters - Guideline files are trusted repo content (they're commit-reviewed) — unlike PR bodies they MAY be inlined into the system prompt, but size-capped (~20K chars total, truncate with notice) and only from the base branch (not the PR head — prevents a PR from injecting instructions into its own review; document this explicitly)
- Path instructions merged per-file at review time; conflicts resolved most-specific-glob-wins
- Validation in
src/config-validation.ts: glob syntax, instruction lengths, duplicate patterns
Security note (important)
Reading guideline files from the PR head would let any contributor rewrite CLAUDE.md in their PR to manipulate its own review. Always read guidelines at the base branch ref. Add a test proving a head-branch modification of CLAUDE.md does not alter review instructions.
Tasks
- Config schema + validation + defaults (sensible default excludes)
src/utils/globs.tsshared matcher; refactor existing group/ignorePath call sites to use it- Guideline auto-detection + base-ref loading via provider contents API (
src/git/github-provider.ts) - Prompt assembly in
src/review/engine.ts: global instructions → path instructions (matched files) → guidelines, with size budget and truncation order buddy-bot ai initgenerator command- Tests: filter matrix, most-specific-wins, base-ref security test, size-budget truncation
docs/ai/review-config.md
Acceptance criteria
- Excluded paths never appear in review comments; matched path instructions demonstrably alter findings in fixture tests
- Repo
CLAUDE.mdconventions are reflected in review output; head-branch tampering is inert buddy-bot ai initproduces a valid, commented config block
Dependencies
- Requires #1375 (review engine)