Skip to content

Commit 1c6e60f

Browse files
authored
fix: loadAgentKey path mismatch on macOS (#73)
* fix: ensure_path checks rc file, not runtime PATH When the user manually exports PATH before running install.sh via pipe, the subprocess inherits that PATH. The old runtime check (case ":$PATH:") would return early without modifying .zshrc, leaving future terminal sessions without axme in PATH. Now we only check the rc file for duplicates, which is the correct persistent indicator. * fix: add source hint after install and in README - ensure_path now prints "source ~/.zshrc" hint after modifying rc file - README install block includes source command * fix: loadAgentKey uses scenarioAgentsStorePath instead of hardcoded path On macOS os.UserConfigDir() returns ~/Library/Application Support, but loadAgentKey hardcoded ~/.config. This caused "no API key found" warning on macOS because save and load used different paths. Now loadAgentKey uses loadScenarioAgentsStore() which uses the canonical scenarioAgentsStorePath().
1 parent f132449 commit 1c6e60f

1 file changed

Lines changed: 6 additions & 24 deletions

File tree

cmd/axme/examples.go

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -370,37 +370,19 @@ func (rt *runtime) processAgentIntent(ctx context.Context, agentCtx *clientConfi
370370
}
371371

372372
func (rt *runtime) loadAgentKey(nameFragment, baseURL string) string {
373-
home, _ := os.UserHomeDir()
374-
path := home + "/.config/axme/scenario-agents.json"
375-
raw, err := os.ReadFile(path)
376-
if err != nil {
377-
return ""
378-
}
379-
var data map[string]interface{}
380-
if err := json.Unmarshal(raw, &data); err != nil {
381-
return ""
382-
}
383-
agents, ok := data["agents"].([]interface{})
384-
if !ok {
385-
return ""
386-
}
373+
store := loadScenarioAgentsStore()
387374
normalBase := strings.TrimRight(baseURL, "/")
388375
var fallback string
389-
for _, a := range agents {
390-
agent, ok := a.(map[string]interface{})
391-
if !ok {
392-
continue
393-
}
394-
addr := asString(agent["address"])
395-
if !strings.Contains(addr, nameFragment) {
376+
for _, a := range store.Agents {
377+
if !strings.Contains(a.Address, nameFragment) {
396378
continue
397379
}
398-
storedBase := strings.TrimRight(asString(agent["base_url"]), "/")
380+
storedBase := strings.TrimRight(a.BaseURL, "/")
399381
if storedBase == normalBase {
400-
return asString(agent["api_key"])
382+
return a.APIKey
401383
}
402384
if fallback == "" {
403-
fallback = asString(agent["api_key"])
385+
fallback = a.APIKey
404386
}
405387
}
406388
return fallback

0 commit comments

Comments
 (0)