DeepSeek Harness 插件

dsh-token-cost

在 DSH Web 侧边栏按项目展示 LLM Token 用量与人民币花费,分别统计输入(未命中)、命中与输出,并按模型标准价格自动计价。

跳到安装方式

来源信息

GitHub 仓库
gdy01/dsh-token-cost
最近更新
2026年8月19日
分类
用量与账单
GitHub stars
0

安装

默认先复制一段 Prompt,让 Agent 读页面和仓库;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读页面和仓库。

请先不要安装。阅读这个 DeepSeek Harness 插件,说明它解决什么问题、会访问哪些文件、网络或密钥,以及如何安装和卸载。

插件页面:https://deepseekplugins.org/zh/plugins/gdy01/dsh-token-cost
GitHub:https://github.com/gdy01/dsh-token-cost
插件名:dsh-token-cost
作者:gdy01
安装命令:dsh plugin --profile web add github:gdy01/dsh-token-cost

确认前不要执行安装命令。

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-token-cost

A DSH plugin that shows per-project LLM token usage and converts tokens to RMB cost, split into:

  • 输入(未命中) — uncached input tokens
  • 命中 — cache-hit input tokens (cacheReadTokens)
  • 输出 — output tokens

Costs are calculated from the model's standard price table (CNY per 1M tokens). Unknown models are listed with their token counts but no cost, so you can add/override prices without touching code.

Features

  • Reads local DSH session logs (~/.dsh/sessions or $DSH_HOME/sessions).
  • Aggregates by project (the session cwd) and by model.
  • Adds a 💰 button to the DSH web sidebar footer; the panel shows project totals and expandable model-level breakdown.
  • Zero runtime npm dependencies: uses Node's built-in node:zlib Zstandard decoder.
  • Loopback-only HTTP API (/dsh-token-cost/*).

Install

Install the subdirectory dsh-token-cost, not the parent dsh plugin folder. The parent folder has no package.json, so installing it produces no sidebar button.

Use the absolute path (the path contains a space, so quote it):

dsh plugin --profile web add "file:/Users/dg/Documents/dsh plugin/dsh-token-cost"

Or, from inside this directory:

cd /Users/dg/Documents/dsh plugin/dsh-token-cost
dsh plugin --profile web add "file:$PWD"

If you previously installed the wrong folder, remove it first:

dsh plugin --profile web remove "dsh plugin"
dsh plugin --profile web add "file:/Users/dg/Documents/dsh plugin/dsh-token-cost"

Then restart dsh web and refresh the browser. A 💰 button appears at the bottom of the sidebar.

You can also use the included installer script:

./scripts/install.sh

How it works

The host plugin scans every session.jsonl.zstd / session.jsonl under the DSH sessions directory. It replays:

  • session.cwd → project
  • request/header → current model
  • assistant/chunk { type: 'usage' } and assistant/message.usage → input / cache-hit / output tokens

The same (turn, step) usage sample is de-duplicated (a later assistant/message replaces the earlier usage chunk), matching DSH's own token-meter accounting.

Price table

Built-in DeepSeek official RMB prices (元 / 1M tokens):

ModelInput (miss)Cache hitOutput
deepseek-chat / deepseek-v4-flash20.58
deepseek-reasoner / deepseek-v4-pro4116

You can override prices in the profile's cordis.patch.yml (a patch row replaces the whole config, so include every price you want to keep):

- id: token-cost
  config:
    prices:
      deepseek-chat:
        input: 2
        hit: 0.5
        output: 8
      deepseek-reasoner:
        input: 4
        hit: 1
        output: 16
      deepseek-v4-flash:
        input: 2
        hit: 0.5
        output: 8
      deepseek-v4-pro:
        input: 4
        hit: 1
        output: 16

API

  • GET /dsh-token-cost/api/stats — full per-project/per-model JSON
  • GET /dsh-token-cost/api/prices — active price table
  • GET /dsh-token-cost/healthz — liveness

License

MIT