userconfig

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 10 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"`
}

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"`
}

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. Returns true if the alias existed.

func (*Config) GetAlias

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

GetAlias retrieves the alias configuration for a given name

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 is invalid.

Jump to

Keyboard shortcuts

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