Agent-first CLI for managing OneCLI agents, secrets, and configuration.
task build # Build the onecli binary
task test # Run all tests
task test:race # Run tests with race detector
task lint # Run golangci-lint
task fmt # Format all Go files
task tidy # Clean up dependencies
task clean # Remove build artifactscmd/onecli/ # CLI entry point and commands (Kong framework)
internal/api/ # HTTP client for OneCLI REST API
internal/config/ # Config file + env resolution
internal/auth/ # API key storage (keychain + file fallback)
pkg/output/ # JSON writer (structured stdout/stderr)
pkg/exitcode/ # Exit codes and string codes
pkg/validate/ # Input hardening at command boundaries
- All stdout is valid JSON — never print plain text to stdout
- Errors go to stderr as JSON —
{"error": "...", "code": "...", "action": "..."} - Exit codes are semantic — 0 success, 1 error, 2 auth, 3 not found, 4 conflict
--fieldsfilters output — agents can request only the fields they need--quietextracts single field — one value per line for piping--dry-runpreviews mutations —{"dry_run": true, "description": "...", "payload": {...}}
pkg/output— all output goes throughoutput.Writer. Never usefmt.Printoros.Stdout.pkg/exitcode— exit codes and string codes. Map API 401 → AuthRequired, 404 → NotFound, 409 → Conflict.pkg/validate— validate resource IDs, URLs, API keys at command boundaries.
- Use
context.Background()for all API calls - Accept interfaces, return structs (API client pattern)
- Wrap errors with
fmt.Errorf("doing X: %w", err) - Use const arrow functions pattern: command structs with
Run(out *output.Writer) errormethods - Kong struct tags for CLI parsing —
required,optional,name,help