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

@ashutoshsinghpr7/opencode-headroom

v1.0.0

Published

OpenCode plugin that compresses tool outputs in real-time — strip progress noise, deduplicate lines, truncate large outputs, and track token savings in the TUI

Readme

opencode-headroom

Real-time tool output compression for OpenCode — strip progress noise, deduplicate lines, truncate large outputs, and track token savings directly in the TUI.

Inspired by headroom-desktop, but works natively inside OpenCode's plugin system — no proxy, no external runtime, zero host pollution.

How it works

Headroom hooks into every tool execution (bash, read, grep, glob, webfetch) via OpenCode's plugin hooks and applies three compression strategies before the output enters the context window:

| Strategy | What it does | Applied to | | --------------------------- | --------------------------------------------------------------------------- | ---------------- | | Strip progress noise | Removes progress bars, spinners, download percentages, build progress lines | bash output | | Deduplicate lines | Collapses repeated lines (e.g. identical grep results) into one | bash, grep, glob | | Summarize large outputs | Truncates 100+/500+ line outputs, keeping head + tail + sample | all tools |

Everything runs locally in-memory — no external services, no API calls, no data leaves your machine.

Installation

opencode plugin opencode-headroom --global

Or add to your opencode.json manually:

{
  "plugin": ["opencode-headroom"]
}

Local plugins are also auto-loaded from .opencode/plugins/ or ~/.config/opencode/plugins/.

Dependencies

Headroom requires these peer dependencies:

  • @opencode-ai/plugin — core plugin API
  • @opentui/core / @opentui/solid — for the sidebar TUI panel
  • solid-js — for reactive UI rendering

If you're using the project-local approach, add them to your .opencode/package.json:

{
  "dependencies": {
    "@opencode-ai/plugin": ">=1.4.3",
    "@opentui/core": ">=0.4.0",
    "@opentui/solid": ">=0.4.0",
    "solid-js": ">=1.0.0",
    "opencode-headroom": "*"
  }
}

Features

Tool output compression

  • bash: strips progress noise → deduplicates lines → summarizes if >100 lines
  • read: summarizes large file reads (>100 lines) keeping head and tail
  • grep / glob: deduplicates repeated lines
  • webfetch: summarizes fetched content

TUI integration

  • Sidebar panel: persistent stats in the right panel showing tokens saved, compressions, timing breakdowns, and performance verdict (reactive, updates every 2s)
  • Periodic toasts: every 5 compressions, shows total tokens saved + avg time per compression
  • Session summary: when OpenCode goes idle, shows total savings with performance verdict
  • Manual stats: type /headroom-stats to see live stats at any point

Configuration

To enable the sidebar panel, add headroom to your tui.json:

{
  "plugin": ["opencode-headroom"]
}

Performance tracking

Headroom measures and reports its own performance impact:

| Verdict | Total compression time | Impact | | -------------- | ---------------------- | ----------------------------- | | Negligible | < 100 ms | Immeasurable | | Minimal | < 500 ms | Barely noticeable | | Moderate | < 2,000 ms | Might add slight latency | | Noticeable | ≥ 2,000 ms | Consider adjusting thresholds |

In practice, average compression takes ~138 µs (microseconds). Even 1,000 compressions only use ~138ms total across the entire session.

Performance benchmarks

Tested on MacBook Pro M1 (Node.js v24.11), 10,000 iterations each:

| Test | Input | Savings | Avg Time | | ---------------------- | ----------------------- | ------------- | -------- | | npm install noise | 3,775 chars / 250 lines | 627 tokens | 31.7 µs | | grep with 200 dupes | 4,422 chars / 202 lines | 1,200 tokens | 16.5 µs | | Large file (850 lines) | 40,689 chars | 11,600 tokens | 13.2 µs | | Full bash pipeline | 11,285 chars | 3,200 tokens | 76.9 µs |

Verdict: negligible performance impact — compression runs in microseconds, three orders of magnitude below perceptible LLM response latency (2-5 seconds).

Configuration

Headroom works out of the box with sensible defaults. The following constants are available in the source if you need to tune them:

| Setting | Default | Description | | ----------------------------- | ---------------------------------- | ---------------------------------------------- | | COMPRESSION_THRESHOLD | 2000 | Minimum chars in output to trigger compression | | TOAST_INTERVAL_COMPRESSIONS | 5 | Toast every N compressions | | Compressible tools | bash, read, grep, glob, webfetch | Tools whose outputs get compressed |

Comparison with DCP

You can use Headroom alongside opencode-dcp — they work at different levels:

| | Headroom | DCP | | ---------------------- | -------------------------------- | ------------------------------- | | What it compresses | Tool outputs (in real-time) | Conversation history (messages) | | When | Before output enters context | Periodically / on demand | | Strategy | Strips noise, dedupes, truncates | Generates summaries via LLM | | Perf impact | Microseconds | Seconds (LLM call) |

They're complementary — Headroom reduces context bloat from noisy tool outputs, DCP handles stale conversation turns.

Commands

| Command | What it does | | ----------------- | ------------------------------------------ | | /headroom-stats | Shows current session stats as a TUI toast |

Development

# Clone the repo
git clone https://github.com/ace/opencode-headroom
cd opencode-headroom

# Link locally for testing
# In your project's opencode.json:
{ "plugin": ["/absolute/path/to/opencode-headroom"] }

License

MIT