All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.
Rust
feat(antigravity): read the plain-text brain transcripts (#52)
Corey Chiu316948b80c48
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cb9c4f2..51655ee 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,7 @@- New: Kilo Code sessions are indexed — from the database the VS Code extension, the `kilo` CLI and the JetBrains plugin share (`~/.local/share/kilo/kilo.db`, read-only), and from the legacy extension's task folders in VS Code and other VS Code-based editors. Titles, models, thinking, tool calls and token counts included; legacy sub-tasks are listed under the task that started them, and a legacy task the new extension has imported is listed once. Open In continues a session with `kilo --session` in its project directory (legacy tasks have no Open In). On remote hosts only the legacy tasks are mirrored, since `kilo.db` also holds Kilo's credentials (#59, thanks @ICEY4040727)- Fix: OpenCode sessions show the slash command that started a sub-agent instead of an empty message, and on Windows they are grouped under the same project as other agents' sessions- New: Enlarge the whole interface to 110%, 125% or 150% with ⌘+ / ⌘− / ⌘0 (Ctrl on Linux and Windows), the new View menu, or the new Settings → Appearance page, which also takes over the light / dark choice from General; the level is remembered (#51, thanks @kyomind)+- New: Antigravity conversations are read in full from the plain-text transcripts recent versions of the desktop app and the IDE save — messages, thinking, tool calls with their output, the model and pasted images — and conversations from the IDE carry an IDE badge. Conversations without a transcript are still listed from Antigravity's index, as before. The agent is now called Antigravity instead of Antigravity CLI (#52, thanks @iroha3)## [0.8.6] — 2026-10-01diff --git a/PRODUCT.md b/PRODUCT.mdindex 282f45f..0f0556f 100644--- a/PRODUCT.md+++ b/PRODUCT.md@@ -30,7 +30,7 @@ Corey 本人(独立开发者,主力工具 Claude Code 与 Codex,中文为主)。已实现:二十二家 adapter、FTS5 trigram 搜索(<3 码点 LIKE 降级)、**搜索跳转定位**(2026-08-18:⌘K 命中直达详情页对应消息并高亮,seq 契约保证)、详情页逐消息渲染(气泡/工具折叠簇/thinking/tree-sitter 高亮;2026-08-17 由整篇 markdown 方案升级)、恢复/收藏/置顶/导出/删除(废纸篓+墓碑)、文件监听增量、Insights 统计页(0.3.0:活跃热力图与 streak、时段/星期/月份分布、Agents·Projects·Models 三榜单按 sessions/tokens/prompts 切换;2026-09-03 加 Last 7 days 周对比行与 Over time 近 53 周按 agent 堆叠的每周 prompts 趋势图;口径=主线用户消息,规格见 DESIGN.md)、Updates 页与 macOS Wake 菜单手动检查 GitHub 最新正式版并打开 Release 页更新(不后台联网、不自动替换应用包)、测试套件(adapter 契约、DB 往返、scanner 回归 + CI 三平台 + pre-commit,合成 fixture)、三端桌面(macOS 主平台;Linux/Windows experimental,终端恢复/废纸篓·回收站/剪贴板按平台原生实现,发版 CI 自动出六产物)、窗口记忆(0.3.6:记住所在屏幕/屏内位置/最大化/全屏,重启与 Dock 重开都回到原处,Settings 开在主窗所在屏)、完整 macOS 菜单栏(0.3.6:标准 Edit/Window 菜单、⌘W、Window → Main Window,主窗关闭后 About/Settings/Updates 仍可用)、导出 Markdown 与保存图片走系统「另存为」并记住上次目录(0.3.6,issue #25)、远程 host(0.4.0,issue #21:Settings → Remote hosts 配 SSH 目标,rsync 白名单镜像会话数据到本地缓存后与本地会话同列同搜,`@host` 徽章标识;阶段 1 只读——不动远端文件、远程会话禁删,resume 以 Copy SSH command 形态提供;分期计划见 CLAUDE.md「远程 host」节)、**MCP 接入**(0.5.0:随应用打包的只读 `wake-mcp` stdio server,四个工具 wake_search / wake_list_sessions / wake_get_session / wake_list_projects,Claude Code / Codex / Cursor 等任何 MCP 客户端可搜历史、按项目列会话、分页读转录;Settings → Connect 展示路径与可复制配置片段,只展示不代写别家配置;零 LLM、零网络、不写库;完整参考 docs/mcp.md)、**命令行与 Skill**(0.6.0:并排打包的只读 `wake-cli`,四个子命令 search / sessions / show / projects 加 setup,给"能跑 shell 但不说 MCP"的 agent 和真人用——它不新写查询逻辑,argv 翻成 JSON 喂同一批工具,输出与 MCP 客户端看到的**逐字节相同**(仅 CLI 末尾补一个换行)并由测试卡住,所以文档只需描述一份格式;`skills/wake/SKILL.md` 是可一行安装的 skill(`npx skills add iAmCorey/Wake`),用触发条件而非名词解释写 description,让 agent 自己想得起来去翻会话历史;完整参考 docs/cli.md;0.6.3 加 `wake-cli index`——装了 Wake 却从没启动过时,agent 自己跑一条就能把索引建起来继续干活,而不是停下来问人。它**只建不存在的索引**,已有的库原样交给 GUI:扫描落在旁边的临时库、扫完才原子占位,所以被中途杀掉可重试、撞上 GUI 首扫就退让;2026-09-22 加 `wake-cli refresh`,issue #43:app 不开时增量刷新已有索引,给靠 MCP / CLI 用 Wake、只在浏览时开 app 的人用 launch agent / systemd timer 定时跑,Wake 开着窗或还有扫描在写就退让——GUI 与两个写命令共用一把索引写锁,锁跟 Workbench 与写线程走、关窗即放,GUI 启动会等正在跑的 refresh 收尾)、Connect 页四区块(0.6.1:MCP server / MCP clients / Command line / Skill,每个面的第一块挂自己的文档链接)、**记忆可见层**(2026-09-17 起,只读:把各家 agent 自己写下的记忆——Claude Code 的按项目 auto-memory、Codex 的 memories 与逐会话摘要、ZCode 的按项目记忆——按项目聚合;GUI 的 Memory 页是侧栏底部的整页目的地,侧栏在这一页换成按记忆计数的 All Memory / Agents / Projects 导航;MCP 加第五个工具 `wake_list_memories`,`wake_get_session` 认 `wake://memory/…` 引用现场读文件,`wake_search` 末尾附记忆命中;CLI 加 `memories`;记忆的项目归属按它挂的会话在读时解析,永远跟着索引走。二期(2026-09-21)把用户写给 agent 的指令文件也收进来:各家 home 里的 CLAUDE.md / AGENTS.md(与 `rules/*.rules`)/ GEMINI.md,以及已索引项目根下的 CLAUDE.md / AGENTS.md / GEMINI.md / `.cursor/rules` / `.cursorrules` / `.kiro/steering` / `.github/copilot-instructions.md`,与记忆同列同搜、不另作区分;Settings 加 Memory locations 页,与 Session locations 同形制:逐来源开关、添加自定义目录或文件、Restore defaults。不编辑、不同步、不删除——写别家数据破铁律,要改一个 Reveal 就到;也不做"把会话自动写成记忆")。后续边界(2026-09-07 定):摘要层(需 LLM、opt-in、明示会把会话正文发给用户配置的端点)只在 MCP 接入有真实使用之后再做;Timeline / Profile 一类视图建立在摘要之上;不做 ChatGPT / Claude.ai 导出导入主线、不做实体本体与知识图谱、不做 Chrome 扩展注入。约束:对 agent 数据目录只读;绝不写 Codex 的 SQLite;不读凭证;GPUI 无 SF Symbols(图标用 lucide SVG 自备)。-已支持二十二家 agent:Claude Code、Codex(0.6.6 起排除可识别的内部线程:guardian auto-review、`/review`、compaction、memory consolidation 与用户会话同树,adapter 文件边界按首行 session_meta 的 source / thread_source 认出即不枚举;老格式或读不出的首行保守放行,`codex exec --thread-source` 打了标签的自动化线程照常收录,issue #30。`spawn_agent` 子代理是其中唯一的例外,issue #42:那是用户自己派出去的活,收录后挂在派它的会话下面、以任务名为标题,fork 进来的父线程历史折成一条不入库的占位,父会话的对话不会被索引两遍)、Qoder CLI(`~/.qoder/projects` JSONL,active-leaf 分支恢复、tool result 回挂、`QODER_CONFIG_DIR`)、Copilot CLI、Cursor(CLI 转录 + 0.6.7 起 IDE Chat/Composer 历史,PR #32:`globalStorage/state.vscdb` 明文 KV 库,composerData 给顺序、bubbleId 行给正文;转录带正文的会话归转录源,库只补转录缺失或只剩 turn_ended 空壳的会话;库里多数老会话没存工作区路径,落 Unknown project)、OpenCode(含 OpenCode 2 next,stable 的 `opencode.db` 与 next 的 `opencode-next.db` 同时扫描;逐会话兼容 `message+part`、真实 `session+session_message` 及早期 `session_v2` schema;preview 会话标 opencode2 徽章)、Kiro、Gemini CLI(2026-08-17 P1 五家落地)+ Pi、Oh My Pi、Grok Build、Kimi Code、Antigravity CLI(2026-08-19 对齐 kooky 内置 roster;Antigravity 正文加密仅元数据卡片)+ DeepSeek Harness(dsh,2026-08-20,zstd 事件日志透明解压;格式由源码推断,当天用户跑出真实会话完成首验)+ Hermes Agent(2026-09-03,多档案 state.db,无 cwd 故 project 留空)、OpenClaw(2026-09-03,两代存储同扫;本机零会话,格式由源码推断未经真机验证)、CodeBuddy(2026-09-14,issue #27:`~/.codebuddy/projects` 的 Responses 形 JSONL,custom / ai / topic 三级标题,`CODEBUDDY_CONFIG_DIR`;本机零会话,格式由官方 CLI 文档与三家第三方实现交叉推断、未经真机验证)、WorkBuddy(同日,CodeBuddy 的孪生实例:同一解析核心,`~/.workbuddy/projects`、`WORKBUDDY_CONFIG_DIR`;桌面 app 无 CLI,不提供 resume;同构只有 cc-switch 一家佐证)、ZCode(2026-09-21:Z.ai 的 GLM-5.3 官方 harness,桌面 app;运行时是 OpenCode 衍生物——`~/.zcode/cli/db/db.sqlite` 的 session/message/part 与 OpenCode v1 同形、part 解码复用,但 session 表没有 model/tokens 列故另起一家;`v2/tasks-index.sqlite` 只借 deleted / migration_source 两个过滤位;按 `task_type` 白名单只列 interactive / fork / selection_side_chat(subagent_child 等运行时会话不列);`semantics.transcriptVisibility == hidden` 与用户消息 `origin != real_user` 归 Meta、compact_summary 折成一条、字段缺席放行;`ZCODE_STORAGE_DIR`;桌面 app 无 CLI、`zcode://` 没有按会话打开的深链,不提供 resume;本机 3.14.0 真会话首验通过,同日开源(Apache-2.0)后语义全部按源码核对)、Craft Agents(2026-09-24,issue #44:Craft Docs 的开源桌面 app,自己不带引擎——Anthropic 连接跑 Claude Agent SDK、其余连接(ChatGPT / Codex 订阅、Copilot、Google)跑 Pi SDK,另记一份给用户看的 `~/.craft-agent/workspaces/<工作区>/sessions/<id>/session.jsonl`,Wake 读这一份;子任务与分支挂回原会话,分支从父会话复制来的那段折成一条;Claude 连接在 `~/.claude/projects` 留下的引擎副本由通用的"认领"机制藏掉,原件还在才藏;工作区可建在任意位置,但登记表带 server token 不读,别处的工作区走 Session locations;桌面 app 无 CLI,不提供 resume;本机 0.13.5 真会话首验通过,ChatGPT 与 Claude 连接各一条)、Devin(2026-09-24,issue #46:`~/.local/share/devin/cli/sessions.db` 单库两表,message_nodes 森林按 `main_chain_id` 叶子沿 `parent_node_id` 取主链,hidden 会话与零正文不列,逐消息 `generation_model` 与 `metrics` 按主链累计;`XDG_DATA_HOME`;`devin --resume <id>` 按 cwd 分桶 resume;格式按本机真库验证)、Kilo Code(2026-10-07,issue #59:一家两源——2026-04 起的新版 VS Code 扩展、`kilo` CLI 与 JetBrains 插件是 OpenCode 分支,三端共用 `~/.local/share/kilo/kilo.db`,表与 OpenCode 同形、按 OpenCode 的孪生实例读;session_message 里只有实验开关零星双写的 shell 一类记录时读 message + part(OpenCode 同一条规则);旧版扩展(Roo / Cline 系)每个任务一个目录,在各个 VS Code 系编辑器的 `globalStorage/kilocode.kilo-code/tasks` 里,正文是 Anthropic 消息数组,`<task>` / `<feedback>` / `<answer>` 才是人打的字、编辑器快照丢掉,旧任务用新版导入时给的 `ses_migrated_` id,导入过的那份 kilo.db 胜出;新版 `kilo --session` 在原项目目录续,旧任务没有 Open In、也不实时监听(任务目录里有整份 checkpoints 影子仓库);kilo.db 里同库存着凭证,远程只同步 vscode-server 下的旧任务;本机零会话,新版的表结构按源码的建库语句核过,数据形状由源码推断、未经真机验证)。做不了的:Windsurf/Trae 加密,Amp/Factory(Droid)/Warp 云端无本地数据,Reasonix 本机零会话格式未实测。+已支持二十二家 agent:Claude Code、Codex(0.6.6 起排除可识别的内部线程:guardian auto-review、`/review`、compaction、memory consolidation 与用户会话同树,adapter 文件边界按首行 session_meta 的 source / thread_source 认出即不枚举;老格式或读不出的首行保守放行,`codex exec --thread-source` 打了标签的自动化线程照常收录,issue #30。`spawn_agent` 子代理是其中唯一的例外,issue #42:那是用户自己派出去的活,收录后挂在派它的会话下面、以任务名为标题,fork 进来的父线程历史折成一条不入库的占位,父会话的对话不会被索引两遍)、Qoder CLI(`~/.qoder/projects` JSONL,active-leaf 分支恢复、tool result 回挂、`QODER_CONFIG_DIR`)、Copilot CLI、Cursor(CLI 转录 + 0.6.7 起 IDE Chat/Composer 历史,PR #32:`globalStorage/state.vscdb` 明文 KV 库,composerData 给顺序、bubbleId 行给正文;转录带正文的会话归转录源,库只补转录缺失或只剩 turn_ended 空壳的会话;库里多数老会话没存工作区路径,落 Unknown project)、OpenCode(含 OpenCode 2 next,stable 的 `opencode.db` 与 next 的 `opencode-next.db` 同时扫描;逐会话兼容 `message+part`、真实 `session+session_message` 及早期 `session_v2` schema;preview 会话标 opencode2 徽章)、Kiro、Gemini CLI(2026-08-17 P1 五家落地)+ Pi、Oh My Pi、Grok Build、Kimi Code、Antigravity(2026-08-19 对齐 kooky 内置 roster,起初只有 `antigravity-cli` 会话索引里的元数据卡片——正文是加密 .pb;2026-10-08 起读新版本桌面端与 IDE 写在 `~/.gemini/antigravity/brain`、`~/.gemini/antigravity-ide/brain` 的明文转录,含工具输出、模型与用户贴图,IDE 会话挂 via 徽章,同一会话转录与卡片按 id 只出一份、没有转录的仍列卡片;显示名由 Antigravity CLI 改为 Antigravity。格式取自 PR #52 @iroha3 对真实数据的整理,本机 brain 目录还没有转录,未经真机验证)+ DeepSeek Harness(dsh,2026-08-20,zstd 事件日志透明解压;格式由源码推断,当天用户跑出真实会话完成首验)+ Hermes Agent(2026-09-03,多档案 state.db,无 cwd 故 project 留空)、OpenClaw(2026-09-03,两代存储同扫;本机零会话,格式由源码推断未经真机验证)、CodeBuddy(2026-09-14,issue #27:`~/.codebuddy/projects` 的 Responses 形 JSONL,custom / ai / topic 三级标题,`CODEBUDDY_CONFIG_DIR`;本机零会话,格式由官方 CLI 文档与三家第三方实现交叉推断、未经真机验证)、WorkBuddy(同日,CodeBuddy 的孪生实例:同一解析核心,`~/.workbuddy/projects`、`WORKBUDDY_CONFIG_DIR`;桌面 app 无 CLI,不提供 resume;同构只有 cc-switch 一家佐证)、ZCode(2026-09-21:Z.ai 的 GLM-5.3 官方 harness,桌面 app;运行时是 OpenCode 衍生物——`~/.zcode/cli/db/db.sqlite` 的 session/message/part 与 OpenCode v1 同形、part 解码复用,但 session 表没有 model/tokens 列故另起一家;`v2/tasks-index.sqlite` 只借 deleted / migration_source 两个过滤位;按 `task_type` 白名单只列 interactive / fork / selection_side_chat(subagent_child 等运行时会话不列);`semantics.transcriptVisibility == hidden` 与用户消息 `origin != real_user` 归 Meta、compact_summary 折成一条、字段缺席放行;`ZCODE_STORAGE_DIR`;桌面 app 无 CLI、`zcode://` 没有按会话打开的深链,不提供 resume;本机 3.14.0 真会话首验通过,同日开源(Apache-2.0)后语义全部按源码核对)、Craft Agents(2026-09-24,issue #44:Craft Docs 的开源桌面 app,自己不带引擎——Anthropic 连接跑 Claude Agent SDK、其余连接(ChatGPT / Codex 订阅、Copilot、Google)跑 Pi SDK,另记一份给用户看的 `~/.craft-agent/workspaces/<工作区>/sessions/<id>/session.jsonl`,Wake 读这一份;子任务与分支挂回原会话,分支从父会话复制来的那段折成一条;Claude 连接在 `~/.claude/projects` 留下的引擎副本由通用的"认领"机制藏掉,原件还在才藏;工作区可建在任意位置,但登记表带 server token 不读,别处的工作区走 Session locations;桌面 app 无 CLI,不提供 resume;本机 0.13.5 真会话首验通过,ChatGPT 与 Claude 连接各一条)、Devin(2026-09-24,issue #46:`~/.local/share/devin/cli/sessions.db` 单库两表,message_nodes 森林按 `main_chain_id` 叶子沿 `parent_node_id` 取主链,hidden 会话与零正文不列,逐消息 `generation_model` 与 `metrics` 按主链累计;`XDG_DATA_HOME`;`devin --resume <id>` 按 cwd 分桶 resume;格式按本机真库验证)、Kilo Code(2026-10-07,issue #59:一家两源——2026-04 起的新版 VS Code 扩展、`kilo` CLI 与 JetBrains 插件是 OpenCode 分支,三端共用 `~/.local/share/kilo/kilo.db`,表与 OpenCode 同形、按 OpenCode 的孪生实例读;session_message 里只有实验开关零星双写的 shell 一类记录时读 message + part(OpenCode 同一条规则);旧版扩展(Roo / Cline 系)每个任务一个目录,在各个 VS Code 系编辑器的 `globalStorage/kilocode.kilo-code/tasks` 里,正文是 Anthropic 消息数组,`<task>` / `<feedback>` / `<answer>` 才是人打的字、编辑器快照丢掉,旧任务用新版导入时给的 `ses_migrated_` id,导入过的那份 kilo.db 胜出;新版 `kilo --session` 在原项目目录续,旧任务没有 Open In、也不实时监听(任务目录里有整份 checkpoints 影子仓库);kilo.db 里同库存着凭证,远程只同步 vscode-server 下的旧任务;本机零会话,新版的表结构按源码的建库语句核过,数据形状由源码推断、未经真机验证)。做不了的:Windsurf/Trae 加密,Amp/Factory(Droid)/Warp 云端无本地数据,Reasonix 本机零会话格式未实测。## Brand Commitmentsdiff --git a/README.md b/README.mdindex 7eccaa5..a8236aa 100644--- a/README.md+++ b/README.md@@ -44,7 +44,7 @@ Your agent history is scattered across `~/.claude`, `~/.codex`, and a dozen othe| Oh My Pi | `~/.omp/agent/sessions/**/*.jsonl` | ✅ | — || Grok Build | `~/.grok/sessions/**/updates.jsonl` | ✅ | — || Kimi Code | `~/.kimi-code/sessions/**/wire.jsonl` | — | — |-| Antigravity CLI | `~/.gemini/antigravity-cli/conversation_summaries.db` (metadata only — transcripts are encrypted) | — | — |+| Antigravity | `~/.gemini/antigravity/brain` and `~/.gemini/antigravity-ide/brain` (the plain-text transcripts recent versions of the desktop app and the IDE write, pasted images included) + `~/.gemini/antigravity-cli/conversation_summaries.db` (the conversation index shared by the CLI, desktop app and IDE; a conversation with no transcript on disk is listed from it as a summary card, since its body is stored encrypted) | ✅ | ✅ || DeepSeek Harness (`dsh`) | `~/.dsh/sessions/**/session[.vN].jsonl[.zstd]` (the newest log format generation is read; zstd-compressed logs are decoded transparently) | ✅ | — || Hermes Agent | `~/.hermes/state.db` + `profiles/*/state.db` (`HERMES_HOME` is respected) | ✅ | ✅ || OpenClaw | `~/.openclaw/agents/*/agent/openclaw-agent.sqlite` + legacy `agents/*/sessions/*.jsonl` (`OPENCLAW_STATE_DIR` is respected) | ✅ | ✅ |@@ -55,7 +55,7 @@ Your agent history is scattered across `~/.claude`, `~/.codex`, and a dozen othe| Devin | `~/.local/share/devin/cli/sessions.db` (read-only; `XDG_DATA_HOME` is respected) | ✅ | — || Kilo Code | `~/.local/share/kilo/kilo.db` (VS Code extension, CLI and JetBrains plugin share it; read-only; `XDG_DATA_HOME` and `KILO_DB` are respected) + the legacy extension's `globalStorage/kilocode.kilo-code/tasks` in VS Code and other VS Code-based editors | ✅ | ✅ |-**Model** = whether Wake shows which LLM a session used (the model the session last used). **Via** = whether Wake shows where the session was started from (CLI, IDE extension, desktop app) — Codex records this in its local data; Hermes and OpenClaw record the channel a session came in through (Telegram, Discord, …); Craft Agents marks sessions its automations started; Kilo Code's legacy tasks show which editor they ran in. A "—" means the agent's local data simply doesn't record that field, not a missing feature.+**Model** = whether Wake shows which LLM a session used (the model the session last used). **Via** = whether Wake shows where the session was started from (CLI, IDE extension, desktop app) — Codex records this in its local data; Hermes and OpenClaw record the channel a session came in through (Telegram, Discord, …); Antigravity marks conversations from its IDE; Craft Agents marks sessions its automations started; Kilo Code's legacy tasks show which editor they ran in. A "—" means the agent's local data simply doesn't record that field, not a missing feature.Craft Agents runs other agents' engines rather than its own: a Claude connection drives the Claude Agent SDK, which also saves every conversation into Claude Code's history. Wake lists the Craft session and hides that engine copy for as long as the Craft session exists — delete the session in Craft and the copy shows up again as a Claude Code session. Craft's short title-generation calls on a Claude connection are saved by the SDK too, and appear as one-message Claude Code sessions under *Unknown project*.diff --git a/crates/wake-core/src/adapters/antigravity.rs b/crates/wake-core/src/adapters/antigravity.rsindex 764f3a3..36526ba 100644--- a/crates/wake-core/src/adapters/antigravity.rs+++ b/crates/wake-core/src/adapters/antigravity.rs@@ -1,163 +1,613 @@use super::parse_utils::*;-use super::sqlite_ro::{open_sqlite_ro, virtual_path};+use super::sqlite_ro::{db_cache_stamp, open_sqlite_ro, table_columns, virtual_path};use super::AgentAdapter;use crate::models::*;use anyhow::{anyhow, Result};+use serde_json::Value;+use std::borrow::Cow;use std::collections::HashMap;-use std::path::PathBuf;+use std::io::{BufRead, BufReader};+use std::path::{Path, PathBuf};+use std::sync::Arc;-/// Antigravity CLI(Google,binary `agy`):会话正文是加密 .pb,唯一明文是-/// `~/.gemini/antigravity-cli/conversation_summaries.db`(WAL)——只能做-/// 元数据级会话卡片:标题在 preview 列(title 列基本为空)、时间、workspace。-/// 详情页由一条 System 消息承载 preview 与"正文加密"说明,FTS 只搜得到它。-/// 无每会话文件,SessionFileRef 用虚拟路径;打开一律走 sqlite_ro 三级梯度。+/// Antigravity(Google,binary `agy`):CLI、桌面端与 IDE 共用一个会话 id 空间,本地有两种数据。+/// - `~/.gemini/antigravity-cli/conversation_summaries.db`:跨端的会话索引(WAL)。只有元数据+/// ——标题在 preview 列(title 列常空)、时间、workspace、父会话、会话所在的 app 数据目录+/// (`app_data_dir`,老库没有这一列);正文另存为加密 .pb,读不到。+/// - `<app 数据目录>/brain/<id>/.system_generated/logs/transcript.jsonl`:新版本写下的明文转录+/// (`~/.gemini/antigravity/brain` 与 `~/.gemini/antigravity-ide/brain`),用户贴图在同会话的+/// `.user_uploaded/media_<毫秒>.<ext>`。格式来自 PR #52(@iroha3)对真实数据的整理;本机的+/// brain 目录还没有转录,这一形态未经真机验证。+///+/// 两种都如实列出,同一会话转录与卡片的胜负交给 scanner 的副本裁决(`dedup_rank`:转录恒胜,+/// 转录读不出时卡片接得住);转录的标题、工作区与来自哪一端仍以索引为准。pub struct AntigravityAdapter {- db: PathBuf,- /// 全表很小(元数据行),按 db mtime 缓存一轮扫描内的重复调用- rows_cache: MtimeCache<Vec<AgRow>>,+ /// 会话索引;选中的自定义 location 不含它时为 None+ db: Option<PathBuf>,+ /// 转录根(各 app 数据目录下的 `brain`)+ brains: Vec<PathBuf>,+ /// 索引全表很小(元数据行),按库戳缓存;读失败交回上一次读到的+ index_cache: MtimeCache<Arc<Index>>,+}++const DB_FILE: &str = "conversation_summaries.db";+/// 写 `brain` 的 app 数据目录(`~/.gemini` 下):桌面端 / CLI 与 IDE+const APP_DIRS: [&str; 2] = ["antigravity", "antigravity-ide"];+/// 会话目录里转录的相对路径+const TRANSCRIPT: [&str; 3] = [".system_generated", "logs", "transcript.jsonl"];+const ENCRYPTED_NOTE: &str =+ "Antigravity stores this conversation encrypted — only its summary is available in Wake.";++/// 会话 id → 索引里那一行+type Index = HashMap<String, AgRow>;++struct AgRow {+ title: String,+ preview: String,+ step_count: i64,+ modified_ms: i64,+ cwd: String,+ /// 子会话(派生的、并行比较的):卡片与转录都不列+ child: bool,+ /// 会话所在的 app 数据目录名;老库没有这一列,空+ app: String,+}++impl AgRow {+ /// 这一行展示出来的东西的指纹(dirty 判断用):卡片的 size 就是它,转录的 size 加上它+ fn fingerprint(&self) -> i64 {+ (self.title.len() + self.preview.len() + self.cwd.len() + self.app.len()) as i64+ }}impl AntigravityAdapter {pub fn new() -> Self {+ Self::at(&super::home_dir().unwrap_or_default().join(".gemini"))+ }++ /// `~/.gemini` 形态:索引 + 两个 app 数据目录下的 brain+ fn at(gemini: &Path) -> Self {+ Self::from_parts(+ Some(gemini.join("antigravity-cli").join(DB_FILE)),+ APP_DIRS+ .iter()+ .map(|app| gemini.join(app).join("brain"))+ .collect(),+ )+ }++ fn from_parts(db: Option<PathBuf>, brains: Vec<PathBuf>) -> Self {Self {- db: super::home_dir()- .unwrap_or_default()- .join(".gemini")- .join("antigravity-cli")- .join("conversation_summaries.db"),- rows_cache: MtimeCache::new(),+ db,+ brains,+ index_cache: MtimeCache::new(),}}- fn rows(&self) -> Option<Vec<AgRow>> {- let mtime = super::sqlite_ro::db_cache_stamp(&self.db);- self.rows_cache.get_or_try_build(mtime, || {- let ro = open_sqlite_ro(&self.db, "antigravity")?;- let mut stmt = ro- .conn- .prepare(- "SELECT conversation_id, title, preview, step_count, last_modified_time, workspace_uris- FROM conversation_summaries- WHERE parent_conversation_id = '' AND nesting_depth = 0",- )- .ok()?;- let rows = stmt+ /// 索引全表(含子会话,列表与转录都要按它滤)。None = 没有索引库,或从没读成功过。+ /// 库不在了是确定没有,不交回上一次读到的(删掉的会话会一直列着);在却读不出才用旧的+ fn index(&self) -> Option<Arc<Index>> {+ let db = self.db.as_ref().filter(|db| db.is_file())?;+ self.index_cache.get_or_stale(db_cache_stamp(db), || {+ let ro = open_sqlite_ro(db, "antigravity")?;+ let app = if table_columns(&ro.conn, "conversation_summaries").contains("app_data_dir")+ {+ "app_data_dir"+ } else {+ "''"+ };+ let sql = format!(+ "SELECT conversation_id, title, preview, step_count, last_modified_time,+ workspace_uris, parent_conversation_id, nesting_depth, {app}+ FROM conversation_summaries"+ );+ let mut stmt = ro.conn.prepare(&sql).ok()?;+ let index = stmt.query_map([], |r| {- Ok(AgRow {- id: r.get(0)?,- title: r.get::<_, Option<String>>(1)?.unwrap_or_default(),- preview: r.get::<_, Option<String>>(2)?.unwrap_or_default(),+ let text =+ |i: usize| r.get::<_, Option<String>>(i).map(Option::unwrap_or_default);+ let row = AgRow {+ title: text(1)?,+ preview: text(2)?,step_count: r.get::<_, Option<i64>>(3)?.unwrap_or(0),- modified_ms: sqlite_dt_ms(r.get::<_, Option<String>>(4)?.unwrap_or_default().trim()),- cwd: first_workspace(&r.get::<_, Option<String>>(5)?.unwrap_or_default()),- })+ modified_ms: sqlite_dt_ms(text(4)?.trim()),+ cwd: canonical_project_path(&first_workspace(&text(5)?)),+ child: !text(6)?.is_empty() || r.get::<_, Option<i64>>(7)?.unwrap_or(0) > 0,+ app: text(8)?,+ };+ Ok((r.get::<_, String>(0)?, row))}).ok()?- .collect::<rusqlite::Result<Vec<_>>>()+ .collect::<rusqlite::Result<Index>>().ok()?;- Some(rows)+ Some(Arc::new(index))})}- fn build_meta(&self, r: &SessionFileRef, row: &AgRow) -> SessionMeta {- let title = Some(clean_title_candidate(&row.title))- .filter(|t| !t.is_empty())- .or_else(|| Some(clean_title_candidate(&row.preview)).filter(|t| !t.is_empty()))- .unwrap_or_else(|| UNTITLED.to_string());- // 库里只有 last_modified 一个时间,created/updated 同源- let ts = if row.modified_ms > 0 {- row.modified_ms- } else {- r.mtime_ms- };- SessionMeta {- key: format!("antigravity:{}", row.id),- host: String::new(),- id: row.id.clone(),- agent: AgentId::Antigravity,- title,- project_path: row.cwd.clone(),- project_name: project_name_of(&row.cwd),- file_path: r.file_path.clone(),- created_at: ts,- updated_at: ts,- message_count: row.step_count,- size_bytes: r.size,- git_branch: None,- model: None,- tokens_used: None,- archived: false,- source: None,- favorite: false,- pinned: false,+ fn parse(+ &self,+ r: &SessionFileRef,+ decode_images: bool,+ ) -> Result<(SessionMeta, Vec<TranscriptMessage>, u32)> {+ let index = self.index();+ let row = index.as_deref().and_then(|index| index.get(&r.native_id));+ if is_transcript(&r.file_path) {+ return transcript(r, row, decode_images);}+ let row = row+ .ok_or_else(|| anyhow!("antigravity conversation {} not in the index", r.native_id))?;+ Ok(card(r, row))}+}- fn parse(&self, r: &SessionFileRef) -> Result<(SessionMeta, Vec<TranscriptMessage>)> {- let rows = self- .rows()- .ok_or_else(|| anyhow!("cannot open antigravity summaries store"))?;- let row = rows- .iter()- .find(|x| x.id == r.native_id)- .ok_or_else(|| anyhow!("antigravity conversation {} not in store", r.native_id))?;-- // 正文加密不可读:一条 System 消息承载 preview,详情页与 FTS 都有着落- let mut text = String::new();- if !row.preview.trim().is_empty() {- text.push_str(row.preview.trim());- text.push_str("\n\n");- }- text.push_str("Antigravity stores conversation content encrypted — only this summary is available in Wake.");- let mut messages = vec![text_msg(Role::System, &text, row.modified_ms)];- assign_seq(&mut messages);- Ok((self.build_meta(r, row), messages))+/// 两种数据共有的那一半:身份、文件与大小;其余字段由调用方填+fn base_meta(r: &SessionFileRef) -> SessionMeta {+ SessionMeta {+ key: session_key(AgentId::Antigravity, "", &r.native_id),+ host: String::new(),+ id: r.native_id.clone(),+ agent: AgentId::Antigravity,+ title: String::new(),+ project_name: String::new(),+ project_path: String::new(),+ file_path: r.file_path.clone(),+ created_at: 0,+ updated_at: 0,+ message_count: 0,+ size_bytes: r.size,+ git_branch: None,+ model: None,+ tokens_used: None,+ archived: false,+ source: None,+ favorite: false,+ pinned: false,}}-#[derive(Clone)]-struct AgRow {- id: String,- title: String,- preview: String,- step_count: i64,- modified_ms: i64,- cwd: String,+fn card_meta(r: &SessionFileRef, row: &AgRow) -> SessionMeta {+ // 库里只有 last_modified 一个时间,created/updated 同源+ let ts = if row.modified_ms > 0 {+ row.modified_ms+ } else {+ r.mtime_ms+ };+ SessionMeta {+ title: first_title(&[&row.title, &row.preview]),+ project_name: project_name_of(&row.cwd),+ project_path: row.cwd.clone(),+ created_at: ts,+ updated_at: ts,+ message_count: row.step_count,+ source: surface(&row.app),+ ..base_meta(r)+ }+}++/// 只有元数据的卡片:正文加密不可读,一条 System 消息承载 preview,详情页与 FTS 都有着落+fn card(r: &SessionFileRef, row: &AgRow) -> (SessionMeta, Vec<TranscriptMessage>, u32) {+ let mut text = ParsedContent::default();+ text.push_text(&row.preview);+ text.push_text(ENCRYPTED_NOTE);+ let mut messages = vec![text_msg(Role::System, &text.text, row.modified_ms)];+ assign_seq(&mut messages);+ (card_meta(r, row), messages, 0)+}++fn transcript(+ r: &SessionFileRef,+ row: Option<&AgRow>,+ decode_images: bool,+) -> Result<(SessionMeta, Vec<TranscriptMessage>, u32)> {+ let path = Path::new(&r.file_path);+ let t = read_transcript(path, decode_images)?;+ // 一条消息都读不出(截断、全是不认识的行)算解析失败:scanner 退回同一会话的卡片,+ // 不让坏转录把读得出的摘要顶掉(cursor.rs 对零消息的坏转录同样报 Err)+ if t.messages.is_empty() {+ return Err(anyhow!(+ "antigravity transcript has no readable messages: {}",+ r.file_path+ ));+ }+ // 标题、工作区与来自哪一端以索引为准;没进索引的会话退回转录里的线索+ let (indexed_title, preview) =+ row.map_or(("", ""), |row| (row.title.as_str(), row.preview.as_str()));+ let request = title_from_messages(&t.messages).unwrap_or_default();+ let project = row+ .map(|row| row.cwd.clone())+ .filter(|cwd| !cwd.is_empty())+ .or_else(|| t.workspace.as_deref().map(canonical_project_path))+ .unwrap_or_default();+ let app = row+ .map(|row| row.app.as_str())+ .filter(|app| !app.is_empty())+ .or_else(|| app_dir_of(path))+ .unwrap_or_default();+ let fallback = row+ .map(|row| row.modified_ms)+ .filter(|ms| *ms > 0)+ .unwrap_or(r.mtime_ms);+ let meta = SessionMeta {+ title: first_title(&[indexed_title, &request, preview]),+ project_name: project_name_of(&project),+ project_path: project,+ created_at: if t.first_ts > 0 { t.first_ts } else { fallback },+ updated_at: if t.last_ts > 0 { t.last_ts } else { fallback },+ message_count: t.messages.len() as i64,+ model: t.model,+ source: surface(app),+ ..base_meta(r)+ };+ Ok((meta, t.messages, t.unknown_lines))+}++/// 依次取第一个洗得出东西的候选作标题+fn first_title(candidates: &[&str]) -> String {+ candidates+ .iter()+ .map(|raw| clean_title_candidate(raw))+ .find(|title| !title.is_empty())+ .unwrap_or_else(|| UNTITLED.to_string())+}++/// 会话来自哪一端:IDE 挂 via 徽章;桌面端 / CLI 是默认形态,不挂+fn surface(app_dir: &str) -> Option<String> {+ (app_dir == "antigravity-ide").then(|| "IDE".to_string())+}++fn is_transcript(path: &str) -> bool {+ Path::new(path).file_name().and_then(|n| n.to_str()) == Some(TRANSCRIPT[2])+}++/// 会话目录里转录的相对路径,按平台分隔符拼(写死 `/` 的话 Windows 上与 watcher 报来的+/// 路径对不上)+fn transcript_rel() -> PathBuf {+ TRANSCRIPT.iter().collect()+}++/// `<brain>/<id>/.system_generated/logs/transcript.jsonl` → `<brain>/<id>`(形状不对给 None)+fn session_dir(transcript: &Path) -> Option<&Path> {+ transcript+ .ends_with(transcript_rel())+ .then(|| transcript.ancestors().nth(TRANSCRIPT.len()))+ .flatten()+}++/// 转录所在的 app 数据目录名(`<app>/brain/<id>/…` 的 `<app>`)+fn app_dir_of(transcript: &Path) -> Option<&str> {+ session_dir(transcript)?+ .parent()?+ .parent()?+ .file_name()?+ .to_str()+}++/// 转录的会话引用,列表与 watcher 同一个判据。索引里那一行也算进 mtime / size:它变了而+/// 转录没动(在 app 里改了名、转录先于索引写出来)也会重解析+fn transcript_ref(index: Option<&Index>, path: &Path) -> Option<SessionFileRef> {+ let id = session_dir(path)?.file_name()?.to_str()?;+ let row = index.and_then(|index| index.get(id));+ if row.is_some_and(|row| row.child) {+ return None;+ }+ let mut r = default_file_ref(AgentId::Antigravity, path)?;+ r.native_id = id.to_string();+ if let Some(row) = row {+ r.mtime_ms = r.mtime_ms.max(row.modified_ms);+ r.size += row.fingerprint();+ }+ Some(r)+}++fn card_ref(db: &Path, id: &str, row: &AgRow) -> SessionFileRef {+ SessionFileRef {+ agent: AgentId::Antigravity,+ native_id: id.to_string(),+ file_path: virtual_path(db, id),+ mtime_ms: row.modified_ms,+ // 正文不可读,这一行的指纹即内容指纹+ size: row.fingerprint(),+ }}/// workspace_uris JSON 数组("[\"file:///Users/…\"]")首项 → 本地路径fn first_workspace(raw: &str) -> String {- let Ok(v) = serde_json::from_str::<serde_json::Value>(raw) else {+ let Ok(v) = serde_json::from_str::<Value>(raw) else {return String::new();};- let Some(uri) = v- .as_array()- .and_then(|a| a.first())- .and_then(|x| x.as_str())- else {+ let Some(uri) = v.as_array().and_then(|a| a.first()).and_then(Value::as_str) else {return String::new();};- let path = uri.strip_prefix("file://").unwrap_or(uri);- percent_decode(path)-}--/// file:// URI 的最小 percent-decode(路径含空格/中文时是 %XX 编码)-fn percent_decode(s: &str) -> String {- let bytes = s.as_bytes();- let mut out: Vec<u8> = Vec::with_capacity(bytes.len());- let mut i = 0;- while i < bytes.len() {- if bytes[i] == b'%' && i + 2 < bytes.len() {- if let Ok(b) = u8::from_str_radix(&s[i + 1..i + 3], 16) {- out.push(b);- i += 3;- continue;+ percent_decode(uri.strip_prefix("file://").unwrap_or(uri))+}++// ---------------------------------------------------------------- 转录++/// 一行一个步骤 `{step_index, source, type, status, created_at, content?, thinking?, tool_calls?}`。+/// `USER_INPUT` 是用户的一轮(正文在 `<USER_REQUEST>` 里,其余是 IDE 注入的元数据);+/// `PLANNER_RESPONSE` 是模型的一步(正文 / thinking / tool_calls),一轮里的多步并成一条助手+/// 消息;下面这些是工具执行的结果,按顺序回填到还没有输出的调用上;`CHECKPOINT` 是上下文压缩+const TOOL_RESULTS: &[&str] = &[+ "VIEW_FILE",+ "RUN_COMMAND",+ "GREP_SEARCH",+ "LIST_DIRECTORY",+ "CODE_ACTION",+ "BROWSER_SUBAGENT",+ "SEARCH_WEB",+ "READ_URL_CONTENT",+ "ASK_QUESTION",+ "GENERIC",+ "ERROR_MESSAGE",+];+/// 给模型看的上下文,不是对话+const KNOWN_SKIP: &[&str] = &[+ "CONVERSATION_HISTORY",+ "KNOWLEDGE_ARTIFACTS",+ "SYSTEM_MESSAGE",+];+/// 工具输入里能当一行摘要的字段,依次取第一个(键是 PascalCase,`make_preview` 认的那几个+/// snake_case 键对不上)+const PREVIEW_KEYS: &[&str] = &[+ "toolSummary",+ "toolAction",+ "CommandLine",+ "TargetFile",+ "AbsolutePath",+ "Query",+ "DirectoryPath",+];+/// 工具输入里的工作目录(没进索引的会话拿它推工作区)+const CWD_KEYS: &[&str] = &["Cwd", "DirectoryPath", "SearchPath"];++#[derive(Default)]+struct Transcript {+ messages: Vec<TranscriptMessage>,+ /// 工具的工作目录 > 用户当时打开的文件所在目录+ workspace: Option<String>,+ model: Option<String>,+ first_ts: i64,+ last_ts: i64,+ unknown_lines: u32,+}++#[derive(Default)]+struct Turn {+ content: ParsedContent,+ thinking: Vec<String>,+ tool_calls: Vec<ToolCallView>,+ timestamp: Option<i64>,+ model: Option<String>,+}++impl Turn {+ fn flush(&mut self, messages: &mut Vec<TranscriptMessage>) {+ let turn = std::mem::take(self);+ if turn.content.text.is_empty() && turn.thinking.is_empty() && turn.tool_calls.is_empty() {+ return;+ }+ let (text, truncated) = clip(&turn.content.text, MAX_MSG_TEXT);+ messages.push(TranscriptMessage {+ seq: 0,+ role: Role::Assistant,+ kind: MessageKind::Text,+ text,+ truncated,+ tool_calls: turn.tool_calls,+ thinking: (!turn.thinking.is_empty())+ .then(|| clip(&turn.thinking.join("\n\n"), MAX_TOOL_IO).0),+ timestamp: turn.timestamp,+ model: turn.model,+ images: Vec::new(),+ });+ }+}++fn read_transcript(path: &Path, decode_images: bool) -> Result<Transcript> {+ let _budget = transcript_image_decode_budget(decode_images);+ let reader = BufReader::new(std::fs::File::open(path)?);+ let mut t = Transcript::default();+ let mut turn = Turn::default();+ let mut document = None;++ for line in reader.lines() {+ let Ok(line) = line else {+ t.unknown_lines += 1;+ continue;+ };+ if line.trim().is_empty() {+ continue;+ }+ let Ok(row) = serde_json::from_str::<Value>(&line) else {+ t.unknown_lines += 1;+ continue;+ };+ let str_of = |key: &str| row.get(key).and_then(Value::as_str).unwrap_or("");+ let ts = iso_ms(str_of("created_at"));+ if ts > 0 {+ if t.first_ts == 0 {+ t.first_ts = ts;+ }+ t.last_ts = ts;+ }+ let step = str_of("type");+ match step {+ "USER_INPUT" => {+ turn.flush(&mut t.messages);+ let content = str_of("content");+ let text = extract_tag(content, "USER_REQUEST")+ .map(|inner| inner.trim().to_string())+ .unwrap_or_else(|| content.trim().to_string());+ if let Some(selected) = model_selection(content) {+ t.model = Some(selected);+ }+ if document.is_none() {+ document = active_document(content);+ }+ let mut message = text_msg(Role::User, &text, ts);+ message.model = t.model.clone();+ t.messages.push(message);}+ "PLANNER_RESPONSE" => {+ if turn.timestamp.is_none() && ts > 0 {+ turn.timestamp = Some(ts);+ }+ if turn.model.is_none() {+ turn.model = t.model.clone();+ }+ turn.content.push_text(str_of("content"));+ let thinking = str_of("thinking").trim();+ if !thinking.is_empty() {+ turn.thinking.push(thinking.to_string());+ }+ let step_ix = row.get("step_index").and_then(Value::as_i64).unwrap_or(0);+ let calls = row.get("tool_calls").and_then(Value::as_array);+ for (n, call) in calls.into_iter().flatten().enumerate() {+ let args = tool_args(call.get("args"));+ if t.workspace.is_none() {+ t.workspace = first_str(&args, CWD_KEYS);+ }+ let name = call.get("name").and_then(Value::as_str).unwrap_or_default();+ let mut view =+ tool_call_view(format!("step-{step_ix}-{n}"), name, &args, None, false);+ if let Some(preview) = first_str(&args, PREVIEW_KEYS) {+ view.input_preview = make_preview(&Value::String(preview));+ }+ turn.tool_calls.push(view);+ }+ }+ _ if TOOL_RESULTS.contains(&step) => {+ let content = str_of("content").trim();+ let is_error = str_of("status") == "ERROR" || step == "ERROR_MESSAGE";+ // 结果按调用的先后到达:回填给第一个还没有输出的调用+ if let Some(call) = turn.tool_calls.iter_mut().find(|c| c.output.is_none()) {+ call.output = Some(clip(content, MAX_TOOL_IO).0);+ call.is_error = is_error;+ } else if is_error && !content.is_empty() {+ // 没有待回填的调用:先把这一轮已有的回复落下,错误排在它后面+ turn.flush(&mut t.messages);+ t.messages.push(text_msg(Role::System, content, ts));+ }+ }+ "CHECKPOINT" => {+ turn.flush(&mut t.messages);+ let content = str_of("content").trim();+ if !content.is_empty() {+ let mut summary = text_msg(Role::System, content, ts);+ summary.kind = MessageKind::CompactSummary;+ t.messages.push(summary);+ }+ }+ _ if KNOWN_SKIP.contains(&step) => {}+ _ => t.unknown_lines += 1,+ }+ }+ turn.flush(&mut t.messages);+ if t.workspace.is_none() {+ t.workspace = document.and_then(|doc| {+ Path::new(&doc)+ .parent()+ .map(|dir| dir.to_string_lossy().into_owned())+ });+ }+ if decode_images {+ if let Some(dir) = session_dir(path) {+ attach_uploads(&mut t.messages, dir);+ }+ }+ assign_seq(&mut t.messages);+ Ok(t)+}++/// 工具参数:对象,或者装着对象的 JSON 字符串(解不开就按原样)+fn tool_args(args: Option<&Value>) -> Cow<'_, Value> {+ let Some(args) = args else {+ return Cow::Owned(Value::Null);+ };+ match args.as_str().and_then(|s| serde_json::from_str(s).ok()) {+ Some(parsed) => Cow::Owned(parsed),+ None => Cow::Borrowed(args),+ }+}++fn first_str(args: &Value, keys: &[&str]) -> Option<String> {+ let map = args.as_object()?;+ keys.iter().find_map(|key| {+ let value = map+ .get(*key)?+ .as_str()?+ .trim()+ .trim_matches(['"', '\''])+ .trim();+ (!value.is_empty()).then(|| value.to_string())+ })+}++/// `<USER_SETTINGS_CHANGE>` 里的 "changed setting `Model Selection` from X to Y."+fn model_selection(content: &str) -> Option<String> {+ let at = content.find("`Model Selection` from")?;+ let after = &content[at..];+ let to = after.find(" to ")? + " to ".len();+ let value = after[to..].lines().next()?.trim();+ let value = value+ .split(". ")+ .next()+ .unwrap_or(value)+ .trim_end_matches('.')+ .trim();+ (!value.is_empty()).then(|| value.to_string())+}++/// `<ADDITIONAL_METADATA>` 里的 "Active Document: /path/file.rs (LANGUAGE_RUST)"+fn active_document(content: &str) -> Option<String> {+ let at = content.find("Active Document:")?;+ let line = content[at + "Active Document:".len()..]+ .lines()+ .next()?+ .trim();+ let path = line.split_once(" (").map_or(line, |(path, _)| path).trim();+ (!path.is_empty()).then(|| path.to_string())+}++/// 用户贴图:`<会话>/.user_uploaded/media_<毫秒>.<ext>`,文件名里的毫秒是上传时刻,与所属那条+/// 用户消息的时间只差几秒(PR #52 实测 36 张:35 张在 5 分钟内)。按时间回挂到最近的一条用户+/// 消息、插在正文末尾;差出半小时的宁可不挂,也不塞给别的轮次+fn attach_uploads(messages: &mut [TranscriptMessage], session: &Path) {+ const MAX_GAP_MS: i64 = 30 * 60 * 1000;+ let Ok(entries) = std::fs::read_dir(session.join(".user_uploaded")) else {+ return;+ };+ let mut uploads: Vec<(i64, PathBuf)> = entries+ .flatten()+ .filter_map(|entry| {+ let name = entry.file_name().to_string_lossy().to_string();+ let ms = name+ .strip_prefix("media_")?+ .split_once('.')?+ .0+ .parse()+ .ok()?;+ Some((ms, entry.path()))+ })+ .collect();+ uploads.sort();+ let users: Vec<(usize, i64)> = messages+ .iter()+ .enumerate()+ .filter(|(_, m)| m.role == Role::User)+ .filter_map(|(ix, m)| m.timestamp.map(|ts| (ix, ts)))+ .collect();+ for (ms, path) in uploads {+ let Some(&(ix, ts)) = users.iter().min_by_key(|(_, ts)| (ts - ms).abs()) else {+ return;+ };+ if (ts - ms).abs() > MAX_GAP_MS {+ continue;+ }+ if let Some(image) = image_from_session_file(session, &path) {+ append_images_to_message_end(&mut messages[ix], vec![image]);}- out.push(bytes[i]);- i += 1;}- String::from_utf8_lossy(&out).to_string()}impl AgentAdapter for AntigravityAdapter {@@ -166,69 +616,197 @@ impl AgentAdapter for AntigravityAdapter {}fn list_session_files(&self) -> Result<Vec<SessionFileRef>> {- let Some(rows) = self.rows() else {- return Ok(Vec::new());- };- Ok(rows- .into_iter()- .map(|row| SessionFileRef {- agent: AgentId::Antigravity,- native_id: row.id.clone(),- file_path: virtual_path(&self.db, &row.id),- mtime_ms: row.modified_ms,- // 正文不可读,标题/preview 长度即内容指纹(dirty 判断用)- size: (row.title.len() + row.preview.len()) as i64,- })- .collect())+ let index = self.index();+ // 索引在却从没读成功过:报错,scanner 把这一家这一轮冻结住(库里的卡片原样留着),+ // 别把它当成"没有会话"——那会把卡片整批删掉;库不在才是确定没有+ if index.is_none() && self.db.as_ref().is_some_and(|db| db.is_file()) {+ return Err(anyhow!("cannot read the Antigravity conversation index"));+ }+ let index = index.as_deref();+ let rel = transcript_rel();+ let mut refs = Vec::new();+ for brain in &self.brains {+ let Ok(entries) = std::fs::read_dir(brain) else {+ continue;+ };+ refs.extend(+ entries+ .flatten()+ .filter_map(|entry| transcript_ref(index, &entry.path().join(&rel))),+ );+ }+ // 有转录的会话也照列卡片:scanner 按 dedup_rank 取转录,转录读不出时退回卡片+ if let (Some(db), Some(index)) = (&self.db, index) {+ refs.extend(+ index+ .iter()+ .filter(|(_, row)| !row.child)+ .map(|(id, row)| card_ref(db, id, row)),+ );+ }+ Ok(refs)+ }++ fn file_ref(&self, path: &Path) -> Option<SessionFileRef> {+ transcript_ref(self.index().as_deref(), path)}fn quick_meta(&self, refs: &[SessionFileRef]) -> Option<HashMap<String, SessionMeta>> {- let rows = self.rows()?;- let by_id: HashMap<&str, &AgRow> = rows.iter().map(|r| (r.id.as_str(), r)).collect();- let mut out = HashMap::new();- for r in refs {- if let Some(row) = by_id.get(r.native_id.as_str()) {- out.insert(r.file_path.clone(), self.build_meta(r, row));- }- }- Some(out)+ let index = self.index()?;+ Some(+ refs.iter()+ // 卡片的元数据全在库里;转录要解析才有+ .filter(|r| !is_transcript(&r.file_path))+ .filter_map(|r| {+ let row = index.get(&r.native_id)?;+ Some((r.file_path.clone(), card_meta(r, row)))+ })+ .collect(),+ )}fn parse_session(&self, r: &SessionFileRef) -> Result<ParsedSession> {- let (meta, messages) = self.parse(r)?;- Ok(ParsedSession::derive(meta, &messages, 0))+ let (meta, messages, unknown) = self.parse(r, false)?;+ Ok(ParsedSession::derive(meta, &messages, unknown))}fn parse_transcript(&self, r: &SessionFileRef) -> Result<ParsedTranscript> {- let (meta, messages) = self.parse(r)?;+ let (meta, messages, unknown) = self.parse(r, true)?;Ok(ParsedTranscript {meta,mainline: messages,sidechains: Vec::new(),- unknown_line_count: 0,+ unknown_line_count: unknown,})}+ /// 同一会话的转录永远压过库里的卡片——卡片只是转录还没写出来时的占位+ fn dedup_rank(&self, path: &str) -> u8 {+ u8::from(!is_transcript(path))+ }++ /// 转录是整个会话目录(贴图、生成的产物都在里面),整目录进废纸篓;卡片是库里的行,+ /// 只记墓碑+ fn session_paths(&self, meta: &SessionMeta) -> Vec<String> {+ match session_dir(Path::new(&meta.file_path)) {+ Some(dir) => vec![dir.to_string_lossy().to_string()],+ None => vec![meta.file_path.clone()],+ }+ }++ fn cleanup_paths(&self, meta: &SessionMeta) -> Option<Vec<String>> {+ is_transcript(&meta.file_path).then(|| self.session_paths(meta))+ }+fn with_custom_root(&self, dir: PathBuf) -> Box<dyn AgentAdapter> {- // 选中 `~/.gemini` 形态(含 antigravity-cli/)、库所在目录,或直接- // 给到库文件路径都认(Codex review)- let nested = dir- .join("antigravity-cli")- .join("conversation_summaries.db");- let db = if dir.is_file() {- dir- } else if nested.is_file() {- nested+ // 按名字认形状;只在选中的路径本身与它里面探索引库,不摸它外面的东西。远程挂载点+ // 在第一次同步之前还不存在,落到最后一支的 `.gemini` 形态+ let name = dir+ .file_name()+ .and_then(|n| n.to_str())+ .unwrap_or_default()+ .to_string();+ let adapter = if dir.is_file() {+ // 直接选了索引库文件+ Self::from_parts(Some(dir), Vec::new())+ } else if name == "brain" {+ Self::from_parts(None, vec![dir])+ } else if name == "antigravity-cli" || dir.join(DB_FILE).is_file() {+ // 索引库所在的目录(或它的拷贝)+ Self::from_parts(Some(dir.join(DB_FILE)), Vec::new())+ } else if APP_DIRS.contains(&name.as_str()) {+ Self::from_parts(None, vec![dir.join("brain")])} else {- dir.join("conversation_summaries.db")+ Self::at(&dir)};- Box::new(Self {- db,- rows_cache: MtimeCache::new(),- })+ Box::new(adapter)}fn data_roots(&self) -> Vec<PathBuf> {- vec![self.db.clone()]+ self.db.iter().chain(&self.brains).cloned().collect()+ }++ /// 索引与各 brain 彼此独立,Session locations 里可以单独停掉其中一个+ fn supports_individual_root_removal(&self) -> bool {+ true+ }++ fn excluding_data_roots(&self, roots: &[PathBuf]) -> Option<Box<dyn AgentAdapter>> {+ Some(Box::new(Self::from_parts(+ self.db.clone().filter(|db| !roots.contains(db)),+ self.brains+ .iter()+ .filter(|brain| !roots.contains(brain))+ .cloned()+ .collect(),+ )))+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn user_input_metadata_is_read_out_of_the_injected_blocks() {+ let content = "<USER_REQUEST>\nFix it\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\n\+ Active Document: /Users/me/proj/src/ui.rs (LANGUAGE_RUST)\n\+ </ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting \+ `Model Selection` from None to Gemini 3.7 Flash (High). No need to reply.\n\+ </USER_SETTINGS_CHANGE>";+ assert_eq!(+ active_document(content).as_deref(),+ Some("/Users/me/proj/src/ui.rs")+ );+ assert_eq!(+ model_selection(content).as_deref(),+ Some("Gemini 3.7 Flash (High)")+ );+ assert_eq!(model_selection("<USER_REQUEST>hi</USER_REQUEST>"), None);+ }++ /// 没有待回填的调用时来的错误:排在这一轮已有的回复后面,不插到它前面+ #[test]+ fn a_standalone_error_follows_the_reply_before_it() {+ let dir = tempfile::tempdir().unwrap();+ let path = dir.path().join("transcript.jsonl");+ std::fs::write(+ &path,+ concat!(+ r#"{"type":"USER_INPUT","created_at":"2026-08-30T02:11:10Z","content":"<USER_REQUEST>go</USER_REQUEST>"}"#,+ "\n",+ r#"{"type":"PLANNER_RESPONSE","created_at":"2026-08-30T02:11:12Z","content":"Working on it."}"#,+ "\n",+ r#"{"type":"ERROR_MESSAGE","status":"ERROR","created_at":"2026-08-30T02:11:13Z","content":"quota exceeded"}"#,+ "\n",+ ),+ )+ .unwrap();+ let t = read_transcript(&path, false).unwrap();+ let roles: Vec<Role> = t.messages.iter().map(|m| m.role).collect();+ assert_eq!(roles, vec![Role::User, Role::Assistant, Role::System]);+ assert_eq!(t.messages[1].text, "Working on it.");+ assert_eq!(t.messages[2].text, "quota exceeded");+ }++ #[test]+ fn transcript_paths_have_one_shape() {+ let path: PathBuf = ["/h", ".gemini", "antigravity-ide", "brain", "abc"]+ .iter()+ .collect::<PathBuf>()+ .join(transcript_rel());+ let session: PathBuf = ["/h", ".gemini", "antigravity-ide", "brain", "abc"]+ .iter()+ .collect();+ assert_eq!(session_dir(&path), Some(session.as_path()));+ assert_eq!(app_dir_of(&path), Some("antigravity-ide"));+ assert_eq!(+ session_dir(Path::new("/h/brain/abc/logs/transcript.jsonl")),+ None+ );+ assert!(is_transcript(&path.to_string_lossy()));+ assert!(!is_transcript(+ "/h/.gemini/antigravity-cli/conversation_summaries.db#abc"+ ));}}diff --git a/crates/wake-core/src/adapters/grok_group.rs b/crates/wake-core/src/adapters/grok_group.rsindex 415bfe3..e68c7e4 100644--- a/crates/wake-core/src/adapters/grok_group.rs+++ b/crates/wake-core/src/adapters/grok_group.rs@@ -1,7 +1,7 @@//! Grok 会话归组:主会话登记的 subagent 关系优先,无父会话时再用//! worktree registry、git remote 与临时 worktree 名称恢复真实项目。-use super::parse_utils::project_name_of;+use super::parse_utils::{percent_decode, project_name_of};use super::sqlite_ro::open_sqlite_ro;use serde_json::Value;use std::collections::{HashMap, HashSet};@@ -139,33 +139,6 @@ fn load_worktree_rows(grok_home: &Path) -> Vec<WorktreeRow> {rows.flatten().collect()}-fn hex_digit(c: u8) -> Option<u8> {- Some(match c {- b'0'..=b'9' => c - b'0',- b'a'..=b'f' => c - b'a' + 10,- b'A'..=b'F' => c - b'A' + 10,- _ => return None,- })-}--fn percent_decode(input: &str) -> String {- let bytes = input.as_bytes();- let mut out = Vec::with_capacity(bytes.len());- let mut ix = 0;- while ix < bytes.len() {- if bytes[ix] == b'%' && ix + 2 < bytes.len() {- if let (Some(high), Some(low)) = (hex_digit(bytes[ix + 1]), hex_digit(bytes[ix + 2])) {- out.push((high << 4) | low);- ix += 3;- continue;- }- }- out.push(bytes[ix]);- ix += 1;- }- String::from_utf8_lossy(&out).into_owned()-}-fn group_cwd(cwd_dir: &Path) -> String {if let Ok(raw) = fs::read_to_string(cwd_dir.join(".cwd")) {let cwd = raw.trim();diff --git a/crates/wake-core/src/adapters/mod.rs b/crates/wake-core/src/adapters/mod.rsindex e92203a..0f6c055 100644--- a/crates/wake-core/src/adapters/mod.rs+++ b/crates/wake-core/src/adapters/mod.rs@@ -53,7 +53,8 @@ pub trait AgentAdapter: Send + Sync {}/// 枚举全部会话文件。契约是"枚举必须廉价、绝不做全量解析":多数家纯 stat,/// SQLite 型跑元数据查询,dsh 读有界首行(子代理标志只存在于文件头)。- /// 故障就地降级为空列表,不外溢炸掉整轮扫描。+ /// 根不在就是确定没有,降级为 Ok(空);Err 只表示"这一刻读不出"(库在却打不开)——+ /// scanner 冻结这一家这一轮(库里归它的行原样留着),别家照常。fn list_session_files(&self) -> Result<Vec<SessionFileRef>>;/// watcher 事件路径 → 本 adapter 的会话文件引用;None = 非会话文件/// (边车、子代理转录等)。默认:非空 .jsonl,stem 即 native_id。@@ -320,8 +321,8 @@ pub(crate) fn home_dir() -> Option<std::path::PathBuf> {/// 全量二十二家 roster,**不按 detect 过滤**。这是全应用唯一的构造点:/// scanner/watcher/resume/Session locations 面板共享 Workbench 启动时的-/// 同一份实例。缺根的家由各自 list_session_files 降级为 Ok(空)(scanner-/// 对 Err 会 `?` 截断整轮,新 adapter 必须维持这条降级约定,contract 测试+/// 同一份实例。缺根的家由各自 list_session_files 降级为 Ok(空)(Err 会让+/// scanner 把这一家这一轮当成"读不出"冻结住,缺根不是读不出,contract 测试/// 有卡)。**不要为任何用途二次构造 roster**:根路径是构造时刻对 env/// (CODEX_HOME/XDG_DATA_HOME)与文件系统的快照,两份实例可能解析出不同的/// 根,UI 就会展示一个扫描器并不在读的路径。diff --git a/crates/wake-core/src/adapters/parse_utils.rs b/crates/wake-core/src/adapters/parse_utils.rsindex 31be551..043e2cd 100644--- a/crates/wake-core/src/adapters/parse_utils.rs+++ b/crates/wake-core/src/adapters/parse_utils.rs@@ -39,6 +39,11 @@ impl Drop for ImageDecodeBudgetGuard {}}+/// 预算还放不放得下 `bytes`(只看不扣):读文件之前先问,放不下的连读都不读+fn image_decode_budget_allows(bytes: usize) -> bool {+ IMAGE_DECODE_REMAINING.with(|remaining| remaining.get().is_none_or(|left| bytes <= left))+}+fn consume_image_decode_budget(bytes: usize) -> bool {IMAGE_DECODE_REMAINING.with(|remaining| match remaining.get() {Some(left) if bytes <= left => {@@ -651,6 +656,56 @@ pub fn decode_data_uri(uri: &str) -> Option<ImageAttachment> {decode_base64_image(data, Some(media_type))}+/// 会话自己目录里的图片文件(Antigravity 的 `.user_uploaded/`)→ 图片附件。只给 adapter 自己+/// 枚举出来的文件用,**不要拿转录内容里写的路径来调**——那条路一律不解引用本地路径(见+/// `image_parser_never_dereferences_local_paths`)。解开符号链接后必须仍在 `session` 目录里:+/// 远程镜像原样保留符号链接,指到外面的会读到本机的文件(中间哪一层目录是链接都一样)。+/// 类型按字节嗅探;解码预算与 base64 那条路同一份(调用方的解析要开着+/// `transcript_image_decode_budget`),按 stat 到的大小先问预算再读+pub fn image_from_session_file(+ session: &std::path::Path,+ path: &std::path::Path,+) -> Option<ImageAttachment> {+ let real = std::fs::canonicalize(path).ok()?;+ if !real.starts_with(std::fs::canonicalize(session).ok()?) {+ return None;+ }+ let len = std::fs::metadata(&real).ok()?.len();+ if len == 0 || len > MAX_IMAGE_BYTES || !image_decode_budget_allows(len as usize) {+ return None;+ }+ attachment_from_bytes(std::fs::read(&real).ok()?, None)+}++/// URI / 目录名里的 percent-encoding(`%2F` → `/`)。逐字节解,不成对的 `%` 原样留着,+/// 后面跟着多字节字符也不会切坏(按 `&str` 下标切会 panic)+pub fn percent_decode(input: &str) -> String {+ let bytes = input.as_bytes();+ let mut out = Vec::with_capacity(bytes.len());+ let mut ix = 0;+ while ix < bytes.len() {+ if bytes[ix] == b'%' && ix + 2 < bytes.len() {+ if let (Some(high), Some(low)) = (hex_digit(bytes[ix + 1]), hex_digit(bytes[ix + 2])) {+ out.push((high << 4) | low);+ ix += 3;+ continue;+ }+ }+ out.push(bytes[ix]);+ ix += 1;+ }+ String::from_utf8_lossy(&out).into_owned()+}++fn hex_digit(c: u8) -> Option<u8> {+ Some(match c {+ b'0'..=b'9' => c - b'0',+ b'a'..=b'f' => c - b'a' + 10,+ b'A'..=b'F' => c - b'A' + 10,+ _ => return None,+ })+}+fn attachment_from_bytes(bytes: Vec<u8>, media_type: Option<&str>) -> Option<ImageAttachment> {if bytes.is_empty() || bytes.len() as u64 > MAX_IMAGE_BYTES {return None;@@ -1057,6 +1112,14 @@ pub fn make_preview(input: &Value) -> String {mod tests {use super::*;+ #[test]+ fn percent_decode_walks_bytes() {+ assert_eq!(percent_decode("/Users/a%20b/%E4%B8%AD"), "/Users/a b/中");+ // 不成对的 `%`、后面跟多字节字符的 `%` 原样留着,不 panic+ assert_eq!(percent_decode("100%"), "100%");+ assert_eq!(percent_decode("%中%z9"), "%中%z9");+ }+/// Windows 形状的项目路径换成别家记的写法:盘符大写、Windows 上正斜杠换反斜杠;/// POSIX 路径(含远程镜像来的)原样#[test]diff --git a/crates/wake-core/src/models.rs b/crates/wake-core/src/models.rsindex 1894f06..a0018d9 100644--- a/crates/wake-core/src/models.rs+++ b/crates/wake-core/src/models.rs@@ -127,7 +127,7 @@ impl AgentId {AgentId::Omp => "Oh My Pi",AgentId::Grok => "Grok Build",AgentId::Kimi => "Kimi Code",- AgentId::Antigravity => "Antigravity CLI",+ AgentId::Antigravity => "Antigravity",AgentId::Dsh => "DeepSeek Harness",AgentId::Hermes => "Hermes Agent",AgentId::Openclaw => "OpenClaw",diff --git a/crates/wake-core/src/remote.rs b/crates/wake-core/src/remote.rsindex 9432e6b..07744c5 100644--- a/crates/wake-core/src/remote.rs+++ b/crates/wake-core/src/remote.rs@@ -156,13 +156,17 @@ pub const REMOTE_LAYOUTS: &[RemoteAgentLayout] = &[},RemoteAgentLayout {agent: AgentId::Antigravity,- // 库所在目录层(is_file 判据对未同步目录失真,目录层恒正确)- mount: ".gemini/antigravity-cli",+ // `.gemini` 层:with_custom_root 按目录名认出整套布局(会话索引 + 两个 app 数据+ // 目录下的 brain 转录),未同步时目录还不存在也不失真。brain 只拉会话目录,+ // 浏览器子代理的临时录屏不拉;凭证(oauth_creds.json 等)不在白名单里+ mount: ".gemini",sync_paths: &[".gemini/antigravity-cli/conversation_summaries.db",".gemini/antigravity-cli/conversation_summaries.db-wal",+ ".gemini/antigravity/brain",+ ".gemini/antigravity-ide/brain",],- exclude: &[],+ exclude: &["brain/tempmediaStorage"],},RemoteAgentLayout {agent: AgentId::Dsh,diff --git a/crates/wake-core/src/scanner.rs b/crates/wake-core/src/scanner.rsindex 88acb5d..3bf6ae2 100644--- a/crates/wake-core/src/scanner.rs+++ b/crates/wake-core/src/scanner.rs@@ -282,7 +282,10 @@ pub fn run_scan(events.on_progress(&fin.progress);let result = run_scan_inner(adapters, store, events, full, &mut fin.progress);- fin.progress.error = result.as_ref().err().map(|e| e.to_string());+ // 某一家枚举失败时 run_scan_inner 已把它记在 error 上、整轮照常跑完:只在整轮失败时覆盖+ if let Err(e) = &result {+ fin.progress.error = Some(e.to_string());+ }fin.graceful = true;result}@@ -364,11 +367,25 @@ fn run_scan_inner(// 下面四处同一口径,别各自 formatlet key_of =|ix: usize, r: &SessionFileRef| session_key(r.agent, adapters[ix].host(), &r.native_id);- // 第一遍:全量枚举 + 归属过滤+ // 第一遍:全量枚举 + 归属过滤。一家枚举报错(库在却读不出、目录读不了)只冻结这一家:+ // 这一轮不入队,库里归它的行原样留着(下面的删除检测跳过),错误记进进度、别家照常——+ // 一个坏库既不能截断整轮(别家的新会话跟着进不来),也不能被当成"会话全没了"let mut per_adapter: Vec<Vec<SessionFileRef>> = Vec::with_capacity(adapters.len());+ let mut frozen: Vec<usize> = Vec::new();for (ix, adapter) in adapters.iter().enumerate() {- let refs: Vec<SessionFileRef> = adapter- .list_session_files()?+ let listed = match adapter.list_session_files() {+ Ok(listed) => listed,+ Err(e) => {+ eprintln!("[scan] {}: {e:#}", adapter.agent().as_str());+ progress+ .error+ .get_or_insert_with(|| format!("{}: {e}", adapter.agent().display_name()));+ frozen.push(ix);+ per_adapter.push(Vec::new());+ continue;+ }+ };+ let refs: Vec<SessionFileRef> = listed.into_iter()// 墓碑双轨:物理路径之外还按逻辑会话(key)屏蔽——多 location 下// 删除只 trash 了胜者文件,别的 location 里的副本不得复活它@@ -505,10 +522,10 @@ fn run_scan_inner(}}- // 删除检测:库里有但磁盘没了+ // 删除检测:库里有但磁盘没了。枚举失败的那几家这一轮不知道在不在,归它们的行不动let mut pruned = false;for (path, (_, _, key)) in &known {- if !seen_paths.contains(path) {+ if !seen_paths.contains(path) && !owner_of(path).is_some_and(|ix| frozen.contains(&ix)) {let _ = store.remove_session(key, false);pruned = true;}diff --git a/crates/wake-core/tests/adapter_contracts.rs b/crates/wake-core/tests/adapter_contracts.rsindex f0fac56..e013208 100644--- a/crates/wake-core/tests/adapter_contracts.rs+++ b/crates/wake-core/tests/adapter_contracts.rs@@ -1984,6 +1984,200 @@ fn antigravity_parse_contract() {assert!(s.units[0].text.contains("QR overlay polish"));}+/// 新版本写下的明文转录(PR #52 整理的格式,合成 fixture):转录与索引卡片都如实列出,+/// 同一个 id 由 dedup_rank 让转录胜出;索引里的子会话两种都不列+#[test]+fn antigravity_transcripts_replace_index_cards() {+ use common::AgIndexRow;+ setup();+ let tmp = tempfile::tempdir().unwrap();+ let gemini = tmp.path().join(".gemini");+ let db = common::build_antigravity_index(+ &gemini,+ &[+ AgIndexRow {+ id: "ag-1",+ preview: "Dashboard buttons",+ workspace: "/Users/tester/Github/dashboard",+ app: "antigravity-ide",+ ..Default::default()+ },+ AgIndexRow {+ id: "ag-2",+ preview: "Card only conversation",+ workspace: "/Users/tester/Github/wakefx",+ app: "antigravity",+ ..Default::default()+ },+ AgIndexRow {+ id: "ag-3",+ preview: "Spawned helper",+ workspace: "/Users/tester/Github/dashboard",+ parent: "ag-1",+ app: "antigravity-ide",+ },+ ],+ );+ let ide = gemini.join("antigravity-ide").join("brain");+ let desktop = gemini.join("antigravity").join("brain");+ let asked = ms("2026-08-30T02:11:10Z");+ // 第一张贴图在第一轮之后几秒;第二张离哪一轮都差出两个小时,不挂+ let t1 =+ common::stage_antigravity_transcript(&ide, "ag-1", &[asked + 3_000, asked + 2 * 3_600_000]);+ // 指到会话目录外面的贴图(远程镜像原样保留符号链接)不读+ #[cfg(unix)]+ {+ let outside = tmp.path().join("outside.png");+ fs::write(&outside, b"\x89PNG\r\n\x1a\noutside").unwrap();+ let uploads = ide.join("ag-1").join(".user_uploaded");+ std::os::unix::fs::symlink(+ &outside,+ uploads.join(format!("media_{}.png", asked + 5_000)),+ )+ .unwrap();+ }+ let t3 = common::stage_antigravity_transcript(&ide, "ag-3", &[]);+ let t4 = common::stage_antigravity_transcript(&desktop, "ag-4", &[]);+ // brain 根下不是会话的目录(浏览器子代理的临时录屏)+ fs::create_dir_all(desktop.join("tempmediaStorage")).unwrap();++ let adapter = AntigravityAdapter::new().with_custom_root(gemini.clone());+ assert_eq!(+ adapter.data_roots(),+ vec![db.clone(), desktop.clone(), ide.clone()]+ );+ let mut refs = adapter.list_session_files().expect("antigravity list");+ refs.sort_by(|a, b| (&a.native_id, &a.file_path).cmp(&(&b.native_id, &b.file_path)));+ let card = |id: &str| format!("{}#{id}", db.display());+ let listed: Vec<(&str, String)> = refs+ .iter()+ .map(|r| (r.native_id.as_str(), r.file_path.clone()))+ .collect();+ assert_eq!(+ listed,+ vec![+ ("ag-1", card("ag-1")),+ ("ag-1", t1.to_string_lossy().to_string()),+ ("ag-2", card("ag-2")),+ ("ag-4", t4.to_string_lossy().to_string()),+ ]+ );+ // 同一个 id 的卡片与转录同时出现时,转录胜出+ assert_eq!(adapter.dedup_rank(&refs[1].file_path), 0);+ assert_eq!(adapter.dedup_rank(&refs[0].file_path), 1);++ let r = &refs[1];+ let s = adapter.parse_session(r).expect("ag-1 parse_session");+ let t = adapter.parse_transcript(r).expect("ag-1 parse_transcript");+ assert_eq!(s.meta.key, "antigravity:ag-1");+ // 索引没起标题(title 列空),第一轮请求压过 preview+ assert_eq!(s.meta.title, "Fix the button layout on the dashboard");+ assert_eq!(s.meta.project_path, "/Users/tester/Github/dashboard");+ assert_eq!(s.meta.source.as_deref(), Some("IDE"));+ assert_eq!(s.meta.model.as_deref(), Some("Gemini 3.7 Flash (High)"));+ assert_eq!(s.meta.created_at, asked);+ assert_eq!(s.meta.updated_at, ms("2026-08-30T02:12:06Z"));+ assert_eq!(t.unknown_line_count, 1);+ assert_eq!(+ roles_kinds(&t.mainline),+ vec![+ (Role::User, MessageKind::Text),+ (Role::Assistant, MessageKind::Text),+ (Role::System, MessageKind::CompactSummary),+ (Role::User, MessageKind::Text),+ (Role::Assistant, MessageKind::Text),+ ]+ );+ let answer = &t.mainline[1];+ assert!(answer.text.contains("updated the button alignment"));+ assert!(answer+ .thinking+ .as_deref()+ .is_some_and(|thinking| thinking.contains("find where the buttons")));+ // 一轮里的两步并成一条;工具结果按调用顺序回填+ let tools: Vec<(&str, &str)> = answer+ .tool_calls+ .iter()+ .map(|call| (call.name.as_str(), call.output.as_deref().unwrap_or("")))+ .collect();+ assert_eq!(+ tools,+ vec![+ ("view_file", "pub fn render_buttons() {}"),+ ("grep_search", "src/ui.rs:12: pub fn render_buttons() {}"),+ ("run_command", "test result: ok. 5 passed"),+ ]+ );+ assert_eq!(answer.tool_calls[0].input_preview, "View ui.rs");+ // 装在 JSON 字符串里的参数也解开+ assert_eq!(answer.tool_calls[1].input_preview, "render_buttons");+ assert!(answer.tool_calls[1]+ .input+ .as_deref()+ .is_some_and(|input| input.contains("\"SearchPath\"")));+ // 贴图只在详情页解码,挂在正文末尾+ let asked_msg = &t.mainline[0];+ assert_eq!(asked_msg.images.len(), 1);+ assert_eq!(asked_msg.images[0].media_type, "image/png");+ assert_eq!(asked_msg.images[0].text_offset, asked_msg.text.len());+ assert!(t.mainline[3].images.is_empty());+ assert_seq_contract(adapter.as_ref(), r);++ // 卡片:preview 作标题,正文是加密说明;同一会话转录读不出时就是它+ let card1 = adapter.parse_transcript(&refs[0]).expect("ag-1 card");+ assert_eq!(card1.meta.title, "Dashboard buttons");+ assert_eq!(card1.meta.source.as_deref(), Some("IDE"));+ let card2 = adapter.parse_transcript(&refs[2]).expect("ag-2 card");+ assert_eq!(card2.meta.title, "Card only conversation");+ assert_eq!(card2.meta.source, None);+ assert!(card2.mainline[0].text.contains("encrypted"));++ // 没进索引的会话:工作区取工具的工作目录,桌面端不挂 via+ let s4 = adapter.parse_session(&refs[3]).expect("ag-4 parse_session");+ assert_eq!(s4.meta.project_path, "/Users/tester/Github/wakefx");+ assert_eq!(s4.meta.source, None);+ assert_eq!(s4.meta.title, "Fix the button layout on the dashboard");++ // watcher 入口与列表同一个判据(含索引那一行算进的指纹)+ let watched = adapter.file_ref(&t1).expect("ag-1 转录");+ assert_eq!(+ (watched.native_id.as_str(), watched.mtime_ms, watched.size),+ ("ag-1", r.mtime_ms, r.size)+ );+ assert!(adapter.file_ref(&t3).is_none(), "子会话不列");+ // 转录会话整个目录进废纸篓,卡片只记墓碑+ assert_eq!(+ adapter.session_paths(&s.meta),+ vec![ide.join("ag-1").to_string_lossy().to_string()]+ );+ assert_eq!(adapter.cleanup_paths(&card2.meta), None);++ // 一条消息都读不出的转录算解析失败(scanner 据此退回同一会话的卡片)+ let broken = common::stage_antigravity_transcript(&desktop, "ag-5", &[]);+ fs::write(&broken, "{\"type\":\"USER_INPUT\",\"content\":\"trunc").unwrap();+ let broken_ref = adapter.file_ref(&broken).expect("ag-5 转录");+ assert!(adapter.parse_session(&broken_ref).is_err());++ // 索引库删掉了:卡片不再列,不交回上一次读到的+ fs::remove_file(&db).unwrap();+ let after: Vec<String> = adapter+ .list_session_files()+ .expect("antigravity list without index")+ .into_iter()+ .map(|r| r.file_path)+ .collect();+ assert!(+ after.iter().all(|path| path.ends_with("transcript.jsonl")),+ "{after:?}"+ );++ // 自定义 location 的其余形状:单个 brain、app 数据目录、索引所在目录+ let roots = |dir: PathBuf| AntigravityAdapter::new().with_custom_root(dir).data_roots();+ assert_eq!(roots(ide.clone()), vec![ide.clone()]);+ assert_eq!(roots(gemini.join("antigravity-ide")), vec![ide.clone()]);+ assert_eq!(roots(gemini.join("antigravity-cli")), vec![db.clone()]);+}+// ---------------------------------------------------------------- seq 契约/// 跨文件不变量 1:FTS 单元的 seq 必须能在详情页 mainline 中找到同号消息,diff --git a/crates/wake-core/tests/common/mod.rs b/crates/wake-core/tests/common/mod.rsindex eceb7fc..524eb1b 100644--- a/crates/wake-core/tests/common/mod.rs+++ b/crates/wake-core/tests/common/mod.rs@@ -830,21 +830,27 @@ pub fn build_opencode_next_db(path: &Path) {.expect("populate opencode next fixture db");}-/// Antigravity `conversation_summaries.db` 最小同构库:标题在 preview 列-/// (title 列常空);ag-0002 是子会话(parent 非空),必须被过滤。+/// Antigravity 会话索引表,老库形态(新版多一列 `app_data_dir`,见 `build_antigravity_index`)+const ANTIGRAVITY_INDEX_TABLE: &str = r#"+ CREATE TABLE conversation_summaries (+ conversation_id text, title text NOT NULL DEFAULT "",+ preview text NOT NULL DEFAULT "", step_count integer NOT NULL DEFAULT 0,+ last_modified_time datetime NOT NULL, workspace_uris text NOT NULL,+ parent_conversation_id text NOT NULL DEFAULT "",+ nesting_depth integer NOT NULL DEFAULT 0,+ last_user_input_time datetime NOT NULL,+ PRIMARY KEY (conversation_id)+ );+"#;++/// Antigravity `conversation_summaries.db` 最小同构库(老库,没有 `app_data_dir`):标题在+/// preview 列(title 列常空);ag-0002 是子会话(parent 非空),必须被过滤。pub fn build_antigravity_db(path: &Path) {let conn = rusqlite::Connection::open(path).expect("create antigravity fixture db");+ conn.execute_batch(ANTIGRAVITY_INDEX_TABLE)+ .expect("create antigravity fixture table");conn.execute_batch(r#"- CREATE TABLE conversation_summaries (- conversation_id text, title text NOT NULL DEFAULT "",- preview text NOT NULL DEFAULT "", step_count integer NOT NULL DEFAULT 0,- last_modified_time datetime NOT NULL, workspace_uris text NOT NULL,- parent_conversation_id text NOT NULL DEFAULT "",- nesting_depth integer NOT NULL DEFAULT 0,- last_user_input_time datetime NOT NULL,- PRIMARY KEY (conversation_id)- );INSERT INTO conversation_summaries(conversation_id, title, preview, step_count, last_modified_time,workspace_uris, parent_conversation_id, nesting_depth, last_user_input_time)@@ -858,6 +864,73 @@ pub fn build_antigravity_db(path: &Path) {.expect("populate antigravity fixture db");}+/// 新版 Antigravity 会话索引里的一行(`build_antigravity_index` 用)+#[derive(Clone, Copy, Default)]+pub struct AgIndexRow {+ pub id: &'static str,+ pub preview: &'static str,+ pub workspace: &'static str,+ /// 父会话 id;非空 = 子会话,同时记 nesting_depth = 1+ pub parent: &'static str,+ /// 会话所在的 app 数据目录名(`antigravity` / `antigravity-ide`)+ pub app: &'static str,+}++/// 新版的会话索引(多一列 `app_data_dir`)建在 `<gemini>/antigravity-cli/` 下,返回库路径+pub fn build_antigravity_index(gemini: &Path, rows: &[AgIndexRow]) -> PathBuf {+ let dir = gemini.join("antigravity-cli");+ fs::create_dir_all(&dir).expect("mkdir antigravity-cli");+ let path = dir.join("conversation_summaries.db");+ let conn = rusqlite::Connection::open(&path).expect("create antigravity index");+ conn.execute_batch(ANTIGRAVITY_INDEX_TABLE)+ .expect("create antigravity index table");+ conn.execute_batch(+ r#"ALTER TABLE conversation_summaries ADD COLUMN app_data_dir text NOT NULL DEFAULT """#,+ )+ .expect("add app_data_dir");+ for row in rows {+ conn.execute(+ "INSERT INTO conversation_summaries (conversation_id, preview, step_count,+ last_modified_time, workspace_uris, parent_conversation_id, nesting_depth,+ last_user_input_time, app_data_dir)+ VALUES (?1, ?2, 4, '2026-08-30 02:12:05.000000+00:00', ?3, ?4, ?5,+ '2026-08-30 02:12:00.000000+00:00', ?6)",+ rusqlite::params![+ row.id,+ row.preview,+ format!("[\"file://{}\"]", row.workspace),+ row.parent,+ i64::from(!row.parent.is_empty()),+ row.app+ ],+ )+ .expect("insert antigravity index row");+ }+ path+}++/// 一条 Antigravity brain 转录(合成 fixture,格式见 PR #52)+ 若干用户贴图+/// (`.user_uploaded/media_<毫秒>.png`),返回转录路径+pub fn stage_antigravity_transcript(brain: &Path, id: &str, uploads: &[i64]) -> PathBuf {+ let session = brain.join(id);+ let logs = session.join(".system_generated").join("logs");+ fs::create_dir_all(&logs).expect("mkdir antigravity transcript dir");+ let transcript = logs.join("transcript.jsonl");+ fs::copy(fixture("antigravity/transcript.jsonl"), &transcript).expect("copy transcript");+ if !uploads.is_empty() {+ let dir = session.join(".user_uploaded");+ fs::create_dir_all(&dir).expect("mkdir .user_uploaded");+ for ms in uploads {+ fs::write(+ dir.join(format!("media_{ms}.png")),+ b"\x89PNG\r\n\x1a\nfixture",+ )+ .expect("write upload");+ }+ }+ transcript+}+/// Cursor IDE `state.vscdb` 最小同构库:VS Code 的两张 KV 表 + 2026 新增的/// composerHeaders 索引表。/// - `cide-0001`:正常会话。气泡顺序只在 `fullConversationHeadersOnly` 里,diff --git a/crates/wake-core/tests/fixtures/antigravity/transcript.jsonl b/crates/wake-core/tests/fixtures/antigravity/transcript.jsonlnew file mode 100644index 0000000..dfcfb8c--- /dev/null+++ b/crates/wake-core/tests/fixtures/antigravity/transcript.jsonl@@ -0,0 +1,11 @@+{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-08-30T02:11:10Z","content":"<USER_REQUEST>\nFix the button layout on the dashboard\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\nThe current local time is: 2026-08-30T10:11:10+08:00.\nActive Document: /Users/tester/Github/wakefx/src/ui.rs (LANGUAGE_RUST)\n</ADDITIONAL_METADATA>\n<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to Gemini 3.7 Flash (High). No need to respond.\n</USER_SETTINGS_CHANGE>"}+{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-08-30T02:11:12Z","thinking":"Need to view ui.rs and find where the buttons are laid out.","tool_calls":[{"name":"view_file","args":{"AbsolutePath":"/Users/tester/Github/wakefx/src/ui.rs","toolSummary":"View ui.rs"}},{"name":"grep_search","args":"{\"Query\":\"render_buttons\",\"SearchPath\":\"/Users/tester/Github/wakefx\"}"}]}+{"step_index":2,"source":"MODEL","type":"VIEW_FILE","status":"DONE","created_at":"2026-08-30T02:11:14Z","content":"pub fn render_buttons() {}"}+{"step_index":3,"source":"MODEL","type":"GREP_SEARCH","status":"DONE","created_at":"2026-08-30T02:11:15Z","content":"src/ui.rs:12: pub fn render_buttons() {}"}+{"step_index":4,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-08-30T02:11:16Z","content":"I have examined the layout and updated the button alignment.","tool_calls":[{"name":"run_command","args":{"CommandLine":"cargo test","Cwd":"/Users/tester/Github/wakefx","toolSummary":"Run cargo test"}}]}+{"step_index":5,"source":"MODEL","type":"RUN_COMMAND","status":"DONE","created_at":"2026-08-30T02:11:18Z","content":"test result: ok. 5 passed"}+{"step_index":6,"source":"SYSTEM","type":"CHECKPOINT","status":"DONE","created_at":"2026-08-30T02:11:20Z","content":"# Resuming from a compaction"}+{"step_index":7,"source":"SYSTEM","type":"KNOWLEDGE_ARTIFACTS","status":"DONE","created_at":"2026-08-30T02:11:21Z","content":"(knowledge items)"}+{"step_index":8,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-08-30T02:12:00Z","content":"<USER_REQUEST>\nLooks good, please commit the changes\n</USER_REQUEST>"}+{"step_index":9,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-08-30T02:12:05Z","content":"Committed successfully."}+{"step_index":10,"source":"MODEL","type":"SOMETHING_NEW","status":"DONE","created_at":"2026-08-30T02:12:06Z"}diff --git a/crates/wake-core/tests/scanner_finale.rs b/crates/wake-core/tests/scanner_finale.rsindex 4dafde9..8dc4e5b 100644--- a/crates/wake-core/tests/scanner_finale.rs+++ b/crates/wake-core/tests/scanner_finale.rs@@ -205,6 +205,71 @@ fn finale_fires_when_adapter_fails() {assert_terminal_event(&rec.0.lock().unwrap(), "adapter 枚举失败");}+/// 一家枚举失败(库在却读不出)只冻结这一家:它在库里的行原样留着,别家照常入库、照常+/// 删除检测,整轮跑完;失败记进进度的 error,界面照常提示+#[test]+fn one_failing_adapter_freezes_only_its_own_rows() {+ let dir = tempfile::tempdir().unwrap();+ let store = temp_store(dir.path());+ let adapters: Vec<Box<dyn AgentAdapter>> = vec![+ Box::new(seed(+ AgentId::Grok,+ "/tmp/freeze-a",+ "/tmp/freeze-a/a.jsonl",+ "a",+ 10,+ )),+ Box::new(seed(+ AgentId::Devin,+ "/tmp/freeze-b",+ "/tmp/freeze-b/b.jsonl",+ "b",+ 10,+ )),+ ];+ run_scan(&adapters, &store, &Recorder::new(), true).unwrap();+ assert!(store.get_session("devin:b").unwrap().is_some());++ let mut unreadable = seed(+ AgentId::Devin,+ "/tmp/freeze-b",+ "/tmp/freeze-b/b.jsonl",+ "b",+ 10,+ );+ unreadable.fail_list = true;+ let adapters: Vec<Box<dyn AgentAdapter>> = vec![+ Box::new(seed(+ AgentId::Grok,+ "/tmp/freeze-a",+ "/tmp/freeze-a/a2.jsonl",+ "a2",+ 20,+ )),+ Box::new(unreadable),+ ];+ let rec = Recorder::new();+ run_scan(&adapters, &store, &rec, false).expect("一家读不出不截断整轮");+ assert!(+ store.get_session("devin:b").unwrap().is_some(),+ "读不出的那家行原样留着"+ );+ assert!(+ store.get_session("grok:a2").unwrap().is_some(),+ "别家照常入库"+ );+ assert!(+ store.get_session("grok:a").unwrap().is_none(),+ "别家的删除检测照常"+ );+ let events = rec.0.lock().unwrap();+ assert_terminal_event(&events, "一家枚举失败");+ assert!(events+ .last()+ .and_then(|p| p.error.as_deref())+ .is_some_and(|e| e.contains("simulated unreadable index")));+}+#[test]fn parent_links_from_multiple_locations_are_merged_by_winning_file() {let dir = tempfile::tempdir().unwrap();@@ -584,6 +649,8 @@ struct SeedAdapter {meta: SessionMeta,/// 模拟截断/损坏副本:解析一律报错(副本回退测试用)fail_parse: bool,+ /// 模拟库在却读不出:枚举报错+ fail_list: bool,/// 模拟 codex 的 state 改名:quick 给出的 key 与文件 native key 不同,/// merge 时 quick key 压过 parsed(codex 同款优先级)quick_key: Option<String>,@@ -602,6 +669,9 @@ impl AgentAdapter for SeedAdapter {self.rank}fn list_session_files(&self) -> Result<Vec<SessionFileRef>> {+ if self.fail_list {+ bail!("simulated unreadable index")+ }Ok(vec![self.r.clone()])}fn file_ref(&self, path: &Path) -> Option<SessionFileRef> {@@ -655,6 +725,7 @@ impl AgentAdapter for SeedAdapter {r: self.r.clone(),meta: self.meta.clone(),fail_parse: self.fail_parse,+ fail_list: self.fail_list,quick_key: self.quick_key.clone(),manages_links: self.manages_links,parent_links: self.parent_links.clone(),@@ -1060,6 +1131,7 @@ fn seed(agent: AgentId, root: &str, path: &str, native_id: &str, mtime: i64) ->pinned: false,},fail_parse: false,+ fail_list: false,quick_key: None,manages_links: false,parent_links: Vec::new(),@@ -1108,6 +1180,7 @@ fn tombstoned_session_does_not_resurrect_on_rescan() {r,meta: meta.clone(),fail_parse: false,+ fail_list: false,quick_key: None,manages_links: false,parent_links: Vec::new(),@@ -1282,6 +1355,78 @@ fn dsh_newer_generation_takes_over_an_indexed_older_one() {);}+/// Antigravity:索引里先只有卡片,明文转录后来才写出来——同一个 key 由转录接替+/// (`dedup_rank`,转录的 mtime 与卡片的时间毫不相干),增量与全量两条写路径都是;+/// 转录目录没了、索引还在,卡片回来。库里始终只有一行+#[test]+fn antigravity_transcript_takes_over_its_index_card() {+ use wake_core::adapters::antigravity::AntigravityAdapter;+ const KEY: &str = "antigravity:ag-1";+ let home = tempfile::tempdir().unwrap();+ let gemini = home.path().join(".gemini");+ common::build_antigravity_index(+ &gemini,+ &[common::AgIndexRow {+ id: "ag-1",+ preview: "Dashboard buttons",+ workspace: "/Users/tester/Github/dashboard",+ app: "antigravity-ide",+ ..Default::default()+ }],+ );+ let adapters: Vec<Box<dyn AgentAdapter>> =+ vec![AntigravityAdapter::new().with_custom_root(gemini.clone())];+ let dir = tempfile::tempdir().unwrap();+ let store = temp_store(dir.path());+ let rows = || {+ store+ .list_sessions(&SessionFilter {+ limit: 10,+ ..Default::default()+ })+ .unwrap()+ .1+ };+ run_scan(&adapters, &store, &Recorder::new(), true).unwrap();+ let s = store.get_session(KEY).unwrap().expect("卡片入库");+ assert!(s.file_path.ends_with("#ag-1"));+ assert_eq!(s.title, "Dashboard buttons");++ let brain = gemini.join("antigravity-ide").join("brain");+ let transcript = common::stage_antigravity_transcript(&brain, "ag-1", &[]);+ // 转录写坏了(一条消息都读不出):卡片接着顶着,不被空会话顶掉+ let good = std::fs::read(&transcript).unwrap();+ std::fs::write(&transcript, "{\"type\":\"USER_INPUT\",\"content\":\"trunc").unwrap();+ run_scan(&adapters, &store, &Recorder::new(), false).unwrap();+ let s = store.get_session(KEY).unwrap().expect("会话仍在库");+ assert!(s.file_path.ends_with("#ag-1"), "坏转录退回卡片");+ assert_eq!(rows(), 1);++ std::fs::write(&transcript, good).unwrap();+ let incoming = adapters[0].file_ref(&transcript).expect("转录是这个会话的");+ scan_files(&adapters, &store, &Recorder::new(), vec![incoming]);+ let s = store.get_session(KEY).unwrap().expect("会话仍在库");+ assert_eq!(+ s.file_path,+ transcript.to_string_lossy(),+ "增量写入由转录接替"+ );+ assert_eq!(s.title, "Fix the button layout on the dashboard");+ assert_eq!(s.source.as_deref(), Some("IDE"));+ assert_eq!(rows(), 1);++ run_scan(&adapters, &store, &Recorder::new(), false).unwrap();+ let s = store.get_session(KEY).unwrap().unwrap();+ assert_eq!(s.file_path, transcript.to_string_lossy());+ assert_eq!(rows(), 1);++ std::fs::remove_dir_all(brain.join("ag-1")).unwrap();+ run_scan(&adapters, &store, &Recorder::new(), false).unwrap();+ let s = store.get_session(KEY).unwrap().expect("索引还在,卡片回来");+ assert!(s.file_path.ends_with("#ag-1"));+ assert_eq!(rows(), 1);+}+/// Cursor 两源端到端:转录带正文的会话固定由 CLI 源胜出(它有 slug 可反推/// 项目),哪怕 IDE 库里那份 lastUpdatedAt 更新、roster 里 IDE 实例排在前面;/// 转录只剩 turn_ended 空壳的会话由 IDE 库副本胜出。按 mtime 裁决的话胜负随diff --git a/docs/mcp.md b/docs/mcp.mdindex 41aa17d..da5727e 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -109,7 +109,7 @@ Everything above happens locally; Wake itself does not change and the other agen- No write tools: nothing can delete, star, rename or resume a session. Resuming stays in Wake.- Subagent transcripts that live inside a session (Claude Code sidechains, Cursor subagents) are not merged into the main transcript: `wake_get_session` lists their ids at the end and reads one when it is passed as `subagent`. Sub-agents that their agent records as sessions of their own (Codex `spawn_agent`, Grok) are folded under their parent in `wake_list_sessions`; the parent's `wake_get_session` output lists them by key, and each reads like any other session.-- Antigravity sessions are metadata only — their transcripts are encrypted on disk, so an agent gets the same preview card Wake shows.+- Antigravity conversations with no plain-text transcript on disk (older versions store the body encrypted) are metadata only, so an agent gets the same preview card Wake shows.- Archived Codex sessions appear in search results but not in `wake_list_sessions` or `wake_list_projects`.- Codex's own background threads — the guardian auto-review, `/review`, compaction and memory consolidation that Codex writes into the same `sessions` directory — are not indexed at all: they never show up in search, lists or project counts, and there is no key to read them by. Threads started by `spawn_agent` are the exception: they are work the user asked for, so they are indexed under the session that spawned them, titled with the task name. The turns Codex copies from the parent when it forks a sub-agent are dropped, so the parent's own conversation is only indexed once. After upgrading, rows an older Wake had indexed disappear once Wake itself has rescanned (launch it, or press Refresh); `wake-mcp` only reads the index and never rescans.