personal-bot 0.3.3 → 0.3.5
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/bin/pbot.mjs +3 -17
- package/docs/architecture/design.md +8 -6
- package/docs/architecture/extensibility.md +21 -0
- package/docs/architecture/principles.md +1 -1
- package/docs/guides/workspace-configuration.md +13 -0
- package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
- package/lib/antigravity-plugin/lib/common/paths.js +2 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +26 -24
- package/lib/antigravity-plugin/lib/extension/cli.js +22596 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +9 -2
- package/lib/antigravity-plugin/lib/extension/mcp.js +22 -20
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +5 -20121
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +12 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +52 -4
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +1 -1
- package/lib/common/paths.d.ts +1 -0
- package/lib/common/paths.js +2 -0
- package/lib/extension/acp-worker.js +26 -24
- package/lib/extension/cli.js +22596 -0
- package/lib/extension/hosts/plugin-runtime.js +9 -2
- package/lib/extension/mcp.js +22 -20
- package/lib/extension/workspace-cli.js +5 -20121
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +1 -1
- package/lib/services/workspace/plugin-releases.d.ts +12 -0
- package/lib/services/workspace/plugin-releases.js +52 -4
- package/package.json +1 -1
- package/scripts/README.md +1 -1
- package/src/common/paths.ts +2 -0
- package/src/extension/cli/args.ts +104 -0
- package/src/extension/cli/commands/history.ts +81 -0
- package/src/extension/cli/commands/mcp.ts +165 -0
- package/src/extension/cli/commands/plugin.ts +33 -0
- package/src/extension/cli/commands/setup.ts +159 -0
- package/src/extension/cli/commands/upgrade.ts +158 -0
- package/src/extension/cli/commands/workspace.ts +71 -0
- package/src/extension/cli/index.ts +193 -0
- package/src/extension/cli/types.ts +30 -0
- package/src/extension/hosts/plugin-runtime.ts +9 -2
- package/src/integrations/installation/cli-update.ts +31 -3
- package/src/integrations/installation/pi-setup.ts +6 -3
- package/src/integrations/installation/upgraders/antigravity.ts +68 -0
- package/src/integrations/installation/upgraders/claude.ts +123 -0
- package/src/integrations/installation/upgraders/codex.ts +73 -0
- package/src/integrations/installation/upgraders/dsh.ts +63 -0
- package/src/integrations/installation/upgraders/pi.ts +87 -0
- package/src/integrations/installation/upgraders/qoder.ts +68 -0
- package/src/integrations/installation/upgraders/registry.ts +48 -0
- package/src/model/installation.ts +45 -0
- package/src/services/installation/setup-service.ts +0 -30
- package/src/services/installation/upgrade-service.ts +127 -0
- package/src/services/workspace/plugin-releases.ts +57 -4
- package/lib/extension/setup/cli.js +0 -352
- package/lib/integrations/installation/pi-setup.js +0 -193
- package/lib/integrations/installation/processes.js +0 -140
- package/lib/integrations/installation/workspace.js +0 -21
- package/lib/services/installation/setup-service.js +0 -137
- package/lib/ui/setup.js +0 -52
- package/src/extension/setup/cli.ts +0 -296
- package/src/extension/setup/workspace-cli.ts +0 -159
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "personal-bot",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.5",
|
|
10
10
|
"description": "Workspace materials, skills, and cross-harness MCP worker delegation.",
|
|
11
11
|
"source": {
|
|
12
12
|
"source": "npm",
|
|
13
13
|
"package": "personal-bot",
|
|
14
|
-
"version": "0.3.
|
|
14
|
+
"version": "0.3.5"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
]
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Missing, disabled, or invalid configuration keeps Personal Bot inactive without
|
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
23
|
-
The workspace CLI runs from the workspace root or accepts `--workspace <dir>`. Install it with `npm install -g personal-bot`, or use `npx personal-bot@<installed-plugin-version>`. Use `pbot init`, `pbot status` and `pbot history status|list|summary|migrate|search|read`. During initialization and in enabled workspaces, the CLI selects a version that meets the registered plugins’ requirements. [CLI and history guide](docs/guides/history.md)
|
|
23
|
+
The workspace CLI runs from the workspace root or accepts `--workspace <dir>`. Install it with `npm install -g personal-bot`, or use `npx personal-bot@<installed-plugin-version>`. Use `pbot init`, `pbot status`, `pbot upgrade|update`, and `pbot history status|list|summary|migrate|search|read`. Run `pbot upgrade` to update the global CLI and all host plugins bound to the current workspace to the latest stable npm release. During initialization and in enabled workspaces, the CLI also selects a version that meets the registered plugins’ requirements. [Workspace configuration](docs/guides/workspace-configuration.md) · [CLI and history guide](docs/guides/history.md)
|
|
24
24
|
|
|
25
25
|
### Pi
|
|
26
26
|
|
|
@@ -100,7 +100,7 @@ Supports built-in presets (`pi`, `dsh`, `claude`, `antigravity`, `codex`, `qoder
|
|
|
100
100
|
|
|
101
101
|
## Development
|
|
102
102
|
|
|
103
|
-
The package version is **0.3.
|
|
103
|
+
The package version is **0.3.4**. Full development uses Linux/macOS and Node.js 24.9+:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
npm ci --ignore-scripts
|
package/README.zh-CN.md
CHANGED
|
@@ -20,7 +20,7 @@ Personal Bot 为多宿主环境([Pi](https://pi.dev)、dsh、Claude Code、Ant
|
|
|
20
20
|
|
|
21
21
|
## 安装
|
|
22
22
|
|
|
23
|
-
在工作区根目录运行 CLI,或用 `--workspace <目录>` 指定。全局安装用 `npm install -g personal-bot`,临时运行用 `npx personal-bot@<插件版本>`。所有宿主共用 `pbot init`、`pbot status` 和 `pbot history status|list|summary|migrate|search|read
|
|
23
|
+
在工作区根目录运行 CLI,或用 `--workspace <目录>` 指定。全局安装用 `npm install -g personal-bot`,临时运行用 `npx personal-bot@<插件版本>`。所有宿主共用 `pbot init`、`pbot status`、`pbot upgrade|update` 和 `pbot history status|list|summary|migrate|search|read`。运行 `pbot upgrade` 可将全局 CLI 与当前工作区已绑定的各宿主插件统一升级到 npm 最新稳定版;显式初始化或在已启用的工作区执行命令时,CLI 也会自动选择满足插件要求的版本。详见[工作区配置](docs/guides/workspace-configuration.md)与[历史与 CLI 指南](docs/guides/history.md)。
|
|
24
24
|
|
|
25
25
|
### Pi
|
|
26
26
|
|
|
@@ -100,7 +100,7 @@ pbot mcp
|
|
|
100
100
|
|
|
101
101
|
## 开发与验证
|
|
102
102
|
|
|
103
|
-
当前版本 **0.3.
|
|
103
|
+
当前版本 **0.3.4**。完整开发使用 Linux/macOS、Node.js 24.9+:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
npm ci --ignore-scripts
|
package/bin/pbot.mjs
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { main } from "../lib/extension/cli.js";
|
|
3
|
+
|
|
3
4
|
try {
|
|
4
|
-
|
|
5
|
-
const { main } = await import("../lib/extension/workspace-cli.js");
|
|
6
|
-
process.exitCode = await main(args);
|
|
7
|
-
} else {
|
|
8
|
-
const { updateForCommand, updateForWorkspace } = await import("../lib/extension/workspace-cli.js");
|
|
9
|
-
const updated = args.length && !["-h", "--help"].includes(args[0]) ? await updateForCommand(args) : undefined;
|
|
10
|
-
if (updated !== undefined) {
|
|
11
|
-
process.exitCode = updated;
|
|
12
|
-
} else if (args[0] === "plugin") {
|
|
13
|
-
const { main } = await import("../lib/plugin.js");
|
|
14
|
-
await main(args.slice(1), (root, input) => updateForWorkspace(root, args, input));
|
|
15
|
-
} else {
|
|
16
|
-
const { main } = await import("../lib/extension/setup/cli.js");
|
|
17
|
-
process.exitCode = await main(args);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
5
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
20
6
|
} catch (error) {
|
|
21
7
|
console.error(error instanceof Error ? error.message : String(error));
|
|
22
8
|
process.exitCode = 1;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
| `src/pbot.ts` / `src/dsh.ts` | Pi 与 dsh Host 装配(工作区生命周期、历史工具、原生 MCP 挂载) |
|
|
22
22
|
| `src/plugin.ts` / `src/claude.ts` | 通用插件宿主 CLI/hook 入口(查 `PluginHostRegistry`)与 Claude 兼容入口 |
|
|
23
23
|
| `src/mcp.ts` | 独立 stdio MCP 服务入口,暴露 6 个 `worker_*` 工具,按工作区功能与宿主原生挂载情况提供共享 MCP 和历史查询 |
|
|
24
|
-
| `src/extension/` | 运行时编排。 `hosts/` 装配宿主,`mcp/` 提供 MCP 服务与桥接,`acp/` 启动 worker,`history/` 执行共享历史命令,`
|
|
24
|
+
| `src/extension/` | 运行时编排。 `hosts/` 装配宿主,`mcp/` 提供 MCP 服务与桥接,`acp/` 启动 worker,`history/` 执行共享历史命令,`cli/` 提供统一 CLI 路由与各子命令实现,`setup/` 提供 Pi 初始化保护 |
|
|
25
25
|
| `src/integrations/` | 按外部集成域划分的适配器:`hosts/`(各宿主平级目录 `pi/`、`dsh/`、`claude/`、`antigravity/` 及 `plugin-registry.ts`)、`acp/`(协议、`harnesses/` 与独立摘要执行器 `history-summary.ts`)、`installation/`(安装桥接),以及跨宿主辅助(`agent-resources.ts`) |
|
|
26
26
|
| `src/services/` | 宿主无关业务规则(`agents/`、`workspace/`、`history/`、`installation/`) |
|
|
27
27
|
| `src/model/` | 纯数据类型与窄能力契约(`plugin-host.ts`、`acp.ts`、`agent.ts`、`history.ts`、`workspace-config.ts`),不含实现或宿主 SDK 类型 |
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
2. **跨宿主协议与运行域**:
|
|
42
42
|
- **ACP Harness**:实现 `AcpHarnessAdapter` 放入 `src/integrations/acp/harnesses/<name>.ts` 并在 `src/integrations/acp/registry.ts` 注册;运行时在 `src/extension/acp/`;辅助模块避免与适配器重名(如 `acp/claude-settings.ts`)。
|
|
43
43
|
- **MCP 服务与桥接**:统一放在 `src/extension/mcp/`。
|
|
44
|
-
-
|
|
44
|
+
- **统一 CLI 与安装器**:CLI 路由与命令处理器在 `src/extension/cli/`,Pi 初始化保护在 `src/extension/setup/guard.ts`,外部环境桥接与宿主升级器在 `src/integrations/installation/`。
|
|
45
45
|
3. **宿主无关业务与共享模块**:业务规则放 `src/services/<domain>/`,纯数据契约放 `src/model/`,存储放 `src/storage/`,跨宿主 UI/展示辅助放 `src/ui/` 顶层。
|
|
46
46
|
|
|
47
47
|
所有单向依赖与宿主 SDK 隔离规则由 `.dependency-cruiser.cjs` 静态强制。`common/validation` 保持零第三方依赖,`common/schema`(Ajv)仅由 Pi/dsh 历史工具与管理查询显式引入。
|
|
@@ -69,13 +69,15 @@
|
|
|
69
69
|
- `atomic-json` 先校验对象再写入临时文件并原子替换,拒绝符号链接、路径越界与特殊文件;短目录锁(`.control` / `.write-<host>`)串行化控制写操作。
|
|
70
70
|
- 兼容线规则:发布版本遵循 `package.json` 的 `MAJOR.MINOR.PATCH`,1.0 前按次版本、之后按主版本判断控制记录兼容性,不引入自动迁移或存储版本计数器。
|
|
71
71
|
|
|
72
|
-
##
|
|
72
|
+
## 统一 CLI(`pbot`)
|
|
73
73
|
|
|
74
|
-
`bin/pbot.mjs`
|
|
75
|
-
- `pbot init|status` 与 `pbot history status|list|summary|migrate|search|read
|
|
74
|
+
`bin/pbot.mjs` 直接委派给独立打包的 `lib/extension/cli.js`(同时保留 `lib/extension/workspace-cli.js` 兼容入口供既有插件技能调用),由 `src/extension/cli/index.ts` 统一负责参数提取(`--workspace`、`--json`、`--help`)、本地探针(`--version`、`--at-least`)、工作区版本自动更新中间件与声明式命令分发:
|
|
75
|
+
- `pbot init|status` 与 `pbot history status|list|summary|migrate|search|read`:与 Pi/dsh 共用 `src/extension/history/command.ts`。根目录、精确版本和输出契约见[历史与 CLI 指南](../guides/history.md)。
|
|
76
|
+
- `pbot upgrade|update [--workspace <dir>] [--version <ver>] [--hosts <h1,h2>] [--dsh-profile <name>] [--json]`:统一升级全局 CLI 与当前工作区已绑定的各宿主插件。
|
|
77
|
+
- `pbot mcp [list|add|remove ...]`:无参数时运行独立打包的 `lib/extension/mcp.js` 供任意 MCP 客户端连接;带子命令时管理工作区 `.pbot/mcp.json`。
|
|
78
|
+
- `pbot plugin <host> hook|init|status`:经 `PluginHostRegistry` 运行轻插件宿主的无状态 hook 或工作区命令。
|
|
76
79
|
- `pbot setup [--workspace <dir>]`:交互式检查环境、安装/更新 Pi 与工作区扩展,保留自定义本地/Git/固定来源,完成后通过临时 `setup-guard` 启动 Pi 执行 `/pbot init`。
|
|
77
80
|
- `pbot install-antigravity`:调用原生 `agy plugin install ./lib/antigravity-plugin` 安装或更新 Antigravity 插件。
|
|
78
|
-
- `pbot mcp`:直接运行独立打包的 `lib/extension/mcp.js` 供任意 MCP 客户端连接。
|
|
79
81
|
|
|
80
82
|
## 构建与分发
|
|
81
83
|
|
|
@@ -84,3 +84,24 @@ MCP Server (src/extension/mcp/workers.ts) -> AgentService -> AcpWorkerHost -> sr
|
|
|
84
84
|
- 每次调用动态读取工作区 `.pbot/config.json` 并刷新 `acp` 映射,新增自定义 Harness 即改即生效。
|
|
85
85
|
- 支持 `PBOT_MCP_SESSION_ID` 与 `PBOT_MCP_AGENT_DIR`,使 Pi/dsh 的 `/pbot worker` 命令与自动挂载的 MCP 进程共享同一会话归属。
|
|
86
86
|
- `lib/extension/mcp.js` 与 `lib/extension/acp-worker.js` 通过 `esbuild` 独立打包,确保插件缓存目录在无 `node_modules` 环境下稳定运行。
|
|
87
|
+
|
|
88
|
+
## 4. 可扩展宿主升级适配器(`HostUpgraderRegistry`)
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
pbot upgrade|update (src/extension/cli/commands/upgrade.ts)
|
|
92
|
+
↓
|
|
93
|
+
src/services/installation/upgrade-service.ts (宿主无关编排与单宿主容错)
|
|
94
|
+
↓
|
|
95
|
+
HostUpgraderRegistry (src/integrations/installation/upgraders/registry.ts)
|
|
96
|
+
├── piUpgrader (src/integrations/installation/upgraders/pi.ts)
|
|
97
|
+
├── claudeUpgrader (src/integrations/installation/upgraders/claude.ts)
|
|
98
|
+
├── antigravityUpgrader (src/integrations/installation/upgraders/antigravity.ts)
|
|
99
|
+
├── codexUpgrader (src/integrations/installation/upgraders/codex.ts)
|
|
100
|
+
├── qoderUpgrader (src/integrations/installation/upgraders/qoder.ts)
|
|
101
|
+
├── dshUpgrader (src/integrations/installation/upgraders/dsh.ts)
|
|
102
|
+
└── <自定义宿主升级器> (通过 registerHostUpgrader 动态注册)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- `HostUpgrader` 契约定义在 `src/model/installation.ts`(`host: string` + `upgrade(context): Promise<HostUpgradeResult>`)。
|
|
106
|
+
- 升级编排主链路只按当前工作区绑定的宿主列表(`~/.pbot/workspaces/<hash>/*.json` 与本地 `.pi/`)动态查表调用,不感知具体宿主实现;单宿主失败或跳过不阻塞其余宿主。
|
|
107
|
+
- 接入新宿主升级能力只需新增 `src/integrations/installation/upgraders/<host>.ts` 并在 `registry.ts` 注册,无需修改 `upgrade-service.ts` 或 `upgrade.ts`。
|
|
@@ -21,7 +21,7 @@ Personal Bot 不绑定单一宿主,所有能力按两条正交主线组织:
|
|
|
21
21
|
## 保持单向依赖与对称目录维度
|
|
22
22
|
|
|
23
23
|
- 宿主入口与 extension 装配服务和适配器。tools 调用服务,UI 经宿主接口取得业务数据。services 与 integrations 通过 model 共享能力契约,两层分别访问所需存储。直接依赖见[技术设计](design.md),静态边界由 `.dependency-cruiser.cjs` 检查。
|
|
24
|
-
- `src/extension/` 按运行域划分为 `hosts/`、`mcp/`、`acp/`、`history/` 和 `setup/`。宿主与 CLI 在 `history/` 共用历史命令。 `src/integrations/` 按外部集成域划分为 `hosts/`、`acp/` 和 `installation/`。具体宿主在 `hosts/` 下平级建目录。详见[技术设计](design.md)。
|
|
24
|
+
- `src/extension/` 按运行域划分为 `hosts/`、`mcp/`、`acp/`、`history/`、`cli/` 和 `setup/`。宿主与 CLI 在 `history/` 共用历史命令。 `src/integrations/` 按外部集成域划分为 `hosts/`、`acp/` 和 `installation/`。具体宿主在 `hosts/` 下平级建目录。详见[技术设计](design.md)。
|
|
25
25
|
- 资源的创建、状态变更和释放由同一责任主体管理。工具与服务绑定工作区实例,关闭后旧调用失效。
|
|
26
26
|
|
|
27
27
|
## 区分两类文档方法论
|
|
@@ -15,6 +15,19 @@
|
|
|
15
15
|
|
|
16
16
|
`init` 先补建资料目录(`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/`)和缺失的根 `AGENTS.md`,再将 `.pbot/config.json` 中的 `enabled` 设为 `true` 并显式写入 `features`(`prompts`、`skills`、`mcp`、`history`,未设置项默认 `true`)与 `summary`(`backend: "pi"`、`concurrency: 3`),保留已有资料、宿主自有文件(如 `CLAUDE.md`)、已设置的开关/摘要配置及其他未知配置字段;配置文件损坏时先报错而不覆写。
|
|
17
17
|
|
|
18
|
+
## 统一升级工作区多宿主插件
|
|
19
|
+
|
|
20
|
+
当同一工作区交替使用多个宿主(如 Claude Code、Codex、Pi、Antigravity、Qoder CLI、dsh)时,各宿主激活后会在 `~/.pbot/workspaces/<工作区hash>/` 记录绑定版本;若检测到版本不一致,`pbot status` 会标记 `outOfSync: true`,会话启动时也会提示同步。在终端执行:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pbot upgrade [--workspace <目录>] [--version <版本>] [--hosts <h1,h2>] [--dsh-profile <名称>] [--json]
|
|
24
|
+
# 等价别名
|
|
25
|
+
pbot update [--workspace <目录>]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- 默认将全局 `pbot` CLI 与当前工作区已绑定的宿主插件统一升级到 npm 最新稳定版(本地开发或 `npm link` 安装跳过全局 CLI 覆盖)。
|
|
29
|
+
- 遵循最小影响原则:仅处理当前工作区已绑定的宿主并保留既有安装作用域(Pi 仅更新工作区 `--local` 的 `personal-bot`、非 npm 自定义来源跳过;Claude 保留原有的 `local`/`project`/`user` 作用域;dsh 自动从绑定路径识别 profile 或通过 `--dsh-profile` 指定,不强杀运行中的服务)。
|
|
30
|
+
|
|
18
31
|
## 启用、模块开关(`features`)与停用规则
|
|
19
32
|
|
|
20
33
|
```json
|
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/extension/acp/worker.ts
|
|
8
8
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
9
|
-
import { dirname as dirname4, join as join11, resolve as
|
|
9
|
+
import { dirname as dirname4, join as join11, resolve as resolve6 } from "node:path";
|
|
10
10
|
|
|
11
11
|
// src/storage/agent-files.ts
|
|
12
12
|
import { existsSync, mkdirSync as mkdirSync3, readdirSync, rmSync } from "node:fs";
|
|
@@ -4000,7 +4000,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
4000
4000
|
var NONE = 0;
|
|
4001
4001
|
var ASSUMED = 1;
|
|
4002
4002
|
var PROVEN = 2;
|
|
4003
|
-
function isRecursive(inst, stack,
|
|
4003
|
+
function isRecursive(inst, stack, resolve7) {
|
|
4004
4004
|
const cached2 = recursive.get(inst);
|
|
4005
4005
|
if (cached2 !== void 0)
|
|
4006
4006
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4010,7 +4010,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
4010
4010
|
let result = NONE;
|
|
4011
4011
|
const check = (child) => {
|
|
4012
4012
|
if (result !== PROVEN && child?._zod) {
|
|
4013
|
-
const answer = isRecursive(child, stack,
|
|
4013
|
+
const answer = isRecursive(child, stack, resolve7);
|
|
4014
4014
|
if (answer > result)
|
|
4015
4015
|
result = answer;
|
|
4016
4016
|
}
|
|
@@ -4021,7 +4021,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
4021
4021
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
4022
4022
|
if (spread && !desc.enumerable)
|
|
4023
4023
|
continue;
|
|
4024
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4024
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve7) : NONE;
|
|
4025
4025
|
if (child > answer)
|
|
4026
4026
|
answer = child;
|
|
4027
4027
|
}
|
|
@@ -4085,7 +4085,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
4085
4085
|
break;
|
|
4086
4086
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4087
4087
|
case "lazy": {
|
|
4088
|
-
const inner = def._cachedInner ?? (
|
|
4088
|
+
const inner = def._cachedInner ?? (resolve7 ? inst._zod.innerType : void 0);
|
|
4089
4089
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4090
4090
|
break;
|
|
4091
4091
|
}
|
|
@@ -8536,11 +8536,11 @@ var Connection = class {
|
|
|
8536
8536
|
const id = this.nextRequestId++;
|
|
8537
8537
|
let cancel = () => {
|
|
8538
8538
|
};
|
|
8539
|
-
const response = new Promise((
|
|
8539
|
+
const response = new Promise((resolve7, reject) => {
|
|
8540
8540
|
const pendingResponse = {
|
|
8541
8541
|
resolve: (value) => {
|
|
8542
8542
|
try {
|
|
8543
|
-
|
|
8543
|
+
resolve7(mapResponse ? mapResponse(value) : value);
|
|
8544
8544
|
} catch (error2) {
|
|
8545
8545
|
reject(error2);
|
|
8546
8546
|
}
|
|
@@ -8601,8 +8601,8 @@ var Connection = class {
|
|
|
8601
8601
|
this.stream = stream;
|
|
8602
8602
|
this.staticHandlers = handlers;
|
|
8603
8603
|
this.fallbackHandlers = [...options?.fallbackHandlers ?? []];
|
|
8604
|
-
this.closedPromise = new Promise((
|
|
8605
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
8604
|
+
this.closedPromise = new Promise((resolve7) => {
|
|
8605
|
+
this.abortController.signal.addEventListener("abort", () => resolve7());
|
|
8606
8606
|
});
|
|
8607
8607
|
void this.receive();
|
|
8608
8608
|
}
|
|
@@ -9667,8 +9667,8 @@ var AsyncQueue = class {
|
|
|
9667
9667
|
if (this.failed) {
|
|
9668
9668
|
return Promise.reject(this.failure);
|
|
9669
9669
|
}
|
|
9670
|
-
return new Promise((
|
|
9671
|
-
this.waiters.push({ resolve:
|
|
9670
|
+
return new Promise((resolve7, reject) => {
|
|
9671
|
+
this.waiters.push({ resolve: resolve7, reject });
|
|
9672
9672
|
});
|
|
9673
9673
|
}
|
|
9674
9674
|
};
|
|
@@ -10357,11 +10357,13 @@ releaseLine(packageVersion);
|
|
|
10357
10357
|
// src/integrations/acp/claude-settings.ts
|
|
10358
10358
|
import { createRequire } from "node:module";
|
|
10359
10359
|
import { pathToFileURL } from "node:url";
|
|
10360
|
-
import { basename, join as join4, resolve } from "node:path";
|
|
10360
|
+
import { basename, join as join4, resolve as resolve2 } from "node:path";
|
|
10361
10361
|
|
|
10362
10362
|
// src/common/paths.ts
|
|
10363
|
+
import { resolve } from "node:path";
|
|
10363
10364
|
import { fileURLToPath } from "node:url";
|
|
10364
10365
|
var resourceRoot = fileURLToPath(new URL("../../resources/", import.meta.url));
|
|
10366
|
+
var packageRoot = resolve(resourceRoot, "..");
|
|
10365
10367
|
|
|
10366
10368
|
// src/integrations/acp/claude-settings.ts
|
|
10367
10369
|
var levels = ["low", "medium", "high", "xhigh", "max"];
|
|
@@ -10369,7 +10371,7 @@ async function claudeOptions(command, cwd, supplied, includeSkills = true) {
|
|
|
10369
10371
|
const normalized = supplied?.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
10370
10372
|
const requested = normalized === "extrahigh" ? "xhigh" : normalized;
|
|
10371
10373
|
const script = command.args[0];
|
|
10372
|
-
const anchor2 = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ?
|
|
10374
|
+
const anchor2 = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ? resolve2(cwd, script) : command.command;
|
|
10373
10375
|
const require2 = createRequire(pathToFileURL(anchor2));
|
|
10374
10376
|
const sdk = await import(pathToFileURL(require2.resolve("@anthropic-ai/claude-agent-sdk")).href);
|
|
10375
10377
|
requireThat(object(sdk) && typeof sdk.resolveSettings === "function", "Claude ACP \u9700\u8981\u63D0\u4F9B resolveSettings \u7684\u539F\u751F SDK\u3002");
|
|
@@ -10520,9 +10522,9 @@ import { join as join6 } from "node:path";
|
|
|
10520
10522
|
|
|
10521
10523
|
// src/integrations/acp/executable.ts
|
|
10522
10524
|
import { accessSync, constants as constants2, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
10523
|
-
import { delimiter, isAbsolute as isAbsolute2, resolve as
|
|
10525
|
+
import { delimiter, isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
|
|
10524
10526
|
function findAcpExecutable(command) {
|
|
10525
|
-
const candidates = isAbsolute2(command) ? [command] : (process.env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) =>
|
|
10527
|
+
const candidates = isAbsolute2(command) ? [command] : (process.env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve3(directory, command));
|
|
10526
10528
|
for (const candidate of candidates) {
|
|
10527
10529
|
try {
|
|
10528
10530
|
accessSync(candidate, constants2.X_OK);
|
|
@@ -10749,10 +10751,10 @@ function acpChoices(options) {
|
|
|
10749
10751
|
}
|
|
10750
10752
|
|
|
10751
10753
|
// src/integrations/acp/mcp.ts
|
|
10752
|
-
import { isAbsolute as isAbsolute3, resolve as
|
|
10754
|
+
import { isAbsolute as isAbsolute3, resolve as resolve4 } from "node:path";
|
|
10753
10755
|
function resolveStdioCommand(command, cwd) {
|
|
10754
10756
|
if (isAbsolute3(command)) return command;
|
|
10755
|
-
if (command.includes("/") || command.includes("\\")) return
|
|
10757
|
+
if (command.includes("/") || command.includes("\\")) return resolve4(cwd, command);
|
|
10756
10758
|
return findAcpExecutable(command) ?? command;
|
|
10757
10759
|
}
|
|
10758
10760
|
function toAcpMcpServers(servers) {
|
|
@@ -10792,7 +10794,7 @@ async function openAcp(reference, cwd, env, callbacks, signal, openOptions = {})
|
|
|
10792
10794
|
const child = spawn(reference.command, reference.args, { cwd, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
10793
10795
|
const lifetime = new AbortController();
|
|
10794
10796
|
const cancel = AbortSignal.any([signal, lifetime.signal]);
|
|
10795
|
-
const exited = new Promise((
|
|
10797
|
+
const exited = new Promise((resolve7) => child.once("close", () => resolve7()));
|
|
10796
10798
|
child.once("error", (error2) => lifetime.abort(error2));
|
|
10797
10799
|
child.once("exit", (code, termination) => lifetime.abort(new Error("ACP \u8FDB\u7A0B\u9000\u51FA\uFF1A" + (termination ?? code))));
|
|
10798
10800
|
child.stderr.resume();
|
|
@@ -11159,7 +11161,7 @@ async function readWorkspaceConfig(root) {
|
|
|
11159
11161
|
|
|
11160
11162
|
// src/services/workspace/workspace-mcp.ts
|
|
11161
11163
|
import { mkdir as mkdir2, readFile as readFile3 } from "node:fs/promises";
|
|
11162
|
-
import { dirname as dirname3, join as join9, resolve as
|
|
11164
|
+
import { dirname as dirname3, join as join9, resolve as resolve5 } from "node:path";
|
|
11163
11165
|
var serverNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
11164
11166
|
var reservedServerNames = /* @__PURE__ */ new Set(["pbot"]);
|
|
11165
11167
|
var stdioKeys = /* @__PURE__ */ new Set(["command", "args", "env", "cwd", "description", "timeout", "enabled"]);
|
|
@@ -11313,7 +11315,7 @@ function resolveWorkspaceMcpServer(root, name, server, env = process.env) {
|
|
|
11313
11315
|
}
|
|
11314
11316
|
const command = expandEnvTemplate(server.command, env, `MCP \u670D\u52A1 "${name}" \u7684 command`);
|
|
11315
11317
|
const args2 = (server.args ?? []).map((arg, index) => expandEnvTemplate(arg, env, `MCP \u670D\u52A1 "${name}" \u7684 args[${index}]`));
|
|
11316
|
-
const cwd = server.cwd ?
|
|
11318
|
+
const cwd = server.cwd ? resolve5(root, expandEnvTemplate(server.cwd, env, `MCP \u670D\u52A1 "${name}" \u7684 cwd`)) : root;
|
|
11317
11319
|
return {
|
|
11318
11320
|
transport: "stdio",
|
|
11319
11321
|
name,
|
|
@@ -11515,7 +11517,7 @@ async function runWorker(args2) {
|
|
|
11515
11517
|
requireThat(files.read(id, "launch.json", launch).generation === generation, "ACP worker \u542F\u52A8\u4EE3\u6B21\u5DF2\u5931\u6548\u3002");
|
|
11516
11518
|
const harness = resolveAcpHarness(reference.backend);
|
|
11517
11519
|
const exactAnswer = Boolean(harness.exactAnswer);
|
|
11518
|
-
const
|
|
11520
|
+
const packageRoot2 = resolve6(resourceRoot, "..");
|
|
11519
11521
|
const configuration = await readWorkspaceConfig(d.workspace);
|
|
11520
11522
|
const features = workspaceFeatures(configuration);
|
|
11521
11523
|
const baseEnv = {
|
|
@@ -11525,7 +11527,7 @@ async function runWorker(args2) {
|
|
|
11525
11527
|
PBOT_SUBAGENT_GENERATION: generation,
|
|
11526
11528
|
...validating ? { PBOT_ACP_VALIDATE: "1" } : {}
|
|
11527
11529
|
};
|
|
11528
|
-
const prepared = harness.prepareLaunch ? await harness.prepareLaunch({ reference, cwd: d.cwd, directory, packageRoot, options: d.options, env: baseEnv, features }) : { command: { ...reference, args: [...reference.args] }, env: { ...baseEnv, ...reference.env ?? {} } };
|
|
11530
|
+
const prepared = harness.prepareLaunch ? await harness.prepareLaunch({ reference, cwd: d.cwd, directory, packageRoot: packageRoot2, options: d.options, env: baseEnv, features }) : { command: { ...reference, args: [...reference.args] }, env: { ...baseEnv, ...reference.env ?? {} } };
|
|
11529
11531
|
let prompt;
|
|
11530
11532
|
if (!exactAnswer) {
|
|
11531
11533
|
const workspaceSkills = features.skills && !harness.nativeWorkspaceSkills && !d.options.noSkills ? await discoverWorkspaceSkills(d.workspace) : [];
|
|
@@ -11686,7 +11688,7 @@ async function runOneShotPrompt() {
|
|
|
11686
11688
|
requireThat(typeof payload.cwd === "string" && payload.cwd.length > 0, "\u7F3A\u5C11 ACP \u6458\u8981\u5DE5\u4F5C\u76EE\u5F55\u3002");
|
|
11687
11689
|
requireThat(typeof payload.prompt === "string" && payload.prompt.trim().length > 0, "\u7F3A\u5C11 ACP \u6458\u8981\u8F93\u5165\u5185\u5BB9\u3002");
|
|
11688
11690
|
const harness = resolveAcpHarness(reference.backend);
|
|
11689
|
-
const
|
|
11691
|
+
const packageRoot2 = resolve6(resourceRoot, "..");
|
|
11690
11692
|
const env = {
|
|
11691
11693
|
...process.env,
|
|
11692
11694
|
...reference.env ?? {},
|
|
@@ -11695,7 +11697,7 @@ async function runOneShotPrompt() {
|
|
|
11695
11697
|
PBOT_SUMMARY_WORKER: "1",
|
|
11696
11698
|
PI_OFFLINE: "1",
|
|
11697
11699
|
PBOT_ACP_PI_COMMAND: process.env.PI_ACP_PI_COMMAND ?? acpExecutable("pi", "pi"),
|
|
11698
|
-
PI_ACP_PI_COMMAND: join11(
|
|
11700
|
+
PI_ACP_PI_COMMAND: join11(packageRoot2, "bin/pbot-pi-acp.mjs")
|
|
11699
11701
|
} : {}
|
|
11700
11702
|
};
|
|
11701
11703
|
let collecting = false;
|