kingcharleslzy-ai/dsh-cost-balance-pro0

dsh-cost-balance-pro

DSH plugin: visible cost/balance stats pill below the composer, with settings page and one-click reset. Fixed fork-level issues of dsh-cost-balance (slot id collision, missing ctx, invisible 5px bar).

AI Analysis

核心用途是修复原版冲突并提供更清晰的 API 账单统计。适合需要精确掌控每轮对话 Token 消耗、缓存命中率及账户余额的付费 API 用户。

Package
dsh-cost-balance-pro
Version
0.1.4
License
MIT
Last updated
Aug 15, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:kingcharleslzy-ai/dsh-cost-balance-pro

dsh-cost-balance-pro

DSH 插件:输入框下方可见文字的会话花费/余额统计条,带设置页与一键还原。

能力

  • 折叠态直接显示 余额(¥)· 本次花费($),点击展开明细(缓存命中 / Token / 花费 / 余额)
  • 设置页(设置 → 插件 → 余额统计条):显示开关(余额/花费/命中率)、字号(10–16px)、颜色(跟随主题/灰色/自定义取色器)、一键还原
  • 配置持久化于 $DSH_HOME/dsh-cost-balance-pro.json,重启保留,保存后统计条即时刷新

设置页字段

字段类型默认值说明
showBalancebooleantrue折叠态显示余额
showCostbooleantrue折叠态显示本次花费
showHitRatebooleantrue展开面板显示缓存命中率
fontSizenumber12折叠态字号,限制 10–16
colorModeenumautoauto 跟随主题 / mono 灰色 / custom 自定义
customColorstring#8b5cf6colorMode=custom 时的文字颜色(#RRGGBB)

相对 dsh-cost-balance 的修复

  1. 槽位注册 id 改为唯一 cost-balance-pro,不再与官方统计栏冲突(原版同槽同 id 同 priority 会挂掉整个前端);
  2. ctx 经 props 传入组件(原版模块级裸 ctx 导致槽位条目渲染期 ReferenceError,药丸从未渲染成功);
  3. 折叠态从 5px 无字细线改为可见文字;
  4. 客户端工厂补上 return module.exports(缺失时加载器收到 undefined,插件静默失效);
  5. 客户端模块声明 exports.inject = ['timer']ctx.interval 需要 timer 注入)。

安装

dsh plugin --profile web add dsh-cost-balance-pro

装后重启服务一次(或下次登录),刷新页面即可看到统计条;样式去设置页调整。

模型定价

内置 DeepSeek V4 官方定价(USD/1M),可在 profile 的 cordis.patch.yml 按 id 覆盖整行 config 传入 prices

开发

npm test          # 客户端契约测试(node:test)
npm pack --dry-run

发布:push v* 标签触发 GitHub Actions,经 npm OIDC trusted publishing 自动发布(带 provenance)。

License

MIT