Skip to content

Xenia0922/dsh-opencode-go-usage

52Last commit Aug 15, 2026

dsh-opencode-go-usage DSH plugin

A DSH plugin that provides a draggable, resizable floating panel showing OpenCode Go quota, per-request usage, and costs. It fetches data from official OpenCode API and DSH session analysis, with automatic cookie extraction via CDP.

How to install the dsh-opencode-go-usage DSH plugin

dsh plugin --profile my-profile add ./dsh-opencode-go-usage

Copying does not run this command. Review the repository and version before installing the dsh-opencode-go-usage DSH plugin.

dsh-opencode-go-usage DSH plugin data source

dsh-opencode-go-usage DSH plugin snapshot date: Aug 16, 2026

discovered

What the dsh-opencode-go-usage DSH plugin can do

  • Floating FAB showing cumulative cost and rolling quota percentage with color warnings (yellow ≥70%, red ≥90%)
  • Window controls: drag title bar to move, drag edges/corner to resize, double-click to maximize, positions and sizes persisted
  • Official account-level view via usage.list API with CDP auto-extracted cookie, zero configuration needed
  • DSH session analysis view with official pricing estimation and exact backfill matching (83% match rate)
  • Multi-key quota pool: auto-discovers OPENCODE_GO_KEY_* entries from .credentials.yaml, labels active key with ★, limited keys with ⚠️
  • Model ranking bar chart, spending trend (7/14/30 days), recent sessions list with real titles
  • Quota alert bar at panel top when any window ≥90%
  • Language switch (Chinese/English, remembers choice, falls back to DSH language), CSV export of current view statistics

Where the dsh-opencode-go-usage DSH plugin fits

  • Monitor real-time OpenCode Go spending and quota usage across multiple API keys
  • Analyze per-request billing details from official OpenCode dashboard
  • Track DSH session costs and compare with official billing records
  • Export usage data as CSV for expense reporting or budgeting
  • Quickly identify when quota is running low and get estimated depletion time

Who the dsh-opencode-go-usage DSH plugin is for

  • OpenCode Go users who want to track their API usage and costs
  • DSH users who need a visual dashboard for monitoring OpenCode Go activity
  • Developers managing multiple OpenCode Go API keys and quotas

dsh-opencode-go-usage DSH plugin limitations

  • Data depends on OpenCode official API (usage.list and quota endpoints); offline or API failures will show 'loading' state
  • Requires manual login to opencode.ai once via CDP debug browser for cookie extraction; cookie can expire and need refresh
  • Dynamic loading (method A) is lost after DSH restart; only bundle method (method B) persists across restarts
  • Plugin directory path containing spaces will cause dsh plugin add to fail (e.g., 'D:\Opencode view\...')
  • Fetched data has a 60-second auto-refresh interval; official view disk cache is only used as incremental baseline, not instant
  • DSH view amounts are partly estimated (cache increments) and only matched to official records at 83% accuracy
  • Page limit for usage.list fetch is 5000 pages (~250k records); can be overridden with maxPages config, but truncation may occur

dsh-opencode-go-usage DSH plugin: from the repository README

Quoted from the Xenia0922/dsh-opencode-go-usage README, the upstream source of the dsh-opencode-go-usage DSH plugin. Copyright remains with the original authors.

> 由 Xenia0922 维护。数据完全本机获取,API key 不出本机、不进日志。 ## 特性 - **悬浮 FAB**:右下角胶囊,可拖动,实时显示累计金额 + 滚动配额 %(≥70% 变黄、≥90% 变红);**面板开/关都 60s 自动刷新**;位置越界自动重置 - **窗口控制**:拖标题栏移动、拖边缘/右下角缩放、双击/按钮最大化、位置/大小持久化 - **官方账户级视图(主数据源)**:直接调官网 `usage.list`,逐请求官方计费(与官网账单一致、跨设备);凭据**自动提取**(调试端口 CDP,一键启动),零配置 - **DSH 会话分析**:会话级视角,官方定价估算 + 与 `usage.list` 逐请求**精确回填**(实测匹配率 83%) - **配额环形图**:滚动(5h)/ 周 / 月配额 % + 重置倒计时;**多 key 池支持**(自动发现 `.credentials.yaml` 的 `OPENCODE_GO_KEY_*`,key 切换标签 ★ 当前生效,⚠ 已限流状态红色徽标);**明细不可用时也始终显示**;超速时红色提示预计耗尽时间 - **按模型排行 / 花费趋势 / 最近会话**:花费降序条状图 + 费用分项展开、7/14/30 天柱状图、真实会话标题 - **配额告警条**:任一窗口 ≥90% 面板顶部醒目提示 - **中英切换 / CSV 导出**:面板标题栏一键切换(记忆选择,未选择时跟随 DSH 语言)、导出当前视图统计 ## 界面预览 <img src="docs/screenshot.svg" alt="OpenCode Go 用量面板界面预览" width="640"> > 上图为按真实界面风格绘制的示意图(默认官方视图)。将实际截图保存为 `docs/screenshot.png` 即可替换预览(该文件已被 `.gitignore` 排除,不会入库)。 ## 安装 ### 方式 A:会话内动态加载(快速体验,免构建) 1. 打开 DSH 会话,让 Agent 执行 `cordis_define`(kind: new, idPrefix: `zenus`) 2. 将 [`src/host.js`](src/host.js) 内容粘贴为 `code.host`,将 [`src/client.js`](src/client.js) 内容粘贴为 `code.client` 3. `cordis_run` 授权后,右下角出现 FAB 胶囊 > ⚠️ 动态定义只活在当前进程,**DSH 重启后丢失**;想长期使用请用方式 B。 ### 方式 B:Bundle 插件(推荐,随 DSH 启动自动加载) ```sh git clone https://github.com/Xenia

Read the full READMERepository license: MIT

dsh-opencode-go-usage DSH plugin questions

How do I install the OpenCode Go Usage panel plugin?

Use method B: clone the repo, cd into it, then run 'dsh plugin --profile my-profile add ./dsh-opencode-go-usage' and start DSH with that profile. Alternatively, you can copy the src/host.js and src/client.js content into a session via cordis_define (method A), but that will be lost on restart.

Do I need to manually configure API keys or cookies?

For the official view, the plugin automatically extracts the auth cookie via CDP (debug port) after you log in once. For the quota pool, it auto-discovers OPENCODE_GO_KEY_* entries from your .credentials.yaml file. No manual configuration is needed unless you want to override key names or max pages.

Why does the cumulative amount not match the official quota percentage?

The cumulative amount is the total USD cost of all historical requests. The official quota percentage is based on a rolling 5-hour/week/month window of usage units (some models have 2x multiplier). The two use different measurement bases, so they are not directly comparable. Use the panel's 'this month' vs official window conversion as a reference.

Does codex traffic count as OpenCode Go usage?

Yes. Codex's config.toml points to opencode.ai/zen/go/v1 (same Go key), so its usage is already included in the official usage.list requests. The official view and quota percentages naturally include codex traffic.

The plugin disappeared after I restarted DSH. What happened?

If you used method A (dynamic loading via cordis_define), it's designed to be per-session only and is lost on restart. To persist across restarts, use method B: add the plugin via 'dsh plugin add' and ensure it's in your profile's bundles. Then restart DSH.