DeepSeek Harness plugin

dsh-session-cost-jyhnhuna

DeepSeek Harness 插件:按会话统计 token 消耗并以人民币显示费用(session_cost 工具、/session-cost 命令、侧边栏每行金额 UI)

Jump to install

Source facts

Repository
jyhn-hunao/dsh-session-cost
Latest update
Aug 17, 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/jyhn-hunao/dsh-session-cost
Plugin: dsh-session-cost-jyhnhuna
Author: jyhn-hunao

Check the source files

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

File explorer3 files
README.mdSource · read only

dsh-session-cost

DeepSeek Harness 插件:按会话统计模型上报的 token 用量,并以人民币显示估算费用。

  • session_cost 模型工具:让 agent 查询一个或多个对话的消耗(不传 sessionIds 时查当前对话)。
  • /session-cost [sessionId] 命令:面向用户,不带参数时查当前对话;/session-cost-config 查看当前价格表。
  • 侧边栏会话列表每行金额:见 [已知依赖](#已知依赖)。

数据来自会话日志中模型上报的 usageassistant/message / assistant/chunk),与内置 token 统计同源,非估算;费用按模型价格表换算。

效果

侧边栏会话列表每一行末尾显示该会话的累计费用(¥):

![效果图](assets/screenshot.png)

安装

从 GitHub 安装(源码安装无需构建:本包为纯 JS,无 build 步骤):

dsh plugin --profile <name> add github:jyhn-hunao/dsh-session-cost

首次安装若 pnpm 提示构建脚本未授权,在 profile 的 pnpm-workspace.yaml 加入 allowBuilds: dsh-session-cost: true 并重试(本包实际没有构建脚本,该提示可安全允许)。

使用

/session-cost                 # 当前对话的累计消耗
/session-cost <sessionId>     # 指定会话
/session-cost-config          # 查看当前价格表

让 agent 查询时直接说「查一下每个对话消耗了多少钱」即可触发 session_cost 工具。

价格表

默认价格表(元 / 每百万 tokens,DeepSeek 常规费率):

模型输入缓存命中缓存写输出
deepseek-chat20.528
deepseek-reasoner41416
*(回退)20.528

> ⚠️ DeepSeek 自 2026-08-17 起执行峰谷定价,高峰时段费率更高。默认值为常规费率估算,请按你的实际结算费率覆盖。

在 profile 的 cordis.patch.yml 中按 id 覆盖整行 config(整表替换,未列出的模型回退到 *):

- patch:
    - id: session-cost
      config:
        pricing:
          deepseek-chat: { inputPerM: 2, cacheReadPerM: 0.5, cacheWritePerM: 2, outputPerM: 8 }
          deepseek-reasoner: { inputPerM: 4, cacheReadPerM: 1, cacheWritePerM: 4, outputPerM: 16 }
          '*': { inputPerM: 2, cacheReadPerM: 0.5, cacheWritePerM: 2, outputPerM: 8 }

已知依赖

侧边栏会话列表每行金额(lib/client.js)注册到 sidebar.workspaces.sessionRow 插槽,该插槽是 DSH 官方仓库的本地扩展(ui-workspace 新增的行级插槽),官方原版 DSH 尚未包含。在官方原版上:

  • session_cost 工具与 /session-cost 命令正常工作;
  • 侧边栏行内金额静默不生效(插槽未声明,Client 贡献等待而不报错)。

要让行内金额生效,需要安装带 sidebar.workspaces.sessionRow 插槽的 DSH 构建(或在官方仓库合入对应补丁:ui-workspacecontract/slots.ts 声明插槽、WorkspaceBrowser/Rows.tsx 渲染每行 rowSlot)。

结构

dsh-session-cost/
├── package.json       # dsh.bundle(patch 层)+ dsh.client(浏览器 bundle)
├── cordis.patch.yml   # 插入插件行
├── index.js           # Host 端:工具 + 命令 + 价格表(纯 JS,零依赖)
├── lib/client.js      # Client 端:会话行金额(手写 bundle,免构建)
└── README.md

License

MIT