dsh-token-count
Manifest validToken usage dashboard for DeepSeek Harness. A dedicated settings page shows cumulative input / output / cache-read / cache-write token totals, a green GitHub-style daily heatmap colored by usage, and
dsh-token-count(Token 统计)
DeepSeek Harness 的 token 用量看板插件:在设置页单开一页,用绿色热力网格展示按天 token 用量,并用「饼图 / 柱状图」切换展示各模型(provider/model)的用量占比。
灵感来自 dsh-codex-gpt 的用量看板,但这是一个全新独立插件,数据源也完全不同。
数据来源(全部本机,不调上游 API)
| 数据 | 来源 |
|---|---|
| 累计总量 | 扫描 ~/.dsh/sessions/<workspace>/<session>/session.v4.jsonl.zstd,聚合 assistant/message 事件的 usage(输入 / 输出 / 缓存读 / 缓存写四大互斥桶) |
| 按天热力 | 同上,按事件 time(毫秒)归到本地时区 YYYY-MM-DD |
| 按模型分桶 | 从 assistant/message 事件的 data.message.source 取 provider / model |
| 日志解压 | DSH 会话日志是多帧 zstd 拼接,按魔数 28 B5 2F FD 切帧、逐帧解压(node:zlib 的 zstdDecompressSync) |
功能
- 累计总量:输入 / 输出 / 缓存读 / 缓存写 四大桶 + 总计,覆盖会话数、日志体积。
- 每日用量热力图:GitHub 贡献图风格,横轴 = 周、纵轴 = 星期几,每格 = 一天,颜色越深用量越高;鼠标悬停显示当日用量;可切 30 / 90 / 180 / 365 天。
- 用量结构:饼图 / 柱状图一键切换,按模型(provider/model)分块,多色区分。
缓存策略
按天聚合需要扫描会话日志(较重),所以首次扫描落盘缓存 ~/.dsh/dsh-token-count-cache.json,之后按文件 mtime + size 增量重扫——只有日志文件变化时才全量重算。
安装 / 开发
方式一:本地 Junction 软链(改代码即生效)
# 需要管理员权限,或在「设置 → 开发者选项 → 开发人员模式」开启后运行
$nm = "$env:USERPROFILE\.dsh\profiles\desktop\node_modules"
cmd /c "mklink /J `"$nm\dsh-token-count`" `"C:\Users\17367\Desktop\dsh-token-count`""
方式二:DSH 插件市场「本地安装」,指向本目录。
跑测试
node test/stats.test.mjs
node test/session-log.test.mjs
node test/index.test.mjs
改宿主代码后需「禁用 → 启用」插件重载;改客户端后 Ctrl+R 即可。
目录结构
index.js 宿主入口:扫描 + 增量缓存 + GET /dsh-token-count-api 路由
session-log.js 会话日志读取(zstd 多帧解压 + 逐行解析)
stats.js 纯聚合逻辑(四大桶 / 按天 / 按模型)
client.js 浏览器侧:设置页热力网格 + 饼图/柱状图(按模型分色)
License
MIT
Comments
Loading…
Similar plugins
by solstice621
该仓库暂未提供项目说明。
★ 3
↓ 37/wk
MIT
JavaScript
Oct 22, 2026
dsh plugin --profile web add dsh-token-usage-dashboardby zhujiuyi
Token usage dashboard in the DeepSeek Harness sidebar: daily totals from session logs with a 12-month heatmap, per-provider breakdown over today/7d/30d/all (hourly for today), and a per-session rankin
★ 2
↓ 49/wk
MIT
JavaScript
Oct 24, 2026
dsh plugin --profile web add @zhujiuyi/dsh-token-dashboardby KIDLi1412
GitHub-style daily token-usage heatmap on the new-session screen with a selectable calendar-year view, green/blue color schemes, and today / this-month / all-time totals.
★ 1
↓ 178/wk
MIT
JavaScript
Oct 18, 2026
dsh plugin --profile web add @kidli1412/dsh-token-heatmapCumulative token usage tracking for DeepSeek Harness, with per-model and per-day breakdowns, a settings-page dashboard and an online-changeable data directory.
★ 0
dsh plugin --profile web add token-statToken usage statistics for DeepSeek Harness with a session drawer and today / last-3-day / last-7-day panels, plus configurable charts and metrics.
★ 0
dsh plugin --profile web add dsh-token-chartToken usage statistics for DeepSeek Harness. Per-channel usage with balances and plan quotas for mainstream providers, CNY cost estimates, and daily charts — a settings-sidebar section.
★ 1
NOASSERTION
TypeScript
dsh plugin --profile web add @linxin666/dsh-stats-panel