ChrisZhangWG/dsh-codex-meter ↗★ 2

dsh-codex-meter

Native DSH Settings → Usage page for DeepSeek API: balance, official token and cost analysis, trends, context warnings, and live API activity. 适合需要详细分析 Token 消耗、消费趋势和实时 API 活动的用户。

Package
dsh-codex-meter
Compatibility
Unverified
Harness peer range
>=0.1.0-rc.6 <0.2.0-0
Version
1.2.2
License
MIT
Last updated
Aug 18, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:ChrisZhangWG/dsh-codex-meter

Usage overview and token analysis

Settings → Usage overview and token analysis

用量缓存(Usage cache)

打开 Settings → Usage 时,页面会先立即显示最近一次成功获取的用量统计,同时并行拉取最新数据,请求成功后替换显示;缓存存活 7 天。

  • 刷新期间显示 Showing saved data · refreshing…
  • 刷新失败时保留已有数据并显示 Refresh failed · showing the last saved data.
  • 只缓存展示型统计数据:余额(balance)、今日消费(Today)、官方 Token 分析(todayAnalysis)、官方历史(usageHistory)与观测到的余额变动(balanceChanges)
  • 绝不缓存 DEEPSEEK_PLATFORM_TOKEN、API Key、凭据等任何密钥(缓存结构里没有这些字段)
  • API activity 不缓存:Active/Idle 始终来自实时活动接口 /api/codex-meter/api-activity
  • 首次打开(无缓存)会等待一次真实请求,属预期行为

配置

  • 余额读取复用 DEEPSEEK_API_KEY(设置 → 模型,或 ~/.dsh/.credentials.yaml)。

  • 官方数据需要 DEEPSEEK_PLATFORM_TOKEN(趋势图、今日官方消费、逐日明细均来自官方接口): 登录 platform.deepseek.com → DevTools → Console → JSON.parse(localStorage.getItem('userToken')).value, 存到 ~/.dsh/.credentials.yaml:

    DEEPSEEK_PLATFORM_TOKEN: 
    

    配置后 Today / 趋势图显示官方精确数据;token 会随平台会话过期,失效时 Today 行显示 Today (refresh needed) 并自动退回 ≈ 估算(数据落 ~/.dsh/storages/codex-meter-day.json), 重新按上述步骤取新 token 即可恢复。

  • 观测到的余额变动记录在 ~/.dsh/storages/codex-meter-balance-history.json(运行期数据,不入库)。

改 lib/index.js(宿主)/ lib/client.js(浏览器端 Usage 页面)

npm test