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
@@ -13,4 +13,5 @@ export declare function loadWorkspaceContext(options: {
13
13
  includeRootAgents?: boolean;
14
14
  localRoleOnly?: boolean;
15
15
  workspaceSkills?: readonly WorkspaceSkillMeta[];
16
+ notices?: readonly string[];
16
17
  }): Promise<WorkspaceContext>;
@@ -32,10 +32,10 @@ export function formatWorkspaceSkills(skills) {
32
32
  if (!skills.length)
33
33
  return "";
34
34
  const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
35
- return "## 工作区技能\n\n以下为工作区自有专业方法(位于 `.agents/skills/`),匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
35
+ return "## 工作区技能\n\n匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
36
36
  }
37
37
  export async function loadWorkspaceContext(options) {
38
- const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], } = options;
38
+ const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], notices = [], } = options;
39
39
  const [workspace, roleText, rootAgents] = includePrompts
40
40
  ? await Promise.all([
41
41
  readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"),
@@ -44,12 +44,16 @@ export async function loadWorkspaceContext(options) {
44
44
  ])
45
45
  : ["", "", ""];
46
46
  const skillsSection = formatWorkspaceSkills(workspaceSkills);
47
+ const noticesSection = notices.length
48
+ ? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
49
+ : "";
47
50
  const environment = { host, workspaceRoot: root, resourceRoot };
48
51
  const text = [
49
52
  workspace,
50
53
  roleText,
51
54
  rootAgents,
52
55
  skillsSection,
56
+ noticesSection,
53
57
  "## 环境\n\n" + JSON.stringify(environment),
54
58
  ].filter(Boolean).join("\n\n");
55
59
  return { workspace, role: roleText, rootAgents, workspaceSkills: [...workspaceSkills], environment, text };
@@ -0,0 +1,6 @@
1
+ import type { HistorySession } from "../../../model/history.js";
2
+ import type { PluginHostAdapter } from "../../../model/plugin-host.js";
3
+ export declare function projectAntigravityTranscript(sessionId: string, content: string, terminationReason?: string): HistorySession;
4
+ export declare function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string>;
5
+ export declare const antigravityAdapter: PluginHostAdapter;
6
+ export declare const antigravitySkillPath: (pluginRoot: string, skill: string) => string;
@@ -0,0 +1,171 @@
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
+ const supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
7
+ function cleanUserRequest(content) {
8
+ const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
9
+ return (match ? match[1] : content).trim();
10
+ }
11
+ export function projectAntigravityTranscript(sessionId, content, terminationReason) {
12
+ const exchanges = [];
13
+ const lines = content.split(/\r?\n/);
14
+ let users = [];
15
+ let answer;
16
+ const finish = (completed) => {
17
+ if (!users.length)
18
+ return;
19
+ const entryIds = [...users.map(u => u.id), ...(answer ? [answer.id] : [])];
20
+ const from = users[0].time;
21
+ const to = answer?.time ?? users.at(-1).time;
22
+ const text = users.map(u => "用户:\n" + u.text).join("\n\n") +
23
+ (answer ? "\n\n助手:\n" + answer.text : "");
24
+ exchanges.push({ entryIds, from, to, completed, text });
25
+ users = [];
26
+ answer = undefined;
27
+ };
28
+ for (const line of lines) {
29
+ const trimmed = line.trim();
30
+ if (!trimmed)
31
+ continue;
32
+ let entry;
33
+ try {
34
+ entry = JSON.parse(trimmed);
35
+ }
36
+ catch {
37
+ continue;
38
+ }
39
+ if (!object(entry) || typeof entry.type !== "string")
40
+ continue;
41
+ const stepIndex = typeof entry.step_index === "number" ? entry.step_index : exchanges.length;
42
+ const time = typeof entry.created_at === "string" && entry.created_at ? entry.created_at : new Date().toISOString();
43
+ if (entry.type === "USER_INPUT" && typeof entry.content === "string") {
44
+ if (answer)
45
+ finish(true);
46
+ const cleaned = cleanUserRequest(entry.content);
47
+ if (cleaned)
48
+ users.push({ id: `agy:${stepIndex}`, text: cleaned, time });
49
+ }
50
+ else if (entry.type === "PLANNER_RESPONSE" && users.length) {
51
+ const hasToolCalls = Array.isArray(entry.tool_calls) && entry.tool_calls.length > 0;
52
+ const text = typeof entry.content === "string" ? entry.content.trim() : "";
53
+ if (!hasToolCalls && text) {
54
+ answer = { id: `agy:${stepIndex}`, text, time };
55
+ }
56
+ }
57
+ }
58
+ const completed = Boolean(answer) && (!terminationReason || terminationReason === "NO_TOOL_CALL");
59
+ finish(completed);
60
+ return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
61
+ }
62
+ async function readAntigravityTranscript(transcriptPath) {
63
+ const fullPath = join(dirname(transcriptPath), "transcript_full.jsonl");
64
+ for (const path of [fullPath, transcriptPath]) {
65
+ try {
66
+ return await readFile(path, "utf8");
67
+ }
68
+ catch (error) {
69
+ if (error.code !== "ENOENT")
70
+ throw error;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+ function workspaceFromPayload(cwd, payload) {
76
+ if (object(payload) && Array.isArray(payload.workspacePaths)) {
77
+ const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
78
+ if (typeof first === "string")
79
+ return first;
80
+ }
81
+ return cwd;
82
+ }
83
+ function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")) {
84
+ const skillsRoot = resolve(pluginRoot, "skills");
85
+ const rel = relative(skillsRoot, resolve(targetPath));
86
+ if (!rel || rel.startsWith("..") || isAbsolute(rel))
87
+ return undefined;
88
+ const skill = rel.split(sep)[0];
89
+ if (!skill || skill === "pbot")
90
+ return undefined;
91
+ return skill;
92
+ }
93
+ function isPreToolUse(payload) {
94
+ return object(payload) && payload.hookEventName === "PreToolUse";
95
+ }
96
+ export async function antigravityWorkspaceRoot(cwd, payload) {
97
+ const directory = workspaceFromPayload(cwd, payload);
98
+ requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
99
+ const root = await realpath(directory);
100
+ requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
101
+ return root;
102
+ }
103
+ export const antigravityAdapter = {
104
+ host: "antigravity",
105
+ nativeRootAgents: true,
106
+ nativeWorkspaceSkills: true,
107
+ coordinatorPrompt: "plugin-coordinator.md",
108
+ initCommandHint: "/pbot init",
109
+ usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
110
+ resolveRoot(cwd, rawPayload) {
111
+ return antigravityWorkspaceRoot(cwd, rawPayload);
112
+ },
113
+ parseEvent(value) {
114
+ requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
115
+ const event = value.hookEventName;
116
+ requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
117
+ const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
118
+ requireThat(cwd, "Antigravity hook 缺少工作目录。");
119
+ if (event === "SessionStart") {
120
+ return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd, raw: value };
121
+ }
122
+ if (event === "Stop") {
123
+ return { kind: "record-history", cwd, raw: value };
124
+ }
125
+ if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
126
+ return { kind: "ignore" };
127
+ }
128
+ const { name, args } = value.toolCall;
129
+ if (name === "read_file" && typeof args.Path === "string") {
130
+ const skill = skillFromReadPath(args.Path);
131
+ if (skill)
132
+ return { kind: "check-skill", skill, cwd, raw: value };
133
+ }
134
+ return { kind: "ignore" };
135
+ },
136
+ async extractHistory(event) {
137
+ if (event.kind !== "record-history" || !object(event.raw))
138
+ return undefined;
139
+ const sessionId = typeof event.raw.conversationId === "string" ? event.raw.conversationId.trim() : "";
140
+ if (!sessionId)
141
+ return undefined;
142
+ const terminationReason = typeof event.raw.terminationReason === "string" ? event.raw.terminationReason : undefined;
143
+ const transcriptPath = typeof event.raw.transcriptPath === "string" ? event.raw.transcriptPath.trim() : "";
144
+ if (transcriptPath) {
145
+ const content = await readAntigravityTranscript(transcriptPath);
146
+ if (content) {
147
+ const session = projectAntigravityTranscript(sessionId, content, terminationReason);
148
+ if (session.branches.length)
149
+ return { kind: "session", session };
150
+ }
151
+ }
152
+ const lastUserInput = typeof event.raw.lastUserInput === "string" ? event.raw.lastUserInput.trim() : "";
153
+ if (lastUserInput)
154
+ return { kind: "input", sessionId, text: lastUserInput };
155
+ return undefined;
156
+ },
157
+ formatPass(payload) {
158
+ return isPreToolUse(payload) ? { decision: "allow" } : {};
159
+ },
160
+ formatContext(_event, context) {
161
+ return {
162
+ injectSteps: [
163
+ { systemMessage: { systemMessage: context.text } },
164
+ ],
165
+ };
166
+ },
167
+ formatDeny(_event, reason) {
168
+ return { decision: "deny", reason };
169
+ },
170
+ };
171
+ export const antigravitySkillPath = (pluginRoot, skill) => join(pluginRoot, "skills", skill, "SKILL.md");
@@ -1,3 +1,3 @@
1
- import type { PluginHostAdapter } from "../../model/plugin-host.js";
1
+ import type { PluginHostAdapter } from "../../../model/plugin-host.js";
2
2
  export declare function claudeWorkspaceRoot(cwd: string, projectDirectory?: string | undefined): Promise<string>;
3
3
  export declare const claudeAdapter: PluginHostAdapter;
@@ -0,0 +1,36 @@
1
+ import { object } from "../../../common/json.js";
2
+ import { requireThat } from "../../../common/validation.js";
3
+ import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
4
+ const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
5
+ const boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
6
+ export async function claudeWorkspaceRoot(cwd, projectDirectory = boundWorkspaceRoot()) {
7
+ return pluginWorkspaceRoot(projectDirectory || cwd);
8
+ }
9
+ export const claudeAdapter = {
10
+ host: "claude",
11
+ nativeRootAgents: false,
12
+ nativeWorkspaceSkills: false,
13
+ coordinatorPrompt: "plugin-coordinator.md",
14
+ initCommandHint: "/personal-bot:pbot init",
15
+ usage: "用法:node <插件目录>/lib/claude.js init|status",
16
+ boundWorkspaceRoot,
17
+ resolveRoot(cwd) {
18
+ return claudeWorkspaceRoot(cwd);
19
+ },
20
+ parseEvent(value) {
21
+ requireThat(object(value) && typeof value.hook_event_name === "string", "Claude hook 输入无效。");
22
+ const event = value.hook_event_name;
23
+ requireThat(supportedEvents.includes(event), "Claude hook 事件未支持。");
24
+ if (event === "PreToolUse" || event === "UserPromptExpansion") {
25
+ const skill = event === "UserPromptExpansion"
26
+ ? value.expansion_type === "slash_command" ? value.command_name : undefined
27
+ : value.tool_name === "Skill" && object(value.tool_input) ? value.tool_input.skill : undefined;
28
+ if (typeof skill !== "string" || !skill.startsWith("personal-bot:") || skill === "personal-bot:pbot")
29
+ return { kind: "ignore" };
30
+ requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
31
+ return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
32
+ }
33
+ return parsePromptEvent(value);
34
+ },
35
+ ...promptHooks,
36
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginHostAdapter } from "../../../model/plugin-host.js";
2
+ export declare const codexAdapter: PluginHostAdapter;
@@ -0,0 +1,14 @@
1
+ import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
2
+ export const codexAdapter = {
3
+ host: "codex",
4
+ nativeRootAgents: true,
5
+ nativeWorkspaceSkills: true,
6
+ indexBundledSkills: true,
7
+ initCommandHint: "pbot plugin codex init",
8
+ usage: "用法:pbot plugin codex init|status",
9
+ resolveRoot(cwd) {
10
+ return pluginWorkspaceRoot(cwd);
11
+ },
12
+ parseEvent: parsePromptEvent,
13
+ ...promptHooks,
14
+ };
@@ -1,4 +1,4 @@
1
1
  import * as McpClient from "@deepseek-ai/dsh-mcp-client";
2
- import type { ResolvedWorkspaceMcpServer } from "../../model/workspace-mcp.js";
2
+ import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
3
3
  /** Translate a resolved workspace MCP entry into dsh's native `@deepseek-ai/dsh-mcp-client` config. */
4
4
  export declare function toDshMcpConfig(server: ResolvedWorkspaceMcpServer): McpClient.Config;
@@ -1,6 +1,6 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
3
- import type { AgentOptions } from "../../model/agent.js";
3
+ import type { AgentOptions } from "../../../model/agent.js";
4
4
  export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string): Promise<void>;
5
5
  /** Map an ACP dsh worker's native loadout without interfering with coordinator sessions. */
6
6
  export declare function dshExpertTools(ctx: Context, agent: Agent, options: AgentOptions): void;
@@ -1,9 +1,9 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { agentText } from "../agent-resources.js";
4
- import { resourceRoot } from "../../common/paths.js";
5
- import { requireThat } from "../../common/validation.js";
6
- import { isMcpWorkerTool } from "../../model/acp.js";
3
+ import { agentText } from "../../agent-resources.js";
4
+ import { resourceRoot } from "../../../common/paths.js";
5
+ import { requireThat } from "../../../common/validation.js";
6
+ import { isMcpWorkerTool } from "../../../model/acp.js";
7
7
  export async function dshResources(ctx, _agent, root, role, check, coordinatorPrompt = "history-coordinator.md") {
8
8
  const read = () => Promise.all([agentText(role, root, coordinatorPrompt), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
9
9
  const [text, workspace] = await read();
@@ -1,7 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { scopeParentOf } from "@deepseek-ai/dsh-scope";
3
3
  import { FileSystemSkillProvider } from "@deepseek-ai/dsh-skill-filesystem";
4
- import { resourceRoot } from "../../common/paths.js";
4
+ import { resourceRoot } from "../../../common/paths.js";
5
5
  /** Keep bundled methods local to this Agent without overriding its native project/user methods. */
6
6
  export function registerDshSkills(ctx, agent, options = {}) {
7
7
  const customSkillDirs = options.workspaceRoot ? [join(options.workspaceRoot, ".agents", "skills")] : undefined;
@@ -0,0 +1,3 @@
1
+ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+ /** Native tools still own parsing, mutation queues and results; authorize at the actual file write. */
3
+ export declare function agentFileTools(root: string, signal: AbortSignal, authorize: (path: string, change: unknown, signal: AbortSignal) => Promise<void>): ToolDefinition[];
@@ -0,0 +1,32 @@
1
+ import { access as fileAccess, mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { constants } from "node:fs";
3
+ import { dirname } from "node:path";
4
+ import { defineTool, createWriteToolDefinition, createEditToolDefinition } from "@earendil-works/pi-coding-agent";
5
+ /** Native tools still own parsing, mutation queues and results; authorize at the actual file write. */
6
+ export function agentFileTools(root, signal, authorize) {
7
+ const guardedWrite = (cancel, parameters) => async (path, content) => {
8
+ await authorize(path, { parameters, content }, cancel);
9
+ await mkdir(dirname(path), { recursive: true });
10
+ cancel.throwIfAborted();
11
+ await writeFile(path, content, "utf8");
12
+ };
13
+ return [
14
+ defineTool({ ...createWriteToolDefinition(root),
15
+ execute(id, args, inner, update, child) {
16
+ const cancel = AbortSignal.any([signal, ...(inner ? [inner] : [])]);
17
+ return createWriteToolDefinition(root, { operations: {
18
+ // Directory creation belongs to guardedWrite, after authorization.
19
+ mkdir: async () => { }, writeFile: guardedWrite(cancel, args),
20
+ } }).execute(id, args, cancel, update, child);
21
+ },
22
+ }),
23
+ defineTool({ ...createEditToolDefinition(root),
24
+ execute(id, args, inner, update, child) {
25
+ const cancel = AbortSignal.any([signal, ...(inner ? [inner] : [])]);
26
+ return createEditToolDefinition(root, { operations: {
27
+ readFile, access: path => fileAccess(path, constants.R_OK | constants.W_OK), writeFile: guardedWrite(cancel, args),
28
+ } }).execute(id, args, cancel, update, child);
29
+ },
30
+ }),
31
+ ];
32
+ }
@@ -0,0 +1,4 @@
1
+ import type { McpServerConfig } from "@earendil-works/pi-coding-agent";
2
+ import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
3
+ /** Translate a resolved workspace MCP entry into Pi's native `registerMcpServer` config. */
4
+ export declare function toPiMcpConfig(server: ResolvedWorkspaceMcpServer): McpServerConfig;
@@ -0,0 +1,23 @@
1
+ /** Translate a resolved workspace MCP entry into Pi's native `registerMcpServer` config. */
2
+ export function toPiMcpConfig(server) {
3
+ if (server.transport === "http") {
4
+ return {
5
+ type: "http",
6
+ url: server.url,
7
+ ...(Object.keys(server.headers).length ? { headers: { ...server.headers } } : {}),
8
+ exposure: "direct",
9
+ timeout: server.timeout,
10
+ ...(server.description ? { description: server.description } : {}),
11
+ };
12
+ }
13
+ return {
14
+ type: "stdio",
15
+ command: server.command,
16
+ args: [...server.args],
17
+ ...(Object.keys(server.env).length ? { env: { ...server.env } } : {}),
18
+ cwd: server.cwd,
19
+ exposure: "direct",
20
+ timeout: server.timeout,
21
+ ...(server.description ? { description: server.description } : {}),
22
+ };
23
+ }
@@ -13,3 +13,4 @@ export declare const pluginHosts: PluginHostRegistry;
13
13
  export declare const registerPluginHost: (adapter: PluginHostAdapter) => PluginHostRegistry;
14
14
  export declare const getPluginHost: (host: PluginHostId) => PluginHostAdapter | undefined;
15
15
  export declare const listPluginHosts: () => string[];
16
+ export declare function pluginMcpWorkspaceRoot(): string | undefined;
@@ -1,6 +1,8 @@
1
1
  import { requireThat } from "../../common/validation.js";
2
- import { antigravityAdapter } from "./antigravity.js";
3
- import { claudeAdapter } from "./claude.js";
2
+ import { antigravityAdapter } from "./antigravity/adapter.js";
3
+ import { claudeAdapter } from "./claude/adapter.js";
4
+ import { codexAdapter } from "./codex/adapter.js";
5
+ import { qoderAdapter } from "./qoder/adapter.js";
4
6
  /** Extensible registry of hook-based plugin host adapters; runtime never branches on host IDs. */
5
7
  export class PluginHostRegistry {
6
8
  #adapters = new Map();
@@ -28,7 +30,12 @@ export class PluginHostRegistry {
28
30
  return [...this.#adapters.keys()];
29
31
  }
30
32
  }
31
- export const pluginHosts = new PluginHostRegistry([claudeAdapter, antigravityAdapter]);
33
+ export const pluginHosts = new PluginHostRegistry([claudeAdapter, antigravityAdapter, codexAdapter, qoderAdapter]);
32
34
  export const registerPluginHost = (adapter) => pluginHosts.register(adapter);
33
35
  export const getPluginHost = (host) => pluginHosts.get(host);
34
36
  export const listPluginHosts = () => pluginHosts.list();
37
+ export function pluginMcpWorkspaceRoot() {
38
+ // Older standalone Claude mounts supply the project directory without PBOT_HOST.
39
+ const adapter = process.env.PBOT_HOST ? pluginHosts.get(process.env.PBOT_HOST) : claudeAdapter;
40
+ return adapter?.boundWorkspaceRoot?.() || process.env.PBOT_WORKSPACE_ROOT;
41
+ }
@@ -0,0 +1,76 @@
1
+ import type { HostEvent } from "../../model/plugin-host.js";
2
+ /** Shared stdin/stdout contract for hosts with Claude-compatible prompt and stop hooks. */
3
+ export declare function pluginWorkspaceRoot(directory: string): Promise<string>;
4
+ export declare function parsePromptEvent(value: unknown): HostEvent;
5
+ export declare const promptHooks: {
6
+ extractHistory(event: {
7
+ kind: "inject-context";
8
+ role: import("../../model/plugin-host.js").WorkspaceRole;
9
+ localRoleOnly?: boolean;
10
+ isSessionStart?: boolean;
11
+ noticesOnly?: boolean;
12
+ cwd: string;
13
+ raw: unknown;
14
+ } | {
15
+ kind: "record-history";
16
+ cwd: string;
17
+ raw: unknown;
18
+ }): Promise<{
19
+ text: string;
20
+ sessionId: string;
21
+ turnId: string;
22
+ kind: "input";
23
+ } | {
24
+ text: string;
25
+ sessionId: string;
26
+ turnId?: never;
27
+ kind: "input";
28
+ } | {
29
+ isContinuation?: true;
30
+ assistantText: string;
31
+ completed: true;
32
+ sessionId: string;
33
+ turnId: string;
34
+ kind: "answer";
35
+ } | {
36
+ isContinuation?: true;
37
+ assistantText: string;
38
+ completed: true;
39
+ sessionId: string;
40
+ turnId?: never;
41
+ kind: "answer";
42
+ } | undefined>;
43
+ formatPass(): {};
44
+ formatContext(event: {
45
+ kind: "inject-context";
46
+ role: import("../../model/plugin-host.js").WorkspaceRole;
47
+ localRoleOnly?: boolean;
48
+ isSessionStart?: boolean;
49
+ noticesOnly?: boolean;
50
+ cwd: string;
51
+ raw: unknown;
52
+ }, context: import("../../model/plugin-host.js").WorkspaceContext): {
53
+ hookSpecificOutput: {
54
+ hookEventName: string;
55
+ additionalContext: string;
56
+ };
57
+ };
58
+ formatDeny(event: {
59
+ kind: "check-skill";
60
+ skill: string;
61
+ cwd: string;
62
+ raw: unknown;
63
+ }, reason: string): {
64
+ decision: string;
65
+ reason: string;
66
+ hookSpecificOutput?: never;
67
+ } | {
68
+ hookSpecificOutput: {
69
+ hookEventName: string;
70
+ permissionDecision: string;
71
+ permissionDecisionReason: string;
72
+ };
73
+ decision?: never;
74
+ reason?: never;
75
+ };
76
+ };
@@ -0,0 +1,76 @@
1
+ import { realpath, stat } from "node:fs/promises";
2
+ import { isAbsolute } from "node:path";
3
+ import { object } from "../../common/json.js";
4
+ import { requireThat } from "../../common/validation.js";
5
+ /** Shared stdin/stdout contract for hosts with Claude-compatible prompt and stop hooks. */
6
+ export async function pluginWorkspaceRoot(directory) {
7
+ requireThat(isAbsolute(directory), "插件工作区需要绝对路径。");
8
+ const root = await realpath(directory);
9
+ requireThat((await stat(root)).isDirectory(), "插件工作区需要目录。");
10
+ return root;
11
+ }
12
+ export function parsePromptEvent(value) {
13
+ requireThat(object(value), "插件 hook 输入无效。");
14
+ const name = value.hook_event_name;
15
+ if (name !== "Stop" && name !== "UserPromptSubmit" && name !== "SessionStart")
16
+ return { kind: "ignore" };
17
+ if (typeof value.agent_id === "string")
18
+ return { kind: "ignore" };
19
+ requireThat(typeof value.cwd === "string", "插件 hook 缺少工作目录。");
20
+ if (name === "Stop")
21
+ return { kind: "record-history", cwd: value.cwd, raw: value };
22
+ if (name === "SessionStart") {
23
+ if (value.source === "resume" || value.source === "compact")
24
+ return { kind: "ignore" };
25
+ return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
26
+ }
27
+ return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
28
+ }
29
+ export const promptHooks = {
30
+ async extractHistory(event) {
31
+ if (!object(event.raw))
32
+ return undefined;
33
+ const sessionId = typeof event.raw.session_id === "string" ? event.raw.session_id.trim() : "";
34
+ if (!sessionId)
35
+ return undefined;
36
+ const turnId = typeof event.raw.turn_id === "string" ? event.raw.turn_id.trim() : "";
37
+ const identity = turnId ? { sessionId, turnId } : { sessionId };
38
+ if (event.raw.hook_event_name === "UserPromptSubmit") {
39
+ const text = typeof event.raw.prompt === "string" ? event.raw.prompt.trim() : "";
40
+ if (!text && !turnId)
41
+ return undefined;
42
+ return { kind: "input", ...identity, text };
43
+ }
44
+ if (event.raw.hook_event_name === "Stop") {
45
+ const assistantText = typeof event.raw.last_assistant_message === "string" ? event.raw.last_assistant_message.trim() : "";
46
+ if (!assistantText)
47
+ return undefined;
48
+ return {
49
+ kind: "answer",
50
+ ...identity,
51
+ assistantText,
52
+ completed: true,
53
+ ...(event.raw.stop_hook_active === true ? { isContinuation: true } : {}),
54
+ };
55
+ }
56
+ return undefined;
57
+ },
58
+ formatPass() {
59
+ return {};
60
+ },
61
+ formatContext(event, context) {
62
+ const raw = event.raw;
63
+ return {
64
+ hookSpecificOutput: {
65
+ hookEventName: raw.hook_event_name,
66
+ additionalContext: context.text,
67
+ },
68
+ };
69
+ },
70
+ formatDeny(event, reason) {
71
+ const raw = event.raw;
72
+ return raw.hook_event_name === "UserPromptExpansion"
73
+ ? { decision: "block", reason }
74
+ : { hookSpecificOutput: { hookEventName: raw.hook_event_name, permissionDecision: "deny", permissionDecisionReason: reason } };
75
+ },
76
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginHostAdapter } from "../../../model/plugin-host.js";
2
+ export declare const qoderAdapter: PluginHostAdapter;
@@ -0,0 +1,16 @@
1
+ import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
2
+ const boundWorkspaceRoot = () => process.env.QODER_PROJECT_DIR || process.env.PBOT_WORKSPACE_ROOT;
3
+ export const qoderAdapter = {
4
+ host: "qoder",
5
+ nativeRootAgents: true,
6
+ nativeWorkspaceSkills: true,
7
+ indexBundledSkills: true,
8
+ initCommandHint: "pbot plugin qoder init",
9
+ usage: "用法:pbot plugin qoder init|status",
10
+ boundWorkspaceRoot,
11
+ resolveRoot(cwd) {
12
+ return pluginWorkspaceRoot(boundWorkspaceRoot() || cwd);
13
+ },
14
+ parseEvent: parsePromptEvent,
15
+ ...promptHooks,
16
+ };
@@ -8,7 +8,8 @@ export interface AcpCommand {
8
8
  env?: Record<string, string>;
9
9
  }
10
10
  /** ask: forward target permission requests to the parent session; allow/deny: answer them automatically. */
11
- export type AcpPermissionPolicy = "ask" | "allow" | "deny";
11
+ export declare const acpPermissionPolicies: readonly ["ask", "allow", "deny"];
12
+ export type AcpPermissionPolicy = typeof acpPermissionPolicies[number];
12
13
  /** Workspace `acp.<name>` entry; omitting `command` keeps a registered harness's default command. */
13
14
  export interface AcpHarnessConfig {
14
15
  command?: string;
@@ -59,9 +60,10 @@ export interface AcpInput {
59
60
  generation: string;
60
61
  requestId: string;
61
62
  }
63
+ export declare const acpAnswerStates: readonly ["completed", "failed", "cancelled"];
62
64
  export interface AcpAnswer extends AcpInput {
63
65
  answer: string;
64
- state: "completed" | "failed" | "cancelled";
66
+ state: typeof acpAnswerStates[number];
65
67
  error?: string;
66
68
  }
67
69
  export interface AcpReport {
@@ -84,8 +86,10 @@ export interface AcpPermissionReply {
84
86
  requestId: string;
85
87
  optionId: string | null;
86
88
  }
87
- export type AcpElicitationAction = "accept" | "decline" | "cancel";
89
+ export declare const acpElicitationActions: readonly ["accept", "decline", "cancel"];
90
+ export type AcpElicitationAction = typeof acpElicitationActions[number];
88
91
  export type AcpElicitationValue = string | number | boolean | string[];
92
+ export declare function isAcpElicitationValue(value: unknown): value is AcpElicitationValue;
89
93
  export type AcpElicitationContent = Record<string, AcpElicitationValue>;
90
94
  export interface AcpElicitation {
91
95
  generation: string;
@@ -10,3 +10,11 @@ export function isMcpWorkerTool(name) {
10
10
  const bare = name.startsWith("mcp__pbot__") ? name.slice("mcp__pbot__".length) : name;
11
11
  return bare === "pbot_worker" || mcpWorkerToolNames.includes(bare);
12
12
  }
13
+ /** ask: forward target permission requests to the parent session; allow/deny: answer them automatically. */
14
+ export const acpPermissionPolicies = ["ask", "allow", "deny"];
15
+ export const acpAnswerStates = ["completed", "failed", "cancelled"];
16
+ export const acpElicitationActions = ["accept", "decline", "cancel"];
17
+ export function isAcpElicitationValue(value) {
18
+ return typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value))
19
+ || (Array.isArray(value) && value.every(item => typeof item === "string"));
20
+ }