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

@ryan_nookpi/pi-extension-headroom

v0.1.2

Published

Headroom token compression for pi — compress large tool results via a local Headroom proxy to reclaim context window.

Readme

@ryan_nookpi/pi-extension-headroom

This extension reclaims context window in pi by compressing large tool results through a Headroom proxy before each LLM call.

Headroom runs locally, compresses only oversized toolResult payloads, and leaves your prompts, assistant turns, and tool-call metadata untouched. Compression is applied only when the proxy is online and the change passes strict alignment guards, so it never silently rewrites your conversation.

Install

pi install npm:@ryan_nookpi/pi-extension-headroom

You also need the Headroom proxy available on your machine:

pip install "headroom-ai[proxy]"

By default the extension auto-starts a local token-mode proxy (headroom proxy --mode token --no-cache) on http://127.0.0.1:8788 and leaves it running after pi exits.

How it works

  • Listens on the context event fired before each LLM call.
  • Skips entirely until context usage reaches the configured token threshold.
  • Sends an OpenAI-shaped copy of the conversation to the proxy's /v1/compress endpoint.
  • Applies the result only to large toolResult messages, preserving pi metadata (toolName, details, tool-call ids, images).
  • Rejects any response that changes message count, roles, tool-call ids, or non-candidate content.

Privacy

Compression sends conversation context to the proxy, so remote URLs are blocked by default. Only localhost/127.0.0.1/::1 are allowed unless you explicitly set PI_HEADROOM_ALLOW_REMOTE=1 for a proxy you trust.

Commands

  • /headroom — show current status and session stats.
  • /headroom on — enable compression and ensure the proxy is running.
  • /headroom off — disable compression for this session (the proxy keeps running).
  • /headroom health — check / start the proxy and report whether it is online.
  • /headroom stats — print the proxy's own /stats output.
  • /headroom-health — shortcut for /headroom health.

The footer shows a compact status (✓ Headroom -42% (12,345 saved)) once compression is applied.

Configuration

Settings are read at startup from ~/.pi/agent/headroom/settings.json. Values in this file override environment variables; environment variables remain supported as fallbacks.

Example:

{
  "minContextTokens": 10000,
  "minMessageChars": 1000
}

| Setting key | Env fallback | Default | Description | | --- | --- | --- | --- | | enabled | PI_HEADROOM_ENABLED | true | Enable compression on start. | | baseUrl (url also accepted) | PI_HEADROOM_URL (HEADROOM_URL / HEADROOM_BASE_URL also accepted) | http://127.0.0.1:8788 | Proxy base URL. | | allowRemote | PI_HEADROOM_ALLOW_REMOTE | false | Allow non-local proxy URLs. | | autoStart | PI_HEADROOM_AUTO_START | true | Auto-start a local persistent proxy when offline. | | command | PI_HEADROOM_COMMAND | headroom | Command used to launch the proxy. | | minContextTokens | PI_HEADROOM_MIN_CONTEXT_TOKENS | 20000 | Skip compression below this context token count. | | minMessageChars | PI_HEADROOM_MIN_MESSAGE_CHARS | 2000 | Only compress tool results at or above this size. | | timeoutMs | PI_HEADROOM_TIMEOUT_MS | 30000 | HTTP timeout for proxy requests. |

Boolean values accept JSON booleans, or strings such as 1/0, true/false, yes/no, on/off.