config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func LoopbackHost(host string) bool

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

func Save(c Config) error

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

func Validate(c Config) error

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 Default

func Default() Config

Default returns the built-in defaults (PLAN.md §5).

func Load

func Load(ov Overrides) (Config, error)

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

func (c *Config) ConfigPath() string

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).

Jump to

Keyboard shortcuts

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