Documentation
¶
Overview ¶
Package config holds SelfTUI's runtime configuration.
Resolution priority (highest first): command-line flags > environment variables > config file (~/.config/selftui/config.toml) > built-in defaults. See load.go for the chain and config_test.go for the priority tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoopbackHost ¶
LoopbackHost reports whether host — an http(s) base URL or a bare hostname — is one of the loopback spellings SelfTUI treats as local (localhost, 127.0.0.1, ::1). The UI reuses it to warn when workspace content could leave the machine; validateHost uses it for the plain-http token rule.
func Save ¶
Save writes the current Config state to the resolved config path. The value is validated first — config.Validate is the single policy, reused by Load, Save, and the Settings form — then written atomically via writeFileAtomic so a failure at any point leaves any previous file untouched.
func Validate ¶
Validate enforces SelfTUI's configuration policy. It is the single source of truth for value rules and is reused everywhere a Config is accepted or produced: Load validates after all sources are applied, Save validates before marshaling, and the Settings form delegates its field checks here.
Errors are stable and field-prefixed ("config: host: …") so every surface — startup load, a settings save, the Settings form — reports the same message no matter which source supplied the value. The first violation in a fixed field order is returned.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
Temperature float64
TopP float64
NumCtx int
SystemPrompt string
MaxToolIterations int // bounds each agent run
}
AgentConfig mirrors the agent.* keys of PLAN.md §5.
type Config ¶
type Config struct {
// Host is the Ollama base URL, e.g. http://localhost:11434.
Host string
// AuthToken is an optional bearer token for remote Ollama hosts.
AuthToken string
// DefaultModel is auto-selected for the agent chat (first /api/tags entry
// at runtime when empty; qwen3:8b is the recommended agent model).
DefaultModel string
// Theme is "dark" or "light".
Theme string
// WorkspaceRoot is the project root the agent operates on (defaults to cwd).
WorkspaceRoot string
// ToolsEnabled arms the jailed workspace tools (read/list/grep/write/
// edit) for the Agent tab. It defaults to false: the agent is plain chat
// until the user explicitly trusts a workspace root (see the validation
// pairing in Validate — tools require a real project root, never the
// whole filesystem or the home directory).
ToolsEnabled bool
// Agent parameters.
Agent AgentConfig
// contains filtered or unexported fields
}
Config is the full configuration surface defined by PLAN.md §5.
func Load ¶
Load resolves the configuration: defaults -> config file -> env -> overrides. The resolved value is validated with Validate (the single configuration policy), so an invalid value is rejected with the same stable error no matter which source supplied it.
func (*Config) ConfigPath ¶
ConfigPath returns the config file path this Config was resolved to.
type Overrides ¶
type Overrides struct {
ConfigPath *string
Host *string
AuthToken *string
Theme *string
DefaultModel *string
WorkspaceRoot *string
Temperature *float64
TopP *float64
NumCtx *int
SystemPrompt *string
MaxToolIterations *int
}
Overrides carries flag (or other highest-priority) values. Nil fields do not override env/file/defaults. ConfigPath overrides the config file location (default: $XDG_CONFIG_HOME/selftui/config.toml via xdg).