@orbit-labs-ai/pi-antigravity 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CHANGELOG.zh-CN.md +36 -0
  3. package/LICENSE +22 -0
  4. package/README.md +138 -2
  5. package/README.zh-CN.md +139 -0
  6. package/docs/upstream.md +49 -0
  7. package/extensions/index.ts +2418 -0
  8. package/package.json +73 -4
  9. package/src/acp/connection.ts +662 -0
  10. package/src/acp/driver.ts +1115 -0
  11. package/src/acp/events.ts +324 -0
  12. package/src/acp/history-sync.ts +221 -0
  13. package/src/acp/home.ts +144 -0
  14. package/src/acp/jsonrpc.ts +243 -0
  15. package/src/acp/setup.ts +108 -0
  16. package/src/acp/usage-estimate.ts +61 -0
  17. package/src/agents.ts +64 -0
  18. package/src/agy-install.ts +93 -0
  19. package/src/agy-paths.ts +30 -0
  20. package/src/agy-setup.ts +81 -0
  21. package/src/agy-version.ts +292 -0
  22. package/src/approval-detect.ts +161 -0
  23. package/src/approval-gate.ts +274 -0
  24. package/src/approval-hook.ts +326 -0
  25. package/src/artifacts-ui.ts +88 -0
  26. package/src/artifacts.ts +144 -0
  27. package/src/ask-tool.ts +1247 -0
  28. package/src/atomic-write.ts +42 -0
  29. package/src/background-watch.ts +226 -0
  30. package/src/bridge-catalog.ts +282 -0
  31. package/src/compaction-preempt.ts +69 -0
  32. package/src/config.ts +708 -0
  33. package/src/daily-log.ts +205 -0
  34. package/src/dialog-lock.ts +48 -0
  35. package/src/diff-render.ts +207 -0
  36. package/src/driver-types.ts +202 -0
  37. package/src/driver.ts +904 -0
  38. package/src/engine-picker.ts +213 -0
  39. package/src/frame-guard.ts +38 -0
  40. package/src/handoff-toast.ts +21 -0
  41. package/src/history-projection.ts +210 -0
  42. package/src/history-sync.ts +311 -0
  43. package/src/mcp-registration.ts +380 -0
  44. package/src/mcp-server.ts +648 -0
  45. package/src/models.ts +402 -0
  46. package/src/native-fileops.ts +40 -0
  47. package/src/native-tools.ts +108 -0
  48. package/src/parked-turn.ts +125 -0
  49. package/src/patch-cleanup.ts +518 -0
  50. package/src/poll-fold.ts +55 -0
  51. package/src/prompt-images.ts +93 -0
  52. package/src/provider.ts +3303 -0
  53. package/src/queued-messages.ts +150 -0
  54. package/src/quota-notice.ts +40 -0
  55. package/src/redact.ts +27 -0
  56. package/src/runtime.ts +329 -0
  57. package/src/sessions.ts +220 -0
  58. package/src/skills.ts +207 -0
  59. package/src/stream-events.ts +161 -0
  60. package/src/stream-sanitizer.ts +180 -0
  61. package/src/subagent-roster.ts +244 -0
  62. package/src/sysprompt-agent.ts +176 -0
  63. package/src/tasks-ui.ts +91 -0
  64. package/src/tasks.ts +174 -0
  65. package/src/usage.ts +174 -0
  66. package/src/version.ts +32 -0
  67. package/src/web-tools.ts +320 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ English | [简体中文](./CHANGELOG.zh-CN.md)
4
+
5
+ ## 0.0.2 — 2026-12-02
6
+
7
+ ### Added
8
+
9
+ - `npm run link-host-types` runs the existing host-type linker, so an editor or language server resolves the Pi SDK through `tsconfig.json`.
10
+
11
+ ### Fixed
12
+
13
+ - Move three argument helpers of the ACP activity renderer (`callIdArg`, `acpFileArg`, `acpQueryArg`) out of the middle of its `switch` to module level. They had been declared after a `return` inside the `tool_start` case; behavior is unchanged, and the `tool_start` case now ends where it returns.
14
+
15
+ ### Changed
16
+
17
+ - Clear the remaining lint findings without changing behavior: loops that cancel or settle entries walk a named snapshot of the collection, an unused generation counter and an unused file flag are removed, a redundant empty-list check is dropped, and the shadow tool's parameters are typed `unknown`.
18
+
19
+ ## 0.0.1 — 2026-12-02
20
+
21
+ Initial Orbit Labs release of `@orbit-labs-ai/pi-antigravity`, forked from `@estebanforge/pi-antigravity-bridge@1.17.2` (commit `28b0a52`; see [docs/upstream.md](docs/upstream.md)).
22
+
23
+ ### Added
24
+
25
+ - Real-time mid-turn steering delivery: injects Pi steering prompts (text and attached images) directly into resolving MCP bridge tool results while a parked `agy` turn is live, so the model pivots immediately and produces one unified final response.
26
+ - Pending mid-turn steering channel for escalated tool polls (`bridge_poll_result`) and bridge-local tool responses (`bridge_tool_info`, `activate_skill`, `escalated-ack`), with lossless post-outcome fallback for approval-only parks.
27
+ - Race-free, non-destructive one-shot migration (atomic temp copy + hard-link create) and read-only fallback from legacy `~/.pi/agent/antigravity-bridge/` to `~/.pi/agent/pi-antigravity/`, plus legacy backup discovery in `/agy patch-cleanup`.
28
+ - Orbit Labs package identity (`@orbit-labs-ai/pi-antigravity`), dynamic manifest version reporting in MCP server metadata and `/agy doctor`, updated Pi Antigravity UI titles, scoped log directory (`extensions-data/orbit-labs-ai/pi-antigravity`), portable `tsconfig.json`, bilingual documentation, upstream tracking record, strict `scripts/typecheck.mjs`, and 15 offline steering/runtime/package tests.
29
+
30
+ ### Fixed
31
+
32
+ - Deduplicated dead-turn continuations that carry both stranded escalated results and trailing steered user messages.
33
+ - Cleared `steerCursors` on session compaction and dropped stale cursors after transcript shrinks (`/tree`, `/fork`, `/compact`).
34
+ - Hardened `writeJsonAtomic` with per-write random temp suffixes to prevent concurrent same-PID temp collisions, and unified `writeModelsCache` onto `writeJsonAtomic`.
35
+ - Fixed `scripts/typecheck.mjs` host resolution for packages whose `exports` omit `./package.json` (such as `typebox`).
36
+ - Resolved all strict TypeScript and `pi-lens` errors and warnings across `src/`, `extensions/`, tests, and documentation (including safe TypeBox schema cloning, atomic staged MCP config writes, typed realm branding without `Reflect.get`, dead-code cleanup, and eliminating unsafe non-null assertions, empty catch blocks, and bare `console.*` calls).
@@ -0,0 +1,36 @@
1
+ # 更新日志
2
+
3
+ [English](./CHANGELOG.md) | 简体中文
4
+
5
+ ## 0.0.2 — 2026-12-02
6
+
7
+ ### 新增
8
+
9
+ - 新增 `npm run link-host-types`,调用已有的宿主类型链接脚本,让编辑器或语言服务器通过 `tsconfig.json` 解析 Pi SDK。
10
+
11
+ ### 修复
12
+
13
+ - 把 ACP 活动渲染器 `switch` 中间的三个参数辅助函数(`callIdArg`、`acpFileArg`、`acpQueryArg`)移到模块层级。它们此前声明在 `tool_start` 分支的 `return` 之后;行为不变,`tool_start` 分支现在在返回处结束。
14
+
15
+ ### 变更
16
+
17
+ - 清除剩余静态检查问题,行为不变:会取消或结算条目的循环改为遍历集合的具名快照,删除未使用的代数计数器和文件标志,去掉多余的空列表判断,影子工具的参数类型改为 `unknown`。
18
+
19
+ ## 0.0.1 — 2026-12-02
20
+
21
+ `@orbit-labs-ai/pi-antigravity` 首个 Orbit Labs 独立版本,基于 `@estebanforge/pi-antigravity-bridge@1.17.2`(提交 `28b0a52`;详见 [docs/upstream.md](docs/upstream.md)(英文))。
22
+
23
+ ### 新增
24
+
25
+ - **实时回合中 steering 注入**:在 parked 的 `agy` 回合存活期间,将 Pi 插入的 steering 消息(文本与附带图片)直接随正在返回的 MCP 桥接工具结果注入,使模型从下一步起立即调整策略并生成单一完整回答。
26
+ - **慢工具轮询与桥接本地通道投递**:支持在 `bridge_poll_result`、`bridge_tool_info`、`activate_skill` 与升级回执返回时投递待发送的回合中 steering;仅包含审批门禁的回合在未触发后续桥接调用时无损回落至回合结束补发。
27
+ - **旧版配置原子无损迁移**:首次加载时通过临时文件与原子硬链接从 `~/.pi/agent/antigravity-bridge/` 单向复制配置、模型缓存与会话绑定至 `~/.pi/agent/pi-antigravity/`,避免并发启动覆盖,并在迁移前提供只读兜底读取;`/agy patch-cleanup` 同时兼容发现旧目录备份。
28
+ - **Orbit Labs 独立包与验证体系**:更名为 `@orbit-labs-ai/pi-antigravity`,MCP 服务器与 `/agy doctor` 动态读取 `package.json` 版本,统一 Pi Antigravity 界面标题,独立日志目录 `extensions-data/orbit-labs-ai/pi-antigravity`,新增可移植 `tsconfig.json`、完整中英文文档、上游选择性跟踪记录、严格类型检查脚本 `scripts/typecheck.mjs` 与 15 项离线单元/运行时/打包测试。
29
+
30
+ ### 修复
31
+
32
+ - 修复 dead-turn 同时包含滞后工具结果与末尾 steering 消息时可能重复发送 steering 的问题。
33
+ - 在 `session_compact` 时清理 `steerCursors`,并在 `/tree`、`/fork`、`/compact` 缩短会话后自动丢弃过期游标。
34
+ - 为 `writeJsonAtomic` 增加随机临时文件后缀以防止同进程并发写入冲突,并将 `writeModelsCache` 统一迁移至 `writeJsonAtomic`。
35
+ - 修复 `scripts/typecheck.mjs` 对未导出 `./package.json` 的宿主依赖(如 `typebox`)的路径解析。
36
+ - 全面清零 `src/`、`extensions/`、测试与文档中的严格 TypeScript 及 `pi-lens` error/warning(包括 TypeBox schema 安全克隆、隔离目录原子写入、无 `Reflect.get` 的类型化 realm 标记、清理死代码与空 catch,以及消除非空断言与杂散 `console.*` 调用)。
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Orbit Labs
4
+ Copyright (c) 2026 EstebanForge (upstream @estebanforge/pi-antigravity-bridge@1.17.2)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,139 @@
1
- # Temporary Holding Version
1
+ # Pi Antigravity
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.19-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
7
+ [![Pi](https://img.shields.io/badge/host-Pi%201.5%2B-8A2BE2)](#requirements)
8
+
9
+ **Orbit Labs Antigravity provider for Pi with real-time mid-turn steering delivery, codemode/MCP tool bridging, and full `/model` picker support.**
10
+
11
+ Pi Antigravity (`@orbit-labs-ai/pi-antigravity`) registers Antigravity (`agy`) models under the `antigravity/*` provider in Pi over the official Antigravity ACP server (`agy acp`, default) or the `stream-json` CLI engine. It bridges Pi tools (including `codemode`, extension tools, and builtin MCP tools) into `agy` over an authenticated loopback MCP server and delivers Pi steering messages **mid-turn** rather than waiting for the previous prompt to finish.
12
+
13
+ > **Upstream provenance**: Forked from `@estebanforge/pi-antigravity-bridge@1.17.2` (MIT) and maintained independently in Orbit Tools. Upstream updates are tracked selectively without wholesale replacement; see [docs/upstream.md](docs/upstream.md).
14
+
15
+ ## Key Improvements Over Upstream 1.17.2
16
+
17
+ - **Real-time mid-turn steering delivery**: When Pi drains a steering prompt right after a bridged tool call finishes, Pi Antigravity injects the steering text (appended at the tail so middle-truncation of large tool output preserves it) and any user-attached image blocks directly into the resolving MCP `CallToolResult`. `agy` acts on the steering instruction on its very next step and integrates everything into **one complete final answer**, instead of finishing the pre-steering response first and splitting the reply across a post-turn rerun.
18
+ - **Escalated tool & bridge-local steering**: Long-running calls that escalate past ~20s deliver pending mid-turn steers as soon as `bridge_poll_result`, `bridge_tool_info`, `activate_skill`, or an escalation ack returns. Approval-only parks that end without another bridge call fall back losslessly to post-outcome delivery.
19
+ - **Boundary & cursor hygiene**: Deduplicates dead-turn `late + steer` dispatches, clears steering cursors on compaction, and drops stale cursors after transcript shrinks (`/tree`, `/fork`, `/compact`).
20
+ - **Orbit Labs isolated state & non-destructive migration**: Stores configuration and session bindings under `~/.pi/agent/pi-antigravity/` and logs under `~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/logs/`. On first load, automatically copies `config.json`, `models-cache.json`, and `sessions.json` from legacy `~/.pi/agent/antigravity-bridge/` without overwriting or deleting legacy files.
21
+ - **Strict TypeScript and `pi-lens` hardening**: Zero strict `tsc` errors and zero `pi-lens` errors or warnings across all source files and documentation.
22
+
23
+ ## Requirements
24
+
25
+ - **Node.js**: `>= 22.19.0`
26
+ - **Pi**: `@earendil-works/pi-coding-agent` `>= 1.5.1` (verified on Pi `1.7.0`)
27
+ - **Antigravity CLI**: `agy` installed and authenticated (`agy --version`, verified on `1.5.21`)
28
+
29
+ ## Installation
30
+
31
+ Keep the live installation outside a branch-switching git checkout (for example under `~/.local/share/orbit-tools/pi-antigravity-0.0.2`).
32
+
33
+ ### Option 1: Local Versioned Snapshot (Recommended for Orbit Tools)
34
+
35
+ ```sh
36
+ mkdir -p ~/.local/share/orbit-tools/pi-antigravity-0.0.2
37
+ # Copy Pi/pi-antigravity from the Orbit Tools 0.0.2 release or checkout, then:
38
+ cd ~/.local/share/orbit-tools/pi-antigravity-0.0.2
39
+ npm ci --omit=dev --ignore-scripts --legacy-peer-deps
40
+ ```
41
+
42
+ Add the path to `~/.pi/agent/settings.json` under `packages` (and remove any previous `npm:@estebanforge/pi-antigravity-bridge` entry so two Antigravity providers never load simultaneously):
43
+
44
+ ```json
45
+ {
46
+ "packages": [
47
+ "/Users/<you>/.local/share/orbit-tools/pi-antigravity-0.0.2"
48
+ ]
49
+ }
50
+ ```
51
+
52
+ ### Option 2: npm Package
53
+
54
+ ```sh
55
+ pi install npm:@orbit-labs-ai/pi-antigravity@0.0.2
56
+ ```
57
+
58
+ Restart Pi or run `/reload`, then pick an `antigravity/*` model via `/model` or inspect health with `/agy doctor`.
59
+
60
+ ## Quick Start and Commands
61
+
62
+ | Command | Purpose |
63
+ | --- | --- |
64
+ | `/agy` | Open interactive settings picker |
65
+ | `/agy doctor` | Show engine, binary version, config path, bridge stats, and warnings |
66
+ | `/agy engine acp\|stream-json` | Select backend engine (takes effect on next Pi start) |
67
+ | `/agy bridge all\|mcp\|codemode\|none` | Control which Pi tools are exposed to `agy` over loopback MCP |
68
+ | `/agy mode accept-edits\|plan` | Switch Antigravity execution mode |
69
+ | `/agy thinking low\|medium\|high\|xhigh` | Set default thinking tier for `AskAntigravity` |
70
+ | `/agy digest on\|off` | Toggle cross-provider / compaction context digest handoff |
71
+ | `/agy system-prompt on\|off` | Toggle sending Pi system prompt and `AGENTS.md` on new conversations |
72
+ | `/agy clear` | Clear stored Pi-to-Antigravity conversation bindings |
73
+
74
+ ## Configuration
75
+
76
+ Runtime configuration lives at `<agentDir>/pi-antigravity/config.json` (default `~/.pi/agent/pi-antigravity/config.json`). Example:
77
+
78
+ ```json
79
+ {
80
+ "engine": "acp",
81
+ "mode": "accept-edits",
82
+ "handoff": "digest",
83
+ "readOnly": false,
84
+ "skipPermissions": true,
85
+ "defaultModel": "gemini-4-neon",
86
+ "defaultThinking": "xhigh",
87
+ "askTool": true,
88
+ "webTools": false,
89
+ "bridgeTools": "codemode",
90
+ "digest": true,
91
+ "systemPrompt": true,
92
+ "inactivityTimeoutMin": 5,
93
+ "approvals": {
94
+ "gateMode": "auto",
95
+ "mode": "ask"
96
+ },
97
+ "acp": {
98
+ "usageEstimate": "estimate",
99
+ "sessionTimeoutMs": 20000,
100
+ "sessionRetryOnTimeout": false
101
+ }
102
+ }
103
+ ```
104
+
105
+ Key environment overrides: `AGY_ENGINE`, `AGY_MODE`, `AGY_BRIDGE_TOOLS`, `AGY_HANDOFF`, `AGY_SKIP_PERMISSIONS`, `AGY_READONLY`, `AGY_DEFAULT_MODEL`, `AGY_DEFAULT_THINKING`, `AGY_DEBUG=1`, `PI_CODING_AGENT_DIR`.
106
+
107
+ ## Data Locations, Network Access, and Privacy
108
+
109
+ - **State & cache**: `~/.pi/agent/pi-antigravity/{config.json,sessions.json,models-cache.json}` (mode `0600`, atomic writes).
110
+ - **Isolated ACP homes**: `~/.pi/agent/pi-antigravity/acp-homes/` (ephemeral per-session staged directories, cleaned on teardown).
111
+ - **Daily logs**: `~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/logs/<YYYY-MM-DD>.ndjson` (error-only by default; secret keys and tokens are redacted; pruned after 14 days).
112
+ - **Network & model access**: Model inference runs through your locally authenticated `agy` CLI. The MCP tool bridge binds exclusively to `127.0.0.1` with a per-process random `x-bridge-token` header.
113
+ - **Failure behavior**: Fail-closed on unauthorized MCP requests, hidden/inactive Pi tools, and unapproved gated native tool calls.
114
+
115
+ ## Development, Testing, and Verification
116
+
117
+ From `Pi/pi-antigravity`:
118
+
119
+ ```sh
120
+ npm ci --ignore-scripts --legacy-peer-deps
121
+ npm run typecheck
122
+ npm test
123
+ npm audit --omit=dev
124
+ ```
125
+
126
+ - `npm run typecheck` resolves the installed Pi SDK (via `PI_SDK_PATH` or `~/.pi/agent/install/current-version`) and runs strict TypeScript checks across `src/` and `extensions/`.
127
+ - `npm run link-host-types` links that Pi SDK and the type packages it ships into `node_modules/`, so an editor or language server resolves the host imports through `tsconfig.json`. The links are local and ignored by Git; `npm ci` removes them, so run it again afterwards.
128
+ - `npm test` runs offline unit tests covering mid-turn steering delivery (`test/steering.test.mjs`), runtime/schema/migration behavior (`test/runtime.test.mjs`), and dry-run packaging/documentation checks (`test/package.test.mjs`). No paid API calls are made by `npm test`.
129
+ - **Known limitations**: When `agy` completes a turn using only internal thinking or native tools without calling any bridged Pi tool, Pi itself keeps steering messages queued until turn end (matching standard Pi behavior for all providers). Mid-turn injection applies whenever Pi drains steering after a bridged tool round-trip.
130
+
131
+ ## Uninstall and Cleanup
132
+
133
+ 1. Remove the package path (or `npm:@orbit-labs-ai/pi-antigravity`) from `~/.pi/agent/settings.json` and restart Pi or run `/reload`.
134
+ 2. Delete the local install directory `~/.local/share/orbit-tools/pi-antigravity-0.0.2`.
135
+ 3. Optionally remove state and logs: `~/.pi/agent/pi-antigravity/` and `~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/`.
136
+
137
+ ## License
138
+
139
+ MIT — see [LICENSE](../../LICENSE) and [package LICENSE](LICENSE).
@@ -0,0 +1,139 @@
1
+ # Pi Antigravity
2
+
3
+ [English](./README.md) | 简体中文
4
+
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.19-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
7
+ [![Pi](https://img.shields.io/badge/host-Pi%201.5%2B-8A2BE2)](#运行要求)
8
+
9
+ **Orbit Labs 维护的 Pi Antigravity Provider 插件:支持实时回合中(mid-turn)steering 注入、codemode/MCP 工具桥接与完整的 `/model` 模型选择。**
10
+
11
+ Pi Antigravity(`@orbit-labs-ai/pi-antigravity`)在 Pi 中通过官方 Antigravity ACP 服务(`agy acp`,默认)或 `stream-json` 引擎注册 `antigravity/*` 模型。插件通过本地回环认证 MCP 服务将 Pi 工具(包括 `codemode`、扩展工具与内置 MCP 工具)桥接给 `agy`,并在工具调用返回时**实时注入** Pi 的 steering 消息,而不是等上一轮回答完全结束后才补发。
12
+
13
+ > **上游来源与跟踪策略**:基于 `@estebanforge/pi-antigravity-bridge@1.17.2`(MIT)分支独立维护,不再全量跟随上游直接覆盖更新,而是持续跟踪上游提交并按需选择性移植修复;详见 [docs/upstream.md](docs/upstream.md)(英文)。
14
+
15
+ ## 相对上游 1.17.2 的核心改进
16
+
17
+ - **实时回合中 steering 注入**:当 Pi 在桥接工具返回后立即 drain 你的 steering prompt 时,插件会将 steering 文本(追加在工具输出末尾,避免超大输出被中间截断时丢失)及用户附带的图片直接写入正在返回的 MCP `CallToolResult`。`agy` 在紧接着的下一步推理就能立即看到并遵守 steering 指令,最终合并输出**单一、完整的回答**,不再出现“先写完旧答案、结束后再起第二轮零散回答”的撕裂现象。
18
+ - **慢工具轮询与本地桥接工具无缝投递**:运行超过 ~20 秒并升级为轮询的工具会在 `bridge_poll_result`、`bridge_tool_info`、`activate_skill` 或升级回执返回时立刻附带待投递的 steering 消息;仅包含审批门禁(approval park)且后续未调用任何桥接工具的极端场景仍会无损回落到回合结束后补发。
19
+ - **边界与游标健壮性**:修复 dead-turn 同时存在滞后工具结果(`late`)与 steering 消息时的重复投递问题;在会话压缩(`session_compact`)时重置 steering 游标,并在 `/tree`、`/fork`、`/compact` 导致历史缩短时自动清理过期游标。
20
+ - **Orbit Labs 独立目录与无损迁移**:配置与会话绑定默认存放在 `~/.pi/agent/pi-antigravity/`,日志存放在 `~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/logs/`。首次加载时会自动从旧版 `~/.pi/agent/antigravity-bridge/` 单向无损复制 `config.json`、`models-cache.json` 与 `sessions.json`,不覆盖目标已有文件,也不删除旧目录。
21
+ - **严格 TypeScript 与 `pi-lens` 零警告加固**:全包所有源码与文档均通过严格 `tsc` 检查及 `pi-lens` 0 error / 0 warning 校验。
22
+
23
+ ## 运行要求
24
+
25
+ - **Node.js**:`>= 22.19.0`
26
+ - **Pi**:`@earendil-works/pi-coding-agent` `>= 1.5.1`(已在 Pi `1.7.0` 验证)
27
+ - **Antigravity CLI**:已安装并登录 `agy`(`agy --version`,已在 `1.5.21` 验证)
28
+
29
+ ## 安装与快速开始
30
+
31
+ 建议将生产运行的插件副本放在独立目录(不要直接指向频繁切换分支的 Git 工作区),例如 `~/.local/share/orbit-tools/pi-antigravity-0.0.2`。
32
+
33
+ ### 方式一:本地版本化快照安装(Orbit Tools 推荐)
34
+
35
+ ```sh
36
+ mkdir -p ~/.local/share/orbit-tools/pi-antigravity-0.0.2
37
+ # 从 Orbit Tools 0.0.2 发布版或检出目录复制 Pi/pi-antigravity 后执行:
38
+ cd ~/.local/share/orbit-tools/pi-antigravity-0.0.2
39
+ npm ci --omit=dev --ignore-scripts --legacy-peer-deps
40
+ ```
41
+
42
+ 在 `~/.pi/agent/settings.json` 的 `packages` 数组中登记该路径,并移除原有的 `npm:@estebanforge/pi-antigravity-bridge`(避免同时加载两个 Antigravity provider 冲突):
43
+
44
+ ```json
45
+ {
46
+ "packages": [
47
+ "/Users/<你的用户名>/.local/share/orbit-tools/pi-antigravity-0.0.2"
48
+ ]
49
+ }
50
+ ```
51
+
52
+ ### 方式二:npm 安装
53
+
54
+ ```sh
55
+ pi install npm:@orbit-labs-ai/pi-antigravity@0.0.2
56
+ ```
57
+
58
+ 重启 Pi 或执行 `/reload`,通过 `/model` 选择 `antigravity/*` 模型,或运行 `/agy doctor` 查看状态。
59
+
60
+ ## 常用命令
61
+
62
+ | 命令 | 说明 |
63
+ | --- | --- |
64
+ | `/agy` | 打开交互式设置面板 |
65
+ | `/agy doctor` | 查看引擎、CLI 版本、配置路径、桥接统计与告警 |
66
+ | `/agy engine acp\|stream-json` | 切换底层引擎(下次启动 Pi 生效) |
67
+ | `/agy bridge all\|mcp\|codemode\|none` | 控制通过回环 MCP 暴露给 `agy` 的 Pi 工具集合 |
68
+ | `/agy mode accept-edits\|plan` | 切换 Antigravity 执行模式 |
69
+ | `/agy thinking low\|medium\|high\|xhigh` | 设置 `AskAntigravity` 默认思考档位 |
70
+ | `/agy digest on\|off` | 开关跨 provider / 压缩后的上下文摘要交接 |
71
+ | `/agy system-prompt on\|off` | 开关新会话首轮发送 Pi 系统提示与 `AGENTS.md` |
72
+ | `/agy clear` | 清空 Pi 与 Antigravity 的会话绑定记录 |
73
+
74
+ ## 配置文件
75
+
76
+ 运行时配置位于 `<agentDir>/pi-antigravity/config.json`(默认 `~/.pi/agent/pi-antigravity/config.json`)。示例:
77
+
78
+ ```json
79
+ {
80
+ "engine": "acp",
81
+ "mode": "accept-edits",
82
+ "handoff": "digest",
83
+ "readOnly": false,
84
+ "skipPermissions": true,
85
+ "defaultModel": "gemini-4-neon",
86
+ "defaultThinking": "xhigh",
87
+ "askTool": true,
88
+ "webTools": false,
89
+ "bridgeTools": "codemode",
90
+ "digest": true,
91
+ "systemPrompt": true,
92
+ "inactivityTimeoutMin": 5,
93
+ "approvals": {
94
+ "gateMode": "auto",
95
+ "mode": "ask"
96
+ },
97
+ "acp": {
98
+ "usageEstimate": "estimate",
99
+ "sessionTimeoutMs": 20000,
100
+ "sessionRetryOnTimeout": false
101
+ }
102
+ }
103
+ ```
104
+
105
+ 常用环境变量覆盖:`AGY_ENGINE`、`AGY_MODE`、`AGY_BRIDGE_TOOLS`、`AGY_HANDOFF`、`AGY_SKIP_PERMISSIONS`、`AGY_READONLY`、`AGY_DEFAULT_MODEL`、`AGY_DEFAULT_THINKING`、`AGY_DEBUG=1`、`PI_CODING_AGENT_DIR`。
106
+
107
+ ## 数据位置、网络访问与隐私
108
+
109
+ - **状态与缓存**:`~/.pi/agent/pi-antigravity/{config.json,sessions.json,models-cache.json}`(`0600` 权限、原子写入)。
110
+ - **ACP 隔离主目录**:`~/.pi/agent/pi-antigravity/acp-homes/`(每会话临时目录,退出时清理)。
111
+ - **按日日志**:`~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/logs/<YYYY-MM-DD>.ndjson`(默认仅记录错误;自动脱敏密钥与 token;保留 14 天)。
112
+ - **网络与模型访问**:模型推理由本机已登录的 `agy` CLI 执行;MCP 桥接服务仅监听 `127.0.0.1` 并校验每进程随机生成的 `x-bridge-token` 请求头。
113
+ - **失败策略**:未认证的 MCP 请求、已隐藏/未激活的 Pi 工具以及未经批准的受控原生工具调用均采用 fail-closed 拒绝策略。
114
+
115
+ ## 开发、测试与验证
116
+
117
+ 在 `Pi/pi-antigravity` 目录执行:
118
+
119
+ ```sh
120
+ npm ci --ignore-scripts --legacy-peer-deps
121
+ npm run typecheck
122
+ npm test
123
+ npm audit --omit=dev
124
+ ```
125
+
126
+ - `npm run typecheck` 自动解析已安装的 Pi SDK(通过 `PI_SDK_PATH` 或 `~/.pi/agent/install/current-version`)并对 `src/` 与 `extensions/` 执行严格 TypeScript 检查。
127
+ - `npm run link-host-types` 把该 Pi SDK 及其附带的类型包链接到 `node_modules/`,让编辑器或语言服务器通过 `tsconfig.json` 解析宿主导入。这些链接只在本机,Git 会忽略;`npm ci` 会删除它们,之后请重新运行。
128
+ - `npm test` 运行离线自动化测试,覆盖实时 mid-turn steering 注入(`test/steering.test.mjs`)、运行时/schema 克隆/配置迁移(`test/runtime.test.mjs`)及打包与文档完整性检查(`test/package.test.mjs`),不触发付费模型调用。
129
+ - **已知边界**:当 `agy` 仅使用内部思考或原生工具完成整个回合、未触发任何 Pi 桥接工具调用时,Pi 会像对待其他所有 provider 一样将 steering 消息排队至本轮结束;只要触发了桥接工具往返,Pi 在工具返回后排入的 steering 消息都会实时回合中注入。
130
+
131
+ ## 卸载与清理
132
+
133
+ 1. 从 `~/.pi/agent/settings.json` 中移除该插件路径(或 `npm:@orbit-labs-ai/pi-antigravity`),然后重启 Pi 或执行 `/reload`。
134
+ 2. 删除本地安装目录 `~/.local/share/orbit-tools/pi-antigravity-0.0.2`。
135
+ 3. 如需清理状态与日志,可删除 `~/.pi/agent/pi-antigravity/` 与 `~/.pi/extensions-data/orbit-labs-ai/pi-antigravity/`。
136
+
137
+ ## 许可证
138
+
139
+ MIT — 见根目录 [LICENSE](../../LICENSE) 与本包 [LICENSE](LICENSE)。
@@ -0,0 +1,49 @@
1
+ # Upstream Provenance and Selective Tracking
2
+
3
+ `@orbit-labs-ai/pi-antigravity` is an independent Orbit Labs fork maintained in `Orbit-Tools/Pi/pi-antigravity`. It is no longer updated wholesale from upstream, while still tracking upstream changes selectively for bug fixes and protocol compatibility.
4
+
5
+ ## Fork Baseline
6
+
7
+ | Field | Value |
8
+ | --- | --- |
9
+ | Upstream package | `@estebanforge/pi-antigravity-bridge` |
10
+ | Upstream repository | `https://github.com/EstebanForge/pi-extensions` (`packages/pi-antigravity-bridge`) |
11
+ | Upstream license | MIT (attribution preserved in [../LICENSE](../LICENSE)) |
12
+ | Forked version | `1.17.2` |
13
+ | Forked commit | `28b0a52` (2026-11-30) |
14
+
15
+ ## Intentional Divergences (0.0.1)
16
+
17
+ 1. **Real-time mid-turn steering delivery** (`src/provider.ts`, `extensions/index.ts`):
18
+ - Injects Pi mid-turn steering messages (text and user-attached image blocks) directly into the resolving MCP `CallToolResult` while a parked `agy` turn is still active, rather than letting the previous turn finish and splitting the reply across a post-turn redelivery.
19
+ - Arms pending mid-turn steering for escalated tool polls (`bridge_poll_result`) and bridge-local responses (`bridge_tool_info`, `activate_skill`, `escalated-ack`), falling back losslessly to post-outcome delivery only when no mid-turn channel fires.
20
+ - Deduplicates dead-turn `late + steer` dispatches and guards against stale `steerCursors` after `/tree`, `/fork`, or `/compact`.
21
+ 2. **Orbit Labs identity and isolated state layout**:
22
+ - Package renamed to `@orbit-labs-ai/pi-antigravity` with Orbit Labs runtime symbols, MCP server identity (`pi-antigravity`), and scoped log storage (`<configRoot>/extensions-data/orbit-labs-ai/pi-antigravity`).
23
+ - State directory moved to `<agentDir>/pi-antigravity` with one-shot non-destructive migration and read-only fallback from legacy `<agentDir>/antigravity-bridge`.
24
+ - Keeps provider ID `antigravity`, API `agy-bridge`, slash command `/agy`, and tool `AskAntigravity` for seamless compatibility with Pi configs and `@orbit-labs-ai/pi-metrics`.
25
+ 3. **Strict quality gate and test harness**:
26
+ - Zero `tsc --strict` errors and zero `pi-lens` errors or warnings across all source and documentation files.
27
+ - Self-contained offline test suite (`test/steering.test.mjs`, `test/runtime.test.mjs`, `test/package.test.mjs`) and host-aware typecheck runner (`scripts/typecheck.mjs`).
28
+
29
+ ## Tracking Upstream Selectively
30
+
31
+ Do **not** replace `Pi/pi-antigravity` wholesale with a newer npm release of `@estebanforge/pi-antigravity-bridge`. Instead, inspect upstream commits periodically and port only relevant changes:
32
+
33
+ ```sh
34
+ # Inspect upstream commits since the fork baseline (28b0a52)
35
+ gh api "repos/EstebanForge/pi-extensions/commits?path=packages/pi-antigravity-bridge&per_page=20" \
36
+ --jq '.[] | "\(.sha[0:7]) \(.commit.author.date[0:10]) \(.commit.message | split("\n")[0])"'
37
+ ```
38
+
39
+ When porting a fix from upstream:
40
+
41
+ 1. Review the upstream diff for protocol or `agy` CLI changes (ACP frames, model catalog format, compaction hooks).
42
+ 2. Re-apply only the targeted fix onto `Pi/pi-antigravity`, preserving mid-turn steering delivery, Orbit Labs state paths, and `pi-lens` / strict TypeScript compliance.
43
+ 3. Update the table below with the reviewed commit SHA and date, add bilingual changelog entries, and run `npm run typecheck` and `npm test`.
44
+
45
+ ## Upstream Review Log
46
+
47
+ | Date | Upstream Commit | Upstream Version | Disposition |
48
+ | --- | --- | --- | --- |
49
+ | 2026-12-02 | `28b0a52` | `1.17.2` | Fork baseline for `@orbit-labs-ai/pi-antigravity@0.0.1` |