eurt-nano/dsh-cache-cost-monitor ↗★ 1
dsh-cache-cost-monitor
DSH (DeepSeek Harness) v0.1.x Cordis 插件:自动监听每轮模型 API 调用的缓存命中/未命中/输出 tokens,实时统计缓存命中率与按官方定价(含峰谷时段)预估的 API 费用,注册 cache_report 工具,并在浏览器每条消息末尾低调显示本轮 tokens 与人民币消耗。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:eurt-nano/dsh-cache-cost-monitor说明文档
阅读完整 README ↗2. 安装进 profile(web 即你正在使用的浏览器 profile),
或安装固定版本(Release 标签,推荐生产使用)
dsh plugin --profile web add https://github.com/eurt-nano/dsh-cache-cost-monitor.git#v0.2.0 --config.node-linker=isolated
> **git 安装说明**:包内 `prepare` 脚本会在安装时自动构建(`npm run build`);
> pnpm 默认拦截第三方包的构建脚本,若被拦截,把 `dsh-cache-cost-monitor`
> 加入 profile 的 `pnpm-workspace.yaml` 的 `allowBuilds` 列表即可
> (DSH 会打印具体需要的键名)。Windows 下同样请保留
> `--config.node-linker=isolated`(见上文 Windows 说明)。
---
## 使用
### 1. `cache_report` 工具
安装重启后,Agent 的工具列表会自动出现 `cache_report`。直接对它说"调用 cache_report"即可,报表形如:
```markdown
## 使用
### 1. `cache_report` 工具
安装重启后,Agent 的工具列表会自动出现 `cache_report`。直接对它说"调用 cache_report"即可,报表形如:
```markdown
## 配置参考(`cordis.patch.yml`)
| 字段 | 默认 | 说明 |
| --- | --- | --- |
| `threshold` | `0.3` | 单轮缓存命中率告警阈值(0~1) |
| `cumulativeThreshold` | `0.3` | 累计缓存命中率告警阈值(0~1),状态翻转时提示一次 |
| `historySize` | `20` | 趋势窗口轮数(>= 2) |
| `warnOnMissingUsage` | `true` | 响应缺 usage 字段时是否输出 debug 日志 |
| `timeBilling` | `auto` | 峰谷计价:`auto`(高峰 UTC 00:30–16:30,非高峰为其半价)/ `peak` / `off-peak` |
| `currency` | `both` | 费用显示:`USD` / `CNY` / `both` |
| `usdCnyRate` | `6.8` | 美元→人民币汇率 |
| `pricing` | 见下 | 按模型 ID 的定价表(USD / 每百万 tokens) |
内置定价(`cacheHit` / `cacheMiss` / `output`,USD / 1M tokens):
| 模型 | OFF-PEAK 非高峰 | PEAK 高峰 |
| --- | --- | --- |
| deepseek-v4-flash | 0.007 / 0.22 / 0.66 | 0.014 / 0.44 / 1.32 |
| deepseek-v4-pro | 0.022 / 0.66 / 1.98 | 0.044 / 1.32 / 3.96 |
| deepseek-chat | 0.028 / 0.28 / 0.42 | — |
| deepseek-reasoner | 0.14 / 0.55 / 2.19 | — |
未配置的模型按 0 计费并在报表中标注;`deepseek-v4-*` 变体按前缀回退到对应系列定价。官方调价后直接在 `cordis.patch.yml` 的 `config.pricing` 覆盖即可(补丁按层合并、后写胜出)。
---