Documentation
¶
Overview ¶
Package formula provides parsing and validation for formula.toml files.
Formulas define structured workflows that can be executed by agents. There are four types of formulas:
- convoy: Parallel execution of legs with synthesis
- workflow: Sequential steps with dependencies
- expansion: Template-based step generation
- aspect: Multi-aspect parallel analysis (like convoy but for analysis)
Index ¶
- func ProvisionFormulas(beadsPath string) (int, error)
- type Aspect
- type Formula
- func (f *Formula) GetAllIDs() []string
- func (f *Formula) GetAspect(id string) *Aspect
- func (f *Formula) GetDependencies(id string) []string
- func (f *Formula) GetLeg(id string) *Leg
- func (f *Formula) GetStep(id string) *Step
- func (f *Formula) GetTemplate(id string) *Template
- func (f *Formula) ReadySteps(completed map[string]bool) []string
- func (f *Formula) TopologicalSort() ([]string, error)
- func (f *Formula) Validate() error
- type FormulaType
- type Input
- type Leg
- type Output
- type Step
- type Synthesis
- type Template
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProvisionFormulas ¶
ProvisionFormulas creates the .beads/formulas/ directory with embedded formulas. This ensures new installations have the standard formula library. If a formula already exists, it is skipped (no overwrite). Returns the number of formulas provisioned.
Types ¶
type Aspect ¶
type Aspect struct {
ID string `toml:"id"`
Title string `toml:"title"`
Focus string `toml:"focus"`
Description string `toml:"description"`
}
Aspect represents a parallel analysis aspect in an aspect formula.
type Formula ¶
type Formula struct {
// Common fields
Name string `toml:"formula"`
Description string `toml:"description"`
Type FormulaType `toml:"type"`
Version int `toml:"version"`
// Convoy-specific
Inputs map[string]Input `toml:"inputs"`
Prompts map[string]string `toml:"prompts"`
Output *Output `toml:"output"`
Legs []Leg `toml:"legs"`
Synthesis *Synthesis `toml:"synthesis"`
// Workflow-specific
Steps []Step `toml:"steps"`
Vars map[string]Var `toml:"vars"`
// Expansion-specific
Template []Template `toml:"template"`
// Aspect-specific (similar to convoy but for analysis)
Aspects []Aspect `toml:"aspects"`
}
Formula represents a parsed formula.toml file.
func (*Formula) GetDependencies ¶
GetDependencies returns the ordered dependencies for a step/template. For convoy formulas, legs are parallel so this returns an empty slice. For workflow and expansion formulas, this returns the Needs field.
func (*Formula) GetTemplate ¶
GetTemplate returns a template by ID, or nil if not found.
func (*Formula) ReadySteps ¶
ReadySteps returns steps that have no unmet dependencies. completed is a set of step IDs that have been completed.
func (*Formula) TopologicalSort ¶
TopologicalSort returns steps in dependency order (dependencies before dependents). Only applicable to workflow and expansion formulas. Returns an error if there are cycles.
type FormulaType ¶
type FormulaType string
FormulaType represents the type of formula.
const ( // TypeConvoy is a convoy formula with parallel legs and synthesis. TypeConvoy FormulaType = "convoy" // TypeWorkflow is a workflow formula with sequential steps. TypeWorkflow FormulaType = "workflow" // TypeExpansion is an expansion formula with template-based steps. TypeExpansion FormulaType = "expansion" // TypeAspect is an aspect-based formula for multi-aspect parallel analysis. TypeAspect FormulaType = "aspect" )
func (FormulaType) IsValid ¶
func (t FormulaType) IsValid() bool
IsValid returns true if the formula type is recognized.
type Input ¶
type Input struct {
Description string `toml:"description"`
Type string `toml:"type"`
Required bool `toml:"required"`
RequiredUnless []string `toml:"required_unless"`
Default string `toml:"default"`
}
Input represents an input parameter for a formula.
type Leg ¶
type Leg struct {
ID string `toml:"id"`
Title string `toml:"title"`
Focus string `toml:"focus"`
Description string `toml:"description"`
}
Leg represents a parallel execution unit in a convoy formula.
type Output ¶
type Output struct {
Directory string `toml:"directory"`
LegPattern string `toml:"leg_pattern"`
Synthesis string `toml:"synthesis"`
}
Output configures where formula outputs are written.
type Step ¶
type Step struct {
ID string `toml:"id"`
Title string `toml:"title"`
Description string `toml:"description"`
Needs []string `toml:"needs"`
}
Step represents a sequential step in a workflow formula.
type Synthesis ¶
type Synthesis struct {
Title string `toml:"title"`
Description string `toml:"description"`
DependsOn []string `toml:"depends_on"`
}
Synthesis represents the synthesis step that combines leg outputs.