zhangzheng25/dsh-token-monitor
DeepSeek Harness 插件:Token 用量与对话统计设置页 - 今日 / 7日 / 30日总计,GitHub 风格 90 天贡献图,会话日志回填 | DeepSeek Harness 插件:Token 用量与对话统计设置页
Project Overview项目介绍
This is a native DeepSeek Harness (DSH) plugin built exclusively for DSH that adds a persistent "Today's Usage" card to the bottom of the DSH sidebar, right next to the settings icon. The card displays a live running total of daily token usage, updating automatically every 30 seconds, and it collapses to just show the numeric value when the sidebar is folded to save space. Clicking the card opens a full-featured modal statistics window that shows aggregated usage data across multiple time ranges, including daily, 7-day, and 30-day totals, plus 30-day stacked usage charts broken out by model.
This plugin is designed for DSH users who want to easily track their token usage and understand how much they are using each model over time. The plugin automatically pulls usage data directly from DSH session logs, which is the only data source it uses, and it does an idempotent re-scan of all existing sessions on launch, on manual trigger, and every 30 seconds during auto-refresh. This means that even usage from before you installed the plugin will be counted correctly, with no duplicate counts even if you run the backfill process multiple times. It also separates top-level sessions from internal sub-agent conversations for accurate session count statistics.
To install the plugin, you can run the DSH plugin command directly from this GitHub repository, or install it from a local directory if you cloned it to your machine. After running the install command, you will need to restart DSH for the plugin to load, and the usage card will automatically appear in the sidebar once DSH restarts. All usage data is stored persistently in a JSON file under the DSH home directory, and it retains 181 days of data sorted into daily buckets by model. The plugin follows DSH's native styling conventions, uses DSH theme variables to automatically match light and dark mode, and is released under the open source MIT license.
这是一款专为 DeepSeek Harness (DSH) 开发的原生插件,会在 DSH 侧边栏底部(设置图标旁)添加一张「今日用量」卡片,实时显示当日累计使用的 token 总量。点击卡片即可弹出完整统计窗口,提供今日、近7天、近30天的总量统计、近30天按模型分类的堆叠用量图、30天窗口的模型使用排行,以及会话数统计。
这款插件面向需要追踪 DSH token 使用量、掌握不同模型调用频率的开发者,每30秒自动轮询刷新数据,也支持手动刷新和历史用量回填功能,安装插件之前产生的历史用量也可以完整统计。日常使用中,用户无需进入设置页面即可一键查看用量情况,侧边栏折叠时仅显示数值,不占用多余界面空间。
数据默认存储在 $DSH_HOME/plugins/token-monitor/data.json,支持持久化保存,重启应用不会丢失,按天分桶保留181天的数据。插件遵循原生 DSH 主题风格,自动跟随亮色/深色主题切换,采用 MIT 许可开源,安装后只需要重启 DSH 即可使用。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-token-monitor(zhangzheng25/dsh-token-monitor)
仓库:https://github.com/zhangzheng25/dsh-token-monitor
本站详情页:https://www.yhbd.top/plugins/zhangzheng25-dsh-token-monitor/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 MIT · ⭐ 6 · 最近提交 2026-08-16 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- Only 6 stars - very few users, little community feedback星标只有 6,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add github:zhangzheng25/dsh-token-monitor
把 zhangzheng25/dsh-token-monitor 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-token-monitor
简体中文 | English
🤖 AI 生成声明:本项目由 AI 辅助生成,仅供学习与技术交流使用,不构成任何形式的商业保证或支持承诺。
一个 DeepSeek Harness 插件:在侧边栏底部(设置图标旁)放一张 「今日用量」卡片,实时显示今日 token 总量(形如"今日用量:8888万");点击卡片即弹出完整统计窗口——今日 / 近 7 天 / 近 30 天总量、近 30 天按模型的堆叠用量图、按模型的使用排行(固定 30 天窗口)、以及会话数统计。不再占用设置页面,一键直达。

功能特性
- 🚀 一键直达 — 侧边栏「今日用量」卡片实时显示今日 token 总量(单行"今日用量:8888万",每 30 秒自刷新,折叠成窄栏时只显示数值);点击弹出统计窗口(支持 Esc / ✕ / 点遮罩关闭,背景滚动锁定)。
- 📊 近 30 天模型使用情况 — 30 天堆叠柱状图:每根柱子按模型分色堆叠(当天用量最高的模型在柱底,颜色按 30 天排名固定);图表区域铺满灰色点阵网格背景(每一天恰好两列点、垂直每 13px 一行,参考
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 深色主题。
安装
从本仓库安装:
dsh plugin --profile web add github:zhangzheng25/dsh-token-monitor
或从本地目录安装:
dsh plugin --profile web add E:\path\to\dsh-token-monitor
dsh plugin 会在 profile 目录中转发给 pnpm 安装,并自动调和 dsh.profile.bundles;包内 dsh.bundle.patch(cordis.patch.yml)把插件行插入宿主组合,dsh.client.platform: "web" 让 web 外壳加载 client/bundle.js。
安装后重启 DSH,侧边栏底部(设置图标旁)会出现「今日用量」卡片,点击即弹出统计窗口。
架构
┌────────────────────────── Host(Node.js)──────────────────────────┐
│ src/index.js │
│ • backfill() ← 会话日志为唯一数据源(幂等全量重建: │
│ sessionQuery 为 live-preferred,内存活跃会话 + 落盘日志都算, │
│ 每次把窗口内全部 assistant/message 的 usage 折叠进新桶并原子 │
│ 替换,重复运行不重复计数;启动 / 点「回填历史」/ 30 秒轮询都跑) │
│ (输入 / 输出 / 缓存命中 / 缓存未命中 / 推理,按天按模型分桶, │
│ 模型归属取 message.source,覆盖 181 天窗口) │
│ • buildSessionStats() ← 顶层对话统计(delegationDepth === 0)│
│ (20 秒缓存) │
│ • persist() ← 防抖写入(schema v3:按天按模型分桶, │
│ 保留 181 天) │
│ $DSH_HOME/plugins/token-monitor/data.json │
│ • webServer.register('/token-monitor/today') ← 轻量今日读数(不触发│
│ 重建,供侧边栏卡片轮询) │
│ • webServer.register('/token-monitor/snapshot') ← 供 Client 读取 │
│ (静态 bundle 模式,含 modelRank 三档聚合 + modelDaily30) │
└─────────────────────────────────────────────────────────────────────┘
│ fetch('/token-monitor/snapshot')
▼
┌────────────────────────── Client(浏览器)─────────────────────────┐
│ client/bundle.js — 手工构建的 web bundle,符合 client-modules 协议 │
│ (window.__ModuleLoader__.load) │
│ • slots.inject('sidebar.footer.action') → 侧边栏「今日用量」卡片 │
│ (点击弹出 fixed 模态,内容 = 完整统计面板;无 settings.section)│
│ • 指标卡 + 会话卡 + 30 天模型堆叠图 + 模型使用排行 │
│ • 卡片每 30 秒轮询 /token-monitor/today;弹窗打开时拉取快照并 │
│ 每 30 秒刷新,另有刷新 / 回填历史按钮 │
└─────────────────────────────────────────────────────────────────────┘
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
edison7009/EchoBird
wssfk12138/dsh-damage-pulse
edonadei/caliper
Ychris12138/dsh-usage-stats
JingbiaoMei/Tokdash
yxxbc/dsh-balance-plugin
feiyang-dev/dsh-usage-plugin
Make0209/dsh-usage-stats