Per-session cost & usage report cards: tokens, cache hits, duration.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:yangyongzhen/dsh-session-report
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
DeepSeek Harness 会话成本与耗时复盘报表插件:turn 结束后生成 Markdown 报表卡——token 消耗(含缓存命中率)、按 turn 拆分、工具调用频率、错误记录、可选成本估算。
与 dsh-session-export(对话导出)互补:导出看内容,报表看数字。
- 监听
session/event事件流,turn/end后防抖debounceMs生成报表 - 输出
$DSH_HOME/reports/report-<id>.md(默认~/.dsh/reports/) - 缓存命中率按 DeepSeek 口径:
cacheRead / (未缓存输入 + 缓存读 + 缓存写) - 配置单价后自动估算成本(计费输入 = 三项之和)
- 进程退出时同步 flush(headless 一次性任务不丢报表)
安装
# 本地 checkout 安装
dsh plugin --profile <web|tui|headless> add file:/path/to/dsh-session-report
# 或从 Git 仓库安装
dsh plugin --profile <web|tui|headless> add https://gitcode.com/qq8864/dsh-session-report.git
配置
- id: report
config:
enabled: true
outDir: ~/reports # 报表目录,默认 $DSH_HOME/reports
debounceMs: 1000 # turn/end 后的静默等待
costPerMInput: 1.2 # 可选:每百万输入 token 价格(元),配置后估算成本
costPerMOutput: 4.0 # 可选:每百万输出 token 价格(元)
价格单位任意(元/美元/分),按"每百万 token"填写;不配置则不显示成本。
报表样例
# 会话成本与耗时报表
- **会话 ID**:`session-29487994-...` · **模型**:`deepseek-official/deepseek-v4-flash`
- **总耗时**:2s · **估算成本**:0.0105
## Token 消耗
| 输入 tokens(未缓存) | 6322 |
| 缓存命中(读) | 1920 |
| 计费输入合计 | 8242 |
| 缓存命中率 | 23.3% |
## 按 Turn 拆分
| Turn | Step | 工具调用 | 输入 | 输出 | 缓存读 | 耗时 | 结果 |
| 1 | 1 | 0 | 6322 | 156 | 1920 | 2s | 完成 |
## 工具调用频率
| `pwsh` | 2 |
| `glob` | 1 |
口径说明
dsh 的 TokenUsage 计数是不相交的:inputTokens 只含未缓存输入,缓存命中/写入分开报。因此:
- 计费输入 = inputTokens + cacheReadTokens + cacheWriteTokens
- 缓存命中率 = cacheReadTokens / 计费输入(DeepSeek 口径,clamp 到 0–100%)
- 成本估算按计费输入计算
开发
pnpm install
pnpm run build # tsc -> lib/
端到端验证:
dsh plugin --profile headless add file:./
dsh --profile headless --patch ./test/report-patch.yml "一句话介绍你自己"
cat ~/.dsh/reports/*.md
Links
More in this category
bowenliang123/dsh-context★ 1556
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 344
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 214
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 202
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 168
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 120
Personal center for DeepSeek Harness: cross-session usage statistics, per-model cost estimation, global custom instructions, a global font-size adjuster, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.