Skip to content

feat(pi): show which Codex authentication store the Pi session uses - #13

Merged
doitdigital0495 merged 2 commits into
mainfrom
fm/firstmate-pi-codex-account-visibility-publish-2026-09-09
Sep 9, 2026
Merged

doitdigital0495 merged 2 commits into
mainfrom
fm/firstmate-pi-codex-account-visibility-publish-2026-09-09

Conversation

@doitdigital0495

Copy link
Copy Markdown
Owner

Intent

Publish the completed Firstmate Pi active-Codex-account indicator so Pi visibly names which Codex authentication store the running session actually uses.

Background and constraints:

  • Two Pi homes exist on this machine. The personal home resolves to ~/.pi/agent and the Geris home resolves to ~/.pi-geris/agent. Pi's footer already shows quota, model, and provider, but nothing said which Codex login the session spends, so the two homes looked identical on screen. This indicator closes that gap.
  • Identity must come from the active authentication store only. It is never inferred from model selection, shell context, environment convention, or the directory name alone. getAgentDir() resolves the agent directory the process authenticates from, and ModelRegistry.getProviderAuthStatus reports whether a credential is configured and which surface supplied it. A store is named only when Pi reports the credential source as 'stored'.
  • Unknown or mismatched state must be explicit rather than guessed. A credential from the environment or runtime belongs to another account and renders codex@unverified(); a store with no login renders codex@unverified(no-login); a store whose path is not plainly path-shaped renders codex@unknown instead of being sanitized into something that reads like a real store. An unavailable auth status is treated as missing evidence, never as a signed-in account.
  • Hard security requirement: never display or log tokens, email addresses, credential content, or any secret-derived identifier. The extension reads no access token, no refresh token, no stored credential, no account id, and no address. It names a store, never a person. The regression suite enforces this two ways: the fake registry raises from every credential-bearing Pi API, and the resolved store holds an unreadable credential file, so any run that reached for either would fail rather than pass quietly.
  • Deliberate surface decision: a footer status via ctx.ui.setStatus() was chosen over a widget. Pi sorts extension statuses by key on their own footer line beneath the token/cost/context row, so the indicator is on screen exactly as long as the quota display is and changes none of its numbers or layout. A widget was rejected because Pi orders widgets by unsorted directory load order and caps the widget area at ten lines, so a second widget could land above or below the quota block from one run to the next.
  • Pi exposes no login or logout event, so the status refreshes on session_start, model_select, and turn_start, which bracket every way the credential can change under a running session.
  • Existing Pi behavior outside this indicator must be preserved. The extension is additive and no-ops when there is no UI.
  • Tests and documentation are deliberately kept proportionate: one behavioral regression suite, one operator doc (docs/pi-account-indicator.md), and the required Firstmate maintainer-verification evidence (docs/verification/pi-account-indicator.md), registered in docs/documentation-audiences.json and wired into bin/fm-test-run.sh.
  • Verified live on Pi 0.84.4 for both stores.

How this branch was produced: the feature was already completed and reviewed as clean source commit 418096f95825fb964e8459ecf49c9f70efdc55d5. This task cherry-picked that exact commit onto the current default-branch head, confirmed it applied cleanly with a byte-identical diff, and deliberately did NOT recreate or broaden the feature. No compatibility fix was required, so there are no additional commits. Pre-pipeline checks run locally: tests/fm-codex-account-pi-extension.test.sh (6/6 pass), tests/fm-documentation-audiences.test.sh (4/4 pass), bin/fm-lint.sh (clean). tests/fm-pi-primary-types.test.sh skipped because tsc is not installed in this worktree.

The publication target is the captain's fork doitdigital0495/firstmate, not upstream kunchenguid/firstmate.

What Changed

  • Added the .pi/extensions/fm-codex-account.ts Pi extension, which resolves the active agent directory via getAgentDir() and reads ModelRegistry.getProviderAuthStatus to publish a ctx.ui.setStatus() footer entry naming the Codex store in use. A store is named only when the credential source is stored; an environment or runtime credential renders codex@unverified(<source>), a store with no login renders codex@unverified(no-login), a non-path-shaped store renders codex@unknown, and an unavailable auth status is treated as missing evidence. The status refreshes on session_start, model_select, and turn_start, and the extension no-ops when there is no UI.
  • Added tests/fm-codex-account-pi-extension.test.sh, a regression suite whose fake registry raises from every credential-bearing Pi API and whose resolved store holds an unreadable credential file, so any read of a token, address, or account id fails the run instead of passing quietly. Wired the suite into bin/fm-test-run.sh and added the extension to tests/fm-pi-primary-types.test.sh.
  • Added the operator doc docs/pi-account-indicator.md and maintainer-verification evidence docs/verification/pi-account-indicator.md, registered both in docs/documentation-audiences.json, and linked the operator doc from the README.md index.

Risk Assessment

✅ Low: Purely additive, UI-only indicator with a behavioral regression suite that executes the real extension against the installed Pi package; it reads no credentials, changes no existing Pi behavior, and every intent constraint (store-only identity, explicit unverified/unknown states, three refresh events, no-UI no-op, docs plus verification wiring) is satisfied in source.

Testing

Ran the focused regression suite for the indicator against the real installed Pi package (all checks pass, including the secret-safety assertions where the fake registry raises from every credential-bearing API and the resolved store holds an unreadable auth.json), plus the documentation-audiences suite and the test-runner coverage/lane checks proving the new suite is wired in. For end-user evidence I launched the real Pi TUI twice under tmux at 200 columns with --no-session, once against the default agent home and once with PI_CODING_AGENT_DIR pointed at the Geris home, and captured the footer: the two homes render codex@.pi and codex@.pi-geris on their own line beneath an unchanged token/cost/context/model row. Account emails printed by the pre-existing quota widget were redacted in the saved captures; the indicator renders none itself. The only failure anywhere is a pre-existing type error in the untouched fm-calm.ts, visible only when tsc is supplied manually.

Evidence: Live Pi footer for both Codex stores (redacted transcript)

Source: Live Pi footer for both Codex stores (redacted transcript)

# Live Pi footer: Codex credential-store indicator

Captured 2026-09-09 on the installed Pi 0.84.4, in tmux at 200 columns, from the
worktree under test, with `--no-session` so no session file was written.
Account emails visible in the pre-existing quota widget are redacted here; the
indicator itself never renders them.

Full pane captures: `pi-footer-personal.txt`, `pi-footer-geris.txt`.

## Personal store (default agent directory, `~/.pi/agent`)

`` `sh
pi --no-session -e .pi/extensions/fm-codex-account.ts
`` `

`` `text
 cl personal                   5h ●○○○○○○○  10%  (4h 29m)                │ 7d ●●○○○○○○  20%  (14.6%/d) (Mon 19:59)
 cl geris                      5h ●●○○○○○○  26%  (4h 29m)                │ 7d ●○○○○○○○  17%  (13.6%/d) (Tue 10:59)
 cx <redacted-account-email>   5h --                                     │ 7d ●○○○○○○○  12%  (15.1%/d) (Tue 04:07)
 cx <redacted-account-email>   5h ●●●○○○○○  39%  (4h 39m)                │ 7d ●○○○○○○○  11%  (14.7%/d) (Tue 09:55)
~/.no-mistakes/worktrees/cf62ac6bfd91/01M22CXN69KHH8ECW387N9AHVF (detached)
$0.000 (sub) 0.0%/272k (auto)                                    (openai-codex) gpt-5.5 • medium
codex@.pi
`` `

## Geris store (`PI_CODING_AGENT_DIR=~/.pi-geris/agent`)

`` `sh
PI_CODING_AGENT_DIR=~/.pi-geris/agent pi --no-session -e .pi/extensions/fm-codex-account.ts
`` `

`` `text
 cl personal                   5h ●○○○○○○○  10%  (4h 29m)                │ 7d ●●○○○○○○  20%  (14.6%/d) (Mon 19:59)
 cl geris                      5h ●●○○○○○○  26%  (4h 29m)                │ 7d ●○○○○○○○  17%  (13.6%/d) (Tue 10:59)
 cx <redacted-account-email>   5h --                                     │ 7d ●○○○○○○○  12%  (15.1%/d) (Tue 04:07)
 cx <redacted-account-email>   5h ●●●○○○○○  39%  (4h 38m)                │ 7d ●○○○○○○○  11%  (14.7%/d) (Tue 09:55)
~/.no-mistakes/worktrees/cf62ac6bfd91/01M22CXN69KHH8ECW387N9AHVF (detached)
$0.000 (sub) 0.0%/272k (auto)                                                   gpt-5.5 • medium
codex@.pi-geris
`` `

The two homes render distinct labels on their own footer line beneath the
token/cost/context/model row, and the quota block above is unchanged in both
runs. The second run also shows the label following the credential store rather
than the model: Pi reported no provider tag there and the store was still named.
Evidence: Full tmux pane capture - personal store

Source: Full tmux pane capture - personal store

[Skills]
  1password, adhd, ads-creative-development, ads-performance-analytics, afk, after-action-report, agent-skills-guide, ahoy, analytics-strategy, ask-user-authority, bearings, beta-program-management,
bootstrap-diagnostics, brand-identity, brand-style-guide, brand-voice, captain-hold-lifecycle, cold-outreach, competitor-experience-audit, content-and-copy, content-distribution, content-repurposing,
content-strategy, conversion-first-design, convex-create-component, convex-migration-helper, convex-patterns, convex-performance-audit, convex-quickstart, convex-setup-auth, copywriting,
cro-optimization, decision-hold-lifecycle, deep-site-audit, diagnostic-reasoning, discovery-research-synthesis, editorial-qa, email-deliverability, email-sequences, experiment-design,
feature-launch-playbook, find-skills, firstmate-codexapp, firstmate-coding-guidelines, firstmate-orca, five-whys, fmx-respond, form-strategy, funnel-flow-architecture, google-ads-build,
google-ads-manager, growth-hq, handoff, harness-adapters, journey-mapping, jtbd-framing, landing-page-copy, lavish, lead-magnet-design, linear-deliver, nextjs-15, no-mistakes, okr-design,
openai-agent-sdk-skill, outrank-competitor, paid-media-strategy, pm-spec-writing, process-event-sources, project-management, quota-array-dispatch, react-bits, remotion-best-practices,
roadmap-planning, secondmate-provisioning, seo-decisions, ship, stakeholder-communication, stow, structure-agent-docs, stuck-crewmate-recovery, team-onboarding-playbook, treehouse-worktree-cleanup,
updatefirstmate, user-feedback-aggregation, validate-model-ladder, vendor-evaluation, vision, vps-deploy, web-design-guidelines
[Extensions]
  fm-calm.ts, fm-codex-account.ts, fm-primary-pi-watch.ts, fm-primary-turnend-guard.ts, herdr-agent-state.ts, rtk-compact.ts, sys-quota-status.ts
[Skill conflicts]
  "no-mistakes" collision:
    ✓ user ~/.claude/skills/no-mistakes/SKILL.md
    ✗ ~/.agents/skills/no-mistakes/SKILL.md (skipped)
 Warning: tmux extended-keys is off. Modified Enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Update Available
 New version 0.85.1 is available. Run pi update
 Changelog: https://pi.dev/changelog
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 cl personal                   5h ●○○○○○○○  10%  (4h 30m)                │ 7d ●●○○○○○○  20%  (14.6%/d) (Mon 20:00)
 cl geris                      5h ●●○○○○○○  26%  (4h 30m)                │ 7d ●○○○○○○○  17%  (13.6%/d) (Tue 11:00)
 cx <redacted-account-email>  5h --                                     │ 7d ●○○○○○○○  12%  (15.1%/d) (Tue 04:07)
 cx <redacted-account-email>        5h ●●●○○○○○  39%  (4h 39m)                │ 7d ●○○○○○○○  11%  (14.7%/d) (Tue 09:55)  │ CPU 41% RAM 14.9/23.5G
~/.no-mistakes/worktrees/cf62ac6bfd91/01M22CXN69KHH8ECW387N9AHVF (detached)
$0.000 (sub) 0.0%/272k (auto)                                                                                                                                            (openai-codex) gpt-5.5 • medium
codex@.pi
Evidence: Full tmux pane capture - Geris store

Source: Full tmux pane capture - Geris store

[Skills]
  1password, adhd, ads-creative-development, ads-performance-analytics, afk, after-action-report, agent-skills-guide, ahoy, analytics-strategy, ask-user-authority, bearings, beta-program-management,
bootstrap-diagnostics, brand-identity, brand-style-guide, brand-voice, captain-hold-lifecycle, cold-outreach, competitor-experience-audit, content-and-copy, content-distribution, content-repurposing,
content-strategy, conversion-first-design, convex-create-component, convex-migration-helper, convex-patterns, convex-performance-audit, convex-quickstart, convex-setup-auth, copywriting,
cro-optimization, decision-hold-lifecycle, deep-site-audit, diagnostic-reasoning, discovery-research-synthesis, editorial-qa, email-deliverability, email-sequences, experiment-design,
feature-launch-playbook, find-skills, firstmate-codexapp, firstmate-coding-guidelines, firstmate-orca, five-whys, fmx-respond, form-strategy, funnel-flow-architecture, google-ads-build,
google-ads-manager, growth-hq, handoff, harness-adapters, journey-mapping, jtbd-framing, landing-page-copy, lavish, lead-magnet-design, linear-deliver, nextjs-15, no-mistakes, okr-design,
openai-agent-sdk-skill, outrank-competitor, paid-media-strategy, pm-spec-writing, process-event-sources, project-management, quota-array-dispatch, react-bits, remotion-best-practices,
roadmap-planning, secondmate-provisioning, seo-decisions, ship, stakeholder-communication, stow, structure-agent-docs, stuck-crewmate-recovery, team-onboarding-playbook, treehouse-worktree-cleanup,
updatefirstmate, user-feedback-aggregation, validate-model-ladder, vendor-evaluation, vision, vps-deploy, web-design-guidelines
[Extensions]
  fm-calm.ts, fm-codex-account.ts, fm-primary-pi-watch.ts, fm-primary-turnend-guard.ts, herdr-agent-state.ts, rtk-compact.ts, sys-quota-status.ts
[Skill conflicts]
  "no-mistakes" collision:
    ✓ user ~/.claude/skills/no-mistakes/SKILL.md
    ✗ ~/.agents/skills/no-mistakes/SKILL.md (skipped)
 Warning: tmux extended-keys is off. Modified Enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Update Available
 New version 0.85.1 is available. Run pi update
 Changelog: https://pi.dev/changelog
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 cl personal                   5h ●○○○○○○○  10%  (4h 29m)                │ 7d ●●○○○○○○  20%  (14.6%/d) (Mon 19:59)
 cl geris                      5h ●●○○○○○○  26%  (4h 29m)                │ 7d ●○○○○○○○  17%  (13.6%/d) (Tue 10:59)
 cx <redacted-account-email>  5h --                                     │ 7d ●○○○○○○○  12%  (15.1%/d) (Tue 04:07)
 cx <redacted-account-email>        5h ●●●○○○○○  39%  (4h 38m)                │ 7d ●○○○○○○○  11%  (14.7%/d) (Tue 09:55)  │ CPU 31% RAM 12.8/23.5G
~/.no-mistakes/worktrees/cf62ac6bfd91/01M22CXN69KHH8ECW387N9AHVF (detached)
$0.000 (sub) 0.0%/272k (auto)                                                                                                                                                           gpt-5.5 • medium
codex@.pi-geris
Evidence: Footer lines side by side
personal: $0.000 (sub) 0.0%/272k (auto) (openai-codex) gpt-5.5 - medium
codex@.pi
geris: $0.000 (sub) 0.0%/272k (auto) gpt-5.5 - medium
codex@.pi-geris
- Outcome: ⚠️ 1 warning across 1 run (4m41s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ .pi/extensions/fm-codex-account.ts:77 - An unavailable auth status (getProviderAuthStatus throws, or returns undefined) falls into the same branch as a configured=false store and renders codex@unverified(no-login). That satisfies the intent's "never as a signed-in account" rule, but docs/pi-account-indicator.md:13 states that no-login "means the store holds no Codex credential", which is not what happened in the throw case. Tradeoff noted only; distinguishing it (e.g. unverified(unavailable)) would change user-visible output, so it is the author's call.
  • ℹ️ .pi/extensions/fm-codex-account.ts:37 - SAFE_LABEL caps the label at 64 characters, so a perfectly path-shaped absolute store outside the home that is longer than 64 chars (e.g. a deep scratch or worktree agent dir) renders codex@unknown, while docs/pi-account-indicator.md:11 promises "A store outside the home directory is named by its absolute path instead." Degraded rather than wrong (it never borrows another store's label), and unreachable for the two named homes, but the doc and the cap disagree.
⚠️ **Test** - 1 warning
  • ⚠️ .pi/extensions/fm-calm.ts:426 - Pre-existing and unrelated to this change: tests/fm-pi-primary-types.test.sh skips locally because tsc is not installed; run with an npx-provided tsc 5.x it fails on untouched .pi/extensions/fm-calm.ts (fm-calm.ts(426,57): error TS2345: Argument of type '(data: string) => void' is not assignable to parameter of type 'TerminalInputHandler'). The new extension fm-codex-account.ts type-checks clean under the same strict config. Fixing fm-calm.ts is outside this change's named scope.
  • bash tests/fm-codex-account-pi-extension.test.sh (5 checks, ok against Pi 0.84.4)
  • bash tests/fm-documentation-audiences.test.sh (4 checks)
  • bin/fm-test-run.sh --check-coverage and bin/fm-test-run.sh --list --lane portable-serial | grep fm-codex-account
  • bash tests/fm-pi-primary-types.test.sh (skips: no tsc) plus a strict tsc --noEmit of .pi/extensions/fm-codex-account.ts alone against the installed Pi declarations (clean)
  • Manual live run: tmux new-session -x 200 -y 40 &#39;pi --no-session -e .pi/extensions/fm-codex-account.ts&#39; + tmux capture-pane -> footer line codex@.pi
  • Manual live run: PI_CODING_AGENT_DIR=~/.pi-geris/agent pi --no-session -e .pi/extensions/fm-codex-account.ts under tmux -> footer line codex@.pi-geris
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…s from

Pi's footer already carries the quota figures for every subscription, but
nothing on screen said which Codex login the running session actually spends.
With two Pi homes on this machine, that left the quota block readable and the
account behind it a guess: the personal home and the Geris home render the same
model, the same provider, and the same numbers.

.pi/extensions/fm-codex-account.ts publishes one always-visible footer status,
"codex@.pi" or "codex@.pi-geris", naming the agent directory this process
authenticates from. Pi renders every extension status on its own footer line
below the token, cost, context, and model row, so the indicator is on screen for
exactly as long as the quota display is and changes none of its numbers or
layout. A widget was the wrong surface: Pi orders widgets by unsorted directory
order and caps the widget area at ten lines, so a second one could land above or
below the quota block from one run to the next.

Identity comes from the runtime, not from convention. getAgentDir() is Pi's own
resolver for the directory it reads its credential from, and
ModelRegistry.getProviderAuthStatus reports whether a credential is configured
and which surface supplied it. A store is named only when Pi reports the
credential as the stored one; a credential from the environment or the runtime
belongs to some other account, so those render codex@unverified(<source>), a
store with no login renders codex@unverified(no-login), and a store whose path
is not plainly path-shaped renders codex@unknown rather than being cleaned up
into something that reads like a real store.

Nothing credential-bearing is touched. The extension reads no access token, no
refresh token, no stored credential, no account id, and no address, and it
displays none of them, so it names a store and never a person. The regression
suite asserts that two ways that fail for different reasons: the fake registry
raises from every credential-bearing Pi API, and the resolved store holds an
unreadable credential file, so a run that reached for either would fail rather
than pass quietly.

Verified live on Pi 0.84.4 for both stores, with the evidence and the surface
facts recorded in docs/verification/pi-account-indicator.md.
@doitdigital0495
doitdigital0495 merged commit fba7773 into main Sep 9, 2026
13 checks passed
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