DeepSeek Harness plugin

dsh-conversation-cost-uersx

DeepSeek Harness (dsh) plugin: track how much the current conversation costs in real time. Reads the real token usage recorded in the session log and estimates the cost per DeepSeek V4 official

Jump to install

Source facts

Repository
Uersx/dsh-conversation-cost
Latest update
Aug 18, 2026
Category
Memory
GitHub stars
0
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/Uersx/dsh-conversation-cost
Plugin: dsh-conversation-cost-uersx
Author: Uersx

Check the source files

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

File explorer3 files
README.mdSource · read only

dsh-conversation-cost

DeepSeek Harness(dsh)插件:实时统计当前对话(当前会话)花费了多少钱

基于会话日志中每条 assistant/message 携带的真实 usage(provider 返回的 token 数), 按内置 DeepSeek V4 官方价(元/百万 tokens)估算费用,并按每条调用实际发生时间区分高峰 / 空闲时段分别计价。

特性

  • 实时金额:侧边栏底部常驻显示 ¥X.XX · N 次,每 5 秒自动刷新,随对话增长实时更新(完全替代出厂 Cordis 面板徽标位,侧边栏底部只显示金额)。
  • 真实数据:读的是会话日志里的权威 usage(inputTokens / outputTokens / cacheReadTokens / cacheWriteTokens / reasoningTokens),不是估算出来的 token 数。
  • 分段计费:每条调用按自身 event.time 归属高峰(每日 9:00–14:00,价 ×2)或空闲时段,分别累加,不做整段统一价。
  • 缓存命中计价:输入计费 = 未命中输入 + 缓存写入(未命中价)+ 缓存命中(命中价,仅为未命中价的 1/30)。
  • 模型工具conversation_cost,模型可主动调用,返回逐次明细 + 汇总。
  • 技能conversation-cost,出现在技能目录,指导模型何时调用与如何汇报。

目录结构

dsh-conversation-cost/
├── package.json        # npm 包清单 + dsh.bundle / dsh.client 声明 + prepare 构建脚本
├── tsconfig.json       # 严格模式类型检查配置(tsc --noEmit)
├── tsdown.config.ts    # 构建配置:Node 库(lib/)+ 浏览器 client bundle(lib/client.js)
├── cordis.patch.yml    # bundle 配置层:插入插件行
├── src/
│   ├── index.ts        # 主插件:费用计算 + conversation_cost 工具 + 技能 + HTTP route
│   └── client.ts       # 浏览器半边:侧边栏底部费用读数(sidebar.footer.action 插槽,完全替代 Cordis 面板位)
└── pnpm-workspace.yaml # 独立 workspace 声明

安装

# 本地目录
dsh plugin --profile demo add /path/to/dsh-conversation-cost

# 从 GitHub 安装(拉源码并自动构建 lib/)
dsh plugin --profile demo add github:you/dsh-conversation-cost

安装后验证配置层并启动:

dsh --profile demo --dump-config   # 应看到 "# == dsh-conversation-cost" 层
dsh --profile demo

> 侧边栏读数(client 半边)只在插件以包名安装进带完整界面的 profile 时加载 > (如 dsh plugin --profile web add ...);--patch 源码路径挂载只加载 host 半边。

conversation_cost 工具

用户问"这个对话/会话花了多少钱、费用、成本"时,模型会自动调用:

{
  "timeBucket": "auto"
}

timeBucket 可选:auto(默认,按每条调用实际时间分别计费)、peak(全部按高峰价)、off-peak(全部按空闲价)。

返回示例(工具渲染后):

当前对话(会话 session-xxx)模型费用估算(按每次调用实际时段)
- 模型调用:171 次,其中可计价 171 次
- 总费用:¥3.8600
  · 空闲时段:¥3.8600(171 次调用)
  · 高峰时段:¥0.0000(0 次调用)
- 输入 tokens:759975(缓存命中 20600448,缓存写入 0)
- 输出 tokens:140346

计费口径

模型时段输入未命中缓存命中输出
deepseek-v4-flash空闲1.50.054.5
deepseek-v4-flash高峰3.00.109.0
deepseek-v4-pro空闲4.50.1513.5
deepseek-v4-pro高峰9.00.3027.0
  • 高峰时段为每日 9:00–14:00(按事件实际时间判断),其余为空闲时段;高峰价 = 空闲价 ×2。
  • 输入计费 = 未命中输入 + 缓存写入(未命中价)+ 缓存命中(命中价);输出按输出价(DeepSeek completion_tokens 已含 reasoning tokens,不会重复计)。
  • 金额为估算值,实际以平台账单为准;未知模型会单独列出(token 照常统计,费用不计入)。

架构

flowchart LR
    subgraph dsh["DeepSeek Harness (dsh)"]
        P["dsh-conversation-cost"]
        P -->|"会话日志 assistant/message usage"| C["费用计算<br/>按 event.time 分高峰/空闲"]
        C -->|"conversation_cost 工具"| M["模型主动查询"]
        C -->|"GET /dsh-conversation-cost/summary"| W["webServer route"]
        W -->|"fetch 轮询 5s"| F["侧边栏底部读数"]
    end

本地开发

pnpm install
pnpm typecheck
pnpm build

在 deepseek-harness 源码根目录用 overlay 直接加载 host 半边:

pnpm dsh web --patch /absolute/path/to/dsh-conversation-cost/cordis.patch.yml

> ⚠️ --patch overlay 只加载 host 半边(发现不了包级 dsh.client 声明), > 侧边栏读数不会出现;要测试 client 半边,必须把包按包名安装进带 GUI 的 profile: > pnpm dsh plugin --profile web add /absolute/path/to/dsh-conversation-cost && pnpm dsh web

发布

  • npmpnpm publishfiles 已包含构建产物与补丁)
  • tarballpnpm pack,用户 dsh plugin --profile demo add ./dsh-conversation-cost-0.1.0.tgz
  • gitdsh plugin add github:you/dsh-conversation-cost。pnpm ≥10/11 对 git 依赖的

prepare 构建脚本有白名单限制,首次安装会报 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED, 需要把该仓库加进 profile 的 pnpm-workspace.yamlallowBuilds

``yaml allowBuilds: dsh-conversation-cost@git+https://github.com/you/dsh-conversation-cost.git: true ``

相关文档