Query SurfCore's daily token and CNY spend from QQ with a rendered usage card; commands and reply mode are configurable in DSH Settings. Requires SurfCore to be installed; reads its usage data and never modifies it. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-surfcore-usage
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:yxl826/dsh-surfcore-usage
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
在 QQ 里查 SurfCore 的每日用量:Token 与人民币双口径,出图回复。 指令与回复方式都能在 DSH 设置页里改。
⚠️ 前置要求:必须先安装 SurfCore
本插件不是独立的数据源,它读取 SurfCore 记录的用量文件来统计和出图:
<SurfCore>/state/token-usage.jsonl(逐轮 Token 账本)~/.dsh/surfcore/token-usage-daily.json(当日快照,含 B站)~/.dsh/surfcore/token-budget.json(日限额)<SurfCore>/src/model-prices.js(价目表)没有 SurfCore,或 SurfCore 从未产生过调用记录,本插件查不到任何数据。 SurfCore 需要
dsh plugin add surfcore或用它的安装包部署,并至少运行过一次。另外本插件还要能连上 SnowLuma 的 OneBot 服务(SurfCore 部署时通常一并提供):
ws://127.0.0.1:3001收事件、http://127.0.0.1:3000发消息。本插件只读这些文件,不修改 SurfCore,SurfCore 升级不会让它失效。
功能
/surfuse查今天(命令名可在设置里改)/surfuse 2026-11-29查指定日期/surfclear 2026-11-29删除该日账本记录(先备份)- 仅主人 QQ 可用,其他人发送静默忽略
- 装了 Pillow 发图片卡片;没有就自动回退纯文本图表
- 展示 token 占用条、分类进度、近 7 日趋势(横轴按天排布)、人民币花费与 ¥限额
安装
方式一:让 DSH 自己装(最省事)
在 DSH 对话框里发一句话就行:
帮我安装插件 https://github.com/yxl826/dsh-surfcore-usage
DSH 会自己把它装进当前 profile。装完重启 DSH,或按 F5 刷新页面。
方式二:手动点添加
- 打开 DSH,左侧点 插件
- 右上角点 添加插件
- 输入包名
dsh-surfcore-usage - 点 安装
- 重启 DSH,或按 F5 刷新页面
- 设置里出现 SurfCore 用量 即成功
方式三:命令行
dsh plugin --profile <你的 profile> add dsh-surfcore-usage
本地开发时,装目录而不是包名:
dsh plugin --profile <你的 profile> add <本目录绝对路径>
桌面端 profile 由 Electron 独占,命令行可能被拒(
managed exclusively by the Electron application)。 遇到就用方式一或方式二。三种方式装完都要重启 DSH 或刷新页面——客户端模块是页面加载时的快照,不刷新看不到新面板。
装好之后
打开 设置 → SurfCore 用量:
| 项 | 说明 |
|---|---|
| 查询命令 | 默认 surfuse,可改成任意词(支持中文,如 用量) |
| 清理命令 | 默认 surfclear |
| 主人 QQ | 只有这个号有效;留空自动从 SurfCore 配置读取 |
| SurfCore 路径 | 留空自动探测 |
| 回复方式 | 图片卡片 / 文本图表 |
OneBot 地址与令牌自动探测,也可在 ~/.dsh/surfcore-usage/config.json 手改。
数据口径
| 数据 | 来源 |
|---|---|
| QQ / 其他 token 与金额 | 账本 k=turn 行按本地日期聚合(k=base 是累计快照,计入会重复,故排除) |
| B站 token 与金额 | 当日快照;历史读本插件归档 |
| 日限额 | token-budget.json 的 token 与 cny 两套 |
| 金额折算 | 动态载入 SurfCore 的 model-prices.js,与 SurfCore 自身计价同口径 |
关于"AI 也会回一句"
DSH 插件注册的斜杠命令只对 UI 输入生效;QQ 消息走 SurfCore bridge.js → session.prompt,不经过命令注册表。
所以在主人号私聊或白名单群发指令时,bridge.js 也会把它转给 AI,AI 可能跟着回一句。
想完全静默:在未加入 allow.groups 的群里发——bridge.js 会忽略非白名单会话,只有本插件响应。
技术说明
Electron 主进程的 WebSocket(Chromium 实现)与 undici 的 WebSocket 都无法连上 OneBot 的 ws 服务(握手后 1006),
因此 lib/ws-min.js 用 node:net 实现了 RFC 6455 的最小客户端,只做接收,发送走 OneBot 的 HTTP API。
注意 SnowLuma 的 HTTP 与 WS 是两个不同的 accessToken(accessToken / wsAccessToken),填错会 401。
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 5656
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 781
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 291
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 207
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 194
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.