Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

refactor(local): rely on provider-owned session data - #149

Merged
makoMakoGo merged 2 commits into
personal/local-clientsfrom
refactor/remove-obsolete-headless-capture
Jul 15, 2026
Merged

refactor(local): rely on provider-owned session data#149
makoMakoGo merged 2 commits into
personal/local-clientsfrom
refactor/remove-obsolete-headless-capture

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • remove the headless subprocess-capture command and its shadow session root
  • remove the Antigravity IDE/2.0 language-server RPC bridge, sync commands, manifest, and generated JSONL source
  • keep the canonical antigravity client backed directly by current AGY CLI SQLite/WAL databases
  • document the provider-owned source boundary and the Antigravity decision in ADR 0025

Why

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-cache is removed.
  • Antigravity reports and the TUI now read $GEMINI_CLI_HOME/antigravity-cli/conversations/*.db, falling back to ~/.gemini/antigravity-cli/conversations/*.db, without an explicit sync step.
  • Antigravity IDE and Antigravity 2.0 Agent Manager history are intentionally unsupported.

Validation

  • cargo test --workspace — 2209 passed, 5 ignored
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo build --release -p tokscale-cli
  • atomically installed the release binary and successfully ran tokscale models --client antigravity --json --no-spinner against current local AGY CLI data

Summary by CodeRabbit

  • 新功能

    • Antigravity 现直接读取 AGY CLI 的 SQLite/WAL 会话数据,无需同步命令。
    • 支持通过客户端与模型报告查看 Antigravity CLI 数据。
  • 变更

    • 移除 headless 捕获命令及相关扫描路径。
    • 移除 Antigravity 同步、状态与缓存清理命令。
    • 不再支持已退休的 Antigravity IDE/2.0 私有 RPC bridge。
    • 移除 native timeout 配置项及相关环境变量。
  • 文档

    • 更新客户端、配置、CLI 与架构说明,明确新的数据来源和支持范围。

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.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

移除了 headless 捕获与 Antigravity 集成命令,删除相关扫描、配置、计数和解析路径;Antigravity 现仅读取 AGY CLI SQLite/WAL,并同步更新 Codex、Claude、Gemini 解析器、缓存身份、测试及文档。

Changes

本地数据源与命令边界

Layer / File(s) Summary
CLI 路由与命令移除
crates/tokscale-cli/src/cli.rs, crates/tokscale-cli/src/main.rs, crates/tokscale-cli/src/commands/*
移除 headless 与 Antigravity 集成命令及执行计划,保留 Cache 与 Warp 路由。
客户端目录与扫描契约
crates/tokscale-core/src/local_clients.rs, crates/tokscale-core/src/scanner.rs, crates/tokscale-cli/src/commands/clients.rs
移除 headless 客户端字段和扫描根,Antigravity 改用 GEMINI_CLI_HOME 下的 CLI 数据路径。
Antigravity CLI 数据源摄取
crates/tokscale-core/src/adapters/antigravity.rs, crates/tokscale-core/src/sessions/antigravity_cli.rs, crates/tokscale-core/src/message_cache.rs
仅发现 SQLite/WAL 数据,使用 CLI parser identity,并在本地计算 response 去重键。
设置与客户端计数收敛
crates/tokscale-cli/src/tui/settings.rs, crates/tokscale-core/src/lib.rs, crates/tokscale-cli/src/failure.rs
删除 native timeout 配置和 headless Codex 计数字段,更新错误分类与设置 fixtures。

解析与缓存管线

Layer / File(s) Summary
Codex 适配器与缓存重构
crates/tokscale-core/src/adapters/mod.rs, crates/tokscale-core/src/adapters/codex.rs, crates/tokscale-core/src/adapters/cache.rs
移除 Codex headless metadata,改用 exec identity,并同步调整解析、恢复、折叠和缓存命中路径。
会话解析语义清理
crates/tokscale-core/src/sessions/codex.rs, crates/tokscale-core/src/sessions/claudecode.rs
删除 headless 解析状态机,将 Codex 状态和 agent 标签改为 exec 语义。
Gemini usage 解析模型
crates/tokscale-core/src/sessions/gemini.rs
将 Gemini 解析命名和数据结构迁移到 usage 模型,保留 token 与 cache 归一化测试。

文档与回归验证

Layer / File(s) Summary
CLI 回归覆盖
crates/tokscale-cli/tests/*, crates/tokscale-core/src/lib_tests.rs
验证 headless 命令不可用、Antigravity 本地路径解析,以及新的 SQLite 测试夹具和输出字段。
数据源边界文档
README*, docs/adr/*, docs/cli.md, docs/clients.md, docs/configuration.md
文档统一说明 AGY CLI SQLite/WAL 为当前 Antigravity 来源,并移除旧 headless 与同步命令说明。

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
Loading

Possibly related PRs

Poem

小兔挥爪删 headless,
CLI 数据落进 SQLite。
WAL 轻响,消息归巢,
Exec 标签闪闪亮;
旧桥退休,报告清爽。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次重构的核心:改为依赖 provider-owned 的本地会话数据。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-obsolete-headless-capture

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@makoMakoGo
makoMakoGo marked this pull request as ready for review July 15, 2026 17:31
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks


Comparing refactor/remove-obsolete-headless-capture (263aa09) with personal/local-clients (3eb5c39)

Open in CodSpeed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3eb5c39 and 263aa09.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (43)
  • README.md
  • README.zh-cn.md
  • crates/tokscale-cli/Cargo.toml
  • crates/tokscale-cli/src/antigravity.rs
  • crates/tokscale-cli/src/cli.rs
  • crates/tokscale-cli/src/commands/clients.rs
  • crates/tokscale-cli/src/commands/headless.rs
  • crates/tokscale-cli/src/commands/integrations.rs
  • crates/tokscale-cli/src/commands/mod.rs
  • crates/tokscale-cli/src/failure.rs
  • crates/tokscale-cli/src/main.rs
  • crates/tokscale-cli/src/main_tests.rs
  • crates/tokscale-cli/src/tui/settings.rs
  • crates/tokscale-cli/tests/cli_tests.rs
  • crates/tokscale-cli/tests/copilot_memory.rs
  • crates/tokscale-core/src/adapters/antigravity.rs
  • crates/tokscale-core/src/adapters/cache.rs
  • crates/tokscale-core/src/adapters/claude.rs
  • crates/tokscale-core/src/adapters/codex.rs
  • crates/tokscale-core/src/adapters/kiro.rs
  • crates/tokscale-core/src/adapters/mod.rs
  • crates/tokscale-core/src/adapters/opencode.rs
  • crates/tokscale-core/src/lib.rs
  • crates/tokscale-core/src/lib_tests.rs
  • crates/tokscale-core/src/local_clients.rs
  • crates/tokscale-core/src/message_cache.rs
  • crates/tokscale-core/src/scanner.rs
  • crates/tokscale-core/src/sessions/antigravity.rs
  • crates/tokscale-core/src/sessions/antigravity_cli.rs
  • crates/tokscale-core/src/sessions/claudecode.rs
  • crates/tokscale-core/src/sessions/codex.rs
  • crates/tokscale-core/src/sessions/gemini.rs
  • crates/tokscale-core/src/sessions/mod.rs
  • docs/adr/0005-local-client-boundaries.md
  • docs/adr/0006-agent-identity-for-agents-tab.md
  • docs/adr/0018-bounded-source-fold-pipeline.md
  • docs/adr/0020-strict-source-identity-and-error-contract.md
  • docs/adr/0022-deterministic-cli-command-semantics.md
  • docs/adr/0025-antigravity-cli-only-local-source.md
  • docs/cli.md
  • docs/clients.md
  • docs/configuration.md
  • docs/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

Comment thread crates/tokscale-cli/src/main_tests.rs
Comment thread crates/tokscale-cli/tests/cli_tests.rs
@makoMakoGo
makoMakoGo merged commit c284102 into personal/local-clients Jul 15, 2026
10 checks passed
@makoMakoGo
makoMakoGo deleted the refactor/remove-obsolete-headless-capture branch July 16, 2026 03:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant