Skip to content

Commit f98fd29

Browse files
refactor(prompt): make prompt construction template-driven (#625)
## Why Prompt construction in `internal/prompt` had accumulated too much behavior in Go-side string assembly, which made the actual prompt structure hard to reason about, easy to regress during cleanup, and split across multiple sources of truth. This refactor moves the prompt format itself into templates so the rendered prompt shape is defined where it is authored, while preserving existing review behavior and fixing the regressions uncovered during the migration and subsequent `roborev` reviews. ## Summary - make prompt construction template-driven end to end by moving assembled prompt bodies, prompt sections, and agent-specific system prompts onto embedded `.md.gotmpl` templates backed by typed view data - preserve existing prompt behavior while fixing cleanup regressions in dirty and range prompt fitting, including truncated diff fallbacks, optional-context retention, and fallback selection quality - resolve the accumulated `roborev` findings on `gotmpl` so the branch ends with no open review jobs ## Test Plan - [x] go fmt ./... - [x] go vet ./... - [x] go test ./... Co-authored-by: Marius van Niekerk <mariusvniekerk@users.noreply.github.com>
1 parent c27d4dc commit f98fd29

21 files changed

Lines changed: 1661 additions & 642 deletions

internal/agent/claude_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func TestParseModel(t *testing.T) {
115115
t.Run(tt.name, func(t *testing.T) {
116116
assert := assert.New(t)
117117
m, u, err := parseModel(tt.spec)
118-
assert.NoError(err)
118+
require.NoError(t, err)
119119
assert.Equal(tt.wantModel, m)
120120
assert.Equal(tt.wantBaseURL, u)
121121
})
@@ -144,7 +144,7 @@ func TestParseModel(t *testing.T) {
144144
t.Run(tt.name, func(t *testing.T) {
145145
assert := assert.New(t)
146146
_, _, err := parseModel(tt.spec)
147-
assert.Error(err)
147+
require.Error(t, err)
148148
assert.Contains(err.Error(), tt.errSubstr)
149149
})
150150
}

0 commit comments

Comments
 (0)