feat(account): resolve account from CSHIP_ACCOUNT env var - #201
Open
nh13 wants to merge 1 commit into
Open
Conversation
The account module resolves the authenticated Anthropic account from the OAuth profile endpoint using the macOS keychain / credentials-file token. Under a multi-account launcher that injects a per-session OAuth token, that token is stripped from the statusline subprocess, so the keychain path reports the last interactive login — the wrong account. Add a higher-priority source: the CSHIP_ACCOUNT environment variable, a compact JSON payload matching the account profile shape. A launcher that has resolved the session's account can pass it here and the module renders it directly, falling back to the keychain/OAuth path when the variable is absent or malformed. Non-secret identity only; never a token.
nh13
force-pushed
the
nh13/feat-account-env-var
branch
from
August 25, 2026 02:14
714d271 to
aac3620
Compare
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.
Problem
cship.accountresolves the authenticated Anthropic account from the OAuth profile endpoint using the token read from the OS keychain / credentials file — whatever the last interactiveclaudelogin wrote.A launcher that runs Claude Code under multiple accounts by injecting a per-session token via
CLAUDE_CODE_OAUTH_TOKENbreaks this: Claude Code strips that variable before spawning the statusline command, socshipcan't see it and falls back to the keychain token — reporting the wrong account (and wrong plan tier) for any session not launched under the default login.Change
Add a higher-priority account source: the
CSHIP_ACCOUNTenvironment variable. Its value is compact JSON matching the account profile shape (organization_name,organization_tier,organization_type,account_display_name— all optional, non-secret; never a token). When set, the account module renders it directly and skips the keychain/OAuth path; when absent or malformed it falls back to the existing behavior, so a plainclaudeis unchanged.This is a small, tool-agnostic contract: any launcher that has resolved the session's account (it holds the token at launch, where the statusline never does) can hand it to the statusline this way.
Testing
CSHIP_ACCOUNTparse: valid JSON, empty, and malformed.cargo fmt,cargo clippy --all-targets, and the full test suite pass.