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

@destiner/pi-usage

v0.2.1

Published

/usage for pi: how much of each coding subscription is spent — Claude Code, Codex, Cursor, Copilot, OpenCode Go, Z.ai, OpenRouter

Readme

pi-usage

A pi extension that answers "how much of my coding subscriptions have I burned?" in one command, across every provider you're signed in to.

Claude Code (Max 20x)
  Session: 13% used, resets 12:59am
  Week:    74% used, resets Sat at 4:59am
  Fable:   68% used, resets Sat at 4:59am

Codex (Pro Lite)
  Week:   96% used, resets Thu at 8:26am
  Resets: 1 banked

GitHub Copilot (Individual)
  Chat:        0% used, resets Sep 1 at 12:00am
  Completions: 0% used, resets Sep 1 at 12:00am

OpenRouter (Pay as you go)
  Credits: $14.75 available

Install

pi install npm:@destiner/pi-usage

Use

/usage           # subscriptions you're signed in to
/usage refresh   # bypass the 60s cache
/usage all       # include the ones with no credentials, and why

Providers with no credentials on the machine are hidden, so the list stays short. Works in every pi mode: the TUI renders it in the transcript, RPC clients get it as a notification, and print/JSON modes write it to stderr.

Nothing is sent anywhere except each provider's own usage endpoint. Credentials are read from the places the vendors' own tools already put them, and never logged, copied, or persisted.

Providers

| Provider | Meters | Credentials, in order | |---|---|---| | Claude Code | Session, Week, model-scoped weekly limits (such as Fable) | pi's anthropic OAuth, then ~/.claude/.credentials.json (CLAUDE_CONFIG_DIR), then the macOS keychain | | Codex | Session, Week, banked resets | pi's openai-codex OAuth | | Cursor | Cycle | CURSOR_API_KEY, then the CLI's auth.json, then Cursor's state.vscdb, then the macOS keychain; CURSOR_SESSION_TOKEN overrides all of them | | GitHub Copilot | Credits, Chat, Completions | ~/.config/github-copilot/{apps,hosts}.json, then ~/.config/gh/hosts.yml, then pi's github-copilot credential | | OpenCode Go | Session, Week, Month | auth.json in OpenCode's data dir (OPENCODE_DATA_DIR, XDG_DATA_HOME), then pi's opencode-go key | | Z.ai (GLM Coding Plan) | Session, Week | ZAI_API_KEY, GLM_API_KEY, then pi's zai key | | OpenRouter | Credits | OPENROUTER_API_KEY, then pi's openrouter key |

Notes:

  • Cursor works without the desktop app: create a user API key (crsr_…) in the dashboard and export it as CURSOR_API_KEY. It is exchanged for a one-hour access token, which drives the same RPC the Cursor CLI uses. Otherwise the token comes from the CLI's auth.json or the desktop app's key/value store (read via node:sqlite, bun:sqlite, or the sqlite3 CLI) and is refreshed in memory when expired. CURSOR_SESSION_TOKEN (the dashboard's WorkosCursorSessionToken cookie) skips credential discovery entirely.
  • Claude Code on macOS keeps its credential in the login keychain and writes no .credentials.json at all, so the keychain is read when the file is missing.
  • Copilot needs the GitHub OAuth token that a Copilot editor plugin or Pi's Copilot login writes, not the short-lived Copilot API token. A generic gh auth login is only considered when Copilot is active or scoped in Pi, so a normal GitHub login does not imply a Copilot subscription. Org-managed seats report no per-seat quota, so the plan shows with no meters.
  • OpenRouter is prepaid credits rather than a plan: Credits shows the remaining balance. Lifetime spend, percentage used, and per-key caps are intentionally omitted.

Meters are percentages where a denominator exists; meters without one show the figure instead.

Not covered: Grok and Antigravity (their usage APIs need a protobuf-JSON decoder and a loopback language server respectively), Cursor on-demand spend, and Copilot overage counts.

Caveats

These are the same subscription/backend endpoints the vendors' own apps call. Most are undocumented and can change without notice — if a provider starts reporting an error, that is the first thing to check. Only Claude Code, Codex, and GitHub Copilot have been exercised against live accounts; the rest are verified against captured payloads plus each endpoint's live unauthenticated response.

Development

npm install
npm test         # offline: fetch is stubbed, credentials are planted in a temp HOME
npm run typecheck

On Node 22.x, run the tests as node --experimental-strip-types test.ts.

License

MIT