Documentation
¶
Overview ¶
Package recipe parses and resolves Errata recipe.md configuration files.
A recipe is a human-readable Markdown file that configures a reproducible comparison environment: which models to run, what tools they can use, how the agentic loop is constrained, and (in headless mode) what tasks to run.
Discovery order (first match wins):
- Explicit path passed to Discover
- recipe.md in cwd
- .errata/recipe.md in cwd
- ~/.errata/default.recipe.md
- Built-in compiled-in defaults
Index ¶
Constants ¶
const MaxVersion = 1
MaxVersion is the highest recipe version supported by this binary.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConstraintsConfig ¶
type ConstraintsConfig struct {
MaxSteps int // 0 = not set (unlimited)
Timeout time.Duration // 0 = not set (use runner default)
BashTimeout time.Duration // 0 = not set (use tools default 2m)
}
ConstraintsConfig limits agentic loop execution.
type ContextConfig ¶
type ContextConfig struct {
MaxHistoryTurns int // 0 = not set
Strategy string // "" | "auto_compact" | "manual" | "off"
CompactThreshold float64 // 0 = not set
TaskMode string // "" | "independent" | "sequential"
}
ContextConfig controls conversation history management.
type HookConfig ¶
type HookConfig struct {
Name string // unique name for this hook
Event string // "session_start", "pre_tool_use", "post_tool_use", etc.
Matcher string // tool name or glob; "" = all events of type
Action string // "command" (Phase 1 only)
Command string // shell command to execute
Timeout string // duration string, e.g. "30s"
InjectOutput bool // feed command stdout back as model context
}
HookConfig is one lifecycle event hook (Gap 5).
type MCPServerEntry ¶
type MCPServerEntry struct {
Name string // display name
Command string // full command string including arguments
}
MCPServerEntry is one named MCP server subprocess.
type MetadataConfig ¶
type MetadataConfig struct {
Name string
Description string
Tags []string
Author string
Version string
Extends string
Contribute bool
ProjectRoot string
}
MetadataConfig carries recipe labels and sharing settings.
type ModelParamsConfig ¶
ModelParamsConfig carries API sampling parameters. Pointer fields distinguish "not set" (nil) from "set to zero".
type ModelProfileConfig ¶
type ModelProfileConfig struct {
ContextBudget int // override context budget (0 = not set)
ToolFormat string // "native", "function_calling", "text_in_prompt" ("" = not set)
SystemRole *bool // nil = not set
MidConvoSystem *bool // nil = not set
}
ModelProfileConfig overrides auto-discovered model capabilities.
type OutputRuleConfig ¶
type OutputRuleConfig struct {
MaxLines int // truncate at this many lines (0 = unlimited)
MaxTokens int // truncate at this many tokens (0 = unlimited)
Truncation string // "head", "tail", "head_tail"
TruncationMessage string // template with {line_count}, {token_count}
}
OutputRuleConfig is a deterministic output processing rule (Gap 7).
type Recipe ¶
type Recipe struct {
Version int // recipe schema version (required; currently only 1)
Name string
Models []string // nil = not set
SystemPrompt string // "" = not set
Tools *ToolsConfig // nil = all tools enabled
MCPServers []MCPServerEntry
ModelParams ModelParamsConfig
Constraints ConstraintsConfig
Context ContextConfig
SubAgent SubAgentConfig
Sandbox SandboxConfig
Tasks []string
SuccessCriteria []string
Metadata MetadataConfig
// Uniform per-tool description overrides (applied to all models).
ToolDescriptions map[string]string // tool_name → description
// Sub-agent mode prompts (applied to all models).
SubAgentModes map[string]string // mode_name → prompt
// Gap 4: conditional mid-conversation injections
SystemReminders []SystemReminderConfig
// Gap 5: lifecycle event hooks
Hooks []HookConfig
// Context summarization prompt (applied to all models).
SummarizationPrompt string
// Deterministic output processing rules (applied to all models).
OutputProcessing map[string]OutputRuleConfig // tool → rule
// Model profiles for capability overrides
ModelProfiles map[string]ModelProfileConfig // model_id → profile
// SectionsPresent tracks which ## sections were declared in the parsed recipe.
// nil for programmatic recipes; populated by parseV1(). Used by ApplyRecipe
// to decide between atomic (section-replaces-defaults) and legacy (field-by-field)
// merge behavior.
SectionsPresent map[string]bool
}
Recipe holds all settings parsed from a recipe.md file. Nil/zero values mean "not set"; callers check zero values before applying recipe fields to runtime configuration.
The Version field is the recipe schema version (integer). Every recipe must declare its version explicitly; recipes without a version are rejected. The Recipe type only grows: new fields are added with zero-value defaults so that older-version parsers can migrate forward without breaking.
func Default ¶
func Default() *Recipe
Default returns the built-in default Recipe (embedded default.recipe.md). Always returns a non-nil Recipe.
func Discover ¶
Discover parses the recipe at explicitPath, or returns the built-in embedded default if explicitPath is empty.
func ParseContent ¶
ParseContent parses raw recipe markdown bytes into a Recipe. This is the programmatic equivalent of Parse but accepts content directly instead of reading from a file path.
func (*Recipe) BuildRunner ¶
BuildRunner creates a version-specific Runner for this recipe. Returns an error if the recipe version is unsupported.
func (*Recipe) HasSection ¶
HasSection reports whether the named section (lowercase) was declared in the parsed recipe file. Returns false when SectionsPresent is nil, which is the case for programmatically constructed recipes.
func (*Recipe) MarshalMarkdown ¶
MarshalMarkdown serializes the recipe back to the Markdown format used by recipe.md files. Only non-zero/non-default fields are included.
type Runner ¶
type Runner interface {
// Version returns the recipe format version this runner implements.
Version() int
// Recipe returns the underlying recipe configuration.
Recipe() *Recipe
}
Runner encapsulates version-specific recipe execution behavior. Each recipe version maps to its own Runner implementation, ensuring that a recipe's runtime behavior is pinned to the version it was written for.
func NewV1Runner ¶
NewV1Runner creates a Runner for a version 1 recipe.
type SandboxConfig ¶
type SandboxConfig struct {
Filesystem string // "" | "unrestricted" | "project_only" | "read_only"
Network string // "" | "full" | "none"
AllowLocalFetch bool // allow web_fetch to target localhost URLs
}
SandboxConfig restricts the execution environment.
type SubAgentConfig ¶
type SubAgentConfig struct {
Model string // "" = not set (inherit parent)
MaxDepth int // -1 = not set; 0 = disable; ≥1 = limit
Tools string // "inherit" or comma-separated tool names
}
SubAgentConfig configures spawn_agent sub-agent behaviour.
type SystemReminderConfig ¶
type SystemReminderConfig struct {
Name string // unique name for this reminder
Trigger string // trigger expression, e.g. "context_usage > 0.75"
Content string // prompt text to inject when trigger fires
}
SystemReminderConfig is one conditional mid-conversation injection (Gap 4).
type ToolsConfig ¶
type ToolsConfig struct {
// Allowlist is the explicit set of tool names available to models.
// nil means all tools; non-nil means only these tools.
Allowlist []string
// BashPrefixes, if non-nil, restricts bash execution to commands whose
// trimmed text starts with one of the listed prefix patterns.
// nil (with bash in Allowlist) means all bash commands are allowed.
BashPrefixes []string
// Guidance maps tool names to per-tool guidance text from "- name: guidance" format.
// nil means no per-tool guidance overrides (use code defaults).
Guidance map[string]string
}
ToolsConfig describes which tools are available in a recipe. When nil (section absent), all tools are enabled.