@jumpmaster/opencode-throughput
v2.2.0
Published
Real-time LLM performance monitoring plugin for OpenCode. Tracks TTFT, TPS, latency, token usage and cost per model with a TUI sidebar display.
Maintainers
Readme
Forks from opencode-throughput
Why fork? I want the simpler realtime stats bar, instead of complete.
opencode-throughput
Real-time LLM performance monitoring plugin for OpenCode. Tracks TTFT, TPS, latency, token usage, and cost with a live readout in the prompt status bar. Supports both OpenCode 1.x (V1 TUI plugins) and OpenCode 2.x (V2 CLI plugins) from one package.
Features
- TTFT (Time To First Token) — measures how fast the model starts generating
- TPS (Tokens Per Second) — generation throughput during streaming
- Total Latency — end-to-end request time
- Token Usage — input, output, reasoning, cache read/write
- Cost Tracking — per-request and cumulative cost
- Status Bar Readout — live
TTFT · ↓tokens · TPSwhile streaming, plus a per-turn summary when idle
Installation
OpenCode 2.x — add to ~/.config/opencode/cli.json:
{
"$schema": "https://opencode.ai/v2/cli.json",
"plugins": ["@jumpmaster/opencode-throughput"]
}OpenCode 1.x — add to tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["@jumpmaster/opencode-throughput"]
}OpenCode installs the plugin from npm at startup. Requires opencode >= 1.18.0; OpenCode 2.x needs no extra configuration.
Usage
Once installed, the plugin runs automatically. While a model generates, the prompt status bar shows the live readout:
TTFT 1.2s · ↓1.2k tok · 58.3 tok/sWhen idle it shows the last turn's summary:
TTFT 2.1s · ↓1.5k tok · 57.3 tok/s- TPS is generation throughput: it excludes prefill (TTFT) and tool-execution time
- The turn summary resets on each new user message / execution
- While the next prompt is still in prefill (no first token yet), the previous turn's token and TPS values stay on screen in muted color, so nothing blanks out
How It Works
The plugin is a TUI plugin (@opentui/solid + solid-js) with two implementations behind one entrypoint:
- V1 (
src/v1.tsx) subscribes tomessage.part.updated,message.part.delta,session.next.*.delta, andmessage.updated, and renders intosession_prompt_right/home_prompt_right - V2 (
src/v2.tsx) subscribes tosession.step.started,session.text.delta,session.reasoning.delta,session.tool.input.delta,session.step.ended, andsession.execution.*, and renders intoprompt.footer.status/home.footer.status
Both share the pure TTFT/TPS helpers in src/stats.ts. V1 reads the first token time and the completed message totals; V2 uses the step start time as the TTFT anchor and session.step.ended for real token usage per step.
Development
Local development
V1 — add to tui.json (TUI plugins are loaded from tui.json, not opencode.json):
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["file:///absolute/path/to/opencode-throughput/src/index.ts"]
}V2 — add to ~/.config/opencode/cli.json:
{
"$schema": "https://opencode.ai/v2/cli.json",
"plugins": ["file:///absolute/path/to/opencode-throughput/src/tui.tsx"]
}Edits to src/** only take effect after restarting opencode. Keep exactly one registration (published package or local file) while developing.
Build
bun install
bun run build
bun run typecheck
bun testbun test includes a render test that drives the V2 slot with synthetic events via @opentui/solid's testRender.
Publish
npm login # once
bun run release # bump + build + typecheck + test + npm publishbun run release [patch|minor|major|x.y.z] [--dry-run] [--yes] [--tag=beta]
License
MIT
