dsh-session-usage-meterv0.1.0

limingwei-88/dsh-session-usage-meter

客户端 MIT 最近更新 2026-11-07
0Stars
0Forks
0待解决 Issue
安装命令 dsh plugin --profile web add github:limingwei-88/dsh-session-usage-meter#63c9da8986d2d31fa613b1e0862102bc944bb2a2

介绍

DeepSeek Harness plugin: per-session token usage and estimated cost in the sidebar session-row hover card.

标签

cost-tracking deepseek-harness dsh dsh-plugin token-usage

概述

dsh-session-usage-meter

一个 DeepSeek Harness 插件:在侧边栏会话行的悬浮卡片里显示该会话的累计 Token 消耗与预估成本。

English: shows per-Session cumulative token usage and an estimated cost inside the sidebar session-row hover card.

功能

  • 汇总当前会话每个 assistant/message 事件上的 usage(输入 / 输出 / 缓存命中 / 缓存写入)。
  • 按内置价格表估算成本,价格可在本地覆盖(见下文),无需重新构建。
  • 悬浮卡片里一行显示:12.4k Tokens · 估算 ¥0.0081;鼠标悬停可见分项明细。
  • 跟随 DSH 主题,不引入新的配色体系;中英文文案随界面语言切换。

安装

# 从 npm 安装(发布后)
dsh plugin --profile web add dsh-session-usage-meter

# 从 GitHub 安装
dsh plugin --profile web add github:<owner>/dsh-session-usage-meter

# 从本地目录安装(开发调试)
dsh plugin --profile web add "C:\path\to\dsh-session-usage-meter"
profile 说明:--profile web 是 DSH 的默认 Web profile;本机若运行的是别的 profile(例如 Desktop 使用 desktop),把它换成你实际启动的 profile 名即可,否则装到了另一个 profile 里,当前界面不会出现该插件。

安装后重启 dsh 并刷新页面。dsh plugin ... add 只是把包加进 profile 的依赖;要让 bundle 真正挂载,还需要该包的 dsh.bundle.patch 被 profile 选中(本包已自带 cordis.patch.yml,在支持 dsh.bundle 的 DSH 版本上会自动登记)。

工作原理

半边作用
Host (index.js)仅用于让 bundle 行可解析,不注册任何资源。
Client (client.js)通过 ctx.slots.inject('sidebar.session.row.hover', ...) 注册一个区块,读取该会话已落盘的 assistant/message.usage 并求和。

数据全部来自会话自身的事件窗口,不发额外请求,也不把用量写回会话。

价格表

默认价格(人民币 / 每百万 Token)写在 client.js 的 DEFAULT_PRICES 中,按模型名匹配,匹配不到时使用 default:

字段含义默认值
input输入(缓存未命中)2
cacheRead缓存命中0.2
cacheWrite缓存写入2
output输出3

不改代码覆盖价格:在浏览器控制台写入 localStorage 后刷新页面。

localStorage.setItem(
  'dsh-session-usage-meter.prices',
  JSON.stringify({ default: { input: 2, cacheRead: 0.2, cacheWrite: 2, output: 3 } })
)

金额是估算值,不是账单:它不包含套餐折扣、阶梯计价、缓存策略差异,也不计入未被 usage 覆盖的部分。

已知限制

  • 只统计事件里带 usage 的 assistant/message;早期历史或中断的调用可能没有 usage。
  • 悬浮卡片仅在该会话行被悬停时挂载,因此没有常驻的数字显示。
  • 价格表按模型名精确匹配;自定义 provider 的模型名会落到 default。

开发

node --check index.js
node --check client.js
node -e "JSON.parse(require('fs').readFileSync('locale/zh.json','utf8'))"

本仓库无构建步骤:client.js 直接是浏览器模块加载器接受的格式。

License

MIT

星级评价

0.0 按 GitHub Stars 换算的社区热度,非用户打分
Stars0
Forks0
待解决 Issue0
最近更新2026-11-07

基本信息

作者limingwei-88
版本0.1.0
开源许可MIT
默认分支main
入库时间2026-11-07

插件信息来自公开 GitHub 仓库与 SkillHub,版权归原作者所有;安装前请自行审查仓库代码。