refactor(local): rely on provider-owned session data - #149
Conversation
Read provider-owned non-interactive sessions directly and remove the Tokscale-owned shadow session source. Update local-source boundary docs and drop obsolete timeout and configuration support.
Walkthrough移除了 headless 捕获与 Antigravity 集成命令,删除相关扫描、配置、计数和解析路径;Antigravity 现仅读取 AGY CLI SQLite/WAL,并同步更新 Codex、Claude、Gemini 解析器、缓存身份、测试及文档。 Changes本地数据源与命令边界
解析与缓存管线
文档与回归验证
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant TokscaleCLI
participant LocalScanner
participant AGYSQLiteWAL
participant Report
User->>TokscaleCLI: clients/models --client antigravity
TokscaleCLI->>LocalScanner: resolve Antigravity CLI roots
LocalScanner->>AGYSQLiteWAL: scan SQLite/WAL
AGYSQLiteWAL-->>LocalScanner: CLI conversation records
LocalScanner->>Report: parse and fold messages
Report-->>User: client/model report
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/tokscale-core/src/lib_tests.rs (1)
694-707: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value考虑简化 varint 编码逻辑。
目前的实现通过
loop与条件分支组合来处理,逻辑正确但可以通过简单的while循环使其更加紧凑、符合惯用写法。💡 建议的重构方案
-fn encode_proto_varint(mut value: u64) -> Vec<u8> { - let mut bytes = Vec::new(); - loop { - let mut byte = (value & 0x7f) as u8; - value >>= 7; - if value != 0 { - byte |= 0x80; - } - bytes.push(byte); - if value == 0 { - return bytes; - } - } -} +fn encode_proto_varint(mut value: u64) -> Vec<u8> { + let mut bytes = Vec::new(); + while value >= 0x80 { + bytes.push((value as u8) | 0x80); + value >>= 7; + } + bytes.push(value as u8); + bytes +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/tokscale-core/src/lib_tests.rs` around lines 694 - 707, 简化 encode_proto_varint 的控制流:改用以 value 非零为条件的 while 循环编码完整字节,并在循环结束后追加最终的低 7 位字节;保持现有 u64 varint 编码结果和返回值不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/tokscale-cli/src/main_tests.rs`:
- Line 936: 为测试函数
antigravity_is_a_local_client_without_an_integration_command_namespace 添加
#[test] 属性,确保 cargo test 能发现并执行该测试。
In `@crates/tokscale-cli/tests/cli_tests.rs`:
- Around line 907-920: Update both Tokscale CLI invocations in
test_headless_command_is_not_registered to include the required --no-spinner
argument, preserving the existing help-output and unrecognized-subcommand
assertions.
---
Nitpick comments:
In `@crates/tokscale-core/src/lib_tests.rs`:
- Around line 694-707: 简化 encode_proto_varint 的控制流:改用以 value 非零为条件的 while
循环编码完整字节,并在循环结束后追加最终的低 7 位字节;保持现有 u64 varint 编码结果和返回值不变。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7e7fc21b-63e6-4366-afba-998c508cb02c
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (43)
README.mdREADME.zh-cn.mdcrates/tokscale-cli/Cargo.tomlcrates/tokscale-cli/src/antigravity.rscrates/tokscale-cli/src/cli.rscrates/tokscale-cli/src/commands/clients.rscrates/tokscale-cli/src/commands/headless.rscrates/tokscale-cli/src/commands/integrations.rscrates/tokscale-cli/src/commands/mod.rscrates/tokscale-cli/src/failure.rscrates/tokscale-cli/src/main.rscrates/tokscale-cli/src/main_tests.rscrates/tokscale-cli/src/tui/settings.rscrates/tokscale-cli/tests/cli_tests.rscrates/tokscale-cli/tests/copilot_memory.rscrates/tokscale-core/src/adapters/antigravity.rscrates/tokscale-core/src/adapters/cache.rscrates/tokscale-core/src/adapters/claude.rscrates/tokscale-core/src/adapters/codex.rscrates/tokscale-core/src/adapters/kiro.rscrates/tokscale-core/src/adapters/mod.rscrates/tokscale-core/src/adapters/opencode.rscrates/tokscale-core/src/lib.rscrates/tokscale-core/src/lib_tests.rscrates/tokscale-core/src/local_clients.rscrates/tokscale-core/src/message_cache.rscrates/tokscale-core/src/scanner.rscrates/tokscale-core/src/sessions/antigravity.rscrates/tokscale-core/src/sessions/antigravity_cli.rscrates/tokscale-core/src/sessions/claudecode.rscrates/tokscale-core/src/sessions/codex.rscrates/tokscale-core/src/sessions/gemini.rscrates/tokscale-core/src/sessions/mod.rsdocs/adr/0005-local-client-boundaries.mddocs/adr/0006-agent-identity-for-agents-tab.mddocs/adr/0018-bounded-source-fold-pipeline.mddocs/adr/0020-strict-source-identity-and-error-contract.mddocs/adr/0022-deterministic-cli-command-semantics.mddocs/adr/0025-antigravity-cli-only-local-source.mddocs/cli.mddocs/clients.mddocs/configuration.mddocs/performance/2026-07-10-scan-rss-optimization.md
💤 Files with no reviewable changes (9)
- crates/tokscale-cli/src/commands/mod.rs
- crates/tokscale-cli/tests/copilot_memory.rs
- crates/tokscale-core/src/sessions/antigravity.rs
- crates/tokscale-cli/Cargo.toml
- crates/tokscale-core/src/sessions/mod.rs
- crates/tokscale-cli/src/commands/headless.rs
- crates/tokscale-core/src/scanner.rs
- crates/tokscale-core/src/lib.rs
- crates/tokscale-cli/src/cli.rs
Summary
headlesssubprocess-capture command and its shadow session rootantigravityclient backed directly by current AGY CLI SQLite/WAL databasesWhy
Provider-owned local artifacts are already the authoritative usage source. Capturing provider stdout into a second Tokscale session tree can double count the same execution, while the Antigravity bridge depends on a running process, transient CSRF state, undocumented RPCs, and a Tokscale-owned semantic copy. Both paths add fragile parallel ingestion pipelines without improving current local reporting.
This change intentionally provides no compatibility aliases. Existing
~/.config/tokscale/headless/and~/.config/tokscale/antigravity-cache/files are ignored and may be removed manually.User impact
tokscale headless ...is removed; provider CLIs persist their own non-interactive sessions for ordinary local scanning.tokscale antigravity sync|status|purge-cacheis removed.$GEMINI_CLI_HOME/antigravity-cli/conversations/*.db, falling back to~/.gemini/antigravity-cli/conversations/*.db, without an explicit sync step.Validation
cargo test --workspace— 2209 passed, 5 ignoredcargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo build --release -p tokscale-clitokscale models --client antigravity --json --no-spinneragainst current local AGY CLI dataSummary by CodeRabbit
新功能
变更
headless捕获命令及相关扫描路径。文档