userconfig

package
v1.19.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package userconfig provides user-level configuration for cagent. This configuration is stored in ~/.config/cagent/config.yaml and contains user preferences like aliases.

Index

Constants

View Source
const CurrentVersion = "v1"

CurrentVersion is the current version of the user config format

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the path to the config file

func ValidateAliasName

func ValidateAliasName(name string) error

ValidateAliasName checks if an alias name is valid. Valid names must: - Not be empty - Start with an alphanumeric character - Contain only alphanumeric characters, hyphens, and underscores - Not contain path separators or special characters

Types

type Alias

type Alias struct {
	// Path is the agent file path or OCI reference
	Path string `yaml:"path"`
	// Yolo enables auto-approve mode for all tool calls
	Yolo bool `yaml:"yolo,omitempty"`
	// Model overrides the agent's model (format: [agent=]provider/model)
	Model string `yaml:"model,omitempty"`
	// HideToolResults hides tool call results in the TUI
	HideToolResults bool `yaml:"hide_tool_results,omitempty"`
}

Alias represents an alias configuration with optional runtime settings

func (*Alias) HasOptions

func (a *Alias) HasOptions() bool

HasOptions returns true if the alias has any runtime options set

type Config

type Config struct {

	// Version is the config format version
	Version string `yaml:"version,omitempty"`
	// ModelsGateway is the default models gateway URL
	ModelsGateway string `yaml:"models_gateway,omitempty"`
	// Aliases maps alias names to alias configurations
	Aliases map[string]*Alias `yaml:"aliases,omitempty"`
	// Settings contains global user settings
	Settings *Settings `yaml:"settings,omitempty"`
	// CredentialHelper configures an external command to retrieve Docker credentials
	CredentialHelper *CredentialHelper `yaml:"credential_helper,omitempty"`
	// contains filtered or unexported fields
}

Config represents the user-level cagent configuration

func Load

func Load() (*Config, error)

Load loads the user configuration from the config file. If the config file doesn't exist but a legacy aliases.yaml does, the aliases are migrated to the new config file.

func (*Config) DeleteAlias

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

DeleteAlias removes an alias by name. It returns true if the alias existed.

This method is safe for concurrent use. Access to the Aliases map is protected by a mutex to prevent concurrent map read/write panics when called from parallel tests or goroutines.

func (*Config) GetAlias

func (c *Config) GetAlias(name string) (*Alias, bool)

GetAlias retrieves the alias configuration for a given name.

This method is safe for concurrent use. Reads from the Aliases map are protected by a mutex to avoid concurrent read/write panics when aliases are accessed while being modified.

func (*Config) GetSettings added in v1.19.5

func (c *Config) GetSettings() *Settings

GetSettings returns the global settings, or an empty Settings if not set

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to the config file

func (*Config) SetAlias

func (c *Config) SetAlias(name string, alias *Alias) error

SetAlias creates or updates an alias. Returns an error if the alias name or alias configuration is invalid.

This method is safe for concurrent use. Writes to the Aliases map are protected by a mutex to avoid concurrent map write panics when aliases are modified from multiple goroutines.

type CredentialHelper added in v1.19.5

type CredentialHelper struct {
	// Command is the CLI command to execute to retrieve the Docker token.
	// The command should output the token on stdout.
	Command string   `yaml:"command,omitempty"`
	Args    []string `yaml:"args,omitempty"`
}

CredentialHelper contains configuration for a credential helper command that retrieves Docker credentials (DOCKER_TOKEN) from an external source.

type Settings added in v1.19.5

type Settings struct {
	// HideToolResults hides tool call results in the TUI by default
	HideToolResults bool `yaml:"hide_tool_results,omitempty"`
}

Settings represents global user settings

Jump to

Keyboard shortcuts

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