@specode/pi-antigravity 0.1.0 → 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/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/package.json +1 -1
- package/src/google-shared.ts +28 -0
- package/src/request.ts +2 -2
- package/src/stream.ts +1 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ An independently maintained Antigravity subscription provider for Pi. It adapts
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
Requires Node.js >= 22.19.0 and the Pi 1.5.2 provider APIs used by this implementation.
|
|
11
|
+
Requires Node.js >= 22.19.0 and the Pi 1.5.2 provider APIs used by this implementation. Use version 0.1.1 or later for clean npm installations; 0.1.0 could rely on development dependencies to resolve Pi subpath imports.
|
|
12
12
|
|
|
13
13
|
From npm:
|
|
14
14
|
|
|
@@ -39,13 +39,13 @@ npm ci
|
|
|
39
39
|
npm run check
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
`check` runs strict type checking, offline tests, an isolated
|
|
42
|
+
`check` runs strict type checking, offline tests, an isolated packed-extension smoke test, and a package dry run. The smoke test packs and extracts the package outside the checkout, without the extension's development dependencies, then loads it in real Pi with synthetic credentials and network fetches blocked. It does not touch your installed extensions or credentials. After publication, `npm run smoke -- @specode/pi-antigravity@<version>` validates the registry artifact the same way.
|
|
43
43
|
|
|
44
44
|
The extension entry is `src/index.ts`. Do not load it alongside another provider registered as `antigravity`. Switching your installed provider, live account testing, and publishing are separate steps—not performed by development tests.
|
|
45
45
|
|
|
46
46
|
## Publishing
|
|
47
47
|
|
|
48
|
-
The scoped npm package is
|
|
48
|
+
The scoped npm package is public. GitHub Actions validates pushes and pull requests. npm Trusted Publishing is configured for `specode/pi-antigravity` and `npm-publish.yml`, allowing future GitHub Release publications through OIDC without a long-lived npm token. Version 0.1.0 was bootstrapped through maintainer authentication; releases must use a new package version, never republish an existing one. Publishing and creating releases are external operations and require explicit authorization.
|
|
49
49
|
|
|
50
50
|
## Request flow
|
|
51
51
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
|
-
需要 Node.js >= 22.19.0,以及本实现使用的 Pi 1.5.2 provider API
|
|
11
|
+
需要 Node.js >= 22.19.0,以及本实现使用的 Pi 1.5.2 provider API。全新 npm 安装请使用 0.1.1 或更高版本;0.1.0 的 Pi 子路径导入可能依赖开发目录中的依赖才能解析。
|
|
12
12
|
|
|
13
13
|
从 npm 安装:
|
|
14
14
|
|
|
@@ -39,13 +39,13 @@ npm ci
|
|
|
39
39
|
npm run check
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
`check`
|
|
42
|
+
`check` 包含严格类型检查、离线测试、隔离的发布包加载测试及打包预检。冒烟测试先打包,再解压到源码目录之外,不带扩展的开发依赖,以合成凭据在真实 Pi 中加载并阻止网络 fetch,不触碰用户已安装扩展或凭据。发布后可运行 `npm run smoke -- @specode/pi-antigravity@<version>` 同样验证 registry 中的实际包。
|
|
43
43
|
|
|
44
44
|
扩展入口为 `src/index.ts`。不要与另一个注册 `antigravity` 的 provider 同时加载。切换用户安装、真实账号测试和发布均为独立步骤,不会由开发测试执行。
|
|
45
45
|
|
|
46
46
|
## 发布
|
|
47
47
|
|
|
48
|
-
scoped npm
|
|
48
|
+
scoped npm 包公开访问。GitHub Actions 验证 push 和 pull request。npm 已为 `specode/pi-antigravity` 和 `npm-publish.yml` 配置 Trusted Publishing,后续 GitHub Release 通过 OIDC 发布,不使用长期 npm token。0.1.0 已经维护者认证完成首次发布;后续 Release 必须使用新版本号,不重复发布既有版本。发布和创建 Release 属于外部操作,仍须明确授权。
|
|
49
49
|
|
|
50
50
|
## 请求主流程
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { findPackageJSON } from "node:module";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { getPackageDir } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type * as GoogleShared from "@earendil-works/pi-ai/api/google-shared";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pi 1.5.2 aliases the pi-ai root, but not its api/* subpaths, for extensions.
|
|
10
|
+
* Resolve the host's public export using public Node/Pi APIs instead of relying
|
|
11
|
+
* on this extension's devDependencies or bundling a second Pi implementation.
|
|
12
|
+
*/
|
|
13
|
+
const anchor = join(getPackageDir(), "package.json");
|
|
14
|
+
const manifestPath = findPackageJSON("@earendil-works/pi-ai", pathToFileURL(anchor));
|
|
15
|
+
if (!manifestPath) throw new Error("The Pi host does not provide @earendil-works/pi-ai.");
|
|
16
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as {
|
|
17
|
+
exports?: Record<string, string | { import?: string }>;
|
|
18
|
+
};
|
|
19
|
+
const entry = manifest.exports?.["./api/google-shared"] ?? manifest.exports?.["./api/*"];
|
|
20
|
+
const target = typeof entry === "string" ? entry : entry?.import;
|
|
21
|
+
if (typeof target !== "string" || !target.startsWith("./")) {
|
|
22
|
+
throw new Error("The Pi host does not expose the public Google converter API.");
|
|
23
|
+
}
|
|
24
|
+
const googleShared = await import(
|
|
25
|
+
pathToFileURL(resolve(dirname(manifestPath), target.replace("*", "google-shared"))).href
|
|
26
|
+
) as typeof GoogleShared;
|
|
27
|
+
|
|
28
|
+
export const { convertMessages, convertTools, mapToolChoice } = googleShared;
|
package/src/request.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import type { Api, Model, SimpleStreamOptions, TranscriptContext } from "@earendil-works/pi-ai";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getCurrentSystemPrompt, getCurrentTools } from "@earendil-works/pi-ai";
|
|
4
|
+
import { convertMessages, convertTools, mapToolChoice } from "./google-shared.ts";
|
|
5
5
|
|
|
6
6
|
const PI_OPENING = "You are a coding assistant running inside pi, a coding agent harness. Help users inspect files, run commands, and modify code.";
|
|
7
7
|
const CLI_OPENING = "You are a coding agent helping the user with their project.";
|
package/src/stream.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import type {
|
|
3
3
|
Api, AssistantMessage, AssistantMessageEventStream, JsonObject, Model, SimpleStreamOptions, TranscriptContext,
|
|
4
4
|
} from "@earendil-works/pi-ai";
|
|
5
|
-
import { calculateCost } from "@earendil-works/pi-ai
|
|
6
|
-
import { createAssistantMessageEventStream } from "@earendil-works/pi-ai/utils/event-stream";
|
|
5
|
+
import { calculateCost, createAssistantMessageEventStream } from "@earendil-works/pi-ai";
|
|
7
6
|
import { CLIENT_USER_AGENT, DEFAULT_BASE_URL, assertOfficialBaseUrl } from "./client.ts";
|
|
8
7
|
|
|
9
8
|
export interface AntigravityStreamOptions extends SimpleStreamOptions {
|