pi-antigravity-bridge 0.0.0-stage → 0.1.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## [0.1.1] - 2026-11-21
4
+
5
+ ### Changed
6
+
7
+ - 改进多步工具调用期间的流式事件采样与分步 Token 归因,支持实时与单步 TPS 统计并在工具执行途中持续保持缓存命中率与上下文窗口进度同步。
8
+ - 校准 Gemini 系列模型的初始上下文窗口上限,并在收到实时窗口回报时立即更新活跃模型窗口容量。
9
+ - 对齐 `/agy mode` 命令补全及选择列表中的默认模式提示说明。
10
+
11
+ ### Fixed
12
+
13
+ - 修复多步工具调用结束时将整轮累计 Token 写入单条消息导致上下文窗口占用率虚高及误触发自动压缩的问题。
14
+ - 修复 `agy-tools` 模式下开启 `bridgePiMcp` 时宿主 MCP 相关工具未被纳入激活列表的问题。
15
+ - 修复 `agy-tools` 模式下省略显式完成事件时的镜像工具等待挂起问题,以及 `hybrid` 模式下省略标题的工具更新事件路由偏差。
16
+ - 修复交互式 TUI 下执行 `/agy login` 未先释放终端的问题。
17
+ - 修复 `processPerSession: false` 时 Stdio 转发桥串行阻塞并发工具调用的问题。
18
+ - 修复跨模型切换同名思考档位漏同步、导入历史会话首次恢复未命中、辅助请求进程复用及子进程管道异常防护等边界问题。
19
+
20
+ ## [0.1.0] - 2026-11-21
21
+
22
+ ### Added
23
+
24
+ - 新增 `antigravity` 模型后端注册,支持通过官方 `agy acp` 接入 Gemini 与 Claude 等可用模型。
25
+ - 新增模型家族自动聚合与 Thinking 档位(`low`、`medium`、`high`、`xhigh`、`max`)联动支持。
26
+ - 新增 `pi-tools`(默认)、`agy-tools` 与 `hybrid` 三种可切换工具运行模式。
27
+ - 新增 `agy-tools` 模式原生工具卡片与红绿对比 Diff 主题渲染器,支持交互式权限审批与结构化提问弹窗。
28
+ - 新增 `bridgePiMcp`、`bridgePiSkills`、`bridgePiAgentsMd` 独立桥接控制开关及反向 Skills 发现支持。
29
+ - 新增跨会话恢复、分支回退同步、上下文压缩自动轮换及 `/agy sessions` 本机历史会话导入能力。
30
+ - 新增 `/agy` 斜杠命令族与底部状态栏状态标识,支持 Windows、Linux 与 macOS。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 onprs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # Temporary Holding Version
1
+ # Pi Antigravity Bridge
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
+ 将 Google Antigravity CLI(`agy`)作为原生模型与 Agent 后端接入 [Pi](https://github.com/earendil-works/pi)(`@earendil-works/pi-coding-agent`),在完整的 Pi TUI 交互界面中直接使用 Antigravity 提供的模型、思考档位与工具生态。
4
+
5
+ ## 功能特性
6
+
7
+ - **原生模型与思考控制**:通过 `/model` 选择当前账号可用的 Gemini、Claude 等模型,直接联动 Pi 的 Thinking 档位切换与思考块折叠展示。
8
+ - **三种工具运行模式**:
9
+ - `pi-tools`(默认):通过标准 MCP 挂载并使用 Pi 内置工具、第三方 Pi 扩展工具与审批流程,保持原生 Pi 交互体验。
10
+ - `agy-tools`:使用 Antigravity 原生文件、终端、搜索、Subagents 与沙箱能力,并在 Pi 聊天流中呈现为原生工具卡片与对比 Diff。
11
+ - `hybrid`:同时启用 Antigravity 原生工具与 Pi 专属扩展工具。
12
+ - **可选生态挂载**:支持独立控制是否将 Pi 的 MCP、Skills 与 `AGENTS.md` 规则桥接至 Antigravity。
13
+ - **完整会话体验**:支持多模态图片输入、运行中实时转向(Steering)、`/resume` 会话恢复、`/fork` 与 `/tree` 分支导航、`/compact` 上下文压缩以及导入本机已有的 Antigravity 会话。
14
+ - **跨平台支持**:支持 Windows、Ubuntu(Linux)与 macOS。
15
+
16
+ ## 环境要求
17
+
18
+ - Node.js `>= 22.5.0`
19
+ - 已安装 `@earendil-works/pi-coding-agent`(`pi` 命令可用)
20
+ - 已安装官方 Google Antigravity CLI(`agy` 命令可用,推荐 `>= 1.5.13`)
21
+
22
+ ## 安装
23
+
24
+ 通过 npm 安装:
25
+
26
+ ```bash
27
+ pi install npm:pi-antigravity-bridge
28
+ ```
29
+
30
+ 或通过 GitHub 仓库安装:
31
+
32
+ ```bash
33
+ pi install https://github.com/onprs/Pi-Antigravity-Bridge.git
34
+ ```
35
+
36
+ 单次会话临时加载试用:
37
+
38
+ ```bash
39
+ pi -e npm:pi-antigravity-bridge
40
+ ```
41
+
42
+ 升级与卸载:
43
+
44
+ ```bash
45
+ pi update --extensions
46
+ pi remove npm:pi-antigravity-bridge
47
+ ```
48
+
49
+ ## 快速开始
50
+
51
+ 1. 确保本机 `agy` 已登录(若尚未登录,可在终端运行 `agy acp --login`,或在启动 `pi` 后执行 `/agy login`)。
52
+ 2. 启动 `pi`,输入 `/model` 并选择 `antigravity` 分组下的模型(如 `gemini-4-neon`、`gemini-4-carbon`、`claude-sonnet-5-5`)。
53
+ 3. 使用快捷键循环切换 Thinking 档位,直接开始对话。
54
+
55
+ ## 斜杠命令
56
+
57
+ 在 Pi 交互界面中可使用以下 `/agy` 命令:
58
+
59
+ | 命令 | 说明 |
60
+ |---|---|
61
+ | `/agy` 或 `/agy status` | 查看可执行文件路径、订阅等级、当前模式、桥接状态与上下文占用 |
62
+ | `/agy mode [pi-tools \| agy-tools \| hybrid]` | 查看或切换工具运行模式 |
63
+ | `/agy bridge [mcp \| skills \| agents-md] [on \| off \| auto]` | 控制是否将 Pi 的 MCP、Skills 或 `AGENTS.md` 桥接至 Antigravity |
64
+ | `/agy agent-mode [default \| accept-edits \| plan]` | 在 `agy-tools` 或 `hybrid` 模式下切换 Antigravity 执行权限策略 |
65
+ | `/agy refresh` | 重新探测并刷新当前账号可用的模型列表 |
66
+ | `/agy sessions` | 浏览本机 Antigravity 历史会话并导入为新的 Pi 会话 |
67
+ | `/agy login` / `/agy logout` | 引导执行官方 `agy` 登录或登出当前账号 |
68
+
69
+ ## 配置说明
70
+
71
+ 全局配置文件位于 `~/.pi/agent/antigravity.json`(受信项目可在项目根目录 `.pi/antigravity.json` 覆盖配置):
72
+
73
+ ```json
74
+ {
75
+ "toolMode": "pi-tools",
76
+ "bridgePiMcp": "auto",
77
+ "bridgePiSkills": "auto",
78
+ "bridgePiAgentsMd": "auto",
79
+ "piMcpBridgeStrategy": "via-host",
80
+ "agyInheritCustomizations": "auto",
81
+ "agyInheritMcp": "auto",
82
+ "shareAgySkillsToPi": false,
83
+ "agyExecutionMode": "default",
84
+ "processPerSession": true,
85
+ "enableSqliteFork": true,
86
+ "sandbox": false,
87
+ "mcpHoldLimitMs": 165000
88
+ }
89
+ ```
90
+
91
+ ### 常用配置项说明
92
+
93
+ - `toolMode`:默认工具模式,可选 `"pi-tools"`、`"agy-tools"`、`"hybrid"`。
94
+ - `bridgePiMcp` / `bridgePiSkills` / `bridgePiAgentsMd`:设为 `"auto"` 时,在 `pi-tools` 模式下默认开启,在 `agy-tools` 与 `hybrid` 模式下默认关闭;设为 `true` 或 `false` 时在所有模式下强制生效。
95
+ - `shareAgySkillsToPi`:设为 `true` 时,将 `~/.gemini/config/skills` 与项目 `.agents/skills` 中的技能同步提供给 Pi。
96
+ - `agyExecutionMode`:控制 Antigravity 原生工具权限行为,可选 `"default"`(按规则询问)、`"accept-edits"`(自动批准工作区文件修改)、`"plan"`(先规划后执行)。
97
+ - `sandbox`:设为 `true` 时启用 Antigravity 终端沙箱。
98
+
99
+ ### 环境变量
100
+
101
+ | 环境变量 | 作用 |
102
+ |---|---|
103
+ | `PI_AGY_BIN` | 指定 `agy` 可执行文件的完整路径 |
104
+ | `PI_AGY_GEMINI_DIR` | 指定自定义 Gemini 数据目录(默认 `~/.gemini`) |
105
+ | `PI_AGY_TOOL_MODE` | 覆盖启动默认工具模式(`pi-tools`、`agy-tools`、`hybrid`) |
106
+ | `PI_AGY_BRIDGE_MCP` | 覆盖 `bridgePiMcp`(`true`、`false`、`auto`) |
107
+ | `PI_AGY_BRIDGE_SKILLS` | 覆盖 `bridgePiSkills`(`true`、`false`、`auto`) |
108
+ | `PI_AGY_BRIDGE_AGENTS_MD` | 覆盖 `bridgePiAgentsMd`(`true`、`false`、`auto`) |
109
+
110
+ ## 账号与隐私说明
111
+
112
+ - 本扩展不读取、不解密、不复制或保存 `agy` 内部的任何 OAuth 令牌与账号凭据,认证状态完全由本机官方 `agy` 自行管理。
113
+ - 本扩展保持 Antigravity 官方系统提示词不变,仅通过官方公开的 ACP、MCP 与原生插件清单机制挂载所需工具、规则及技能。
114
+ - Gemini 系列模型面向所有客户端开放;Claude 等第三方模型的可用范围取决于当前账号权限与 Antigravity 官方客户端开放策略。
115
+
116
+ ## 开源协议
117
+
118
+ [MIT](./LICENSE)
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: pi-bridge
3
+ description: Tool execution bridge agent for Pi.
4
+ mainAgent: true
5
+ subagent: false
6
+ tools: []
7
+ excludeDefaultComponents: true
8
+ inheritCustomizations: false
9
+ inheritMcp: false
10
+ ---
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "pi-antigravity-bridge",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Google Antigravity CLI (agy acp) agent backend bridge for Pi",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22.5.0"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/onprs/Pi-Antigravity-Bridge.git"
13
+ },
14
+ "homepage": "https://github.com/onprs/Pi-Antigravity-Bridge#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/onprs/Pi-Antigravity-Bridge/issues"
17
+ },
18
+ "keywords": [
19
+ "pi-package",
20
+ "pi-extension",
21
+ "antigravity",
22
+ "acp",
23
+ "coding-agent"
24
+ ],
25
+ "pi": {
26
+ "extensions": [
27
+ "./src/index.ts"
28
+ ],
29
+ "changelogPath": "./CHANGELOG.md"
30
+ },
31
+ "files": [
32
+ "src",
33
+ "assets",
34
+ "CHANGELOG.md",
35
+ "LICENSE",
36
+ "README.md"
37
+ ],
38
+ "scripts": {
39
+ "typecheck": "node ./node_modules/typescript/bin/tsc --noEmit",
40
+ "test": "node --experimental-strip-types --test",
41
+ "check": "npm run typecheck && npm test"
42
+ },
43
+ "peerDependencies": {
44
+ "@earendil-works/pi-agent-core": "*",
45
+ "@earendil-works/pi-ai": "*",
46
+ "@earendil-works/pi-coding-agent": "*",
47
+ "@earendil-works/pi-tui": "*",
48
+ "typebox": "*"
49
+ },
50
+ "devDependencies": {
51
+ "@earendil-works/pi-agent-core": "^1.6.0",
52
+ "@earendil-works/pi-ai": "^1.6.0",
53
+ "@earendil-works/pi-coding-agent": "^1.6.0",
54
+ "@earendil-works/pi-tui": "^1.6.0",
55
+ "@types/node": "^22.19.0",
56
+ "typebox": "^1.3.27",
57
+ "typescript": "^5.8.2"
58
+ }
59
+ }
@@ -0,0 +1,165 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import * as fs from "node:fs";
3
+ import * as os from "node:os";
4
+ import * as path from "node:path";
5
+
6
+ export interface ResolvedBinary {
7
+ /** 可执行文件绝对路径 */
8
+ binPath: string;
9
+ /** 是否为 Windows 批处理包装脚本(.cmd / .bat) */
10
+ isWindowsWrapperScript: boolean;
11
+ /** 解析来源说明 */
12
+ source: "config" | "path" | "standard-location";
13
+ }
14
+
15
+ function isExecutableFile(candidate: string, platform: NodeJS.Platform): boolean {
16
+ try {
17
+ const stat = fs.statSync(candidate);
18
+ if (!stat.isFile()) {
19
+ return false;
20
+ }
21
+ if (platform !== "win32") {
22
+ fs.accessSync(candidate, fs.constants.X_OK);
23
+ }
24
+ return true;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ function getWindowsExtensions(env: NodeJS.ProcessEnv): string[] {
31
+ const raw = env.PATHEXT || ".EXE;.CMD;.BAT;.COM";
32
+ const parsed = raw
33
+ .split(";")
34
+ .map((ext) => ext.trim().toLowerCase())
35
+ .filter((ext) => ext.length > 0);
36
+ // 优先定位原生 .exe,避免不必要的 cmd.exe 包装层
37
+ const ordered = [".exe", ...parsed.filter((ext) => ext !== ".exe")];
38
+ return Array.from(new Set(ordered));
39
+ }
40
+
41
+ function getStandardLocations(
42
+ platform: NodeJS.Platform,
43
+ homeDir: string,
44
+ geminiDir: string,
45
+ env: NodeJS.ProcessEnv,
46
+ ): string[] {
47
+ if (platform === "win32") {
48
+ const localAppData = env.LOCALAPPDATA || path.join(homeDir, "AppData", "Local");
49
+ const userProfile = env.USERPROFILE || homeDir;
50
+ return [
51
+ path.join(localAppData, "Programs", "Antigravity", "bin", "agy.exe"),
52
+ path.join(localAppData, "antigravity-cli", "bin", "agy.exe"),
53
+ path.join(userProfile, ".local", "bin", "agy.exe"),
54
+ path.join(geminiDir, "antigravity-cli", "bin", "agy.exe"),
55
+ path.join(localAppData, "Programs", "Antigravity", "bin", "agy.cmd"),
56
+ ];
57
+ }
58
+
59
+ const candidates = [
60
+ path.join(homeDir, ".local", "bin", "agy"),
61
+ path.join(geminiDir, "antigravity-cli", "bin", "agy"),
62
+ "/usr/local/bin/agy",
63
+ "/usr/bin/agy",
64
+ ];
65
+ if (platform === "darwin") {
66
+ candidates.push("/opt/homebrew/bin/agy");
67
+ candidates.push(path.join(homeDir, "Applications", "Antigravity.app", "Contents", "Resources", "app", "bin", "agy"));
68
+ }
69
+ return candidates;
70
+ }
71
+
72
+ export interface ResolveBinaryOptions {
73
+ configuredBin?: string;
74
+ geminiDir?: string;
75
+ env?: NodeJS.ProcessEnv;
76
+ platform?: NodeJS.Platform;
77
+ homeDir?: string;
78
+ }
79
+
80
+ /**
81
+ * 跨平台定位 `agy` 可执行文件。
82
+ * 查找顺序:配置/环境变量显式路径 -> 系统 PATH -> 平台标准安装位置。
83
+ */
84
+ export function resolveAgyBinary(options: ResolveBinaryOptions = {}): ResolvedBinary | undefined {
85
+ const env = options.env ?? process.env;
86
+ const platform = options.platform ?? process.platform;
87
+ const homeDir = options.homeDir ?? os.homedir();
88
+ const geminiDir = options.geminiDir ?? path.join(homeDir, ".gemini");
89
+ const winExts = platform === "win32" ? getWindowsExtensions(env) : [""];
90
+
91
+ const checkCandidate = (
92
+ rawCandidate: string,
93
+ source: ResolvedBinary["source"],
94
+ ): ResolvedBinary | undefined => {
95
+ const resolved = path.resolve(rawCandidate);
96
+ if (platform === "win32" && path.extname(resolved) === "") {
97
+ for (const ext of winExts) {
98
+ const withExt = `${resolved}${ext}`;
99
+ if (isExecutableFile(withExt, platform)) {
100
+ const lower = ext.toLowerCase();
101
+ return {
102
+ binPath: withExt,
103
+ isWindowsWrapperScript: lower === ".cmd" || lower === ".bat",
104
+ source,
105
+ };
106
+ }
107
+ }
108
+ }
109
+ if (isExecutableFile(resolved, platform)) {
110
+ const ext = path.extname(resolved).toLowerCase();
111
+ return {
112
+ binPath: resolved,
113
+ isWindowsWrapperScript: platform === "win32" && (ext === ".cmd" || ext === ".bat"),
114
+ source,
115
+ };
116
+ }
117
+ return undefined;
118
+ };
119
+
120
+ // 1. 显式配置或环境变量
121
+ const explicit = options.configuredBin?.trim() || env.PI_AGY_BIN?.trim();
122
+ if (explicit) {
123
+ const hit = checkCandidate(explicit, "config");
124
+ if (hit) return hit;
125
+ }
126
+
127
+ // 2. 系统 PATH 检索(兼容 Windows 大小写环境变量 Path / PATH)
128
+ const pathValue = env.PATH ?? env.Path ?? "";
129
+ for (const dir of pathValue.split(path.delimiter)) {
130
+ const trimmed = dir.trim().replace(/^"(.*)"$/, "$1");
131
+ if (!trimmed) continue;
132
+ const hit = checkCandidate(path.join(trimmed, "agy"), "path");
133
+ if (hit) return hit;
134
+ }
135
+
136
+ // 3. 平台标准安装路径探测
137
+ for (const stdPath of getStandardLocations(platform, homeDir, geminiDir, env)) {
138
+ const hit = checkCandidate(stdPath, "standard-location");
139
+ if (hit) return hit;
140
+ }
141
+
142
+ return undefined;
143
+ }
144
+
145
+ /** 读取本机 `agy --version` 版本字符串 */
146
+ export function probeAgyVersion(binary: ResolvedBinary, timeoutMs = 4_000): string | undefined {
147
+ try {
148
+ const result = spawnSync(binary.binPath, ["--version"], {
149
+ encoding: "utf8",
150
+ timeout: timeoutMs,
151
+ shell: binary.isWindowsWrapperScript,
152
+ windowsHide: true,
153
+ });
154
+ if (result.status === 0 && result.stdout) {
155
+ const line = result.stdout
156
+ .split(/\r?\n/)
157
+ .map((s) => s.trim())
158
+ .find((s) => s.length > 0);
159
+ return line;
160
+ }
161
+ } catch {
162
+ // 忽略探测异常
163
+ }
164
+ return undefined;
165
+ }