personal-bot 0.3.7 → 0.4.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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +4 -4
- package/docs/architecture/model-context.md +6 -3
- package/docs/guides/cross-harness-workers.md +5 -5
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +5 -5
- package/docs/hosts/claude-code.md +3 -3
- package/docs/hosts/codex-qoder.md +4 -2
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +349 -204
- package/lib/antigravity-plugin/lib/extension/cli.js +596 -572
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/antigravity-plugin/lib/extension/mcp.js +463 -379
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +2 -2
- package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
- package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
- 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 +11 -3
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +349 -204
- package/lib/extension/cli.js +596 -572
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +2 -2
- package/lib/extension/hosts/dsh/workspace.js +5 -5
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +61 -107
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +40 -24
- package/lib/extension/mcp.js +463 -379
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/integrations/agent-resources.js +3 -3
- package/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +182 -128
- package/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/services/history/summary-runner.js +3 -3
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/storage/history-files.js +3 -2
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +14 -16
- package/package.json +2 -2
- package/resources/agents/coordinator.md +2 -4
- package/resources/agents/general-purpose.md +2 -4
- package/resources/antigravity/skills/pbot/SKILL.md +6 -23
- package/resources/claude/skills/pbot/SKILL.md +6 -23
- package/resources/plugin/skills/pbot/SKILL.md +11 -3
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +6 -11
- package/resources/prompts/history-summary.md +6 -11
- package/resources/prompts/plugin-coordinator.md +1 -1
- package/resources/prompts/workspace.md +16 -23
- package/resources/skills/project-maintenance/SKILL.md +14 -21
- package/resources/skills/provider-connections/SKILL.md +23 -36
- package/resources/templates/workspace-agents.md +5 -13
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/mcp.ts +1 -1
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +2 -2
- package/src/extension/hosts/dsh/workspace.ts +5 -4
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +2 -2
- package/src/extension/hosts/pi/events.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +1 -11
- package/src/extension/mcp/tool-contract.ts +61 -108
- package/src/extension/mcp/workers.ts +39 -24
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +5 -5
- package/src/integrations/hosts/antigravity/adapter.ts +0 -1
- package/src/integrations/hosts/claude/adapter.ts +1 -2
- package/src/integrations/hosts/dsh/resources.ts +1 -1
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +3 -3
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +206 -135
- package/src/services/history/summary-dimensions/monthly.ts +1 -1
- package/src/services/history/summary-dimensions/session.ts +6 -3
- package/src/services/history/summary-runner.ts +3 -3
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: project-maintenance
|
|
3
|
-
description:
|
|
3
|
+
description: 续做周期任务、更新项目结论或归档交付物时,维护正文、任务定义和项目导航。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# 项目资料维护
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
从根 `AGENTS.md` 的项目速查找到实际入口,沿用项目已有布局。更新本次涉及的资料和引用,全盘整理按用户指定的范围进行。
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 续做或复现任务
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- **用户偏好与约定**:按用户实际表达记录,不把推测写成既定约定。
|
|
14
|
-
- **可复用知识**(`knowledge/<主题>/`):提炼可跨任务复用的概念、方法与口径,注明适用条件并引用来源。需要留史的研究和决策按日期与主题命名。
|
|
15
|
-
- **排查过程与测试流水**:不逐次追加到正文,必要实现细节写入对应技术资料。
|
|
12
|
+
在所属项目或 `areas/<领域>/` 查原任务定义。需要重复执行的任务,记下目标、输入、执行入口和预期交付物。周期报告还应保留影响复算的口径,如来源和查询方式、筛选范围、期间与时区、单位、指标公式与分母、分组与比较基准。每期报告引用这份定义。
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
- 查上次结论,引用当期正文或交付物。
|
|
15
|
+
- 按原口径更新,核对原定义,用本期数据计算。口径变动时写明对比较结果的影响。
|
|
16
|
+
- 复现历史结果,使用当时的输入和版本。
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
## 更新正文与导航
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
直接修订项目正文(默认 `projects/<目录名>/README.md`)或长期事务正文。合并同主题内容,写清当前结论、适用条件和未决问题。决定有变化时,注明原因、日期并引用原始资料。来源有冲突且无法判定时,标明分歧。用户偏好按用户实际表达记录。
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
可跨任务复用的方法归入 `knowledge/<主题>/`,注明适用条件与来源。需要留史的资料按日期和主题命名。排查记录与实现细节按需放在技术资料中。
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
在根 `AGENTS.md` 用目录名和常用称呼登记项目。默认入口写目录名即可,其他入口链接到实际文件。
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
- 按原口径更新:核对原定义的来源与前提,使用本期数据;口径变化时说明对可比性的影响。
|
|
29
|
-
- 复现历史结果:使用当时的输入和版本。
|
|
26
|
+
## 归档与结项
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
整理或结项时,检查本次涉及的项目目录和 `scratch/`:将结论与方法并入正文,将交付物和可复用源码归入项目目录,同步来源引用与执行入口。
|
|
34
|
-
|
|
35
|
-
归集完成后,只清理本次范围内已被吸收或不再需要的临时文件,不删除正式资料、历史记录或备份。结项时按目标核对交付物和执行入口,在项目正文记录交付结果、剩余工作和复用条件。
|
|
28
|
+
把本次交付物和可复用源码归入项目,补齐来源引用和执行入口。核对交付结果,记录余项和复用条件。只清理本次 `scratch/` 等临时目录中已归集或用完的文件,保留正式资料、历史记录和备份。
|
|
@@ -1,53 +1,40 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: provider-connections
|
|
3
|
-
description:
|
|
3
|
+
description: 接入或排查 CLI 和 MCP,选择工作区或宿主配置,并更新工具手册。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# CLI 与 MCP 接入
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
沿用工作区现有的工具索引和手册,默认位置为 `providers/AGENTS.md` 和 `providers/<id>/GUIDE.md`。CLI 沿用现有登录和 profile,按已安装版本的子命令 `--help` 核对参数。
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 确定 MCP 放在哪里
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
先查工作区和宿主已配置的服务,复用已有接入。一个服务只登记一处。
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
- 给当前工作区的多个宿主和受派助手共用,写入 `.pbot/mcp.json`。适合能接受并发连接、通过 stdio 或 Streamable HTTP 提供工具调用的 MCP 服务。
|
|
15
|
+
- 跨项目通用的工具,或依赖宿主浏览器 OAuth、配套插件、MCP resources/prompts、主动通知或独占本地资源的服务,使用宿主原生配置。工具很多、需要频繁直接调用,或用户明确要求绑定宿主时,也用原生入口。
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
范围明确就按该范围配置。两处都适用、用户意图不清时,先问要给当前工作区共用还是绑定宿主。
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
- **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
|
|
20
|
-
1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
|
|
21
|
-
2. 依赖宿主浏览器交互式 OAuth 登录;
|
|
22
|
-
3. 依赖宿主配套插件、斜杠命令、原生技能、MCP resources/prompts 或服务端主动事件推送;
|
|
23
|
-
4. 工具极多且高频交互,或独占本机端口/浏览器目录、不宜自动透传给 ACP worker;
|
|
24
|
-
5. 用户明确要求绑定到当前宿主原生配置。
|
|
19
|
+
## 工作区共享 MCP
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
将 `<workspaceRoot>` 换成工作区根目录。`pbot mcp add` 新建或替换同名服务,`pbot` 是保留服务名。配置用环境变量引用凭据。给命令参数加单引号,保留字面量 `${TOKEN}` 供连接时读取。
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
```sh
|
|
24
|
+
pbot mcp list --workspace "<workspaceRoot>"
|
|
25
|
+
pbot mcp add <name> --workspace "<workspaceRoot>" --env 'KEY=${TOKEN}' --cwd . -- <command> [args...]
|
|
26
|
+
pbot mcp add <name> --workspace "<workspaceRoot>" --url <url> --header 'Authorization=Bearer ${TOKEN}'
|
|
27
|
+
pbot mcp remove <name> --workspace "<workspaceRoot>"
|
|
28
|
+
```
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
|
|
32
|
-
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
|
|
33
|
-
- **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
|
|
34
|
-
|
|
35
|
-
生效方式(原生挂载与桥接二选一,不重复暴露):
|
|
36
|
-
- Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
|
|
37
|
-
- 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
|
|
38
|
-
- ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
|
|
30
|
+
终端没有 `pbot` 时,用 `node "<resourceRoot>/../lib/extension/cli.js"` 运行相同子命令。修改后,Pi 执行 `/reload`,dsh 打开新会话,再直接调用服务的工具。提供 `workspace_mcp_discover` 的宿主可立即查询该服务,并用 `workspace_mcp_call` 调用。受派助手在新建或恢复会话时加载服务,HTTP 接入需要该助手支持。
|
|
39
31
|
|
|
40
32
|
## 宿主原生 MCP
|
|
41
33
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
## 验证与手册
|
|
49
|
-
|
|
50
|
-
用一个简单的只读查询验证所需能力(例如 `workspace_mcp_discover(server)` + 只读 `workspace_mcp_call` 或原生工具调用),失败时按实际错误排障。
|
|
34
|
+
- Pi 用 `pi mcp add <name> --local ...` 配置当前项目,全局配置省略 `--local`。用 `/reload` 重新加载,用 `/mcp` 查看状态。
|
|
35
|
+
- dsh 使用原生界面或 profile 配置,先确认该 profile 的使用范围。
|
|
36
|
+
- Claude Code 的项目级 HTTP 服务用 `claude mcp add --scope project --transport http <name> <url>`,在会话的 `/mcp` 中核对认证。
|
|
37
|
+
- Antigravity 的全局服务用 `agy mcp add <name> <commandOrUrl> [args...]` 注册,用 `agy mcp list` 查看,删除用 `agy mcp remove <name>`。
|
|
38
|
+
- 其他宿主使用其原生 MCP 命令或配置入口。
|
|
51
39
|
|
|
52
|
-
|
|
53
|
-
- `providers/AGENTS.md`:只做能力导航和选用约定。
|
|
40
|
+
用一个能覆盖本次需求的只读查询验证接入。在工具索引中登记能力和适用场景,在手册中更新接入位置、适用版本,以及原生帮助未说明的数据口径和限制。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "personal-bot",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
|
|
5
5
|
"skills": "./skills/",
|
|
6
6
|
"mcpServers": "./.mcp.json"
|
|
7
7
|
}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"command": "sh",
|
|
5
5
|
"args": [
|
|
6
6
|
"-c",
|
|
7
|
-
"if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.
|
|
7
|
+
"if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"",
|
|
8
8
|
"pbot",
|
|
9
9
|
"mcp"
|
|
10
10
|
],
|
|
11
11
|
"env": {
|
|
12
12
|
"PBOT_HOST": "codex",
|
|
13
|
-
"PBOT_PLUGIN_VERSION": "0.
|
|
13
|
+
"PBOT_PLUGIN_VERSION": "0.4.1"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"hooks": [
|
|
6
6
|
{
|
|
7
7
|
"type": "command",
|
|
8
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
8
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin codex hook",
|
|
9
9
|
"timeout": 120
|
|
10
10
|
}
|
|
11
11
|
]
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"hooks": [
|
|
17
17
|
{
|
|
18
18
|
"type": "command",
|
|
19
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
19
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin codex hook",
|
|
20
20
|
"timeout": 120
|
|
21
21
|
}
|
|
22
22
|
]
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"hooks": [
|
|
28
28
|
{
|
|
29
29
|
"type": "command",
|
|
30
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
30
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin codex hook",
|
|
31
31
|
"timeout": 120
|
|
32
32
|
}
|
|
33
33
|
]
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pbot
|
|
3
|
-
description:
|
|
3
|
+
description: 初始化或检查 Personal Bot 工作区,检索、汇总或迁移历史归档。
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
用当前会话的工作区根目录替换 `<workspaceRoot>`。无参数时执行 `status`。用户要求初始化时执行 `init`,启用工作区并补建缺失的资料目录和根 `AGENTS.md`。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
会话给出 `resourceRoot` 时,用随包 CLI 执行所选命令。查看状态可运行
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
node "<resourceRoot>/../lib/extension/cli.js" status --workspace "<workspaceRoot>"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
没有该路径时,若 `pbot --at-least 0.4.1` 成功,用 `pbot` 替换上例的 `node ".../cli.js"`,否则用 `npx --yes --ignore-scripts personal-bot@0.4.1`。
|
|
16
|
+
|
|
17
|
+
历史操作将 `status` 替换为 `history` 和用户指定的子命令、参数。`history summary` 更新各维度,`history summary monthly` 汇总已有会话摘要。迁移预览用 `history migrate --dry-run`,其他用法见 `history --help`。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentFiles } from "../../storage/agent-files.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AcpAnswer, AcpInput } from "../../model/acp.js";
|
|
3
3
|
export declare function acpMember(): Promise<{
|
|
4
4
|
files: AgentFiles;
|
|
5
5
|
d: import("../../model/agent.js").AgentDescriptor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
|
-
import { AgentFiles,
|
|
4
|
-
import {
|
|
3
|
+
import { AgentFiles, status, toDescriptor } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpAnswer } from "../../storage/acp-files.js";
|
|
5
5
|
import { requireThat } from "../../common/validation.js";
|
|
6
6
|
import { packageVersion, releaseLine } from "../../common/version.js";
|
|
7
7
|
import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
|
|
@@ -11,15 +11,15 @@ export async function acpMember() {
|
|
|
11
11
|
requireThat(id && directory && generation, "缺少 ACP 成员启动身份。");
|
|
12
12
|
const files = new AgentFiles(dirname(realpathSync(directory)));
|
|
13
13
|
requireThat(files.directory(id) === realpathSync(directory), "ACP 成员目录不匹配。");
|
|
14
|
-
const d = files.
|
|
14
|
+
const d = toDescriptor(files.worker(id));
|
|
15
15
|
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP 成员身份或版本无效。");
|
|
16
16
|
const configuration = await readWorkspaceConfig(d.workspace);
|
|
17
17
|
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
18
18
|
const features = workspaceFeatures(configuration);
|
|
19
19
|
const check = () => {
|
|
20
20
|
files.check();
|
|
21
|
-
const
|
|
22
|
-
requireThat(
|
|
21
|
+
const w = files.worker(id);
|
|
22
|
+
requireThat(w.generation === generation && (!w.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
|
|
23
23
|
};
|
|
24
24
|
const context = async () => {
|
|
25
25
|
const reference = files.reference(id);
|
|
@@ -27,16 +27,17 @@ export async function acpMember() {
|
|
|
27
27
|
const loaded = await loadWorkspaceContext({ host, root: d.workspace, role: "general-purpose" });
|
|
28
28
|
return { workspace: loaded.workspace, role: loaded.role, environment: JSON.stringify(loaded.environment) };
|
|
29
29
|
};
|
|
30
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
files, d, id, generation, configuration, features, check, context,
|
|
31
32
|
input() {
|
|
32
33
|
check();
|
|
33
|
-
const
|
|
34
|
-
requireThat(
|
|
35
|
-
return
|
|
34
|
+
const saved = files.read(id, "state.json", status);
|
|
35
|
+
requireThat(saved.generation === generation && typeof saved.activeRequestId === "string" && saved.activeRequestId.length > 0, "ACP 输入代次无效。");
|
|
36
|
+
return { generation, requestId: saved.activeRequestId };
|
|
36
37
|
},
|
|
37
38
|
answer(input, state, answer, error) {
|
|
38
39
|
// A stop can race the native terminal event. The current generation may still seal its result.
|
|
39
|
-
if (files.
|
|
40
|
+
if (files.worker(id).generation !== generation)
|
|
40
41
|
return;
|
|
41
42
|
files.write(id, "acp-answer.json", { ...input, state, answer, ...(error ? { error } : {}) }, acpAnswer);
|
|
42
43
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
|
-
import { AgentFiles,
|
|
4
|
-
import {
|
|
3
|
+
import { AgentFiles, status, toDescriptor } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpReference } from "../../storage/acp-files.js";
|
|
5
5
|
import { AcpAgentRun } from "../../services/agents/acp-run.js";
|
|
6
|
+
import { AgentRun } from "../../services/agents/agent-run.js";
|
|
6
7
|
import { openAcp } from "../../integrations/acp/connection.js";
|
|
7
8
|
import { acpExecutable } from "../../integrations/acp/executable.js";
|
|
8
9
|
import { acpContent } from "../../integrations/acp/input.js";
|
|
@@ -93,16 +94,17 @@ async function runWorker(args) {
|
|
|
93
94
|
requireThat(directory && id && generation, "缺少 ACP worker 启动信息。");
|
|
94
95
|
const files = new AgentFiles(dirname(directory));
|
|
95
96
|
requireThat(files.directory(id) === directory, "ACP worker 目录不匹配。");
|
|
96
|
-
const d = files.
|
|
97
|
+
const d = toDescriptor(files.worker(id)), reference = files.reference(id);
|
|
97
98
|
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP worker 身份或版本不匹配。");
|
|
98
99
|
const validating = args.includes("--validate"), lifetime = new AbortController();
|
|
100
|
+
const agentRun = validating ? undefined : new AgentRun(files, id, generation);
|
|
99
101
|
let execution;
|
|
100
102
|
const stop = () => { void execution?.stop().catch(error => lifetime.abort(error)); if (!execution)
|
|
101
103
|
lifetime.abort(); };
|
|
102
104
|
process.on("SIGTERM", stop);
|
|
103
105
|
process.on("SIGINT", stop);
|
|
104
106
|
async function main() {
|
|
105
|
-
requireThat(files.
|
|
107
|
+
requireThat(files.worker(id).generation === generation, "ACP worker 启动代次已失效。");
|
|
106
108
|
const harness = resolveAcpHarness(reference.backend);
|
|
107
109
|
const exactAnswer = Boolean(harness.exactAnswer);
|
|
108
110
|
const packageRoot = resolve(resourceRoot, "..");
|
|
@@ -116,7 +118,7 @@ async function runWorker(args) {
|
|
|
116
118
|
...(validating ? { PBOT_ACP_VALIDATE: "1" } : {}),
|
|
117
119
|
};
|
|
118
120
|
const prepared = harness.prepareLaunch
|
|
119
|
-
? await harness.prepareLaunch({ reference,
|
|
121
|
+
? await harness.prepareLaunch({ reference, workspace: d.workspace, directory: directory, packageRoot, options: d.options, env: baseEnv, features })
|
|
120
122
|
: { command: { ...reference, args: [...reference.args] }, env: { ...baseEnv, ...(reference.env ?? {}) } };
|
|
121
123
|
let prompt;
|
|
122
124
|
if (!exactAnswer) {
|
|
@@ -142,16 +144,16 @@ async function runWorker(args) {
|
|
|
142
144
|
mcpServers = toAcpMcpServers(resolved);
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
|
-
// Only publish
|
|
147
|
+
// Only publish selection after requested model/thinking options are applied so callers can detect startup readiness.
|
|
146
148
|
let configured = false;
|
|
147
149
|
const saveSelection = (selection) => {
|
|
148
|
-
if (validating || !configured)
|
|
150
|
+
if (validating || !configured || !agentRun)
|
|
149
151
|
return;
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
|
|
152
|
+
const w = files.worker(id);
|
|
153
|
+
if (w.generation === generation && !w.stop)
|
|
154
|
+
agentRun.setSelection(selection);
|
|
153
155
|
};
|
|
154
|
-
const connection = await openAcp(prepared.command, d.
|
|
156
|
+
const connection = await openAcp(prepared.command, d.workspace, prepared.env, {
|
|
155
157
|
selection: saveSelection,
|
|
156
158
|
update(update) {
|
|
157
159
|
if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
|
|
@@ -210,12 +212,10 @@ async function runWorker(args) {
|
|
|
210
212
|
}
|
|
211
213
|
if (reference.sessionId === null)
|
|
212
214
|
await connection.configure(d.options);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
capabilities: connection.capabilities,
|
|
218
|
-
}, acpReference);
|
|
215
|
+
const currentWorker = files.worker(id);
|
|
216
|
+
requireThat(currentWorker.generation === generation && !currentWorker.stop, "ACP 启动已取消。");
|
|
217
|
+
let sessionId = harness.eagerSessionId || reference.sessionId !== null ? connection.sessionId : null;
|
|
218
|
+
agentRun.setSession(sessionId, connection.capabilities);
|
|
219
219
|
configured = true;
|
|
220
220
|
saveSelection(connection.selection());
|
|
221
221
|
let promptInjected = reference.sessionId !== null || connection.systemPrompt;
|
|
@@ -227,16 +227,17 @@ async function runWorker(args) {
|
|
|
227
227
|
: request;
|
|
228
228
|
promptInjected = true;
|
|
229
229
|
const content = await acpContent(effective, connection.images, connection.signal);
|
|
230
|
-
const
|
|
231
|
-
requireThat(
|
|
230
|
+
const w = files.worker(id);
|
|
231
|
+
requireThat(w.generation === generation && !w.stop, "ACP 输入已取消或启动代次变化。");
|
|
232
232
|
connection.signal.throwIfAborted();
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
if (sessionId === null) {
|
|
234
|
+
sessionId = connection.sessionId;
|
|
235
|
+
agentRun.setSession(sessionId, connection.capabilities);
|
|
236
|
+
}
|
|
236
237
|
return connection.prompt(content);
|
|
237
238
|
},
|
|
238
239
|
cancel: () => connection.cancel(),
|
|
239
|
-
}, exactAnswer);
|
|
240
|
+
}, exactAnswer, agentRun);
|
|
240
241
|
await execution.run();
|
|
241
242
|
}
|
|
242
243
|
finally {
|
|
@@ -250,24 +251,24 @@ async function runWorker(args) {
|
|
|
250
251
|
}
|
|
251
252
|
try {
|
|
252
253
|
await main();
|
|
253
|
-
if (!validating && files.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
else
|
|
257
|
-
files.write(id, "status.json", { generation, state: "stopped", activity: "已停止", updatedAt: Date.now() }, status);
|
|
254
|
+
if (!validating && files.worker(id).generation === generation) {
|
|
255
|
+
agentRun.save({ state: "stopped", activity: "已停止" });
|
|
256
|
+
files.clearTransient(id);
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
catch (error) {
|
|
261
260
|
if (validating) {
|
|
262
261
|
await sendIpc({ type: "error", error: errorMessage(error) });
|
|
263
262
|
}
|
|
264
|
-
else if (files.
|
|
265
|
-
const stopped = files.
|
|
263
|
+
else if (files.worker(id).generation === generation) {
|
|
264
|
+
const stopped = files.worker(id).stop;
|
|
266
265
|
const patch = { state: stopped ? "stopped" : "error", activity: stopped ? "已停止" : "ACP 执行失败", ...(stopped ? {} : { error: errorMessage(error) }) };
|
|
267
|
-
if (
|
|
268
|
-
|
|
266
|
+
if (agentRun)
|
|
267
|
+
agentRun.save(patch);
|
|
269
268
|
else
|
|
270
|
-
files.write(id, "
|
|
269
|
+
files.write(id, "state.json", { generation, ...patch, updatedAt: Date.now() }, status);
|
|
270
|
+
if (stopped)
|
|
271
|
+
files.clearTransient(id);
|
|
271
272
|
}
|
|
272
273
|
process.exitCode = 1;
|
|
273
274
|
}
|