Horizon215/dsh-plugins--packages-token-stats ↗★ 9
@your-scope/dsh-token-stats
统计并展示单轮及全局的Token用量与成本 适合需要精确监控、统计和分析Token消耗及成本的用户。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Horizon215/dsh-plugins#47c61d624358f92d2f229dd981ef3883ee2af6a1&path:packages/token-stats说明文档
阅读完整 README ↗@your-scope/dsh-token-stats
Token usage & cost stats for the DeepSeek Harness (dsh) web UI.
DeepSeek Harness Web UI 的 Token 用量与成本统计插件。
Screenshots / 截图见仓库根 README:https://github.com/Horizon215/dsh-plugins
English
Features
- Per-turn usage chip — under each completed turn:
input · output | cache hit | duration | ≈cost - This-session badge — at the sidebar foot (above Settings): the current session's tokens + ≈cost with cache-hit detail, a "today · all sessions" counter, and tweened number updates
- Aggregate dashboard (Settings → Usage & Cost) — true all-session totals: a background scanner folds every session's history (including ones you never opened) through the same local RPC the UI uses; four-bucket cards (new input / output / cache write / cache hit), cache-hit-rate bar, estimated cost + request count, one-click rescan
- One range scopes everything — Today / 7 days / 30 days / All drives the dashboard cards, trend chart and model table together (cc-switch style)
- Day drill-down — click any day in the trend chart for that day's per-session breakdown (which session burned what), powered by the per-session-day ledger
- Usage trend chart — cumulative area chart, growing live as turns complete; draw-in animation on range switch, tweened headline numbers
- Per-model breakdown — requests / tokens / ≈cost / average cost per model, attributed by true event time across all scanned sessions
- Price presets — built-in list prices for DeepSeek V4-Flash / V4-Pro / Kimi K3 (CNY & USD); pick one or edit the three rates manually, every display reprices live
- Reset that sticks — "Reset stats" tombstones old events and rebases the live feed, so the next background scan does not resurrect cleared totals
Install
From source (npm package coming soon):
git clone https://github.com/Horizon215/dsh-plugins.git
cd dsh-plugins
pnpm install && pnpm build
dsh plugin --profile web add file:./packages/token-stats
Restart dsh web. The package declares dsh.bundle, so it joins the profile automatically — no config edits.
Notes
- Requires dsh ≥
0.1.0-rc.5(verified on rc.5 / rc.6), web UI only - All stats live in browser localStorage; nothing is uploaded. The background scanner only reads the loopback
/api/session.list//api/session.historyRPCs (same origin and trust level as the UI itself) — it never parses files on disk - Costs are estimates from configurable list prices — your provider invoice wins
Uninstall
dsh plugin --profile web remove @your-scope/dsh-token-stats
中文
功能
- 每轮用量条:每轮对话末尾显示
输入 · 输出 | 缓存命中率 | 耗时 | ≈成本 - 本会话徽章:侧栏底部(设置按钮上方)实时显示当前会话的 tokens + ≈成本 + 缓存命中率,另有「今天 · 全部会话」一行全局计数,数字变化滚动补间
- 汇总仪表盘(设置 → 用量与成本):真正的全部会话总账——后台扫描器通过与 UI 同源的本地 RPC 折叠每个会话的历史(含从未打开过的);四格指标(新增输入 / 输出 / 缓存创建 / 缓存命中)、缓存命中率条、估算成本 + 总请求数,可一键重新扫描
- 一个时间范围管全部:今天 / 近 7 天 / 近 30 天 / 全部 同时驱动仪表盘四格、趋势图和模型表(cc-switch 式)
- 按天下钻:点击趋势图任意一天,看当天每个会话各烧了多少(按会话-天账本)
- 使用趋势图:累计用量面积图,随对话动态增长;切换范围有描绘动画,大数字滚动补间
- 按模型统计:分模型的 请求数 / tokens / ≈成本 / 单次均价,按事件真实时间归属,覆盖全部被扫描会话
- 价格预设:内置 DeepSeek V4-Flash / V4-Pro / Kimi K3(人民币与美元)刊例价,可一键选用或手动微调;改价后所有展示实时重算
- 清空不复活:「清空统计」会为旧事件打墓碑并让实时 feed 重设基线,下一轮后台扫描不会把已清空的总数加回来
安装
从源码安装(npm 包稍后发布):
git clone https://github.com/Horizon215/dsh-plugins.git
cd dsh-plugins
pnpm install && pnpm build
dsh plugin --profile web add file:./packages/token-stats
装完重启 dsh web 即可(插件声明了 dsh.bundle,会自动装配进 profile,无需手动改配置)。
说明
- 需要 dsh ≥
0.1.0-rc.5(在 rc.5 / rc.6 上验证通过),仅 Web UI - 所有统计数据仅存浏览器 localStorage,不上传任何服务器;后台扫描只读本机 loopback 的
/api/session.list//api/session.history(与 UI 自身同源同权限),不解析磁盘文件 - 成本为基于可配置刊例价的估算值,以供应商账单为准
卸载
dsh plugin --profile web remove @your-scope/dsh-token-stats
License
MIT