Monitor token usage and cost for each DSH model call, display each deduction as a health-deduction animation on the balance floating card, and automatically calibrate the real-time balance of the DeepSeek account.
- Language
- TypeScript
- License
- MIT
- Branch
- master
Install
$ dsh plugin --profile web add dsh-damage-pulseRun the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial
Install via your agent
Install the DeepSeek Harness plugin wssfk12138/dsh-damage-pulse for me: review the repository at https://github.com/wssfk12138/dsh-damage-pulse first, then run the install command and verify the plugin loads successfully.
Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.
One-Line Description
A balance monitoring plugin that presents the Token usage and cost of each DeepSeek Harness (DSH) model call with a game-style "damage pulse" animation; also real-time pulls the DeepSeek official account balance and auto-calibrates, letting users intuitively feel each deduction during chat.
Core Features
- After each model call ends, insert a line into the conversation flow showing single-call usage details (input / cache hit / output / reasoning) and the precise amount
- Continuously display the cumulative Token count and cumulative amount for the current session above the input box
- The balance floating card precisely deducts each expense locally, with red deduction numbers floating up from the balance and accompanied by hit rebound animations
- When cache misses occur or cache is written, trigger a stronger red "miss" animation with a brief horizontal shake; pure cache hits follow the normal hit animation
- Pull the DeepSeek official account balance every 60 seconds for calibration; when a balance increase is detected, float a green "recharge" number
- The balance card displays a "Peak / Valley" indicator in the bottom right corner, combined with Beijing time peak/valley periods with red/green glow effects
- Append each single-call usage detail as JSONL to local storage for historical query and session-based filtering
Technical Implementation
- Language: TypeScript + React 18
- Key Dependencies:
@deepseek-ai/cordis,@deepseek-ai/schemastery,zod,react - Architecture Pattern: Standard DSH Host + Client combined package; Host injects
dsh-damage-pulseplugin viacordis.patch.yml, Client declares injection via package.json'sdsh.client.injectto inject intodsh-client-runtime/dsh-client-ui-conversation/dsh-client-ui-layout. Host listens tosession/eventto collect each call → registerstokenCostsession projection → registers three HTTP endpoints for balance / usage / deduction events; Client occupiesconversation.chat.node,conversation.composer.dock,shell.overlaythree slots to render UI. - Entry Files:
lib/index.js(Host bundle, corresponding to sourceplugins/dsh-token-monitor/src/index.ts);lib/client.js(Client bundle, corresponding to sourcepackages/client/ui-token-monitor/src/client/index.ts)
Use Cases
Heavy users of DeepSeek models (especially those with context caching enabled) who want to see the exact amount and damage feedback immediately with each deduction, avoiding discovering accumulated spending exceeds budget at the end of the day. Regular users can also use it to intuitively feel "how much this answer cost", the money-saving effect from cache hit rates, and peak/valley period price differences.
Prerequisites and Compatibility
| Dependency | Minimum Version | Description |
|---|---|---|
| DSH | ^0.1.0-rc.5 | Host side requires cordis, session-projection, session-projection-cache, session-persistence, host-webserver, credentials, session, llm, settings and other services |
| Node.js | ^22.19.0 or >=24.0.0 | Declared in repository engines field |
| Platform | Cross-platform | Uses browser Web profile, no native binary dependencies |
| Native Modules | None | Does not depend on node-pty, sqlite, better-sqlite3, etc. |
Note: This plugin only works in DSH's Web profile (
--profile web), because the Client bundle is a browser-side React package.
Installation
dsh plugin --profile web add github:wssfk12138/dsh-damage-pulse
After installation, restart the Web profile with dsh --profile web. The balance card, single-call usage row, session accumulation in input area, and damage pulse animation will take effect.
Configuration
| Config | Type | Description | Default |
|---|---|---|---|
DEEPSEEK_API_KEY (credential) | String | Configured via DSH credential system (~/.dsh/.credentials.yaml); when not configured, balance card shows "unconfigured" state, but Token metering and damage pulse animation still work normally | Not configured |
settings namespace dsh-token-monitor → priceTable | Object | Custom price table, overriding built-in 2026-08-17 peak/valley pricing; historical costs before 2026-08-17 are not affected | Built-in PRICE_TABLE |
| Peak Hours (built-in only) | Time period array | Beijing time 9:00-12:00, 14:00-18:00; peak/valley shown with red/green glow indicators | Not configurable |
Note: This plugin has no runtime toggle; it enables upon installation, and the Host automatically registers three HTTP endpoints for balance / usage / deduction events.
FAQ
Q: The balance card shows "API Key Not Configured" - what should I do?
A: You need to configure DEEPSEEK_API_KEY in the DSH credential system (write to ~/.dsh/.credentials.yaml). Not configuring will only cause the balance card to show the unconfigured state; it does not affect Token metering or damage pulse animation.
Q: Does each deduction immediately deduct from the balance?
A: The balance is precisely deducted locally: after each model call ends, the exact amount is immediately subtracted and the damage pulse animation is triggered; at the same time, the DeepSeek official balance is pulled every 60 seconds for calibration. If the official balance is higher than what the local display shows, a green "recharge" animation automatically appears.
Q: What's the difference between cache hit and cache miss?
A: Pure cache hits only show normal red deduction numbers; as long as there is cache miss input or cache write in a single call, it triggers a stronger red "miss -x.xx¥" animation, accompanied by a brief horizontal shake and larger balance rebound. Multiple deductions merged within the same second, if any one belongs to a miss, the entire group plays as miss.
Q: What should I do if I don't see any animation after installation?
A: Confirm that you have restarted the target profile with dsh --profile web. If you previously used the source integration version, please first remove manual patches and duplicate mounts to avoid loading the same plugin twice.
Q: Why don't old sessions show amounts at first?
A: When the plugin starts, it automatically triggers a cold read fold for historical sessions missing Token amount projections. After a few seconds, the page will display the amounts. Once projections are written to checkpoint, no re-filling is needed on next startup.
Q: Why doesn't the left session list show cumulative amounts?
A: DSH currently does not expose a third-party slot for "left session row trailing information", so the standard package does not modify the host DOM. If using full DSH source code and this function is truly needed, you can run the sidebar integration script in the repository to modify the source code, but this is not a capability of the standard package.
Q: Can I override the price table?
A: Yes. Enter custom pricing in the settings namespace "dsh-token-monitor"'s priceTable field to override the built-in table; old prices (before the 2026-08-17 price increase) will automatically use old prices based on their timestamp, without recalculation.
Getting Started Difficulty
Beginner — Install with a single command to use; all features are enabled by default; further setup is only needed when wanting to override the price table or adjust peak/valley periods.
Known Issues and Limitations
- Although the public brand has been renamed to
dsh-damage-pulse, the plugin runtime identifier / settings namespace / localStorage keys / data directory / API paths still use the old namedsh-token-monitorto ensure compatibility for already-installed users; a full rename has not been done yet - Cache damage pulse animation merges multiple deductions within the same second into a single floating text; consecutive deductions keep at most three groups of floating text at the same time, excess ones get overwritten
- The standard package does not modify the host DOM; DSH's left session list does not show cumulative amounts; this feature is only available for full Harness source code and requires running a separate sidebar integration script
- The built-in price table version is 2026-08-17 peak/valley pricing (peak: Beijing time 9:00-12:00, 14:00-18:00); model names are matched by prefix (e.g.,
deepseek-v4-promatchesdeepseek-v4-pro-xxx), unmatched models fall back to flash peak pricing - Deduction details are appended as JSONL to local
~/.dsh/data/dsh-token-monitor/usage.jsonl, with cold boot automatic recall; corrupted lines are silently skipped
DSH(DeepSeek Harness)扣血式 Token 余额监控插件:每次产生 token 消耗,余额数字都会受击回弹,并飘出红色扣费数值;同时提供会话用量、精确金额和 DeepSeek 账户实时余额。

目录
功能特性
- 单次用量行:每次模型调用结束,在对话流内插入一行 token 明细(输入 / 缓存命中 / 输出 / 思考 reasoning)与精确金额。
- 会话累计条:输入框上方显示当前会话累计 token 与金额(基于
tokenCostsession projection)。 - 会话累计金额:输入区持续显示当前会话累计消费;源码集成版还可选在左侧原生会话列表显示累计金额。
- 缓存感知扣血动画:纯缓存命中使用普通红色
-x.xx¥命中脉冲;存在缓存未命中输入或缓存写入时,显示更大的红色「未命中 -x.xx¥」、短促横向抖动和更强的余额回弹。同一秒合并的多笔扣费中只要有一次未命中,整组即按未命中播放;连续扣费最多保留三组飘字。 - 余额悬浮窗:
- 充值动画:检测到余额变多,飘出绿色
+x.xx¥; - 可拖动:按住卡片可随意移动,位置自动记忆(localStorage);
- 峰谷标识:余额栏最右侧显示「峰」(红 / 高峰)或「谷」(绿 / 谷时),带红绿灯发光效果。
- 充值动画:检测到余额变多,飘出绿色
- 价格表:内置 DeepSeek 2026-08-17 峰谷定价(含高峰 / 谷时区分),历史费用按每条调用发生的时间戳自动使用旧价,涨价前已算的费用不会重算。
- 精确计费:按每次调用的实际模型名计价(
deepseek-v4-pro/deepseek-v4-flash,支持版本后缀前缀匹配),缓存命中与缓存未命中分别计价。
架构
项目公开品牌为
dsh-damage-pulse。为兼容已安装用户,下列目录名、包名、API 路径、设置命名空间和本地存储键仍沿用dsh-token-monitor/token-monitor,无需迁移已有配置与历史数据。
| 部分 | 位置 | 职责 |
|---|---|---|
| Host 插件 | plugins/dsh-token-monitor | 监听 session/event,精确计费(token × 单价),注册 tokenCost session projection、余额轮询服务、HTTP 端点(balance / usage / charge-events / stats) |
| Client 包 | packages/client/ui-token-monitor | Web GUI 组件:余额悬浮窗(BalanceWidget)、单次用量行、会话累计条,读投影与 HTTP 端点渲染 |
安装
本仓库从 0.2.0 起是标准 DSH Host + Client 组合包,已提交预编译产物。无需复制源码、修改 DSH tsconfig、手动传入 --patch 或重建 Client bundle。
dsh plugin --profile web add github:wssfk12138/dsh-damage-pulse
安装后重启 Web profile:
dsh --profile web
标准包直接提供余额悬浮栏、余额实时扣减、缓存命中/未命中动画、单次用量行和输入区会话累计。升级自早期源码集成版时,请移除原有手工 --patch 或重复挂载项,避免同一插件加载两次。
可选:原生侧边栏金额源码增强
DSH 当前没有开放“左侧会话行尾部信息”的第三方 slot,因此标准包不会修改宿主 DOM,也不会强行注入左侧会话列表。标准包内的输入区会话累计不受影响。
只有在使用完整 DSH 源码且确实需要原生左侧会话行金额时,才运行:
.\scripts\apply-sidebar-integration.ps1 -HarnessRoot 'C:\path\to\deepseek-harness'
$env:DSH_BUILD_FACE = 'client'
corepack pnpm --dir 'C:\path\to\deepseek-harness\packages\client\ui-workspace' exec tsdown
脚本会先备份三个目标文件,并以幂等方式读取 projectionValues.tokenCost.cost。上游结构不匹配时会停止,不会猜测写入。
源码开发
corepack pnpm install
corepack pnpm build
corepack pnpm run check:bundle
配置
API Key
通过 DSH 的 credentials 机制配置 DEEPSEEK_API_KEY(~/.dsh/.credentials.yaml),未配置时余额卡片显示引导态,token 计量不受影响。
价格表(可选覆盖)
价格表默认内置(见 src/pricing.ts),可通过 settings namespace dsh-token-monitor 的 priceTable 字段覆盖新价格(旧价与高峰时段切换内置)。高峰时段默认北京时间 9:00–12:00、14:00–18:00。
HTTP 端点
| 端点 | 说明 |
|---|---|
GET /api/token-monitor/balance | DeepSeek 账户余额(含 currency / 总余额 / 赠送余额) |
GET /api/token-monitor/usage?sessionId= | 用量明细历史(可过滤会话) |
GET /api/token-monitor/charge-events?since=<seq> | 扣费事件增量(含 damageKind,驱动缓存感知扣血动画) |
常见问题
- 余额卡片显示「未配置」:未配置
DEEPSEEK_API_KEY,token 计量仍正常。 - 左侧原生会话行没有金额:这是源码增强功能,不属于标准包能力;需要完整 DSH 源码并执行上面的侧边栏集成脚本。输入区会话累计仍可正常使用。
- 只有旧会话没有金额:插件加载前结束的旧会话需在下次启动时自动补齐(插件启动时对缺失投影的历史会话触发冷读 fold),启动后请稍等几秒再刷新页面。
- 窗口启动后仍无动画:确认已重启安装目标 profile;若以前使用过源码集成版,先删除旧的手工 patch 和重复挂载。
社区与反馈
本项目的安装、运行和功能不依赖任何模型中转服务、充值渠道或返利计划。欢迎在 LINUX DO 社区 交流使用体验、反馈问题和分享改进建议。
许可证
MIT
支持作者
如果这个项目对你有帮助,欢迎自愿赞赏,支持后续维护和更多开源项目。赞赏完全自愿,不影响插件的任何功能、技术支持或后续更新。

Read the usage guide →
Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.
Listing badge
[](https://deepseek-plugin.org/plugins/wssfk12138/dsh-damage-pulse)Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.