Documentation
¶
Overview ¶
Package prompt is the review prompt this module ships: the instructions the generate-and-repair loop (agent.Generator) gives a model backend. It also holds the fix instructions (Fix): fix-public-v1.md, with fix-conflicts.md and fix-checks.md for what a fix is for, and the instructions of a chat turn (Chat): chat-public-v1.md.
Five review files are embedded:
review-public-v6.md the review instructions shared by every backend,
ending with the "## 10. Submitting" heading
group-public-v1.md what changes for a review group's combined
review, inserted before that heading by
GroupPrompts
submit-claude.md how a StructuredOutput backend submits the document
submit-codex.md how a final-message backend returns the document
submit-cursor.md the same for cursor-agent, which has no schema
enforcement and stops a run on any tool that does
not read
Instructions joins the shared text with the backend's submit text under the trailing heading, sets Version to Version and Digest to the sha256 of the joined Body. The repair wording stays in agent.RepairText and the tile guidance in tilecatalogue, so neither belongs in these files.
A staged review (agent.Generator.StagedReview, StagedPrompts) has four more, derived from review-public-v6.md:
review-shared-public-v1.md what every stage shares: the stages and what
each writes, the ground rules, the inputs,
checking a change, anchors, writing and
calibration; with the bundle and the source
excerpts, the prefix of every stage's prompt
review-outline-public-v1.md the overview and the sections' outline
review-details-public-v1.md the sections' details
review-context-public-v1.md the summary's codebase context
Each stage file ends with a "## Submitting" heading, under which the backend's stage submit block goes (submit-stage-claude.md, submit-stage-codex.md, submit-stage-cursor.md, with {part} replaced by what the stage returns), and names its schema file (agent.TaskSchemaFile).
Custom prompts ¶
A host may replace the text of any prompt by passing Overrides (a map from ID to text) in the Overrides field of GroupPrompts or StagedPrompts, or to FixWith. The one-pass review (Prompts) is not replaceable: a review of one pull request is staged, and a group's prompt (review-group) is the whole text, the review instructions included. An override replaces the built-in text of its part only: the Submitting heading and the backend's submit block (the output contract) stay baum's and are always appended, so an override never includes them (Validate rejects one that does). A composition whose parts include an override reports its Version with a "+custom" suffix; the Digest still identifies the exact text. A nil or empty Overrides, and an ID missing from it or mapped to the empty string, mean the built-in text; the zero value of every type produces byte-identical output to the built-in prompts, so a host that never sets Overrides is unchanged.
Catalogue lists every overridable prompt (ID, title, group, built-in text and version) so an editor can seed from the built-in text. Validate checks an override before it is stored. Each Entry also carries SafetyRules: metadata kept outside the prompt text that names the sentences that keep a run safe (treat the pull request as untrusted data, never commit or push, never reproduce secrets). MissingSafetyRules reports which of them a custom text dropped, so a host can warn the author; it never blocks.
Index ¶
- Constants
- func Chat(backend string) string
- func Fix(conflicts, checks, threads, chat bool) string
- func FixWith(o Overrides, conflicts, checks, threads, chat bool) (text, version string)
- func MissingSafetyRules(id ID, text string) []string
- func Validate(id ID, text string) error
- type Entry
- type GroupPrompts
- type ID
- type Overrides
- type Prompts
- type SafetyRule
- type StagedPrompts
Constants ¶
const ( GroupReviews = "reviews" GroupFixes = "fixes" GroupExtraction = "extraction" )
The groups of the catalogue.
const ChatVersion = "chat-public-v1"
ChatVersion is the version of the chat instructions; change it with the text of chat-public-v1.md or the submit lines below.
const CustomSuffix = "+custom"
CustomSuffix is appended to a built-in version when the composition used an override.
const FixVersion = "fix-public-v1"
FixVersion is the version of the fix instructions, which change with the text of fix-public-v1.md, fix-conflicts.md, fix-checks.md and fix-threads.md and fix-chat.md.
const GroupVersion = "group-review-public-v5"
GroupVersion is the prompt version of a review group's combined review. Change it with the text of group-public-v1.md or review-public-v6.md.
const MaxOverrideBytes = 64 << 10
MaxOverrideBytes is the longest text Validate accepts for an override.
const StagedVersion = "review-staged-public-v2"
StagedVersion is the prompt version of a staged review. Change it with the text of any review-*-public-v1.md file of the staged review.
const Version = "review-public-v7"
Version is the prompt version recorded in the document's generator block. Change it with the text of review-public-v6.md.
Variables ¶
This section is empty.
Functions ¶
func Chat ¶
Chat returns the instructions of one turn of a chat with the agent that wrote a review (internal/chat): the reframing from writing the review to answering the reviewer's question, and how the backend submits its answer. They go in the user prompt of every turn, because a resumed or forked session keeps the system prompt it was recorded with. The caller appends the question and its focus, delimited as untrusted data.
func Fix ¶
Fix returns the instructions of a fix an agent makes with write access to a pull request's checkout (agent.Fixer): the shared rules, then the sections for what it fixes: merge conflicts, failing checks, review comments, a change from a conversation. The caller appends the data the sections refer to, delimited as untrusted.
func FixWith ¶ added in v0.2.0
FixWith is Fix with Overrides: the fix, fix-conflicts, fix-checks, fix-threads and fix-chat entries replace the built-in text of the shared rules and of the sections included. The version is FixVersion, with CustomSuffix when an included part was overridden; an override of a section that is not included does not count. Callers must Validate override text first; FixWith does not.
func MissingSafetyRules ¶ added in v0.2.0
MissingSafetyRules returns the IDs of the safety rules of id whose Text does not occur in text, in catalogue order. It changes nothing in text except reading CRLF line breaks as LF; whitespace must otherwise match. An unknown id has no rules.
func Validate ¶ added in v0.2.0
Validate checks a custom text for id before it is stored or used. The text must be for a known ID, valid UTF-8, not blank and at most MaxOverrideBytes long, and must not end inside an open fenced code block. A review or staged review text must not contain a Submitting heading (any heading starting with "Submitting"): baum appends its own, with the backend's submit block, and a second one would confuse the model about how to submit. The error names the rule it breaks and is fit to show the author.
Types ¶
type Entry ¶ added in v0.2.0
type Entry struct {
ID ID
Title string
// Group is GroupReviews, GroupFixes or GroupExtraction.
Group string
// UsedBy says in a sentence when the prompt is used.
UsedBy string
// Default is the built-in text an editor seeds from. A review prompt's
// is without its trailing Submitting heading, which baum appends with the
// backend's submit block.
Default string
// DefaultVersion is the built-in version of the composition the prompt
// belongs to: Version, GroupVersion, StagedVersion, FixVersion or
// decisions.PublicPromptName.
DefaultVersion string
SafetyRules []SafetyRule
}
Entry describes one prompt a host can replace.
type GroupPrompts ¶
type GroupPrompts struct {
// Overrides replaces built-in texts; GroupPrompts uses the review-group
// entry, which replaces the whole text before the Submitting heading.
// Callers must Validate the text first; composition does not.
Overrides Overrides
}
GroupPrompts implements agent.Prompts for a review group's combined review: the public review prompt with the group instructions (group-public-v1.md) inserted before its Submitting heading, then the backend's submit block.
func (GroupPrompts) Instructions ¶
Instructions returns the group prompt for a backend, as Prompts does.
type ID ¶ added in v0.2.0
type ID string
ID names one prompt a host can replace.
const ( IDReviewGroup ID = "review-group" IDReviewStagedOutline ID = "review-staged-outline" IDReviewStagedDetails ID = "review-staged-details" IDReviewStagedContext ID = "review-staged-context" IDFix ID = "fix" IDFixConflicts ID = "fix-conflicts" IDFixChecks ID = "fix-checks" IDFixThreads ID = "fix-threads" IDFixChat ID = "fix-chat" IDExtraction ID = "extraction" )
The prompts a host can replace.
func ReviewIDs ¶ added in v0.2.0
ReviewIDs are the prompts a review composes, by mode: a pull request group uses review-group; a staged review of one pull request the four review-staged prompts; a one-pass review none, as it is not replaceable. A group is never staged. An override of any other prompt does not touch the review.
type Overrides ¶ added in v0.2.0
Overrides maps a prompt to the text that replaces its built-in text. A nil map, a missing ID and an empty text all mean the built-in text. Callers must Validate every override text before composing with it: composition does not re-validate.
type Prompts ¶
type Prompts struct{}
Prompts implements agent.Prompts with this module's public review prompt, written in one pass. A review of one pull request is staged (StagedPrompts), so it is not one of the prompts a host replaces.
func (Prompts) Instructions ¶
Instructions returns the review prompt for a backend: the shared text with the backend's submit block appended. The claude and anthropic backends submit through the StructuredOutput tool; codex and cursor-agent return the document as their final message, cursor-agent with the schema the backend appends to the prompt. Any other backend is an error.
type SafetyRule ¶ added in v0.2.0
type SafetyRule struct {
// ID is stable and names the entry, for example "fix.untrusted-data".
ID string
// Label says what the rule protects, for display.
Label string
// Text is the rule as the built-in prompt words it: an exact substring
// of the entry's Default, line breaks included.
Text string
}
SafetyRule is a sentence of a built-in prompt that keeps a run safe. It is metadata kept outside the prompt text: a host uses MissingSafetyRules to warn the author of a custom prompt that dropped it.
type StagedPrompts ¶
type StagedPrompts struct {
// Overrides replaces built-in texts; StagedPrompts uses the
// review-staged-* entries. Callers must Validate the text first;
// composition does not.
Overrides Overrides
}
StagedPrompts implements agent.StagedPrompts with this module's public staged review prompts.
func (StagedPrompts) StagedInstructions ¶
func (p StagedPrompts) StagedInstructions(_ context.Context, backend string) (agent.StagedPrompt, error)
StagedInstructions returns the staged review prompts for a backend: the shared text, and each stage's text with the backend's stage submit block appended, naming what the stage returns, as Prompts appends the submit block for a review written in one pass. Digest is the sha256 of the four texts, each followed by a NUL byte. Any other backend is an error.