dsh-usage-report

August 16, 2026 · View on GitHub

npm version License: MIT

DeepSeek Harness(DSH)Web 界面插件:在会话头部加一个「额度」按钮,一键查看当前会话各模型的 token 用量、缓存命中率和估算费用

模型输入输出缓存命中率费用
deepseek-v4-flash207,272289,84599.7%¥4.6291

这是什么

DSH 是 DeepSeek 官方的 agent 运行环境。这个插件解决一个实际问题:我到底花了多少钱?

  • 点开会话头部的「额度」按钮,立刻看到当前会话每个模型的:
    • 输入 / 输出 token 数
    • 缓存命中率(命中 / (命中+未命中))
    • DeepSeek 官方峰谷价估算的费用(高峰/空闲自动区分,按每个请求的发生时间计价)
  • 数据来自 DSH 自己的会话日志(assistant/message 的 provider 用量记录),只读、不上传、不联网(打开面板零网络请求,数据由本地 host 实时推送)。

安装(npm 一条命令)

前提:本机有 DeepSeek Harness(dsh web 可用)。

dsh plugin --profile web add dsh-usage-report

dsh plugin 会自动把插件加进 profile 的 bundle 层栈并挂载(无需改任何配置文件),然后重启 dsh web 即可。

关于 dsh 命令:必须是 DeepSeek Harness 的 CLI@deepseek-ai/dsh,带 plugin 子命令)。如果你的终端里 dsh 不是它(例如报 {doctor, chat, probe, validate, estimate, version} 之类的不认识 plugin 的命令集,或提示找不到命令),请用完整路径调用:

node "<dsh 安装目录>/node_modules/@deepseek-ai/dsh/lib/bin.js" plugin --profile web add dsh-usage-report

常见安装位置:%LOCALAPPDATA%\npx-cache\...\node_modules\@deepseek-ai\dsh\lib\bin.js(Windows npx 缓存)或 $(npm root -g)/@deepseek-ai/dsh/lib/bin.js。不确定时先执行 node "<路径>/bin.js" --help,能看到 plugin 子命令的就是对的。

使用

  1. 打开任意会话;
  2. 会话头部(Session log 旁边)出现「额度」按钮;
  3. 点击弹出面板:模型明细表 + 本会话合计 + 计价说明;
  4. 鼠标悬停在"缓存命中率"上可看原始 token 数。

价格

DeepSeek 官方 2026-08-17 生效的峰谷定价(人民币 / 百万 tokens):

模型时段缓存命中输入(未命中)输出
deepseek-v4-flash空闲¥0.05¥1.5¥4.5
deepseek-v4-flash高峰¥0.10¥3.0¥9.0
deepseek-v4-pro空闲¥0.15¥4.5¥13.5
deepseek-v4-pro高峰¥0.30¥9.0¥27.0

高峰时段:北京时间 9:00–12:00、14:00–18:00(其余为空闲)。默认 mode: auto 按事件时间自动选价;未列出的模型用默认价估算。

改价格:编辑自己 profile 的 cordis.patch.yml$env:USERPROFILE\.dsh\profiles\web\cordis.patch.yml),按 id 覆写配置,重启生效:

- id: dsh-usage-report
  config:
    mode: auto          # auto | peak | off-peak
    prices:
      deepseek-v4-flash:
        peak: { inputPerM: 3.0, outputPerM: 9.0, cacheReadPerM: 0.1, cacheWritePerM: 3.0 }
        offPeak: { inputPerM: 1.5, outputPerM: 4.5, cacheReadPerM: 0.05, cacheWritePerM: 1.5 }

说明

  • 统计范围:本机这个 DSH 实例自己的会话日志($DSH_HOME/sessions)。在 Claude Code 等其他工具里直接调用 DeepSeek API 的消耗不计入。
  • 口径:费用 = 输入/1e6×输入价 + 输出/1e6×输出价 + 缓存命中/1e6×命中价;只统计成功落地且带 provider 用量记录的请求;精确金额以官方账单为准。
  • 兼容性:基于 DSH 0.1.0-rc.6 的 slot / 投影 / bundle 接口编写,DSH 版本差异过大可能不兼容。装完看「设置 → Plugins → 插件清单」中 dsh-usage-report 是否为 active。
  • 更新dsh plugin --profile web add dsh-usage-report@latest(或 dsh plugin --profile web update dsh-usage-report),重启生效。

开发者

  • 结构:lib/index.js(host 半区:投影单元 usageByModel + 全量汇总路由)、lib/client.js(客户端 bundle)、cordis.patch.yml(bundle 挂载层)。
  • 零运行时依赖:host 半区不 import 外部包,客户端 bundle 仅依赖 react
  • 修改后需重启 DSH web 生效(Web 面禁用共享 HMR)。

许可证

MIT