1
128
近 7 天 50
35.3
生态多维模型
8 天前
2026-08-11
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-usage-total@0.3.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-usage-total@0.3.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-usage-totalopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Track model usage and costs per agent in the OpenCode TUI sidebar.
A TUI plugin for OpenCode that shows every model used by the main agent and its sub-agents, with the cost accumulated per model and a session total that includes sub-agent work.
[!NOTE] Español: README.es.md
Features
- Per-agent breakdown — lists the main agent and every sub-agent with the model and accumulated cost for each
- Tree total — the header sums the root session and all sub-agents, so you see the real session cost
- Collapsible — toggle the section with
Alt+M; the state persists across restarts - Session-wide accumulation — costs keep adding up for the whole session
- Parent attribution — sub-agent models are attributed to their parent session
- KV persistence — survives restarts and session switches
[!WARNING] Token counts are hidden until the metric is accurate. The sidebar currently shows cost only; token data is still collected internally (in KV) and will be rendered once it can be counted reliably.
Install
opencode plugin -g opencode-usage-total
The command registers both the server and the TUI sidebar entry in your global config. Restart opencode afterwards.
Update
rm -rf ~/.cache/opencode/packages/opencode-usage-total@latest
opencode plugin -g opencode-usage-total
Usage
Start a session in OpenCode and open the sidebar: the 🧠 Models section lists every model used in the current session, with the accumulated cost per model and a total that includes sub-agent work.
Press Alt+M to collapse or expand the list.

Requirements
- OpenCode with TUI support (plugin API ≥ 1.14.50)
Development
npm install
npm run build # bundle with tsup
npm test # run the vitest suite
MIT