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-context-usage

v0.4.1

Published

Pi extension that shows context window usage visualization

Readme

pi-context-usage

A pi extension package that adds:

  • /context — a dot-grid visualization of current context usage
  • /context details — a deeper breakdown of system prompt, active tools, and conversation turns
  • /release <major|minor|patch> — the repository release workflow

Usage

Context summary

/context

Shows a dot-grid summary with five breakdown categories:

Context Usage

◍ ⚙ ● ● ● ● ● ● ● ● ●
● ● ● ● · · · · · · ·
· · · · · · · · · · ·
· · · · · · · · · · ·
· · · · · · · · · · ·
· · · · · · · · · · ·
· · · · · · · · · · ·
· · · · · · ○ ○ ○ ○ ○

claude-sonnet-4-5   31.4k / 200.0k tokens (16%)

◍ System Prompt:    1.7k (1%)
⚙ Tools:              275 (0%)
● Messages:        29.4k (15%)
· Empty:           152.2k (76%)
○ Buffer:           16.4k (8%)

Context details

/context details

When UI is available, this opens a keyboard-driven overlay that keeps the grid summary at the top and adds expandable sections for:

  • System Prompt — visible system prompt token estimate from ctx.getSystemPrompt()
  • Tools — active tool breakdown from pi.getAllTools() filtered by pi.getActiveTools()
  • Conversation — one line per user turn, plus inline compaction summaries and per-message drill-down

Keyboard shortcuts in the overlay:

  • ↑/↓ move focus
  • Enter or expand a section/row
  • collapse a section/row
  • Tab jump between top-level sections
  • PageUp/PageDown, Home/End scroll faster
  • Esc or q close

When UI is not available, /context details falls back to a plain-text dump.

Example plain-text output:

System / Tools Details

Item                Tokens  Chars
System prompt         6.2k  24,800
read                    70     279
bash                    61     244
edit                   142     567
Total visible parts    6.5k  25,890

Note: visible parts sum to 2.2k tokens, while the top summary uses 14.3k cached prompt tokens from the last assistant cache. That cache number includes provider-side scaffolding and cached context that extensions cannot inspect.

Conversation (6 turns)
Per-turn and cumulative values are visible-entry estimates from estimateTokens(message); they will not match the summary's provider/cache totals.

 #1  10:00  U  Can you inspect the repo and summarize how /context currently works?      55      55 cum est
 #2  10:01  U  Now sketch a plan for a /context details mode with a deeper breakdown.      36      91 cum est
  Σ  10:06  Σ  Earlier discussion established the design…      38     197 cum est
 #3  10:10  U  Add the system prompt and active-tools breakdown next.      65     262 cum est

Install

As a pi package

pi install git:github.com/championswimmer/pi-context-usage

Manual (project-local)

Copy or symlink this directory into .pi/extensions/pi-context-usage/.

Development

# Load extension directly into a live pi session
pi -e ./src/index.ts

# After sending at least one message
/context
/context details

# Standalone mock tests
bun run test:mock
bun run test:mock-details

How it works

Summary buckets

| Category | Symbol | Theme color | Token source | |--------------|--------|-------------|--------------| | System Prompt | | accent | Math.ceil(systemPrompt.length / 4) — estimated from visible system prompt text | | Tools | | muted | Sum of Math.ceil((name + description + JSON.stringify(parameters)).length / 4) over active tools | | Messages | | success | usedTokens - systemPromptTokens - toolTokens — conversation entries | | Empty | · | dim | contextWindow - usedTokens - bufferTokens — unused space | | Buffer | | warning | model.maxTokens — reserved for model output |

All visible estimates use a chars / 4 heuristic. The grid distributes cells proportionally across the five categories.

Details view estimates

  • System prompt tokens: Math.ceil(systemPrompt.length / 4)
  • Per-tool tokens: Math.ceil((name + description).length / 4) + Math.ceil(JSON.stringify(parameters).length / 4)
  • Turn tokens: summed via pi's exported estimateTokens(message) heuristic

Because pi does not expose the exact provider-serialized request payload, the visible system prompt + tools total is intentionally labeled as an approximation. The cache-provided number in details remains the authoritative cached-prompt value, and it is not directly comparable to the visible estimates.

Release automation

/release patch
/release minor
/release major

The /release command will:

  • verify the git working tree is clean
  • run npm run test:mock
  • bump package.json and package-lock.json
  • create a release: vX.Y.Z commit
  • publish to npm
  • create a vX.Y.Z git tag
  • push the branch and tag to GitHub

Prerequisites:

  • you are on the branch you want to release from
  • you can push to the repository remote
  • npm whoami succeeds for an account that can publish pi-context-usage

Release skill

This package also ships a release skill that teaches pi when and how to use the repo's release flow. If the skill is loaded manually, it will direct the agent to prefer:

/release major|minor|patch