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

@porche/pi-usage

v0.3.5

Published

Pi Coding Agent extension for tracking session token usage, provider account limits, and historical local consumption.

Readme

Overview

pi-usage brings a native, Hermes-style /usage command to the Pi Coding Agent. It provides complete visibility into your token consumption without spending LLM tokens to query it.

Every time you run /usage, it displays:

  1. Live Session Token Usage: The exact tokens (input, output, and context window percentage) spent in your current active session.
  2. Provider Account Limits: The real-time remaining quota from your active provider's API (e.g., ChatGPT Plus 5-hour limits, GitHub Copilot monthly quotas, OpenRouter credits).
  3. Graceful Fallback: If your active provider (like Google Gemini) does not expose a public quota API, it automatically falls back to local historical usage computed directly from your Pi session files.

Installation

Install directly from GitHub into your Pi environment:

pi install git:github.com/aporcelli/pi-usage

After installation, reload your Pi session:

/reload

Commands

  • /usage Detects your active provider and displays session token usage and API limits for that provider.

  • /usage limits Checks account limits for the active provider only.

  • /usage Checks account limits for a specific provider. Supported providers: openai-codex, anthropic, github-copilot, openrouter.

  • /usage local Bypasses provider APIs completely and calculates historical token usage (24h, 7d, 30d) directly from your Pi session files.

How It Works Under the Hood

1. Smart Active Provider Inference

Pi extensions run synchronously in the UI. To accurately determine what model you are using (even if you just ran /model or resumed a session with --resume), the extension uses a robust fallback chain:

  1. Direct API: ctx.getModel()?.provider
  2. Context model: ctx.model?.provider
  3. Session History: Scans the session branch backwards for the last model_change event.
  4. Global Settings: defaultProvider from ~/.pi/agent/settings.json.

2. Pi-Native Authentication

The extension does not use hardcoded paths. It reads credentials natively from Pi:

  • Checks ~/.pi/agent/auth.json first (for OAuth tokens generated via Pi's /login or saved API keys).
  • Falls back to standard environment variables (e.g., ANTHROPIC_API_KEY, OPENROUTER_API_KEY, GITHUB_TOKEN/GH_TOKEN).
  • For GitHub Copilot, it also falls back to gh auth token automatically when available.

3. Portable Timezone Formatting

Reset times (e.g., "Resets: 15:00 on 12 May") are automatically localized. You can force a specific timezone by setting an environment variable. Resolution order:

  1. PI_USAGE_TZ environment variable (e.g., export PI_USAGE_TZ=America/Argentina/Buenos_Aires)
  2. TZ environment variable
  3. System runtime timezone (Intl.DateTimeFormat)
  4. UTC (fallback)

UI & UX

The terminal output uses specialized formatting:

  • Visual Progress Bars: [██████████░░░░] 60%
  • Traffic Light Indicators: 🟢 (>70% remaining), 🟡 (30-70% remaining), 🔴 (<30% remaining).
  • Absolute Countdowns: Clearly shows exactly when limits reset (in 2h 15m).

Troubleshooting

  • "No limits data" or "Unavailable": Ensure you have logged in via /login in Pi (for OAuth providers) or that your API keys are exported in your shell.
  • GitHub Copilot unavailable: run gh auth login (or export GITHUB_TOKEN) so /usage github-copilot can resolve a valid token fallback.
  • Wrong Reset Timezone: Export PI_USAGE_TZ in your shell profile.
  • "local usage unavailable": Verify that ~/.pi/agent/sessions exists and contains Pi session .jsonl files.

License

MIT