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

pi-token-count

v0.1.2

Published

Pi extension that shows tokens, context usage, cost spent, and model/reasoning in the footer.

Downloads

479

Readme

pi-token-count

A focused Pi extension that replaces Pi's default footer with a pipe-separated footer that gives the current context token count its own field.

The footer shows current context tokens first, followed by percentage/context-window used, cost spent, and active model/reasoning as separate fields:

84,000 tok | 7.6%/1.1M used | $0.60 spent | gpt-5.5/high

Pi's other default footer information is still preserved where possible: cwd, git branch, session name, provider when needed, and extension status lines.

The current token count changes color based on a raw token threshold, not based on the context-window percentage:

  • dim/default: below the warning threshold
  • warning/yellow: at or above 75% of the dumb-zone token count by default
  • error/red: at or beyond the dumb-zone token count

By default, the dumb-zone token count is computed the same way Pi's auto-compaction threshold is computed:

contextWindow - compaction.reserveTokens

compaction.reserveTokens and compaction.enabled are read from Pi settings, including project overrides. You can also set an explicit raw dumb-zone token count for this extension.

Configuration

/dumb-zone command

Run the extension command from Pi's slash menu:

/dumb-zone

With no arguments, it prompts for where to save the setting and then asks for the raw token count where the dumb zone starts.

You can also set it directly:

/dumb-zone 160000
/dumb-zone project 160000
/dumb-zone global 160000
/dumb-zone project 160k
/dumb-zone global 1m

The command writes piTokenCount.dumbZoneStartTokens to either .pi/settings.json for the current project or ~/.pi/agent/settings.json globally.

Settings JSON

Use Pi's existing compaction settings when you want this extension to infer the dumb-zone boundary from the active model's context window:

{
  "compaction": {
    "enabled": true,
    "reserveTokens": 16384,
    "keepRecentTokens": 20000
  }
}

Or set an explicit raw token threshold for this extension manually:

{
  "piTokenCount": {
    "dumbZoneStartTokens": 160000,
    "warningRatio": 0.75
  }
}

With that config, the current-token field turns yellow at 120,000 tok and red at 160,000 tok, regardless of the selected model's context-window percentage.

Global settings live at ~/.pi/agent/settings.json; project settings live at .pi/settings.json. Project settings override global settings.

Behavior notes

  • This extension replaces the whole footer because Pi's extension API exposes footer replacement via ctx.ui.setFooter() rather than patching individual built-in footer fields.
  • The replacement footer intentionally mirrors Pi's default footer around the requested stats line: cwd, git branch, session name, model/provider, reasoning level, and extension status lines are preserved. Model and reasoning are combined at the end as model/reasoning.
  • Right after compaction, Pi may not know the current post-compaction token count until the next assistant response. In that case the footer shows ? tok.