Skip to content

fix: CLI exit codes, config.yaml, setup agent key (RUN4.06-08) - #52

Merged
egerev merged 2 commits into
mainfrom
feat/tech-debt-sprint-4
Apr 9, 2026
Merged

fix: CLI exit codes, config.yaml, setup agent key (RUN4.06-08)#52
egerev merged 2 commits into
mainfrom
feat/tech-debt-sprint-4

Conversation

@egerev

@egerev egerev commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New apierror package: APIError type with exit codes (2=auth, 3=not_found, 4=timeout, 5=rate_limited)
  • client.go returns structured APIError with HTTP status mapping
  • config.go reads YAML from ~/.alaya/config.yaml, env vars override
  • setup agent creates API key via bootstrap key if none exists
  • Proper error handling for config read errors (not just missing file)

Items closed

  • RUN4.06 (P2): CLI exit codes not differentiated
  • RUN4.07 (P2): CLI config.yaml not read from disk
  • RUN4.08 (P2): setup agent doesn't create API key

Test plan

  • apierror tests (status mapping, wrapped errors, nil, timeout, context deadline)
  • config tests (YAML load, env override, missing file, permission denied)
  • setup tests (bootstrap key flow)
  • go test ./... all pass

🤖 Generated with Claude Code

egerev and others added 2 commits April 9, 2026 02:45
…UN4.06, RUN4.07, RUN4.08)

- Add apierror package with structured APIError type and exit code constants
- Map HTTP 401/403 → exit 2, 404 → exit 3, 429 → exit 5, timeout → exit 4
- Update client.go to return *apierror.APIError instead of fmt.Errorf
- Update main.go to call apierror.ExitCodeFrom(err) for correct exit codes
- Add LoadFromPath to config.go; Load now reads ~/.alaya/config.yaml via yaml.v3, env vars override
- Add createAPIKeyViaBootstrap to setup.go; setup agent creates key via ALAYA_BOOTSTRAP_KEY when none stored

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- LoadFromPath propagates non-ErrNotExist errors (permission denied, I/O)
- ExitCodeFrom(nil) returns 0 instead of ExitGeneric
- isTimeout checks context.DeadlineExceeded in addition to net.Error.Timeout()
- Added tests: permission denied config, nil error, context deadline exceeded

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@egerev
egerev merged commit 4a5d6db into main Apr 9, 2026
14 checks passed
@egerev
egerev deleted the feat/tech-debt-sprint-4 branch April 16, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant