fix(cli): make sonilo whoami answerable, in both directions - #53
Merged
Conversation
Two bugs that compound into one: whoami could not be used to answer "am I signed in", and its output said the wrong thing when you were. Exit code. whoami returned 0 whether or not a credential existed — "Not signed in. Run sonilo login." printed, then success. Anything branching on it took the signed-in path with nothing on disk and only found out when the next command failed on auth. `gh auth status` sets the precedent: a status command that cannot be branched on is not a status command. It now exits 1 with no credential, and stays 0 for an expired one, which names a real account and wants `sonilo login`, not first-time setup. Blank account name. `accountLabel` was `account_name ?? account_id`, and the API returns `account_name: " "` for an account with no display name set. A single space is neither null nor undefined, so it won, and whoami printed `account: ` with nothing after it — indistinguishable from a credential that never loaded. Trimming first and falling back on any blank shows the id, which is always present. Found while testing the skills repo's transport routing, whose CLI branch is gated on exactly this command. An agent ran whoami against a fully authenticated CLI, read the empty account line, concluded nothing was set up, and detoured to first-time setup. Reproduced 2/2. runWhoami returns a boolean rather than setting process.exitCode itself, so the tests that call it directly do not leave the runner's exit code at 1. Verified: 157 tests pass; built and run against a real credential (account id now shown) and against an empty HOME (exit 1). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Lightsage docs evalsWaiting for the staging docs URL before running evals. Lightsage will start the selected PR evals automatically when GitHub reports a successful docs deployment for this PR. This usually happens within 15 minutes. Commit: |
This was referenced Aug 14, 2026
spencer-zqian
added a commit
that referenced
this pull request
Aug 17, 2026
…ed it (#57) #53 landed on main without a changeset, so `sonilo whoami`'s exit-code change rode out inside 0.14.0 with nothing in that release's notes. The version number is right — it went out in a minor bump, which is the correct slot for a behaviour change at 0.x — only the changelog was silent. Written against the existing 0.14.0 heading rather than as a new changeset, so no phantom 0.15.0 gets published for a change that is already in users' hands. Anyone whose script broke on `whoami` returning 1 can now find the version that did it. Supersedes #54, which proposed the changeset and would have dated this to the next release instead.
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.
Two bugs that compound into one:
whoamicould not be used to answer "am I signed in", and its output said the wrong thing when you were.Exit code
whoamireturned 0 whether or not a credential existed — it printedNot signed in. Run sonilo login.and then exited successfully. Anything branching on it took the signed-in path with nothing on disk, and only found out when the next command failed on auth.sonilo whoami(before)sonilo whoami(after)sonilo accountgh auth statussets the precedent: a status command that cannot be branched on is not a status command.An expired credential still exits 0. It names a real account, the line already says
(expired), andsonilo loginis the fix — reporting "not signed in" would send callers to first-time setup instead.Blank account name
accountLabelwasaccount_name ?? account_id, and the API returnsaccount_name: " "for an account with no display name set. A single space is neithernullnorundefined, so it won, andwhoamiprinted:That empty line is indistinguishable from a credential that never loaded.
How this surfaced
Found while testing the skills repo's transport routing, whose CLI branch is gated on this command ("
sonilo whoamiexits 0 → use the CLI").Both bugs are verified directly and independently of any agent behaviour — the exit-code table above and the
" "account name are reproducible from a shell in one command each. That is what this PR rests on.One agent run did misread the blank
account:line against a fully authenticated CLI and conclude nothing was set up. I initially wrote that up as "reproduced 2/2"; a later controlled comparison showed that was overstated — the second run had failed for an unrelated reason (Bash was not permitted in that non-interactive session), and with permissions held constant the misread did not reproduce every time. The behavioural evidence is one real occurrence, not a consistent failure. The exit-code defect needs no behavioural evidence at all: a probe that returns 0 in both states carries no information by construction.Notes
runWhoamireturns a boolean instead of settingprocess.exitCodeitself — the tests call it directly, and setting the exit code there would leave the whole vitest run at 1.Verification
tsc --noEmitclean.HOME—Not signed in, exit 1." ",""," ", andnull.🤖 Generated with Claude Code