pi-usage-bar-focus

AI subscription usage gauge for the pi coding agent — Claude Pro/Max and ChatGPT Plus/Pro quota bars with provider status (incident) alerts, in the footer. Model-aware fork.

Packages

Package details

extension

Install pi-usage-bar-focus from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-usage-bar-focus
Package
pi-usage-bar-focus
Version
0.5.0
Published
Jul 28, 2026
Downloads
1,288/mo · 713/wk
Author
sakiko233
License
MIT
Types
extension
Size
32.1 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-usage-bar-focus

npm · source

Fork of satas20/pi-usage-bar (MIT) that automatically follows the active model and shows only that model provider's quota.

An AI subscription usage gauge for the pi coding agent.

Shows how much of your coding-plan quota you've used and how long until it resets, in a status line at the bottom of the footer. Supports Claude Pro/Max, ChatGPT Plus/Pro (Codex), GitHub Copilot, the GLM coding plan (z.ai), and the Kimi coding plan. Providers are auto-detected from pi's auth store; there is no configuration file.

 ▓▓▓▓░░ 65% · 0h 11m

When the active provider reports multiple windows, all of them are shown:

 5h ▓▓▓▓░ 65% · 0h 11m 7d ▓░░░░ 19% · 1d 11h

During a vendor incident:

 ! ▓▓▓▓░░ 65% · 0h 11m
  • The strip follows /model and Ctrl+P switches immediately.
  • Bar color escalates with usage: green < 50%, amber 50–85%, red > 85%.
  • The countdown ticks live; usage refreshes every 2 minutes.
  • Every detected provider is polled, keeping its cache warm for instant model switches, while only the active provider is rendered.
  • Last known values are cached, so the bar appears instantly on restart.
  • An unmapped model or an active provider without credentials produces no bar.
  • Fetch errors appear as a red marker instead of crashing pi.
  • The ! status marker is red for critical/major incidents, amber for minor, accent for maintenance.

Install

pi install npm:pi-usage-bar-focus

To run the bleeding edge (every push to main), install the canary dist-tag instead — it never affects the default latest install above:

pi install npm:pi-usage-bar-focus@canary

Or add it manually to ~/.pi/agent/settings.json:

{
  "packages": ["npm:pi-usage-bar-focus"]
}

To try it without installing:

git clone https://github.com/SakikoTogawa233/pi-usage-bar-focus.git
pi -e ./pi-usage-bar-focus/extensions/index.ts

Configuration

There is no configuration file. Log in to the providers you use with pi's /login, then start or restart pi. At session start the extension detects credentials in ~/.pi/agent/auth.json and polls every detected provider. Existing ~/.pi/agent/usage-bar.json files from older versions are ignored and can be deleted.

The behavior is fixed:

  • Only the active model's provider is rendered.
  • Every non-reset quota window reported by that provider is shown.
  • Mini-bars and vendor incident markers are always enabled.
  • Bar width is 6 cells for one window and 5 cells for two or more windows.

Model matching uses the active model's provider and id: codex/openai/chatgpt → OpenAI, anthropic/claude → Anthropic, copilot → GitHub Copilot, kimi → Kimi, and zai/glm/zhipu/bigmodel → Z.ai. If no keyword matches (for example, a DeepSeek or custom model), the strip is hidden rather than falling back to other providers. It is also hidden when the matched provider has no credentials. /model and Ctrl+P changes re-render immediately from the warm cache.

Providers & data sources

Provider Credentials Usage endpoint Status endpoint Windows
anthropic pi's auth store (anthropic entry) api.anthropic.com/api/oauth/usage (what Claude Code's /usage uses) status.anthropic.com 5h session, 7d all-models, 7d per-model
openai pi's auth store (openai-codex entry) chatgpt.com/backend-api/wham/usage status.openai.com 5h session, 7d weekly
github-copilot pi's auth store (github-copilot entry) api.github.com/copilot_internal/user githubstatus.com monthly premium requests
zai pi's auth store (zai-coding-cn entry) api.z.ai/api/monitor/usage/quota/limit 5h session, 7d weekly, monthly tools
kimi pi's auth store (kimi-coding entry) api.kimi.com/coding/v1/usages plan-dependent (5h/7d/monthly)

If you log in through pi itself (/login), everything works with zero extra setup. The extension reads pi's own auth store (~/.pi/agent/auth.json), keyed by provider ID (anthropic, openai-codex, github-copilot, zai-coding-cn, kimi-coding). All credential access is read-only; any fetch error surfaces as a red marker in the strip rather than crashing the host.

Security note: each credential is read from pi's auth store and sent only to its own provider's API host, over HTTPS, to fetch usage numbers. Status pages are public Statuspage JSON endpoints fetched without any credentials. Nothing else is read, stored, or transmitted. The usage endpoints are undocumented/internal (the same ones the vendors' own tooling uses) and may change without notice.

Develop

npm install         # dev deps (typescript, pi types)
npm run typecheck   # tsc --noEmit
npm test            # mocked integration tests
pi -e ./extensions/index.ts       # run pi with your working copy

No build step — pi loads TypeScript extensions directly.

CI/CD & releases

.github/workflows/release.yml keeps this fork current with upstream and publishes automatically via npm trusted publishing (GitHub OIDC — no npm token stored anywhere):

  • Upstream sync (manual workflow_dispatch only — there is no schedule): fetches satas20/pi-usage-bar, and if it's ahead, merges it into main, restores the fork's package identity via scripts/release/brand.mjs (so upstream's package.json can't clobber the pi-usage-bar-focus identity or regress the version), runs npm run typecheck, bumps the patch version, tags vX.Y.Z, pushes, and publishes. A no-op when upstream isn't ahead.
  • Manual release: push a local v* tag — the same workflow typechecks and publishes it (skipping the sync).
  • Canary (continuous): every push to main publishes a prerelease <base>-canary.<sha>.<attempt> under the canary dist-tag via npm publish --tag canary. It never touches latest, creates no git tag, and pushes nothing back to main, so it can't promote to stable or retrigger itself. Install it with pi install npm:pi-usage-bar-focus@canary. latest is advanced only by the two paths above.
  • Conflicts: if upstream changes the same code lines as the model-aware patch, the merge is aborted and a GitHub issue is opened instead of publishing a broken build.

One-time setup on npmjs.com (package → Settings → Trusted Publisher): provider GitHub Actions, user SakikoTogawa233, repository pi-usage-bar-focus, workflow filename release.yml, environment blank, allowed action npm publish. Do not add an NPM_TOKEN secret to the repo.

Sibling project

Using opencode too? The same gauge exists as @satas/opencode-usage-bar.

Roadmap

  • Anthropic/OpenAI OAuth token auto-refresh (both credential files include a refresh token; for now the respective CLIs keep them fresh).

Requirements

Contributing

Contributions welcome — especially new providers (see the checklist in CONTRIBUTING.md). The whole extension is a single file with zero runtime dependencies.

License

MIT