dsh-usage-stats
开发工具 活跃维护

dsh-usage-stats

Triple3h/dsh-usage-stats

提供按天及模型维度的Token、会话、消息统计,附带活跃热力图,以zcode风格侧边栏面板呈现,可直观查看DSH Web使用数据。

1
Stars 标星
0
Forks 分支
1
Watchers 关注
0
Open Issues
JavaScript
主要语言
None
开源协议
50 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:Triple3h/dsh-usage-stats
git clone https://github.com/Triple3h/dsh-usage-stats.git
git clone git@github.com:Triple3h/dsh-usage-stats.git
README.md master

dsh-usage-stats

English | 中文

GitHub stars
GitHub license

A DeepSeek Harness (dsh) Web plugin that adds a Usage stats button above the sidebar settings row, opening a full-page, zcode-style usage dashboard.

Track how you use the harness: tokens by day and by model, sessions, messages, active days, and an activity heatmap — all read from your own session logs, no third-party telemetry.

What you get

  • Time-range switch — last 24 hours (default, hour-level buckets) / 7 days / 30 days
  • Six metric cards — token usage, session count, message count, active days, current streak, most-used model (with share)
  • Activity heatmap — 30 full weeks, bucketed into 5 levels by non-zero quantiles
  • Daily token trend — per-model stacked bars (top 6 models + other) with legend
  • Model usage — donut chart + breakdown list (share, tokens)
  • Refresh button in the panel header (top-right); close via Esc or the × (top-right)

Numbers are formatted the zcode way: 10.1亿 / 6178.2万.

How it works

Half File Role
host lib/index.js Hooks the sessionPersistence seam, scans session logs and folds them into daily/per-model summaries (in-memory index: full scan at boot + incremental every 60s); read-only loopback endpoint GET /api/usage-stats/usage?days=N
client src/client.jslib/client.js Registers a button in the sidebar.footer.action slot; react-dom portal full-page panel; hand-written SVG/DOM charts, no third-party deps

Event-parsing semantics match TokenLedger (both usage chunks and assistant/message are received, same-(turn,step) samples replace each other, message counts ride on events), but no relay attribution — aggregation is per-model only.

Install (link, development)

npm install
npm run build        # esbuild syntax-check src/client.js → lib/client.js
npm run link-profile # wire into ~/.dsh/profiles/web, then restart dsh web

link-profile does: add a link: dependency to the profile's dependencies, append to dsh.profile.bundles, and run pnpm install in the profile. Then restart dsh web (by convention, no auto-restart).

Verify

After restarting dsh web: a Usage stats row appears above Settings; DevTools console shows [usage-stats] bundle script executing / factory materializing. If the panel 404s or errors, check the host log for usage-stats: serving /api/usage-stats/usage.

Development

npm install
npm run build
npm test             # node test/smoke.mjs — core contract smoke tests for both halves
npm run link-profile

License

MIT