Skip to content

新增:Cursor++ 支持按供应商筛选的 BYOK 成本统计 - #26

Open
happy-ling wants to merge 7 commits into
CometixSpace:mainfrom
happy-ling:feat/usage-cost-dashboard
Open

新增:Cursor++ 支持按供应商筛选的 BYOK 成本统计#26
happy-ling wants to merge 7 commits into
CometixSpace:mainfrom
happy-ling:feat/usage-cost-dashboard

Conversation

@happy-ling

@happy-ling happy-ling commented Sep 2, 2026

Copy link
Copy Markdown

Summary

为 Cursor++ 新增完整的 BYOK 用量/成本统计闭环:侧边栏面板 + 状态栏常驻显示。

计费口径(对照 cc-switch 验证)

  • 四桶 Token:输入 / 输出 / 缓存读取 / 缓存写入
  • 缓存语义按供应商协议归一化:OpenAI/Gemini 的输入含缓存需扣除,Anthropic 为净输入
  • 整数微元(bigint)计费,倍率只作用于总价;每条账单记录当时的币种与价格快照,改价不重算历史
  • 价格直接配置在供应商的模型卡片上(Input/Output/Cache read/Cache write/倍率),同一模型可在不同中转配不同价,无需模型名清洗匹配

侧边栏 Usage 面板

  • Hero 大字跟随所选时间范围联动(Today/7d/14d/30d),副行显示今日花费
  • 六项指标卡:Cost / Requests / Success / Tokens / Cache hit / Cache write
  • 每日费用趋势柱状图(零依赖纯 CSS,多天显示,悬停看当日明细)
  • 供应商 → 模型树形勾选过滤:只影响视图口径,记录永不跳过
  • Recent 列表默认 3 条,点击展开单条请求的 Token 明细与耗时
  • 未计价请求数提示;金额统一 4 位小数展示

状态栏

  • 今日费用(整数)常驻挂在 BYOK 开关后面:✓ BYOK ◉ ¥4
  • 悬停显示精确费用/请求数/成功数;启动初期数据库未就绪时自动重试显示
  • 独立 name 注册,可在状态栏右键菜单单独隐藏

数据治理

  • 每次激活自动清理 90 天前的请求明细,防止 usage_logs 无限膨胀

Notes

  • 密钥与配置仅存于用户主目录(~/.ccursor/),代码不包含任何凭据
  • 官方 Cursor 流量不在统计范围(仅 BYOK 代理请求)

Test

  • pnpm check-types / lint 通过
  • 新增 3 个测试文件(calculator / instrument / store),vitest 全部通过(既有无关模块的 5 个失败在 base 分支上同样存在)

@happy-ling

happy-ling commented Sep 2, 2026

Copy link
Copy Markdown
Author
image image image

图如上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant