dsh-opencode-usage-panel
v0.1.0
Published
DeepSeek Harness panel that shows local OpenCode token usage: today, last 7 days, model mix, projects and recent sessions. Tuned for the OpenCode Go subscription.
Maintainers
Readme
OpenCode usage panel for DeepSeek Harness
A DeepSeek Harness Web plugin that shows how much of your OpenCode Go subscription the Harness has consumed — today, the last 7 days, a configurable window, the model mix, the project split, a 14-day chart and your most recent sessions — in a compact strip docked at the right end below the chat composer.
The Harness reaches OpenCode Go through its own LLM provider, so the numbers come from the token
usage the Harness records on every assistant message (ctx.sessionQuery), not from the OpenCode CLI
database. Every figure is a plain sum of assistant/message usage records for the configured
provider; nothing is estimated and nothing leaves the machine.
Install
npm install dsh-opencode-usage-panelThe package ships a cordis.patch.yml that inserts one entry:
- insert:
- id: opencode-usage
name: dsh-opencode-usage-panel
config: {}Configuration
Optional fields on the row's config:
config:
provider: opencode # LLM provider id counted as OpenCode usage (default: opencode)
days: 30 # history folded into the totals (1-3650)
chartDays: 14 # days in the bar chart (3-90)
recentSessions: 8 # recent sessions listed (1-50)
cacheMs: 15000 # host-side snapshot cacheWhen the configured provider id matches nothing, the panel falls back to every provider and says so in the footer tooltip.
OpenCode 用量面板
在 Harness 输入框右下方显示 OpenCode Go 订阅的消耗情况:今日 / 7 天 / 近 N 天的 token、输入输出与缓存明细、最近 14 天柱状图、模型占比、项目分布和最近会话。
Harness 是通过自己的 LLM provider 走 OpenCode Go 的,所以数据取自 Harness 自己记录的会话用量(每条 assistant 消息的 usage,经 ctx.sessionQuery 汇总),不是 OpenCode CLI 的 opencode.db。所有数字都是逐条消息相加,不做估算,也不发送到本机以外。
显示内容
- 收起状态:
今日、7 天、近 N 天三个 token 数字,点一下展开;整块贴在输入框下方最右侧。 - 展开状态:近 5 小时 / 今日 / 7 天 / 近 N 天;输入、输出、推理、缓存明细;每日柱状图;模型占比;项目分布;最近会话;刷新按钮。
- 每 60 秒自动刷新;宿主机侧快照缓存 15 秒,并按每条会话的最后事件号做增量折叠,没变化的会话不重复解析。
配置(可选)
config:
provider: opencode # 算作 OpenCode 用量的 provider id,默认 opencode
days: 30 # 折叠多少天,默认 30
chartDays: 14 # 柱状图天数,默认 14
recentSessions: 8 # 最近会话条数,默认 8
cacheMs: 15000 # 宿主机缓存毫秒provider 匹配不到任何记录时,会退回统计全部 provider,并在底部提示里标注。
License
MIT
