config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config provides configuration management using Viper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeCodeHooksDir

func ClaudeCodeHooksDir() string

ClaudeCodeHooksDir returns the hooks directory for Claude Code.

func CursorConfigDir

func CursorConfigDir() string

CursorConfigDir returns the config directory for Cursor.

func CursorHooksFile

func CursorHooksFile() string

CursorHooksFile returns the hooks file path for Cursor.

func EnsureDirectories

func EnsureDirectories() error

EnsureDirectories creates all required directories if they don't exist.

func ParseValue

func ParseValue(value string) interface{}

ParseValue parses a string value into an appropriate Go type. It handles booleans and simple arrays.

Types

type AgentConfig

type AgentConfig struct {
	Enabled      bool         `mapstructure:"enabled"`
	LoggingLevel LoggingLevel `mapstructure:"logging_level,omitempty"`
}

AgentConfig holds settings for a specific agent.

type AgentsConfig

type AgentsConfig struct {
	ClaudeCode AgentConfig `mapstructure:"claude-code"`
	Cursor     AgentConfig `mapstructure:"cursor"`
	Gemini     AgentConfig `mapstructure:"gemini"`
	OpenCode   AgentConfig `mapstructure:"opencode"`
	OpenClaw   AgentConfig `mapstructure:"openclaw"`
	Windsurf   AgentConfig `mapstructure:"windsurf"`
	PiAgent    AgentConfig `mapstructure:"pi-agent"`
	Codex      AgentConfig `mapstructure:"codex"`
}

AgentsConfig holds per-agent settings.

type ColorMode

type ColorMode string

ColorMode represents the color output mode.

const (
	// ColorAuto automatically detects terminal support.
	ColorAuto ColorMode = "auto"
	// ColorAlways always uses colors.
	ColorAlways ColorMode = "always"
	// ColorNever never uses colors.
	ColorNever ColorMode = "never"
)

type Config

type Config struct {
	Logging LoggingConfig `mapstructure:"logging"`
	Storage StorageConfig `mapstructure:"storage"`
	Privacy PrivacyConfig `mapstructure:"privacy"`
	Filters FiltersConfig `mapstructure:"filters"`
	Agents  AgentsConfig  `mapstructure:"agents"`
	Display DisplayConfig `mapstructure:"display"`
	Streams StreamsConfig `mapstructure:"streams"`
}

Config holds all configuration values.

func Default

func Default() *Config

Default returns a Config with all default values.

func Load

func Load(configPath string) (*Config, error)

Load loads configuration from the given path or default locations.

func (*Config) GetAgentLoggingLevel

func (c *Config) GetAgentLoggingLevel(agentName string) LoggingLevel

GetAgentLoggingLevel returns the logging level for a specific agent. Falls back to global level if not set.

func (*Config) GetDatabasePath

func (c *Config) GetDatabasePath() string

GetDatabasePath returns the resolved database path from config or default.

func (*Config) IsAgentEnabled

func (c *Config) IsAgentEnabled(agentName string) bool

IsAgentEnabled returns true if the given agent is enabled.

func (*Config) ShouldUseColors

func (c *Config) ShouldUseColors() bool

ShouldUseColors returns true if colors should be used based on config and terminal.

type DisplayConfig

type DisplayConfig struct {
	Colors   ColorMode    `mapstructure:"colors"`
	Timezone TimezoneMode `mapstructure:"timezone"`
}

DisplayConfig holds display-related settings.

type FiltersConfig

type FiltersConfig struct {
	Enabled bool `mapstructure:"enabled"`
}

FiltersConfig holds content filter settings.

type LoggingConfig

type LoggingConfig struct {
	Level           LoggingLevel `mapstructure:"level"`
	StdoutMaxChars  int          `mapstructure:"stdout_max_chars"`
	StderrMaxChars  int          `mapstructure:"stderr_max_chars"`
	ContextMaxChars int          `mapstructure:"context_max_chars"`
	ContentHash     bool         `mapstructure:"content_hash"`
}

LoggingConfig holds logging-related settings.

type LoggingLevel

type LoggingLevel string

LoggingLevel represents the verbosity level for logging. This is for agent event logging only. Not for our own internal logging.

const (
	// LoggingMinimal logs action type, file path, timestamp, result only.
	LoggingMinimal LoggingLevel = "minimal"
	// LoggingStandard adds diff stats, command exit codes, truncated output.
	LoggingStandard LoggingLevel = "standard"
	// LoggingFull adds raw events, conversation context, full command output, file diffs.
	LoggingFull LoggingLevel = "full"
)

func (LoggingLevel) IsAtLeast

func (l LoggingLevel) IsAtLeast(other LoggingLevel) bool

IsAtLeast returns true if this logging level is at least as verbose as other.

type Manager

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

Manager provides a high-level API for configuration management. It encapsulates viper and handles defaults, file persistence, and validation.

func NewManager

func NewManager(configPath string) (*Manager, error)

NewManager creates a new configuration manager. It initializes with defaults and reads the config file if it exists.

func (*Manager) AllSettings

func (m *Manager) AllSettings() map[string]interface{}

AllSettings returns all configuration values as a map. This includes defaults merged with any file-based overrides.

func (*Manager) ConfigPath

func (m *Manager) ConfigPath() string

ConfigPath returns the path to the configuration file.

func (*Manager) Get

func (m *Manager) Get(key string) interface{}

Get returns the value for a given key. Returns nil if the key does not exist.

func (*Manager) HasKey

func (m *Manager) HasKey(key string) bool

HasKey returns true if the given key exists in the configuration.

func (*Manager) Reset

func (m *Manager) Reset() error

Reset removes the config file, effectively resetting to defaults.

func (*Manager) Set

func (m *Manager) Set(key string, value interface{}) error

Set sets a configuration value and persists it to the config file. It ensures the config directory exists and writes a complete config file.

type Paths

type Paths struct {
	ConfigFile   string
	ConfigDir    string
	DataDir      string
	DatabaseFile string
	CacheDir     string
	BackupsDir   string
}

Paths holds resolved filesystem paths.

func ResolvePaths

func ResolvePaths() *Paths

ResolvePaths returns the resolved filesystem paths for the current platform.

type PrivacyConfig

type PrivacyConfig struct {
	SensitivePaths []string `mapstructure:"sensitive_paths"`
	RedactPatterns []string `mapstructure:"redact_patterns"`
}

PrivacyConfig holds privacy-related settings.

type StorageConfig

type StorageConfig struct {
	Path          string `mapstructure:"path"`
	RetentionDays int    `mapstructure:"retention_days"`
}

StorageConfig holds storage-related settings.

type StreamTargetConfig

type StreamTargetConfig struct {
	Name    string         `mapstructure:"name"`
	Type    string         `mapstructure:"type"`
	Enabled bool           `mapstructure:"enabled"`
	Config  map[string]any `mapstructure:"config"`
}

StreamTargetConfig holds settings for a single stream target.

type StreamsConfig

type StreamsConfig struct {
	Targets []StreamTargetConfig `mapstructure:"targets"`
}

StreamsConfig holds stream target settings.

type TimezoneMode

type TimezoneMode string

TimezoneMode represents the timezone display mode.

const (
	// TimezoneLocal uses the local timezone.
	TimezoneLocal TimezoneMode = "local"
	// TimezoneUTC uses UTC.
	TimezoneUTC TimezoneMode = "utc"
)

Jump to

Keyboard shortcuts

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