Provides DSH with DeepSeek session costs, official balance, budget and peak-valley pricing visualization. Supports OpenCode Go and multi-vendor Coding Plan quota queries with one-click official price sync.
$ dsh plugin --profile web add github:Han-1413141/dsh-cost-meterRun 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
Real-time cost tracking for DeepSeek Harness: monitors current session and historical model call costs, official account balance, budget progress, and peak/off-peak pricing tiers. Optional integration with OpenCode Go subscription and multi-vendor Coding Plan quotas, with one-click sync from the official pricing page.
.js source files under lib/ + single-file browser bundle)zod (config/state schema validation), @deepseek-ai/dsh-credentials (OpenCode Go / Coding Plan / balance Key parsing), @deepseek-ai/dsh-home-paths (ledger root directory resolution)ctx.on('llm/stream', ...) to capture usage blocks and write to ledger per price list; ctx.inject(['sessionProjections']) registers costUsage session projection (client prices by current price table); ctx.provide('costMeter', service) exposes ledger snapshot/config/refresh/sync/reset RPC, hand-written typertRemote binding to match Typert gateway validation. Client half is single-file bundle, injects into four slots: conversation.composer.dock, conversation.session.header.actions, sidebar.footer.action, settings.section; styles entirely based on --dsw-* theme variables following light/dark modelib/index.js (apply / name = 'cost-meter'); client entry lib/client.js; mount declaration cordis.patch.yml (1 line Loader insertion in web profile) + package.json#dsh.bundle.patchWhen DSH users want a visible "ledger feel" for model spending — real-time view of current session and historical cost trends, setting monthly budgets with progress bar alerts, verifying official price tables in settings, checking OpenCode Go and multiple Coding Plan remaining quotas at a glance. This plugin consolidates all measurable dimensions into a single "Cost" settings section, eliminating the need to switch between multiple official consoles.
| Dependency | Minimum Version | Notes |
|---|---|---|
| DeepSeek Harness (DSH) | 0.1.0-rc.5 | package.json#dshhub.compatibility.dsh declares >=0.1.0-rc.5 |
| Node.js | >=20 | package.json#dshhub.compatibility.node declares >=20 |
| Platform | Cross-platform | No native modules; ledger uses node:fs atomic writes, Key parsing reads pure text files like ~/.local/share/opencode/auth.json, ~/.claude/.credentials.json |
| Native modules | None | All third-party dependencies are pure JS (zod / dsh-credentials / dsh-home-paths) |
| Network | api.deepseek.com (balance), api-docs.deepseek.com (official pricing), opencode.ai (Go quota), six Coding Plan vendor endpoints | Balance strictly whitelist official domains, Keys not sent to other endpoints |
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter
Visualized editing by default in Settings → Cost all sections; below is the adjustable field overview (excerpt from lib/store.js:27-95, all fields validated by zod schema in updateConfig RPC and auto-saved instantly with 600ms debounce).
| Config | Type | Description | Default |
|---|---|---|---|
locale | enum | UI language: auto (follow browser) / zh (Simplified Chinese) / en (English) | auto |
position | enum | Session cost badge position: dock (below input area) / header (session title bar) / off (disabled) | dock |
sidebar | boolean | Show today's cost at sidebar bottom | true |
currency / symbol / decimals / exchangeRate | string / string / number(0-10) / number | Display currency and exchange rate (default CNY / ¥ / 4 digits / 7.2), ledger amounts always stored in USD | CNY / ¥ / 4 / 7.2 |
peakEnabled | boolean | Enable peak/off-peak two-tier pricing (UTC 01:00–04:00 and 06:00–10:00 are peak periods, off-peak price = half of peak price) | true |
peakNotice / peakStyle | boolean / enum | Prominent alert during high-price peak periods and period bar style (compact single-line / classic segmented capsule) | true / compact |
priceMatch / priceOverrides / priceTableDisplay | enum / map / map | Unknown model auto-match strategy (auto strip suffix / prefix / family similarity, or exact only), manual match override, per-model whether to display directly in "Price Table" area | auto / {} / {} |
prices.models / prices.default / prices.providers | map / entry / map | DeepSeek and third-party vendor price tables, three buckets (cacheHit/cacheMiss/output) or two-tier shorthand (input/output) both supported; peak/off-peak sub-tiers filled per DeepSeek model structure | Built-in DeepSeek price table + third-party catalog |
budget.enabled / amount / period / customStart / customEnd / detail | boolean / number / enum / date / date / boolean | Budget box master switch and quota, period (day/month/all/custom), detail rows | false / 100 / month / null / null / true |
balance.display / refreshMinutes | enum / number(1-1440) | Balance display position (sidebar / settings / both / off) and auto-refresh interval | both / 5 |
goQuota.enabled / display / refreshMinutes / apiKey / main / detail | boolean / enum / number / string / enum / boolean | OpenCode Go subscription quota master switch, display position, refresh interval, Key (box main quota rolling 5h / weekly / monthly) | true / both / 15 / "" / rolling / true |
corner.enabled / goRolling / goWeekly / goMonthly / budget | boolean × 5 | Bottom-right (composer dock) four independent chips: rolling 5h / this week / this month / budget used % | false / true / true / true / true |
codingPlans.<provider>.enabled / display / refreshMinutes / apiKey | boolean / enum / number / string | Six Coding Plan vendors (anthropic / zai / minimax / kimi / openrouter / siliconflow) independent enable, display position, refresh interval, Key | false / settings / 15 / "" |
usage.position | enum | Token usage statistics display position: cost (inside cost settings section) / general (general settings) / section (standalone section) | cost |
historyDays | number(7-3650) | Ledger retention days | 180 |
Q: Is the interface in Chinese or English? Can I switch?
A: Simplified Chinese / English / follow browser (auto) three modes. Default follows browser (zh* → Chinese, others → English), detection result not persisted. Switch in Settings → Cost → Display Settings → Interface Language, entire UI takes effect instantly and auto-saves; balance returned by server and price sync prompts also display in current language.
Q: I don't see balance in the sidebar after installation / display is abnormal. What should I do?
A: Balance depends on DeepSeek API Key in DSH model settings; please configure Key in Settings → Models on first launch or export DEEPSEEK_API_KEY. Balance endpoint strictly only sends to official domain api.deepseek.com, balance query is rejected when baseURL points to non-official domain (model calls unaffected). Balance auto-refreshes every 5 minutes by default, can be disabled in Settings → Cost → Balance display position.
Q: OpenCode Go or Coding Plan quotas disappear automatically / show "not enabled"?
A: Go quota requires DSH credential store or env var OPENCODE_GO_API_KEY, unconfigured shows neutral hint in settings page, won't turn red. Open Settings → Cost → OpenCode Go panel to enable; unsubscribed can disable "Enable" switch. Similar for each Coding Plan: fill Key in corresponding panel or configure env var, disable "Enable" to stop.
Q: How to sync the latest official prices? Will sync overwrite my custom prices?
A: Click "Sync from Official Docs" in Settings → Cost → Data & Sync area, plugin scrapes official pricing page and writes after parsing. Only overwrites same-named model entries listed on official page, custom model entries unaffected; sync reports error and preserves original price table on parse failure, manual edit as fallback.
Q: Will reaching 100% budget stop model calls?
A: No. Budget and overspend alerts only notify without blocking calls; ≥80% turns yellow, ≥100% turns red and shows overspend badge in sidebar bottom budget box. Hard limit requires handling at model layer yourself.
Q: Where is data stored? How to clear all history?
A: Ledger file at $DSH_HOME/storages/cost-meter/ledger.json, retained per historyDays (default 180 days), max 200 session details per day; writes use temp file + atomic rename + 2s debounce. Clear: click "Clear All History" in Settings → Cost → Data & Sync; also can manually delete ledger.json.
Q: How to uninstall?
A: dsh plugin --profile web remove dsh-cost-meter, restart dsh web. Plugin doesn't introduce extra background processes or modify host files; ledger file remains at $DSH_HOME/storages/cost-meter/ledger.json, delete manually if needed.
Q: Page doesn't change after installation/update?
A: Must restart dsh web after plugin installation or update; plugin line, Typert manifest, and client bundle all scanned at startup; only refreshing browser won't reload server-side plugin.
Beginner — one dsh plugin add + restart dsh web shows cost panel in sidebar and settings; official price sync requires access to api-docs.deepseek.com. Advanced: read Price Table / Extend Price Table / Multi-provider Model Adaptation (see docs/model-and-plan-adaptation.md) and manually verify non-DeepSeek model prices per vendor.
api.deepseek.com accepted, balance query rejected when baseURL points to non-official domain, model requests unaffectedopencode.ai/zen/go/v1/usage (community docs): when interface structure changes, settings shows error, can disable display in Display Settingsdsh web after plugin install/update: plugin line, Typert manifest, and client bundle all scanned at startupDeepSeek Harness 会话费用统计插件(界面中英双语)
本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段) · 官方价格一键同步 · 类 Codex Token 用量热图
English | 中文

| 功能 | 位置 | 说明 |
|---|---|---|
| 本会话费用 | 输入区下方 / 会话标题栏 | 实时累计费用 + 输入/缓存/输出 token,位置可配 |
| 官方余额 | 侧边栏顶部 / 设置页(可配) | 总余额 / 赠送 / 充值,自动刷新 + 手动刷新 |
| OpenCode Go 额度 | 侧边栏 / 设置页 / 右下角(dock,可配) | 滚动 5 小时 / 本周 / 本月用量百分比与重置时间,三档可分别开关,可同时显示预算已用%;Key 自动发现(DSH 凭据库 OPENCODE_GO_API_KEY / 环境变量 / opencode 登录态)或手动填写 |
| Coding Plan 额度 | 设置页 | 多厂商 coding plan 订阅额度查询(Anthropic Claude Pro/Max、Z.ai/智谱 GLM、MiniMax Token Plan、Kimi/Moonshot 余额、OpenRouter credits、SiliconFlow 余额),各家独立启用开关与 Key,凭据只发往官方端点;无凭据/无订阅为中性提示 |
| 当日费用 | 侧边栏底部(设置按钮上方) | 「今日 ¥x」,悬停见调用次数与 token 明细 |
| 预算图框 | 侧边栏底部(余额行与设置按钮之间) | 圆角方形图框:预算、已用%、进度条、今日费用与占预算%、已用/额度,≥80% 预警、≥100% 超支 |
| 汇总卡片 | 设置页 | 今日 / 本月 / 累计费用与调用次数 |
| Token 用量统计 | 设置页(费用设置) | 历史累计 token 总量(输入/缓存/输出/调用)+ 类 Codex 的 26 周每日用量方格热图,横向铺满设置页宽度,悬停见当日明细 |
| 今日会话明细 | 设置页 | 每个会话的调用次数、输入/缓存/输出 token 与费用 |
| 历史记录 | 设置页 | 按天汇总,保留天数可配(默认 180 天) |
| 预算设置 | 设置页顶部 | 额度、周期(今日/本月/累计/自定义日期区间)、已用% |
| 价格表 | 设置页 | 每模型 谷时/峰时 两档价格(支持 input/output 简写,缓存价自动补齐),增删改自由 |
| 峰谷计价时段显示 | 设置页 / 预算 / 今日费用 | 显示 UTC 峰时段 01:00–04:00、06:00–10:00 与当前档位;展开态显示峰时/平价时段条(当前时段 + 倒计时),收起(rail)态显示竖向峰谷进度条,可单独开关 |
| 官方价格同步 | 设置页 | 抓取解析官方定价页,一键应用 |
| 界面语言 | 设置页 → 显示设置 | 简体中文 / English / 跟随浏览器(自动);切换即时生效并自动保存 |
| AI 价格同步 | 提示词 | DeepSeek 官方同步;其他 provider 使用已核对的官方价格目录与手动配置 |
| 模型与 Plan 适配说明 | 适配文档 | 各厂商模型计费与 6 家 Coding Plan 的适配矩阵、自动匹配机制与价格来源(English) |
| 多 provider 计费 | 设置页 / 账本 | 支持 OpenAI、Anthropic、Google Gemini、Mistral 等 provider 的 input/output、缓存与 reasoning token 价格,按 provider+model 隔离计费 |
| 模型名自动匹配 | 设置页 / 账本 | 未知模型 id 自动匹配价格表:忽略大小写/空格/横杠/点号与括号附注,归一化等价或请求名包含表内模型名即命中(如 gpt5.6 luna(go));路由 provider(opencode/zen 等)下跨厂商全库查找;可关闭为仅精确;未命中模型可手动指定计费条目 |
| 拓展价格表 | 设置页 → 拓展价格表 | 内置各厂商、按模型家族分类的参考价格目录(点开展开,厂商默认折叠);一键挂载参与计费,挂载的第三方模型默认收入表内可编辑;逐模型「在费用设置直接显示」开关自选哪些模型(含 DeepSeek)在「价格表」区直接显示 |
插件界面(会话徽章、侧边栏余额与预算图框、设置页全部文案)支持简体中文与English:
zh* → 中文,其余 → 英文),并把探测结果写回配置,服务端消息(余额查询、价格同步等)与界面语言保持一致;截图均取自真实 DeepSeek Harness 实例,默认以中文界面展示;插件界面本身中英双语,可在设置中切换为 English。
侧边栏底部(自上而下:官方余额 → 额度 / 预算图框 → 设置按钮):

额度 / 预算图框三态(OpenCode Go 额度与预算各自独立开关,同款圆角图框;两者同时开启时自动合并为一张卡片,Go 在上、预算在下,细分隔线、各自保留预警色;「图框详细信息」开关可收起次要行,只保留 标签 + 已用% + 进度条):
| 仅 OpenCode Go 额度 | 仅预算 | 两者合并 |
|---|---|---|
![]() | ![]() | ![]() |
峰时/平价时段条与收起态竖向进度条:
| 设置页峰谷面板(提示开关/样式切换/预览) | 设置页右下角(dock)显示与图框详细信息 |
|---|---|
![]() | ![]() |
时段条与收起态竖向条真实 DSH 侧边栏实拍(现行样式),按 UI 类型分组(图示为峰时):
不收起(展开态)——预算框 / 今日费用区域显示单行时段条:
| 简洁 | 经典 |
|---|---|
![]() | ![]() |
收起(rail 窄栏)——侧边栏底部堆叠竖向时段条,与百分比方块居中对齐:
| 简洁 | 经典 |
|---|---|
![]() | ![]() |
简洁:竖向条下方仅横排短词「峰时 / 平价」;
经典:竖向条下方竖排完整文案,含距下次切换的倒计时;两种样式下完整文案均悬停可见。
提示遵循 peakNotice / peakEnabled / peakEffectiveAt / peakWindows 门控,按 UTC 峰时窗口显示;
设置 → 费用 → 峰谷计价 下可单独开关「峰时高价时段显著提示」,关闭后展开态时段条与收起态竖向条同时隐藏;
上方第一张为设置页峰谷面板截图(提示开关、样式切换与实时预览);时段条与收起态竖向条的实拍效果见上述分组配图;右下角(dock)各项开关与图框详细信息开关见第二张截图。
Go 图框按主档位(默认滚动 5 小时,可在显示设置切换周/月)显示已用% 与进度条,下方一行展示其余两档与重置时间:

右下角(dock)额度 / 预算 chips(显示设置中开启,四项独立开关:5h / 周 / 月额度 + 预算已用%):
| 右下角实际显示 | 显示设置(开关位置) |
|---|---|
![]() | ![]() |
本会话费用(两个位置,可在设置中切换):
| 输入区下方 | 会话标题栏 |
|---|---|
![]() | ![]() |
上图:本会话 ¥5.5939 · 输入 321K · 缓存 119M · 输出 235K;右图:标题栏徽章「费用 ¥6.1606」(真实会话截图)

概览(OpenCode Go 额度 → 预算 → 余额 → 汇总卡片 → 今日会话 → 历史记录 → 显示设置 → 价格表 → 数据与同步):

OpenCode Go 额度面板(设置页最顶部:三档进度条,主档位高亮,手动刷新;未订阅时为中性提示,可一键关闭):

预算面板(含自定义日期区间):

余额面板(总余额/赠送/充值 + 手动刷新):

显示设置(Go 主档位与 Key、右下角 chips、图框详细信息等):

汇总卡片:

Token 用量统计(历史累计总量 + 类 Codex 的 26 周方格热图,横向铺满设置页宽度;无用量日为半透明玻璃格):

今日会话 / 历史记录(输入、缓存、输出 token 分列):

价格表(谷时/峰时两档,支持 input/output 简写,美元 / 1M tokens):

数据与同步(配置即时自动保存 + 官方价格同步 + 清除历史):

需求:Node.js ≥ 20 + DeepSeek Harness(带
dsh plugin命令的版本,npm install -g @deepseek-ai/dsh)。
PowerShell 一键脚本(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链固定到发布 tag v1.5.2,建议先下载审阅再运行):
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.5.2/install.ps1 | iex
或直接命令行(机器上需已有 pnpm 与 git;同样固定到 tag):
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.5.2
没有 git 时可用 GitHub tag 打包直链:
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.5.2.tar.gz
安装后重启 dsh web(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
dsh web
# 更新:发布新版后用新版 install.ps1 重跑(脚本内固定版本随之更新)
dsh plugin --profile web remove dsh-cost-meter # 卸载
git clone https://github.com/Han-1413141/dsh-cost-meter.git
cd <克隆目录的父目录>
dsh plugin --profile web add link:./dsh-cost-meter # 符号链接,改 lib/client.js 后刷新页面即生效
$DSH_HOME/storages/cost-meter/ledger.json(原子写入 + 2 秒防抖;按 historyDays 保留,每日最多 200 个会话明细);dsh-cost-meter
├── cordis.patch.yml # bundle 补丁:向 web profile 插入 cost-meter 行
├── install.ps1 # 一键安装/更新脚本(irm … | iex)
├── .github/workflows/ # CI:install-smoke 一键安装冒烟验证
├── package.json # dsh.bundle 补丁声明 + dsh.client 浏览器声明
└── lib/
├── index.js # 宿主插件:llm/stream 计费包裹、costUsage 会话投影、
│ # costMeter 服务(手写 typertRemote 绑定)、余额查询
├── pricing.js # 官方价格表、官方页面 HTML 解析、峰谷计费数学
├── store.js # 账本持久化与配置管理($DSH_HOME/storages/cost-meter)
├── typert.host.js # ./typert 导出:Typert 清单(typert-loader 自动注册)
└── client.js # ./client 导出:浏览器单文件 bundle(徽章/图框/设置页)
数据通道:
costUsage 会话投影(纯 token 桶 + 按模型拆分),浏览器经 useProjection('costUsage') 读取并按当前价格表计价;costMeter/getState | updateConfig | fetchPrices | refreshBalance | resetHistory,经 Typert 网关 RPC(remote.costMeter.*);GET {baseURL}/user/balance,复用模型请求的同一把 API Key(凭证服务/环境变量),进程内缓存按 refreshMinutes 过期。插件不导入 cordis/dsh 的 Service/Context 运行时类(仅 Node 内建模块、zod、dsh-home-paths、dsh-credentials 的纯函数),与宿主共享同一运行时实例,无重复依赖风险。
fetchPrices 抓取官方定价页(Docusaurus 服务端预渲染),解析:
解析结果写入价格表并持久化;页面结构变化时同步报错并保留原价格,可手动编辑兜底。
docs/AI-PRICE-SYNC-PROMPT.md(中文)与 docs/AI-PRICE-SYNC-PROMPT.en.md(English) 提供可直接复制给任意 AI 的提示词: AI 自主读取官方定价 → 输出多模型、分时(基础/谷时/峰时 + 生效时间)价格 JSON → 人工核对后应用(设置页 / RPC / 文件三选一)。适合官方价格变动时自主同步。
corepack pnpm install # 依赖
node --check lib/index.js && node --check lib/pricing.js \
&& node --check lib/store.js && node --check lib/typert.host.js \
&& node --check lib/client.js # 语法检查
node test/verify.mjs # 纯模块验证(解析/计费/账本/配置)
node test/mock-balance.mjs # (可选)本地余额接口模拟:3101
dsh --profile web --dump-config # 组合树校验
dsh --profile web --port 3099 # 真机启动(观察启动日志与 UI)
dsh web 生效。各版本更新总览与社区 issue 处理记录见 docs/UPDATE-HISTORY.md;逐条开发记录见 CHANGELOG.md。
MIT © 2026 dsh-cost-meter contributors