package agent import ( "os" "path/filepath" "gopkg.in/yaml.v3" ) // modelsConfig holds the parsed contents of ~/.config/ollie/models.yaml. type modelsConfig struct { Compaction map[string]string `yaml:"compaction"` Completion struct { Model string `yaml:"model"` Backend string `yaml:"backend"` } `yaml:"completion"` } // loadModelsConfig reads and parses the models config file. // Returns zero value if the file doesn't exist or is invalid. func loadModelsConfig() modelsConfig { path := filepath.Join(cfgDir(), "models.yaml") data, err := os.ReadFile(path) if err != nil { return modelsConfig{} } var cfg modelsConfig if err := yaml.Unmarshal(data, &cfg); err != nil { return modelsConfig{} } return cfg } // cfgDir returns the ollie config directory, respecting XDG_CONFIG_HOME. func cfgDir() string { if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" { return filepath.Join(xdg, "ollie") } home, _ := os.UserHomeDir() return filepath.Join(home, ".config", "ollie") }