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.
Provider-recorded token usage, estimated context utilization, cache efficiency, and session activity.
The largest observable retained messages, reasoning, attachments, and tool outputs.
Observable instructions, agents, skills, MCP servers, and available tools.
Published on npm as opencode-context-tui.
- 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 globally so /context is available from every project:
opencode plugin --global opencode-context-tuiThe 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
h/lor left / right arrows: switch tabsj/kor arrow keys: move selectionr: refresh immediatelye: export a redacted snapshotesc: close the modal
The modal also refreshes automatically when session messages change. It follows the active OpenCode theme and adapts to narrow terminals.
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.
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.
bun install
bun test
bun run typecheck
bun run buildTo load a local checkout, reference its absolute directory in OpenCode's TUI plugin configuration, then restart OpenCode.
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.


