config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppDirName    = ".agentic-memorizer"
	MemoryDirName = "memory"
	CacheDirName  = ".cache"
	ConfigFile    = "config.yaml"
	IndexFile     = "index.json"
	DaemonLogFile = "daemon.log"
	DaemonPIDFile = "daemon.pid"
	MCPLogFile    = "mcp.log"
)

Variables

View Source
var DefaultConfig = Config{
	MemoryRoot: "~/" + AppDirName + "/" + MemoryDirName,
	Claude: ClaudeConfig{
		APIKeyEnv:      "ANTHROPIC_API_KEY",
		Model:          "claude-sonnet-4-5-20250929",
		MaxTokens:      1500,
		EnableVision:   true,
		TimeoutSeconds: 30,
	},
	Output: OutputConfig{
		Format:         "xml",
		ShowRecentDays: 7,
	},
	Analysis: AnalysisConfig{
		Enable:         true,
		MaxFileSize:    10485760,
		SkipExtensions: DefaultSkipExtensions,
		SkipFiles:      DefaultSkipFiles,
		CacheDir:       "~/" + AppDirName + "/" + CacheDirName,
	},
	Daemon: DaemonConfig{
		DebounceMs:                 500,
		Workers:                    3,
		RateLimitPerMin:            20,
		FullRebuildIntervalMinutes: 60,
		HealthCheckPort:            0,
		LogFile:                    "~/" + AppDirName + "/" + DaemonLogFile,
		LogLevel:                   "info",
	},
	MCP: MCPConfig{
		LogFile:  "~/" + AppDirName + "/" + MCPLogFile,
		LogLevel: "info",
	},
	Integrations: IntegrationsConfig{
		Enabled: []string{},
	},
}
View Source
var DefaultSkipExtensions = []string{".zip", ".tar", ".gz", ".exe", ".bin", ".dmg", ".iso"}
View Source
var DefaultSkipFiles = []string{"agentic-memorizer"}

Functions

func ExpandHome

func ExpandHome(path string) string

func GetAppDir

func GetAppDir() (string, error)

GetAppDir returns the application directory path. Checks MEMORIZER_APP_DIR environment variable first, then falls back to ~/.agentic-memorizer

func GetConfigPath

func GetConfigPath() string

func GetIndexPath

func GetIndexPath() (string, error)

GetIndexPath returns the path to the precomputed index file. The index is stored at ~/.agentic-memorizer/index.json

func GetPIDPath

func GetPIDPath() (string, error)

GetPIDPath returns the daemon PID file path. The PID file is stored at ~/.agentic-memorizer/daemon.pid

func InitConfig

func InitConfig() error

func ResetForTesting

func ResetForTesting()

ResetForTesting resets viper state for testing purposes. This allows tests to use different config files without interference. Should only be called from test code.

func SafePath

func SafePath(path string) error

SafePath validates that a path is safe (no directory traversal)

func ValidateBinaryPath

func ValidateBinaryPath(path string) error

ValidateBinaryPath validates a binary path for execution

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig validates the complete configuration

func ValidateReload

func ValidateReload(oldCfg, newCfg *Config) error

ValidateReload checks if configuration changes are compatible with hot-reload Returns an error if any immutable fields have changed

func WriteConfig

func WriteConfig(path string, cfg *Config) error

Types

type AnalysisConfig

type AnalysisConfig struct {
	Enable         bool     `mapstructure:"enable" yaml:"enable"`
	MaxFileSize    int64    `mapstructure:"max_file_size" yaml:"max_file_size"`
	SkipExtensions []string `mapstructure:"skip_extensions" yaml:"skip_extensions"`
	SkipFiles      []string `mapstructure:"skip_files" yaml:"skip_files"`
	CacheDir       string   `mapstructure:"cache_dir" yaml:"cache_dir"`
}

type ClaudeConfig

type ClaudeConfig struct {
	APIKey         string `mapstructure:"api_key" yaml:"api_key"`
	APIKeyEnv      string `mapstructure:"api_key_env" yaml:"api_key_env"`
	Model          string `mapstructure:"model" yaml:"model"`
	MaxTokens      int    `mapstructure:"max_tokens" yaml:"max_tokens"`
	EnableVision   bool   `mapstructure:"enable_vision" yaml:"enable_vision"`
	TimeoutSeconds int    `mapstructure:"timeout_seconds" yaml:"timeout_seconds"`
}

type Config

type Config struct {
	MemoryRoot   string             `mapstructure:"memory_root" yaml:"memory_root"`
	Claude       ClaudeConfig       `mapstructure:"claude" yaml:"claude"`
	Output       OutputConfig       `mapstructure:"output" yaml:"output"`
	Analysis     AnalysisConfig     `mapstructure:"analysis" yaml:"analysis"`
	Daemon       DaemonConfig       `mapstructure:"daemon" yaml:"daemon"`
	MCP          MCPConfig          `mapstructure:"mcp" yaml:"mcp"`
	Integrations IntegrationsConfig `mapstructure:"integrations" yaml:"integrations"`
}

func GetConfig

func GetConfig() (*Config, error)

func (*Config) GetAPIKey

func (c *Config) GetAPIKey() string

type DaemonConfig

type DaemonConfig struct {
	DebounceMs                 int    `mapstructure:"debounce_ms" yaml:"debounce_ms"`
	Workers                    int    `mapstructure:"workers" yaml:"workers"`
	RateLimitPerMin            int    `mapstructure:"rate_limit_per_min" yaml:"rate_limit_per_min"`
	FullRebuildIntervalMinutes int    `mapstructure:"full_rebuild_interval_minutes" yaml:"full_rebuild_interval_minutes"`
	HealthCheckPort            int    `mapstructure:"health_check_port" yaml:"health_check_port"`
	LogFile                    string `mapstructure:"log_file" yaml:"log_file"`
	LogLevel                   string `mapstructure:"log_level" yaml:"log_level"`
}

type IntegrationsConfig

type IntegrationsConfig struct {
	Enabled []string `mapstructure:"enabled" yaml:"enabled"`
}

IntegrationsConfig represents the complete integrations configuration section. The Enabled list tracks which integrations have been configured via setup commands. Integration-specific configuration (hooks, tools, etc.) is stored in framework-specific files (e.g., ~/.claude.json, ~/.claude/settings.json) rather than in this config file.

type MCPConfig

type MCPConfig struct {
	LogFile  string `mapstructure:"log_file" yaml:"log_file"`
	LogLevel string `mapstructure:"log_level" yaml:"log_level"`
}

type OutputConfig

type OutputConfig struct {
	Format         string `mapstructure:"format" yaml:"format"`
	ShowRecentDays int    `mapstructure:"show_recent_days" yaml:"show_recent_days"`
}

type ValidationError

type ValidationError struct {
	Field      string
	Value      any
	Rule       string
	Message    string
	Suggestion string
}

ValidationError represents a configuration validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface

type Validator

type Validator struct {
	Errors []ValidationError
}

Validator accumulates validation errors

func (*Validator) AddError

func (v *Validator) AddError(field, rule, message, suggestion string, value any)

AddError adds a validation error

func (*Validator) Error

func (v *Validator) Error() string

Error returns a formatted error message with all validation errors

func (*Validator) HasErrors

func (v *Validator) HasErrors() bool

HasErrors returns true if there are validation errors

Jump to

Keyboard shortcuts

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