Repository navigation
feat: keep last-seen account details offline (v0.3.0) - #2
Merged
Merged
Conversation
dotfiles now carries the kit at the root of its own Stow package, common/coding-agent-kit, with the 14 links at the same package-relative paths. The tests that build a dotfiles-style host (two-hop links from HOME through the package into the kit) follow that layout.
Each launcher now keeps a small metadata cache per account in
${XDG_STATE_HOME:-~/.local/state}/coding-agent-kit/accounts/ (0700; each
file 0600, replaced atomically and only on change, with one writer; no
token, and no time from the launcher's clock):
- codex-as records the email and plan from the id_token before the run,
and after it the newest codex rate-limit snapshot of the run's own
rollouts: the thread it resumed or recovered, or one whose session_meta
names this account's ChatGPT user and workspace. Best effort; it never
fails a launch or changes the exit code. New lib/codex-as/usage.py.
- claude-as asks for an optional label after the enrolment confirmation
and saves it after the token; control characters, more than 100
characters and anything containing sk-ant- are refused.
claude-as --set-label NAME [LABEL] sets, asks for or clears it.
- claude-as passes its child CODING_AGENT_KIT_USAGE_FILE and
CODING_AGENT_KIT_TOKEN_ID; helpers/statusline.cjs records the session's
rate_limits there only while CLAUDE_CODE_OAUTH_TOKEN hashes to that
identifier, into an owned 0700 directory, never on Windows, without
changing what it prints.
New metadata-only queries, which create nothing, start nothing and open
no credential: --account-info NAME and --account-labels for both
launchers. The zsh completions show the email or label as descriptions.
Config gains state_dir (not a key); lib/coding-agent-kit/accounts.py is
the shared cache. The test entry points also unset the two new variables
and XDG_STATE_HOME.
docs/account-launchers.md gains an account metadata section: where the cache lives, its three files and their writers, the --account-info output, where each field comes from and its known gaps (the Codex rollout format is internal; a /resume inside Codex is missed; Claude usage needs a Pro or Max plan and a rendered status line), and a privacy note. configuration.md says state_dir is not a key, codex-as.md and README list the new queries, AGENTS.md extends the public contract, and CHANGELOG gains 0.3.0.
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.
What
v0.3.0, a minor release: each launcher keeps a small offline cache of what it last saw about every account. New queries print it without opening a credential:
codex-as --account-info NAME,claude-as --account-info NAME: the Codex email and plan, or the Claude label, plus the 5-hour and weekly usage with reset times and the snapshot's age (not recorded yetwhen absent).--account-labels:NAME<TAB>LABELlines. The zsh completions use them as descriptions; Bash still completes bare names.claude-as --set-label NAME [LABEL], and an optional label prompt when an account is created (refused: control characters, more than 100 characters, anything containingsk-ant-).Where the data comes from
The cache is
${XDG_STATE_HOME:-~/.local/state}/coding-agent-kit/accounts/. The directory is 0700 and each file 0600; files are replaced atomically and only on change. No token is stored.codex-NAME.jsonid_tokenat launch; after each run, the last rate-limit snapshot from the run's own rolloutsclaude-NAME.jsonclaude-NAME.usage.jsonhelpers/statusline.cjsrate_limits, only whileCLAUDE_CODE_OAUTH_TOKENhashes to theCODING_AGENT_KIT_TOKEN_IDclaude-as passedNew environment for the claude child:
CODING_AGENT_KIT_USAGE_FILEandCODING_AGENT_KIT_TOKEN_ID. Inherited values are dropped.Commits
test: model dotfiles' own coding-agent-kit package: the kit tests' dotfiles host follows the layout of dotfiles PR #4.feat: keep last-seen account details and print them offline: the cache module, the Codex identity and rollout scan, the Claude label and status-line recording, the queries, completions, tests and COVERAGE.docs: describe the account metadata cache for v0.3.0: CHANGELOG, account-launchers, configuration, codex-as, README, AGENTS.Review
An independent review found no Critical issue and two Important ones. Both are fixed in commit 2:
secrets_direqual to the cache directory made the first launch overwritecodex-NAME.json, because the cache file has the same name.secrets_dirthrough a link.--set-labeltests now run with unusable 0600 credentials. All five credential-read mutants fail them.Its minor findings are fixed too:
Verified (lab clones, temporary homes, fakes)
tests/run.sh --ciwith Python 3.15 and 3.11.17, andpre-commit run --all-files, on the tip and on each commit alone.recordUsage.Known limits
/resumeinside Codex and skips.jsonl.zstrollouts.After release
Two checks in a real session:
claude-assetup-token session's status line getsrate_limits, andclaude-NAME.usage.jsonappears.