feat(formula): add default formula configuration at rig level (#297)
Allow `gt formula run` to be called without a formula name by configuring a default in the rig's settings/config.json under workflow.default_formula. Co-authored-by: Brett VanderVeen <brett.vanderveen@gfs.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1227,6 +1227,21 @@ func ExpectedPaneCommands(rc *RuntimeConfig) []string {
|
||||
return []string{filepath.Base(rc.Command)}
|
||||
}
|
||||
|
||||
// GetDefaultFormula returns the default formula for a rig from settings/config.json.
|
||||
// Returns empty string if no default is configured.
|
||||
// rigPath is the path to the rig directory (e.g., ~/gt/gastown).
|
||||
func GetDefaultFormula(rigPath string) string {
|
||||
settingsPath := RigSettingsPath(rigPath)
|
||||
settings, err := LoadRigSettings(settingsPath)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if settings.Workflow == nil {
|
||||
return ""
|
||||
}
|
||||
return settings.Workflow.DefaultFormula
|
||||
}
|
||||
|
||||
// GetRigPrefix returns the beads prefix for a rig from rigs.json.
|
||||
// Falls back to "gt" if the rig isn't found or has no prefix configured.
|
||||
// townRoot is the path to the town directory (e.g., ~/gt).
|
||||
|
||||
@@ -180,6 +180,13 @@ type RigConfig struct {
|
||||
Beads *BeadsConfig `json:"beads,omitempty"`
|
||||
}
|
||||
|
||||
// WorkflowConfig represents workflow settings for a rig.
|
||||
type WorkflowConfig struct {
|
||||
// DefaultFormula is the formula to use when `gt formula run` is called without arguments.
|
||||
// If empty, no default is set and a formula name must be provided.
|
||||
DefaultFormula string `json:"default_formula,omitempty"`
|
||||
}
|
||||
|
||||
// RigSettings represents per-rig behavioral configuration (settings/config.json).
|
||||
type RigSettings struct {
|
||||
Type string `json:"type"` // "rig-settings"
|
||||
@@ -188,6 +195,7 @@ type RigSettings struct {
|
||||
Theme *ThemeConfig `json:"theme,omitempty"` // tmux theme settings
|
||||
Namepool *NamepoolConfig `json:"namepool,omitempty"` // polecat name pool settings
|
||||
Crew *CrewConfig `json:"crew,omitempty"` // crew startup settings
|
||||
Workflow *WorkflowConfig `json:"workflow,omitempty"` // workflow settings
|
||||
Runtime *RuntimeConfig `json:"runtime,omitempty"` // LLM runtime settings (deprecated: use Agent)
|
||||
|
||||
// Agent selects which agent preset to use for this rig.
|
||||
|
||||
Reference in New Issue
Block a user