Repository navigation
feat: add reset --json output and --credit card selection - #203
Merged
Merged
Conversation
codex-auth reset gains a --json contract mirroring switch/remove: a success document with the redeemed account, outcome, remaining_credits, and next_expires_at, plus JSON error documents (account_not_found, ambiguous_query, no_reset_credit, reset_credit_not_found, nothing_to_reset, reset_failed, registry_error, usage). --credit <id> redeems a named available card instead of the soonest-expiring one, in both text and JSON paths.
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues remain. SummaryAdds
|
@loongphy/codex-auth-darwin-arm64
@loongphy/codex-auth-darwin-x64
@loongphy/codex-auth-linux-arm64
@loongphy/codex-auth-linux-x64
@loongphy/codex-auth-win32-arm64
@loongphy/codex-auth-win32-x64
@loongphy/codex-auth
commit: |
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
codex-auth reset <selector>gains two flags:--json: emits a machine-readable success document{schema_version, command: "reset", redeemed, outcome, remaining_credits, next_expires_at}whereremaining_credits/next_expires_atdescribe the stored card list after the consume (already_redeemedcounts as success). Failures reuse the shared JSON error envelope with codesaccount_not_found,ambiguous_query(with candidates),no_reset_credit,reset_credit_not_found,nothing_to_reset,reset_failed,registry_error, andusage.--credit <id>(and--credit=<id>): redeems the available card whose id matches instead of the soonest-expiring one. Works in both text and JSON paths; an id naming no available card fails before any request.The workflow splits into interactive and JSON handlers sharing card selection (
selectCardIndex/nextCardIndex), preserving the UUID v4redeem_request_ididempotency key, the account-scoped consume auth, and all existing text messages/error names.already_redeemedremains a success in both paths.Test plan
zig buildclean;zig fmtclean on changed files.zig build test -Dtest-filter=reset: 17 parser tests + 13 integration tests pass, covering--json, both--creditforms, missing/duplicate values, unknown flags, the success document fields,--creditcard selection shiftingnext_expires_at, and every new error code.zig build test test-helpers: full suite passes.zig build -Doptimize=ReleaseSafe test-helpersinto an isolated prefix, then the reset integration tests and a manual run against a seeded mockCODEX_HOME+tests/fake_curl.zigbackend — success docs, named-card consume (verified inrequests.log),reset_credit_not_found,account_not_found, and JSON usage errors all confirmed; no real account data touched.--creditswallowing a following--json) fixed and re-reviewed clean (confidence 5, no comments).