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

opencode-context-tui

v0.1.0

Published

Native OpenCode TUI modal for inspecting current-session context usage

Readme

opencode-context-tui

npm

Current-session context inspection with a native OpenCode TUI modal.

/context opens a large modal over the current screen with recorded token usage, estimated context utilization, message and tool activity, and the largest retained context contributors. It does not invoke an LLM to build the report.

Overview

Provider-recorded token usage, estimated context utilization, cache efficiency, and session activity.

opencode-context Overview tab showing token usage, context utilization, cache efficiency, and session activity

Content

The largest observable retained messages, reasoning, attachments, and tool outputs.

opencode-context Content tab showing the largest retained context contributors

Environment

Observable instructions, agents, skills, MCP servers, and available tools.

opencode-context Environment tab showing instructions, agents, skills, MCP servers, and tools

Published on npm as opencode-context-tui.

Requirements

  • OpenCode 1.18.11 or newer within the 1.x release line
  • Bun, which is already used by OpenCode's plugin runtime

The TUI plugin API is new and version-coupled. This package declares an engines.opencode range so incompatible OpenCode versions skip it rather than loading an unsupported interface.

Install

Install globally so /context is available from every project:

opencode plugin --global opencode-context-tui

The package exposes a TUI entrypoint only. OpenCode updates ~/.config/opencode/tui.json for the native modal.

Quit and restart OpenCode after installation. Plugin configuration is loaded only at startup.

Then run inside a session:

/context

Context Modal

  • h / l or left / right arrows: switch tabs
  • j / k or arrow keys: move selection
  • r: refresh immediately
  • e: export a redacted snapshot
  • esc: close the modal

The modal also refreshes automatically when session messages change. It follows the active OpenCode theme and adapts to narrow terminals.

Accounting

The report keeps three kinds of data separate:

  • Recorded: input, cache-read, cache-write, output, and reasoning tokens reported on OpenCode assistant messages
  • Measured: local character and byte counts from retained message parts available to the TUI
  • Estimated: retained token counts and context utilization derived locally from observable content

Estimated values are not provider billing totals or an exact reconstruction of the next provider request. OpenCode does not expose the final provider payload or every hidden system-prompt layer through a stable public API.

Export

Press e to write a redacted JSON snapshot under:

<opencode-state>/opencode-context-tui/exports/

Exports are explicit and stored outside the worktree by default. Likely secrets are redacted, and contributor previews are omitted. Review an export before sharing it.

Development

bun install
bun test
bun run typecheck
bun run build

To load a local checkout, reference its absolute directory in OpenCode's TUI plugin configuration, then restart OpenCode.

Data Model

The modal reads current TUI and SDK state for:

  • Current provider, model, and context-window limit
  • Provider-recorded token telemetry
  • User and assistant message counts
  • Tool-call and compaction counts
  • Retained text, reasoning, tool output, and file attachment metadata
  • Configured instructions, agents, skills, MCP servers, and available tools where exposed

Session content is analyzed locally. The plugin does not upload content, invoke an LLM, read OpenCode's private database, or persist session data during normal use.