personal-bot 0.4.1 → 0.4.2

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.
Files changed (60) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +4 -1
  4. package/README.zh-CN.md +4 -1
  5. package/docs/README.md +2 -3
  6. package/docs/architecture/design.md +41 -2
  7. package/docs/architecture/model-context.md +4 -1
  8. package/docs/architecture/principles.md +2 -2
  9. package/docs/guides/cross-harness-workers.md +26 -1
  10. package/docs/guides/workspace-configuration.md +2 -0
  11. package/lib/antigravity-plugin/lib/extension/acp-worker.js +19 -3
  12. package/lib/antigravity-plugin/lib/extension/cli.js +136 -61
  13. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +2 -0
  14. package/lib/antigravity-plugin/lib/extension/mcp.js +96 -17
  15. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -0
  16. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +20 -2
  17. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  18. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +12 -13
  19. package/lib/antigravity-plugin/lib/model/worker-template.d.ts +21 -0
  20. package/lib/antigravity-plugin/lib/model/worker-template.js +1 -0
  21. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.d.ts +17 -0
  22. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.js +88 -0
  23. package/lib/antigravity-plugin/package.json +1 -1
  24. package/lib/antigravity-plugin/plugin.json +1 -1
  25. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
  26. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  27. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  28. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +1 -1
  29. package/lib/extension/acp-worker.js +19 -3
  30. package/lib/extension/cli.js +136 -61
  31. package/lib/extension/hosts/dsh/workspace.js +2 -1
  32. package/lib/extension/hosts/plugin-runtime.js +2 -0
  33. package/lib/extension/mcp/tool-contract.d.ts +3 -3
  34. package/lib/extension/mcp/tool-contract.js +4 -4
  35. package/lib/extension/mcp/workers.d.ts +1 -1
  36. package/lib/extension/mcp/workers.js +15 -7
  37. package/lib/extension/mcp.js +96 -17
  38. package/lib/integrations/agent-resources.d.ts +2 -0
  39. package/lib/integrations/agent-resources.js +20 -2
  40. package/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  41. package/lib/integrations/hosts/dsh/resources.js +12 -13
  42. package/lib/model/worker-template.d.ts +21 -0
  43. package/lib/model/worker-template.js +1 -0
  44. package/lib/qoder-plugin/.mcp.json +2 -2
  45. package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
  46. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  47. package/lib/qoder-plugin/skills/pbot/SKILL.md +1 -1
  48. package/lib/services/workspace/worker-templates.d.ts +17 -0
  49. package/lib/services/workspace/worker-templates.js +88 -0
  50. package/package.json +1 -1
  51. package/src/extension/hosts/dsh/workspace.ts +2 -1
  52. package/src/extension/hosts/pi/events.ts +2 -0
  53. package/src/extension/hosts/plugin-runtime.ts +2 -0
  54. package/src/extension/mcp/tool-contract.ts +4 -5
  55. package/src/extension/mcp/workers.ts +17 -8
  56. package/src/integrations/agent-resources.ts +22 -2
  57. package/src/integrations/hosts/dsh/resources.ts +13 -12
  58. package/src/model/worker-template.ts +24 -0
  59. package/src/services/workspace/worker-templates.ts +80 -0
  60. package/docs/architecture/model-instruction-guidelines.md +0 -34
@@ -6,12 +6,12 @@
6
6
  "plugins": [
7
7
  {
8
8
  "name": "personal-bot",
9
- "version": "0.4.1",
9
+ "version": "0.4.2",
10
10
  "description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
11
11
  "source": {
12
12
  "source": "npm",
13
13
  "package": "personal-bot",
14
- "version": "0.4.1"
14
+ "version": "0.4.2"
15
15
  }
16
16
  }
17
17
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
6
6
  "skills": [
package/README.md CHANGED
@@ -134,9 +134,12 @@ Ask the assistant to delegate to another harness (for example, "use Codex to imp
134
134
  /pbot worker overview
135
135
  /pbot worker backends
136
136
  /pbot worker models claude
137
+ /pbot worker discover {"target":"templates"}
137
138
  /pbot worker create {"backend":"codex"}
138
139
  ```
139
140
 
141
+ After you configure a worker template, you can delegate by name. For example, “Ask Payments Reviewer to review the refund changes.” The coordinator selects the template and sends the task to a worker in its designated workspace. [Worker template setup](docs/guides/cross-harness-workers.md#自定义-worker-模板)
142
+
140
143
  To use built-in ACP targets, install and authenticate the corresponding target CLI (`pi-acp`, `dsh`, `@agentclientprotocol/claude-agent-acp`, `agy`, `@agentclientprotocol/codex-acp`, or `qodercli`). To add any custom ACP v1 binary, declare it in `.pbot/config.json`:
141
144
 
142
145
  ```json
@@ -230,7 +233,7 @@ Remove only the components you installed:
230
233
 
231
234
  Uninstalling never deletes your workspace materials (`AGENTS.md`, `areas/`, `projects/`, `knowledge/`, `providers/`, `scratch/`, `agents/`, `.agents/skills/`) or local state. If you want to remove Personal Bot state files as well:
232
235
 
233
- - Workspace state: `.pbot/` inside the workspace (contains `config.json`, `mcp.json`, `history/`, and `subagents/`)
236
+ - The workspace stores configuration in `.pbot/config.json` and `.pbot/mcp.json`, saved worker templates in `.pbot/worker/templates.json`, worker runtime records in `.pbot/worker/runtime/`, and history in `.pbot/history/`.
234
237
 
235
238
  ## Documentation & Development
236
239
 
package/README.zh-CN.md CHANGED
@@ -134,9 +134,12 @@ pbot init --workspace /path/to/workspace
134
134
  /pbot worker overview
135
135
  /pbot worker backends
136
136
  /pbot worker models claude
137
+ /pbot worker discover {"target":"templates"}
137
138
  /pbot worker create {"backend":"codex"}
138
139
  ```
139
140
 
141
+ 配置好模板后,可以直接说「让支付审查员复核这次退款改动」。主 Agent 按职责选用模板,把任务交给指定工作区中的 worker。[配置助手模板](docs/guides/cross-harness-workers.md#自定义-worker-模板)
142
+
140
143
  使用内置 ACP 目标前,需先安装并登录对应目标程序(`pi-acp`、`dsh`、`@agentclientprotocol/claude-agent-acp`、`agy`、`@agentclientprotocol/codex-acp` 或 `qodercli`)。如需接入自定义 ACP v1 程序,在 `.pbot/config.json` 中声明即可:
141
144
 
142
145
  ```json
@@ -230,7 +233,7 @@ pbot upgrade
230
233
 
231
234
  卸载操作不会删除你的工作区资料(`AGENTS.md`、`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/`、`.agents/skills/`)或本地状态。如需彻底清理 Personal Bot 状态文件,可手动删除:
232
235
 
233
- - 工作区状态目录:工作区内的 `.pbot/`(含 `config.json`、`mcp.json`、`history/` 与 `subagents/`)
236
+ - 工作区配置位于 `.pbot/config.json` 和 `.pbot/mcp.json`,用户保存的 worker 模板位于 `.pbot/worker/templates.json`,实例运行记录位于 `.pbot/worker/runtime/`,历史记录位于 `.pbot/history/`。
234
237
 
235
238
  ## 文档与开发
236
239
 
package/docs/README.md CHANGED
@@ -25,11 +25,10 @@ Personal Bot 文档按使用场景与职责分为四类,根目录 [README.zh-C
25
25
 
26
26
  | 文档 | 内容 |
27
27
  | --- | --- |
28
- | [架构原则](architecture/principles.md) | 两根核心支柱、统一 MCP 调度、不干扰宿主原生 subagent、可扩展与两类文档方法论 |
29
- | [技术设计](architecture/design.md) | 模块分层与依赖边界、宿主生命周期、文件存储、精简交互界面、安装器与构建分发 |
28
+ | [架构原则](architecture/principles.md) | 两根核心支柱、统一 MCP 调度、宿主原生 subagent 的边界、扩展方式与资料归属 |
29
+ | [技术设计](architecture/design.md) | 模块分层与依赖边界、宿主生命周期、文件存储、精简交互界面、安装器与构建分发,以及[工作区 worker 模板](architecture/design.md#工作区-worker-模板) |
30
30
  | [插件宿主与 ACP 扩展设计](architecture/extensibility.md) | 运行时不感知的 `PluginHostRegistry` 与 `AcpHarnessRegistry`、薄 stdio MCP/ACP 桥接与扩展接入步骤 |
31
31
  | [模型上下文](architecture/model-context.md) | 各宿主与 ACP worker 的指令来源、加载时机与更新规则 |
32
- | [模型指令编写原则](architecture/model-instruction-guidelines.md) | 运行时模型可见资料(`resources/`)的独立编写方法论 |
33
32
 
34
33
  ## 维护与发布(`docs/maintainers/`)
35
34
 
@@ -1,6 +1,6 @@
1
1
  # 技术设计
2
2
 
3
- 本文说明 Personal Bot 的模块分层、宿主生命周期、文件存储、精简交互、安装器与构建分发边界。架构原则见[架构原则](principles.md),插件宿主与 ACP 扩展机制见[插件宿主与 ACP 扩展设计](extensibility.md)。
3
+ 本文说明 Personal Bot 的模块分层、宿主生命周期、worker 模板与跨工作区派发、文件存储、精简交互、安装器与构建分发边界。架构原则见[架构原则](principles.md),插件宿主与 ACP 扩展机制见[插件宿主与 ACP 扩展设计](extensibility.md)。
4
4
 
5
5
  ## 模块与依赖
6
6
 
@@ -54,6 +54,42 @@
54
54
  - **dsh**:按根 Agent 的原始 `cwd` 读取配置,启用后注册技能、上下文、工作区外写保护、`pbot_history` 与根会话原始问答采集,并通过 `@deepseek-ai/dsh-mcp-client` 挂载同一 `lib/extension/mcp.js`(暴露 `mcp__pbot__worker_*`)。Web 工作台仅保留**工作区**与**历史**两页,经原生 Typert Remote(`snapshot`、`history`)查询,不增设 HTTP 服务;聊天命令为 `/pbot`、`status`、`init`、`history`、`worker`。
55
55
  - **轻插件宿主(Claude Code、Antigravity 及后续扩展)**:由 `plugin-runtime.ts` 通过 `PluginHostAdapter` 处理无状态 command hook(上下文注入、技能门控与 `raw` 历史采集)及 `init`/`status` CLI,跨 Harness 调度与只读跨宿主历史查询由宿主挂载 `lib/extension/mcp.js` 完成。不设自定义面板,也不拦截宿主原生 subagent。
56
56
 
57
+ ## 工作区 worker 模板
58
+
59
+ 主工作区在 `.pbot/worker/templates.json` 中保存常用的 Harness、执行工作区、模型和思考深度组合。顶层是以稳定模板 ID 为键的 JSON 对象。主 Agent 按职责选用模板,同一模板可创建多个独立的 worker 实例。
60
+
61
+ | 字段 | 配置契约 |
62
+ | --- | --- |
63
+ | 顶层键(模板 ID) | 匹配 `^[a-z0-9][a-z0-9-]{0,63}$`。修改显示名后仍可按此 ID 引用 |
64
+ | `name`、`description` | `name` 为可选显示名,默认使用 ID。`description` 必填,说明适合委派的任务,仅供主 Agent 选择 |
65
+ | `create.backend` | 必填,接受 Harness 名称、别名或执行工作区配置的自定义 ACP 后端 |
66
+ | `create.workspace` | 省略或写 `.` 表示模板所属工作区。普通相对路径(含 `./` 和 `../`)从该工作区根目录展开,`~` 和 `~/…` 从本机用户主目录展开,绝对路径按本机规则规范化 |
67
+ | `create.model`、`create.thinking` | 均可选,省略时使用目标 Harness 的默认设置 |
68
+
69
+ 每个条目及其 `create` 对象只接受表中字段,字符串须有非空白内容且不能含 NUL。
70
+
71
+ 工作区用户维护模板。主 Agent 通过 `worker_discover` 选择模板,通过 `worker_create` 创建会话。配置文件的位置和格式属于工作区维护文档,Agent 依赖工具提供的创建参数。[配置示例](../guides/cross-harness-workers.md#自定义-worker-模板)
72
+
73
+ ### 发现与派发
74
+
75
+ `worker_discover({"target":"templates"})` 从已启用的主工作区读取清单。该查询仅接受 `target` 和可选的绝对路径 `workspace`,后者指定模板所属工作区。省略时采用宿主绑定的工作区,独立 MCP 缺少绑定时采用服务当前目录。
76
+
77
+ 发现结果按模板 ID 排序,每项包含 `id`、有效显示名 `name`、`description` 和可直接传给 `worker_create` 的 `create`。查询只读取配置并将 `create.workspace` 展开为绝对路径,即使目标目录尚未创建,也能查看模板。[模板读取与路径解析](../../src/services/workspace/worker-templates.ts)
78
+
79
+ | 清单状态 | 发现结果 |
80
+ | --- | --- |
81
+ | 文件缺失或顶层为 `{}` | 返回 `templates: []` |
82
+ | 个别条目无效 | 返回有效模板及 `errors`。每项给出不可用模板的 `id` 和说明 `message` |
83
+ | 文件不可读、JSON 损坏或顶层不是对象 | 返回 MCP 工具错误 `isError: true`,说明当前工作区的助手模板不可用 |
84
+
85
+ 主 Agent 在派发前重新查询,按模板 ID 取出最新的 `create`。`worker_create` 检查执行目录存在且已启用 Personal Bot,按该目录的 ACP 配置解析后端、命令和权限,并由目标 Harness 确定模型与思考深度。创建成功后,主 Agent 用返回的 `workerId` 调用 `worker_request` 发送本次任务与所需背景。执行 worker 使用自己的 `general-purpose` 上下文,模板编辑只影响之后的发现与创建。[MCP 工具契约](../../src/extension/mcp/tool-contract.ts)
86
+
87
+ ### 主 Agent 上下文
88
+
89
+ 宿主装配层把模板读取函数传给共享的角色组装逻辑。当工作区启用、`features.prompts` 开启且存在有效模板时,`coordinator` 角色段展示 ID、显示名、职责和启动配置。摘要保留工作区路径原写法,省略时显示 `.`。清单损坏或没有有效条目时,主会话照常加载。关闭提示词注入后仍可显式查询模板。
90
+
91
+ Pi 在 `before_agent_start`、dsh 在 `system-prompt/assemble` 重读并替换角色段。Claude Code、Antigravity、Codex 和 Qoder CLI 在已有的主会话 `SessionStart` 注入点附上摘要。纯 MCP 客户端通过发现接口读取清单。[各宿主的上下文加载时机](model-context.md)
92
+
57
93
  ## 文件存储
58
94
 
59
95
  | 位置 | 内容与所有者 |
@@ -64,7 +100,10 @@
64
100
  | `<workspace>/AGENTS.md`、`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/` | 用户工作区资料(`init` 只补缺、不覆盖) |
65
101
  | `<workspace>/.pbot/history/raw/[<YYYY>/<MM>/]<id>.json` | 全宿主(Pi、dsh、Claude Code、Antigravity 等)原始问答与已知分支(默认按 UTC `YYYY/MM/` 分层,可配置 `history.layout: "flat"` 切回平铺;各自只写本宿主来源) |
66
102
  | `<workspace>/.pbot/history/summaries/<dimension>/[<YYYY>/<MM>/]<id>.json` | 按维度派生的摘要产物(内置 `session` 与 `monthly` 月度汇总,由 `SummaryRunner` 按 `.write-summary-<dimension>` 锁并发生成,携带来源指纹支持去重与增量更新,可独立重建,损坏不影响原始问答查询) |
67
- | `<workspace>/.pbot/subagents/<id>/`(或 `PBOT_MCP_AGENT_DIR`) | MCP `worker_*` 的最小运行时控制记录(常驻 `worker.json`、`state.json` 与最新一轮 `output.json`;`inbox/`、`interactions/`、`acp-answer.json` 按需创建、用完即删;会话关闭时清理整个 `<id>/` 目录) |
103
+ | `<主工作区>/.pbot/worker/templates.json` | 用户维护的模板清单,生命周期独立于 worker 实例 |
104
+ | `<控制工作区>/.pbot/worker/runtime/<workerId>/` | MCP worker 的控制记录,包括 `worker.json`、`state.json`、最新一轮的 `output.json` 及按需创建的队列和交互文件 |
105
+
106
+ Pi 和 dsh 将主工作区的运行根和会话 ID 传给挂载的 MCP,聊天命令与 MCP 共享实例归属。独立 MCP 默认在执行工作区使用上述运行目录。`PBOT_MCP_AGENT_DIR` 可直接指定运行根,模板始终从主工作区读取。`worker_close` 停止实例,主会话结束时仅清理所属实例,并可回收空运行根。旧 `.pbot/subagents/` 完全排除在发现、恢复、迁移和清理范围之外,旧文件保留原位,原实例需要重新创建。
68
107
 
69
108
  - `atomic-json` 先校验对象再写入临时文件并原子替换,拒绝符号链接、路径越界与特殊文件;短目录锁(`.control` / `.write-<host>`)串行化控制写操作。
70
109
  - 兼容线规则:发布版本遵循 `package.json` 的 `MAJOR.MINOR.PATCH`,1.0 前按次版本、之后按主版本判断控制记录兼容性,不引入自动迁移或存储版本计数器。
@@ -1,6 +1,6 @@
1
1
  # 模型上下文
2
2
 
3
- 本文说明各宿主主会话与跨 Harness ACP worker 的上下文来源、加载时机与刷新边界。编写规范见[模型指令编写原则](model-instruction-guidelines.md)。
3
+ 本文说明各宿主主会话与跨 Harness ACP worker 的上下文来源、加载时机与刷新边界。
4
4
 
5
5
  ## 共享内容与来源
6
6
 
@@ -8,6 +8,7 @@
8
8
  | --- | --- |
9
9
  | 公共约定与资料目录用途 | `resources/prompts/workspace.md`,已启用主会话与 ACP worker 加载 |
10
10
  | 协调者 / 通用专家职责 | `resources/agents/coordinator.md`、`general-purpose.md`,叠加工作区 `agents/<role>.md` |
11
+ | 协调者可选的 worker 模板 | 开启 `features.prompts` 且 `.pbot/worker/templates.json` 有有效条目时,在协调者角色段列出模板 ID、显示名、职责及启动设置。工作区路径保留配置写法 |
11
12
  | 协调者的摘要命令 | 内置宿主在 `features.prompts` 和 `features.history` 都开启时加载。Pi/dsh 使用 `resources/prompts/history-coordinator.md`,插件宿主使用 `resources/prompts/plugin-coordinator.md` |
12
13
  | MCP 服务、工具与参数说明 | stdio 服务在 `initialize` 中说明当前可用能力,在 `tools/list` 中提供操作和参数。Pi/dsh 的原生历史工具使用 `src/tools/history/contract.ts` |
13
14
  | 工作区自有技能 | `<workspace>/.agents/skills/*/SKILL.md`,Pi/dsh/Antigravity/Codex/Qoder CLI 原生发现;Claude Code 与未声明原生发现的 ACP worker 按需注入元数据索引(受 `features.skills` 控制) |
@@ -26,6 +27,8 @@
26
27
 
27
28
  Claude Code、Codex 和 Qoder CLI 在恢复会话或压缩上下文时跳过启动注入。`UserPromptSubmit` 和 `Stop` 分别用于记录用户输入和助手回复。
28
29
 
30
+ Pi 和 dsh 在各自的角色段刷新时重读模板。插件宿主在已有的启动注入点读取一次。主 Agent 派发前通过 `worker_discover({"target":"templates"})` 取得当前参数,纯 MCP 客户端也可用同一接口。[工作区 worker 模板](design.md#工作区-worker-模板)
31
+
29
32
  所有宿主在 `PBOT_SUBAGENT_RUN_ID` 存在时(作为 ACP worker 运行)自动跳过主会话上下文注入,避免重复叠加。
30
33
 
31
34
  ## ACP Worker 上下文
@@ -24,10 +24,10 @@ Personal Bot 不绑定单一宿主,所有能力按两条正交主线组织:
24
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
+ ## 开发文档与运行时资料
28
28
 
29
29
  - **技术与使用文档(`AGENTS.md`、`README*.md`、`docs/`、`scripts/README.md`)**:只维护当前设计目标、设计方法、模块边界与操作方式;直接重写或删除过时内容,历史交由 Git 保存。
30
- - **模型可见运行时资料(`resources/`)**:严格遵循[模型指令编写原则](model-instruction-guidelines.md),只写直接影响操作的规则与入口,按需加载专业方法,绝不混入仓库架构、构建方式或开发规范。
30
+ - **运行时资料**放在 `resources/`,包括各宿主主会话和 ACP worker 加载的提示词、职责、技能、参考资料和模板。
31
31
 
32
32
  ## 验证行为
33
33
 
@@ -19,6 +19,31 @@ Personal Bot 将跨 Harness 专家调度统一为单一的 stdio MCP 服务(`l
19
19
  | Codex / Qoder CLI | 插件 `.mcp.json` 自动启动 `pbot mcp` | `worker_*` |
20
20
  | Cursor / 其他 MCP 宿主 | 手动配置 stdio MCP 命令 `npx personal-bot@latest mcp`(或 `pbot mcp`) | `worker_*` |
21
21
 
22
+ ## 自定义 worker 模板
23
+
24
+ 在主工作区的 `.pbot/worker/templates.json` 中配置可复用的助手模板。每个顶层键是稳定的模板 ID,由 1–64 个小写英文字母、数字或连字符组成,首位为字母或数字。例如,下面的模板可以通过「让支付审查员复核这次退款改动」来选用。
25
+
26
+ ```json
27
+ {
28
+ "payments-review": {
29
+ "name": "支付审查员",
30
+ "description": "复核扣款、退款与幂等性",
31
+ "create": {
32
+ "backend": "claude",
33
+ "workspace": "../payments",
34
+ "model": "sonnet",
35
+ "thinking": "high"
36
+ }
37
+ }
38
+ }
39
+ ```
40
+
41
+ `description` 和 `create.backend` 必填。省略 `name` 时使用 ID,省略模型或思考深度时使用目标 Harness 的默认设置。`workspace` 省略或写为 `.` 时使用主工作区,普通相对路径从主工作区根展开,`~` 和 `~/…` 从本机用户目录展开,也可填写绝对路径。主工作区和执行工作区都需要启用 Personal Bot。
42
+
43
+ 开启工作区提示后,主 Agent 可以看到各模板的职责。派发时查询 `worker_discover({"target":"templates"})`,把选定条目的 `create` 交给 `worker_create`,再通过 `worker_request` 发送本次任务。查询返回最新配置及绝对执行目录,修改模板影响之后创建的实例。Pi 和 dsh 中可输入 `/pbot worker discover {"target":"templates"}` 检查刚保存的条目。
44
+
45
+ 实例数据默认位于 `.pbot/worker/runtime/<workerId>/`。升级后需要重新创建原先位于 `.pbot/subagents/` 的实例。旧目录中的文件保留原位。[模板契约](../architecture/design.md#工作区-worker-模板) · [存储布局](../architecture/design.md#文件存储)
46
+
22
47
  ## 6 个 MCP 工具契约
23
48
 
24
49
  `initialize` 的 `instructions` 说明当前可用能力及适用场景。一组工具的操作和参数见 `tools/list`。其中 `worker_create` 列出本机可用的预设及工作区 `.pbot/config.json` 中配置的可用助手。各工具提供独立的参数 Schema 和 MCP `annotations`(读写与破坏性标记)。
@@ -30,7 +55,7 @@ Personal Bot 将跨 Harness 专家调度统一为单一的 stdio MCP 服务(`l
30
55
  | `worker_request` | 主动写 | `workerId`, `message` | `waitMs` | 主动发送首轮任务、多轮追问或回合后问答回复(已关闭自动恢复);默认同步等待 50s 返回报告(`waitMs: 0` 立即异步),遇到挂起交互立即返回 `needsResponse: true` |
31
56
  | `worker_response` | 被动回复写 | `workerId`, `action` | `requestId`, `optionId`, `content`, `waitMs` | 回复 worker 执行中途发起的挂起请求(`pendingRequests[]`):`action` 为 `accept` / `decline` / `cancel`;权限审批(`kind: "permission"`)可用 `optionId` 指定策略,问答/选择/表单输入(`kind: "form"`,含 Claude `AskUserQuestion`)用 `content` 提交键值答案,URL 确认(`kind: "url"`)直接用 `action`;默认回复后继续等待 50s |
32
57
  | `worker_output` | **只读** | `workerId` | `offset`, `waitMs` | 获取最新一轮执行报告:运行中自动等待至结束(默认 50s,可返回 `timedOut` 或 `needsResponse`),已结束立即返回报告;超长报告(单页 16000 字符)含 `nextOffset` 时传 `offset` 立即翻页 |
33
- | `worker_discover` | **只读** | 无 | `target`, `workerId`, `backend`, `model`, `workspace` | 统一只读发现:`target` 省略或 `"overview"` 即时返回本机 `backends` 与当前会话 `workers`;`"workers"` 查全部或单个 worker 状态;`"backends"` 查可用目标与权限策略;`"models"` 临时探测目标可选模型与思考力度(省略 `backend` 回退 `PBOT_HOST`) |
58
+ | `worker_discover` | **只读** | 无 | `target`, `workerId`, `backend`, `model`, `workspace` | `overview`(默认)列出后端与当前会话的实例,`workers` 查实例状态,`backends` 查目标与权限,`models` 探测模型与思考深度,`templates` 读取工作区模板。查模板时只接受 `target` 和可选的绝对路径 `workspace` |
34
59
 
35
60
  典型调用示例:
36
61
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  所有宿主(Pi、dsh、Claude Code、Antigravity 及其他 MCP 宿主)共用工作区根目录下的 `.pbot/config.json`。宿主原生配置决定插件安装范围,该文件决定 Personal Bot 是否在当前工作区启用,并承载自定义 ACP Harness 启动配置。
4
4
 
5
+ 在 `.pbot/worker/templates.json` 中可保存常用的 Harness、执行工作区、模型和思考深度组合。模板归主工作区管理,Harness 的命令和权限取自执行工作区的 `.pbot/config.json`。[配置和选用 worker 模板](cross-harness-workers.md#自定义-worker-模板)
6
+
5
7
  ## 初始化与状态
6
8
 
7
9
  | 宿主 | 初始化 | 状态 |
@@ -11171,6 +11171,20 @@ function formatWorkspaceSkills(skills) {
11171
11171
  const lines = skills.map((skill) => `- **${skill.name}**\uFF08\`${skill.path}\`\uFF09\uFF1A${skill.description}`);
11172
11172
  return "## \u6309\u9700\u8BFB\u53D6\u7684\u6280\u80FD\n\n" + lines.join("\n");
11173
11173
  }
11174
+ function formatWorkerTemplates(templates) {
11175
+ if (!templates.length) return "";
11176
+ const lines = templates.map(({ id, name, description, create }) => {
11177
+ const label = name === id ? id : `${name}\uFF08${id}\uFF09`;
11178
+ const settings = [
11179
+ ["\u52A9\u624B", create.backend],
11180
+ ["\u6267\u884C\u5DE5\u4F5C\u533A", create.workspace],
11181
+ ["\u6A21\u578B", create.model],
11182
+ ["\u601D\u8003\u6DF1\u5EA6", create.thinking]
11183
+ ].filter(([, value]) => value !== void 0).map(([field, value]) => `${field} ${JSON.stringify(value)}`).join("\uFF0C");
11184
+ return `- ${label}\u3000${description}\uFF08${settings}\uFF09`;
11185
+ });
11186
+ return "## \u5DE5\u4F5C\u533A\u52A9\u624B\u6A21\u677F\n\n\u9009\u7528\u6A21\u677F\u65F6\uFF0C\u7528 worker_discover \u67E5\u8BE2\u6700\u65B0\u8BBE\u7F6E\uFF08target=templates\uFF09\u3002\n\n" + lines.join("\n");
11187
+ }
11174
11188
  async function loadWorkspaceContext(options) {
11175
11189
  const {
11176
11190
  host,
@@ -11183,11 +11197,13 @@ async function loadWorkspaceContext(options) {
11183
11197
  workspaceSkills = [],
11184
11198
  notices = []
11185
11199
  } = options;
11186
- const [workspace, roleText, rootAgents] = includePrompts ? await Promise.all([
11200
+ const [workspace, baseRole, rootAgents, catalog] = includePrompts ? await Promise.all([
11187
11201
  readFile(join7(resourceRoot, "prompts/workspace.md"), "utf8"),
11188
11202
  localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
11189
- includeRootAgents ? readOptionalFile(join7(root, "AGENTS.md")) : Promise.resolve("")
11190
- ]) : ["", "", ""];
11203
+ includeRootAgents ? readOptionalFile(join7(root, "AGENTS.md")) : Promise.resolve(""),
11204
+ role === "coordinator" ? options.readWorkerTemplates?.(root) : void 0
11205
+ ]) : ["", "", "", void 0];
11206
+ const roleText = [baseRole, formatWorkerTemplates(catalog?.templates ?? [])].filter(Boolean).join("\n\n");
11191
11207
  const skillsSection = formatWorkspaceSkills(workspaceSkills);
11192
11208
  const noticesSection = notices.length ? "## \u7EF4\u62A4\u63D0\u9192\n\n\u544A\u77E5\u7528\u6237\uFF0C\u6309\u7528\u6237\u8981\u6C42\u6267\u884C\u3002\n\n" + notices.map((item) => `- ${item}`).join("\n") : "";
11193
11209
  const environment = { host, workspaceRoot: root, resourceRoot };