Documentation
¶
Overview ¶
Package config manages application configuration from various sources.
Index ¶
- Constants
- func GetProviderAPIKey(provider models.ModelProvider) string
- func MarkProjectInitialized() error
- func Reset()
- func ShouldShowInitDialog() (bool, error)
- func UpdateAgentModel(agentName AgentName, modelID models.ModelID) error
- func UpdateTheme(themeName string) error
- func Validate() error
- func WorkingDirectory() string
- type Agent
- type AgentMode
- type AgentName
- type AgentOutput
- type Config
- type Configurator
- type Data
- type LSPConfig
- type MCPServer
- type MCPType
- type MySQLConfig
- type PermissionConfig
- type ProjectInitFlag
- type Provider
- type ProviderType
- type SessionProviderConfig
- type ShellConfig
- type SkillsConfig
- type TUIConfig
Constants ¶
const (
// InitFlagFilename is the name of the file that indicates whether the project has been initialized
InitFlagFilename = "init"
)
const (
MaxTokensFallbackDefault = 4096
)
Application constants
Variables ¶
This section is empty.
Functions ¶
func GetProviderAPIKey ¶ added in v1.5.0
func GetProviderAPIKey(provider models.ModelProvider) string
GetProviderAPIKey gets the API key from environment.
func MarkProjectInitialized ¶
func MarkProjectInitialized() error
MarkProjectInitialized marks the current project as initialized
func ShouldShowInitDialog ¶
ShouldShowInitDialog checks if the initialization dialog should be shown for the current directory
func UpdateAgentModel ¶
UpdateAgentModel updates an agent's model in the config.
func WorkingDirectory ¶
func WorkingDirectory() string
WorkingDirectory returns the current working directory.
Types ¶
type Agent ¶
type Agent struct {
Model models.ModelID `json:"model"`
MaxTokens int64 `json:"maxTokens"`
ReasoningEffort string `json:"reasoningEffort"` // For openai models low,medium,high
Permission map[string]any `json:"permission,omitempty"` // tool name -> "allow" | {"pattern": "action"}
Tools map[string]bool `json:"tools,omitempty"` // e.g., {"skill": false}
Mode AgentMode `json:"mode,omitempty"` // "agent" or "subagent"
Name string `json:"name,omitempty"`
Native bool `json:"native,omitempty"`
Description string `json:"description,omitempty"`
Prompt string `json:"prompt,omitempty"`
Color string `json:"color,omitempty"`
Hidden bool `json:"hidden,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Output *AgentOutput `json:"output,omitempty"`
}
Agent defines configuration for different LLM models and their token limits.
type AgentName ¶
type AgentName = string
AgentName is a string alias to allow flexibility
const ( AgentCoder AgentName = "coder" AgentSummarizer AgentName = "summarizer" AgentExplorer AgentName = "explorer" // Replaces Task AgentDescriptor AgentName = "descriptor" // Replaces Title AgentWorkhorse AgentName = "workhorse" AgentHivemind AgentName = "hivemind" // Deprecated names (kept for migration logic) AgentTask AgentName = "task" AgentTitle AgentName = "title" )
Agent Constants
type AgentOutput ¶ added in v1.3.0
AgentOutput defines structured output configuration for an agent.
type Config ¶
type Config struct {
Data Data `json:"data"`
WorkingDir string `json:"wd,omitempty"`
MCPServers map[string]MCPServer `json:"mcpServers,omitempty"`
Providers map[models.ModelProvider]Provider `json:"providers,omitempty"`
LSP map[string]LSPConfig `json:"lsp,omitempty"`
Agents map[AgentName]Agent `json:"agents,omitempty"`
Debug bool `json:"debug,omitempty"`
DebugLSP bool `json:"debugLSP,omitempty"`
ContextPaths []string `json:"contextPaths,omitempty"`
TUI TUIConfig `json:"tui"`
Shell ShellConfig `json:"shell,omitempty"`
AutoCompact bool `json:"autoCompact,omitempty"`
DisableLSPDownload bool `json:"disableLSPDownload,omitempty"`
SessionProvider SessionProviderConfig `json:"sessionProvider,omitempty"`
// Deprecated: use Rules instead, Needed for backward compatibility.
Skills *SkillsConfig `json:"skills,omitempty"`
Permission *PermissionConfig `json:"permission,omitempty"`
}
Config is the main configuration structure for the application.
func (*Config) WorkingDirectory ¶
type Configurator ¶
type Configurator interface {
WorkingDirectory() string
}
Configurator interface for testability
type Data ¶
type Data struct {
Directory string `json:"directory,omitempty"`
}
Data defines storage configuration.
type LSPConfig ¶
type LSPConfig struct {
Disabled bool `json:"disabled"`
Command string `json:"command"`
Args []string `json:"args"`
Extensions []string `json:"extensions,omitempty"`
Env map[string]string `json:"env,omitempty"`
Initialization any `json:"initialization,omitempty"`
}
LSPConfig defines configuration for Language Server Protocol integration.
type MCPServer ¶
type MCPServer struct {
Command string `json:"command"`
Env []string `json:"env"`
Args []string `json:"args"`
Type MCPType `json:"type"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
}
MCPServer defines the configuration for a Model Control Protocol server.
type MySQLConfig ¶
type MySQLConfig struct {
DSN string `json:"dsn,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Database string `json:"database,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
MaxConnections int `json:"maxConnections,omitempty"`
MaxIdleConnections int `json:"maxIdleConnections,omitempty"`
ConnectionTimeout int `json:"connectionTimeout,omitempty"`
}
MySQLConfig defines MySQL-specific configuration.
type PermissionConfig ¶
type PermissionConfig struct {
// Rules maps tool names to permission logic.
Rules map[string]any `json:"rules,omitempty"` // tool name -> "allow" | {"pattern": "action"}
// Deprecated: use Rules instead, Needed for backward compatibility.
Skill map[string]string `json:"skill,omitempty"`
}
PermissionConfig defines permission configuration using Rules. Each tool key maps to either a simple string ("allow"/"deny"/"ask") or an object with glob pattern keys (e.g., {"*": "ask", "git *": "allow"}).
type ProjectInitFlag ¶
type ProjectInitFlag struct {
Initialized bool `json:"initialized"`
}
ProjectInitFlag represents the initialization status for a project directory
type Provider ¶
type Provider struct {
APIKey string `json:"apiKey"`
Disabled bool `json:"disabled"`
BaseURL string `json:"baseURL"`
Headers map[string]string `json:"headers,omitempty"`
}
Provider defines configuration for an LLM provider.
type ProviderType ¶
type ProviderType string
ProviderType defines the type of session storage provider.
const ( ProviderSQLite ProviderType = "sqlite" ProviderMySQL ProviderType = "mysql" )
type SessionProviderConfig ¶
type SessionProviderConfig struct {
Type ProviderType `json:"type,omitempty"`
MySQL MySQLConfig `json:"mysql,omitempty"`
}
SessionProviderConfig defines configuration for session storage.
type ShellConfig ¶
type ShellConfig struct {
Path string `json:"path,omitempty"`
Args []string `json:"args,omitempty"`
}
ShellConfig defines the configuration for the shell used by the bash tool.
type SkillsConfig ¶
type SkillsConfig struct {
Paths []string `json:"paths,omitempty"` // Custom skill paths
}
SkillsConfig defines configuration for skills.