Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions config/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func DefaultCategories() map[ModelCategory]CategoryConfig {
}

// GetCategoryRegistry returns the global category registry.
// It loads overrides from ~/.hawk/categories.json if present.
// It loads overrides from Hawk user config if present.
func GetCategoryRegistry() *CategoryRegistry {
registryOnce.Do(func() {
globalRegistry = &CategoryRegistry{
Expand All @@ -117,11 +117,15 @@ func ResetCategoryRegistry() {
}

func (r *CategoryRegistry) loadOverrides() {
home, err := os.UserHomeDir()
if err != nil {
return
configDir := os.Getenv("HAWK_CONFIG_DIR")
if configDir == "" {
dir, err := os.UserConfigDir()
if err != nil || dir == "" {
return
}
configDir = filepath.Join(dir, "hawk")
}
path := filepath.Join(home, ".hawk", "categories.json")
path := filepath.Join(configDir, "categories.json")
data, err := os.ReadFile(path)
if err != nil {
return // file not found is fine
Expand Down
8 changes: 5 additions & 3 deletions config/provider_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/GrayCodeAI/eyrie/catalog"
)

// ProviderConfig mirrors ~/.hawk/provider.json.
// ProviderConfig mirrors the Hawk provider.json file.
type ProviderConfig struct {
ConfigVersion int `json:"config_version,omitempty"`
Version string `json:"_version,omitempty"`
Expand Down Expand Up @@ -314,8 +314,10 @@ func GetProviderConfigDir() string {
if d := os.Getenv("HAWK_CONFIG_DIR"); d != "" {
return d
}
home, _ := os.UserHomeDir()
return filepath.Join(home, ".hawk")
if d, err := os.UserConfigDir(); err == nil && d != "" {
return filepath.Join(d, "hawk")
}
panic("hawk provider config: user config directory unavailable")
}

// GetProviderConfigPath returns the full path to provider.json.
Expand Down
6 changes: 3 additions & 3 deletions config/provider_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ func TestGetProviderConfigDir(t *testing.T) {
t.Errorf("expected %q, got %q", dir, got)
}

// Test without env var (falls back to ~/.hawk)
// Test without env var (uses OS config dir when available)
os.Unsetenv("HAWK_CONFIG_DIR")
got = GetProviderConfigDir()
if !strings.HasSuffix(got, ".hawk") {
t.Errorf("expected path ending in .hawk, got %q", got)
if !strings.HasSuffix(got, filepath.Join("hawk")) {
t.Errorf("expected path ending in hawk, got %q", got)
}
}

Expand Down
Loading