OpenCode Visual Cache plugin
An OpenCode TUI sidebar plugin that shows live token cache hit rate, session cost and the money the cache saved.
- 318 ★ on the repository
- Last commit
- MIT
Minimal access
Why this level
- The balance key is stored in plugin storage as plain text
- Balance requests go to provider APIs
Install
- Works in
Manual install
{
"plugins": [
{
"package": "opencode-visual-cache@latest",
"options": {
"enabled": true
}
}
]
}The first README option for OpenCode 2.x: an entry in `~/.config/opencode/cli.json`. For 1.x there is an install from the `Ctrl + P` command palette.
Access and checks
How we reviewMinimal accessThe tool runs nothing and makes no network calls.
- The balance key is stored in plugin storage as plain text
- Balance requests go to provider APIs
This is third-party code. Review the repository files before installing.
What it does
OpenCode Visual Cache adds a cache statistics block to the OpenCode terminal sidebar: hit rate with a progress bar, cache read and write tokens, misses and output, session cost and the amount saved. Model prices come from the provider configuration. The slash commands `/cache-session`, `/cache-currency`, `/cache-section` and `/cache-balance` switch the viewed subagent, the currency, block visibility and balance lookup for DeepSeek, SiliconFlow, OpenRouter and Moonshot. The plugin also lists loaded skills with an estimate of their token weight.
Who it is for. OpenCode users paying for tokens who want to see whether a long context lands in the provider cache.
Good fit when
- A long session gets expensive and you want to check whether the hit rate stays above 85%.
- Subagents burn tokens and `/cache-session` shows each one separately.
- Spend is needed in yuan or euro and `/cache-currency` converts it at a rate.
- Before changing provider you want to check the DeepSeek or OpenRouter balance from the terminal.
Not a fit when
- Work happens in Claude Code, Cursor or another agent: the plugin only lives inside OpenCode.
- An exact token split by role is needed: the distribution in the panel is an estimate.
- Statistics are needed for a provider outside DeepSeek, SiliconFlow, OpenRouter and Moonshot: balance is not requested for others.
Example request
Open `/cache-section` and enable the token distribution block, then convert spend to euro through `/cache-currency`.Limitations
On OpenCode 2.x the plugin is declared in the `plugins` array of `cli.json`; `opencode plugin add` causes a load error. OpenCode pins the cached version, so an update means clearing `~/.cache/opencode/` and installing the package again. The balance key sits in the plugin storage as plain text. Prices are assumed to be in dollars and converted at an approximate rate, and the token split by role is an estimate. On OpenCode 1.x the bottom status line is off by default and conflicts with plugins that rebuild the prompt field.
How to disable. Remove the `opencode-visual-cache` entry from the `plugins` array in `~/.config/opencode/cli.json` (`tui.jsonc` on 1.x) and restart OpenCode. If you entered a balance key through `/cache-balance-key`, clear the plugin storage along with the configuration.
FAQ
How does the plugin compute the cache hit rate?
Cache reads are divided by the sum of fresh input tokens, cache reads and cache writes, which matches the approach of OpenAI, Anthropic and Bedrock. Providers that report no separate cache write, such as DeepSeek, use a hit and miss scheme.
How do I view subagent statistics?
Run `/cache-session`; the plugin finds subagents and lists them. After you pick one the panel shows its data, and `/cache-session-back` returns to the main session.
Which providers support balance lookup?
DeepSeek, SiliconFlow, OpenRouter and Moonshot. Enter the key through `/cache-balance-key` or let the plugin reuse the OpenCode connection.
How do I change the panel language?
Use `/cache-lang`: Chinese, English, Japanese and Korean are available, and the choice is saved. The `CACHE_TUI_LANG` variable with `zh`, `en`, `ja` or `ko` also sets it.
Why did the plugin not update after a new release?
OpenCode keeps the version from the first install. Clear the package cache in `~/.cache/opencode/`, install `opencode-visual-cache@latest` again and restart OpenCode.
Discussion
No questions or reviews yet.
Related
PluginsOutput token speed in the OpenCode footer: a rolling TPS while streaming and an exact figure after the reply.
A Windows plugin for OpenCode Desktop that sets edit boundaries, screens commands and ties test results to the current code.
A terminal and browser viewer for coding agent spend: sessions by turn, subagent and context window, with API price estimates.
A local Splunk dashboard shows tokens and cost for Claude Code, Codex and Cursor sessions, and an MCP server answers questions.
Ten Claude Code plugins: panes and bands above the prompt, secret handling, a vague-prompt filter and memory cleanup.
An OpenCode plugin that searches conversation history across all projects by keyword, regex, with typos, and by touched files.
README in short
The panel is built from collapsible blocks: summary, token details, model with prices, distribution, skills and balance. Block state and language persist between launches.