@aiti-ai/ext-shared 0.1.8 → 0.1.11

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 ADDED
@@ -0,0 +1,37 @@
1
+ # @aiti-ai/ext-shared
2
+
3
+ > aiti-agent 扩展的服务端共享层:agent-spawn-env(spawn env 治理 / resolveCliLaunch)、seed-tool(历史回放种子)、cursor-cli-store(Cursor CLI 会话读取器)、exec-async、git-ops-client 等共享模块。扩展 package.json 声明依赖后由 extman reconcile 统一装进共享根 node_modules,jiti walk-up 解析。
4
+
5
+ ## 来源 · Origin
6
+
7
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
8
+
9
+ This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
10
+
11
+ - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
12
+ - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
13
+ - 官网 / site: <https://aiti.pw>
14
+
15
+ ## 功能定位(中文)
16
+
17
+ aiti-agent 扩展的服务端共享层:agent-spawn-env(spawn env 治理 / resolveCliLaunch)、seed-tool(历史回放种子)、cursor-cli-store(Cursor CLI 会话读取器)、exec-async、git-ops-client 等共享模块。扩展 package.json 声明依赖后由 extman reconcile 统一装进共享根 node_modules,jiti walk-up 解析。
18
+
19
+ ## Positioning (English)
20
+
21
+ Server-side shared layer for aiti-agent extensions: agent-spawn-env (spawn env governance / resolveCliLaunch), seed-tool (history-replay seeds), cursor-cli-store (Cursor CLI session reader), exec-async, git-ops-client and more. Declared in each extension's package.json and installed into the shared node_modules root by extman reconcile (resolved via jiti walk-up).
22
+
23
+ ## 安装 / 部署
24
+
25
+ 随 aiti-agent 扩展体系部署(extman 安装 / deploy 脚本拷贝到 `~/.pi/web/extensions/`),一般不单独 npm 安装;作为依赖被引用时经 extman reconcile 自动装入共享 node_modules。
26
+
27
+ Deployed as part of the aiti-agent extension system (extman install / deploy scripts copy it to `~/.pi/web/extensions/`); usually not installed standalone.
28
+
29
+ ## 文档 · Documentation
30
+
31
+ - 中文完整文档(aiti-docs): <https://aiti.pw/guide/ext-services.html>
32
+ - English docs: <https://aiti.pw/en/guide/ext-services.html>
33
+ - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
34
+
35
+ ## License
36
+
37
+ MIT
@@ -23,7 +23,7 @@ import {
23
23
  captureSpawnEnvFeatures,
24
24
  } from "./agent-spawn-env.ts";
25
25
 
26
- const PROC_ENV = { PORT: "3001", PI_WEB_BASE_PATH: "/dev", HOME: "/home/pi", PATH: "/usr/bin" };
26
+ const PROC_ENV = { PORT: "30142", PI_WEB_BASE_PATH: "/dev", HOME: "/home/pi", PATH: "/usr/bin" };
27
27
 
28
28
  test("resolveCliLaunch:缺省 command=defaultCommand,args=[...prefix, ...driverArgs]", () => {
29
29
  const r = resolveCliLaunch({
@@ -52,7 +52,7 @@ test("resolveCliLaunch:command 覆盖生效(driverArgs 不含原 CLI 名由
52
52
 
53
53
  test("resolveCliLaunch:generic 路径自动注入 AITI_BRIDGE_URL(本机实例推导)", () => {
54
54
  const r = resolveCliLaunch({ defaultCommand: "job", processEnv: PROC_ENV });
55
- assert.equal(r.env.AITI_BRIDGE_URL, "http://127.0.0.1:3001/dev/api/extensions/aiti-devtools");
55
+ assert.equal(r.env.AITI_BRIDGE_URL, "http://127.0.0.1:30142/dev/api/extensions/aiti-devtools");
56
56
  });
57
57
 
58
58
  test("resolveCliLaunch:显式 env 已带 AITI_BRIDGE_URL 则保持(不重复注入)", () => {
@@ -74,7 +74,7 @@ test("resolveCliLaunch:$VAR / ${cwd} 展开(argsPrefix + memberEnv;工作
74
74
  processEnv: PROC_ENV,
75
75
  cwd: "/tmp/proj",
76
76
  });
77
- assert.deepEqual(r.args, ["-v", "/tmp/proj:/tmp/proj", "-w", "/tmp/proj", "-e", "K=3001"]);
77
+ assert.deepEqual(r.args, ["-v", "/tmp/proj:/tmp/proj", "-w", "/tmp/proj", "-e", "K=30142"]);
78
78
  assert.equal(r.env.WORK, "/tmp/proj/x");
79
79
  assert.equal(r.env.FROM_ENV, "/home/pi/y");
80
80
  assert.equal(r.warnings.length, 0);
@@ -109,11 +109,11 @@ test("resolveCliLaunch:未定义引用 → 空串 + warning(argsPrefix 与 m
109
109
  test("resolveCliLaunch:bridge=host.docker.internal 替换主机保留端口路径", () => {
110
110
  const r = resolveCliLaunch({
111
111
  defaultCommand: "claude",
112
- env: { AITI_BRIDGE_URL: "http://127.0.0.1:3001/dev/api/extensions/aiti-devtools" },
112
+ env: { AITI_BRIDGE_URL: "http://127.0.0.1:30142/dev/api/extensions/aiti-devtools" },
113
113
  bridge: "host.docker.internal",
114
114
  processEnv: PROC_ENV,
115
115
  });
116
- assert.equal(r.env.AITI_BRIDGE_URL, "http://host.docker.internal:3001/dev/api/extensions/aiti-devtools");
116
+ assert.equal(r.env.AITI_BRIDGE_URL, "http://host.docker.internal:30142/dev/api/extensions/aiti-devtools");
117
117
  });
118
118
 
119
119
  test("resolveCliLaunch:bridge=off 移除;显式 URL 直接采用(支持 ${cwd})", () => {
@@ -126,7 +126,7 @@ test("resolveCliLaunch:bridge=off 移除;显式 URL 直接采用(支持 ${
126
126
  processEnv: PROC_ENV,
127
127
  });
128
128
  assert.equal(url.env.AITI_BRIDGE_URL, "http://bridge.local:8777");
129
- assert.equal(url.env.HINT, "http://127.0.0.1:3001/dev/api/extensions/aiti-devtools",
129
+ assert.equal(url.env.HINT, "http://127.0.0.1:30142/dev/api/extensions/aiti-devtools",
130
130
  "成员 env 在 bridge 重写前展开,看到的是重写前值(自动注入默认)");
131
131
  });
132
132
 
@@ -138,7 +138,7 @@ test("resolveCliLaunch:非法 bridge 模式按 inherit + warning;warn 回调
138
138
  processEnv: PROC_ENV,
139
139
  warn: (m) => viaCb.push(m),
140
140
  });
141
- assert.equal(r.env.AITI_BRIDGE_URL, "http://127.0.0.1:3001/dev/api/extensions/aiti-devtools");
141
+ assert.equal(r.env.AITI_BRIDGE_URL, "http://127.0.0.1:30142/dev/api/extensions/aiti-devtools");
142
142
  assert.equal(r.warnings.length, 1);
143
143
  assert.equal(viaCb.length, 1);
144
144
  });
@@ -23,13 +23,13 @@ import {
23
23
  } from "./agent-spawn-env.ts";
24
24
 
25
25
  test("piWebSelfBase:PORT + PI_WEB_BASE_PATH 归一(尾斜杠剥除)", () => {
26
- assert.equal(piWebSelfBase({ PORT: "3001", PI_WEB_BASE_PATH: "/dev/" }), "http://127.0.0.1:3001/dev");
27
- assert.equal(piWebSelfBase({ PORT: "3002", PI_WEB_BASE_PATH: "" }), "http://127.0.0.1:3002");
26
+ assert.equal(piWebSelfBase({ PORT: "30142", PI_WEB_BASE_PATH: "/dev/" }), "http://127.0.0.1:30142/dev");
27
+ assert.equal(piWebSelfBase({ PORT: "20341", PI_WEB_BASE_PATH: "" }), "http://127.0.0.1:20341");
28
28
  assert.equal(piWebSelfBase({ PI_WEB_BASE_PATH: "/dev" }), "http://127.0.0.1:3000/dev", "缺 PORT 回落 3000");
29
29
  });
30
30
 
31
31
  test("bridgeEnv:端点带扩展路径签名", () => {
32
- assert.equal(bridgeEnv({ PORT: "3002" }).AITI_BRIDGE_URL, "http://127.0.0.1:3002/api/extensions/aiti-devtools");
32
+ assert.equal(bridgeEnv({ PORT: "20341" }).AITI_BRIDGE_URL, "http://127.0.0.1:20341/api/extensions/aiti-devtools");
33
33
  });
34
34
 
35
35
  test("parseEnvList:设置/排除/注释/非法行", () => {
@@ -85,7 +85,7 @@ test("agentSpawnEnv:白名单 < 自动 bridge < 用户列表(可覆盖自动
85
85
  cli: "zcode",
86
86
  governance,
87
87
  envList: "AITI_BRIDGE_URL=http://override:1/mcp\nUSERV=$UNDEF2",
88
- processEnv: { PORT: "3002", UNDEF2: "pv" },
88
+ processEnv: { PORT: "20341", UNDEF2: "pv" },
89
89
  warn: () => {},
90
90
  });
91
91
  assert.equal(out.PATH, "/bin");
@@ -99,7 +99,7 @@ test("agentSpawnEnv:-NAME 急救——拔掉透传漏进来的变量,也可
99
99
  cli: "zcode",
100
100
  governance,
101
101
  envList: "-LEAKY\n-AITI_BRIDGE_URL",
102
- processEnv: { PORT: "3002" },
102
+ processEnv: { PORT: "20341" },
103
103
  warn: () => {},
104
104
  });
105
105
  assert.equal("LEAKY" in out, false, "排除治理透传变量");
@@ -48,7 +48,7 @@ export function registerSpawnEnvDefaults(extId: string, list: string): void {
48
48
  }
49
49
 
50
50
  /** pi-web 自身实例基地址(同进程推导;127.0.0.1 直连不走 nginx/Authelia)。
51
- * dev=3001 + /dev、prod=3002 + 空(48);155/23 随各自服务单元的 PORT/PI_WEB_BASE_PATH。 */
51
+ * dev=30142 + /dev、prod=20341 + 空(48);155/23 随各自服务单元的 PORT/PI_WEB_BASE_PATH。 */
52
52
  export function piWebSelfBase(processEnv?: Record<string, string | undefined>): string {
53
53
  const env = processEnv ?? (process.env as Record<string, string | undefined>);
54
54
  const port = env.PORT || "3000";
package/dev-pack.mjs CHANGED
@@ -54,11 +54,11 @@ export function agentsMdTemplate(extId) {
54
54
  ## 小改现场流程(改文案/样式/小逻辑)
55
55
  1. 改 \`src/\` 下对应源码
56
56
  2. \`node tools/build.mjs\`(client 有构建产物的扩展;纯服务端改动跳过)
57
- 3. \`curl -X POST http://127.0.0.1:3001/api/extensions/reload\`(dev;prod 3002;外部经 nginx 带 basePath:/dev、/mac、/mdev、/win、/wdev → \`/xxx/api/extensions/reload\`)
57
+ 3. \`curl -X POST http://127.0.0.1:30142/api/extensions/reload\`(dev;prod 20341;外部经 nginx 带 basePath:/dev、/mac、/mdev、/win、/wdev → \`/xxx/api/extensions/reload\`)
58
58
  4. 浏览器刷新页面验证
59
59
 
60
60
  ## 大改回源码仓
61
- - 源码仓:\`extensions/${extId}/\`(git 管理,deploy 同步回本目录)
61
+ - 源码仓:\`~/workspace/pi-work/pi-web-ext/${extId}/\`(git 管理,deploy 同步回本目录)
62
62
  - 改完在源码仓跑 \`node tools/deploy.mjs\`(或仓库根 \`node scripts/deploy-all.mjs --only ${extId}\`)
63
63
 
64
64
  ## 数据目录(数据分层:config / cache)
@@ -69,7 +69,7 @@ export function agentsMdTemplate(extId) {
69
69
 
70
70
  ## 红线
71
71
  - 禁轮询(setInterval 拉取);需要等待用事件/回调/SSE(桥的 SSE、aiti-event-bus topics)
72
- - 禁重启生产服务(pi-web 3002 等 restart 须用户明确同意)
72
+ - 禁重启生产服务(pi-web 20341 等 restart 须用户明确同意)
73
73
  - 禁手改 dist/ 与运行时平铺文件;跨扩展通信走 ctx.services(禁 globalThis.__ext 直穿)
74
74
  - 服务端:SQLite 一律 WAL + 分批小事务(批间 setImmediate 让步);禁 execFileSync 调 >1s 外部程序;>8MB 文件禁同步读
75
75
  `;
@@ -7,10 +7,10 @@
7
7
  *
8
8
  * node tools/lazy-loading-metrics.mjs [baseUrl] [timeoutMs]
9
9
  *
10
- * 默认 baseUrl = http://127.0.0.1:3001/dev(dev 实例)。生产传 https://pi.example.com。
10
+ * 默认 baseUrl = http://127.0.0.1:30142/dev(dev 实例)。生产传 https://pi.example.com。
11
11
  * 依赖:无(Node 内置 fetch;页面侧注入采集脚本经 CDP 不可用时降级为 bundle 字节求和)。
12
12
  */
13
- const base = (process.argv[2] || "http://127.0.0.1:3001/dev").replace(/\/$/, "");
13
+ const base = (process.argv[2] || "http://127.0.0.1:30142/dev").replace(/\/$/, "");
14
14
  const manifestUrl = `${base}/api/extensions/manifest`;
15
15
 
16
16
  const d = await fetch(manifestUrl).then((r) => r.json()).catch(() => null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiti-ai/ext-shared",
3
- "version": "0.1.8",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "description": "pi-web 扩展共享层(_shared 原地 package 化)——exports 子路径逐文件暴露",
6
6
  "exports": {
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "license": "MIT",
56
56
  "aitiExtProtocol": "1.0",
57
- "contentHash": "98e4559181401cb6",
57
+ "contentHash": "5946d83874103ee4",
58
58
  "repository": {
59
59
  "type": "git",
60
60
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * _shared/reload-instances.mjs · pi-web 双实例热重载(各扩展 deploy.mjs 共用)
3
3
  *
4
- * dev 3001 / 生产 3002;端口可经 AITI_DEV_PORT / AITI_PROD_PORT 覆盖;
4
+ * dev 30142 / 生产 20341;端口可经 AITI_DEV_PORT / AITI_PROD_PORT 覆盖;
5
5
  * basePath 双 env(AITI_DEV_BASE_PATH / AITI_PROD_BASE_PATH)按机器设值,
6
6
  * 推荐值不带斜杠(48:dev 与 空;155:系统级 wdev 与 win)——git-bash 启动
7
7
  * 原生程序时会把 / 开头的 env 值做 MSYS 路径转换(/wdev → D:/apps/Git/wdev)
@@ -28,8 +28,8 @@ function buildInstance(name, portEnv, portDefault, pathEnv, pathDefault) {
28
28
  /** 双实例清单(dev/prod 各 {name, base});reload-instances 与 reconcile-deps 等共用。 */
29
29
  export function buildInstances() {
30
30
  return [
31
- buildInstance("dev", "AITI_DEV_PORT", 3001, "AITI_DEV_BASE_PATH", "/dev"),
32
- buildInstance("prod", "AITI_PROD_PORT", 3002, "AITI_PROD_BASE_PATH", ""),
31
+ buildInstance("dev", "AITI_DEV_PORT", 30142, "AITI_DEV_BASE_PATH", "/dev"),
32
+ buildInstance("prod", "AITI_PROD_PORT", 20341, "AITI_PROD_BASE_PATH", ""),
33
33
  ];
34
34
  }
35
35