Remove unused crypto module, DataDir/DefaultDBPath (SQLite remnant), and ListenAndServe (replaced by direct http.Server in main). Strip 17 unreferenced i18n keys from en/de translations. Add --llm-provider, --llm-model, and --llm-endpoint CLI flags for runtime LLM override without a config file. Rewrite README with correct Go 1.25 version, shields, LLM providers table, Docker/Helm deployment docs. Fix .gitignore pattern to not match cmd/heatguard/ directory.
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
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")
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|