feat(errors): AuthmuxError taxonomy + --json on 5 core commands (N3)#28
Merged
Conversation
Theme N3 from docs/future/17-ROADMAP.md.
- src/lib/accounts/errors.ts: introduce AuthmuxError base with stable
ErrorCode/ErrorSeverity (per 01-ARCHITECTURE.md §6.2), hint, details,
and toJSON(). Refactor every existing class (AuthFileMissingError,
AccountNotFoundError, NoAccountsSavedError, InvalidAccountNameError,
AccountNameInferenceError, SnapshotEmailMismatchError,
PromptCancelledError, InvalidRemoveSelectionError,
AmbiguousAccountQueryError, AutoSwitchConfigError) to extend it with
the documented stable codes. CodexAuthError is preserved as a
back-compat subclass of AuthmuxError.
- Human-readable `message` strings are unchanged in this round (per N3
Risks: scripts grep against existing messages).
- src/lib/cli/json-envelope.ts: defines the single JSON envelope shape
({ ok: true, data } / { ok: false, error: errorObj.toJSON() }) and the
§6.3 exit-code table mapper.
- src/lib/base-command.ts: adds BaseCommand.jsonFlag, setJsonMode(),
emit() helper, and an AuthmuxError-aware central handler that routes
to the JSON envelope when --json is set and exits with the §6.3 code.
- src/commands/{list,current,status,use,save}.ts: opt into
BaseCommand.jsonFlag, route output through emit(), and suppress
interactive prompts under --json so stdout stays parseable.
- src/tests/error-taxonomy.test.ts: enforces the §6.2 code allowlist,
the §6.3 severity assignments, CodexAuthError back-compat, the
toJSON() shape, and the exit-code table.
Verification: npm run build clean; npm test 89/89 pass;
`authmux list --json` round-trips through JSON.parse.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 17, 2026
NagyVikt
added a commit
that referenced
this pull request
May 18, 2026
Bumps package.json + package-lock.json from 0.1.24 to 0.1.25 and extends releases/v0.1.25.md to cover every theme that landed since v0.1.24: - N1 durability (#29): atomic writes, registry lock, fsync-before-rename - N2 account-service split (#30): 1675 LOC -> 164 LOC orchestrator + 12 modules - N3 error taxonomy + --json (#28): AuthmuxError base, stable codes, JSON envelope - N4 lazy path resolvers (#27): bare constants deprecated for v0.2.0 - P0 wave (#26): secure perms, [y/N] update prompt, kiro ENOENT, CI matrix, registry proxy-source round-trip, 18k-line improvement docs Notes follow the canonical 7-section shape from docs/future/17-ROADMAP.md (Added, Changed, Fixed, Deprecated, Removed, Security, Migration), with the prior Durability section folded into a "Theme deep-dives" appendix so the canonical shape is intact. No code changes. No npm publish. Verification: - npm run build: clean - npm test: 129/129 pass - node -e "require('./package.json').version" -> 0.1.25 - node -e "require('./package-lock.json').version" -> 0.1.25 Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Theme N3 from
docs/future/17-ROADMAP.md— Error taxonomy +--jsonparity for the five core commands.AuthmuxErrorbase class with stablecode,severity,hint,details,toJSON()(per01-ARCHITECTURE.md§6.2). Every class insrc/lib/accounts/errors.ts(AuthFileMissingError,AccountNotFoundError,NoAccountsSavedError,InvalidAccountNameError,AccountNameInferenceError,SnapshotEmailMismatchError,PromptCancelledError,InvalidRemoveSelectionError,AmbiguousAccountQueryError,AutoSwitchConfigError) now extends it with a stableE_*code.CodexAuthErroris kept as a back-compat subclass so existinginstanceof CodexAuthErrorcatches still work.--jsonflag added tolist,current,status,use,save. Output is a single JSON object on stdout; nothing else. Interactive prompts (update offer, account picker) are skipped under--jsonso stdout stays parseable.BaseCommandnow routesAuthmuxErrorto the envelope under--jsonand exits with the §6.3 exit code.src/tests/error-taxonomy.test.tsenforces the §6.2 code allowlist, the severity table,CodexAuthErrorback-compat, thetoJSON()shape, and the exit-code table.Per N3 Risks: human-readable
messagestrings are unchanged in this round. Scripts that grep stdout will keep working.JSON envelope
Exit codes follow §6.3:
3E_AUTH_MISSING,4E_ACCOUNT_NOT_FOUND,5E_SNAPSHOT_EMAIL_MISMATCH,6E_REGISTRY_LOCKED,7E_REGISTRY_CORRUPT,8E_PROVIDER_NOT_INSTALLED,64E_PROMPT_CANCELLED,1generic.Exit-criteria boxes (Theme N3)
AuthmuxErrorclass lands withcode,severity,hint,details, andtoJSON().src/lib/accounts/errors.tsextendsAuthmuxErrorwith a stable code per §6.2.list,current,status,use,save) accept--jsonand write a single JSON object to stdout.src/tests/error-taxonomy.test.tsenforces the code/severity table.Test plan
npm run build— cleannpm test— 89/89 pass (4 new, 85 prior)node dist/index.js list --json | JSON.parse(...)— single valid envelopeauthmux use does-not-exist --jsonemitsE_ACCOUNT_NOT_FOUNDenvelope and exits4authmux list --helpshows the--jsonflagCoordination note
Sibling PRs from N1 (durability — touches
account-service.ts,registry.ts) and N4 (paths deprecation — touchessrc/lib/config/paths.tsand several command callers) are running in parallel. Expect a rebase if they land first; the conflict surface is small (this PR only touches command files at theparse(...)boundary, notpaths.tsorregistry.ts).🤖 Generated with Claude Code