Documentation
¶
Index ¶
- func ClearEnvVar(key string) error
- func CortexDir() string
- func DefaultDBPath() string
- func GetEnvVarName(key string) string
- func Save(cfg *Config, path string) error
- func SetEnvVar(key, value string) error
- type Config
- type DatabaseConfig
- type HTTPConfig
- type LifecycleConfig
- type LoggingConfig
- type MCPConfig
- type MemoryConfig
- type PragmaConfig
- type SearchConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearEnvVar ¶
ClearEnvVar clears an environment variable Useful for testing
func CortexDir ¶
func CortexDir() string
CortexDir returns the centralized data directory (~/.cortex/). It uses $HOME, $USERPROFILE, or os.UserHomeDir() to resolve the home directory.
func DefaultDBPath ¶
func DefaultDBPath() string
DefaultDBPath returns the default database path (~/.cortex/cortex.db).
func GetEnvVarName ¶
GetEnvVarName returns the environment variable name for a given config key e.g., "database.path" -> "CORTEX_DATABASE_PATH"
Types ¶
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server" mapstructure:"server"`
Database DatabaseConfig `yaml:"database" mapstructure:"database"`
MCP MCPConfig `yaml:"mcp" mapstructure:"mcp"`
HTTP HTTPConfig `yaml:"http" mapstructure:"http"`
Logging LoggingConfig `yaml:"logging" mapstructure:"logging"`
Search SearchConfig `yaml:"search" mapstructure:"search"`
Memory MemoryConfig `yaml:"memory" mapstructure:"memory"`
Lifecycle LifecycleConfig `yaml:"lifecycle" mapstructure:"lifecycle"`
// LoadedFrom is the path of the config file that was loaded.
// Used by Save() and ReloadConfig() to always use the same file.
// Not serialized to YAML.
LoadedFrom string `yaml:"-" mapstructure:"-"`
}
Config represents the main configuration structure
func Load ¶
Load reads configuration from file, environment variables, and applies defaults The configPath parameter is optional - if empty, it searches for cortex.yaml
func LoadFromEnv ¶
LoadFromEnv loads configuration exclusively from environment variables and defaults Useful for containerized deployments where config files are not used
type DatabaseConfig ¶
type DatabaseConfig struct {
Path string `yaml:"path" mapstructure:"path"`
InMemory bool `yaml:"in_memory" mapstructure:"in_memory"`
Pragma PragmaConfig `yaml:"pragma" mapstructure:"pragma"`
}
DatabaseConfig holds database configuration
type HTTPConfig ¶
type HTTPConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
Port int `yaml:"port" mapstructure:"port"`
Host string `yaml:"host" mapstructure:"host"`
Token string `yaml:"token" mapstructure:"token"`
}
HTTPConfig holds HTTP server configuration
type LifecycleConfig ¶
type LifecycleConfig struct {
EnableAutoArchive bool `yaml:"enable_auto_archive" mapstructure:"enable_auto_archive"`
ArchiveCheckInterval string `yaml:"archive_check_interval" mapstructure:"archive_check_interval"`
}
LifecycleConfig holds lifecycle management configuration
type LoggingConfig ¶
type LoggingConfig struct {
Level string `yaml:"level" mapstructure:"level"`
Format string `yaml:"format" mapstructure:"format"`
}
LoggingConfig holds logging configuration
type MCPConfig ¶
type MCPConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
}
MCPConfig holds MCP (Model Context Protocol) configuration
type MemoryConfig ¶
type MemoryConfig struct {
MaxObservationLength int `yaml:"max_observation_length" mapstructure:"max_observation_length"`
DedupeWindow string `yaml:"dedupe_window" mapstructure:"dedupe_window"`
AutoArchiveDays int `yaml:"auto_archive_days" mapstructure:"auto_archive_days"`
DecayHalfLifeDays float64 `yaml:"importance_decay_half_life" mapstructure:"importance_decay_half_life"`
MinArchiveScore float64 `yaml:"min_archive_score" mapstructure:"min_archive_score"`
}
MemoryConfig holds memory management configuration
type PragmaConfig ¶
type PragmaConfig struct {
JournalMode string `yaml:"journal_mode" mapstructure:"journal_mode"`
Synchronous string `yaml:"synchronous" mapstructure:"synchronous"`
CacheSize int `yaml:"cache_size" mapstructure:"cache_size"`
ForeignKeys bool `yaml:"foreign_keys" mapstructure:"foreign_keys"`
TempStore string `yaml:"temp_store" mapstructure:"temp_store"`
MmapSize int `yaml:"mmap_size" mapstructure:"mmap_size"`
}
PragmaConfig holds SQLite pragma settings
type SearchConfig ¶
type SearchConfig struct {
DefaultLimit int `yaml:"default_limit" mapstructure:"default_limit"`
MaxLimit int `yaml:"max_limit" mapstructure:"max_limit"`
FTS5 bool `yaml:"fts5" mapstructure:"fts5"`
Vector bool `yaml:"vector" mapstructure:"vector"`
FusionK float64 `yaml:"fusion_k" mapstructure:"fusion_k"`
EmbeddingProvider string `yaml:"embedding_provider" mapstructure:"embedding_provider"` // "ollama", "openai", "none" (default)
EmbeddingModel string `yaml:"embedding_model" mapstructure:"embedding_model"` // Model name override (e.g. "qwen3-embedding:8b")
EmbeddingBaseURL string `yaml:"embedding_base_url" mapstructure:"embedding_base_url"` // Ollama base URL override (default: http://localhost:11434)
OllamaAutoStart bool `yaml:"ollama_auto_start" mapstructure:"ollama_auto_start"` // Auto-start Ollama when configured as provider
}
SearchConfig holds search-related configuration
type ServerConfig ¶
type ServerConfig struct {
Name string `yaml:"name" mapstructure:"name"`
Version string `yaml:"version" mapstructure:"version"`
}
ServerConfig holds server-related configuration