@apralabs/apra-fleet 0.4.1 → 0.4.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 (476) hide show
  1. package/README.md +53 -12
  2. package/dist/agents/backlog-groomer.md +42 -21
  3. package/dist/agents/ci-watcher.md +14 -0
  4. package/dist/agents/deployer.md +59 -46
  5. package/dist/agents/doer.md +157 -134
  6. package/dist/agents/harvester.md +31 -32
  7. package/dist/agents/integ-test-runner.md +92 -113
  8. package/dist/agents/kb-reconciler.md +40 -42
  9. package/dist/agents/plan-reviewer.md +139 -63
  10. package/dist/agents/planner.md +176 -100
  11. package/dist/agents/regression-test-runner.md +77 -81
  12. package/dist/agents/reviewer.md +69 -85
  13. package/dist/agents/schemas/integ-test-runner-output.json +1 -1
  14. package/dist/agents/schemas/plan-reviewer-output.json +37 -0
  15. package/dist/agents/schemas/regression-test-runner-output.json +4 -17
  16. package/dist/cli/agent-transform.d.ts +83 -2
  17. package/dist/cli/agent-transform.d.ts.map +1 -1
  18. package/dist/cli/agent-transform.js +266 -21
  19. package/dist/cli/agent-transform.js.map +1 -1
  20. package/dist/cli/auth.d.ts.map +1 -1
  21. package/dist/cli/auth.js +29 -11
  22. package/dist/cli/auth.js.map +1 -1
  23. package/dist/cli/config.d.ts +7 -5
  24. package/dist/cli/config.d.ts.map +1 -1
  25. package/dist/cli/config.js +44 -43
  26. package/dist/cli/config.js.map +1 -1
  27. package/dist/cli/install.d.ts +33 -0
  28. package/dist/cli/install.d.ts.map +1 -1
  29. package/dist/cli/install.js +294 -61
  30. package/dist/cli/install.js.map +1 -1
  31. package/dist/cli/kb-directives.d.ts.map +1 -1
  32. package/dist/cli/kb-directives.js +2 -1
  33. package/dist/cli/kb-directives.js.map +1 -1
  34. package/dist/cli/register-member.d.ts.map +1 -1
  35. package/dist/cli/register-member.js +7 -3
  36. package/dist/cli/register-member.js.map +1 -1
  37. package/dist/cli/start.d.ts.map +1 -1
  38. package/dist/cli/start.js +7 -0
  39. package/dist/cli/start.js.map +1 -1
  40. package/dist/cli/uninstall.d.ts.map +1 -1
  41. package/dist/cli/uninstall.js +5 -3
  42. package/dist/cli/uninstall.js.map +1 -1
  43. package/dist/cli/watch.d.ts +26 -3
  44. package/dist/cli/watch.d.ts.map +1 -1
  45. package/dist/cli/watch.js +41 -9
  46. package/dist/cli/watch.js.map +1 -1
  47. package/dist/commands/kb-server.d.ts +3 -0
  48. package/dist/commands/kb-server.d.ts.map +1 -1
  49. package/dist/commands/kb-server.js +43 -3
  50. package/dist/commands/kb-server.js.map +1 -1
  51. package/dist/index.js +3 -3
  52. package/dist/os/git-bash-candidates.d.ts +35 -0
  53. package/dist/os/git-bash-candidates.d.ts.map +1 -0
  54. package/dist/os/git-bash-candidates.js +46 -0
  55. package/dist/os/git-bash-candidates.js.map +1 -0
  56. package/dist/os/index.d.ts +13 -4
  57. package/dist/os/index.d.ts.map +1 -1
  58. package/dist/os/index.js +17 -2
  59. package/dist/os/index.js.map +1 -1
  60. package/dist/os/linux.d.ts +6 -0
  61. package/dist/os/linux.d.ts.map +1 -1
  62. package/dist/os/linux.js +36 -3
  63. package/dist/os/linux.js.map +1 -1
  64. package/dist/os/os-commands.d.ts +68 -2
  65. package/dist/os/os-commands.d.ts.map +1 -1
  66. package/dist/os/os-commands.js.map +1 -1
  67. package/dist/os/windows-gitbash.d.ts +98 -0
  68. package/dist/os/windows-gitbash.d.ts.map +1 -0
  69. package/dist/os/windows-gitbash.js +259 -0
  70. package/dist/os/windows-gitbash.js.map +1 -0
  71. package/dist/os/windows.d.ts +6 -0
  72. package/dist/os/windows.d.ts.map +1 -1
  73. package/dist/os/windows.js +73 -8
  74. package/dist/os/windows.js.map +1 -1
  75. package/dist/providers/agy.d.ts +118 -8
  76. package/dist/providers/agy.d.ts.map +1 -1
  77. package/dist/providers/agy.js +580 -55
  78. package/dist/providers/agy.js.map +1 -1
  79. package/dist/providers/claude.d.ts +83 -4
  80. package/dist/providers/claude.d.ts.map +1 -1
  81. package/dist/providers/claude.js +365 -12
  82. package/dist/providers/claude.js.map +1 -1
  83. package/dist/providers/codex.d.ts +7 -4
  84. package/dist/providers/codex.d.ts.map +1 -1
  85. package/dist/providers/codex.js +24 -4
  86. package/dist/providers/codex.js.map +1 -1
  87. package/dist/providers/copilot.d.ts +7 -4
  88. package/dist/providers/copilot.d.ts.map +1 -1
  89. package/dist/providers/copilot.js +27 -4
  90. package/dist/providers/copilot.js.map +1 -1
  91. package/dist/providers/index.d.ts +0 -1
  92. package/dist/providers/index.d.ts.map +1 -1
  93. package/dist/providers/index.js +0 -3
  94. package/dist/providers/index.js.map +1 -1
  95. package/dist/providers/none.d.ts +7 -4
  96. package/dist/providers/none.d.ts.map +1 -1
  97. package/dist/providers/none.js +22 -4
  98. package/dist/providers/none.js.map +1 -1
  99. package/dist/providers/opencode.d.ts +6 -3
  100. package/dist/providers/opencode.d.ts.map +1 -1
  101. package/dist/providers/opencode.js +27 -4
  102. package/dist/providers/opencode.js.map +1 -1
  103. package/dist/providers/provider.d.ts +215 -11
  104. package/dist/providers/provider.d.ts.map +1 -1
  105. package/dist/providers/provider.js +58 -2
  106. package/dist/providers/provider.js.map +1 -1
  107. package/dist/services/agent-provisioner.js +2 -2
  108. package/dist/services/agent-provisioner.js.map +1 -1
  109. package/dist/services/agy-project.d.ts +102 -0
  110. package/dist/services/agy-project.d.ts.map +1 -0
  111. package/dist/services/agy-project.js +356 -0
  112. package/dist/services/agy-project.js.map +1 -0
  113. package/dist/services/auth-socket.js +4 -4
  114. package/dist/services/auth-web.js +1 -1
  115. package/dist/services/cloud/activity.js +2 -2
  116. package/dist/services/cloud/activity.js.map +1 -1
  117. package/dist/services/cloud/lifecycle.d.ts.map +1 -1
  118. package/dist/services/cloud/lifecycle.js +33 -4
  119. package/dist/services/cloud/lifecycle.js.map +1 -1
  120. package/dist/services/context-admission.d.ts.map +1 -1
  121. package/dist/services/context-admission.js +9 -7
  122. package/dist/services/context-admission.js.map +1 -1
  123. package/dist/services/credential-cleanup.d.ts.map +1 -1
  124. package/dist/services/credential-cleanup.js +47 -10
  125. package/dist/services/credential-cleanup.js.map +1 -1
  126. package/dist/services/exit-drain.d.ts +44 -0
  127. package/dist/services/exit-drain.d.ts.map +1 -0
  128. package/dist/services/exit-drain.js +52 -0
  129. package/dist/services/exit-drain.js.map +1 -0
  130. package/dist/services/github-app.d.ts.map +1 -1
  131. package/dist/services/github-app.js +32 -4
  132. package/dist/services/github-app.js.map +1 -1
  133. package/dist/services/http-transport.d.ts +1 -0
  134. package/dist/services/http-transport.d.ts.map +1 -1
  135. package/dist/services/http-transport.js +48 -1
  136. package/dist/services/http-transport.js.map +1 -1
  137. package/dist/services/knowledge/kb-config.d.ts +42 -0
  138. package/dist/services/knowledge/kb-config.d.ts.map +1 -0
  139. package/dist/services/knowledge/kb-config.js +54 -0
  140. package/dist/services/knowledge/kb-config.js.map +1 -0
  141. package/dist/services/knowledge/kb-providers.d.ts +7 -1
  142. package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
  143. package/dist/services/knowledge/kb-providers.js +191 -17
  144. package/dist/services/knowledge/kb-providers.js.map +1 -1
  145. package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
  146. package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
  147. package/dist/services/knowledge/require-sqlite-project.js +38 -0
  148. package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
  149. package/dist/services/member-home.d.ts +1 -1
  150. package/dist/services/member-home.d.ts.map +1 -1
  151. package/dist/services/member-home.js +15 -12
  152. package/dist/services/member-home.js.map +1 -1
  153. package/dist/services/model-pricing.d.ts.map +1 -1
  154. package/dist/services/model-pricing.js +7 -8
  155. package/dist/services/model-pricing.js.map +1 -1
  156. package/dist/services/orphan-recovery.d.ts +6 -3
  157. package/dist/services/orphan-recovery.d.ts.map +1 -1
  158. package/dist/services/orphan-recovery.js +17 -14
  159. package/dist/services/orphan-recovery.js.map +1 -1
  160. package/dist/services/preflight-check.js +2 -2
  161. package/dist/services/preflight-check.js.map +1 -1
  162. package/dist/services/secret-token.d.ts +38 -0
  163. package/dist/services/secret-token.d.ts.map +1 -0
  164. package/dist/services/secret-token.js +51 -0
  165. package/dist/services/secret-token.js.map +1 -0
  166. package/dist/services/service-manager/types.d.ts +3 -1
  167. package/dist/services/service-manager/types.d.ts.map +1 -1
  168. package/dist/services/service-manager/windows.d.ts +14 -2
  169. package/dist/services/service-manager/windows.d.ts.map +1 -1
  170. package/dist/services/service-manager/windows.js +65 -7
  171. package/dist/services/service-manager/windows.js.map +1 -1
  172. package/dist/services/shell-probe.d.ts +131 -0
  173. package/dist/services/shell-probe.d.ts.map +1 -0
  174. package/dist/services/shell-probe.js +210 -0
  175. package/dist/services/shell-probe.js.map +1 -0
  176. package/dist/services/singleton.d.ts +2 -0
  177. package/dist/services/singleton.d.ts.map +1 -1
  178. package/dist/services/singleton.js +1 -1
  179. package/dist/services/singleton.js.map +1 -1
  180. package/dist/services/ssh.d.ts.map +1 -1
  181. package/dist/services/ssh.js +60 -4
  182. package/dist/services/ssh.js.map +1 -1
  183. package/dist/services/stall/find-log-file.d.ts.map +1 -1
  184. package/dist/services/stall/find-log-file.js +22 -16
  185. package/dist/services/stall/find-log-file.js.map +1 -1
  186. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  187. package/dist/services/stall/read-log-tail.js +26 -15
  188. package/dist/services/stall/read-log-tail.js.map +1 -1
  189. package/dist/services/stall/stall-detector.d.ts +53 -4
  190. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  191. package/dist/services/stall/stall-detector.js +212 -34
  192. package/dist/services/stall/stall-detector.js.map +1 -1
  193. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  194. package/dist/services/stall/stall-poller.js +35 -42
  195. package/dist/services/stall/stall-poller.js.map +1 -1
  196. package/dist/services/strategy.d.ts +9 -0
  197. package/dist/services/strategy.d.ts.map +1 -1
  198. package/dist/services/strategy.js +119 -8
  199. package/dist/services/strategy.js.map +1 -1
  200. package/dist/services/substitution-engine.js +2 -2
  201. package/dist/services/substitution-engine.js.map +1 -1
  202. package/dist/services/tool-registry.d.ts.map +1 -1
  203. package/dist/services/tool-registry.js +5 -3
  204. package/dist/services/tool-registry.js.map +1 -1
  205. package/dist/services/user-config.js +1 -1
  206. package/dist/services/user-config.js.map +1 -1
  207. package/dist/services/vcs/azure-devops.d.ts +67 -2
  208. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  209. package/dist/services/vcs/azure-devops.js +281 -15
  210. package/dist/services/vcs/azure-devops.js.map +1 -1
  211. package/dist/services/vcs/bitbucket.d.ts.map +1 -1
  212. package/dist/services/vcs/bitbucket.js +16 -0
  213. package/dist/services/vcs/bitbucket.js.map +1 -1
  214. package/dist/services/vcs/github.d.ts.map +1 -1
  215. package/dist/services/vcs/github.js +24 -0
  216. package/dist/services/vcs/github.js.map +1 -1
  217. package/dist/services/vcs/types.d.ts +123 -2
  218. package/dist/services/vcs/types.d.ts.map +1 -1
  219. package/dist/skills/fleet-sprint-cli/SKILL.md +20 -1
  220. package/dist/skills/pm/SKILL.md +1 -2
  221. package/dist/skills/pm/cost.md +0 -4
  222. package/dist/skills/pm/fleet-addendum.md +2 -3
  223. package/dist/tools/check-status.d.ts +7 -4
  224. package/dist/tools/check-status.d.ts.map +1 -1
  225. package/dist/tools/check-status.js +5 -3
  226. package/dist/tools/check-status.js.map +1 -1
  227. package/dist/tools/cloud-control.js +2 -2
  228. package/dist/tools/cloud-control.js.map +1 -1
  229. package/dist/tools/compose-permissions.d.ts +6 -0
  230. package/dist/tools/compose-permissions.d.ts.map +1 -1
  231. package/dist/tools/compose-permissions.js +211 -50
  232. package/dist/tools/compose-permissions.js.map +1 -1
  233. package/dist/tools/credential-store-set.js +1 -1
  234. package/dist/tools/execute-command.d.ts.map +1 -1
  235. package/dist/tools/execute-command.js +56 -29
  236. package/dist/tools/execute-command.js.map +1 -1
  237. package/dist/tools/execute-prompt.d.ts +15 -2
  238. package/dist/tools/execute-prompt.d.ts.map +1 -1
  239. package/dist/tools/execute-prompt.js +1214 -873
  240. package/dist/tools/execute-prompt.js.map +1 -1
  241. package/dist/tools/kb-capture.d.ts +2 -2
  242. package/dist/tools/kb-capture.d.ts.map +1 -1
  243. package/dist/tools/kb-capture.js +29 -5
  244. package/dist/tools/kb-capture.js.map +1 -1
  245. package/dist/tools/kb-export.d.ts +2 -2
  246. package/dist/tools/kb-export.d.ts.map +1 -1
  247. package/dist/tools/kb-export.js +3 -28
  248. package/dist/tools/kb-export.js.map +1 -1
  249. package/dist/tools/kb-feedback.d.ts.map +1 -1
  250. package/dist/tools/kb-feedback.js +3 -1
  251. package/dist/tools/kb-feedback.js.map +1 -1
  252. package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
  253. package/dist/tools/kb-freshness-sweep.js +3 -1
  254. package/dist/tools/kb-freshness-sweep.js.map +1 -1
  255. package/dist/tools/kb-import.d.ts.map +1 -1
  256. package/dist/tools/kb-import.js +2 -1
  257. package/dist/tools/kb-import.js.map +1 -1
  258. package/dist/tools/kb-list.d.ts.map +1 -1
  259. package/dist/tools/kb-list.js +3 -1
  260. package/dist/tools/kb-list.js.map +1 -1
  261. package/dist/tools/kb-query.d.ts +2 -2
  262. package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
  263. package/dist/tools/kb-reconcile-prefilter.js +3 -1
  264. package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
  265. package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
  266. package/dist/tools/kb-resolve-contradiction.js +3 -1
  267. package/dist/tools/kb-resolve-contradiction.js.map +1 -1
  268. package/dist/tools/kb-setup.d.ts.map +1 -1
  269. package/dist/tools/kb-setup.js +125 -20
  270. package/dist/tools/kb-setup.js.map +1 -1
  271. package/dist/tools/kb-stats.d.ts.map +1 -1
  272. package/dist/tools/kb-stats.js +64 -43
  273. package/dist/tools/kb-stats.js.map +1 -1
  274. package/dist/tools/list-members.d.ts +2 -2
  275. package/dist/tools/list-members.d.ts.map +1 -1
  276. package/dist/tools/list-members.js +7 -2
  277. package/dist/tools/list-members.js.map +1 -1
  278. package/dist/tools/member-detail.d.ts +2 -2
  279. package/dist/tools/member-detail.d.ts.map +1 -1
  280. package/dist/tools/member-detail.js +22 -3
  281. package/dist/tools/member-detail.js.map +1 -1
  282. package/dist/tools/member-reservation.d.ts +58 -1
  283. package/dist/tools/member-reservation.d.ts.map +1 -1
  284. package/dist/tools/member-reservation.js +71 -18
  285. package/dist/tools/member-reservation.js.map +1 -1
  286. package/dist/tools/monitor-task.d.ts.map +1 -1
  287. package/dist/tools/monitor-task.js +17 -2
  288. package/dist/tools/monitor-task.js.map +1 -1
  289. package/dist/tools/provision-auth.d.ts +80 -1
  290. package/dist/tools/provision-auth.d.ts.map +1 -1
  291. package/dist/tools/provision-auth.js +147 -59
  292. package/dist/tools/provision-auth.js.map +1 -1
  293. package/dist/tools/provision-vcs-auth.d.ts +96 -3
  294. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  295. package/dist/tools/provision-vcs-auth.js +254 -88
  296. package/dist/tools/provision-vcs-auth.js.map +1 -1
  297. package/dist/tools/register-member.d.ts +21 -12
  298. package/dist/tools/register-member.d.ts.map +1 -1
  299. package/dist/tools/register-member.js +141 -16
  300. package/dist/tools/register-member.js.map +1 -1
  301. package/dist/tools/remove-member.d.ts.map +1 -1
  302. package/dist/tools/remove-member.js +29 -4
  303. package/dist/tools/remove-member.js.map +1 -1
  304. package/dist/tools/revoke-vcs-auth.js +2 -2
  305. package/dist/tools/revoke-vcs-auth.js.map +1 -1
  306. package/dist/tools/send-email.d.ts +2 -2
  307. package/dist/tools/setup-git-app.d.ts.map +1 -1
  308. package/dist/tools/setup-git-app.js +11 -7
  309. package/dist/tools/setup-git-app.js.map +1 -1
  310. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  311. package/dist/tools/setup-ssh-key.js +2 -1
  312. package/dist/tools/setup-ssh-key.js.map +1 -1
  313. package/dist/tools/shutdown-server.d.ts +2 -0
  314. package/dist/tools/shutdown-server.d.ts.map +1 -1
  315. package/dist/tools/shutdown-server.js +23 -1
  316. package/dist/tools/shutdown-server.js.map +1 -1
  317. package/dist/tools/stop-prompt.js +2 -2
  318. package/dist/tools/stop-prompt.js.map +1 -1
  319. package/dist/tools/update-agent-cli.js +2 -2
  320. package/dist/tools/update-agent-cli.js.map +1 -1
  321. package/dist/tools/update-member.d.ts +21 -12
  322. package/dist/tools/update-member.d.ts.map +1 -1
  323. package/dist/tools/update-member.js +61 -12
  324. package/dist/tools/update-member.js.map +1 -1
  325. package/dist/tools/vcs-credential-exec.d.ts +127 -0
  326. package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
  327. package/dist/tools/vcs-credential-exec.js +197 -0
  328. package/dist/tools/vcs-credential-exec.js.map +1 -0
  329. package/dist/types.d.ts +24 -1
  330. package/dist/types.d.ts.map +1 -1
  331. package/dist/utils/agent-helpers.d.ts +36 -0
  332. package/dist/utils/agent-helpers.d.ts.map +1 -1
  333. package/dist/utils/agent-helpers.js +39 -1
  334. package/dist/utils/agent-helpers.js.map +1 -1
  335. package/dist/utils/log-helpers.d.ts.map +1 -1
  336. package/dist/utils/log-helpers.js +2 -2
  337. package/dist/utils/log-helpers.js.map +1 -1
  338. package/dist/utils/platform.d.ts +7 -0
  339. package/dist/utils/platform.d.ts.map +1 -1
  340. package/dist/utils/platform.js +11 -1
  341. package/dist/utils/platform.js.map +1 -1
  342. package/dist/utils/prompt-errors.d.ts.map +1 -1
  343. package/dist/utils/prompt-errors.js +7 -1
  344. package/dist/utils/prompt-errors.js.map +1 -1
  345. package/dist/utils/shell-escape.d.ts +16 -0
  346. package/dist/utils/shell-escape.d.ts.map +1 -1
  347. package/dist/utils/shell-escape.js +22 -2
  348. package/dist/utils/shell-escape.js.map +1 -1
  349. package/dist/utils/vcs-provider-detect.d.ts +65 -0
  350. package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
  351. package/dist/utils/vcs-provider-detect.js +109 -0
  352. package/dist/utils/vcs-provider-detect.js.map +1 -0
  353. package/dist/utils/workspace-trust.d.ts +20 -17
  354. package/dist/utils/workspace-trust.d.ts.map +1 -1
  355. package/dist/utils/workspace-trust.js +91 -1
  356. package/dist/utils/workspace-trust.js.map +1 -1
  357. package/dist/workflows/auto-sprint.js +180 -32
  358. package/package.json +7 -5
  359. package/packages/apra-fleet-client/src/client/api.mjs +403 -12
  360. package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
  361. package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
  362. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +42 -21
  363. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +14 -0
  364. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +59 -46
  365. package/packages/apra-fleet-se/apra-pm/agents/doer.md +157 -134
  366. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +31 -32
  367. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +92 -113
  368. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +40 -42
  369. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +139 -63
  370. package/packages/apra-fleet-se/apra-pm/agents/planner.md +176 -100
  371. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +77 -81
  372. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +69 -85
  373. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
  374. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
  375. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
  376. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -2
  377. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -4
  378. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -3
  379. package/packages/apra-fleet-se/bin/cli.mjs +280 -3
  380. package/packages/apra-fleet-se/bin/serve.mjs +114 -5
  381. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
  382. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
  383. package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
  384. package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
  385. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
  386. package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
  387. package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
  388. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
  389. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +199 -34
  390. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
  391. package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
  392. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
  393. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
  394. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +23 -8
  395. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
  396. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +285 -4
  397. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +3 -3
  398. package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
  399. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
  400. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
  401. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
  402. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
  403. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1054 -39
  404. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +308 -0
  405. package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
  406. package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
  407. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
  408. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
  409. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
  410. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
  411. package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
  412. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
  413. package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
  414. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
  415. package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
  416. package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
  417. package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
  418. package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
  419. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
  420. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
  421. package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
  422. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
  423. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
  424. package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
  425. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
  426. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
  427. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
  428. package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
  429. package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
  430. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
  431. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
  432. package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
  433. package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
  434. package/packages/apra-fleet-se/fleet-sprint/runner.js +1672 -9072
  435. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
  436. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +159 -0
  437. package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
  438. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
  439. package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
  440. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +20 -1
  441. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
  442. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
  443. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
  444. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
  445. package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
  446. package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
  447. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
  448. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +204 -19
  449. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +707 -12
  450. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
  451. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
  452. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +191 -43
  453. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +333 -6
  454. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +165 -0
  455. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +167 -37
  456. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
  457. package/packages/apra-fleet-se/package.json +1 -1
  458. package/packages/apra-fleet-workflow/src/viewer/index.mjs +178 -1
  459. package/packages/apra-fleet-workflow/src/workflow/index.mjs +478 -32
  460. package/skills/fleet/SKILL.md +27 -16
  461. package/skills/fleet/auth-azdevops.md +57 -7
  462. package/skills/fleet/auth-bitbucket.md +5 -5
  463. package/skills/fleet/auth-github.md +7 -6
  464. package/skills/fleet/beads-conflict-resolution.md +141 -0
  465. package/skills/fleet/beads.md +16 -12
  466. package/skills/fleet/onboarding.md +6 -6
  467. package/skills/fleet/permissions.md +11 -7
  468. package/skills/fleet/profiles/node.json +1 -1
  469. package/skills/fleet/skill-matrix.md +1 -1
  470. package/skills/fleet/troubleshooting.md +4 -3
  471. package/version.json +1 -1
  472. package/dist/providers/gemini.d.ts +0 -52
  473. package/dist/providers/gemini.d.ts.map +0 -1
  474. package/dist/providers/gemini.js +0 -236
  475. package/dist/providers/gemini.js.map +0 -1
  476. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
@@ -22,8 +22,96 @@
22
22
  * rules: { [VCS_FAILURE_KIND]: RegExp[] } // classifyFailure() axis
23
23
  * precedence: string[]|undefined // optional kind-check order override
24
24
  * extractProviderCode: (raw) => string|null // classifyFailure() axis
25
- * matchesHost: (host) => boolean // capabilities() axis
26
- * capabilitiesForHost: (host) => { canOpenPullRequest: boolean } // capabilities() axis
25
+ * matchesHost: (host) => boolean // OPTIONAL; capabilities()
26
+ * // axis. Which remote hosts this
27
+ * // provider claims, for
28
+ * // resolveVcsProviderForHost()
29
+ * // below. Omit for a provider that
30
+ * // never owns a host (dolt), and
31
+ * // for the generic-git catch-all
32
+ * // it returns true unconditionally.
33
+ * matchesHostForAuth: (host) => boolean // OPTIONAL; the CREDENTIAL-
34
+ * // PROVISIONING axis, for
35
+ * // resolveVcsAuthProviderForHost()
36
+ * // below. Declare it ONLY when a
37
+ * // provider's matchesHost() is
38
+ * // deliberately wider than the set
39
+ * // of hosts it is safe to auto-mint
40
+ * // a push credential for (see
41
+ * // ./github.mjs). Omitted means
42
+ * // "matchesHost is already exactly
43
+ * // right for auth too", which is
44
+ * // the case for every anchored
45
+ * // matcher.
46
+ * capabilitiesForHost: (host) => { canOpenPullRequest: boolean } // OPTIONAL;
47
+ * // capabilities() axis. What a
48
+ * // claimed host supports. MUST stay
49
+ * // in lockstep with `builders`:
50
+ * // report canOpenPullRequest:false
51
+ * // while the create-pull-request
52
+ * // builder is absent, so publish
53
+ * // never builds an unsupported
54
+ * // command (see ./azure-devops.mjs).
55
+ * // A provider that omits this hook
56
+ * // is treated as capability-less.
57
+ * parseRepoRef: (url) => { org, project, repo, canonical }|null // OPTIONAL;
58
+ * // remote-URL axis. Parse a git
59
+ * // remote URL into the coordinates
60
+ * // this provider's REST API needs,
61
+ * // for providers whose identity is
62
+ * // not the portable "owner/name"
63
+ * // pair (see ./azure-devops.mjs).
64
+ * // MUST return null -- never throw,
65
+ * // never a partial guess -- for
66
+ * // input it does not recognize, so
67
+ * // the caller can raise its own
68
+ * // typed ERROR naming the expected
69
+ * // shape.
70
+ * repoRefHint: string // OPTIONAL; remote-URL axis. The
71
+ * // human-readable remote shape
72
+ * // parseRepoRef() expects, e.g.
73
+ * // 'https://dev.azure.com/ORG/
74
+ * // PROJECT/_git/REPO'. Quoted
75
+ * // verbatim into the typed ERROR
76
+ * // VCSModule.parseProviderRepoRef()
77
+ * // raises for a claimed-but-
78
+ * // unrecognized remote, which is
79
+ * // what keeps that remedy text --
80
+ * // and every other provider-specific
81
+ * // literal -- out of the shared
82
+ * // callers. Only meaningful
83
+ * // alongside parseRepoRef.
84
+ * buildProvisionArgs: (ctx) => { args, note? }|{ error } // OPTIONAL;
85
+ * // provisioning axis. Build the
86
+ * // provision_vcs_auth argument
87
+ * // object for a member of this
88
+ * // provider, given the shared
89
+ * // caller's `base` args, this
90
+ * // provider's own parseRepoRef()
91
+ * // output for the member's remote
92
+ * // (`repoRef`) and the credential-
93
+ * // store entry names the caller
94
+ * // observed (`availableSecrets`,
95
+ * // null when unreadable). Omit it
96
+ * // and the caller sends its shared
97
+ * // GitHub-App-shaped arguments
98
+ * // unchanged. MUST return a typed
99
+ * // 'ERROR: ' string in `error`
100
+ * // rather than prompting: the
101
+ * // callers are unattended preflight
102
+ * // and self-heal paths, where an
103
+ * // out-of-band prompt stalls a
104
+ * // sprint. MUST pass a secret as a
105
+ * // {{secret.NAME}} placeholder,
106
+ * // never a value -- resolution is
107
+ * // hub-side (see ./azure-devops.mjs).
108
+ * // ctx also carries the raw
109
+ * // `remoteUrl` the caller read and
110
+ * // `remoteReadError` (why it could
111
+ * // not be read, else null). An
112
+ * // optional `note` string next to
113
+ * // `args` is logged as an advisory,
114
+ * // never treated as a failure.
27
115
  * defaultAuthMode: string|null // OPTIONAL, but declaring it (even
28
116
  * // as null) is what makes a provider
29
117
  * // part of resolveProvider()'s/
@@ -33,12 +121,136 @@
33
121
  * // classification-only provider
34
122
  * // (generic-git, dolt) that is not a
35
123
  * // member-facing VCS auth backend.
124
+ * pullRequestResponse: { // OPTIONAL; response axis
125
+ * idField: string, // apra-fleet-lzfv.4. How to read a
126
+ * webUrlField: string|null, // create-pull-request 2xx response
127
+ * webUrlTemplate: string|null, // BODY, which is as provider-
128
+ * map: (body, ctx) => { id, url } // specific as the request is:
129
+ * } // GitHub answers with `number` +
130
+ * // `html_url`, Azure DevOps with
131
+ * // `pullRequestId` and NO web-URL
132
+ * // field at all (its `url` is the
133
+ * // REST resource, not a page), so
134
+ * // its browsable URL must be
135
+ * // CONSTRUCTED from the request's
136
+ * // own org/project/repo plus the
137
+ * // returned id. Declaring the
138
+ * // mapping on the descriptor is
139
+ * // what keeps either dialect out
140
+ * // of the shared caller, which
141
+ * // until this hook existed read
142
+ * // `html_url` off the body itself.
143
+ * // `idField`/`webUrlField`/
144
+ * // `webUrlTemplate` are the
145
+ * // DECLARATION (what a consumer
146
+ * // mirroring this contract in
147
+ * // another language/package
148
+ * // restates); `map` is the single
149
+ * // executable source of truth and
150
+ * // MUST read those same declared
151
+ * // fields rather than repeat them.
152
+ * // `map` MUST NOT throw and MUST
153
+ * // return { id: number|null,
154
+ * // url: string|null } -- an
155
+ * // unreadable id or a coordinate
156
+ * // missing from `ctx` yields null,
157
+ * // never a guessed value, so a
158
+ * // successful PR is never turned
159
+ * // into a crash by its own
160
+ * // reporting step. `ctx` is the
161
+ * // request-side coordinates
162
+ * // (org/project/repo, or a
163
+ * // `repoRef` object -- the same
164
+ * // shape the builders take); a
165
+ * // provider whose body is
166
+ * // self-sufficient ignores it.
36
167
  * builders: { [action]: Function }|null // create-pull-request/comment
37
168
  * // command builders; null means
38
169
  * // "known provider, action(s)
39
170
  * // not yet implemented" (fails
40
171
  * // closed with a typed ERROR:,
41
172
  * // never a silently wrong command)
173
+ * authRemedy: { // OPTIONAL; auth-self-heal axis
174
+ * serverSideReMintable: boolean, // (apra-fleet-5co8.4.2). Whether
175
+ * hint: string // the REACTIVE self-heal callback
176
+ * } // (runner.js's
177
+ * // createVcsAuthSelfHealCallback)
178
+ * // can actually fix an
179
+ * // auth-classified failure by
180
+ * // calling provision_vcs_auth
181
+ * // again on its own: true for a
182
+ * // GitHub App installation token
183
+ * // (minted fresh server-side
184
+ * // every call) or a credential the
185
+ * // fleet can otherwise regenerate
186
+ * // without a human; false for a
187
+ * // long-lived PAT/app password the
188
+ * // fleet only ever stores and
189
+ * // redeploys, never mints (see
190
+ * // ./azure-devops.mjs) -- re-
191
+ * // provisioning there just
192
+ * // redeploys the SAME dead
193
+ * // secret, so the self-heal
194
+ * // attempt is expected to fail
195
+ * // again. `hint` is the exact
196
+ * // operator-facing remedy text
197
+ * // printed alongside the self-
198
+ * // heal attempt when
199
+ * // `serverSideReMintable` is
200
+ * // false, so a provider-specific
201
+ * // literal never leaks into the
202
+ * // shared runner.js caller.
203
+ * // Omitting this hook (or
204
+ * // omitting `serverSideReMintable`
205
+ * // from it) means "assume
206
+ * // re-mintable" -- the
207
+ * // pre-existing GitHub/generic
208
+ * // behavior, unchanged.
209
+ * permissionScope: { // OPTIONAL; permission-scope axis.
210
+ * rules: RegExp[], // Patterns whose match means "the
211
+ * describe?: (raw) => string // identity was understood and the
212
+ * } // PRINCIPAL lacks the granted
213
+ * // permission/scope for this
214
+ * // operation". Two things follow
215
+ * // from a match, and neither is
216
+ * // expressible through `rules` +
217
+ * // `precedence` alone:
218
+ * // (1) the verdict is AUTH_DENIED
219
+ * // OUTRIGHT, ahead of every kind
220
+ * // in KIND_PRECEDENCE -- because
221
+ * // a host's permission refusal
222
+ * // usually arrives wrapped in the
223
+ * // host's GENERIC rejection tail
224
+ * // (for git: "failed to push some
225
+ * // refs", which DIVERGED matches
226
+ * // and which outranks AUTH), and
227
+ * // reordering a whole provider's
228
+ * // `precedence` to fix one rule
229
+ * // would re-read every other
230
+ * // ambiguous text too;
231
+ * // (2) the failure is NOT
232
+ * // self-healable -- re-minting the
233
+ * // same principal's credential
234
+ * // reproduces the same permission
235
+ * // set, so runGitStep returns it
236
+ * // immediately with no
237
+ * // onAuthFailure call and no
238
+ * // retry.
239
+ * // `describe(raw)` returns the
240
+ * // operator-facing referral
241
+ * // (which resource, which missing
242
+ * // permission, what an operator
243
+ * // must grant) that travels on
244
+ * // classifyFailure()'s
245
+ * // `operatorReferral`, so the
246
+ * // provider-specific wording never
247
+ * // leaks into a shared caller.
248
+ * // Omitting this hook means "this
249
+ * // provider has no
250
+ * // permission-scope rules" --
251
+ * // every AUTH_DENIED it produces
252
+ * // keeps today's self-heal
253
+ * // treatment.
42
254
  * }
43
255
  *
44
256
  * The manifest is an explicit import list rather than a directory scan on
@@ -87,10 +299,26 @@ export function registerVcsProvider(impl) {
87
299
  throw new Error('ERROR: VCSModule: a provider implementation must be an object with a non-empty string `name`.');
88
300
  }
89
301
  if (impl.rules != null && typeof impl.rules !== 'object') {
90
- throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`rules\` table.`);
302
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`rules\` table.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
91
303
  }
92
304
  if (impl.extractProviderCode != null && typeof impl.extractProviderCode !== 'function') {
93
- throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-function \`extractProviderCode\`.`);
305
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-function \`extractProviderCode\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
306
+ }
307
+ // apra-fleet-5co8.1.1: the host/URL-axis hooks. All OPTIONAL (a
308
+ // classification-only provider declares none of them), but validated up
309
+ // front for the same reason as `extractProviderCode` above -- a malformed
310
+ // hook must fail at registration, not inside resolveVcsProviderForHost()
311
+ // or a remote-URL preflight where the error would mask the real failure.
312
+ for (const hook of ['matchesHost', 'matchesHostForAuth', 'capabilitiesForHost', 'parseRepoRef', 'buildProvisionArgs']) {
313
+ if (impl[hook] != null && typeof impl[hook] !== 'function') {
314
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-function \`${hook}\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
315
+ }
316
+ }
317
+ // apra-fleet-5co8.1.2: the remedy text quoted into a preflight ERROR. A
318
+ // non-string here would land the literal 'undefined'/'[object Object]' in
319
+ // an operator-facing error, so reject it at registration too.
320
+ if (impl.repoRefHint != null && typeof impl.repoRefHint !== 'string') {
321
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-string \`repoRefHint\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
94
322
  }
95
323
  // apra-fleet-647.1.5.1: the two auth-backend fields folded in from
96
324
  // vcs-module.mjs's former BUILDERS/DEFAULT_AUTH_MODES tables. Both are
@@ -98,11 +326,77 @@ export function registerVcsProvider(impl) {
98
326
  // them entirely -- see isAuthBackend() below), but validated up front,
99
327
  // same rationale as `rules`/`extractProviderCode` above.
100
328
  if (Object.prototype.hasOwnProperty.call(impl, 'defaultAuthMode') && impl.defaultAuthMode !== null && typeof impl.defaultAuthMode !== 'string') {
101
- throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-string, non-null \`defaultAuthMode\`.`);
329
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-string, non-null \`defaultAuthMode\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
330
+ }
331
+ // apra-fleet-lzfv.4: the create-pull-request RESPONSE mapping. OPTIONAL
332
+ // (a classification-only provider, or one with no PR builder, declares
333
+ // none), but validated up front for the same reason as the hooks above --
334
+ // a malformed mapping must fail at registration, not while reporting an
335
+ // already-created pull request, where the error would mask a success.
336
+ if (impl.pullRequestResponse != null) {
337
+ const prr = impl.pullRequestResponse;
338
+ if (typeof prr !== 'object') {
339
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`pullRequestResponse\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
340
+ }
341
+ if (typeof prr.idField !== 'string' || !prr.idField.trim()) {
342
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a \`pullRequestResponse\` with no non-empty string \`idField\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
343
+ }
344
+ if (typeof prr.map !== 'function') {
345
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a \`pullRequestResponse\` with a non-function \`map\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
346
+ }
347
+ for (const field of ['webUrlField', 'webUrlTemplate']) {
348
+ if (prr[field] != null && typeof prr[field] !== 'string') {
349
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a \`pullRequestResponse\` with a non-string, non-null \`${field}\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
350
+ }
351
+ }
352
+ }
353
+ // apra-fleet-5co8.4.2: the auth-self-heal remedy axis. OPTIONAL (omitting
354
+ // it means "assume re-mintable", the pre-existing behavior), but
355
+ // validated up front for the same reason as the hooks above -- a
356
+ // malformed remedy must fail at registration, not while reporting an
357
+ // already-failed self-heal attempt, where the error would mask the real
358
+ // auth failure.
359
+ if (impl.authRemedy != null) {
360
+ const remedy = impl.authRemedy;
361
+ if (typeof remedy !== 'object') {
362
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`authRemedy\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
363
+ }
364
+ if (typeof remedy.serverSideReMintable !== 'boolean') {
365
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has an \`authRemedy\` with a non-boolean \`serverSideReMintable\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
366
+ }
367
+ if (typeof remedy.hint !== 'string' || !remedy.hint.trim()) {
368
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has an \`authRemedy\` with no non-empty string \`hint\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
369
+ }
370
+ }
371
+ // The permission-scope axis. OPTIONAL (omitting it means "this provider
372
+ // declares no permission-scope rules", i.e. today's behavior for every
373
+ // AUTH_DENIED it produces), but validated up front for the same reason as
374
+ // the hooks above: a malformed hook must fail at registration, not inside
375
+ // classifyFailure() where the error would mask the very failure being
376
+ // classified.
377
+ if (impl.permissionScope != null) {
378
+ const scope = impl.permissionScope;
379
+ if (typeof scope !== 'object') {
380
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`permissionScope\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
381
+ }
382
+ if (!Array.isArray(scope.rules) || scope.rules.length === 0) {
383
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a \`permissionScope\` with no non-empty \`rules\` array.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
384
+ }
385
+ for (const re of scope.rules) {
386
+ if (!(re instanceof RegExp)) {
387
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-RegExp entry in \`permissionScope.rules\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
388
+ }
389
+ if (re.global) {
390
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a global (/g) entry in \`permissionScope.rules\` -- a /g regex carries lastIndex between calls and would make classifyFailure non-deterministic.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
391
+ }
392
+ }
393
+ if (scope.describe != null && typeof scope.describe !== 'function') {
394
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a \`permissionScope\` with a non-function \`describe\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
395
+ }
102
396
  }
103
397
  if (impl.builders != null) {
104
398
  if (typeof impl.builders !== 'object') {
105
- throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`builders\` table.`);
399
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-object \`builders\` table.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
106
400
  }
107
401
  for (const [action, builder] of Object.entries(impl.builders)) {
108
402
  if (typeof builder !== 'function') {
@@ -213,6 +507,39 @@ export function resolveVcsProviderForHost(host) {
213
507
  return registry.get('generic-git') || GenericGitVCS;
214
508
  }
215
509
 
510
+ /**
511
+ * The CREDENTIAL-PROVISIONING sibling of resolveVcsProviderForHost().
512
+ *
513
+ * Same dispatch, one deliberate difference: a provider that declares
514
+ * `matchesHostForAuth` is asked THAT instead of `matchesHost`. Recognizing a
515
+ * host for capabilities() ("could a PR be opened here?") is cheap to get
516
+ * wrong -- the worst case is a PR attempt that fails. Recognizing it for auth
517
+ * is not: the caller mints a real push credential and points it at the host,
518
+ * so a substring matcher (see ./github.mjs's matchesHost, deliberately wide
519
+ * for GitHub Enterprise Server) would hand that credential to any lookalike
520
+ * domain containing the vendor name. Providers whose matcher is already
521
+ * anchored (bitbucket, azure-devops) declare no separate hook and are
522
+ * unaffected.
523
+ *
524
+ * Returns null rather than the generic-git catch-all: "no registered auth
525
+ * backend claims this host" is the answer a provisioning caller needs, and a
526
+ * catch-all descriptor there would read as a detection when it is a guess.
527
+ *
528
+ * @param {string|null} host
529
+ * @returns {object|null} an auth-backend provider descriptor, or null.
530
+ */
531
+ export function resolveVcsAuthProviderForHost(host) {
532
+ for (const provider of [...registry.values()].reverse()) {
533
+ if (provider.name === 'generic-git') continue;
534
+ if (!isAuthBackend(provider)) continue;
535
+ const matcher = typeof provider.matchesHostForAuth === 'function'
536
+ ? provider.matchesHostForAuth
537
+ : provider.matchesHost;
538
+ if (typeof matcher === 'function' && matcher(host)) return provider;
539
+ }
540
+ return null;
541
+ }
542
+
216
543
  for (const impl of BUILT_IN_PROVIDERS) registerVcsProvider(impl);
217
544
 
218
545
  export { GenericGitVCS, GitHubVCS, DoltVCS, BitbucketVCS, AzureDevOpsVCS };
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Shared shell-quoting, curl-binary and token-assertion helpers for VCS
3
+ * provider command builders. Used by GitHub and Azure DevOps, and available
4
+ * for use by other providers to ensure consistent shell-escaping rules across
5
+ * all providers.
6
+ *
7
+ * RE-LANDED (apra-fleet-lzfv.2): apra-fleet-lzfv.1 first hoisted shQuote() and
8
+ * assertToken() out of ./github.mjs into this module; commit 1188d2ab (an
9
+ * unrelated orchestrator-sync/dolt-timeout change) then deleted this file and
10
+ * re-inlined both as private definitions in github.mjs. This is that same pure
11
+ * move re-applied, with curlBinary() added to it -- ./azure-devops.mjs needs
12
+ * the Windows curl.exe token for exactly the same reason github.mjs does, and
13
+ * copying it would recreate the duplication this module exists to prevent.
14
+ *
15
+ * shQuote's shell-aware (3rd `shell` arg) form was re-landed here on top of
16
+ * that: 0e291ace (fix(fleet-sprint): quote VCS curl commands by member shell,
17
+ * not bare OS) found that a Windows member whose registered shell is
18
+ * Git-for-Windows bash got PowerShell doubled-quote escaping from the
19
+ * OS-only check, corrupting the create-PR curl -d JSON payload. That fix
20
+ * originally landed inline in github.mjs (github.mjs was still the only
21
+ * caller); merged in here so both providers share the corrected logic
22
+ * instead of github.mjs re-diverging from this module a second time.
23
+ *
24
+ * ASCII only.
25
+ */
26
+
27
+ /** Single-quote a string for embedding in a shell command. The built curl
28
+ * command is dispatched through the member's own COMMAND SHELL, so the
29
+ * quoting dialect must follow that shell -- NOT the bare OS:
30
+ * - POSIX sh/bash (and Git-for-Windows bash on a Windows member) closes/
31
+ * reopens the quote around an embedded single quote ('\'').
32
+ * - Windows PowerShell (see wrapPowerShellEncoded()/isWindows in
33
+ * src/tools/remove-member.ts) escapes an embedded single quote inside a
34
+ * single-quoted string by DOUBLING it (''), not by backslash-closing.
35
+ * Using the POSIX form on a PowerShell member breaks the quoting outright
36
+ * (observed live: Publish PR crashing on any title/body containing an
37
+ * apostrophe) -- and, the mirror defect, using the PowerShell form on a
38
+ * Windows member whose registered shell is gitbash corrupts the curl -d
39
+ * JSON payload (observed live: GitHub's create-PR endpoint answering
40
+ * "HTTP 400: Problems parsing JSON"), because bash reads '' as
41
+ * close-then-reopen, not as an escaped quote.
42
+ *
43
+ * `os` is one of resolveMemberOs()'s return values ('windows'/'linux'/
44
+ * 'darwin'); `shell` is the member's registered shell as resolved by
45
+ * runner.js's resolveMemberTarget() -- 'gitbash' | 'pwsh7' | 'powershell5'
46
+ * | '' (empty/undefined when the registry recorded none, or when a caller
47
+ * does not yet thread shell through -- see usesPowerShellQuoting below).
48
+ * Resolution, mirroring se-os-commands.mjs's getSeCommands() matrix:
49
+ * - shell 'gitbash' -> POSIX quoting, even on Windows
50
+ * - shell 'pwsh7'/'powershell5' -> PowerShell doubling
51
+ * - unresolved shell ('' / undefined) + windows -> PowerShell doubling
52
+ * (the historical default: every Windows member was assumed PowerShell
53
+ * before shells were recorded -- the fallback stays byte-identical)
54
+ * - any non-Windows os -> POSIX quoting, byte-identical to
55
+ * before this parameter existed. */
56
+ function usesPowerShellQuoting(os, shell) {
57
+ if (shell === 'gitbash') return false;
58
+ if (shell === 'pwsh7' || shell === 'powershell5') return true;
59
+ return os === 'windows';
60
+ }
61
+
62
+ /** Pre-escape `value` for the Windows C-runtime argv parser that a NATIVE
63
+ * executable (curl.exe) applies to the command line PowerShell hands it.
64
+ *
65
+ * Windows PowerShell 5.1's native-command argument binder (and pwsh before
66
+ * 7.3) passes a single-quoted argument's VALUE through to the child process
67
+ * command line without escaping anything: the only thing it does is wrap
68
+ * the value in double quotes when it finds whitespace OUTSIDE what it
69
+ * counts as a double-quoted region. The child's CRT parser then eats every
70
+ * embedded `"` as a quote toggle, so a JSON payload like {"title":"x y"}
71
+ * reaches curl.exe as {title:x y} (measured live on powershell.exe
72
+ * 5.1.19041 with a node argv probe: every `"` stripped, spaces kept) and
73
+ * Azure DevOps/GitHub answer HTTP 400 to the unparseable body. Same defect
74
+ * class dolt-settle.mjs's nodeEval() already works around for its
75
+ * PowerShell branch.
76
+ *
77
+ * The CRT rules (CommandLineToArgvW / MSVC argv), which this function
78
+ * inverts so the child reconstructs `value` byte-for-byte:
79
+ * - 2n backslashes + `"` -> n backslashes, `"` toggles quoting
80
+ * - 2n+1 backslashes + `"` -> n backslashes, literal `"`
81
+ * - backslashes NOT followed by `"` are literal (so a JSON `\n` escape
82
+ * inside a string value is left alone)
83
+ * So every run of n backslashes that precedes a `"` becomes 2n+1
84
+ * backslashes + `"` (n=0: `"` -> `\"`).
85
+ *
86
+ * LIMIT (measured, not assumed): the 5.1 binder counts a backslash-escaped
87
+ * `\"` toward its quote parity exactly like a bare `"`, while the CRT does
88
+ * NOT toggle on it -- so for a value carrying BOTH whitespace and quotes
89
+ * the two parsers disagree about whether that whitespace is "inside
90
+ * quotes", the binder skips its wrapping, and the CRT splits the argument
91
+ * at the whitespace (observed: a JSON title 'Auto-sprint [PASS]: x'
92
+ * arrived as two argv entries). There is no escape sequence both parsers
93
+ * read the same way, so a caller must keep such a value whitespace-free --
94
+ * see shQuoteJson() below, which does exactly that for JSON payloads (the
95
+ * only quote-bearing arguments the VCS builders emit). A value with
96
+ * whitespace but NO quotes (an `-H 'Content-Type: application/json'`
97
+ * header) is wrapped by the binder and parsed back intact by the CRT.
98
+ *
99
+ * NOTE pwsh 7.3+ defaults $PSNativeCommandArgumentPassing to 'Windows'
100
+ * mode, which escapes embedded `"` itself; this pre-escaping is for the
101
+ * legacy binder that every Windows member in this fleet is driven through
102
+ * today (src/os/windows.ts cleanExec() spawns `powershell.exe`, and the
103
+ * remote path sends raw PowerShell text to the member's default shell). */
104
+ function escapeForWindowsArgv(value) {
105
+ // shell-guard-allow: ${backslashes} is a JS template interpolation of the regex-replace callback's own parameter, resolved entirely in JavaScript before the escaped string is ever assembled into a command -- not a shell-side expansion.
106
+ return String(value).replace(/(\\*)"/g, (_m, backslashes) => `${backslashes}${backslashes}\\"`);
107
+ }
108
+
109
+ function shQuote(value, os, shell) {
110
+ if (usesPowerShellQuoting(os, shell)) {
111
+ // Two layers, applied inside-out: first the CRT argv pre-escaping
112
+ // above (what the NATIVE child parses), then PowerShell's own
113
+ // single-quoted-string escape (what PowerShell parses to get the
114
+ // value it hands the binder) -- a lone `'` inside a `'...'` string
115
+ // is written as `''`.
116
+ return `'${escapeForWindowsArgv(value).replace(/'/g, "''")}'`;
117
+ }
118
+ return `'${String(value).replace(/'/g, `'\\''`)}'`;
119
+ }
120
+
121
+ /** Quote a JSON document for a `-d` argument. POSIX: plain shQuote of the
122
+ * JSON.stringify() text. PowerShell dialect: every literal whitespace code
123
+ * point left in the JSON text (a space inside a string value; JSON.stringify
124
+ * already escapes \n \t \r) is rewritten as its equivalent JSON `\uXXXX`
125
+ * escape -- byte-different, semantically identical JSON -- so the argument
126
+ * carries NO whitespace and the 5.1 binder-vs-CRT disagreement described on
127
+ * escapeForWindowsArgv() can never arise: the binder leaves the value bare,
128
+ * the CRT reads each `\"` as a literal quote, and curl.exe receives the
129
+ * exact JSON the caller built. Whitespace cannot appear outside a string
130
+ * in JSON.stringify() output, so the rewrite is always inside a string. */
131
+ function shQuoteJson(json, os, shell) {
132
+ const text = String(json);
133
+ if (!usesPowerShellQuoting(os, shell)) return shQuote(text, os, shell);
134
+ const noWhitespace = text.replace(/\s/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, '0')}`);
135
+ return shQuote(noWhitespace, os, shell);
136
+ }
137
+
138
+ /** Which curl binary token to emit for a given member OS. On Windows the bare
139
+ * word `curl` is a built-in PowerShell alias for Invoke-WebRequest, NOT the
140
+ * real curl -- Invoke-WebRequest's -Headers parameter wants a hashtable, not
141
+ * curl's repeatable `-H 'k: v'` string syntax, so a bare `curl -H ...`
142
+ * command sent to a Windows/PowerShell member fails with a parameter-bind
143
+ * error (observed live on the Publish PR step). The real curl.exe binary has
144
+ * shipped in %SystemRoot%\System32 since Windows 10 1803 and is resolvable
145
+ * from PowerShell's default PATH (verified locally: `where curl.exe` and
146
+ * `Get-Command curl.exe` both resolve on a live Windows box), so emitting
147
+ * the explicit `curl.exe` token sidesteps the alias entirely without
148
+ * needing a different request mechanism. Non-Windows os values keep the
149
+ * bare `curl` token byte-identical to before this branch existed.
150
+ * Deliberately OS-keyed (not shell-keyed like shQuote above): curl.exe is
151
+ * equally resolvable from Git-for-Windows bash, so a windows+gitbash member
152
+ * keeps the same binary token. */
153
+ function curlBinary(os) {
154
+ return os === 'windows' ? 'curl.exe' : 'curl';
155
+ }
156
+
157
+ function assertToken(token) {
158
+ const value = String(token ?? '');
159
+ if (!value) {
160
+ throw new Error('ERROR: VCSModule: no token supplied -- caller must mint one via provision_vcs_auth before calling VCSModule.');
161
+ }
162
+ return value;
163
+ }
164
+
165
+ export { shQuote, shQuoteJson, usesPowerShellQuoting, escapeForWindowsArgv, curlBinary, assertToken };