refactor(prompts): the last three instructions written in Go are files (#2051)

AGENTS.md sends every instruction to a file in internal/prompts, and the
workspace scoping rule, the PR-review adversary mission and the model probe
were the three that still read as Go string literals. The text is unchanged:
the templates render the same bytes the concatenations built.
This commit is contained in:
sam committed 2026-11-21 03:48:42 +11:00
1 parent e70c27faf9
commit ee66e4f0f3
9 files changed
+37 -19

No files matched your search

-8
View File
@@ -30,14 +30,6 @@ func ClipToolCallDetail(s string) string {
return s[:cut] + "…"
}
func ProjectScopedRules(workspace, extra string) string {
rule := "Confine discovery to " + workspace + ". Do not inspect home directories, dependency/module caches, or unrelated projects unless the mission explicitly requests that external path."
if strings.TrimSpace(extra) == "" {
return rule
}
return rule + "\n" + extra
}
func ProtectionMatcher(p agentrun.Protection, readOnly bool) func(string) bool {
if readOnly || len(p.Suffixes)+len(p.Globs) == 0 {
return nil
+2 -1
View File
@@ -17,6 +17,7 @@ import (
"github.com/samcharles93/archie-core/internal/agentexec"
"github.com/samcharles93/archie-core/internal/domain/agentrun"
"github.com/samcharles93/archie-core/internal/prompts"
"github.com/samcharles93/archie-core/internal/taskstate"
"github.com/samcharles93/archie-core/internal/tools"
)
@@ -91,7 +92,7 @@ func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Req
MaxParallelToolCalls: MaxParallelToolCalls,
Mission: missionWithHistory(req),
ExtraRules: agentexec.ProjectScopedRules(workspace, req.ExtraRules),
ExtraRules: prompts.ProjectScopedRules(workspace, req.ExtraRules),
Notes: notes,
Gate: toAgentGate(req.Gate),
Preflight: toAgentCommands(req.Preflight),
@@ -11,6 +11,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/agentrun"
"github.com/samcharles93/archie-core/internal/domain/workflow/prreview"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/prompts"
)
func stagePRVerification() Stage {
@@ -355,15 +356,7 @@ func runAdversary(ctx context.Context, tc *TaskContext, findings []prreview.Find
return findings, nil
}
mission := fmt.Sprintf(
"You are the adversary reviewing this pull request's findings. For each finding "+
"below, confirm it (you agree it is a real defect) or challenge it (you believe "+
"it is wrong or not actually a problem). Read the snapshot yourself to check. "+
"%s Also look for any defect every reviewer missed and report it as a new "+
"finding.\n\n%s\n"+
"Call adversary_verdicts exactly once with one verdict per finding index. If you "+
"found anything new, call report_findings once too (skip it if you found "+
"nothing new). Then call finish with status \"passed\".",
mission := prompts.PRReviewAdversary(
adversarySkepticism(tc.prReview.aiGenerated), findingsListing(findings),
)
res, err := runPRReviewAgentRecorded(ctx, tc, tc.prReview.snapshotDir, "adversary", mission, 25, []agentrun.CaptureTool{
+1
View File
@@ -0,0 +1 @@
Reply with the single word OK.
+7
View File
@@ -18,6 +18,9 @@ var followThrough string
//go:embed record_cause.md
var recordCause string
//go:embed model-probe.md
var modelProbe string
// FollowThrough is added to an agent's prompt when it described an action it
// didn't call.
func FollowThrough() string { return followThrough }
@@ -30,6 +33,10 @@ func Agent() string { return agent }
// cause in Archie's memory.
func RecordCause() string { return recordCause }
// ModelProbe is the one question a saved model is tested with, so the operator
// learns the endpoint, model and key work before relying on them.
func ModelProbe() string { return modelProbe }
//go:embed chat_system.tmpl
var chatSystem string
@@ -0,0 +1,4 @@
You are the adversary reviewing this pull request's findings. For each finding below, confirm it (you agree it is a real defect) or challenge it (you believe it is wrong or not actually a problem). Read the snapshot yourself to check. {{.Skepticism}} Also look for any defect every reviewer missed and report it as a new finding.
{{.Findings}}
Call adversary_verdicts exactly once with one verdict per finding index. If you found anything new, call report_findings once too (skip it if you found nothing new). Then call finish with status "passed".
@@ -0,0 +1,4 @@
Confine discovery to {{.Workspace}}. Do not inspect home directories, dependency/module caches, or unrelated projects unless the mission explicitly requests that external path.
{{- if .Extra}}
{{.Extra}}
{{- end}}
+15
View File
@@ -133,6 +133,21 @@ func PRReviewLens(lens Lens, title, body, diff, instructions string) string {
}{lens.Name, lens.Angle, title, body, diff, instructions})
}
// ProjectScopedRules confines a task agent's discovery to its workspace, with
// any extra rules the task adds on their own line.
func ProjectScopedRules(workspace, extra string) string {
if strings.TrimSpace(extra) == "" {
extra = ""
}
return render("project-scoped-rules.tmpl", struct{ Workspace, Extra string }{workspace, extra})
}
// PRReviewAdversary has the adversary confirm or challenge each finding, with
// the listing it references by index.
func PRReviewAdversary(skepticism, findings string) string {
return render("pr-review-adversary.tmpl", struct{ Skepticism, Findings string }{skepticism, findings})
}
// PRReviewReviewer asks a reviewer to report findings for one dimension.
func PRReviewReviewer(dimension, targetFiles, instructions string) string {
return render("pr-review-reviewer.tmpl", struct{ Dimension, TargetFiles, Instructions string }{dimension, targetFiles, instructions})
+2 -1
View File
@@ -24,6 +24,7 @@ import (
"github.com/samcharles93/ai-sdk/runtime"
"github.com/samcharles93/archie-core/internal/platform/httpapi"
"github.com/samcharles93/archie-core/internal/platform/prompts"
"github.com/samcharles93/archie-core/modules/governance/internal/store"
)
@@ -631,7 +632,7 @@ func (m *Module) testAgentModel(ctx context.Context, in *struct{ Body Model }) (
defer cancel()
resp, err := provider.Chat(ctx, chat.Request{
Model: model.Model,
Messages: []chat.Message{{Role: chat.RoleUser, Content: "Reply with the single word OK."}},
Messages: []chat.Message{{Role: chat.RoleUser, Content: prompts.ModelProbe()}},
MaxTokens: 32,
})
if err != nil {