跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    AlonsoSG0

    Usage Total

    v0.3.0可观测与分析
    opencode-usage-total

    Track model usage, tokens, and costs per agent in the OpenCode TUI sidebar

    GitHub 星标

    1

    月装机量

    128

    近 7 天 50

    综合评分SCORE

    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"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    Track model usage and costs per agent in the OpenCode TUI sidebar.

    version license

    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.

    sidebar

    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