Documentation
¶
Overview ¶
Package foreman holds the foreman's fixed, versioned text (design §4): the instructions its session runs under (§4.1) and the wake template a headless turn's prompt is composed from (§4.2 item 2). The engine composes a prompt only from files like these plus verbatim data (§1.4), so each carries a version: a change to either is a version bump, never a silent edit.
Index ¶
- Constants
- func ComposePrompt(text string, events []string, messages []UserMessage) string
- func ComposePromptDigest(text, digest string, events []string, messages []UserMessage) string
- func ComposeTurnPrompt(events []string) string
- func ComposeTurnPromptDigest(digest string, events []string, userMessages []UserMessage) string
- func ComposeTurnPromptWith(events []string, userMessages []UserMessage) string
- func CoordinatorInstructions() string
- func DigestBlock(digest string) string
- func EventBlocks(events []string) string
- func EventsAnswer(events []string, messages []UserMessage) string
- func Instructions() string
- func UserMessageBlocks(messages []UserMessage) string
- func WithCheckout(prompt string, checkout Checkout) string
- type Checkout
- type UserMessage
Constants ¶
const CoordinatorInstructionsVersion = 1
CoordinatorInstructionsVersion is the coordinator instructions' version (§4.6): the text `brigada init` installs in a parent folder for a session over several projects. Editing coordinator.md means bumping this.
const InstructionsVersion = 26
InstructionsVersion is the foreman instructions' version (§4.1): the versioned file shipped with brigada that every foreman prompt prepends. Editing contract.md means bumping this.
const TurnTemplateVersion = 5
TurnTemplateVersion is the wake template's version (§4.2 item 2, §1.4): like the worker template (§5.3), a change to the template below is a version bump, never a silent edit.
Variables ¶
This section is empty.
Functions ¶
func ComposePrompt ¶
func ComposePrompt(text string, events []string, messages []UserMessage) string
ComposePrompt composes the contract, optional foreman role text, then the events and user's messages. It resolves no files or settings.
func ComposePromptDigest ¶
func ComposePromptDigest(text, digest string, events []string, messages []UserMessage) string
ComposePromptDigest is ComposePrompt for a rotated session's first turn (§4.2): the digest, framed, before the events, as a headless turn's wake prompt carries it.
func ComposeTurnPrompt ¶
ComposeTurnPrompt builds a headless foreman turn's wake prompt (§4.2 item 2): the fixed, versioned template plus the pending events verbatim, each wrapped in its own data delimiters — the same discipline as the worker prompt (§5.3), so a worker's output can never pose as instructions to the foreman (§1.4).
func ComposeTurnPromptDigest ¶
func ComposeTurnPromptDigest(digest string, events []string, userMessages []UserMessage) string
ComposeTurnPromptDigest is ComposeTurnPromptWith for the first turn of a fresh session (§4.2): the digest, framed, before the events. An empty digest composes exactly what ComposeTurnPromptWith does.
func ComposeTurnPromptWith ¶
func ComposeTurnPromptWith(events []string, userMessages []UserMessage) string
ComposeTurnPromptWith is ComposeTurnPrompt with the user's waiting messages (§4.2 item 3) in their one section after the events. A wake with messages and no events is no idle wake: the messages are what it is for.
func CoordinatorInstructions ¶
func CoordinatorInstructions() string
CoordinatorInstructions returns the coordinator instructions: what a coordinator session is, which tools it has, and that approving a plan waits for the user's explicit yes.
func DigestBlock ¶
DigestBlock renders an engine-written digest in its framing and data delimiters (§4.2, §1.4); empty for an empty digest.
func EventBlocks ¶
EventBlocks renders events the way every wake prompt carries them (§4.2): each in its own data delimiters, verbatim, one blank line between blocks. The `events` tool's answers and the headless turns' prompts read alike — the same discipline as the worker prompt (§5.3), so what reaches the foreman as data can never pose as instructions about how to run (§1.4).
func EventsAnswer ¶
func EventsAnswer(events []string, messages []UserMessage) string
EventsAnswer renders an `events` tool answer (§4.2, §4.2 item 3): the framing line and the event blocks when there are events, then the user's messages in their own framed section — so no section in the answer arrives without its framing (the §4.2 item 3 invariant).
func Instructions ¶
func Instructions() string
Instructions returns the foreman instructions (§4.1): what the foreman is, its data discipline, and the engine facts it acts on. Editable planning and conversation guidance is supplied to ComposePrompt.
func UserMessageBlocks ¶
func UserMessageBlocks(messages []UserMessage) string
UserMessageBlocks renders the user's messages (§4.2 item 3): the framing, then exactly one <user-message> section holding them as an ordered list, each naming the token label it came from, the words verbatim with the delimiter tags defused. Empty when there are none. The `events` tool's answers and the wake prompts carry it alike, after the events.
func WithCheckout ¶
WithCheckout adds runtime checkout metadata to either a headless wake or attach opening prompt. Both are composed before the client/runner fetches; adding the snapshot here keeps the path and commit accurate on resumes too.
Types ¶
type Checkout ¶
type Checkout struct {
Path string
Branch string // the ref checked out
Commit string
// DefaultBranch is the project's default branch, which may lag what
// landed on the land target. Empty when the caller did not say.
DefaultBranch string
// LandTarget is the project's land target as configured, empty when
// unset. A target other than Branch means the checkout fell back to
// the default branch because the remote holds no such ref yet.
LandTarget string
}
Checkout identifies the runner-prepared reading copy at this turn's fetch.
type UserMessage ¶
UserMessage is one user message as a session reads it (§4.2 item 3): the label of the client token that sent it, and the words.