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.
160 lines
6.5 KiB
Go
160 lines
6.5 KiB
Go
// Package prompts holds every instruction archie gives a model, one file per
|
|
// prompt beside this one, so a prompt is found by its file name rather than by
|
|
// searching the code. A .md file is sent as written; a .tmpl file is a
|
|
// text/template filled from the caller's values.
|
|
//
|
|
// Some prompts are defaults the operator edits in the dashboard: the SOUL
|
|
// (soul.md), curator instructions and workflow missions. The shipped
|
|
// workflows' missions are part of their definitions, in
|
|
// internal/domain/workflow/shipped.
|
|
package prompts
|
|
|
|
import (
|
|
"embed"
|
|
"strings"
|
|
"text/template"
|
|
)
|
|
|
|
//go:embed *.md *.tmpl
|
|
var files embed.FS
|
|
|
|
var templates = template.Must(
|
|
template.New("").
|
|
Funcs(template.FuncMap{
|
|
"xml": EscapeXML,
|
|
"untrustedForgeData": UntrustedForgeData,
|
|
}).
|
|
ParseFS(files, "*.tmpl"),
|
|
)
|
|
|
|
// EscapeXML replaces the bytes that would be read as markup inside a
|
|
// trust="data" block. The chat template applies it, so a caller bounding a
|
|
// block's rendered size measures the same expansion.
|
|
var EscapeXML = strings.NewReplacer("&", "&", "<", "<", ">", ">").Replace
|
|
|
|
// read returns a static prompt without its file's final newline.
|
|
func read(name string) string {
|
|
b, err := files.ReadFile(name)
|
|
if err != nil {
|
|
panic("prompts: " + err.Error())
|
|
}
|
|
return strings.TrimSuffix(string(b), "\n")
|
|
}
|
|
|
|
// render fills a template. The templates are fixed at build time and filled
|
|
// from typed values, so a failure is a defect in this package, not input.
|
|
func render(name string, data any) string {
|
|
var b strings.Builder
|
|
if err := templates.ExecuteTemplate(&b, name, data); err != nil {
|
|
panic("prompts: render " + name + ": " + err.Error())
|
|
}
|
|
return strings.TrimSuffix(b.String(), "\n")
|
|
}
|
|
|
|
// ChatSystem is the chat agent's system prompt, filled from the gateway's
|
|
// prompt data.
|
|
func ChatSystem(data any) string { return strings.TrimSpace(render("chat-system.tmpl", data)) }
|
|
|
|
// ProductGuide is the product guide the chat agent reads from the page index.
|
|
func ProductGuide() string { return read("product-guide.md") }
|
|
|
|
// Soul is the shipped SOUL document: the agent's identity and reporting style.
|
|
func Soul() string { return read("soul.md") + "\n" }
|
|
|
|
// SessionTitle instructs the model to title a conversation.
|
|
func SessionTitle() string { return read("session-title.md") }
|
|
|
|
// SessionTitleExchange is the exchange a title is written from: the
|
|
// operator's message and Archie's reply.
|
|
func SessionTitleExchange(message, reply string) string {
|
|
return render("session-title-exchange.tmpl", struct{ Message, Reply string }{message, reply})
|
|
}
|
|
|
|
// SessionMemory instructs the session-memory curator to extract durable facts
|
|
// that known, the facts already remembered, does not hold.
|
|
func SessionMemory(known []string) string {
|
|
return render("session-memory.tmpl", struct{ Known []string }{known})
|
|
}
|
|
|
|
// CuratorPass is the user turn of a curator pass that names no reason.
|
|
func CuratorPass() string { return read("curator-pass.md") }
|
|
|
|
// ResumeRun introduces an earlier run's conversation to a continued stage.
|
|
func ResumeRun() string { return read("resume-run.md") }
|
|
|
|
// UntrustedForgeData instructs the model to treat forge-authored text as
|
|
// data rather than instructions.
|
|
func UntrustedForgeData() string { return read("untrusted-forge-data.md") }
|
|
|
|
// SkillGuidelines puts a project's skill guidelines ahead of a mission.
|
|
func SkillGuidelines(guidelines, mission string) string {
|
|
return render("skill-guidelines.tmpl", struct{ Guidelines, Mission string }{guidelines, mission})
|
|
}
|
|
|
|
// BaselineFix asks an agent to repair a gate that fails on the base commit.
|
|
func BaselineFix(gate, repository, output string) string {
|
|
return render("baseline-fix.tmpl", struct{ Gate, Repository, Output string }{gate, repository, output})
|
|
}
|
|
|
|
// PRBenchmarkJudge is the system prompt that scores a reviewer against known
|
|
// defects.
|
|
func PRBenchmarkJudge() string { return read("pr-benchmark-judge.md") }
|
|
|
|
// PRReviewAIScore asks whether a pull request's description reads as written
|
|
// by an AI assistant.
|
|
func PRReviewAIScore(title, body, commits string) string {
|
|
return render("pr-review-ai-score.tmpl", struct{ Title, Body, Commits string }{title, body, commits})
|
|
}
|
|
|
|
// PRReviewAnatomy asks for a short narrative of a pull request.
|
|
func PRReviewAnatomy(title, body, diff string) string {
|
|
return render("pr-review-anatomy.tmpl", struct{ Title, Body, Diff string }{title, body, diff})
|
|
}
|
|
|
|
// Lens is one angle the review takes over a pull request.
|
|
type Lens struct {
|
|
Name, Angle string
|
|
}
|
|
|
|
// PRReviewLenses are the angles that propose review dimensions.
|
|
func PRReviewLenses() []Lens {
|
|
return []Lens{
|
|
{Name: "behaviour", Angle: "where the old and new code diverge for any input: API contracts, concurrency and state, security, error handling, data flow"},
|
|
{Name: "mechanics", Angle: "whether the code runs at the language and framework level: types, signatures and every caller, decorators and middleware, framework contracts, imports"},
|
|
{Name: "fit", Angle: "patterns, complexity, abstraction, test adequacy, documentation that no longer matches, dependencies, migration completeness"},
|
|
}
|
|
}
|
|
|
|
// PRReviewLens asks one lens to propose review dimensions. instructions are
|
|
// the operator's re-review instructions, empty for none.
|
|
func PRReviewLens(lens Lens, title, body, diff, instructions string) string {
|
|
return render("pr-review-lens.tmpl", struct {
|
|
Name, Angle, Title, Body, Diff, Instructions 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})
|
|
}
|
|
|
|
// PRReviewPolish asks for a review comment's wording to be tightened.
|
|
func PRReviewPolish(title, body string) string {
|
|
return render("pr-review-polish.tmpl", struct{ Title, Body string }{title, body})
|
|
}
|