修复 ccusage 20 缓存 token 统计与总量显示#2
Open
Eldon27232 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
ccusage 20的统一命令入口ccusage codex,同时保留旧版ccusage-codex兼容路径。cacheReadTokens/cacheCreationTokens新字段,并将“非缓存输入”和“缓存输入”分开统计。totalTokens。B显示,百万级继续使用M。@ccusage/codex安装指引。根因
@ccusage/codex已迁移到统一的ccusage包。ccusage 20 将非缓存输入、缓存读取和缓存创建拆分为独立字段,但现有实现仍读取旧字段cachedInputTokens,并把总量固定计算为input + output,导致缓存输入显示为 0、总 token 严重偏低。初版修复又把缓存加回了inputTokens;但 ccusage 20 的inputTokens本身就是非缓存输入,因此页面输入值仍然口径错误。用户影响
inputTokens。ccusage-codex与 CC Switch 数据会归一化到同一口径。验证
python -m unittest discover -s tests -v:5 个测试通过python -m compileall -q codex_usage_dashboardpython -m pip wheel . --no-deps:wheel 构建成功git diff --check未提交或上传任何本地 session、生成的 HTML 报告或真实用量数据。