Documentation
¶
Overview ¶
Package wizard implements the interactive setup wizard for Agent Layer.
TOML Parsing Strategy ¶
This package uses custom line-based TOML parsing instead of the go-toml library's tree manipulation for config updates. This is intentional for several reasons:
Comment preservation: go-toml's ToTomlString() loses inline comments and rearranges leading comments. Users expect their config formatting to be preserved.
Deterministic output: The wizard rewrites config.toml in preferred section order (Decision wizard-order-policy). Custom parsing lets us control exact output ordering.
Key positioning: When clearing optional keys (like model=""), we convert them to commented lines rather than deleting them, preserving the template structure.
The go-toml library is still used for syntax validation before processing.
Index ¶
- Constants
- func ApprovalModeFieldOptions() []config.FieldOption
- func ClaudeModels() []string
- func ClaudeReasoningEfforts() []string
- func CleanupBackups(root string) ([]string, error)
- func CodexModels() []string
- func CodexReasoningEfforts() []string
- func CopilotCLIModels() []string
- func GeminiModels() []string
- func IsTomlStateInMultiline(state tomlStringState) bool
- func PatchConfig(content string, choices *Choices) (string, error)
- func Run(root string, ui UI, runSync syncer, pinVersion string) error
- func RunProfile(root string, runSync syncer, pinVersion string, profilePath string, apply bool, ...) error
- func RunWithWriter(root string, ui UI, runSync syncer, pinVersion string, out io.Writer) error
- func ScanTomlLineForComment(line string, state tomlStringState) (commentPos int, nextState tomlStringState)
- func SupportedAgents() []string
- type Choices
- type DefaultMCPServer
- type HuhUI
- func (ui *HuhUI) Confirm(title string, value *bool) error
- func (ui *HuhUI) Input(title string, value *string) error
- func (ui *HuhUI) MultiSelect(title string, options []string, selected *[]string) error
- func (ui *HuhUI) Note(title string, body string) error
- func (ui *HuhUI) SecretInput(title string, value *string) error
- func (ui *HuhUI) Select(title string, options []string, current *string) error
- type UI
- type WarningDefaults
Constants ¶
const ( AgentGemini = "gemini" AgentClaude = "claude" AgentClaudeVSCode = "claude_vscode" AgentCodex = "codex" AgentVSCode = "vscode" AgentAntigravity = "antigravity" AgentCopilotCLI = "copilot_cli" )
AgentID constants matching config keys
Variables ¶
This section is empty.
Functions ¶
func ApprovalModeFieldOptions ¶ added in v0.8.2
func ApprovalModeFieldOptions() []config.FieldOption
ApprovalModeFieldOptions returns approval mode options from the config field catalog. Panics if the approvals.mode field is not in the catalog (programming error).
func ClaudeModels ¶
func ClaudeModels() []string
ClaudeModels returns supported Claude model values from the config field catalog.
func ClaudeReasoningEfforts ¶ added in v0.8.7
func ClaudeReasoningEfforts() []string
ClaudeReasoningEfforts returns supported Claude reasoning effort values.
func CleanupBackups ¶ added in v0.8.0
CleanupBackups removes wizard backup files and returns removed paths relative to repo root.
func CodexModels ¶
func CodexModels() []string
CodexModels returns supported Codex model values from the config field catalog.
func CodexReasoningEfforts ¶
func CodexReasoningEfforts() []string
CodexReasoningEfforts returns supported reasoning effort values from the config field catalog.
func CopilotCLIModels ¶ added in v0.9.2
func CopilotCLIModels() []string
CopilotCLIModels returns supported Copilot CLI model values from the config field catalog.
func GeminiModels ¶
func GeminiModels() []string
GeminiModels returns supported Gemini model values from the config field catalog.
func IsTomlStateInMultiline ¶
func IsTomlStateInMultiline(state tomlStringState) bool
IsTomlStateInMultiline returns true if the state indicates we're inside a multiline string.
func PatchConfig ¶
PatchConfig applies wizard choices to TOML config content. content is the current config; choices holds selections; returns updated content or error.
func Run ¶
Run starts the interactive wizard. pinVersion is written to .agent-layer/al.version when install is needed.
func RunProfile ¶ added in v0.8.0
func RunProfile(root string, runSync syncer, pinVersion string, profilePath string, apply bool, out io.Writer) error
RunProfile applies a non-interactive wizard profile from a TOML config file. root is the repo root; runSync executes sync after writes; pinVersion is used when install is required. profilePath points to a TOML file; apply controls whether writes are performed or preview-only output is shown.
func RunWithWriter ¶ added in v0.8.0
RunWithWriter starts the interactive wizard and writes user-facing output to out. pinVersion is written to .agent-layer/al.version when install is needed.
func ScanTomlLineForComment ¶
func ScanTomlLineForComment(line string, state tomlStringState) (commentPos int, nextState tomlStringState)
ScanTomlLineForComment scans a TOML line and returns the position of any inline comment (or -1 if none) along with the next parser state for multiline string tracking. state is the current parser state from the previous line; line is the TOML line to scan.
func SupportedAgents ¶
func SupportedAgents() []string
SupportedAgents returns the agent IDs the wizard can configure. Order matches the config field catalog registration order.
Types ¶
type Choices ¶
type Choices struct {
// Approvals
ApprovalMode string
ApprovalModeTouched bool
// Agents
EnabledAgents map[string]bool
EnabledAgentsTouched bool
// Models
GeminiModel string
GeminiModelTouched bool
ClaudeModel string
ClaudeModelTouched bool
ClaudeReasoning string
ClaudeReasoningTouched bool
ClaudeLocalConfigDir bool
ClaudeLocalConfigDirTouched bool
CodexModel string
CodexModelTouched bool
CodexReasoning string
CodexReasoningTouched bool
CopilotCLIModel string
CopilotCLIModelTouched bool
// MCP
EnabledMCPServers map[string]bool
EnabledMCPServersTouched bool
DisabledMCPServers map[string]bool
MissingDefaultMCPServers []string
RestoreMissingMCPServers bool
DefaultMCPServers []DefaultMCPServer
// Secrets (Env vars)
Secrets map[string]string
// Warnings
WarningsEnabled bool
WarningsEnabledTouched bool
InstructionTokenThreshold int
MCPServerThreshold int
MCPToolsTotalThreshold int
MCPServerToolsThreshold int
MCPSchemaTokensTotalThreshold int
MCPSchemaTokensServerThreshold int
}
Choices tracks user selections in the wizard.
func NewChoices ¶
func NewChoices() *Choices
NewChoices returns a Choices struct initialized with defaults.
type DefaultMCPServer ¶
DefaultMCPServer describes a default MCP server and its required env vars.
type HuhUI ¶
type HuhUI struct {
// contains filtered or unexported fields
}
HuhUI implements UI using charmbracelet/huh.
func NewHuhUI ¶
func NewHuhUI() *HuhUI
NewHuhUI creates a new HuhUI using the default terminal check. The default implementation uses terminal.IsInteractive().
func (*HuhUI) MultiSelect ¶
MultiSelect renders a multi-choice prompt.
func (*HuhUI) SecretInput ¶
SecretInput renders a masked input prompt for secrets.
type UI ¶
type UI interface {
Select(title string, options []string, current *string) error
MultiSelect(title string, options []string, selected *[]string) error
Confirm(title string, value *bool) error
Input(title string, value *string) error
SecretInput(title string, value *string) error
Note(title string, body string) error
}
UI defines the interaction methods.
type WarningDefaults ¶
type WarningDefaults struct {
InstructionTokenThreshold int
MCPServerThreshold int
MCPToolsTotalThreshold int
MCPServerToolsThreshold int
MCPSchemaTokensTotalThreshold int
MCPSchemaTokensServerThreshold int
}
WarningDefaults holds wizard defaults sourced from the template config.