Repository navigation
feat(collector): detect Claude plans from the login credential for 0.10.0 - #41
Merged
Merged
Conversation
Claude Code 2.1.3xx no longer writes organizationType or organizationRateLimitTier to ~/.claude.json, so new logins reported no plan and an unknown account kind. The collector now reads only subscriptionType and rateLimitTier from the local login credential (Keychain via /usr/bin/security, or .credentials.json), confirms the logged-in account did not change during the read, and keeps the last known plan when the credential is unavailable. seatTier identifies Team Standard and Team Premium as a fallback. Plan history now treats only two different known plans as a change. Filling in an unknown plan relabels the existing observation, so the quota estimate keeps every reading of the current cycle. Users can set a Claude account's plan from the account menu; the setting only fills unknown observations and bumps the ledger revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Older collectors recorded Team Premium as max-5x and Team or Enterprise by their raw organization type. Plan history now compares plans through planRelation, so renames and refinements relabel the last observation instead of opening a boundary, and a type-only credential no longer overrides a more specific legacy tier. Legacy histories that end in an unknown observation resume their earlier plan or record a real change at the current time. The collector adopts a credential plan only after two consecutive rounds see the same account and plan, since Claude Code writes the credential before .claude.json when switching accounts. The keychain service suffix hashes the raw CLAUDE_CONFIG_DIR value like Claude Code does. Manual plans apply only to Claude accounts, also fill histories of accounts merged into the target, and refresh the report right after saving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ic plans Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
问题
Claude Code 2.1.3xx 起不再把
organizationType和organizationRateLimitTier写进~/.claude.json,只留下billingType和seatTier(例如team_tier_1),套餐档位只存在登录凭据里。采集器仍按旧字段识别,所以新登录的 Pro 与 Team 账户套餐为空,界面显示「账户类型未知」。另一个隐患是,套餐从未知变成已知时,服务端会当作一次套餐变化,额度预估从识别时刻重新起算,本周期已有读数被丢掉。比如用到 20% 时才识别出套餐,预估会变差。
改动
security命令读取钥匙串条目「Claude Code-credentials」(其他系统读.credentials.json),只取subscriptionType和rateLimitTier,令牌不解析、不保存、不上传。不运行 Claude Code 命令,也不发网络请求。team加default_claude_max_5x)。读不到凭据时,用seatTier识别 Team Standard 和 Team Premium,并沿用此前记录的套餐。.claude.json,所以采集器只采用连续两轮都对同一账户读到的同一套餐,避免把新账户的套餐记到旧账户上。planRelation区分同一套餐的改名、细化和真实变化。只有两个不同的已知套餐才算变化。从未知补成已知,或旧标识换成新标识(旧版把 Team Premium 记为max-5x),都只改写最后一次观测的标签,保留其时间。docs/collector.md(读取范围和凭据说明)、docs/reporting.md(徽标档位、手动设置、套餐变化规则),以及 CHANGELOG。版本 0.10.0,数据库结构版本未变,升级无需备份。验证
bun test tests462 通过;bun run build、所改文件 Prettier 和git diff --check通过。max-5x改名为team-premium时,预估前后完全一致。team加default_claude_max_5x,scan显示team-premium。team-premium和订阅账户。Playwright 在桌面 1440 和手机 390 宽度下打开「设置套餐」,改为 Max 20x 后徽标随之变化,再恢复自动识别,没有页面报错。已知限制
CLAUDE_CONFIG_DIR为相对路径时,钥匙串条目名可能对不上,套餐会退回到席位档位或手动设置。🤖 Generated with Claude Code