package config import ( "os" "path/filepath" "gopkg.in/yaml.v3" ) // Config holds the application configuration. type Config struct { LLM LLMConfig `yaml:"llm"` } // LLMConfig holds LLM provider settings. type LLMConfig struct { Provider string `yaml:"provider"` // anthropic, openai, ollama, none Model string `yaml:"model"` Endpoint string `yaml:"endpoint"` // for ollama } // DefaultConfig returns a Config with sensible defaults. func DefaultConfig() Config { return Config{ LLM: LLMConfig{Provider: "none"}, } } // ConfigDir returns the XDG config directory for heatwave. func ConfigDir() string { if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" { return filepath.Join(xdg, "heatwave") } home, _ := os.UserHomeDir() return filepath.Join(home, ".config", "heatwave") } // DataDir returns the XDG data directory for heatwave. func DataDir() string { if xdg := os.Getenv("XDG_DATA_HOME"); xdg != "" { return filepath.Join(xdg, "heatwave") } home, _ := os.UserHomeDir() return filepath.Join(home, ".local", "share", "heatwave") } // DefaultDBPath returns the default SQLite database path. func DefaultDBPath() string { return filepath.Join(DataDir(), "heatwave.db") } // Load reads the config file from the config directory. func Load() Config { cfg := DefaultConfig() path := filepath.Join(ConfigDir(), "config.yaml") data, err := os.ReadFile(path) if err != nil { return cfg } _ = yaml.Unmarshal(data, &cfg) return cfg }