config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAgentArguments added in v1.0.53

func GetAgentArguments(agentName string) []string

func GetPersonalConfigPath added in v1.0.34

func GetPersonalConfigPath(projectPath string) string

func IsValidKey added in v1.0.34

func IsValidKey(key string) bool

func MigrateConfigFile added in v1.0.53

func MigrateConfigFile() error

MigrateConfigFile performs a one-time migration of the config file. This writes the migrated config back to disk.

func ResolveAgentEnv added in v1.0.34

func ResolveAgentEnv() map[string]string

Types

type AgentConfig added in v1.0.34

type AgentConfig struct {
	BaseURL         string            `yaml:"base-url" json:"base_url"`
	AuthToken       string            `yaml:"auth-token" json:"auth_token" sensitive:"true"`
	APIKey          string            `yaml:"api-key" json:"api_key" sensitive:"true"`
	Model           string            `yaml:"model" json:"model"`
	ModelSonnet     string            `yaml:"model.sonnet" json:"model_sonnet"`
	ModelOpus       string            `yaml:"model.opus" json:"model_opus"`
	ModelHaiku      string            `yaml:"model.haiku" json:"model_haiku"`
	SubagentModel   string            `yaml:"subagent-model" json:"subagent_model"`
	Provider        string            `yaml:"provider" json:"provider"`
	PermissionMode  string            `yaml:"permission-mode" json:"permission_mode"`
	SkipPermissions bool              `yaml:"skip-permissions" json:"skip_permissions"`
	Effort          string            `yaml:"effort" json:"effort"`
	AllowedTools    []string          `yaml:"allowed-tools" json:"allowed_tools"`
	Env             map[string]string `yaml:"env" json:"env"`
}

func DefaultAgentConfig added in v1.0.34

func DefaultAgentConfig() *AgentConfig

type AgentSettings added in v1.0.53

type AgentSettings struct {
	APIKey    string            `yaml:"api_key,omitempty" json:"api_key,omitempty"`
	BaseURL   string            `yaml:"base_url,omitempty" json:"base_url,omitempty"`
	Model     string            `yaml:"model,omitempty" json:"model,omitempty"`
	Arguments []string          `yaml:"arguments,omitempty" json:"arguments,omitempty"`
	Env       map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
}

AgentSettings represents per-agent configuration. This is the universal config structure that applies to all agents.

func NewAgentSettings added in v1.0.53

func NewAgentSettings() *AgentSettings

NewAgentSettings creates a new AgentSettings with initialized maps.

type ClaudeModelAliases added in v1.0.53

type ClaudeModelAliases struct {
	Sonnet string `yaml:"sonnet,omitempty" json:"sonnet,omitempty"`
	Opus   string `yaml:"opus,omitempty" json:"opus,omitempty"`
	Haiku  string `yaml:"haiku,omitempty" json:"haiku,omitempty"`
}

ClaudeModelAliases defines Claude-specific model aliases. These map short names (sonnet, opus, haiku) to full model IDs.

type ClaudeSettings added in v1.0.53

type ClaudeSettings struct {
	AgentSettings `yaml:",inline" json:",inline"`
	ModelAliases  *ClaudeModelAliases `yaml:"model_aliases,omitempty" json:"model_aliases,omitempty"`
}

ClaudeSettings extends AgentSettings with Claude-specific options.

func NewClaudeSettings added in v1.0.53

func NewClaudeSettings() *ClaudeSettings

NewClaudeSettings creates a new ClaudeSettings with initialized nested structs.

type Config

type Config struct {
	DefaultProjectDir  string `yaml:"default_project_dir" json:"default_project_dir"`
	PreferredShell     string `yaml:"preferred_shell" json:"preferred_shell"`
	TUIEnabled         bool   `yaml:"tui_enabled" json:"tui_enabled"`
	AutoInstallDeps    bool   `yaml:"auto_install_deps" json:"auto_install_deps"`
	FallbackToPlainCLI bool   `yaml:"fallback_to_plain_cli" json:"fallback_to_plain_cli"`
	LogLevel           string `yaml:"log_level" json:"log_level"`
	Theme              string `yaml:"theme" json:"theme"`
	Language           string `yaml:"language" json:"language"`

	// NEW: Namespaced agent config
	Agents *ConfigAgents `yaml:"agents,omitempty" json:"agents,omitempty"`

	// DEPRECATED: Keep for backward compatibility during migration
	Agent         *AgentConfig            `yaml:"agent,omitempty" json:"agent,omitempty"`
	Profiles      map[string]*AgentConfig `yaml:"profiles,omitempty" json:"profiles,omitempty"`
	ActiveProfile string                  `yaml:"active-profile,omitempty" json:"active_profile,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func Load

func Load() (*Config, error)

Load loads the configuration from file

func LoadWithMigration added in v1.0.53

func LoadWithMigration() (*Config, error)

LoadWithMigration loads config and performs migration if needed.

func (*Config) CreateProfile added in v1.0.34

func (c *Config) CreateProfile(name string, agent *AgentConfig) error

func (*Config) DeleteProfile added in v1.0.34

func (c *Config) DeleteProfile(name string) error

func (*Config) GetActiveProfile added in v1.0.34

func (c *Config) GetActiveProfile() string

func (*Config) GetProfile added in v1.0.34

func (c *Config) GetProfile(name string) (*AgentConfig, error)

func (*Config) HasProfiles added in v1.0.34

func (c *Config) HasProfiles() bool

func (*Config) HasSensitiveValues added in v1.0.34

func (c *Config) HasSensitiveValues() bool

func (*Config) ListProfiles added in v1.0.34

func (c *Config) ListProfiles() []string

func (*Config) MigrateConfig added in v1.0.53

func (c *Config) MigrateConfig()

MigrateConfig migrates old AgentConfig format to new ConfigAgents format. This is called automatically when loading config.

func (*Config) ProfileExists added in v1.0.34

func (c *Config) ProfileExists(name string) bool

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to file

func (*Config) SetActiveProfile added in v1.0.34

func (c *Config) SetActiveProfile(name string) error

type ConfigAgents added in v1.0.53

type ConfigAgents struct {
	// Default agent to launch when no agent is specified
	Default string `yaml:"default,omitempty" json:"default,omitempty"`

	// Claude-specific settings (has extra fields for model aliases)
	Claude *ClaudeSettings `yaml:"claude,omitempty" json:"claude,omitempty"`

	// Other agents use the base AgentSettings
	OpenCode      *AgentSettings `yaml:"opencode,omitempty" json:"opencode,omitempty"`
	GitHubCopilot *AgentSettings `yaml:"github-copilot,omitempty" json:"github-copilot,omitempty"`
	Codex         *AgentSettings `yaml:"codex,omitempty" json:"codex,omitempty"`
}

ConfigAgents holds all agent configurations with namespacing. This replaces the old single AgentConfig with per-agent settings.

func NewConfigAgents added in v1.0.53

func NewConfigAgents() *ConfigAgents

NewConfigAgents creates a new ConfigAgents with default settings.

func (*ConfigAgents) GetAgentSettings added in v1.0.53

func (c *ConfigAgents) GetAgentSettings(agentName string) *AgentSettings

GetAgentSettings returns the AgentSettings for the given agent name. For Claude, it returns the AgentSettings embedded in ClaudeSettings.

func (*ConfigAgents) GetOrCreateAgentSettings added in v1.0.53

func (c *ConfigAgents) GetOrCreateAgentSettings(agentName string) *AgentSettings

GetOrCreateAgentSettings gets existing settings or creates new ones.

func (*ConfigAgents) SetAgentSettings added in v1.0.53

func (c *ConfigAgents) SetAgentSettings(agentName string, settings *AgentSettings)

SetAgentSettings sets the AgentSettings for the given agent name.

type ConfigKeyDef added in v1.0.34

type ConfigKeyDef struct {
	Key         string        `json:"key"`
	Type        ConfigKeyType `json:"type"`
	EnvVar      string        `json:"env_var"`
	CLIFlag     string        `json:"cli_flag"`
	Default     interface{}   `json:"default"`
	Sensitive   bool          `json:"sensitive"`
	Description string        `json:"description"`
	EnumValues  []string      `json:"enum_values,omitempty"`
	Category    string        `json:"category"`
}

func LookupKey added in v1.0.34

func LookupKey(key string) (*ConfigKeyDef, error)

type ConfigKeyType added in v1.0.34

type ConfigKeyType string
const (
	KeyTypeString     ConfigKeyType = "string"
	KeyTypeBool       ConfigKeyType = "bool"
	KeyTypeEnum       ConfigKeyType = "enum"
	KeyTypeStringList ConfigKeyType = "string-list"
	KeyTypeStringMap  ConfigKeyType = "string-map"
)

type ConfigScope added in v1.0.34

type ConfigScope string
const (
	ScopeDefault       ConfigScope = "default"
	ScopeGlobal        ConfigScope = "global"
	ScopeProfile       ConfigScope = "profile"
	ScopeTeamLocal     ConfigScope = "team-local"
	ScopePersonalLocal ConfigScope = "personal"
)

type PersonalConfig added in v1.0.34

type PersonalConfig struct {
	Agent         *AgentConfig `yaml:"agent,omitempty"`
	ActiveProfile string       `yaml:"active-profile,omitempty"`
}

func LoadPersonal added in v1.0.34

func LoadPersonal(projectPath string) (*PersonalConfig, error)

func (*PersonalConfig) HasAgentConfig added in v1.0.34

func (c *PersonalConfig) HasAgentConfig() bool

func (*PersonalConfig) Save added in v1.0.34

func (c *PersonalConfig) Save(projectPath string) error

func (*PersonalConfig) SetAgentConfigValue added in v1.0.34

func (c *PersonalConfig) SetAgentConfigValue(key, value string) error

func (*PersonalConfig) UnsetAgentConfigValue added in v1.0.34

func (c *PersonalConfig) UnsetAgentConfigValue(key string) error

type ResolvedAgentSettings added in v1.0.53

type ResolvedAgentSettings struct {
	AgentName string
	APIKey    string
	BaseURL   string
	Model     string
	Arguments []string
	EnvVars   map[string]string

	// Claude-specific
	ModelAliases map[string]string
}

ResolvedAgentSettings holds resolved settings for a specific agent.

func GetAgentSettingsFromConfig added in v1.0.53

func GetAgentSettingsFromConfig(agentName string) *ResolvedAgentSettings

GetAgentSettingsFromConfig gets per-agent arguments from the new config structure.

func ResolveAgentSettings added in v1.0.53

func ResolveAgentSettings(agentName string) *ResolvedAgentSettings

ResolveAgentSettings resolves settings for a specific agent. It merges settings from global, project, and personal configs, then maps config values to environment variables using the agent's env var mappings.

type ResolvedConfig added in v1.0.34

type ResolvedConfig struct {
	Values        map[string]*ResolvedValue `json:"values"`
	ActiveProfile string                    `json:"active_profile"`
}

func MergeConfigs added in v1.0.34

func MergeConfigs(defaults, global, profile, teamLocal, personalLocal *AgentConfig) *ResolvedConfig

func ResolveAgentConfig added in v1.0.41

func ResolveAgentConfig() *ResolvedConfig

ResolveAgentConfig returns the fully resolved agent configuration. This includes both environment variables and CLI flags.

func (*ResolvedConfig) Get added in v1.0.34

func (r *ResolvedConfig) Get(key string) *ResolvedValue

func (*ResolvedConfig) GetCLIFlags added in v1.0.41

func (r *ResolvedConfig) GetCLIFlags() []string

GetCLIFlags returns CLI flags based on the schema definitions. This converts config values like skip-permissions=true to "--dangerously-skip-permissions".

func (*ResolvedConfig) GetEnvVars added in v1.0.34

func (r *ResolvedConfig) GetEnvVars() map[string]string

func (*ResolvedConfig) GetValue added in v1.0.34

func (r *ResolvedConfig) GetValue(key string) interface{}

type ResolvedValue added in v1.0.34

type ResolvedValue struct {
	Key       string      `json:"key"`
	Value     interface{} `json:"value"`
	Source    ConfigScope `json:"source"`
	Sensitive bool        `json:"sensitive"`
}

type SchemaRegistry added in v1.0.34

type SchemaRegistry struct {
	// contains filtered or unexported fields
}

func GetRegistry added in v1.0.34

func GetRegistry() *SchemaRegistry

func (*SchemaRegistry) FindSimilar added in v1.0.34

func (r *SchemaRegistry) FindSimilar(key string) []string

func (*SchemaRegistry) IsValidKey added in v1.0.34

func (r *SchemaRegistry) IsValidKey(key string) bool

func (*SchemaRegistry) List added in v1.0.34

func (r *SchemaRegistry) List() []*ConfigKeyDef

func (*SchemaRegistry) ListByCategory added in v1.0.34

func (r *SchemaRegistry) ListByCategory() map[string][]*ConfigKeyDef

func (*SchemaRegistry) Lookup added in v1.0.34

func (r *SchemaRegistry) Lookup(key string) (*ConfigKeyDef, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL