Repository navigation
feat(collector): support multiple Antigravity CLI account profiles - #72
Merged
Merged
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.
背景与问题
当一台 Mac 通过
--app_data_dir antigravity-cli-<name>同时使用多个 Google Antigravity 账号时:~/.gemini/antigravity-cli/conversations/*.db,并仅靠单一的~/.cache/agy-statusline/current-account为所有会话归账,无法采集额外实例目录下的会话,且并发运行时若current-account被覆盖会导致默认实例归账串号并重复扫描全量.db文件。maybeRefreshAgyQuota/refreshAgyQuota)原本只检查全局唯一的节流键和默认账号的缓存文件,也不支持携带--app_data_dir与WSL_INTEROP=1刷新额外实例。变更内容
src/collector/agy.ts):当conversationsDir位于<geminiDir>/antigravity-cli/conversations时,自动发现同级<geminiDir>/antigravity-cli-<name>实例。每个实例优先从自身的antigravity-oauth-token(解析id_tokenJWT 的email本地部分)或cli.log/log/cli-*.log识别账号标签;额外实例回退到current-account-<name>,绝不回退到默认实例的current-account。汇总所有实例的.db路径后统一调用一次forgetMissingAgyFiles,保留各实例已读取文件的游标。src/collector/agy.ts、src/collector/main.ts):记录本轮产生新用量或缺失账户的实例列表,按实例分别检查quota-<label>.tsv缓存时间与节流元数据键(默认实例保持agy_quota_refresh_at,额外实例使用agy_quota_refresh_at:<name>),探测额外实例时传入--gemini_dir、--app_data_dir antigravity-cli-<name>与WSL_INTEROP=1,并将账号标签写回对应的current-account-<name>。tests/collector-agy.test.ts、docs/collector.md):新增多实例自动发现、未登录实例隔离、agy_files跨实例保留及按实例额度刷新的集成测试,并更新采集器文档。验证结果
bun test tests(84 个测试文件共 621 项测试)全部通过。bun run typecheck、bunx prettier --check与git diff --check全部通过。