zhangshaobo608 / dsh-cost-widget

Listed

DSH Web GUI 悬浮面板:当天 V4-Flash/Pro 每百万 token 平均费用与缓存命中率

mainTool View source

Installation

npx -y @deepseek-ai/dsh plugin --profile web add github:zhangshaobo608/dsh-cost-widget

This installation command is an unverified starting point generated from the GitHub repository address.

README

Maintainer-authored documentation snapshot.

View on GitHub ↗
Commit 77714abSynced Aug 18, 2026

This README snapshot could not be refreshed during the latest directory sync.

dsh-cost-widget

DeepSeek Harness(DSH)Web GUI 客户端插件:可拖拽的悬浮浮窗(紧凑悬浮条 ⇄ 完整面板),实时展示你 DeepSeek 开放平台账号当天的:

  • V4-Flash / V4-Pro:每 100 万 token 的平均费用(= 当天成本 ÷ 当天 token 数 × 100 万)
  • 缓存命中率(含进度条)、今日消耗、请求数、今日总成本、总命中率、余额
  • 头部"峰时/闲时"标识(北京时间 9:00–12:00、14:00–18:00 为峰时)

默认形态是右下角的紧凑悬浮条(DeepSeek ¥x · 命中率 · 峰/闲);点击展开完整面板,按住标题栏可拖到任意位置(位置记忆在 localStorage),每 5 分钟自动刷新,也可手动 ↻。挂载在 Web GUI 侧栏底部动作区(sidebar.footer.action 插槽)。

姊妹项目:zhangshaobo608/deepseek-widget —— 同样的指标,macOS 桌面浮窗版(不依赖 DSH)。

安装

需要 DSH web profile(@deepseek-ai/dsh >= 0.1.0-rc.6):

dsh plugin --profile web add "github:zhangshaobo608/dsh-cost-widget"

重启 dsh web(或触发热重载),浏览器硬刷新(Cmd+Shift+R)后面板出现在右下角。

更新 / 卸载:

dsh plugin --profile web update dsh-cost-widget
dsh plugin --profile web remove dsh-cost-widget

配置凭证(一次性)

插件通过 harness 凭证管道读取平台会话 token,添加:

# 在 ~/.dsh/.credentials.yaml 中追加一行(值可从浏览器获取,见下)
# DEEPSEEK_PLATFORM_TOKEN: <userToken>

获取 userToken:Chrome 登录 platform.deepseek.com → F12 → Console 执行(copy() 会把 token 直接放进剪贴板,无需手动选中输出):

copy(JSON.parse(localStorage.getItem('userToken')).value)

然后 Cmd+V 粘贴。也可存成书签一键复制(在 platform.deepseek.com 页面上点一下):

javascript:(()=>{const v=JSON.parse(localStorage.getItem('userToken')).value;navigator.clipboard.writeText(v).then(()=>alert('token 已复制'))})()

复制输出的长串(以 eyJ 开头)。也可用环境变量 DEEPSEEK_PLATFORM_TOKEN 注入(优先级更高)。

数据来源与安全

  • 数据来自 platform.deepseek.com/api/v0/usage/by_api_key/{amount,cost}/users/get_user_summary —— 与官方用量页同一个内部 JSON API,不是爬网页
  • 插件只在本机注册一个只读、仅回环接口 GET /api/dsh-cost/today(非本机调用直接 403),token 在请求时经凭证管道解析,不落盘、不回显
  • 公开 API key(api.deepseek.com)只有 /user/balance,没有用量统计,所以用量必须用平台会话 token。

开发

npm run check   # 语法检查 lib/*
npm run test    # platform.js 纯函数测试(合成数据断言)
  • lib/index.js — host 端 cordis 插件(代理 + 聚合)
  • lib/platform.js — 纯函数:时间范围、解析、聚合(可单测)
  • lib/client.js — 浏览器端 __ModuleLoader__ bundle(React 面板)

License

MIT

Repository information

Language
JavaScript
License
MIT
Last updated
Aug 18, 2026, 5:22 AM

Install deliberately

Review source code, permissions, lifecycle hooks, dependencies and network access. Test untrusted plugins in an isolated environment.