Make0209/dsh-usage-stats 预览 preview

Make0209/dsh-usage-stats

DeepSeek Harness 插件:GitHub 风格用量热力图 + Token / 缓存命中 / 账户余额看板 + 工作区别名管理。

Project Overview项目介绍

This is a native plugin built exclusively for DeepSeek Harness (DSH), adding comprehensive usage tracking and analytics functionality to the DSH web client. The plugin supports two installation methods: the recommended approach is using the official DSH plugin command dsh plugin --profile web add dsh-usage-stats, which handles installation automatically. For users who want to run a local development version, they can manually register the plugin by creating a junction link in the DSH node modules directory and adding an entry to the cordis patch configuration. After either installation method, users only need to refresh the DSH web page to start using the plugin, no additional configuration or DSH restart is required.

Once activated, the plugin automatically pulls historical usage data from DSH's persistent session logs, so no manual data import is needed on the first run. It adds a dedicated analytics page to DSH's settings panel, where users can view the contribution-style heatmap, check aggregated statistics, and manage custom aliases for their workspaces. The heatmap works like GitHub's contribution graph, tracking usage over 53 weeks and updating after each completed conversation turn. Users can hover over any date to see a breakdown of usage by workspace, including total tokens and session counts for that day.

The plugin has no external third-party dependencies, which keeps its installation size small and avoids unnecessary dependency conflicts with other DSH components. The host side only uses built-in Cordis services from DSH, and the client side only uses the React framework that is already provided by DSH's internal module system. All usage data is sourced from DSH's local session logs, so existing usage data remains intact even if the plugin is restarted or uninstalled. It is released under the permissive MIT open source license for free use and modification.

这是一个专为 DeepSeek Harness 开发的原生插件,为 DSH 提供用量统计相关功能。它包含 GitHub 风格的 53 周用量热力图,每完成一次对话回合就会点亮对应日期,支持悬停查看按工作区分的次数明细和当日 Token 消耗。此外还提供多维度统计看板,涵盖 Token 消耗、缓存命中率、DeepSeek 账户余额等指标,同时支持工作区别名管理功能。

该插件可以通过 DSH 官方插件命令一键安装,也支持手动本地注册安装,安装后仅需刷新页面即可使用,无需手动修改配置或重启 DSH 程序。它会自动读取 DSH 持久化存储的历史会话日志,自动回填所有历史用量数据,适合需要统计自身 DeepSeek 用量、跟踪 Token 消耗和账户余额的 DSH 用户使用。

该插件没有额外第三方依赖,宿主端仅依赖 DSH 的 Cordis 服务,前端客户端仅依赖 DSH 内置提供的 React 模块。所有数据都存储在 DSH 的本地持久化会话中,卸载插件不会丢失原有数据,仅统计归属到已注册工作区的会话,采用 MIT 许可证开源,可免费使用和修改。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 note1 项提示
  • 26 stars - an early-stage project星标 26,属于早期项目
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 dsh-usage-stats

把 Make0209/dsh-usage-stats 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-usage-stats

awesome · DSH plugin

DeepSeek Harness 插件:GitHub 风格用量热力图 + Token / 缓存命中 / 账户余额看板 + 工作区别名管理。

  • 热力图:53 周 GitHub 绿,每完成一个回合点亮;悬停按工作区显示次数明细与当日 Token
  • 统计卡片:总花费 Token(分项)、缓存命中率、账户余额(DeepSeek 官方接口)、总使用次数、连续使用、各工作区 Token 进度条
  • 工作区别名:头部「✎ 工作区别名」管理,持久化保存($DSH_HOME/storages 的 KV 单元 usage-stats-aliases)
  • 时间范围切换(近 30 天 / 近 90 天 / 全部)、动画、亮暗主题自适应

效果截图

用量统计页面效果截图 1

用量统计页面效果截图 2

安装

本插件是标准的 DSH 社区插件包(声明 dsh.bundle manifest + web client 半),数据全部来自持久化会话日志,安装后自动回填历史。

方式一:官方插件命令(推荐)

dsh plugin --profile web add dsh-usage-stats

安装后刷新页面即可,无需手动改配置、无需重启。

方式二:手动注册(本地包)

  1. 把本目录放入任意位置,并在 $DSH_HOME/profiles/node_modules/ 下创建指向本目录的符号链接(Windows 用 junction):
    New-Item -ItemType Junction -Path "$env:DSH_HOME\profiles\node_modules\dsh-usage-stats" -Target "<本目录绝对路径>"
    
  2. 在 $DSH_HOME/profiles/web/cordis.patch.yml 添加一行:
    - insert:
        - id: usage-stats
          name: dsh-usage-stats
    
    用户 patch 层会被热重载:保存后刷新页面即可。

架构

  • Host 半(lib/index.js):扫描持久化会话日志聚合用量(turn/end + assistant/message.usage),监听 session/event 实时折叠;通过 webServer 服务注册数据路由:
    • GET /api/usage-stats — 统计快照
    • GET /api/usage-stats/balance?force=1 — 账户余额(复用 llm-deepseek 的 API Key 配置)
    • POST /api/usage-stats/alias — 设置工作区别名
  • Client 半(lib/client.js):window.__ModuleLoader__ 工厂格式的浏览器 bundle,注册设置面板「用量统计」页(settings.section 槽位)。

数据说明

  • 使用次数与 Token 全部来自 DSH 持久化会话日志,插件激活时会自动回填全部历史,插件卸载/重启后数据不丢
  • 余额查询走 DeepSeek 官方 /user/balance 接口;未配置 API Key 时卡片显示引导文案
  • 仅统计能归属到已注册工作区(按会话 cwd 匹配)的会话

开发

  • 修改 lib/index.js / lib/client.js 后刷新页面即生效(client bundle 随页面加载);host 半改动通过重启 DSH 生效
  • 插件包无第三方依赖:host 半只使用 Cordis 服务,client 半只使用 react(模块表提供)

License

MIT

← 上一个 Prev dsh-lsp-actions 下一个 Next dsh-balance →