Show HN: A plugin to monitor OpenCode cache hits

nmdra1 pts0 comments

GitHub - nmdra/opencode-cache-stats: Opencode TUI plugin that shows prompt-cache hit rate in a popup dialog. · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

nmdra

opencode-cache-stats

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>39 Commits<br>39 Commits

assets

assets

docs

docs

tui-plugins

tui-plugins

LICENSE

LICENSE

README.md

README.md

tui.json.example

tui.json.example

View all files

Repository files navigation

cache-stats

cache-stats is a TUI plugin for opencode. A TUI is a text user interface. The plugin shows the prompt-cache hit rate of the active session in a popup dialog.

Run the /cache-stats command (or the cache-stats.show command) inside a session to open the dialog.

Features

Shows the cache hit rate of the active session with a hit bar and a verdict word.

Shows totals for tokens, calls, and cost.

Groups the totals by model and by subagent.

Shows the hit rate of each model and each subagent.

Shows averages per call and the last request.

Colors the rates by level: Excellent, Good, Fair, or Poor.

Scrolls with the arrow keys and the page keys.

Summary and models<br>Totals breakdown<br>Subagents

What it shows

The dialog shows:

The overall cache hit percentage of the active session. A hit bar and a verdict word (Excellent, Good, Fair, or Poor) show the level.

A session summary: total calls, model count, subagent count, total tokens, and total cost.

A per-model breakdown with hit bars, hit percentages, and token totals.

Grouped totals for tokens, calls, and cost. The totals include percentages, averages per call, and the last request.

A subagent list with the hit rate of each subagent and the model that each subagent used.

The plugin computes the cache hit rate with this formula:

hit = cache read / (input + cache read)

A cache write is a one-time priming cost. It is excluded from the hit ratio. The plugin also reports the number of API calls that read from the cache.

Install

Copy the plugin into ~/.config/opencode/tui-plugins/.

Register the plugin in ~/.config/opencode/tui.json:

"$schema": "https://opencode.ai/tui.json",<br>"plugin": ["./tui-plugins/cache-stats.tsx"]

The repo keeps a copy of tui.json as tui.json.example.

After you change tui.json, restart opencode. Then run the /cache-stats command inside a session.

Files

tui-plugins/cache-stats.tsx — the TUI plugin

tui.json.example — registration config example

Documentation

index — overview

installation — how to install the plugin

usage — how to use the plugin

how-it-works — how the plugin collects the data

colors — how the plugin colors the rate

troubleshooting — how to fix common errors

About<br>Opencode TUI plugin that shows prompt-cache hit rate in a popup dialog.<br>Topics<br>opencodeopencode-pluginopencode-pluginsusage-analytics<br>Resources<br>Readme<br>MIT license<br>Activity<br>Stars<br>1 star<br>Watchers<br>0 watching<br>Forks<br>0 forks<br>Report repository

Contributors

Languages

You can’t perform that action at this time.

cache plugin opencode stats shows session

Related Articles