feat(output): pretty whoami + token-refresh fix + renderer cleanups#3
Merged
Conversation
Adds two new generated commands: - `wspc auth me` — low-level GET /auth/me - `wspc org show` — GET /auth/me/org Both flow through the pretty renderer with object-shape display hints. SDK regen has no semantic changes beyond the two new operations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three handwritten commands were still dumping raw JSON regardless of TTY,
which the rest of the CLI no longer does. Move them all to render():
- whoami: now a sectioned ENV / USER / ORG overview. Local env config
(name, api_base, actor, agent_label) sits next to /auth/me and
/auth/me/org. Org fetch is best-effort — missing org doesn't fail the
command. `--json` / pipe emits a combined { env, user, org? } object.
- todo done: pretty path now mirrors `todo update` (id-short, status
badge, relative timestamps). Display hints duplicated from the spec
block; if codegen ever exports them, switch over.
- config show: renders a table of envs with a green ✓ next to current,
hides token contents entirely (was just redacting strings), shows
auth mode (api_key / oauth / none). JSON path emits { current_env,
envs: [...] } — nicer for jq than the previous map shape.
Renderer changes are minimal — `renderObject` is now exported so
handwritten renderers can compose sections without duplicating the
field/format pipeline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d_out
`runWhoami` was making a raw fetch to /auth/me with the persisted
access_token. When that token had expired, the call 401'd and we
returned { status: "logged_out" } — even though refresh_token + client_id
were sitting right there in the config. Any subsequent command that
went through `loadSdkClient` would refresh the token transparently
(via the auth interceptor) and rewrite config.json, after which whoami
suddenly worked again. Net effect: whoami's correctness depended on the
order commands were run in.
Fix: route whoami through the same SDK + interceptor pipeline as
everything else. Side effects:
- `runWhoami` deleted (only the command and one test used it; not part
of the public SDK surface). The relevant integration is already
covered by sdk-auth.test.ts.
- WspcAuthExpiredError (refresh itself failed) is caught locally and
shown as logged_out, rather than bubbling to dispatch() which would
auto-trigger a re-login flow. For a status-check command that's too
aggressive — user can re-login when they actually want to.
- /auth/me and /auth/me/org now fire in parallel via Promise.all; org
remains best-effort polish.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Companion to sadcoderlabs/wspc#350 which adds the upstream
x-clihints this branch consumes.What this changes
Three handwritten commands move off raw JSON dumps onto the renderer:
wspc whoami— now a sectioned ENV / USER / ORG overview. Local env config (name, api_base, actor, agent_label) sits next to/auth/meand/auth/me/org. Org fetch is best-effort;--json/ pipe emits a combined{ env, user, org? }object.wspc todo done— pretty path now mirrorswspc todo update(id-short, status badge, relative timestamps).wspc config show— table of envs with green ✓ next to current, hides token contents entirely, shows auth mode (api_key / oauth / none).Real bug fix in whoami:
runWhoamiused to make a rawfetchto/auth/mewith the persisted access_token. When that token had expired, the call 401'd and we returned{ status: \"logged_out\" }— even though refresh_token + client_id were sitting right there in config. Any subsequent command going throughloadSdkClientwould refresh transparently and rewrite config.json, after which whoami suddenly worked again. Net effect: whoami's correctness depended on the order commands were run in.Fix: route whoami through the same SDK + auth-interceptor pipeline as every other command.
runWhoamiis deleted (not part of the public SDK surface).WspcAuthExpiredErroris caught locally and shown as logged_out — for a status-check command, auto-triggering re-login via dispatch() is too aggressive.Renderer:
renderObjectis now exported so handwritten renderers can compose sections without duplicating the field/format pipeline (used by whoami).wspc auth me+wspc org show, driven by the upstream x-cli hints.Commits
8bfa1b6chore: regenerate from wspc spec with auth_me + org_get x-cli59e8715feat(output): route whoami, todo done, config show through the renderera086be5fix(whoami): refresh expired access tokens instead of reporting logged_outVerification
runWhoamidropped; SDK auth flow is already covered by sdk-auth.test.ts)Depends on
sadcoderlabs/wspc#350 needs to merge first if the spec ever needs to be re-synced from the live API — but the spec change is already committed to this branch (
spec/openapi.jsonupdated in8bfa1b6), so this PR is independently mergeable today.🤖 Generated with Claude Code