personal-bot 0.3.2 → 0.3.4

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 (318) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/DISCLAIMER.md +17 -0
  4. package/LICENSE +21 -0
  5. package/README.md +15 -5
  6. package/README.zh-CN.md +15 -5
  7. package/bin/pbot-pi-acp.mjs +1 -1
  8. package/bin/pbot.mjs +22 -2
  9. package/docs/README.md +2 -0
  10. package/docs/architecture/design.md +16 -16
  11. package/docs/architecture/extensibility.md +29 -2
  12. package/docs/architecture/model-context.md +3 -2
  13. package/docs/architecture/principles.md +2 -2
  14. package/docs/guides/capabilities.md +1 -1
  15. package/docs/guides/cross-harness-workers.md +3 -1
  16. package/docs/guides/history.md +30 -7
  17. package/docs/guides/workspace-configuration.md +20 -3
  18. package/docs/hosts/antigravity.md +1 -1
  19. package/docs/hosts/claude-code.md +1 -1
  20. package/docs/hosts/codex-qoder.md +63 -0
  21. package/docs/maintainers/architecture-governance.md +78 -0
  22. package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
  23. package/lib/antigravity-plugin/LICENSE +21 -0
  24. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
  25. package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
  26. package/lib/antigravity-plugin/lib/common/files.js +44 -0
  27. package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
  28. package/lib/antigravity-plugin/lib/common/validation.js +8 -0
  29. package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +18 -0
  30. package/lib/antigravity-plugin/lib/extension/acp/member.js +44 -0
  31. package/lib/antigravity-plugin/lib/extension/acp-worker.js +71 -45
  32. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  33. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
  34. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
  35. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +58 -0
  36. package/lib/antigravity-plugin/lib/extension/hosts/dsh/files.d.ts +5 -0
  37. package/lib/antigravity-plugin/lib/extension/hosts/dsh/files.js +67 -0
  38. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  39. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
  40. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +3 -1
  41. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +37 -22
  42. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  43. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
  44. package/lib/antigravity-plugin/lib/extension/mcp.js +2577 -2255
  45. package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20171 -0
  46. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +1 -1
  47. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +7 -59
  48. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  49. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
  50. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
  51. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/mcp.js +28 -0
  52. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/messages.d.ts +36 -0
  53. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/messages.js +11 -0
  54. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +6 -0
  55. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +47 -0
  56. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
  57. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/root-agents.js +3 -0
  58. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/skills.d.ts +8 -0
  59. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/skills.js +31 -0
  60. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  61. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
  62. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  63. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
  64. package/lib/antigravity-plugin/lib/integrations/hosts/plugin-registry.d.ts +1 -0
  65. package/lib/antigravity-plugin/lib/integrations/hosts/plugin-registry.js +8 -1
  66. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  67. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
  68. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  69. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
  70. package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
  71. package/lib/antigravity-plugin/lib/model/acp.js +8 -0
  72. package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
  73. package/lib/antigravity-plugin/lib/model/agent.js +4 -0
  74. package/lib/antigravity-plugin/lib/model/history.d.ts +10 -0
  75. package/lib/antigravity-plugin/lib/model/history.js +4 -1
  76. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +5 -0
  77. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +8 -12
  78. package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
  79. package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
  80. package/lib/antigravity-plugin/lib/plugin.js +2 -2
  81. package/lib/antigravity-plugin/lib/services/history/history-capture.js +34 -22
  82. package/lib/antigravity-plugin/lib/services/history/summary-registry.js +2 -3
  83. package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +2 -5
  84. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +72 -74
  85. package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
  86. package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
  87. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +15 -0
  88. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +126 -0
  89. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +9 -8
  90. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
  91. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
  92. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
  93. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
  94. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
  95. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
  96. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
  97. package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
  98. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
  99. package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
  100. package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
  101. package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
  102. package/lib/antigravity-plugin/lib/storage/history-files.d.ts +2 -1
  103. package/lib/antigravity-plugin/lib/storage/history-files.js +21 -15
  104. package/lib/antigravity-plugin/lib/storage/history-format.d.ts +2 -3
  105. package/lib/antigravity-plugin/lib/storage/history-format.js +5 -7
  106. package/lib/antigravity-plugin/package.json +1 -1
  107. package/lib/antigravity-plugin/plugin.json +1 -1
  108. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
  109. package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
  110. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
  111. package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
  112. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
  113. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
  114. package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
  115. package/lib/client.js +22 -50
  116. package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
  117. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
  118. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
  119. package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
  120. package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
  121. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
  122. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
  123. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
  124. package/lib/common/validation.d.ts +4 -0
  125. package/lib/common/validation.js +8 -0
  126. package/lib/dsh.js +2 -2
  127. package/lib/extension/acp/member.d.ts +1 -1
  128. package/lib/extension/acp-worker.js +71 -45
  129. package/lib/extension/history/command.d.ts +37 -0
  130. package/lib/extension/history/command.js +57 -0
  131. package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  132. package/lib/extension/hosts/dsh/acp-entry.js +22 -0
  133. package/lib/extension/hosts/dsh/acp-member.js +4 -18
  134. package/lib/extension/hosts/dsh/command.d.ts +1 -2
  135. package/lib/extension/hosts/dsh/command.js +5 -49
  136. package/lib/extension/hosts/dsh/workspace.js +13 -44
  137. package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  138. package/lib/extension/hosts/pi/acp-member.js +100 -0
  139. package/lib/extension/hosts/plugin-runtime.d.ts +3 -1
  140. package/lib/extension/hosts/plugin-runtime.js +37 -22
  141. package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  142. package/lib/extension/hosts/workspace-mcp.js +21 -0
  143. package/lib/extension/mcp/bridge.d.ts +6 -8
  144. package/lib/extension/mcp/bridge.js +66 -84
  145. package/lib/extension/mcp/tool-contract.d.ts +735 -0
  146. package/lib/extension/mcp/tool-contract.js +441 -0
  147. package/lib/extension/mcp/workers.d.ts +29 -742
  148. package/lib/extension/mcp/workers.js +75 -525
  149. package/lib/extension/mcp.js +2577 -2255
  150. package/lib/extension/setup/cli.js +15 -0
  151. package/lib/extension/setup/upgrade.js +153 -0
  152. package/lib/extension/workspace-cli.js +20171 -0
  153. package/lib/integrations/acp/agents.d.ts +2 -3
  154. package/lib/integrations/acp/harnesses/dsh.js +1 -1
  155. package/lib/integrations/acp/harnesses/presets.js +8 -0
  156. package/lib/integrations/acp/history-summary.js +2 -1
  157. package/lib/integrations/acp/launch.d.ts +2 -2
  158. package/lib/integrations/agent-resources.js +1 -1
  159. package/lib/integrations/hosts/claude/adapter.js +7 -59
  160. package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  161. package/lib/integrations/hosts/codex/adapter.js +14 -0
  162. package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  163. package/lib/integrations/hosts/pi/agent-tools.js +32 -0
  164. package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  165. package/lib/integrations/hosts/pi/mcp.js +23 -0
  166. package/lib/integrations/hosts/plugin-registry.d.ts +1 -0
  167. package/lib/integrations/hosts/plugin-registry.js +8 -1
  168. package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  169. package/lib/integrations/hosts/prompt-hooks.js +76 -0
  170. package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  171. package/lib/integrations/hosts/qoder/adapter.js +16 -0
  172. package/lib/integrations/installation/cli-update.js +146 -0
  173. package/lib/integrations/installation/upgraders/antigravity.js +67 -0
  174. package/lib/integrations/installation/upgraders/claude.js +123 -0
  175. package/lib/integrations/installation/upgraders/codex.js +73 -0
  176. package/lib/integrations/installation/upgraders/dsh.js +62 -0
  177. package/lib/integrations/installation/upgraders/pi.js +90 -0
  178. package/lib/integrations/installation/upgraders/qoder.js +67 -0
  179. package/lib/integrations/installation/upgraders/registry.js +40 -0
  180. package/lib/model/acp.d.ts +7 -3
  181. package/lib/model/acp.js +8 -0
  182. package/lib/model/agent.d.ts +18 -4
  183. package/lib/model/agent.js +4 -1
  184. package/lib/model/history.d.ts +10 -0
  185. package/lib/model/history.js +4 -1
  186. package/lib/model/installation.js +1 -0
  187. package/lib/model/plugin-host.d.ts +5 -0
  188. package/lib/model/workspace-config.d.ts +8 -12
  189. package/lib/model/workspace-config.js +2 -1
  190. package/lib/plugin.d.ts +2 -1
  191. package/lib/plugin.js +2 -2
  192. package/lib/qoder-plugin/.mcp.json +17 -0
  193. package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
  194. package/lib/qoder-plugin/DISCLAIMER.md +17 -0
  195. package/lib/qoder-plugin/LICENSE +21 -0
  196. package/lib/qoder-plugin/hooks/hooks.json +37 -0
  197. package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
  198. package/lib/services/agents/agent-service.d.ts +15 -45
  199. package/lib/services/agents/agent-service.js +22 -3
  200. package/lib/services/history/history-capture.js +34 -22
  201. package/lib/services/history/history-migrate.js +26 -60
  202. package/lib/services/history/history-query.js +38 -57
  203. package/lib/services/history/summary-command.d.ts +1 -1
  204. package/lib/services/history/summary-command.js +8 -7
  205. package/lib/services/history/summary-registry.js +2 -3
  206. package/lib/services/history/summary-runner.d.ts +2 -5
  207. package/lib/services/history/summary-runner.js +72 -74
  208. package/lib/services/history/workspace-history.d.ts +3 -0
  209. package/lib/services/history/workspace-history.js +6 -0
  210. package/lib/services/installation/setup-service.js +4 -1
  211. package/lib/services/installation/upgrade-service.js +95 -0
  212. package/lib/services/workspace/plugin-releases.d.ts +15 -0
  213. package/lib/services/workspace/plugin-releases.js +126 -0
  214. package/lib/services/workspace/workspace-config.js +9 -8
  215. package/lib/services/workspace/workspace-mcp.js +22 -29
  216. package/lib/services/workspace/workspace-skills.d.ts +1 -0
  217. package/lib/services/workspace/workspace-skills.js +4 -2
  218. package/lib/storage/acp-files.js +7 -12
  219. package/lib/storage/agent-files.js +6 -5
  220. package/lib/storage/atomic-json.d.ts +3 -1
  221. package/lib/storage/atomic-json.js +43 -3
  222. package/lib/storage/history-files.d.ts +2 -1
  223. package/lib/storage/history-files.js +21 -15
  224. package/lib/storage/history-format.d.ts +2 -3
  225. package/lib/storage/history-format.js +5 -7
  226. package/lib/tools/history/contract.d.ts +3 -11
  227. package/lib/tools/history/contract.js +8 -7
  228. package/lib/ui/dsh/elements.d.ts +2 -5
  229. package/lib/ui/dsh/elements.js +3 -16
  230. package/lib/ui/dsh/management.js +9 -9
  231. package/lib/ui/dsh/styles.d.ts +1 -1
  232. package/lib/ui/dsh/styles.js +5 -33
  233. package/package.json +4 -1
  234. package/resources/antigravity/skills/pbot/SKILL.md +11 -1
  235. package/resources/claude/skills/pbot/SKILL.md +11 -1
  236. package/resources/plugin/skills/pbot/SKILL.md +9 -0
  237. package/resources/prompts/history-coordinator.md +1 -0
  238. package/resources/prompts/plugin-coordinator.md +1 -0
  239. package/scripts/README.md +3 -2
  240. package/src/common/validation.ts +10 -0
  241. package/src/dsh.ts +2 -2
  242. package/src/extension/history/command.ts +68 -0
  243. package/src/extension/hosts/dsh/acp-entry.ts +21 -0
  244. package/src/extension/hosts/dsh/acp-member.ts +4 -15
  245. package/src/extension/hosts/dsh/command.ts +6 -46
  246. package/src/extension/hosts/dsh/workspace.ts +12 -38
  247. package/src/extension/hosts/pi/acp-member.ts +4 -10
  248. package/src/extension/hosts/pi/command.ts +14 -63
  249. package/src/extension/hosts/pi/events.ts +2 -8
  250. package/src/extension/hosts/pi/lifecycle.ts +3 -2
  251. package/src/extension/hosts/plugin-runtime.ts +39 -19
  252. package/src/extension/hosts/workspace-mcp.ts +25 -0
  253. package/src/extension/mcp/bridge.ts +80 -80
  254. package/src/extension/mcp/tool-contract.ts +462 -0
  255. package/src/extension/mcp/workers.ts +81 -551
  256. package/src/extension/setup/cli.ts +11 -1
  257. package/src/extension/setup/upgrade.ts +158 -0
  258. package/src/extension/setup/workspace-cli.ts +167 -0
  259. package/src/integrations/acp/agents.ts +2 -3
  260. package/src/integrations/acp/harnesses/dsh.ts +1 -1
  261. package/src/integrations/acp/harnesses/presets.ts +8 -0
  262. package/src/integrations/acp/history-summary.ts +2 -1
  263. package/src/integrations/agent-resources.ts +1 -1
  264. package/src/integrations/hosts/claude/adapter.ts +7 -53
  265. package/src/integrations/hosts/codex/adapter.ts +16 -0
  266. package/src/integrations/hosts/plugin-registry.ts +9 -1
  267. package/src/integrations/hosts/prompt-hooks.ts +72 -0
  268. package/src/integrations/hosts/qoder/adapter.ts +19 -0
  269. package/src/integrations/installation/cli-update.ts +144 -0
  270. package/src/integrations/installation/pi-bridge.ts +1 -1
  271. package/src/integrations/installation/pi-setup.ts +1 -1
  272. package/src/integrations/installation/processes.ts +1 -1
  273. package/src/integrations/installation/upgraders/antigravity.ts +68 -0
  274. package/src/integrations/installation/upgraders/claude.ts +123 -0
  275. package/src/integrations/installation/upgraders/codex.ts +73 -0
  276. package/src/integrations/installation/upgraders/dsh.ts +63 -0
  277. package/src/integrations/installation/upgraders/pi.ts +87 -0
  278. package/src/integrations/installation/upgraders/qoder.ts +68 -0
  279. package/src/integrations/installation/upgraders/registry.ts +48 -0
  280. package/src/model/acp.ts +11 -3
  281. package/src/model/agent.ts +20 -4
  282. package/src/model/history.ts +5 -0
  283. package/src/model/installation.ts +86 -0
  284. package/src/model/plugin-host.ts +5 -1
  285. package/src/model/workspace-config.ts +6 -12
  286. package/src/pbot.ts +13 -32
  287. package/src/plugin.ts +3 -3
  288. package/src/services/agents/agent-service.ts +29 -17
  289. package/src/services/history/history-capture.ts +30 -22
  290. package/src/services/history/history-migrate.ts +23 -50
  291. package/src/services/history/history-query.ts +34 -48
  292. package/src/services/history/summary-command.ts +9 -8
  293. package/src/services/history/summary-registry.ts +2 -3
  294. package/src/services/history/summary-runner.ts +72 -81
  295. package/src/services/history/workspace-history.ts +8 -0
  296. package/src/services/installation/setup-service.ts +9 -43
  297. package/src/services/installation/upgrade-service.ts +127 -0
  298. package/src/services/workspace/plugin-releases.ts +121 -0
  299. package/src/services/workspace/workspace-config.ts +9 -8
  300. package/src/services/workspace/workspace-mcp.ts +23 -28
  301. package/src/services/workspace/workspace-skills.ts +5 -2
  302. package/src/storage/acp-files.ts +7 -12
  303. package/src/storage/agent-files.ts +6 -5
  304. package/src/storage/atomic-json.ts +31 -4
  305. package/src/storage/history-files.ts +22 -15
  306. package/src/storage/history-format.ts +6 -8
  307. package/src/tools/history/contract.ts +9 -9
  308. package/src/tools/history/pi-tool.ts +6 -4
  309. package/src/ui/dsh/elements.ts +5 -12
  310. package/src/ui/dsh/management.ts +10 -10
  311. package/src/ui/dsh/styles.ts +5 -33
  312. package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +0 -12
  313. package/lib/antigravity-plugin/lib/services/history/history-migrate.js +0 -88
  314. package/lib/ui/presentation.d.ts +0 -3
  315. package/lib/ui/presentation.js +0 -12
  316. package/src/tools/access.ts +0 -7
  317. package/src/tools/register.ts +0 -21
  318. package/src/ui/presentation.ts +0 -12
package/scripts/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  | 命令 | 作用 |
6
6
  | --- | --- |
7
7
  | `npm run build` | 清理 `dist`,编译测试模块,再依次构建 CLI、dsh 与插件产物 |
8
- | `npm run build:cli` | 清理 `lib`,编译独立 CLI(`setup` / `install-antigravity` / `mcp`)、Pi 检查桥接与启动保护 |
8
+ | `npm run build:cli` | 清理 `lib`,编译安装器、Pi 检查桥接与启动保护,打包工作区 CLI(`init`、`status`、`history`) |
9
9
  | `npm run build:dsh` | 编译 Host,将 TypeBox 与许可证纳入 `lib`,再构建原生 Web Loader 模块 |
10
- | `npm run build:plugins`(`build:claude` 别名) | 编译共享插件运行时(`lib/plugin.js`、`lib/claude.js`),通过 `esbuild` 打包零外部依赖的 `lib/extension/mcp.js` 与 `lib/extension/acp-worker.js`,并执行各已注册插件宿主构建目标(同步 Claude 清单、组装自包含 `lib/antigravity-plugin/`) |
10
+ | `npm run build:plugins`(`build:claude` 别名) | 在临时目录编译一次共享插件运行时(`lib/plugin.js`、`lib/claude.js`),通过 `esbuild` 打包零外部依赖的 `lib/extension/mcp.js` 与 `lib/extension/acp-worker.js`,并执行各已注册插件宿主构建目标(同步 Claude 清单、组装自包含 `lib/antigravity-plugin/`、生成 `lib/codex-marketplace/` 与 `lib/qoder-plugin/`) |
11
11
 
12
12
  完整构建与 `prepack` 均按 **CLI → dsh → plugins** 顺序执行;`build:cli` 会清空 `lib`,单独重建它后须补齐后两项。宿主 SDK 保持 optional peer,Pi 直接加载 `src`。完整开发使用 Linux/macOS、Node.js 24.9+;Pi/CLI/轻插件与打包 MCP/ACP 入口支持 Node.js 22.19+(Claude CLI 2.1.325+,Antigravity `agy` 1.5+)。
13
13
 
@@ -17,6 +17,7 @@
17
17
 
18
18
  | 命令 | 检查内容 |
19
19
  | --- | --- |
20
+ | `qodercli plugin validate --strict ./lib/qoder-plugin --json` | 校验 Qoder CLI 原生插件、hooks、MCP 与管理技能 |
20
21
  | `agy plugin validate --strict ./lib/antigravity-plugin --json` | 按 Antigravity 原生加载器严格校验 `plugin.json`、`hooks.json`、`mcp_config.json` 与 `skills/` |
21
22
  | `claude plugin validate --json ./.claude-plugin/plugin.json` | 校验 Claude 插件清单、hooks、`.mcp.json` 与技能 |
22
23
  | `node scripts/check-consumer.mjs <tarball>` | 独立 CLI、Pi 扩展、技能、工具与资料初始化(确认不连带安装宿主 SDK) |
@@ -7,3 +7,13 @@ export function isAcpBackend(value: unknown): value is string {
7
7
  export function requireThat(condition: unknown, message: string): asserts condition {
8
8
  if (!condition) throw new Error(message);
9
9
  }
10
+
11
+ /** Shared grammar for host and dimension identifiers in history archives and queries. */
12
+ export const historyIdentifierPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
13
+ export function isHistoryIdentifier(value: unknown): value is string {
14
+ return typeof value === "string" && historyIdentifierPattern.test(value);
15
+ }
16
+
17
+ export function isOneOf<T extends string>(value: unknown, choices: readonly T[]): value is T {
18
+ return typeof value === "string" && (choices as readonly string[]).includes(value);
19
+ }
package/src/dsh.ts CHANGED
@@ -14,8 +14,8 @@ export async function apply(ctx: Context) {
14
14
  requireThat(major! > 24 || (major === 24 && minor! >= 9), "dsh 接入需要 Node.js 24.9.0 或更新版本。");
15
15
  const workspaces = new DshWorkspaces(ctx);
16
16
  ctx.effect(() => () => workspaces.close());
17
- const management = registerDshManagement(ctx, workspaces);
18
- registerDshCommand(ctx, workspaces, management);
17
+ registerDshManagement(ctx, workspaces);
18
+ registerDshCommand(ctx, workspaces);
19
19
  ctx.on("agent/created", async ({ agent }) => {
20
20
  if (rootAgents(ctx.agents).includes(agent)) await workspaces.open(agent);
21
21
  });
@@ -0,0 +1,68 @@
1
+ import { requireThat } from "../../common/validation.js";
2
+ import { createAcpHistorySummarizer } from "../../integrations/acp/history-summary.js";
3
+ import type { SummaryRunProgress } from "../../model/history.js";
4
+ import { migrateWorkspaceHistory } from "../../services/history/history-migrate.js";
5
+ import { parseHistoryCommand, type ParsedHistoryCommand } from "../../services/history/summary-command.js";
6
+ import { listSummaryDimensions } from "../../services/history/summary-registry.js";
7
+ import { inspectWorkspaceSummaries, runWorkspaceSummaries } from "../../services/history/summary-runner.js";
8
+ import { readWorkspaceConfig, readWorkspaceHistoryLayoutSync, workspaceDisabledMessage, workspaceFeatures, workspaceSummaryConfig } from "../../services/workspace/workspace-config.js";
9
+ import { executeHistory } from "../../tools/history/actions.js";
10
+ import { historyInput } from "../../tools/history/contract.js";
11
+
12
+ interface CommandContext {
13
+ root: string;
14
+ features: { history: boolean };
15
+ }
16
+
17
+ export async function runHistoryCommand(
18
+ workspace: CommandContext,
19
+ argument: string | ParsedHistoryCommand,
20
+ signal: AbortSignal,
21
+ progress?: { start(backend: string): void; update(event: SummaryRunProgress): void; finish?(): void },
22
+ ) {
23
+ const { root } = workspace;
24
+ signal.throwIfAborted();
25
+ requireThat(workspace.features.history, "当前工作区已停用历史功能(features.history: false)。");
26
+ const command = typeof argument === "string" ? parseHistoryCommand(argument) : argument;
27
+ switch (command.kind) {
28
+ case "status":
29
+ return inspectWorkspaceSummaries(root);
30
+ case "list": {
31
+ const layout = readWorkspaceHistoryLayoutSync(root);
32
+ const dimensions = listSummaryDimensions(layout).map(({ id, title, description }) => ({ id, title, description }));
33
+ return { layout, dimensions };
34
+ }
35
+ case "migrate":
36
+ return migrateWorkspaceHistory(root, { dryRun: command.dryRun });
37
+ case "query":
38
+ return executeHistory(root, historyInput(command.input), signal);
39
+ case "summary": {
40
+ const config = await readWorkspaceConfig(root);
41
+ requireThat(config.enabled && !config.error, workspaceDisabledMessage(config));
42
+ requireThat(workspaceFeatures(config).history, "当前工作区已停用历史功能(features.history: false)。");
43
+ const defaults = workspaceSummaryConfig(config);
44
+ const backend = command.backend ?? defaults.backend;
45
+ const model = command.model ?? defaults.model;
46
+ const thinking = command.thinking ?? defaults.thinking;
47
+ const summarizer = createAcpHistorySummarizer({
48
+ cwd: root, backend,
49
+ ...(config.acp ? { commands: config.acp } : {}),
50
+ ...(model ? { model } : {}),
51
+ ...(thinking ? { thinking } : {}),
52
+ });
53
+ progress?.start(backend);
54
+ try {
55
+ const report = await runWorkspaceSummaries({
56
+ root, summarizer, signal,
57
+ force: command.force,
58
+ concurrency: defaults.concurrency,
59
+ ...(command.dimensions ? { dimensions: command.dimensions } : {}),
60
+ ...(progress ? { onProgress: progress.update } : {}),
61
+ });
62
+ return { backend, ...(model ? { model } : {}), ...report };
63
+ } finally {
64
+ progress?.finish?.();
65
+ }
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,21 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { registerHooks } from "node:module";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ // Keep normal dsh profile resolution. A standalone plugin cache has no SDK
6
+ // peers of its own, so resolve missing peers from the running dsh installation.
7
+ const memberLib = new URL("../../../", import.meta.url).href;
8
+ const peers = registerHooks({
9
+ resolve(specifier, context, nextResolve) {
10
+ if (specifier.startsWith("@deepseek-ai/") && context.parentURL?.startsWith(memberLib)) {
11
+ try { return nextResolve(specifier, context); }
12
+ catch (error) {
13
+ if ((error as NodeJS.ErrnoException).code !== "ERR_MODULE_NOT_FOUND" || !process.argv[1]) throw error;
14
+ return nextResolve(specifier, { ...context, parentURL: pathToFileURL(realpathSync(process.argv[1])).href });
15
+ }
16
+ }
17
+ return nextResolve(specifier, context);
18
+ },
19
+ });
20
+
21
+ export const { name, inject, apply } = await import("./acp-member.js").finally(() => peers.deregister());
@@ -7,7 +7,7 @@ import { dshResources, dshExpertTools } from "../../../integrations/hosts/dsh/re
7
7
  import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
8
8
  import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
9
9
  import { finalDshAnswer } from "../../../integrations/hosts/dsh/messages.js";
10
- import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../../services/workspace/workspace-mcp.js";
10
+ import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
11
11
  import { registerDshFileEvents } from "./files.js";
12
12
  import { requireThat } from "../../../common/validation.js";
13
13
 
@@ -29,20 +29,9 @@ export async function apply(ctx: Context) {
29
29
  await agent.ctx.plugin({ name: "pbot-acp-expert", inject, apply: async scope => {
30
30
  if (member.features.skills) registerDshSkills(scope, agent, { workspaceRoot: member.d.workspace });
31
31
  if (member.features.mcp && process.env.PBOT_ACP_VALIDATE !== "1") {
32
- const mcpConfig = await readWorkspaceMcpConfig(member.d.workspace);
33
- if (mcpConfig.error) {
34
- ctx.logger.warn(mcpConfig.error);
35
- } else {
36
- for (const [serverName, server] of Object.entries(mcpConfig.servers)) {
37
- if (server.enabled === false) continue;
38
- try {
39
- const resolved = resolveWorkspaceMcpServer(member.d.workspace, serverName, server);
40
- await scope.plugin(McpClient, toDshMcpConfig(resolved));
41
- } catch (error) {
42
- ctx.logger.warn(error instanceof Error ? error.message : String(error));
43
- }
44
- }
45
- }
32
+ await loadNativeWorkspaceServers(member.d.workspace, async server => {
33
+ await scope.plugin(McpClient, toDshMcpConfig(server));
34
+ }, { warn: message => ctx.logger.warn(message) });
46
35
  }
47
36
  dshExpertTools(scope, agent, member.d.options);
48
37
  if (member.features.prompts) await dshResources(scope, agent, member.d.workspace, "general-purpose", member.check);
@@ -1,20 +1,13 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type {} from "@deepseek-ai/dsh-commands";
3
- import { json } from "../../../common/json.js";
4
- import { requireThat } from "../../../common/validation.js";
5
- import { createAcpHistorySummarizer } from "../../../integrations/acp/history-summary.js";
6
- import { migrateWorkspaceHistory } from "../../../services/history/history-migrate.js";
7
- import { parseHistoryCommand } from "../../../services/history/summary-command.js";
8
- import { listSummaryDimensions } from "../../../services/history/summary-registry.js";
9
- import { inspectWorkspaceSummaries, runWorkspaceSummaries } from "../../../services/history/summary-runner.js";
10
- import { readWorkspaceConfig, readWorkspaceHistoryLayoutSync, workspaceDisabledMessage, workspaceSummaryConfig } from "../../../services/workspace/workspace-config.js";
11
- import { dshWorkspaceStatus, type PbotManagement } from "./management.js";
3
+ import { dshWorkspaceStatus } from "./management.js";
12
4
  import type { DshWorkspaces } from "./workspace.js";
5
+ import { runHistoryCommand } from "../../history/command.js";
13
6
  import { parseWorkerCommand } from "../../mcp/workers.js";
14
7
 
15
8
  const usage = '用法:/pbot status | init | history [summary [维度] [--force] [--backend <acp>] [--model <model>] | migrate [--dry-run] | status | list | {"action":…}] | worker [overview|status|backends|models|create|request|response|output|close] [JSON]';
16
9
 
17
- export function registerDshCommand(ctx: Context, workspaces: DshWorkspaces, management: PbotManagement) {
10
+ export function registerDshCommand(ctx: Context, workspaces: DshWorkspaces) {
18
11
  ctx.commands.register({
19
12
  name: "pbot",
20
13
  description: "Personal Bot 工作区、历史摘要与跨 Harness worker 管理",
@@ -44,42 +37,9 @@ export function registerDshCommand(ctx: Context, workspaces: DshWorkspaces, mana
44
37
  break;
45
38
  }
46
39
  case "history": {
47
- requireThat(workspace.features.history, "当前工作区已停用历史功能(features.history: false)。");
48
- const parsed = parseHistoryCommand(rest);
49
- if (parsed.kind === "status") {
50
- result = inspectWorkspaceSummaries(workspace.root);
51
- } else if (parsed.kind === "list") {
52
- const layout = readWorkspaceHistoryLayoutSync(workspace.root);
53
- result = { layout, dimensions: listSummaryDimensions(layout).map(({ id, title, description }) => ({ id, title, description })) };
54
- } else if (parsed.kind === "migrate") {
55
- result = migrateWorkspaceHistory(workspace.root, { dryRun: parsed.dryRun });
56
- } else if (parsed.kind === "query") {
57
- result = await management.history({ parentSessionId: agent.id, input: json(parsed.input) }, signal);
58
- } else {
59
- const active = AbortSignal.any([signal, workspace.lifetime.signal]);
60
- const config = await readWorkspaceConfig(workspace.root);
61
- requireThat(config.enabled && !config.error, workspaceDisabledMessage(config));
62
- const summaryCfg = workspaceSummaryConfig(config);
63
- const backend = parsed.backend ?? summaryCfg.backend;
64
- const model = parsed.model ?? summaryCfg.model;
65
- const thinking = parsed.thinking ?? summaryCfg.thinking;
66
- const summarizer = createAcpHistorySummarizer({
67
- cwd: workspace.root,
68
- backend,
69
- ...(config.acp ? { commands: config.acp } : {}),
70
- ...(model ? { model } : {}),
71
- ...(thinking ? { thinking } : {}),
72
- });
73
- const report = await runWorkspaceSummaries({
74
- root: workspace.root,
75
- summarizer,
76
- ...(parsed.dimensions ? { dimensions: parsed.dimensions } : {}),
77
- force: parsed.force,
78
- ...(summaryCfg.concurrency !== undefined ? { concurrency: summaryCfg.concurrency } : {}),
79
- signal: active,
80
- });
81
- result = { backend, ...(model ? { model } : {}), ...report };
82
- }
40
+ const active = AbortSignal.any([signal, workspace.lifetime.signal]);
41
+ result = await runHistoryCommand(workspace, rest, active);
42
+ active.throwIfAborted();
83
43
  break;
84
44
  }
85
45
  default:
@@ -1,6 +1,4 @@
1
- import { existsSync } from "node:fs";
2
1
  import { realpath } from "node:fs/promises";
3
- import { resolve } from "node:path";
4
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
5
3
  import type { Context } from "@deepseek-ai/cordis";
6
4
  import * as McpClient from "@deepseek-ai/dsh-mcp-client";
@@ -9,16 +7,15 @@ import { dshResources } from "../../../integrations/hosts/dsh/resources.js";
9
7
  import { registerDshFileEvents } from "./files.js";
10
8
  import { registerDshHistoryEvents } from "./history.js";
11
9
  import { registerDshHistoryTool } from "../../../tools/history/dsh-tool.js";
12
- import { resourceRoot } from "../../../common/paths.js";
13
10
  import { requireThat } from "../../../common/validation.js";
14
11
  import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
15
12
  import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
13
+ import { bindWorkspacePlugin } from "../../../services/workspace/plugin-releases.js";
16
14
  import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
17
- import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../../services/workspace/workspace-mcp.js";
15
+ import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
18
16
  import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../../model/workspace-config.js";
19
17
  import { initializeWorkspace } from "../../../services/workspace/workspace-preparation.js";
20
- import { checkHistoryMigrationNotice } from "../../../services/history/history-migrate.js";
21
- import { checkHistorySummaryReminder } from "../../../services/history/summary-runner.js";
18
+ import { historyStartupNotices } from "../../../services/history/summary-runner.js";
22
19
  import { McpWorkerRuntime, defaultWorkerDirectory } from "../../mcp/workers.js";
23
20
 
24
21
  export const dshDependencies = ["agents", "sessions", "sessionPersistence", "sessionQuery", "llm", "tools", "systemPrompt", "skills", "fs", "workingDirectory", "approval"];
@@ -43,8 +40,6 @@ export class DshWorkspace {
43
40
 
44
41
  async open() {
45
42
  this.check();
46
- const mcpEntry = resolve(resourceRoot, "../lib/extension/mcp.js");
47
- const workerDir = defaultWorkerDirectory();
48
43
  this.#scope = await this.agent.ctx.plugin({
49
44
  name: "pbot-coordinator",
50
45
  inject: dshDependencies,
@@ -55,29 +50,19 @@ export class DshWorkspace {
55
50
  if (this.features.history) {
56
51
  registerDshHistoryTool(ctx, this.agent, this.root, this.lifetime.signal, this.check);
57
52
  registerDshHistoryEvents(ctx, this.agent, this.root);
58
- try {
59
- const migrationNotice = checkHistoryMigrationNotice(this.root);
60
- if (migrationNotice) this.ctx.logger.info(migrationNotice);
61
- const reminder = checkHistorySummaryReminder(this.root);
62
- if (reminder) this.ctx.logger.info(reminder.message);
63
- } catch { /* Never block workspace startup if history reminder probe fails. */ }
53
+ for (const notice of historyStartupNotices(this.root)) this.ctx.logger.info(notice);
64
54
  }
65
- if (existsSync(mcpEntry)) {
55
+ const server = this.workers.nativeServer(this.root);
56
+ if (server) {
66
57
  await ctx.plugin(McpClient, McpClient.Config({
67
58
  transport: "stdio",
68
59
  serverName: "pbot",
69
- command: process.execPath,
70
- args: [mcpEntry],
60
+ ...server,
71
61
  env: {
72
62
  ...(process.env.PATH ? { PATH: process.env.PATH } : {}),
73
63
  ...(process.env.HOME ? { HOME: process.env.HOME } : {}),
74
64
  ...(process.env.DSH_HOME ? { DSH_HOME: process.env.DSH_HOME } : {}),
75
- PBOT_HOST: "dsh",
76
- PBOT_WORKSPACE_ROOT: this.root,
77
- PBOT_MCP_AGENT_DIR: workerDir,
78
- PBOT_MCP_SESSION_ID: this.agent.id,
79
- PBOT_NATIVE_WORKSPACE_MCP: "1",
80
- PBOT_NATIVE_HISTORY: "1",
65
+ ...server.env,
81
66
  },
82
67
  cwd: this.root,
83
68
  toolCallTimeoutMs: 600_000,
@@ -85,21 +70,9 @@ export class DshWorkspace {
85
70
  }));
86
71
  }
87
72
  if (this.features.mcp) {
88
- const mcpConfig = await readWorkspaceMcpConfig(this.root);
89
- this.check();
90
- if (mcpConfig.error) {
91
- this.ctx.logger.warn(mcpConfig.error);
92
- } else {
93
- for (const [serverName, server] of Object.entries(mcpConfig.servers)) {
94
- if (server.enabled === false) continue;
95
- try {
96
- const resolved = resolveWorkspaceMcpServer(this.root, serverName, server);
97
- await ctx.plugin(McpClient, toDshMcpConfig(resolved));
98
- } catch (error) {
99
- this.ctx.logger.warn(error instanceof Error ? error.message : String(error));
100
- }
101
- }
102
- }
73
+ await loadNativeWorkspaceServers(this.root, async server => {
74
+ await ctx.plugin(McpClient, toDshMcpConfig(server));
75
+ }, { check: this.check, warn: message => this.ctx.logger.warn(message) });
103
76
  }
104
77
  },
105
78
  });
@@ -149,6 +122,7 @@ export class DshWorkspaces {
149
122
  }
150
123
  let workspace: DshWorkspace | undefined;
151
124
  try {
125
+ bindWorkspacePlugin(root, "dsh");
152
126
  workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, workspaceFeatures(configuration));
153
127
  const owned = workspace;
154
128
  const dispose = agent.ctx.effect(() => async () => {
@@ -1,3 +1,4 @@
1
+ import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
1
2
  import { stat } from "node:fs/promises";
2
3
  import { realpathSync } from "node:fs";
3
4
  import { join } from "node:path";
@@ -7,7 +8,7 @@ import { acpMember } from "../../acp/member.js";
7
8
  import { agentFileTools } from "../../../integrations/hosts/pi/agent-tools.js";
8
9
  import { toPiMcpConfig } from "../../../integrations/hosts/pi/mcp.js";
9
10
  import { authorizeMutation } from "../../../services/workspace/workspace-files.js";
10
- import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../../services/workspace/workspace-mcp.js";
11
+ import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
11
12
  import { resourceRoot } from "../../../common/paths.js";
12
13
  import { launch } from "../../../storage/agent-files.js";
13
14
  import { requireThat } from "../../../common/validation.js";
@@ -24,16 +25,9 @@ export default async function piAcpMember(pi: ExtensionAPI) {
24
25
  requireThat(reference.host === "acp" && reference.backend === "pi" && realpathSync(ctx.cwd) === member.d.cwd &&
25
26
  (reference.sessionId === null || reference.sessionId === ctx.sessionManager.getSessionId()), "Pi ACP 会话身份或工作目录不匹配。");
26
27
  };
27
- const workspaceMcpServers: ReturnType<typeof resolveWorkspaceMcpServer>[] = [];
28
+ const workspaceMcpServers: ResolvedWorkspaceMcpServer[] = [];
28
29
  if (member.features.mcp && process.env.PBOT_ACP_VALIDATE !== "1") {
29
- const mcpConfig = await readWorkspaceMcpConfig(member.d.workspace);
30
- if (!mcpConfig.error) {
31
- for (const [name, server] of Object.entries(mcpConfig.servers)) {
32
- if (server.enabled === false) continue;
33
- try { workspaceMcpServers.push(resolveWorkspaceMcpServer(member.d.workspace, name, server)); }
34
- catch { /* Leave individual misconfigured servers unavailable without aborting the worker. */ }
35
- }
36
- }
30
+ await loadNativeWorkspaceServers(member.d.workspace, server => { workspaceMcpServers.push(server); });
37
31
  }
38
32
  pi.on("resources_discover", async () => {
39
33
  if (!member.features.skills || member.d.options.noSkills) return {};
@@ -1,17 +1,11 @@
1
+ import { inspectWorkspaceSummaries } from "../../../services/history/summary-runner.js";
2
+ import { workspaceDisabledMessage } from "../../../services/workspace/workspace-config.js";
1
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
4
  import { packageVersion } from "../../../common/version.js";
3
- import { requireThat } from "../../../common/validation.js";
4
- import { createAcpHistorySummarizer } from "../../../integrations/acp/history-summary.js";
5
- import { migrateWorkspaceHistory } from "../../../services/history/history-migrate.js";
6
- import { parseHistoryCommand } from "../../../services/history/summary-command.js";
7
- import { listSummaryDimensions } from "../../../services/history/summary-registry.js";
8
- import { inspectWorkspaceSummaries, runWorkspaceSummaries } from "../../../services/history/summary-runner.js";
9
5
  import { initializeWorkspace } from "../../../services/workspace/workspace-preparation.js";
10
- import { readWorkspaceConfig, readWorkspaceHistoryLayoutSync, workspaceDisabledMessage, workspaceSummaryConfig } from "../../../services/workspace/workspace-config.js";
11
- import { executeHistory } from "../../../tools/history/actions.js";
12
- import { historyInput } from "../../../tools/history/contract.js";
13
6
  import type { Confirmations } from "../../../ui/pi/confirmation.js";
14
7
  import type { Lifecycle } from "./lifecycle.js";
8
+ import { runHistoryCommand } from "../../history/command.js";
15
9
  import { parseWorkerCommand } from "../../mcp/workers.js";
16
10
 
17
11
  function formatHistoryStatusLine(root: string): string[] {
@@ -82,61 +76,18 @@ export function registerCommand(pi: ExtensionAPI, lifecycle: Lifecycle, confirma
82
76
  }
83
77
  if (command === "history") {
84
78
  try {
85
- requireThat(instance.features.history, "当前工作区已停用历史功能(features.history: false)。");
86
- const parsed = parseHistoryCommand(argument);
87
- if (parsed.kind === "status") {
88
- ctx.ui.notify(JSON.stringify(inspectWorkspaceSummaries(instance.root), null, 2), "info");
89
- return;
90
- }
91
- if (parsed.kind === "list") {
92
- const layout = readWorkspaceHistoryLayoutSync(instance.root);
93
- const dims = listSummaryDimensions(layout).map(({ id, title, description }) => ({ id, title, description }));
94
- ctx.ui.notify(JSON.stringify({ layout, dimensions: dims }, null, 2), "info");
95
- return;
96
- }
97
- if (parsed.kind === "migrate") {
98
- const report = migrateWorkspaceHistory(instance.root, { dryRun: parsed.dryRun });
99
- ctx.ui.notify(JSON.stringify(report, null, 2), "info");
100
- return;
101
- }
102
- if (parsed.kind === "query") {
103
- const result = executeHistory(instance.root, historyInput(parsed.input), instance.signal());
104
- ctx.ui.notify(JSON.stringify(result, null, 2), "info");
105
- return;
106
- }
107
- const signal = instance.signal();
108
- const config = await readWorkspaceConfig(instance.root);
109
- requireThat(config.enabled && !config.error, workspaceDisabledMessage(config));
110
- const summaryCfg = workspaceSummaryConfig(config);
111
- const backend = parsed.backend ?? summaryCfg.backend;
112
- const model = parsed.model ?? summaryCfg.model;
113
- const thinking = parsed.thinking ?? summaryCfg.thinking;
114
- const summarizer = createAcpHistorySummarizer({
115
- cwd: instance.root,
116
- backend,
117
- ...(config.acp ? { commands: config.acp } : {}),
118
- ...(model ? { model } : {}),
119
- ...(thinking ? { thinking } : {}),
79
+ const result = await runHistoryCommand(instance, argument, instance.signal(), {
80
+ start: backend => ctx.ui.setStatus("pbot-history", `历史摘要生成中 (${backend})`),
81
+ update: progress => {
82
+ if (lifecycle.active === instance) {
83
+ ctx.ui.setStatus("pbot-history", `历史摘要 ${progress.dimension} (${progress.completed}/${progress.total})`);
84
+ }
85
+ },
86
+ finish: () => {
87
+ if (lifecycle.active === instance) ctx.ui.setStatus("pbot-history", undefined);
88
+ },
120
89
  });
121
- ctx.ui.setStatus("pbot-history", `历史摘要生成中 (${backend})`);
122
- try {
123
- const report = await runWorkspaceSummaries({
124
- root: instance.root,
125
- summarizer,
126
- ...(parsed.dimensions ? { dimensions: parsed.dimensions } : {}),
127
- force: parsed.force,
128
- ...(summaryCfg.concurrency !== undefined ? { concurrency: summaryCfg.concurrency } : {}),
129
- signal,
130
- onProgress: progress => {
131
- if (lifecycle.active === instance) {
132
- ctx.ui.setStatus("pbot-history", `历史摘要 ${progress.dimension} (${progress.completed}/${progress.total})`);
133
- }
134
- },
135
- });
136
- ctx.ui.notify(JSON.stringify({ backend, ...(model ? { model } : {}), ...report }, null, 2), "info");
137
- } finally {
138
- if (lifecycle.active === instance) ctx.ui.setStatus("pbot-history", undefined);
139
- }
90
+ ctx.ui.notify(JSON.stringify(result, null, 2), "info");
140
91
  } catch (error) {
141
92
  ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
142
93
  }
@@ -6,8 +6,7 @@ import { loadWorkspaceContext } from "../../../integrations/agent-resources.js";
6
6
  import type { Confirmations } from "../../../ui/pi/confirmation.js";
7
7
  import type { Lifecycle } from "./lifecycle.js";
8
8
  import { readWorkspaceConfig, workspaceDisabledMessage } from "../../../services/workspace/workspace-config.js";
9
- import { checkHistoryMigrationNotice } from "../../../services/history/history-migrate.js";
10
- import { checkHistorySummaryReminder } from "../../../services/history/summary-runner.js";
9
+ import { historyStartupNotices } from "../../../services/history/summary-runner.js";
11
10
  import { workspaceSkillPaths } from "../../../integrations/hosts/pi/skills.js";
12
11
 
13
12
  export function registerEvents(pi: ExtensionAPI, lifecycle: Lifecycle, confirmations: Confirmations) {
@@ -21,12 +20,7 @@ export function registerEvents(pi: ExtensionAPI, lifecycle: Lifecycle, confirmat
21
20
  }
22
21
  ctx.ui.setStatus("pbot", "PBot 已启动");
23
22
  if (lifecycle.active.features.history && ctx.hasUI) {
24
- try {
25
- const migrationNotice = checkHistoryMigrationNotice(lifecycle.active.root);
26
- if (migrationNotice) ctx.ui.notify(migrationNotice, "info");
27
- const reminder = checkHistorySummaryReminder(lifecycle.active.root);
28
- if (reminder) ctx.ui.notify(reminder.message, "info");
29
- } catch { /* Never block session startup if history reminder probe fails. */ }
23
+ for (const notice of historyStartupNotices(lifecycle.active.root)) ctx.ui.notify(notice, "info");
30
24
  }
31
25
  } catch (error) {
32
26
  ctx.ui.setStatus("pbot", "PBot 启动失败");
@@ -1,12 +1,12 @@
1
1
  import { realpath } from "node:fs/promises";
2
2
  import { requireThat } from "../../../common/validation.js";
3
+ import { bindWorkspacePlugin } from "../../../services/workspace/plugin-releases.js";
3
4
  import { authorizeMutation } from "../../../services/workspace/workspace-files.js";
4
- import type { CallAccess } from "../../../tools/access.js";
5
5
  import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
6
6
  import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../../model/workspace-config.js";
7
7
  import type { McpWorkerRuntime } from "../../mcp/workers.js";
8
8
 
9
- export class WorkspaceInstance implements CallAccess {
9
+ export class WorkspaceInstance {
10
10
  readonly #controller = new AbortController();
11
11
  #work = new AbortController();
12
12
  #closing: Promise<void> | undefined;
@@ -73,6 +73,7 @@ export class Lifecycle {
73
73
  this.root = await realpath(root);
74
74
  this.configuration = await readWorkspaceConfig(this.root);
75
75
  if (!this.configuration.enabled) return;
76
+ bindWorkspacePlugin(this.root, "pi");
76
77
  const instance = this.create(this.root, sessionId, this.configuration);
77
78
  this.#active = instance;
78
79
  try { await this.register(instance); }