DeepSeek Harness plugin

dsh-token-usage-joyiok

DeepSeek Harness Token 用量统计插件:聚合全部会话日志的 input/output/cache token,注册 token_usage 工具,并在 Web 侧边栏提供统计面板

Jump to install

Source facts

Repository
joyiok/dsh-token-usage
Latest update
Aug 15, 2026
Category
UI Enhancements
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/joyiok/dsh-token-usage
Plugin: dsh-token-usage-joyiok
Author: joyiok

Check the source files

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

File explorer3 files
README.mdSource · read only

dsh-token-usage

DeepSeek Harness(DSH)Token 用量统计插件。

  • Web 侧边栏:底部新增 Tokens 按钮,点击查看全部累计 / 今日 / 每个会话的

input / output / cache-read token(数据通过 Typert RPC 从宿主聚合)。

  • Agent 工具:注册 token_usage 工具,headless / Web 会话里直接问

「我一共用了多少 token」即可得到权威统计。

  • 权威计数:读取 $DSH_HOME/sessions/**/session.jsonl(.zstd),对每个

(turn, step) 只计一次(优先 assistant/messagedata.usage), 不做字符估算;内置多帧 zstd 解码,无需外部 zstd 二进制。

安装

cd /home/joy/Documents
dsh plugin --profile web add /home/joy/Documents/token-usage-dsh-plugin
dsh plugin --profile headless add /home/joy/Documents/token-usage-dsh-plugin

安装完成后重启 dsh web(客户端扫描与 Typert 清单按包缓存):

dsh web

验证:dsh --profile web --dump-config 应出现:

# == dsh-token-usage
- id: token-usage
  name: dsh-token-usage

使用

Web 侧边栏

打开任意会话 → 左下角点击 Tokens 图标 → 面板展示:

  • 全部累计 / 今日:输入、输出、输入+输出、缓存读取、含缓存总计、LLM steps;
  • 会话明细表:标题、模型、输入 / 输出 / 缓存读取、最近活动时间。

Agent 工具(headless / Web 均可)

用户:我一共用了多少 token?
Agent:调用 token_usage(scope: "all") 后回答

工具参数:

参数说明
scopeall(默认,全部会话)/ today(今日)/ current(当前会话)
includeSessions是否包含逐会话明细;默认 current/today 为 true,all 为 false

配置

可在 profile 的 cordis.patch.yml 覆盖(注意:覆盖整行 config):

- id: token-usage
  config:
    cacheTtlMs: 8000        # 聚合缓存毫秒数
    maxToolSessions: 20     # token_usage 工具最多返回的会话数

禁用插件:

- id: token-usage
  disabled: true

结构

src/index.js               # 宿主半体:Typert RPC + token_usage 工具
src/usage.js               # 零依赖聚合核心(多帧 zstd + 会话日志扫描)
lib/client.js              # 浏览器半体:侧边栏按钮 + 统计面板
lib/typert.host.js         # Typert host 清单(token-usage/aggregate)
lib/typert.remote-client.js# Typert remote 描述符(参考)
cordis.patch.yml           # dsh bundle 补丁:插入 token-usage 行
scripts/build.mjs          # esbuild 构建脚本(node scripts/build.mjs)

说明

  • totalTokens = inputTokens + outputTokenstotalWithCache 额外计入

cacheReadTokens + cacheWriteTokens

  • 会话日志正在写入时,内置解码失败会自动回退到 zstd CLI(PATH 可用时)。