noone89A/dsh-gauge 预览 preview

noone89A/dsh-gauge

为DeepSeek Harness Web UI提供精确的缓存命中率、token使用量及费用估算。

Project Overview项目介绍

dsh-gauge is a native plugin built exclusively for DeepSeek Harness Web UI, designed to fix the official rounding issue of cache hit rate and add accurate token usage and cost estimation. It can be installed with one command by running dsh plugin --profile web add dsh-gauge, then restart dsh web to activate it. After installation, it automatically replaces the official stats line with an accurate version that shows hit rate with configurable decimal places, so 99.8% will display as 99.8% instead of misleading 100%. It also adds a usage panel that is accessible via a ⓘ button on the session header.

This plugin works out of the box right after installation, no extra configuration is required for regular users to access all core features. For developers who want to adjust settings like decimal places or currency, you can edit the configuration via the plugin settings card after adding gauge to the DSH whitelist, or edit the cordis.patch.yml file directly if you don’t want to modify the whitelist. All configuration changes take effect immediately after saving, except for the replaceNativeStatsLine setting which requires a restart of dsh web to apply all changes.

dsh-gauge is released under the open source MIT license, so anyone can use, modify and distribute it according to the license terms. It automatically follows DeepSeek's official price adjustments and peak/off-peak pricing rules, calculating cost based on each message's timestamp to ensure accurate estimation. There are a few known caveats: some adapters always report 0 cache-write token, which the plugin handles by hiding the write bucket when it is 0, and this does not affect core functionality. Cost is an estimate only, so you should refer to your official DeepSeek bill for actual charges.

dsh-gauge是专为DeepSeek Harness Web UI开发的原生插件,用于提供精确的缓存命中率、token用量统计和DeepSeek API费用估算。官方原来的统计会把缓存命中率四舍五入成整数,导致99.8%显示成误导性的100%,该插件用可配置小数位的精确数值替换原有统计,还补充分桶token明细、会话用量面板和自动跟随官方调价的会话费用估算。

安装完成后重启dsh web即可开箱即用,无需额外配置,普通用户就能使用所有核心功能。用户可以在输入框下方看到精确统计行,包含精确缓存命中率、分桶明细、预估费用和当前高峰/闲时段标识,还可以点击会话页头的ⓘ按钮打开用量面板,查看完整token统计、上下文占用和新旧价格对比。

该插件采用MIT许可证开源,可通过dsh plugin命令一键安装,也支持手动配置。当前DSH版本限制第三方插件的配置卡片显示,若需要可视化配置,需手动将gauge加入白名单,不加入白名单也不影响任何核心功能,仅无法可视化调整配置。所有配置修改后立即生效,仅修改replaceNativeStatsLine需要重启生效。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
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-gauge

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

READMEREADME

dsh-gauge

中文 | English

为 DeepSeek Harness Web UI 提供精确缓存命中率、token 用量与费用估算。

官方统计行把缓存命中率四舍五入成整数——Math.round 会把 99.8% 显示成误导性的 100%。 dsh-gauge 用一位小数(可配置)的精确数值顶替它,并补充分桶 token 明细、会话用量面板,以及自动跟随 DeepSeek 官方调价的会话费用估算(使用官方 API)。

功能

  • 精确缓存命中率 — cacheRead / (cacheRead + uncached + cacheWrite),小数位可配置(默认 1),99.8% 就是 99.8%。
  • 分桶明细 — 命中 / 未命中输入 token 与输出 token。写入桶为 0 时自动隐藏(opencode-go/pi-ai 适配器从不报告 cache-write,实际恒为 0)。
  • 费用估算 + 调价对比 — 按实际用量 × 模型单价估算(deepseek-v4-flash / deepseek-v4-pro,自动从会话推导)。官方新价生效前显示 当前费用 + 新价费用 + 预计涨幅;生效时刻自动切换到新价。
  • 按请求时刻的峰谷计价 — 估算不是"当前时刻"快照:每条 assistant 消息按自己的时间戳计价,高峰时段消耗的 token 按高峰价、闲时按折扣价,最后求和。
  • 高峰时段徽标 — 北京时间 09:00–12:00 / 14:00–18:00 为 DeepSeek 峰谷定价的高峰窗口。统计行尾按当前时段显示高峰/闲时状态(切换为新价后同样按当前时段显示)。
  • 用量面板 — 会话页头 ⓘ 按钮弹出面板:模型、命中率、计费输入、各桶总数(默认完整数字)、上下文占用与费用估算(含调价后对比)。
  • 两行统计(官方指标 + 精确用量) — 第一行保留官方会话指标(轮/步、LLM/工具调用时长、首 token 平均、tok/s),复刻官方样式(行距刻意收紧,两行视为一个整体);第二行是插件的精确用量(命中率、分桶、输出、费用、高峰/闲时徽标)。replaceNativeStatsLine: false 时保留官方原生行(含原生用量段)。
  • 双语 & 货币自适应 — UI 为英文时文案切英文、费用按国际价目表以 USD 估算。语言与货币实时跟随,无需重启。

截图

统计行 用量面板

安装

# 一条命令(推荐):dsh plugin 会 pnpm add,
# 并自动把声明了 dsh.bundle 的包加进 dsh.profile.bundles
dsh plugin --profile web add dsh-gauge

# 手动方式:cd ~/.dsh/profiles/web && npm install dsh-gauge,
# 然后编辑 profiles/web/package.json,把 "dsh-gauge" 加进 dsh.profile.bundles

# 重启
dsh web

输入框下方应出现精确统计行,会话页头出现 ⓘ 用量入口。

本地开发/调试:用源码安装替代——pnpm add file:C:/Object/dsh-plugin/dsh-gauge(源码改动后 npm run build 即生效,适合改 src/config.ts 的价格/高峰窗口)。

开箱即用 & 配置卡片

装完重启后开箱即用,无需任何配置:

  • 输入框下方两行统计:精确缓存命中率(99.8% 就是 99.8%)、分桶明细、输出、预估费用、高峰/闲时徽标;
  • 会话页头 ⓘ 用量面板:完整 token 数字、上下文占用、模型、费用与调价对比;
  • 中英文文案与费用货币自动跟随界面语言。

设置 → 插件 → 可配置插件里的 dsh-gauge 配置卡片:由于当前 DSH 版本把可暴露给网页端的插件设置写死在白名单(dsh-host-apiproxy 的 WEB_SETTINGS_NAMESPACES),第三方插件需一次性把 gauge 加入白名单后卡片才会显示(步骤见"故障排查")。不加入白名单不影响任何核心功能——不想动白名单时,也可直接编辑 cordis.patch.yml(见"配置")。

工作原理

  • 统计行注册进 conversation.composer.dock 槽位。replaceNativeStatsLine: true(默认)时以 priority: -1 注册进官方 stats cell,影子顶替原生行;false 时以 order: 1 追加为第二行。
  • token 总量来自 tokenUsage 投影(@deepseek-ai/dsh-token-meter);上下文占用来自 contextPressure。
  • 费用估算翻页拉取全会话历史(sessions.history):每条已定稿的 assistant 消息自带完成时间与 usage,按消息自己的时间戳套高峰/闲时费率(新方案)或平价(当前旧价),再求和——窗口外("加载更早"之前)的历史同样精确计价,不会出现"命中 2 亿 token 费用却只有几毛钱"。
  • 当前模型从全量历史的最后一条 assistant 消息推导(source.model;无连接面时降级用 trajectory 视图的 requestConfig.model),或通过 model 配置固定。
  • 上下文压缩(compaction)后旧事件被摘要替代:费用与官方 tokenUsage 投影基于相同的事件集合,两者保持一致(压缩丢弃的用量官方同样丢弃)。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dph-endfield-theme 下一个 Next auto-pwa →