personal-bot 0.3.1 → 0.3.3

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 (436) 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 +27 -11
  8. package/bin/pbot.mjs +22 -2
  9. package/docs/README.md +3 -1
  10. package/docs/architecture/design.md +37 -24
  11. package/docs/architecture/extensibility.md +27 -19
  12. package/docs/architecture/model-context.md +4 -3
  13. package/docs/architecture/principles.md +5 -4
  14. package/docs/guides/capabilities.md +4 -4
  15. package/docs/guides/cross-harness-workers.md +3 -1
  16. package/docs/guides/history.md +73 -16
  17. package/docs/guides/workspace-configuration.md +35 -6
  18. package/docs/hosts/antigravity.md +2 -0
  19. package/docs/hosts/claude-code.md +1 -1
  20. package/docs/hosts/codex-qoder.md +63 -0
  21. package/docs/hosts/dsh.md +1 -1
  22. package/docs/hosts/pi.md +1 -1
  23. package/docs/maintainers/architecture-governance.md +78 -0
  24. package/hooks/hooks.json +3 -0
  25. package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
  26. package/lib/antigravity-plugin/LICENSE +21 -0
  27. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
  28. package/lib/antigravity-plugin/hooks.json +7 -0
  29. package/lib/antigravity-plugin/lib/claude.js +2 -2
  30. package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
  31. package/lib/antigravity-plugin/lib/common/files.js +44 -0
  32. package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
  33. package/lib/antigravity-plugin/lib/common/validation.js +8 -0
  34. package/lib/{extension/acp-member.d.ts → antigravity-plugin/lib/extension/acp/member.d.ts} +5 -5
  35. package/lib/{extension/acp-member.js → antigravity-plugin/lib/extension/acp/member.js} +6 -6
  36. package/lib/antigravity-plugin/lib/extension/acp-worker.js +222 -51
  37. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  38. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
  39. package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.js +11 -25
  40. package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.js +3 -3
  41. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  42. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
  43. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +12 -0
  44. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +101 -0
  45. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  46. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
  47. package/lib/antigravity-plugin/lib/extension/mcp.js +2705 -1348
  48. package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20127 -0
  49. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
  50. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +6 -2
  51. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  52. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
  53. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  54. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +36 -0
  55. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  56. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
  57. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.d.ts +1 -1
  58. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.d.ts +1 -1
  59. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.js +4 -4
  60. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.js +1 -1
  61. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  62. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
  63. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  64. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
  65. package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
  66. package/lib/{integrations/hosts/registry.js → antigravity-plugin/lib/integrations/hosts/plugin-registry.js} +10 -3
  67. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  68. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
  69. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  70. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
  71. package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
  72. package/lib/antigravity-plugin/lib/model/acp.js +8 -0
  73. package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
  74. package/lib/antigravity-plugin/lib/model/agent.js +4 -0
  75. package/lib/antigravity-plugin/lib/model/history.d.ts +179 -0
  76. package/lib/antigravity-plugin/lib/model/history.js +4 -0
  77. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +31 -0
  78. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +28 -7
  79. package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
  80. package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
  81. package/lib/antigravity-plugin/lib/plugin.js +4 -4
  82. package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
  83. package/lib/antigravity-plugin/lib/services/history/history-capture.js +98 -0
  84. package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
  85. package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
  86. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  87. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
  88. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
  89. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
  90. package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
  91. package/lib/antigravity-plugin/lib/services/history/summary-registry.js +35 -0
  92. package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +34 -0
  93. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +299 -0
  94. package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
  95. package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
  96. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +3 -0
  97. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +78 -0
  98. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
  99. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +77 -7
  100. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
  101. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
  102. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
  103. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
  104. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
  105. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
  106. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
  107. package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
  108. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
  109. package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
  110. package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
  111. package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
  112. package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
  113. package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
  114. package/lib/antigravity-plugin/lib/storage/history-files.d.ts +55 -0
  115. package/lib/antigravity-plugin/lib/storage/history-files.js +473 -0
  116. package/lib/antigravity-plugin/lib/storage/history-format.d.ts +5 -0
  117. package/lib/antigravity-plugin/lib/storage/history-format.js +60 -0
  118. package/lib/antigravity-plugin/package.json +1 -1
  119. package/lib/antigravity-plugin/plugin.json +1 -1
  120. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
  121. package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
  122. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
  123. package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
  124. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
  125. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
  126. package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
  127. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
  128. package/lib/claude.js +2 -2
  129. package/lib/client.js +42 -60
  130. package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
  131. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
  132. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
  133. package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
  134. package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
  135. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
  136. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
  137. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
  138. package/lib/common/validation.d.ts +4 -0
  139. package/lib/common/validation.js +8 -0
  140. package/lib/dsh.js +6 -6
  141. package/lib/extension/acp/member.d.ts +18 -0
  142. package/lib/extension/acp/member.js +44 -0
  143. package/lib/extension/acp/worker.js +384 -0
  144. package/lib/extension/acp-worker.js +222 -51
  145. package/lib/extension/history/command.d.ts +37 -0
  146. package/lib/extension/history/command.js +57 -0
  147. package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  148. package/lib/extension/hosts/dsh/acp-entry.js +22 -0
  149. package/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
  150. package/lib/extension/hosts/dsh/acp-member.js +58 -0
  151. package/lib/extension/{dsh → hosts/dsh}/command.d.ts +1 -2
  152. package/lib/extension/{dsh → hosts/dsh}/command.js +9 -11
  153. package/lib/extension/hosts/dsh/files.d.ts +5 -0
  154. package/lib/extension/hosts/dsh/files.js +67 -0
  155. package/lib/extension/hosts/dsh/history.d.ts +4 -0
  156. package/lib/extension/hosts/dsh/history.js +62 -0
  157. package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
  158. package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
  159. package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
  160. package/lib/extension/{dsh → hosts/dsh}/workspace.js +30 -99
  161. package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  162. package/lib/extension/hosts/pi/acp-member.js +100 -0
  163. package/lib/extension/hosts/plugin-runtime.d.ts +12 -0
  164. package/lib/extension/hosts/plugin-runtime.js +101 -0
  165. package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  166. package/lib/extension/hosts/workspace-mcp.js +21 -0
  167. package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +7 -9
  168. package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +70 -88
  169. package/lib/extension/{mcp-workers.d.ts → mcp/tool-contract.d.ts} +129 -374
  170. package/lib/extension/mcp/tool-contract.js +441 -0
  171. package/lib/extension/mcp/workers.d.ts +487 -0
  172. package/lib/extension/mcp/workers.js +598 -0
  173. package/lib/extension/mcp.js +2705 -1348
  174. package/lib/extension/{setup-cli.js → setup/cli.js} +12 -9
  175. package/lib/extension/workspace-cli.js +20127 -0
  176. package/lib/integrations/acp/agents.d.ts +2 -3
  177. package/lib/integrations/acp/connection.d.ts +11 -10
  178. package/lib/integrations/acp/connection.js +6 -0
  179. package/lib/integrations/acp/harnesses/claude.js +1 -1
  180. package/lib/integrations/acp/harnesses/dsh.js +1 -1
  181. package/lib/integrations/acp/harnesses/presets.js +8 -0
  182. package/lib/integrations/acp/history-summary.d.ts +17 -0
  183. package/lib/integrations/acp/history-summary.js +101 -0
  184. package/lib/integrations/acp/launch.d.ts +2 -2
  185. package/lib/integrations/agent-resources.d.ts +1 -0
  186. package/lib/integrations/agent-resources.js +6 -2
  187. package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  188. package/lib/integrations/hosts/antigravity/adapter.js +171 -0
  189. package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  190. package/lib/integrations/hosts/claude/adapter.js +36 -0
  191. package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  192. package/lib/integrations/hosts/codex/adapter.js +14 -0
  193. package/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
  194. package/lib/integrations/hosts/dsh/mcp.js +28 -0
  195. package/lib/integrations/hosts/dsh/messages.d.ts +36 -0
  196. package/lib/integrations/hosts/dsh/messages.js +11 -0
  197. package/lib/integrations/hosts/dsh/resources.d.ts +6 -0
  198. package/lib/integrations/hosts/dsh/resources.js +47 -0
  199. package/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
  200. package/lib/integrations/hosts/dsh/root-agents.js +3 -0
  201. package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
  202. package/lib/integrations/hosts/dsh/skills.d.ts +8 -0
  203. package/lib/integrations/hosts/dsh/skills.js +31 -0
  204. package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  205. package/lib/integrations/hosts/pi/agent-tools.js +32 -0
  206. package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  207. package/lib/integrations/hosts/pi/mcp.js +23 -0
  208. package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
  209. package/lib/{antigravity-plugin/lib/integrations/hosts/registry.js → integrations/hosts/plugin-registry.js} +10 -3
  210. package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  211. package/lib/integrations/hosts/prompt-hooks.js +76 -0
  212. package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  213. package/lib/integrations/hosts/qoder/adapter.js +16 -0
  214. package/lib/integrations/installation/pi-setup.js +1 -1
  215. package/lib/model/acp.d.ts +7 -3
  216. package/lib/model/acp.js +8 -0
  217. package/lib/model/agent.d.ts +18 -4
  218. package/lib/model/agent.js +4 -1
  219. package/lib/model/history.d.ts +143 -34
  220. package/lib/model/history.js +4 -1
  221. package/lib/model/installation.js +1 -0
  222. package/lib/model/plugin-host.d.ts +31 -0
  223. package/lib/model/workspace-config.d.ts +28 -7
  224. package/lib/model/workspace-config.js +2 -1
  225. package/lib/plugin.d.ts +2 -1
  226. package/lib/plugin.js +4 -4
  227. package/lib/qoder-plugin/.mcp.json +17 -0
  228. package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
  229. package/lib/qoder-plugin/DISCLAIMER.md +17 -0
  230. package/lib/qoder-plugin/LICENSE +21 -0
  231. package/lib/qoder-plugin/hooks/hooks.json +37 -0
  232. package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
  233. package/lib/services/agents/agent-run.d.ts +1 -1
  234. package/lib/services/agents/agent-service.d.ts +15 -45
  235. package/lib/services/agents/agent-service.js +22 -3
  236. package/lib/services/history/history-capture.d.ts +4 -0
  237. package/lib/services/history/history-capture.js +98 -0
  238. package/lib/services/history/history-index.d.ts +16 -7
  239. package/lib/services/history/history-index.js +48 -70
  240. package/lib/services/history/history-migrate.d.ts +12 -0
  241. package/lib/services/history/history-migrate.js +54 -0
  242. package/lib/services/history/history-query.d.ts +51 -0
  243. package/lib/services/history/history-query.js +352 -0
  244. package/lib/services/history/summary-command.d.ts +20 -0
  245. package/lib/services/history/summary-command.js +69 -0
  246. package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  247. package/lib/services/history/summary-dimensions/monthly.js +121 -0
  248. package/lib/services/history/summary-dimensions/session.d.ts +7 -0
  249. package/lib/services/history/summary-dimensions/session.js +124 -0
  250. package/lib/services/history/summary-registry.d.ts +7 -0
  251. package/lib/services/history/summary-registry.js +35 -0
  252. package/lib/services/history/summary-runner.d.ts +34 -0
  253. package/lib/services/history/summary-runner.js +299 -0
  254. package/lib/services/history/workspace-history.d.ts +3 -0
  255. package/lib/services/history/workspace-history.js +6 -0
  256. package/lib/services/workspace/plugin-releases.d.ts +3 -0
  257. package/lib/services/workspace/plugin-releases.js +78 -0
  258. package/lib/services/workspace/workspace-config.d.ts +5 -1
  259. package/lib/services/workspace/workspace-config.js +77 -7
  260. package/lib/services/workspace/workspace-mcp.js +22 -29
  261. package/lib/services/workspace/workspace-skills.d.ts +1 -0
  262. package/lib/services/workspace/workspace-skills.js +4 -2
  263. package/lib/storage/acp-files.js +7 -12
  264. package/lib/storage/agent-files.js +6 -5
  265. package/lib/storage/atomic-json.d.ts +3 -1
  266. package/lib/storage/atomic-json.js +43 -3
  267. package/lib/storage/history-files.d.ts +46 -9
  268. package/lib/storage/history-files.js +382 -250
  269. package/lib/storage/history-format.d.ts +3 -13
  270. package/lib/storage/history-format.js +26 -52
  271. package/lib/tools/history/actions.d.ts +3 -68
  272. package/lib/tools/history/actions.js +7 -5
  273. package/lib/tools/history/contract.d.ts +16 -17
  274. package/lib/tools/history/contract.js +63 -22
  275. package/lib/tools/history/dsh-tool.d.ts +1 -2
  276. package/lib/tools/history/dsh-tool.js +11 -5
  277. package/lib/ui/dsh/elements.d.ts +2 -5
  278. package/lib/ui/dsh/elements.js +3 -16
  279. package/lib/ui/dsh/management.js +26 -13
  280. package/lib/ui/dsh/styles.d.ts +1 -1
  281. package/lib/ui/dsh/styles.js +5 -33
  282. package/package.json +4 -1
  283. package/resources/antigravity/skills/pbot/SKILL.md +11 -1
  284. package/resources/claude/skills/pbot/SKILL.md +11 -1
  285. package/resources/plugin/skills/pbot/SKILL.md +9 -0
  286. package/resources/prompts/history-coordinator.md +2 -1
  287. package/resources/prompts/history-monthly-summary.md +13 -0
  288. package/resources/prompts/history-summary.md +10 -4
  289. package/resources/prompts/plugin-coordinator.md +1 -0
  290. package/resources/skills/provider-connections/SKILL.md +22 -12
  291. package/scripts/README.md +3 -2
  292. package/src/claude.ts +2 -2
  293. package/src/common/validation.ts +10 -0
  294. package/src/dsh.ts +6 -6
  295. package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
  296. package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
  297. package/src/extension/history/command.ts +68 -0
  298. package/src/extension/hosts/dsh/acp-entry.ts +21 -0
  299. package/src/extension/{dsh → hosts/dsh}/acp-member.ts +12 -23
  300. package/src/extension/{dsh → hosts/dsh}/command.ts +10 -12
  301. package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
  302. package/src/extension/hosts/dsh/history.ts +67 -0
  303. package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
  304. package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -76
  305. package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +12 -18
  306. package/src/extension/{command.ts → hosts/pi/command.ts} +44 -11
  307. package/src/extension/{events.ts → hosts/pi/events.ts} +8 -4
  308. package/src/extension/hosts/pi/history.ts +45 -0
  309. package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +9 -12
  310. package/src/extension/hosts/plugin-runtime.ts +96 -0
  311. package/src/extension/hosts/workspace-mcp.ts +25 -0
  312. package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +85 -85
  313. package/src/extension/mcp/tool-contract.ts +462 -0
  314. package/src/extension/{mcp-workers.ts → mcp/workers.ts} +151 -448
  315. package/src/extension/{setup-cli.ts → setup/cli.ts} +14 -11
  316. package/src/extension/setup/workspace-cli.ts +159 -0
  317. package/src/integrations/acp/agents.ts +2 -3
  318. package/src/integrations/acp/connection.ts +6 -0
  319. package/src/integrations/acp/harnesses/claude.ts +1 -1
  320. package/src/integrations/acp/harnesses/dsh.ts +1 -1
  321. package/src/integrations/acp/harnesses/presets.ts +8 -0
  322. package/src/integrations/acp/history-summary.ts +109 -0
  323. package/src/integrations/agent-resources.ts +7 -1
  324. package/src/integrations/hosts/antigravity/adapter.ts +161 -0
  325. package/src/integrations/hosts/claude/adapter.ts +39 -0
  326. package/src/integrations/hosts/codex/adapter.ts +16 -0
  327. package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
  328. package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
  329. package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
  330. package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
  331. package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
  332. package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
  333. package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
  334. package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +11 -3
  335. package/src/integrations/hosts/prompt-hooks.ts +72 -0
  336. package/src/integrations/hosts/qoder/adapter.ts +19 -0
  337. package/src/integrations/installation/cli-update.ts +116 -0
  338. package/src/integrations/installation/pi-bridge.ts +1 -1
  339. package/src/integrations/installation/pi-setup.ts +2 -2
  340. package/src/integrations/installation/processes.ts +1 -1
  341. package/src/mcp.ts +1 -1
  342. package/src/model/acp.ts +11 -3
  343. package/src/model/agent.ts +20 -4
  344. package/src/model/history.ts +156 -26
  345. package/src/model/installation.ts +41 -0
  346. package/src/model/plugin-host.ts +30 -2
  347. package/src/model/workspace-config.ts +31 -7
  348. package/src/pbot.ts +22 -50
  349. package/src/plugin.ts +4 -4
  350. package/src/services/agents/agent-service.ts +29 -17
  351. package/src/services/history/history-capture.ts +91 -0
  352. package/src/services/history/history-index.ts +48 -62
  353. package/src/services/history/history-migrate.ts +62 -0
  354. package/src/services/history/history-query.ts +401 -0
  355. package/src/services/history/summary-command.ts +70 -0
  356. package/src/services/history/summary-dimensions/monthly.ts +139 -0
  357. package/src/services/history/summary-dimensions/session.ts +149 -0
  358. package/src/services/history/summary-registry.ts +43 -0
  359. package/src/services/history/summary-runner.ts +343 -0
  360. package/src/services/history/workspace-history.ts +8 -0
  361. package/src/services/installation/setup-service.ts +2 -41
  362. package/src/services/workspace/plugin-releases.ts +68 -0
  363. package/src/services/workspace/workspace-config.ts +95 -8
  364. package/src/services/workspace/workspace-mcp.ts +23 -28
  365. package/src/services/workspace/workspace-skills.ts +5 -2
  366. package/src/storage/acp-files.ts +7 -12
  367. package/src/storage/agent-files.ts +6 -5
  368. package/src/storage/atomic-json.ts +31 -4
  369. package/src/storage/history-files.ts +416 -189
  370. package/src/storage/history-format.ts +45 -61
  371. package/src/tools/history/actions.ts +8 -6
  372. package/src/tools/history/contract.ts +70 -25
  373. package/src/tools/history/dsh-tool.ts +17 -8
  374. package/src/tools/history/pi-tool.ts +23 -0
  375. package/src/ui/dsh/elements.ts +5 -12
  376. package/src/ui/dsh/management.ts +36 -20
  377. package/src/ui/dsh/styles.ts +5 -33
  378. package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
  379. package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +0 -10
  380. package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +0 -67
  381. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
  382. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
  383. package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +0 -60
  384. package/lib/extension/dsh/history.d.ts +0 -15
  385. package/lib/extension/dsh/history.js +0 -87
  386. package/lib/extension/mcp-workers.js +0 -882
  387. package/lib/extension/plugin-runtime.d.ts +0 -10
  388. package/lib/extension/plugin-runtime.js +0 -67
  389. package/lib/integrations/dsh/history-summary.d.ts +0 -11
  390. package/lib/integrations/dsh/history-summary.js +0 -36
  391. package/lib/integrations/dsh/history.d.ts +0 -16
  392. package/lib/integrations/dsh/history.js +0 -167
  393. package/lib/integrations/history-summary.d.ts +0 -4
  394. package/lib/integrations/history-summary.js +0 -32
  395. package/lib/integrations/hosts/antigravity.d.ts +0 -4
  396. package/lib/integrations/hosts/antigravity.js +0 -79
  397. package/lib/integrations/hosts/claude.js +0 -60
  398. package/lib/services/history/history-service.d.ts +0 -106
  399. package/lib/services/history/history-service.js +0 -242
  400. package/lib/storage/acp-history.d.ts +0 -10
  401. package/lib/storage/acp-history.js +0 -57
  402. package/lib/ui/presentation.d.ts +0 -3
  403. package/lib/ui/presentation.js +0 -12
  404. package/src/extension/dsh/history.ts +0 -74
  405. package/src/extension/history.ts +0 -26
  406. package/src/extension/plugin-runtime.ts +0 -63
  407. package/src/integrations/dsh/history-summary.ts +0 -39
  408. package/src/integrations/dsh/history.ts +0 -84
  409. package/src/integrations/history-summary.ts +0 -30
  410. package/src/integrations/hosts/antigravity.ts +0 -83
  411. package/src/integrations/hosts/claude.ts +0 -62
  412. package/src/integrations/pi/history.ts +0 -99
  413. package/src/services/history/history-service.ts +0 -195
  414. package/src/storage/acp-history.ts +0 -49
  415. package/src/tools/access.ts +0 -7
  416. package/src/tools/history/tool.ts +0 -19
  417. package/src/tools/register.ts +0 -22
  418. package/src/ui/presentation.ts +0 -12
  419. /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.d.ts +0 -0
  420. /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.d.ts +0 -0
  421. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.js +0 -0
  422. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.d.ts +0 -0
  423. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.js +0 -0
  424. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.d.ts +0 -0
  425. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.js +0 -0
  426. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.d.ts +0 -0
  427. /package/lib/extension/{acp-worker.d.ts → acp/worker.d.ts} +0 -0
  428. /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
  429. /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
  430. /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
  431. /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
  432. /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
  433. /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
  434. /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
  435. /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
  436. /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
@@ -4,21 +4,21 @@ import { mkdir, readFile, realpath } from "node:fs/promises";
4
4
  import { homedir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { executeSetup, packageChoices, parseCatalog, parseSetupArgs } from "../services/installation/setup-service.js";
8
- import { npmName, ordinaryNpm } from "../common/package-source.js";
9
- import type { InstalledPackage, SetupPlan } from "../services/installation/setup-service.js";
10
- import { PiBootstrapRequired, PiSetup, piPackageName } from "../integrations/installation/pi-setup.js";
11
- import { findExecutable, inspectSystem, SetupProcesses } from "../integrations/installation/processes.js";
12
- import { resolveWorkspace } from "../integrations/installation/workspace.js";
13
- import type { WorkspaceMcpServer } from "../model/workspace-mcp.js";
7
+ import { executeSetup, packageChoices, parseCatalog, parseSetupArgs } from "../../services/installation/setup-service.js";
8
+ import { npmName, ordinaryNpm } from "../../common/package-source.js";
9
+ import type { InstalledPackage, SetupPlan } from "../../model/installation.js";
10
+ import { PiBootstrapRequired, PiSetup, piPackageName } from "../../integrations/installation/pi-setup.js";
11
+ import { findExecutable, inspectSystem, SetupProcesses } from "../../integrations/installation/processes.js";
12
+ import { resolveWorkspace } from "../../integrations/installation/workspace.js";
13
+ import type { WorkspaceMcpServer } from "../../model/workspace-mcp.js";
14
14
  import {
15
15
  readWorkspaceMcpConfig,
16
16
  removeWorkspaceMcpServer,
17
17
  upsertWorkspaceMcpServer,
18
- } from "../services/workspace/workspace-mcp.js";
19
- import { SetupUI } from "../ui/setup.js";
18
+ } from "../../services/workspace/workspace-mcp.js";
19
+ import { SetupUI } from "../../ui/setup.js";
20
20
 
21
- const root = new URL("../../", import.meta.url);
21
+ const root = new URL("../../../", import.meta.url);
22
22
  const quote = (value: string) => "'" + value.replaceAll("'", "'\\''") + "'";
23
23
 
24
24
  const mcpManageUsage =
@@ -168,7 +168,10 @@ export async function main(args: string[]): Promise<number> {
168
168
  if (options.action === "help") {
169
169
  console.log("Personal Bot " + manifest.version + "\n\n用法:pbot setup [--workspace <目录>]\n" +
170
170
  " npx personal-bot@latest setup\n" +
171
+ " pbot init | status [--workspace <目录>] [--json]\n" +
172
+ " pbot history status|list|summary|migrate|search|read [参数] [--workspace <目录>] [--json]\n" +
171
173
  " pbot install-antigravity\n" +
174
+ " pbot plugin <host> hook|init|status\n" +
172
175
  " pbot mcp\n" +
173
176
  " pbot mcp list|add|remove ...\n\n" +
174
177
  "setup 安装或升级 Pi、pbot 和选中的插件,然后启动 Pi 执行 /pbot init。\n" +
@@ -281,7 +284,7 @@ export async function main(args: string[]): Promise<number> {
281
284
  await host.start(result.pi, workspace);
282
285
  } else {
283
286
  ui.text("稍后执行:\ncd " + quote(workspace) + "\n" + quote(result.pi.command) + " --extension " +
284
- quote(fileURLToPath(new URL("extension/setup-guard.js", new URL("../", import.meta.url)))) + " '/pbot init'");
287
+ quote(fileURLToPath(new URL("extension/setup/guard.js", new URL("../../", import.meta.url)))) + " '/pbot init'");
285
288
  }
286
289
  return failed ? 1 : 0;
287
290
  } catch (error) {
@@ -0,0 +1,159 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { mkdir, stat } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { pathToFileURL } from "node:url";
5
+ import { parseArgs } from "node:util";
6
+ import { gte, valid } from "semver";
7
+ import { requireThat } from "../../common/validation.js";
8
+ import { packageVersion } from "../../common/version.js";
9
+ import { getPluginHost, pluginMcpWorkspaceRoot } from "../../integrations/hosts/plugin-registry.js";
10
+ import { minimumCliRelease, runUpdatedCli } from "../../integrations/installation/cli-update.js";
11
+ import { resolveWorkspace } from "../../integrations/installation/workspace.js";
12
+ import { parseHistoryCommand, type ParsedHistoryCommand } from "../../services/history/summary-command.js";
13
+ import { workspacePluginReleases } from "../../services/workspace/plugin-releases.js";
14
+ import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../services/workspace/workspace-config.js";
15
+ import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
16
+
17
+ const usage = `pbot init | status [--workspace <目录>] [--json]
18
+ pbot history status | list
19
+ pbot history summary [维度...] [--force] [--backend <acp>] [--model <模型>] [--thinking <级别>]
20
+ pbot history migrate [--dry-run]
21
+ pbot history search [关键词] [--host <来源>] [--dimension <维度>] [--session-id <ID>] [--from <时间>] [--to <时间>] [--offset N] [--limit N]
22
+ pbot history read <节点ID> [--host <来源>] [--offset N] [--limit N] [--children-offset N]
23
+ 所有工作区命令支持 --workspace <目录> 和 --json。默认工作区为当前目录。`;
24
+
25
+ function workspaceArgs(args: readonly string[]) {
26
+ const rest: string[] = [];
27
+ let workspace: string | undefined;
28
+ let json = false;
29
+ for (let index = 0; index < args.length; index++) {
30
+ const token = args[index]!;
31
+ if (token === "--") { rest.push(...args.slice(index)); break; }
32
+ if (token === "--workspace" || token.startsWith("--workspace=")) {
33
+ requireThat(workspace === undefined, "--workspace 只能指定一次。");
34
+ workspace = token === "--workspace" ? args[++index] : token.slice("--workspace=".length);
35
+ requireThat(workspace && !workspace.startsWith("-"), "--workspace 需要目录。");
36
+ } else if (token === "--json") json = true;
37
+ else rest.push(token);
38
+ }
39
+ return { workspace, json, rest };
40
+ }
41
+
42
+ function historyAction(args: string[]): ParsedHistoryCommand {
43
+ const [action, ...rest] = args;
44
+ if (action !== "search" && action !== "read") return parseHistoryCommand(args);
45
+ const string = { type: "string" } as const;
46
+ const { values, positionals } = parseArgs({
47
+ args: rest, allowPositionals: true,
48
+ options: {
49
+ host: string, offset: string, limit: string,
50
+ ...(action === "search" ? { dimension: string, "session-id": string, from: string, to: string } : { "children-offset": string }),
51
+ },
52
+ });
53
+ requireThat(positionals.length <= 1 && (action === "search" || positionals[0]), usage);
54
+ const input: Record<string, unknown> = { action };
55
+ if (positionals.length) input[action === "search" ? "query" : "id"] = positionals[0];
56
+ for (const [key, value] of Object.entries(values)) {
57
+ if (["offset", "limit", "children-offset"].includes(key)) {
58
+ requireThat(typeof value === "string" && /^\d+$/.test(value) && Number.isSafeInteger(Number(value)), "--" + key + " 需要非负整数。");
59
+ input[key === "children-offset" ? "childrenOffset" : key] = Number(value);
60
+ } else input[key === "session-id" ? "sessionId" : key] = value;
61
+ }
62
+ return { kind: "query", input };
63
+ }
64
+
65
+ export async function updateForWorkspace(root: string, args: string[], input?: string): Promise<number | undefined> {
66
+ return runUpdatedCli(await minimumCliRelease(root, workspacePluginReleases(root)), args, input);
67
+ }
68
+
69
+ /** Hook workspaces are resolved by the adapter from the event on stdin. */
70
+ export async function updateForCommand(args: string[]): Promise<number | undefined> {
71
+ if (args[0] === "plugin" && args[2] === "hook") return undefined;
72
+ const cwd = process.cwd();
73
+ let workspace: string;
74
+ if (args[0] === "plugin" && args[1]) {
75
+ workspace = await getPluginHost(args[1])?.resolveRoot(cwd) ?? cwd;
76
+ } else if (args[0] === "mcp" && args.length === 1) {
77
+ workspace = pluginMcpWorkspaceRoot() ?? cwd;
78
+ } else {
79
+ workspace = workspaceArgs(args).workspace ?? cwd;
80
+ }
81
+ const root = await resolveWorkspace(workspace, cwd, homedir());
82
+ const configuration = await readWorkspaceConfig(root);
83
+ const initializing = args[0] === "plugin" && args[2] === "init" && args.length === 3;
84
+ if (!configuration.enabled && !(initializing && !configuration.error)) return undefined;
85
+ return updateForWorkspace(root, args);
86
+ }
87
+
88
+ export async function main(args: string[]): Promise<number> {
89
+ if (args[0] === "--at-least") {
90
+ const version = args[1];
91
+ requireThat(args.length === 2 && version && valid(version), "用法:pbot --at-least <MAJOR.MINOR.PATCH>");
92
+ return gte(packageVersion, version) ? 0 : 1;
93
+ }
94
+ const { workspace, json, rest } = workspaceArgs(args);
95
+ const [verb, ...tail] = rest;
96
+ const delimiter = rest.indexOf("--");
97
+ if (rest.slice(0, delimiter < 0 ? rest.length : delimiter).some(token => token === "--help" || token === "-h")) {
98
+ console.log(usage);
99
+ return 0;
100
+ }
101
+ requireThat(verb === "history" || ["init", "status", "--version", "-v"].includes(verb ?? "") && !tail.length, usage);
102
+ if (verb === "--version" || verb === "-v") { console.log(packageVersion); return 0; }
103
+ const cwd = process.cwd();
104
+ const root = await resolveWorkspace(workspace ?? cwd, cwd, homedir());
105
+ let configuration = await readWorkspaceConfig(root);
106
+ if (verb === "init" && configuration.error) throw new Error(configuration.error);
107
+ if (verb === "history") {
108
+ requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
109
+ requireThat(workspaceFeatures(configuration).history, "当前工作区已停用历史功能(features.history: false)。");
110
+ }
111
+ const checkRelease = configuration.enabled || verb === "init";
112
+ const plugins = checkRelease ? workspacePluginReleases(root) : {};
113
+ const required = checkRelease ? await minimumCliRelease(root, plugins) : undefined;
114
+ const updated = await runUpdatedCli(required, args);
115
+ if (updated !== undefined) return updated;
116
+ const print = (result: unknown) => console.log(JSON.stringify(result, null, json ? undefined : 2));
117
+ if (verb === "init") {
118
+ await mkdir(root, { recursive: true });
119
+ await initializeWorkspace(root);
120
+ configuration = await readWorkspaceConfig(root);
121
+ }
122
+ requireThat((await stat(root)).isDirectory(), "工作区必须是目录。");
123
+ if (verb !== "history") {
124
+ print({ workspaceRoot: root, version: packageVersion, plugins, minimumCliVersion: required ?? null, configuration });
125
+ return configuration.error ? 1 : 0;
126
+ }
127
+ const command = historyAction(tail);
128
+ const controller = new AbortController();
129
+ let exitCode = 0;
130
+ const interrupt = () => { exitCode = 130; controller.abort(); };
131
+ const terminate = () => { exitCode = 143; controller.abort(); };
132
+ process.on("SIGINT", interrupt);
133
+ process.on("SIGTERM", terminate);
134
+ try {
135
+ const { runHistoryCommand } = await import("../history/command.js");
136
+ const result = await runHistoryCommand({ root, features: workspaceFeatures(configuration) }, command, controller.signal, {
137
+ start: backend => console.error("历史摘要生成中 (" + backend + ")"),
138
+ update: event => console.error(`${event.dimension} ${event.completed}/${event.total}`),
139
+ });
140
+ print(result);
141
+ if ("backend" in result && result.dimensions.some(dimension => dimension.failed.length)) return 1;
142
+ if ("errors" in result && (result.errors.length || result.skipped.length)) return 1;
143
+ return 0;
144
+ } catch (error) {
145
+ if (!exitCode) throw error;
146
+ console.error("历史操作已取消。");
147
+ return exitCode;
148
+ } finally {
149
+ process.off("SIGINT", interrupt);
150
+ process.off("SIGTERM", terminate);
151
+ }
152
+ }
153
+
154
+ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
155
+ main(process.argv.slice(2)).then(code => { process.exitCode = code; }).catch(error => {
156
+ console.error(error instanceof Error ? error.message : String(error));
157
+ process.exitCode = 1;
158
+ });
159
+ }
@@ -2,8 +2,7 @@ import { fork, spawnSync } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
3
  import { join, resolve } from "node:path";
4
4
  import { setTimeout as delay } from "node:timers/promises";
5
- import type { AgentHost } from "../../services/agents/agent-service.js";
6
- import type { AgentDescriptor, AgentOptions, AgentSessionReference } from "../../model/agent.js";
5
+ import type { AgentHost, AgentDescriptor, AgentOptions, AgentSessionReference } from "../../model/agent.js";
7
6
  import type { AcpBackend, AcpCommands, AcpModelsResult } from "../../model/acp.js";
8
7
  import { AgentFiles, launch } from "../../storage/agent-files.js";
9
8
  import { acpInput, acpProcess, acpReport } from "../../storage/acp-files.js";
@@ -17,7 +16,7 @@ export class AcpWorkerHost implements AgentHost {
17
16
  readonly files: AgentFiles;
18
17
  readonly worker = resolve(resourceRoot, "../lib/extension/acp-worker.js");
19
18
 
20
- constructor(directory: string, readonly commands: AcpCommands = {}) {
19
+ constructor(directory: string, public commands: AcpCommands = {}) {
21
20
  this.files = new AgentFiles(directory);
22
21
  }
23
22
 
@@ -4,6 +4,7 @@ import { setTimeout as delay } from "node:timers/promises";
4
4
  import * as acp from "@agentclientprotocol/sdk";
5
5
  import type { AcpHarnessAdapter, AcpModelSelection, AcpSessionReference } from "../../model/acp.js";
6
6
  import type { AgentOptions } from "../../model/agent.js";
7
+ import { object } from "../../common/json.js";
7
8
  import { requireThat } from "../../common/validation.js";
8
9
  import { packageVersion } from "../../common/version.js";
9
10
  import { acpChoices, acpModelSelection, acpModelValue, acpThinkingValue } from "./model-selection.js";
@@ -142,9 +143,13 @@ export async function openAcp(
142
143
  systemPrompt: { mode: "append" as const, content: [{ type: "text" as const, text: openOptions.systemPrompt }] },
143
144
  } : {}),
144
145
  };
146
+ let startupInfo: string | undefined;
145
147
  if (reference.sessionId === null) {
146
148
  const created = await connection.agent.request<acp.NewSessionResponse>(acp.methods.agent.session.new, setup, { cancellationSignal: AbortSignal.any([cancel, AbortSignal.timeout(30_000)]), stopWaitingOnCancel: true });
147
149
  sessionId = created.sessionId; options = created.configOptions ?? [];
150
+ if (object(created._meta) && object(created._meta.piAcp) && typeof created._meta.piAcp.startupInfo === "string") {
151
+ startupInfo = created._meta.piAcp.startupInfo;
152
+ }
148
153
  } else {
149
154
  requireThat(capabilities.resume || capabilities.load, "目标 ACP 后端不支持恢复已有会话,请新建 worker。");
150
155
  const restored = capabilities.resume
@@ -157,6 +162,7 @@ export async function openAcp(
157
162
  return {
158
163
  sessionId: activeId, capabilities, signal: connected, close, images: advertised?.promptCapabilities?.image === true,
159
164
  systemPrompt: Boolean(advertised?.sessionCapabilities?.systemPrompt),
165
+ ...(startupInfo ? { startupInfo } : {}),
160
166
  selection,
161
167
  choices: () => acpChoices(options),
162
168
  async configure(requested: AgentOptions) {
@@ -1,7 +1,7 @@
1
1
  import { object } from "../../../common/json.js";
2
2
  import { requireThat } from "../../../common/validation.js";
3
3
  import type { AcpHarnessAdapter } from "../../../model/acp.js";
4
- import { claudeOptions } from "../claude.js";
4
+ import { claudeOptions } from "../claude-settings.js";
5
5
  import { defaultPrepareLaunch, filterStandardAcpOptions, validateStandardAcpOptions } from "./generic.js";
6
6
 
7
7
  export const claudeAcpHarness: AcpHarnessAdapter = {
@@ -20,7 +20,7 @@ export const dshAcpHarness: AcpHarnessAdapter = {
20
20
  const patch = join(context.directory, "acp-dsh-patch.json");
21
21
  await writeFile(
22
22
  patch,
23
- JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/dsh/acp-member.js") }] }]) + "\n",
23
+ JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/hosts/dsh/acp-entry.js") }] }]) + "\n",
24
24
  { mode: 0o600 },
25
25
  );
26
26
  return {
@@ -11,6 +11,14 @@ export const standardAcpPresets: readonly AcpHarnessAdapter[] = [
11
11
  configureHint: "运行 agy 完成登录与默认模型配置。",
12
12
  nativeWorkspaceSkills: true,
13
13
  }),
14
+ createGenericAcpHarness("qoder", {
15
+ label: "Qoder CLI",
16
+ aliases: ["qodercli", "qoder-cli"],
17
+ nativeWorkspaceSkills: true,
18
+ defaultCommand: { command: "qodercli", args: ["--acp"] },
19
+ installHint: "安装 Qoder CLI(qodercli)",
20
+ configureHint: "运行 qodercli login 完成登录。",
21
+ }),
14
22
  createGenericAcpHarness("codex", {
15
23
  label: "OpenAI Codex",
16
24
  aliases: ["openai-codex", "codex-cli"],
@@ -0,0 +1,109 @@
1
+ import { fork } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { resourceRoot } from "../../common/paths.js";
5
+ import { requireThat } from "../../common/validation.js";
6
+ import type { AcpBackend, AcpCommands } from "../../model/acp.js";
7
+ import type { HistorySummarizer } from "../../model/history.js";
8
+ import { acpLaunch, canonicalAcpBackend } from "./launch.js";
9
+
10
+ export interface AcpHistorySummarizerOptions {
11
+ cwd: string;
12
+ backend?: AcpBackend;
13
+ commands?: AcpCommands;
14
+ model?: string;
15
+ thinking?: string;
16
+ timeoutMs?: number;
17
+ }
18
+
19
+ const defaultTimeoutMs = 180_000;
20
+
21
+ /**
22
+ * Spawns one isolated, ephemeral ACP worker process per summary task (default backend: "pi").
23
+ * Each worker runs with PBOT_SUBAGENT_RUN_ID set (so no host records raw history),
24
+ * denies all write/tool permissions, uses the target harness's default model unless overridden,
25
+ * and exits immediately after returning the summary text.
26
+ */
27
+ export function createAcpHistorySummarizer(options: AcpHistorySummarizerOptions): HistorySummarizer {
28
+ const workerPath = resolve(resourceRoot, "../lib/extension/acp-worker.js");
29
+ requireThat(process.platform === "linux" || process.platform === "darwin", "ACP 摘要 worker 当前支持 Linux 和 macOS。");
30
+ requireThat(existsSync(workerPath), "缺少 ACP worker 构建产物;请先运行 npm run build。");
31
+
32
+ const commands = options.commands ?? {};
33
+ const backend = canonicalAcpBackend(options.backend ?? "pi", commands);
34
+ let resolvedReference: ReturnType<typeof acpLaunch> | undefined;
35
+ const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
36
+
37
+ return async (request, signal) => {
38
+ signal.throwIfAborted();
39
+ const reference = (resolvedReference ??= acpLaunch(backend, commands, {}));
40
+ return await new Promise<string>((resolveAnswer, reject) => {
41
+ const child = fork(workerPath, ["--prompt"], {
42
+ cwd: options.cwd,
43
+ env: { ...process.env },
44
+ detached: true,
45
+ stdio: ["ignore", "ignore", "ignore", "ipc"],
46
+ execArgv: [],
47
+ });
48
+
49
+ let answer: string | undefined;
50
+ let failure: Error | undefined;
51
+ let settled = false;
52
+
53
+ const killGroup = () => {
54
+ if (!child.pid) return;
55
+ try { process.kill(-child.pid, "SIGKILL"); }
56
+ catch { /* Process group already exited. */ }
57
+ };
58
+
59
+ const onAbort = () => {
60
+ const abortError = signal.reason instanceof Error
61
+ ? signal.reason
62
+ : Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" });
63
+ failure = abortError;
64
+ killGroup();
65
+ };
66
+ signal.addEventListener("abort", onAbort, { once: true });
67
+
68
+ const timer = setTimeout(() => {
69
+ failure = new Error(`ACP 摘要 worker(${backend})执行超时。`);
70
+ killGroup();
71
+ }, timeoutMs);
72
+
73
+ const finish = (err?: Error, value?: string) => {
74
+ if (settled) return;
75
+ settled = true;
76
+ clearTimeout(timer);
77
+ signal.removeEventListener("abort", onAbort);
78
+ if (err) reject(err);
79
+ else resolveAnswer(value!);
80
+ };
81
+
82
+ child.on("message", (message: { type?: string; text?: string; error?: string }) => {
83
+ if (message.type === "answer" && typeof message.text === "string") answer = message.text;
84
+ if (message.type === "error") failure = new Error(message.error ?? `ACP 摘要 worker(${backend})失败。`);
85
+ });
86
+ child.once("error", error => { failure = error; });
87
+ child.once("spawn", () => {
88
+ if (signal.aborted) { onAbort(); return; }
89
+ child.send({
90
+ reference,
91
+ cwd: options.cwd,
92
+ system: request.system,
93
+ prompt: request.prompt,
94
+ ...(options.model ? { model: options.model } : {}),
95
+ ...(options.thinking ? { thinking: options.thinking } : {}),
96
+ });
97
+ });
98
+ child.once("close", code => {
99
+ if (signal.aborted) {
100
+ finish(failure ?? Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" }));
101
+ } else if (answer && code === 0 && !failure) {
102
+ finish(undefined, answer);
103
+ } else {
104
+ finish(failure ?? new Error(`ACP 摘要 worker(${backend})异常退出(code=${String(code)})。`));
105
+ }
106
+ });
107
+ });
108
+ };
109
+ }
@@ -37,7 +37,7 @@ export async function agentText(
37
37
  export function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string {
38
38
  if (!skills.length) return "";
39
39
  const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
40
- return "## 工作区技能\n\n以下为工作区自有专业方法(位于 `.agents/skills/`),匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
40
+ return "## 工作区技能\n\n匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
41
41
  }
42
42
 
43
43
  export async function loadWorkspaceContext(options: {
@@ -49,6 +49,7 @@ export async function loadWorkspaceContext(options: {
49
49
  includeRootAgents?: boolean;
50
50
  localRoleOnly?: boolean;
51
51
  workspaceSkills?: readonly WorkspaceSkillMeta[];
52
+ notices?: readonly string[];
52
53
  }): Promise<WorkspaceContext> {
53
54
  const {
54
55
  host,
@@ -59,6 +60,7 @@ export async function loadWorkspaceContext(options: {
59
60
  includeRootAgents = false,
60
61
  localRoleOnly = false,
61
62
  workspaceSkills = [],
63
+ notices = [],
62
64
  } = options;
63
65
  const [workspace, roleText, rootAgents] = includePrompts
64
66
  ? await Promise.all([
@@ -68,12 +70,16 @@ export async function loadWorkspaceContext(options: {
68
70
  ])
69
71
  : ["", "", ""];
70
72
  const skillsSection = formatWorkspaceSkills(workspaceSkills);
73
+ const noticesSection = notices.length
74
+ ? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
75
+ : "";
71
76
  const environment = { host, workspaceRoot: root, resourceRoot };
72
77
  const text = [
73
78
  workspace,
74
79
  roleText,
75
80
  rootAgents,
76
81
  skillsSection,
82
+ noticesSection,
77
83
  "## 环境\n\n" + JSON.stringify(environment),
78
84
  ].filter(Boolean).join("\n\n");
79
85
  return { workspace, role: roleText, rootAgents, workspaceSkills: [...workspaceSkills], environment, text };
@@ -0,0 +1,161 @@
1
+ import { readFile, realpath, stat } from "node:fs/promises";
2
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { object } from "../../../common/json.js";
4
+ import { resourceRoot } from "../../../common/paths.js";
5
+ import { requireThat } from "../../../common/validation.js";
6
+ import type { HistoryExchange, HistorySession } from "../../../model/history.js";
7
+ import type { HostEvent, PluginHostAdapter } from "../../../model/plugin-host.js";
8
+
9
+ const supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
10
+
11
+ function cleanUserRequest(content: string): string {
12
+ const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
13
+ return (match ? match[1]! : content).trim();
14
+ }
15
+
16
+ export function projectAntigravityTranscript(sessionId: string, content: string, terminationReason?: string): HistorySession {
17
+ const exchanges: HistoryExchange[] = [];
18
+ const lines = content.split(/\r?\n/);
19
+ let users: { id: string; text: string; time: string }[] = [];
20
+ let answer: { id: string; text: string; time: string } | undefined;
21
+
22
+ const finish = (completed: boolean) => {
23
+ if (!users.length) return;
24
+ const entryIds = [...users.map(u => u.id), ...(answer ? [answer.id] : [])];
25
+ const from = users[0]!.time;
26
+ const to = answer?.time ?? users.at(-1)!.time;
27
+ const text = users.map(u => "用户:\n" + u.text).join("\n\n") +
28
+ (answer ? "\n\n助手:\n" + answer.text : "");
29
+ exchanges.push({ entryIds, from, to, completed, text });
30
+ users = [];
31
+ answer = undefined;
32
+ };
33
+
34
+ for (const line of lines) {
35
+ const trimmed = line.trim();
36
+ if (!trimmed) continue;
37
+ let entry: unknown;
38
+ try { entry = JSON.parse(trimmed); } catch { continue; }
39
+ if (!object(entry) || typeof entry.type !== "string") continue;
40
+ const stepIndex = typeof entry.step_index === "number" ? entry.step_index : exchanges.length;
41
+ const time = typeof entry.created_at === "string" && entry.created_at ? entry.created_at : new Date().toISOString();
42
+ if (entry.type === "USER_INPUT" && typeof entry.content === "string") {
43
+ if (answer) finish(true);
44
+ const cleaned = cleanUserRequest(entry.content);
45
+ if (cleaned) users.push({ id: `agy:${stepIndex}`, text: cleaned, time });
46
+ } else if (entry.type === "PLANNER_RESPONSE" && users.length) {
47
+ const hasToolCalls = Array.isArray(entry.tool_calls) && entry.tool_calls.length > 0;
48
+ const text = typeof entry.content === "string" ? entry.content.trim() : "";
49
+ if (!hasToolCalls && text) {
50
+ answer = { id: `agy:${stepIndex}`, text, time };
51
+ }
52
+ }
53
+ }
54
+ const completed = Boolean(answer) && (!terminationReason || terminationReason === "NO_TOOL_CALL");
55
+ finish(completed);
56
+ return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
57
+ }
58
+
59
+ async function readAntigravityTranscript(transcriptPath: string): Promise<string | undefined> {
60
+ const fullPath = join(dirname(transcriptPath), "transcript_full.jsonl");
61
+ for (const path of [fullPath, transcriptPath]) {
62
+ try { return await readFile(path, "utf8"); }
63
+ catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
64
+ }
65
+ return undefined;
66
+ }
67
+
68
+ function workspaceFromPayload(cwd: string, payload?: unknown): string {
69
+ if (object(payload) && Array.isArray(payload.workspacePaths)) {
70
+ const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
71
+ if (typeof first === "string") return first;
72
+ }
73
+ return cwd;
74
+ }
75
+
76
+ function skillFromReadPath(targetPath: string, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")): string | undefined {
77
+ const skillsRoot = resolve(pluginRoot, "skills");
78
+ const rel = relative(skillsRoot, resolve(targetPath));
79
+ if (!rel || rel.startsWith("..") || isAbsolute(rel)) return undefined;
80
+ const skill = rel.split(sep)[0];
81
+ if (!skill || skill === "pbot") return undefined;
82
+ return skill;
83
+ }
84
+
85
+ function isPreToolUse(payload: unknown): boolean {
86
+ return object(payload) && payload.hookEventName === "PreToolUse";
87
+ }
88
+
89
+ export async function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string> {
90
+ const directory = workspaceFromPayload(cwd, payload);
91
+ requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
92
+ const root = await realpath(directory);
93
+ requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
94
+ return root;
95
+ }
96
+
97
+ export const antigravityAdapter: PluginHostAdapter = {
98
+ host: "antigravity",
99
+ nativeRootAgents: true,
100
+ nativeWorkspaceSkills: true,
101
+ coordinatorPrompt: "plugin-coordinator.md",
102
+ initCommandHint: "/pbot init",
103
+ usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
104
+ resolveRoot(cwd, rawPayload) {
105
+ return antigravityWorkspaceRoot(cwd, rawPayload);
106
+ },
107
+ parseEvent(value): HostEvent {
108
+ requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
109
+ const event = value.hookEventName;
110
+ requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
111
+ const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
112
+ requireThat(cwd, "Antigravity hook 缺少工作目录。");
113
+ if (event === "SessionStart") {
114
+ return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd, raw: value };
115
+ }
116
+ if (event === "Stop") {
117
+ return { kind: "record-history", cwd, raw: value };
118
+ }
119
+ if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
120
+ return { kind: "ignore" };
121
+ }
122
+ const { name, args } = value.toolCall;
123
+ if (name === "read_file" && typeof args.Path === "string") {
124
+ const skill = skillFromReadPath(args.Path);
125
+ if (skill) return { kind: "check-skill", skill, cwd, raw: value };
126
+ }
127
+ return { kind: "ignore" };
128
+ },
129
+ async extractHistory(event) {
130
+ if (event.kind !== "record-history" || !object(event.raw)) return undefined;
131
+ const sessionId = typeof event.raw.conversationId === "string" ? event.raw.conversationId.trim() : "";
132
+ if (!sessionId) return undefined;
133
+ const terminationReason = typeof event.raw.terminationReason === "string" ? event.raw.terminationReason : undefined;
134
+ const transcriptPath = typeof event.raw.transcriptPath === "string" ? event.raw.transcriptPath.trim() : "";
135
+ if (transcriptPath) {
136
+ const content = await readAntigravityTranscript(transcriptPath);
137
+ if (content) {
138
+ const session = projectAntigravityTranscript(sessionId, content, terminationReason);
139
+ if (session.branches.length) return { kind: "session", session };
140
+ }
141
+ }
142
+ const lastUserInput = typeof event.raw.lastUserInput === "string" ? event.raw.lastUserInput.trim() : "";
143
+ if (lastUserInput) return { kind: "input", sessionId, text: lastUserInput };
144
+ return undefined;
145
+ },
146
+ formatPass(payload) {
147
+ return isPreToolUse(payload) ? { decision: "allow" } : {};
148
+ },
149
+ formatContext(_event, context) {
150
+ return {
151
+ injectSteps: [
152
+ { systemMessage: { systemMessage: context.text } },
153
+ ],
154
+ };
155
+ },
156
+ formatDeny(_event, reason) {
157
+ return { decision: "deny", reason };
158
+ },
159
+ };
160
+
161
+ export const antigravitySkillPath = (pluginRoot: string, skill: string) => join(pluginRoot, "skills", skill, "SKILL.md");
@@ -0,0 +1,39 @@
1
+ import { object } from "../../../common/json.js";
2
+ import { requireThat } from "../../../common/validation.js";
3
+ import type { HostEvent, PluginHostAdapter } from "../../../model/plugin-host.js";
4
+ import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
5
+
6
+ const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
7
+ const boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
8
+
9
+ export async function claudeWorkspaceRoot(cwd: string, projectDirectory = boundWorkspaceRoot()): Promise<string> {
10
+ return pluginWorkspaceRoot(projectDirectory || cwd);
11
+ }
12
+
13
+ export const claudeAdapter: PluginHostAdapter = {
14
+ host: "claude",
15
+ nativeRootAgents: false,
16
+ nativeWorkspaceSkills: false,
17
+ coordinatorPrompt: "plugin-coordinator.md",
18
+ initCommandHint: "/personal-bot:pbot init",
19
+ usage: "用法:node <插件目录>/lib/claude.js init|status",
20
+ boundWorkspaceRoot,
21
+ resolveRoot(cwd) {
22
+ return claudeWorkspaceRoot(cwd);
23
+ },
24
+ parseEvent(value): HostEvent {
25
+ requireThat(object(value) && typeof value.hook_event_name === "string", "Claude hook 输入无效。");
26
+ const event = value.hook_event_name;
27
+ requireThat(supportedEvents.includes(event), "Claude hook 事件未支持。");
28
+ if (event === "PreToolUse" || event === "UserPromptExpansion") {
29
+ const skill = event === "UserPromptExpansion"
30
+ ? value.expansion_type === "slash_command" ? value.command_name : undefined
31
+ : value.tool_name === "Skill" && object(value.tool_input) ? value.tool_input.skill : undefined;
32
+ if (typeof skill !== "string" || !skill.startsWith("personal-bot:") || skill === "personal-bot:pbot") return { kind: "ignore" };
33
+ requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
34
+ return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
35
+ }
36
+ return parsePromptEvent(value);
37
+ },
38
+ ...promptHooks,
39
+ };