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

    Burn Rate

    v1.0.0智能体编排
    opencode-burn-rate

    opencode TUI plugin that shows a projected hourly USD burn rate for the current session, subagents included

    GitHub 星标

    0

    月装机量

    743

    近 7 天 28

    综合评分SCORE

    37.2

    生态多维模型

    最近提交

    14 天前

    2026-08-05

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-burn-rate@1.0.0"]
    }

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

    npm version MIT license

    opencode TUI plugin that adds a "Burn Rate" item to the TUI sidebar showing two projected hourly USD rates (session-lifetime average and active-work rate) for the current session, including all subagent (child) sessions. The session's own cost updates immediately; subagent costs and activity data are polled every 60 seconds.

    Installation

    Recommended: opencode CLI

    opencode plugin -g opencode-burn-rate
    

    opencode plug -g opencode-burn-rate is an alias. The -g flag (or --global) installs at global scope; omit it to install locally instead. Because the package exports ./tui, the command also writes the entry into tui.json automatically.

    From the TUI

    Press Ctrl+P to open the command palette, run "Install plugin", enter opencode-burn-rate, and press Enter. Press Tab to toggle between local and global scope.

    Manual

    Add opencode-burn-rate to the plugin array in ~/.config/opencode/tui.json, or a project-level tui.json:

    {
      "plugin": ["opencode-burn-rate"]
    }
    

    Restart opencode after installing with any method.

    This is a TUI plugin: adding it to the plugin array in opencode.json will not load it. tui.json is the TUI-side config.

    AI-assisted install

    Give any coding agent this block:

    Install the opencode-burn-rate TUI plugin by running `opencode plugin -g opencode-burn-rate`; if that command is unavailable, add "opencode-burn-rate" to the "plugin" array in ~/.config/opencode/tui.json (create the file if missing), then tell me to restart opencode. Note it must go in tui.json, not opencode.json.
    

    How the rate is computed

    The plugin computes two projected hourly USD rates from the total cost of the session and all subagent (child) sessions. The session's own cost updates immediately; subagent costs and activity data are polled every 60 seconds. Both rates floor elapsed time at 1 minute so sessions younger than one minute do not show absurd extrapolations.

    Session avg — a running session-lifetime average:

    (total USD cost) / elapsed * 3_600_000

    The elapsed window runs from session creation to the last time the total cost was observed to change across the session and its subagent tree. The rate holds steady between cost changes and jumps to a fresh, tighter window when new cost is observed; it does not decay toward zero while the session is idle.

    Active rate — total cost divided by time the session was actually doing work:

    (total USD cost) / active-elapsed * 3_600_000

    The active-elapsed window is the union of every span where the assistant was generating a message or a tool call was in-flight (for the root session), plus the [created, updated] window for each subagent session. Idle gaps between activity bursts are excluded automatically.

    Limits

    The subagent tree walk is capped at depth 5 and 100 total sessions. Deeper or wider trees are silently truncated. The plugin requires an opencode version whose server exposes GET /session/:id/children and GET /session/:id/messages (roughly >= 1.18).

    Subagent active time uses the session's [created, updated] window rather than detailed message activity. When opencode's experimental backgrounded-subagent feature detaches a subagent to keep running after the parent tool call returns, this coarse window may under- or over-count that subagent's active time.

    Local development

    bun install
    bun run check
    bun run build
    

    The build must run first so dist/tui.js exists. Point tui.json at the built entry file for a smoke test:

    {
      "plugin": ["./path/to/burn-rate/dist/tui.js"]
    }
    

    Releasing

    Releases are tag-driven. Run bun run patch (or minor / major) to bump the version, commit, tag vX.Y.Z, and push the branch and tag to origin. CI then publishes to npm and creates a GitHub release with generated notes.

    License

    MIT