Skip to content

feat: keep last-seen account details offline (v0.3.0) - #2

Merged
FridrichMethod merged 3 commits into
mainfrom
feat/account-info
Oct 21, 2026
Merged

FridrichMethod merged 3 commits into
mainfrom
feat/account-info

Conversation

@FridrichMethod

Copy link
Copy Markdown
Owner

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 yet when absent).
  • --account-labels: NAME<TAB>LABEL lines. 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 containing sk-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.

File Writer Content
codex-NAME.json codex-as email and plan from the id_token at launch; after each run, the last rate-limit snapshot from the run's own rollouts
claude-NAME.json claude-as the label
claude-NAME.usage.json helpers/statusline.cjs the session's rate_limits, only while CLAUDE_CODE_OAUTH_TOKEN hashes to the CODING_AGENT_KIT_TOKEN_ID claude-as passed

New environment for the claude child: CODING_AGENT_KIT_USAGE_FILE and CODING_AGENT_KIT_TOKEN_ID. Inherited values are dropped.

Commits

  1. test: model dotfiles' own coding-agent-kit package: the kit tests' dotfiles host follows the layout of dotfiles PR #4.
  2. 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.
  3. 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:

  • Credential overwrite. A secrets_dir equal to the cache directory made the first launch overwrite codex-NAME.json, because the cache file has the same name.
    • Now the loader refuses that configuration.
    • The cache directory is never read or written when it is secrets_dir through a link.
    • A lab probe through a linked ancestor reproduced the overwrite on the old code; the new tests catch it.
  • Missing "never opens a credential" tests. The query and --set-label tests now run with unusable 0600 credentials. All five credential-read mutants fail them.

Its minor findings are fixed too:

  • only regular rollouts are opened, so a FIFO no longer hangs the launcher;
  • a fork's source thread no longer counts;
  • other accounts' rollouts no longer use up the file budget (8 of this account's, after at most 64 others' first lines, resumed thread first);
  • the stored record is read just before it is replaced;
  • times from the year 10000 on are ignored instead of raising;
  • long account names now record Claude usage;
  • three doc overclaims are corrected.

Verified (lab clones, temporary homes, fakes)

  • tests/run.sh --ci with Python 3.15 and 3.11.17, and pre-commit run --all-files, on the tip and on each commit alone.
  • 16 targeted mutants of the review fixes, each failing its suite. Earlier mutation passes covered the cache, the scan and recordUsage.
  • Dotfiles PR-2 consumes this tip:
    • full checks and parity against PR #4;
    • a real fzf-tab preview in an interactive zsh.

Known limits

  • Codex usage depends on Codex's internal rollout format.
  • It misses a session switched with /resume inside Codex and skips .jsonl.zst rollouts.
  • It can miss this account's new session when more than 64 other rollouts were modified during the run.
  • It can count a thread this account created that another account resumed during the run.
  • Claude usage exists only for Pro/Max, after the first API response, in sessions that render a status line.

After release

Two checks in a real session:

  • A claude-as setup-token session's status line gets rate_limits, and claude-NAME.usage.json appears.
  • Codex rollouts record the 300-minute primary window.

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.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 12:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@FridrichMethod
FridrichMethod merged commit 081f54a into main Oct 21, 2026
3 checks passed
@FridrichMethod
FridrichMethod deleted the feat/account-info branch October 21, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants