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

@mrclrchtr/supi-context

v4.6.0

Published

Live context pressure and token-use reports

Readme

@mrclrchtr/supi-context — Context Window and Token Usage Monitor for Pi

Adds context window and token usage monitoring to the Pi coding agent.

Install

pi install npm:@mrclrchtr/supi-context

For local development:

pi install ./packages/supi-context

Two concepts, two surfaces

  • A Context Pressure Snapshot is a small point-in-time capacity reading for deciding whether a session has room for another operation.
  • A Context Usage Report is a diagnostic account of where the session's context is spent.

Human: Context Usage Report

In interactive TUI mode, pi gets these commands:

  • /supi-context — render a report with guideline and tool previews
  • /supi-context full — render the same report with complete guideline and tool lists

The command appends a durable supi-context custom entry and uses a dedicated entry renderer. The report remains in the transcript but never enters LLM context.

Agent: Context Pressure Snapshot

supi_context is agent-callable when enabled in configuration. It defaults to a one-line, constant-shape JSON Context Pressure Snapshot:

interface ContextPressureSnapshot {
  modelName: string;
  contextWindow: number | null;
  usedTokens: number;
  usagePercent: number | null;
  compactionEnabled: boolean;
  reserveTokens: number;
  headroomTokens: number | null;
  pressurePercent: number | null;
  compacted: boolean;
  approximationNote: string | null;
}

Use supi_context({ mode: "full" }) only when diagnostic attribution is needed. Full mode returns compact JSON for the Context Usage Report. If it exceeds Pi's normal tool-output limits, it returns a small valid-JSON envelope with the path to a temporary file containing the complete report.

The tool TUI never shows raw agent JSON: concise results render as a dense snapshot that expands into its metrics; full results expand into the diagnostic report.

What the report shows

The Context Usage Report includes:

  • model name, context-window size, used tokens, usage percentage, pressure percentage, and Headroom
  • the effective Compaction reserve and factual presence of compaction on the active branch
  • approximation or pending-usage notes when exact usage is not available
  • a visual usage bar and attribution-category breakdown for system prompt, messages, tool calls, tool results, and other context
  • system-prompt composition, instruction/context files, skills, guideline sources, tool definitions, injected files, and registered provider sections

Configuration

The human /supi-context command needs no configuration.

To enable the agent-callable supi_context tool, set agentToolEnabled to true in your supi config:

{
  "supi-context": {
    "agentToolEnabled": true
  }
}

Or toggle it via /supi-settingsContextAgent Tool, then /reload.

The tool is disabled by default and requires a /reload or restart after toggling.

Notes

  • The extension caches the latest systemPromptOptions from before_agent_start. If those are missing or incomplete, it backfills context files and skills from the current system prompt.
  • Exact usage comes from Pi's current context-usage data when available. Otherwise the extension estimates usage and preserves an approximation note.
  • The Active Context Limit is the auto-compaction threshold while auto-compaction is enabled, otherwise the raw model context window. Headroom and pressure use that limit.

Source

  • src/context.ts — surface registration and cached prompt-option handling
  • src/capacity.ts — shared capacity analysis and snapshot shape
  • src/analysis.ts — diagnostic attribution and report data assembly
  • src/entry-renderer.ts — TUI-only custom-entry renderer for the human command
  • src/format*.ts and src/report-component.ts — Context Usage Report rendering
  • src/snapshot-component.ts — compact, width-safe snapshot rendering
  • src/tool/guidance.ts, src/tool/output.ts, and src/tool/render.ts — agent-tool guidance, safe full JSON output, and tool rendering

Tests live under __tests__/unit/.