npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@andre-barbosa/pi-codex-usage

v0.1.0

Published

Show ChatGPT plan usage limits in pi's footer when an OpenAI model is selected.

Readme

@andre-barbosa/pi-codex-usage

A pi package that shows your OpenAI Codex (ChatGPT plan) usage limits in the top-right of pi's footer whenever a Codex model (openai-codex provider) is selected — and hands the footer back to pi when you switch to any other provider.

Codex 5h 72% left (2h 13m) · week 44% left (5d 15h)

Percentages are colored by how much you have left (green / yellow / red). Snapshots older than 15 minutes are marked · stale — plan usage shifts whenever any of your sessions consumes quota, so old numbers can quietly become wrong.

Install

From npm

pi install npm:@andre-barbosa/pi-codex-usage

From git

pi install git:github.com/<you>/pi-codex-usage
# pinned tag:
pi install git:github.com/<you>/[email protected]

From a local checkout (development)

Add the extension entry to ~/.pi/agent/settings.json:

{
	"extensions": ["/absolute/path/to/pi-codex-usage/src"]
}

Then start pi and run /reload after making changes.

Managing

pi list                            # show installed packages
pi update --all                    # update pi + packages
pi update npm:pi-codex-usage       # just this one
pi remove npm:pi-codex-usage       # uninstall

Requirements

  • Signed in via /loginOpenAI Codex (ChatGPT subscription auth). API-key openai models have no plan windows and are ignored.
  • No runtime dependencies. Node >= 23.6 is only needed to run the test suite locally; pi's own runtime handles the extension.

What it shows

  • Primary window (usually 5 hours) and secondary window (usually weekly), labeled from the window duration the backend reports rather than hardcoded assumptions — on some plans the weekly window arrives in the primary slot.
  • Additional limit buckets (e.g. model-specific limits like codex_spark) when present.
  • Per-window reset countdowns, plus plan type, credits, data age, and the last error in /codex-usage.
  • Placeholder buckets reported by the backend (0% used, no duration, no reset time) are hidden instead of rendering as noise like 1m 100% left.

Commands

| Command | Description | | --- | --- | | /codex-usage | Open a detail panel with per-window bars, reset times, plan, credits | | /codex-usage refresh | Force a fresh fetch, then show the panel |

Display

The usage renders right-aligned on the footer's top line:

~/projects/x (main)     Codex 5h 72% left (2h 13m) · week 44% left (5d 15h)
↑1.2k ↓340 R980 CH95.2% $0.012 (sub) 18.3%/272k        gpt-5.6-sol • xhigh

While a Codex model is active, the extension owns the footer and reproduces everything from pi's built-in one: pwd/branch/session name, token + cache + cost stats, context %, model / thinking level, and other extensions' statuses. Switching to a non-Codex model restores the built-in footer automatically. Because it owns the footer, another extension calling setFooter would replace it (and vice versa).

Token/cost stats are recomputed on every render pass like the built-in footer; idle-time usage refreshes trigger an explicit re-render nudge.

How it gets data

Two sources, used together:

  1. Usage endpointGET <baseUrl>/wham/usage (or /api/codex/usage on non-ChatGPT hosts), the same endpoint the official Codex CLI uses (see rate_limit_resets.rs).
  2. Response headers — Codex responses carry x-codex-*-used-percent style headers, parsed exactly like rate_limits.rs in the official client. These are read opportunistically on every response so data stays fresh between endpoint fetches.

Authentication uses your existing pi OAuth credentials resolved through ctx.modelRegistry.getProviderAuth(); tokens are refreshed by pi and never logged or persisted by this extension.

Refresh triggers: session start, switching to a Codex model, and after each settled agent run — throttled to at most one fetch per 30 seconds. There is no background polling loop, so after 15 minutes idle the footer marks the numbers stale.

Troubleshooting

| Symptom | Likely cause / fix | | --- | --- | | Footer looks unchanged | A non-Codex model is selected, another extension replaced the footer, or you're not signed in via /login. | | Shows · stale | Last snapshot is >15 min old (idle period). Send a message or run /codex-usage refresh. | | Numbers look wrong | Check /codex-usage for last error: and updated Ns ago via …; compare with /status in the official Codex CLI. | | No footer in scripts / RPC | Non-TUI modes have no footer; only /codex-usage works there. |

Notes & limitations

  • The usage endpoint is internal and undocumented; if OpenAI changes it, header parsing keeps working as a fallback.
  • Values are "percent of window used" as reported by the backend; this extension displays the complement ("left").
  • Errors never surface as popups during normal use — check /codex-usage for the last error.

Development

npm install        # optional: types + editor support
npm test           # unit tests over parsing/formatting/client (no network)
npm run typecheck  # requires devDependencies installed

Run a single suite: node --test test/parse.test.ts

Layout:

src/
├── index.ts    # extension entry: events, footer, detail panel, command
├── client.ts   # endpoint URL building, JWT account-id extraction, fetch
├── parse.ts    # pure parsers: wham payload, x-codex-* headers, merge
├── format.ts   # pure formatting: labels, bars, colors, status groups
└── types.ts    # shared snapshot/window types
test/
├── fixtures/   # sample wham/usage payload
└── *.test.ts   # node:test suites

License

MIT