dsh-usage-vendor-stats
按厂商(订阅/官方API)统计用量看板:按供应商/模型拆分 Token、缓存、输出等 KPI,53 周热力图,趋势折线图(今天按小时),模型钻取,费用估算,CSV 导出,以及健康度卡片(TTFT、生成速度、峰值 Context、错误率)。
安装
dsh plugin --profile web add dsh-usage-vendor-stats
沙箱测试结果
| 阶段 | 结果 |
|---|---|
| 1 安装 | ✗ |
| 2 列装 | — |
| 3 挂载 | — |
| 4 启动 | — |
dsh: initialized profile web at /home/node/.dsh/profiles/web四阶段在隔离沙箱里跑:安装(有网)→ 列装 → 挂载 → 启动(后三步断网)。
README
dsh-usage-vendor-stats
[English](#english) · [中文](#中文)
English
DeepSeek Harness usage statistics plugin: aggregates API usage by vendor (subscription / official API) × KPI, with a GitHub-style calendar heatmap and daily / monthly dashboards.
Distinct fromdsh-usage-stats(which aggregates by workspace): this plugin uses the vendor (provider) as the primary dimension, auto-detectingmessage.source.providerandmessage.source.modelfromassistant/messageevents, and splits KPIs into tokens / cache hits / output / reasoning.
Features
- Vendor dimension: auto-discovers every vendor used (e.g.
huoshan,hebox,deepseek-official,tokenrhythm,opencode), with manual labels for subscription / official API and aliases (persisted to a KV unit under$DSH_HOME/storages). - KPI cards: total tokens (input / cache hit / output / reasoning breakdown), cache hit rate, model calls, turns, sessions, vendor count, with a multi-color token composition ratio bar.
- 53-week heatmap: GitHub-green style, intensity by daily model calls; click a vendor chip to filter; hover for per-vendor and per-token details.
- Trend line chart: Token / Calls dual-axis trend, per-day by default and per-hour for "today" (hourly aggregation).
- Vendor model drilldown: click a vendor row to expand its per-model consumption.
- Daily detail: per-day tokens / cache / output / reasoning / hit rate / turns (last 30 days).
- Monthly summary: all history aggregated by month.
- Vendor KPI table: sorted by total tokens, with hit rate, model count, type badge; click a row to drill into models.
- Time presets: today / 7d / 14d / 30d / 90d / all.
- Cost estimation: set a per-million-token unit price per vendor to see an estimated fee column.
- CSV export: export daily / monthly / vendor tables to CSV.
- Health / performance cards: average TTFT (time to first token), generation speed (t/s), peak context size, request error rate, and total model / tool wall time, aggregated from DSH's
sessionStatsprojection. - Range switching, animations, light/dark theme adaptation.
Screenshots
Data source
- All data comes from DSH durable session logs:
assistant/messageevents carryusage(token accounting) andmessage.source.{provider,model}(vendor/model provenance). - Token accounting (consistent with DSH):
inputTokens= uncached input,cacheReadTokens= cached input,outputTokens= output,reasoningTokens= reasoning,cacheWriteTokens= cache write. - Cache hit rate = hits / (hits + uncached input) × 100%.
- History is backfilled automatically on activation; data survives plugin uninstall / restart.
Install
This is a standard DSH community plugin package (declares dsh.bundle manifest + web client half).
From GitHub (recommended)
dsh plugin --profile web add "github:kirigayakazima/dsh-usage-vendor-stats"
Refresh the page after install — no manual config, no restart.
Manual registration (local development)
1. Place this directory anywhere and create a symlink pointing to it under $DSH_HOME/profiles/node_modules/ (use a junction on Windows):
New-Item -ItemType Junction -Path "$env:DSH_HOME\profiles\node_modules\dsh-usage-vendor-stats" -Target "<absolute path to this dir>"
2. Add a line to $DSH_HOME/profiles/web/cordis.patch.yml:
- insert:
- id: usage-vendor-stats
name: dsh-usage-vendor-stats
The user patch layer hot-reloads: save and refresh the page.
Usage
1. Open Settings (sidebar footer) and find the API Usage Stats page, or click the 📊 Usage Stats entry in the sidebar footer to open the fullscreen panel.
2. Heatmap color = daily call count; click a vendor chip or table row to filter / drill down.
3. In Vendor Management, set each vendor's alias and type (subscription / official API), and optionally a per-million-token unit price for cost estimation.
Architecture
- Host half (
lib/index.js): scans durable session logs and aggregates usage (assistant/message.usage+message.source), listens tosession/eventfor live folding; serves data routes via thewebServerservice: GET /api/usage-vendor-stats— stats snapshot (vendors / models / daily / monthly / hourly / totals)POST /api/usage-vendor-stats/vendor— set vendor alias, type, and unit price- Client half (
lib/client.js):window.__ModuleLoader__factory-format browser bundle, registering the API Usage Stats settings page (settings.sectionslot), a sidebar footer entry (sidebar.footer.action), and a fullscreen panel (shell.overlay).
Development
- Editing
lib/index.js/lib/client.jstakes effect after a page refresh (client bundle loads with the page); host-half changes require a DSH restart. - The plugin has no third-party runtime dependencies: the host half uses only Cordis services, the client half only React (provided by the module table).
License
MIT
中文
DeepSeek Harness 用量统计插件:按厂商(订阅 / 官方 API)× KPI 聚合 API 使用量,带 GitHub 风格日历热力图、趋势折线图与日 / 月 / 小时统计看板。
区别于dsh-usage-stats(按工作区统计):本插件以厂商(provider)为第一维度,自动识别assistant/message事件里的message.source.provider与message.source.model,拆分 token / 缓存命中 / 输出 / 推理等 KPI。
功能
- 厂商维度:自动发现所有使用过的厂商(如
huoshan、hebox、deepseek-official、tokenrhythm、opencode),可手动标记为「订阅 / 官方API」,设置别名(持久化到$DSH_HOME/storages的 KV 单元) - KPI 卡片:总花费 Token(输入 / 缓存命中 / 输出 / 推理分项)、缓存命中率、模型调用次数、回合数、会话数、厂商数量,附多色 Token 构成比例条
- 53 周热力图:GitHub 绿色风格,颜色深浅按当日模型调用次数;点击厂商筛选后仅统计该厂商;悬停查看按厂商明细与 Token 明细
- 趋势折线图:Token / 调用双轴趋势,默认按日;选「今天」时按小时展示(小时级聚合)
- 厂商模型钻取:点击厂商行展开该厂商的逐模型消耗
- 每日明细:近 30 天逐日 Token / 缓存 / 输出 / 推理 / 命中率 / 回合
- 每月汇总:全
…(truncated)
以上内容来自 npm 上的 README,我们只做格式化,不改内容。
版本
npm 上共发布:2,最后更新 2026-10-02