config

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config provides configuration loading, saving, and caching for Kairo.

Cache Behavior:

  • ConfigCache is designed for CLI usage where processes are short-lived
  • Cache entries have a TTL (default 5 minutes) to balance freshness vs I/O
  • Cleanup() is available but typically not needed for CLI tools
  • For long-running processes, call Cleanup() periodically to prevent memory growth

Index

Constants

View Source
const (
	KeyFileName     = "age.key"
	SecretsFileName = "secrets.age"
	ConfigFileName  = "config.yaml"
)

Variables

This section is empty.

Functions

func FormatMigrationChanges added in v1.8.1

func FormatMigrationChanges(changes []MigrationChange) string

func FormatSecrets added in v1.10.1

func FormatSecrets(secrets map[string]string) string

FormatSecrets formats a secrets map into a string suitable for file storage. Keys are sorted for deterministic output. Empty keys or values are skipped.

func ParseSecrets

func ParseSecrets(secrets string) map[string]string

ParseSecrets parses a newline-separated list of key=value pairs into a map. Empty lines and lines without '=' are silently ignored. Lines without '=' are treated as malformed and skipped to handle edge cases gracefully. This allows the function to continue processing other valid entries even if some lines are malformed. Keys or values containing newlines are skipped as malformed input.

func SaveConfig

func SaveConfig(configDir string, cfg *Config) error

SaveConfig writes the configuration to the specified directory.

Types

type Config

type Config struct {
	DefaultProvider string              `yaml:"default_provider"`
	Providers       map[string]Provider `yaml:"providers"`
	DefaultModels   map[string]string   `yaml:"default_models"`
	// Version is deprecated and kept for backward compatibility with existing configs.
	// It is no longer used but cannot be removed without breaking existing configs.
	Version string `yaml:"version,omitempty"`
	// DefaultHarness specifies the default CLI harness to use (claude or qwen).
	DefaultHarness string `yaml:"default_harness,omitempty"`
}

Config represents the application configuration.

func LoadConfig

func LoadConfig(configDir string) (*Config, error)

LoadConfig reads and parses the configuration file from the specified directory. Returns ErrConfigNotFound if the file doesn't exist. Automatically migrates old "config" file to "config.yaml" if needed.

type ConfigCache added in v1.8.0

type ConfigCache struct {
	// contains filtered or unexported fields
}

func NewConfigCache added in v1.8.0

func NewConfigCache(ttl time.Duration) *ConfigCache

func (*ConfigCache) Cleanup added in v1.10.0

func (c *ConfigCache) Cleanup()

Cleanup removes all expired entries from the cache.

Note: This method is typically not needed for CLI usage since the process exits after each command, releasing all memory. It is provided for long-running processes (e.g., daemons, services) that need to prevent unbounded memory growth when processing many different config directories.

func (*ConfigCache) Get added in v1.8.0

func (c *ConfigCache) Get(configDir string) (*Config, error)

func (*ConfigCache) Invalidate added in v1.8.0

func (c *ConfigCache) Invalidate(configDir string)

type MigrationChange added in v1.8.1

type MigrationChange struct {
	Provider string
	Field    string
	Old      string
	New      string
}

func MigrateConfigOnUpdate added in v1.8.1

func MigrateConfigOnUpdate(configDir string) ([]MigrationChange, error)

type Provider

type Provider struct {
	Name    string   `yaml:"name"`
	BaseURL string   `yaml:"base_url"`
	Model   string   `yaml:"model"`
	EnvVars []string `yaml:"env_vars"`
}

Provider represents a configured API provider.

Jump to

Keyboard shortcuts

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