DeepSeek Harness plugin

dsh-model-usage-timmonon

模型用量 (Model Usage) dashboard for DeepSeek Harness — per-API token/cost tracking with a GitHub-style activity heatmap and usage details in the settings page.

Jump to install

Source facts

Repository
Timmononon/dsh-model-usage
Latest update
Aug 20, 2026
Category
Models & Providers
GitHub stars
1
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/Timmononon/dsh-model-usage
Plugin: dsh-model-usage-timmonon
Author: Timmononon

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-model-usage

DeepSeek Harness(DSH)的本地模型用量统计插件。插件在 DSH 设置页中增加“模型用量”页面,用于查看 Token 活动、模型调用次数、缓存命中和成本估算。

所有用量记录均保存在本机,不上传聊天内容、API Key 或统计数据。

功能

  • 统计输入、输出、缓存读取、缓存写入和推理 Token
  • provider/model 汇总模型用量
  • 展示累计 Token、单次峰值、最长调用时长和连续使用天数
  • 提供近半年和近一年的 Token 活动视图
  • 支持每日、每周和累计三种活动展示方式
  • 展示总 Token、总请求数、缓存命中、缓存命中率和总成本
  • 支持人民币与美元切换,固定汇率为 1 美元 = 6.8 人民币
  • 支持全部模型或指定模型筛选
  • 页面加载时刷新,并每 60 秒自动刷新;也可手动刷新
  • 每次调用结束后立即写入本地 JSONL(包括失败和取消),重启 DSH 后自动恢复统计
  • 采集 DSH web_search 产生的 DeepSeek Flash 用量,并合并到现有 Flash 统计中

环境要求

  • DeepSeek Harness,且已安装 web profile
  • Node.js(版本以当前 DSH 的运行要求为准)
  • pnpm

源码安装

克隆项目并安装依赖:

git clone https://github.com/Timmononon/dsh-model-usage.git
cd dsh-model-usage
pnpm install
pnpm build

将项目以本地链接方式加入 DSH Web profile:

dsh plugin --profile web add "link:D:/path/to/dsh-model-usage"

然后启动 DSH:

dsh web

默认访问地址为:

http://127.0.0.1:3080

打开 DSH 设置页后,可以在“模型用量”分区中查看统计。

本地开发挂载

也可以直接编辑 Web profile 的配置文件:

~/.dsh/profiles/web/package.json

bundles 中加入插件,并在 dependencies 中设置本地路径:

{
  "dsh": {
    "profile": {
      "bundles": [
        "@deepseek-ai/dsh-base",
        "@deepseek-ai/dsh-web-app",
        "dsh-model-usage"
      ]
    }
  },
  "dependencies": {
    "dsh-model-usage": "link:D:/path/to/dsh-model-usage"
  }
}

修改后在 profile 目录刷新依赖:

cd $HOME\.dsh\profiles\web
pnpm install

Host 端代码变更需要重新构建并重启 dsh web;前端代码变更需要重新构建并刷新浏览器页面。

数据采集方式

普通模型请求通过 DSH 的 llm/stream 流采集。插件原样透传响应,并在正常完成、失败或取消时各写入一条记录,不改变模型输出。异常仍会继续抛给原调用方;若中断前已经收到 usage,则保留该用量,否则 Token 记为 0。

DSH 的 DeepSeek 网页搜索不会经过 llm/stream。插件会透明观察模型名确认为 DeepSeek、且带有 web_search_20250305 工具标识的搜索请求,克隆成功响应并读取其中的 usage。搜索用量使用 deepseek-official/deepseek-v4-flash 标识,因此会与普通 DeepSeek Flash 请求合并显示;其他提供商使用同名工具时不会被计入。

记录结构如下:

{
  ts: number       // 开始时间
  provider: string
  model: string
  inp: number      // 非缓存输入 Token
  out: number      // 输出 Token
  cr: number       // 缓存读取 Token
  cw: number       // 缓存写入 Token
  rsn: number      // 推理 Token
  dur: number      // 调用耗时,单位毫秒
  status: 'completed' | 'cancelled' | 'failed'
}

页面中的总 Token 为输入、输出、缓存读取和缓存写入之和。推理 Token 通常属于输出 Token 的细分,因此不会再次加入总量,避免重复计算。

旧版本写入的记录没有 status 字段,读取时会自动按 completed 兼容。

本地存储

默认数据文件:

~/.dsh/storages/model-usage.jsonl

如果设置了 DSH_HOME,则使用:

$DSH_HOME/storages/model-usage.jsonl

每次调用结束后追加一行记录。插件启动时从文件尾部最多回放最新 50,000 条有效记录;达到该上限后无需继续读取更早的数据。磁盘文件保持追加写入。

每日活动和连续天数统一按北京时间自然日计算。

不要将该 JSONL 文件提交到代码仓库,其中可能包含模型名称、调用时间和用量信息。

成本估算

价格配置位于 src/report.ts。当前对以下模型使用专用价格表:

  • GPT-5.6 Luna
  • GPT-5.6 Terra
  • GPT-5.6 Sol
  • DeepSeek V4 Flash
  • DeepSeek V4 Pro

GPT-5.6 分别计算非缓存输入、输出、缓存读取和缓存写入;单次计费输入超过 272,000 Token 时使用长上下文价格。

DeepSeek V4 分别计算缓存命中、缓存未命中输入和输出,并按北京时间使用峰谷定价:

  • 高峰:09:00–12:00、14:00–18:00
  • 空闲:其他时段

未配置专用价格的模型使用通用美元单价估算。页面显示的成本仅用于本地参考,不代表服务商最终账单。

HTTP 接口

插件在本地 DSH Web 服务中注册以下接口:

方法路径说明
GET/api/model-usage?model=获取汇总、每日活动、模型列表和调试信息

开发命令

pnpm typecheck
pnpm test
pnpm build
pnpm watch
  • pnpm typecheck:执行 TypeScript 类型检查
  • pnpm test:执行价格、缓存、日期、热力图、流式异常、搜索归属和持久化行为测试
  • pnpm build:生成 Host、浏览器端代码和类型声明
  • pnpm watch:监听源码变化并重新打包

构建产物位于 lib/,不会提交到代码仓库。

项目结构

src/index.ts                         Host 插件、持久化、聚合与 HTTP 接口
src/search-usage.ts                  DeepSeek 网页搜索用量采集
src/storage.ts                       JSONL 尾部读取与记录校验
src/stream-usage.ts                  模型流透传、结束状态与用量落盘
src/usage-math.ts                    价格、缓存与北京时间统计逻辑
src/activity-grid.ts                 活动图日期窗口计算
src/report.ts                        数据类型和模型价格表
src/client/index.ts                  设置页注册入口
src/client/UsageSection.tsx          模型用量页面
src/client/UsageSection.module.css   页面样式
test/                                行为回归测试
cordis.patch.yml                     DSH bundle 注册配置

License

MIT