Commit 60a4c77
refactor(prompt): consolidate template context and add golden snapshot tests (#630)
## Summary
- Consolidates the template-facing prompt data model under a single
`TemplateContext` root; unifies prompt rendering, fitting, and range
fallback selection through it.
- Restores three regressions from the earlier template refactor:
per-commit `InRangeReviews` section in range prompts, the tool-attempts
/ user-comments split in address prompts, and the codex "do not read
files outside the repo checkout" guardrail.
- Adds a golden-file snapshot test suite under
`internal/prompt/testdata/golden/` covering 18 scenarios across agents
(default, codex, claude-code, gemini), review types (review, range,
dirty, address, security, design), context injection (previous reviews,
guidelines, additional context, severity filter), and diff-truncation
fallbacks. Regenerate with `go test -update-golden ./internal/prompt/`.
- Fixes template whitespace leaks (stray `\n` in empty sections, extra
blank lines between range entries) surfaced by byte-diffing against the
pre-refactor output.
- Forces LF line endings for `*.gotmpl` templates via `.gitattributes`
so the embedded FS produces identical output on Windows.
---------
Co-authored-by: Wes McKinney <wesmckinn+git@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cf6ee49 commit 60a4c77
43 files changed
Lines changed: 3406 additions & 536 deletions
File tree
- internal/prompt
- templates
- testdata/golden
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments