Documentation
¶
Overview ¶
Package models defines agent stages, model catalogs, and per-stage model resolution.
Index ¶
- Constants
- Variables
- func Describe(sel Selections) string
- func FromValues(v url.Values) (map[string]string, string)
- func Resolve(c Catalog, s Selections) (map[Stage]string, []string)
- func TierValue(t Tier) string
- func ValidModelID(id string) bool
- type Catalog
- type Model
- type Selections
- type Stage
- type Tier
Constants ¶
const BackendField = FieldPrefix + "backend"
BackendField names the field carrying the backend a selection is for.
const DefaultKey = "default"
DefaultKey is the Selections key holding the ticket-wide model choice.
const FieldPrefix = "model_"
FieldPrefix names the form and query fields a selection is submitted in: FieldPrefix + DefaultKey, and FieldPrefix + <stage>.
Variables ¶
var Stages = []Stage{ StageBrainstorm, StagePlan, StageImplement, StageRevise, StageValidate, StageObserve, StageReview, StagePRDescription, StageGraph, StageTest, StageEpicPlan, StageDiagnose, }
Stages is the closed set of stages, in display order.
Functions ¶
func Describe ¶
func Describe(sel Selections) string
Describe renders sel as "default=opus, plan=sonnet".
func FromValues ¶
FromValues reads a selection out of submitted values, dropping empties, and returns it with the backend named alongside it.
func Resolve ¶
func Resolve(c Catalog, s Selections) (map[Stage]string, []string)
Resolve returns a model id for every stage and the selections it dropped, each as "stage=value".
func ValidModelID ¶
ValidModelID reports whether id is safe to pass as a single argv token. "/" is allowed for provider-qualified ids (opencode's "provider/model" form); it cannot start a flag, escape an argv element, or glob-expand because adapters never pass model ids through a shell.
Types ¶
type Catalog ¶
type Catalog struct {
SupportsSelection bool `json:"supports_selection" yaml:"supports_selection"`
Tiers []Tier `json:"tiers" yaml:"tiers"`
Models []Model `json:"models" yaml:"models"`
StageDefaults map[Stage]Tier `json:"stage_defaults" yaml:"stage_defaults"`
}
Catalog is a backend's selectable models and per-stage default tiers.
func (Catalog) ForTier ¶
ForTier returns the first model at t, else the nearest cheaper, else the nearest larger, else "".
func (Catalog) Has ¶
func (c Catalog) Has(s Selections) bool
Has reports whether every model id in s names a model in c. Tier references always resolve, so they are ignored.
func (Catalog) ValidateSelections ¶
func (c Catalog) ValidateSelections(s Selections) error
ValidateSelections reports the first selection c cannot satisfy.
type Selections ¶
Selections maps a stage name, or DefaultKey, to a model id or a "tier:<label>" reference.
func ValidateSelections ¶
func ValidateSelections(catalogs map[string][]Catalog, backend string, raw map[string]string) (Selections, string, error)
ValidateSelections checks raw against the named backend's shem catalogs, one of which must declare all of it, and returns the selections to store and the backend to bind them to. A tier-only selection binds no backend.
type Stage ¶
type Stage string
Stage is an agent invocation site.
const ( StageBrainstorm Stage = "brainstorm" StagePlan Stage = "plan" StageImplement Stage = "implement" StageRevise Stage = "revise" StageValidate Stage = "validate" StageObserve Stage = "observe" StageReview Stage = "review" StagePRDescription Stage = "pr-description" StageGraph Stage = "graph" // StageTest is the epic tester, whose verdict gates auto-merge. StageTest Stage = "test" // StageEpicPlan is the plan-generation session a shem runs for an epic: // one long-form session that writes the plan JSON. Planning shapes every // ticket downstream, so it defaults to the large tier. StageEpicPlan Stage = "epic-plan" // StageDiagnose classifies a failed run and writes repair feedback. StageDiagnose Stage = "diagnose" )