TwotwoPiggy/dsh-balance 预览 preview

TwotwoPiggy/dsh-balance

dsh余额插件。一个用于实时令牌追踪和高精度会话成本估算的DeepSeek Harness插件,支持动态峰谷定价。

Project Overview项目介绍

This is a native DSH plugin built exclusively for DeepSeek Harness that adds real-time DeepSeek API balance tracking and current session cost calculation to the DSH web user interface. It displays a color-coded balance status indicator and estimated current session cost on the same row as the existing token stats bar directly under the input box. Users can click the status indicator to force a fresh real-time balance query, hover over UI elements to see detailed dual-pane cards with full account and session breakdowns, and it automatically adapts to DeepSeek's official peak and off-peak pricing rules as well as the latest September 2026 price cuts.

This plugin is targeted at developers and general users who call DeepSeek API models through DSH for development work or everyday chat sessions. After installation, it lets users constantly monitor their account balance status to avoid unexpected interruptions to work or conversations when the account balance runs out. It also lets users plan their API calls around official peak and off-peak pricing to reduce overall API usage costs, and it includes a visual web-based configuration panel that lets you change all settings on the fly without needing to restart the dsh web service.

The plugin can be installed automatically with a single command via the DSH CLI, and you can choose between the full version with all features or the lightweight lite version that only includes core balance and cost display. It automatically reuses the DeepSeek API key already stored in your DSH credentials, so you do not need to manually add or reconfigure your API key during setup. To upgrade to the latest version, you first need to clear your local pnpm cache, and uninstallation is also handled with a single DSH CLI command that automatically cleans up all related configuration entries.

dsh-balance 是专为 DeepSeek Harness (DSH) 开发的原生插件,用于在 DSH Web UI 上实时显示 DeepSeek API 账户余额和当前对话的估算消耗。它在输入框下方统计条同行展示带颜色状态提示的余额、本次会话消耗,点击状态圆点可手动强刷查询最新余额,支持悬停查看双栏详情卡片,内置 DeepSeek 峰谷计费规则自动适配与最新降价同步。

该插件适合所有使用 DeepSeek API、依托 DSH 进行开发和对话的开发者,安装后可随时掌握账户余额充足度,避免因余额不足突然中断开发工作或对话会话,还可根据峰谷计费规则合理安排调用计划,帮助降低 API 使用成本。它自带可视化配置面板,支持在网页端直接修改参数,修改后即时生效无需重启服务。

该插件可通过 DSH CLI 一键安装,分为带完整功能的完整版和仅保留核心显示的精简版,两个版本二选一即可,也可以让 AI 助手协助安装,或从本地源码安装。它默认复用 DSH 已存储的 DeepSeek API 密钥,无需用户额外手动配置密钥。升级需要先清除 pnpm 本地缓存,卸载也可通过 DSH CLI 一键完成。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
  • 11 stars - an early-stage project星标 11,属于早期项目
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-balance

把 TwotwoPiggy/dsh-balance 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-balance

DeepSeek 余额实时显示插件: 在 dsh Web UI 输入框下方、命中率/输入输出 token 统计条所在的同一行, 实时显示:

  • 账户余额与充足度状态指示灯(如 🟢 余额 ¥97.69, 红/黄/绿三色直观反映余额充裕状况,点击状态圆点可直接手动强刷查询最新余额)
  • 本次对话的估算消耗(如 本会话约 ¥3.92, 按模型、按 DeepSeek 官方单价估算)
  • ? 定价参考图标: 悬停以 ? 为中心优雅浮现 DeepSeek V4 系列专属定价微卡片(全面支持 deepseek-v4-flash、deepseek-v4-flash-vision-exp 多模态视觉模型与 deepseek-v4-pro),点击直达官方定价页 https://api-docs.deepseek.com/zh-cn/quick_start/pricing/

悬停读数可查看左右双栏毛玻璃卡片:

  • 左栏【📊 账户余额】:实时大字总额、充足度 Badge、充值与赠送金额构成、5分钟自动刷新时间戳点击指示灯强刷指引以及偏好设置快速入口。
  • 右栏【⚡ 本会话消耗】:当前会话预估总花费、按模型细分明细(如 • deepseek-v4-flash: ¥3.92)、换行小字体展示输入/输出与缓存命中统计(如第一行 Token: 输入 124M · 输出 301K 与第二行 命中: 123M (99.3%))。
  • 时间感知引擎:内置 DeepSeek 谷峰计费自动切换机制(北京时间周一至周五 09:0012:00, 14:0018:00 为峰时 2 倍计费 / 其余时段含周末全天享 5 折空闲特惠),并严格对齐 2026-09-10 12:00 起生效的 Flash 最新降价分水岭,全自动无缝同步。

示例预览图

架构

┌─────────────┐  按 refreshIntervalMs 轮询   ┌──────────────────┐
│ DeepSeek API│◀────────────────────────────│ 服务器插件(host)  │
│ /user/balance│                            │ · 余额缓存(带陈旧回退)│
│             │  ?force=1 手动强刷路由       │ · /query-balance 路由│
└─────────────┘                             │ · queryBalanceCost  │
                                            │   会话花费投影(含V4谷峰)│
                                            └────────┬───────────┘
                                                     │ 只读缓存 / 投影推送帧
                                            ┌────────▼───────────┐
                                            │ 浏览器插件(client)   │
                                            │ · 双栏悬停卡片      │
                                            │ · 点击指示灯手动强刷  │
                                            │ · 单例轮询器(页面隐藏 │
                                            │   时暂停)            │
                                            └────────────────────┘
  • 性能: 浏览器只读本地缓存(每 clientPollIntervalMs 一次极小 JSON), 不直接访问 DeepSeek; 服务器按 refreshIntervalMs 拉取并缓存(失败保留上次成功值); 花费由投影折叠计算 (与 dsh-token-meter 相同的 O(1) 状态机, 同引用事件零开销), 随既有 session/projection 推送帧实时到达客户端, 无额外网络请求。
  • 手动强刷: 点击状态指示灯按钮可直接穿透缓存向 DeepSeek 官方发起实时查询,服务端内置 2000ms 冷却防刷保护。
  • 密钥: 复用 Harness 的 credentials 能力(ctx.credentials), 默认引用 DEEPSEEK_API_KEY(即 $DSH_HOME/.credentials.yaml 或进程环境), 无需在配置里写密钥。
  • 同行动态布局: 组件全 Flex 居中对齐,与输入框底部统计条完美处于绝对水平中线。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-api-gateway 下一个 Next dsh-tool-writing →