Skip to content

zhangzheng25/dsh-token-monitor

41Last commit Aug 15, 2026

dsh-token-monitor DSH plugin

This plugin adds a 'Token Usage' section to the DSH settings page, showing today's, last 7 days', and last 30 days' total tokens, a 30-day stacked bar chart by model, a model usage ranking (fixed 30-day window), and conversation statistics. It automatically refreshes every 30 seconds and persists data to disk for restart resilience.

How to install the dsh-token-monitor DSH plugin

dsh plugin --profile web add github:zhangzheng25/dsh-token-monitor

Copying does not run this command. Review the repository and version before installing the dsh-token-monitor DSH plugin.

dsh-token-monitor DSH plugin data source

dsh-token-monitor DSH plugin snapshot date: Aug 16, 2026

discovered

What the dsh-token-monitor DSH plugin can do

  • Displays token metrics cards for today, last 7 days, and last 30 days in wan/yi units
  • Shows a 30-day stacked bar chart with model colors and a dotted grid background, with tooltip on hover
  • Provides a 2×2 model usage ranking card for the top 4 models over the last 30 days
  • Counts top-level conversations (delegationDepth === 0) for today, last 7 days, and last 30 days
  • Auto-refreshes every 30 seconds with idempotent re-scan; manual 'Refresh' and 'Backfill History' buttons
  • Persists data to $DSH_HOME/plugins/token-monitor/data.json, retaining 181 days of daily buckets
  • Backfill history from session logs on startup, button click, or periodic polling, idempotently rebuilding all data without duplicates
  • Follows DSH native theme with --dsw-alias-* variables, supporting light/dark modes

Where the dsh-token-monitor DSH plugin fits

  • Monitor personal token consumption across different models to manage costs
  • Identify which models are used most frequently over the last 30 days
  • Track conversation activity trends to evaluate usage patterns
  • Ensure data persistence across restarts for continuous monitoring
  • Backfill historical data from before plugin installation to get a complete picture

Who the dsh-token-monitor DSH plugin is for

  • DSH users who want to track their LLM token usage
  • Developers or researchers who need to monitor model usage patterns in DSH

dsh-token-monitor DSH plugin limitations

  • Requires DSH installed and running with a web profile
  • Data source is limited to session logs; messages without usage fields are not counted
  • Only supports the web client (client/bundle.js, not terminal or other modes)
  • Data retention is fixed at 181 days; older data is automatically discarded
  • The plugin is AI-generated and for learning/technical exchange only, no commercial guarantee

dsh-token-monitor DSH plugin: from the repository README

Quoted from the zhangzheng25/dsh-token-monitor README, the upstream source of the dsh-token-monitor DSH plugin. Copyright remains with the original authors.

> 🤖 **AI 生成声明**:本项目由 AI 辅助生成,仅供学习与技术交流使用,不构成任何形式的商业保证或支持承诺。 一个 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 插件:在 **设置 → Token 用量** 页面上原生展示你的 **token 用量与对话统计**——今日 / 近 7 天 / 近 30 天总量、近 30 天**按模型**的堆叠用量图、按模型的使用排行(固定 30 天窗口)、以及会话数统计。 ![Token 用量设置页](screenshot.png) ## 功能特性 - 📊 **指标卡** — 今日 / 近 7 天 / 近 30 天的 Tokens 总量(万 / 亿单位),只显示大数字,保持清爽。 - 📊 **近 30 天模型使用情况** — 30 天堆叠柱状图:每根柱子按模型分色堆叠(当天用量最高的模型在柱底,颜色按 30 天排名固定);图表区域铺满**灰色点阵网格背景**(每列约两列点、从上到下铺满,参考 `temp/model-usage.png`),有调用的柱子叠在点阵之上;横轴只显示**每周一**的基准日期;悬浮/点击某天弹出明细卡片(日期 / 总计 / 各模型色块行,样式参考 `temp/tooltip.png`),无任何高亮/变灰/柱上标签效果。 - 🏆 **模型使用排行** — 固定 30 天窗口:前 4 名 **2×2** 卡片(序号一行 / 模型名 + token 总数 / 提供商 + 占比右对齐,无增长与单位标签),悬停轻微放大。 - 💬 **会话统计** — 今日 / 近 7 天 / 近 30 天开启的顶层对话数(不含子代理内部会话),副文字显示对应时段的模型请求次数。 - 🔄 **自动刷新** — 页面每 30 秒轮询(带幂等重扫,数字自动修正),另有手动「刷新」与「回填历史」按钮。 - 💾 **持久化** — 数据写入 `$DSH_HOME/plugins/token-monitor/data.json`,重启不丢(按天桶保留 181 天;每个桶内按模型细分)。 - 🕘 **历史回填** — 会话日志是唯一数据源:启动 / 点击「回填历史」/ 30 秒轮询都会把窗口内全部会话用量**幂等重扫**进新桶(原子替换),把插件安装**之前**的用量也统计进来;重复运行不会重复计数,旧桶脏数据自动自愈,30 天堆叠图与模型排行立即可用。 - 🎨 **DSH 原生风格** — 亮色主题、1px 细边框卡片、8–10px 圆角、无阴影;颜色走 `--dsw-alias-*` 主题变量,跟随 DSH 深色主题。 ## 安装 从本仓库安装: ```bash dsh plugin --profile we

Read the full READMERepository license: MIT

dsh-token-monitor DSH plugin questions

How do I install the dsh-token-monitor plugin?

Run the command `dsh plugin --profile web add github:zhangzheng25/dsh-token-monitor` in your terminal. After installation, restart DSH and navigate to Settings → Token Usage to see the page. You can also install from a local directory using `dsh plugin --profile web add E:\path\to\dsh-token-monitor`.

Does the plugin automatically refresh data?

Yes, the plugin polls every 30 seconds to refresh token usage and conversation statistics. The refresh is idempotent, meaning it will not duplicate data. There are also manual 'Refresh' and 'Backfill History' buttons on the page.

Will my data persist after restarting DSH?

Yes, all data is persisted to `$DSH_HOME/plugins/token-monitor/data.json` and survives restarts. The plugin retains daily buckets for up to 181 days. Older data is automatically discarded.

Can I see historical token usage before installing the plugin?

Yes, the plugin can backfill historical data from existing session logs. On startup, when you click the 'Backfill History' button, or during periodic 30-second polling, it will idempotently rebuild all data from the session logs, including usage before the plugin was installed.

What data sources does the plugin use for token counting?

The plugin uses session logs as its sole data source. It reads the `usage` field from `assistant/message` events in session logs, and model attribution is taken from the `message.source` provider/model. It also reads top-level conversations (delegationDepth === 0) for conversation counts.