bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
DeepSeek Harness 侧边栏余额胶囊:把 DeepSeek 官方账户余额 和 峰谷时段 做成一个 20px 高的小胶囊,贴在侧栏页脚「名字那一行」的右侧,不占一整块地方。
¥56.10 · 谷 1d9h
图中为按 lib/client.js 的样式渲染的外观预览(同一份 CSS,脱离 DSH 页面单独成像);实际位置在侧栏名字按钮右侧、连接指示灯左侧。
GET /user/balance,用 DSH 凭证服务里的 DEEPSEEK_API_KEY(不出本机)。2d15h / 5h47m / 23m),每 15 秒刷新。—,悬停能看到原因,不会编数字。从 npm 装(当前版本 0.1.2):
dsh plugin --profile <你的 profile> add @nomxy/dsh-balance@0.1.2装完刷新页面或重启 DSH 即生效。要求 DSH >= 0.2.1(需要 dsh.client + dsh.bundle 清单)。
常用配套命令:
# 看装了哪些版本
dsh plugin --profile <profile> list
# 升级到最新
dsh plugin --profile <profile> update @nomxy/dsh-balance
# 卸载
dsh plugin --profile <profile> remove @nomxy/dsh-balance装完可以做一次自检(把端口换成你当前 GUI 的端口,可在 DSH 窗口标题或 dsh web 输出里看到):
curl -s http://127.0.0.1:<port>/api/dsh-balance
# {"ok":true,"balance":{"isAvailable":true,"total":53.08,"currency":"CNY"},
# "peak":false,"next":{"peak":true,"at":...,"ms":...},
# "tier":{"input":1,"cacheRead":0.02,"cacheWrite":0,"output":4,"model":"deepseek-flash","known":true}}侧栏出现 ¥53.08 · 谷 19h 这样的胶囊即为成功。
胶囊里的「峰 / 谷」用的是 DeepSeek 官方峰谷计费口径,逐条如下(实现见 lib/pricing.js):
项目 · 规则 高峰时段 · 北京时间 09:00–12:00、14:00–18:00(半开区间,12:00 整属于空闲) 适用日 · 周一至周五;周末全天按空闲计价(调休上班的周末也算空闲) 法定节假日 · 全天按空闲计价(HOLIDAY_RANGES 内置 2026 年及以前的中国法定节假日表) 时区 · 判定固定按北京时间(UTC+8,无夏令时),与部署机器时区无关 倒计时 · 距下一次峰谷切换的时长:午休结束 12:00→14:00 显示 2h;周五 18:00 之后显示到下周一 09:00(如 2d15h) 价格 · 悬停提示的单价按当前所处的峰谷档取(元 / 百万 tokens),缓存写官方暂不计费(0)
两种颜色:峰=#d97706(橙)、谷=#15803d(绿);模型不在内置价格表里(例如第三方网关上的同名模型)时,胶囊只显示余额,不显示峰谷。
无需配置。余额需要 DSH 里已经配好 DeepSeek 的 API Key:
DEEPSEEK_API_KEY(与 llm-deepseek 同一引用);DEEPSEEK_BASE_URL(注意:指向第三方网关时 API Key 会发给该地址)。/api/dsh-balance、/api/dsh-balance/holidays),且只接受 Host 为回环地址或本监听地址的请求(与 DSH 自身 /api 栅栏同一口径);跨站标记与异源 Origin 一律拒绝。lib/pricing.js),官方调整规则或发布次年放假日历时需要更新版本。div[class*="triggerRow"]。宿主半(lib/index.js、lib/pricing.js:余额读取、峰谷与节假日规则、单价表)取自 @dougen/dsh-deepseek-usage(MIT),仅把插件 id 与路由改名,并去掉了对 @deepseek-ai/dsh-credentials 的运行时依赖(credentialRef 是编译期 brand,运行时为恒等函数)。 客户端半(lib/client.js)为本项目重写:不注册槽位,直接挂载紧凑胶囊。
本项目的代码、发布到 npm、以及向 awesome-dsh-plugin 提交的收录条目,均由作者本机运行的 DSH(DeepSeek Harness) 代理端到端完成,作者负责需求与授权。
MIT,见 LICENSE(包含上游 MIT 声明)。
A 20px balance chip for the DeepSeek Harness sidebar footer, sitting right of the name row: official DeepSeek balance plus the current peak/off-peak window with a countdown to the next switch, hover for the active model's unit prices, click to refresh. No telemetry; the host half only serves two loopback-only routes.
Peak/off-peak (official DeepSeek billing rules): peak = Beijing time 09:00–12:00 and 14:00–18:00 on weekdays only; everything else — weekends (even make-up workdays), Chinese public holidays, and the 12:00–14:00 lunch gap — is off-peak/idle. The countdown shows the time until the next switch (e.g. 2d15h from Friday 18:00 to Monday 09:00).
Install:
dsh plugin --profile <your-profile> add @nomxy/dsh-balance@0.1.2Requires DSH >= 0.2.1 (dsh.client + dsh.bundle present). Verify with curl -s http://127.0.0.1:/api/dsh-balance.
Host half derived from @dougen/dsh-deepseek-usage (MIT). Code, the npm publish, and the awesome-dsh-plugin listing were all prepared end-to-end by DSH (DeepSeek Harness), the agent running on the author's own machine.