@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
@@ -8,14 +8,17 @@
8
8
  * new provider had to also edit.
9
9
  *
10
10
  * No auth-mode axis of its own (a single PAT token field at
11
- * provision_vcs_auth time, same as Bitbucket -- see ./bitbucket.mjs), and no
12
- * REST create-pull-request/comment builders implemented yet -- both are
13
- * DELIBERATELY absent (`builders: null`) rather than guessed at, so
14
- * buildVcsCommand() fails closed with a clear ASCII "ERROR: ... does not yet
15
- * implement action ..." instead of silently building a wrong command.
16
- * Declaring `defaultAuthMode` (even as `null`) is what makes 'azure-devops'
17
- * part of resolveProvider()'s known vocabulary -- see ./index.mjs's
18
- * isAuthBackend().
11
+ * provision_vcs_auth time, same as Bitbucket -- see ./bitbucket.mjs).
12
+ * apra-fleet-lzfv.2 adds the REST create-pull-request/comment builders (see
13
+ * buildAzureDevOpsCreatePrCommand/buildAzureDevOpsCommentCommand below);
14
+ * capabilitiesForHost()'s canOpenPullRequest is now true (apra-fleet-lzfv.5),
15
+ * once runner.js's publish path could actually dispatch them (see that
16
+ * function's doc comment). Any action WITHOUT a builder still fails closed
17
+ * with a clear ASCII
18
+ * "ERROR: ... does not yet implement action ..." from buildVcsCommand()
19
+ * instead of a silently wrong command. Declaring `defaultAuthMode` (even as
20
+ * `null`) is what makes 'azure-devops' part of resolveProvider()'s known
21
+ * vocabulary -- see ./index.mjs's isAuthBackend().
19
22
  *
20
23
  * Extends GenericGitVCS for stderr classification. Azure DevOps' own
21
24
  * TF-numbered error codes (e.g. TF401019) previously were NOT added as a
@@ -37,32 +40,724 @@
37
40
  * with vcs-classify-failure.test.mjs's own AC1 example provider, which models
38
41
  * TF401019 the same way.
39
42
  *
43
+ * apra-fleet-5co8.1.1 adds the host/URL axis: matchesHost(),
44
+ * capabilitiesForHost() and parseRepoRef(). All three are descriptor hooks
45
+ * dispatched from shared code (./index.mjs's resolveVcsProviderForHost(),
46
+ * vcs-module.mjs's capabilities()), so no Azure DevOps conditional leaks into
47
+ * a shared file. capabilitiesForHost() now reports canOpenPullRequest:true
48
+ * (apra-fleet-lzfv.5) -- runner.js's publish path (raiseVcsPrForMember) is
49
+ * provider-aware now, resolving the member's own registered provider instead
50
+ * of hardcoding 'github', so this host can actually reach `builders` above.
51
+ *
52
+ * apra-fleet-5co8.4.1 adds two more additive rules on top of the bare
53
+ * TF401019 AUTH_DENIED rule above (which stays exactly as-is): a REST 401 /
54
+ * TF400813 both mean the PAT itself is expired or revoked (AUTH_EXPIRED --
55
+ * re-minting the token is the fix), while a REST 403 is a missing-scope
56
+ * refusal (AUTH_DENIED -- widening the PAT's scopes is the fix, per
57
+ * skills/fleet/auth-azdevops.md's role/scope table). See the AUTH_EXPIRED /
58
+ * AUTH_DENIED doc comments below for the exact texts and why each is
59
+ * additive only, with no verdict moved for the pre-existing TF401019 case.
60
+ *
61
+ * apra-fleet-5co8.4.2 declares `authRemedy` (see its own doc comment below):
62
+ * an auth-classified failure here can never be fixed by the shared reactive
63
+ * self-heal alone, because a PAT is stored/redeployed, never re-minted --
64
+ * runner.js prints this provider's remedy text via that generic descriptor
65
+ * field rather than a provider-name conditional of its own.
66
+ *
40
67
  * ASCII only.
41
68
  */
42
69
 
43
70
  import { VCS_FAILURE_KINDS as K } from '../errors.mjs';
71
+ import { shQuote, shQuoteJson, curlBinary, assertToken } from './shell-helpers.mjs';
72
+
73
+ /** Credential no longer good -- re-minting a PAT (skills/fleet/auth-azdevops.md
74
+ * "401 Unauthorized -> Create new PAT and re-deploy") is the remedy, so
75
+ * AUTH_EXPIRED, same split GenericGitVCS/GitHubVCS already use for a 401 vs a
76
+ * 403.
77
+ *
78
+ * apra-fleet-5co8.4.1: two independent signals both mean "the PAT itself is
79
+ * expired/revoked", not "wrong scope":
80
+ * - A bare trailing REST status line of '401'. VCSModule's curl builders
81
+ * append `-w '\n%{http_code}'` (see ./github.mjs's identical convention),
82
+ * so a REST call's own stdout ends in a status-code-only line; anchored
83
+ * to end-of-string/line so an inline "401" mentioned mid-sentence (which
84
+ * says nothing about THIS call's own outcome) is never matched.
85
+ * azure-devops.mjs's own REST builders (added apra-fleet-lzfv.2, below)
86
+ * append it too, and classifyFailure() is reachable standalone (see
87
+ * vcs-classify-failure.test.mjs AC1/'providers listed as known but
88
+ * unimplemented ... still classify'), and PAT validation elsewhere in
89
+ * the fleet already shells a curl+`-w '\n%{http_code}'` call against this
90
+ * same REST API (skills/fleet/auth-azdevops.md's own `curl -sf` Test
91
+ * section) whose failure text this rule must classify correctly today.
92
+ * - TF400813, whose text is a generic "resource not available" refusal
93
+ * that Azure DevOps also emits for an expired/revoked PAT (the org-URL
94
+ * misconfiguration case in the troubleshooting table above resolves
95
+ * through the SAME message; re-minting -- which also forces a fresh
96
+ * provision_vcs_auth pass where the org URL is re-checked -- is still the
97
+ * correct first remedy, per the design recorded on the parent
98
+ * apra-fleet-5co8.4 goal). */
99
+ const AUTH_EXPIRED = [
100
+ /(?:^|\n)\s*401\s*$/,
101
+ /TF400813/,
102
+ ];
44
103
 
104
+ /** Identity understood, PAT itself still valid, access refused -- re-minting
105
+ * the SAME credential cannot fix either of these; the remedy is a broader
106
+ * scope (skills/fleet/auth-azdevops.md's role/scope table) or -- for
107
+ * TF401019 specifically -- the repo/permission grant itself. AUTH_DENIED.
108
+ *
109
+ * apra-fleet-5co8.4.1:
110
+ * - A bare trailing REST status line of '403' (skills/fleet/auth-
111
+ * azdevops.md "403 Forbidden -> Create PAT with broader scopes"). Same
112
+ * anchored shape and same rationale as the 401 rule above -- mirrors it
113
+ * exactly, just the denied half of the 401/403 HTTP split.
114
+ * - TF401019 (unchanged from before this task -- see the module doc
115
+ * comment above and vcs-nongithub-auth-selfheal.test.mjs's real-bd
116
+ * end-to-end assertion through withGitSync, which this rule must keep
117
+ * passing verbatim): "does not exist, or you do not have permission" is
118
+ * Azure DevOps' deliberately ambiguous repo-not-found-or-no-access
119
+ * message; re-minting the identical PAT cannot fix either case. */
45
120
  const AUTH_DENIED = [
121
+ /(?:^|\n)\s*403\s*$/,
46
122
  /TF401019/,
47
123
  ];
48
124
 
49
125
  /** Best-effort Azure DevOps TF-numbered error code, purely DIAGNOSTIC: never
50
- * branch on it -- branch on `kind`. */
126
+ * branch on it -- branch on `kind`. Falls back to a bare trailing REST status
127
+ * line (the `-w '\n%{http_code}'` convention -- see ./github.mjs's
128
+ * extractProviderCode for the same fallback), so a REST 401/403 with no
129
+ * TF-numbered code still surfaces its status for diagnostics. */
51
130
  function extractProviderCode(raw) {
52
131
  const text = String(raw == null ? '' : raw);
53
- const match = text.match(/\b(TF\d{6})\b/);
54
- return match ? match[1] : null;
132
+ const tf = text.match(/\b(TF\d{6})\b/);
133
+ if (tf) return tf[1];
134
+ const trailing = text.match(/(?:^|\n)\s*(\d{3})\s*$/);
135
+ return trailing ? trailing[1] : null;
136
+ }
137
+
138
+ /** The three Azure DevOps host forms, ANCHORED (never a substring test -- see
139
+ * the lookalike cases in test/vcs-azure-devops-repo-ref.test.mjs):
140
+ * - dev.azure.com https remotes
141
+ * - ssh.dev.azure.com the v3 ssh remotes
142
+ * - <org>.visualstudio.com the legacy host, plus bare visualstudio.com
143
+ * Contrast GitHubVCS.matchesHost(), which is deliberately a substring test
144
+ * because GitHub Enterprise Server hosts have no fixed domain; Azure DevOps
145
+ * is a hosted-only service with exactly these domains, so anchoring costs
146
+ * nothing and keeps `dev.azure.com.evil.example` from being claimed. */
147
+ const HOST_RE = /^(?:dev\.azure\.com|ssh\.dev\.azure\.com|(?:[a-z0-9-]+\.)*visualstudio\.com)$/i;
148
+
149
+ /** Host-recognition for VCSModule.capabilities() and
150
+ * resolveVcsProviderForHost() (see ./index.mjs). */
151
+ function matchesHost(host) {
152
+ return typeof host === 'string' && HOST_RE.test(host.trim());
153
+ }
154
+
155
+ /** TRUE (apra-fleet-lzfv.5), now that `builders` (apra-fleet-lzfv.2) is
156
+ * reachable through a publish path that actually knows how to dispatch them
157
+ * -- honouring the lockstep rule in ./index.mjs's REQUIRED EXPORT SHAPE: a
158
+ * host never ADVERTISES a pull request it cannot actually deliver. Before
159
+ * this flip, Azure DevOps genuinely could not: runner.js's publish path
160
+ * (raiseVcsPrForMember) called buildCreatePrCommand with a HARDCODED
161
+ * `provider: 'github'` and a two-part 'owner/name' repo, so an Azure DevOps
162
+ * remote reaching it died inside GitHubVCS's assertRepo on the three-part
163
+ * org/project/repo canonical ("invalid repo ... expected \"owner/name\"")
164
+ * instead of building this file's command -- measured, not assumed:
165
+ * test/mock-sprint-azure-devops-vcs-preflight.test.mjs failed 2 of 3 with the
166
+ * flip alone and passed 3 of 3 without it. raiseVcsPrForMember now resolves
167
+ * the member's own registered provider (VCSModule.resolveProvider(), never
168
+ * hardcoded) and reads the provider-owned repoRef/response-mapping
169
+ * descriptors instead of a GitHub literal, which is what makes this flip
170
+ * safe. */
171
+ function capabilitiesForHost(_host) {
172
+ return { canOpenPullRequest: true };
173
+ }
174
+
175
+ /** Percent-decode one path segment; an invalid escape (e.g. a bare '%') is
176
+ * left as-is rather than throwing, because parseRepoRef must never throw. */
177
+ function decodeSegment(segment) {
178
+ try {
179
+ return decodeURIComponent(segment);
180
+ } catch {
181
+ return segment;
182
+ }
183
+ }
184
+
185
+ /** Split `path` into non-empty, percent-decoded segments with any trailing
186
+ * '.git' stripped off the LAST one. */
187
+ function pathSegments(path) {
188
+ const raw = String(path).split('/').filter((part) => part !== '');
189
+ if (raw.length === 0) return raw;
190
+ raw[raw.length - 1] = raw[raw.length - 1].replace(/\.git$/i, '');
191
+ return raw.map(decodeSegment);
192
+ }
193
+
194
+ /** Split a remote URL into { host, path } for BOTH shapes git speaks: a real
195
+ * scheme'd URL (https/ssh, with optional userinfo and port) and the scp-like
196
+ * shorthand `git@host:path` that `new URL()` cannot parse at all. */
197
+ function splitRemote(url) {
198
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(url)) {
199
+ let parsed;
200
+ try {
201
+ parsed = new URL(url);
202
+ } catch {
203
+ return null;
204
+ }
205
+ if (!parsed.hostname) return null;
206
+ return { host: parsed.hostname.toLowerCase(), path: parsed.pathname };
207
+ }
208
+ const scp = /^(?:[^@\s/]+@)?([^:\s/]+):(.*)$/.exec(url);
209
+ if (!scp) return null;
210
+ return { host: scp[1].toLowerCase(), path: `/${scp[2]}` };
211
+ }
212
+
213
+ function makeRef(org, project, repo) {
214
+ if (!org || !project || !repo) return null;
215
+ return {
216
+ org,
217
+ project,
218
+ repo,
219
+ canonical: `${org}/${project}/${repo}`,
220
+ };
221
+ }
222
+
223
+ /**
224
+ * Parse an Azure DevOps git remote URL into its { org, project, repo,
225
+ * canonical } coordinates -- the identity every Azure DevOps REST call needs
226
+ * (https://dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/...).
227
+ *
228
+ * Recognized shapes:
229
+ * https://[user@]dev.azure.com/ORG/PROJECT/_git/REPO[.git][/]
230
+ * https://[user@]dev.azure.com/ORG/_git/REPO (project == repo)
231
+ * git@ssh.dev.azure.com:v3/ORG/PROJECT/REPO[.git]
232
+ * ssh://git@ssh.dev.azure.com[:22]/v3/ORG/PROJECT/REPO[.git]
233
+ * https://ORG.visualstudio.com/[DefaultCollection/]PROJECT/_git/REPO[.git]
234
+ * https://ORG.visualstudio.com/_git/REPO (project == repo)
235
+ *
236
+ * The project-omitted shorthand is how Azure DevOps itself renders a repo
237
+ * whose name equals its project's, so taking the repo name as the project is
238
+ * the correct expansion, not a guess.
239
+ *
240
+ * Percent-encoded project names (the common case -- Azure DevOps allows
241
+ * spaces in project names) are decoded in EVERY returned field, so `canonical`
242
+ * is a display/identity key, not a URL fragment: re-encode per segment before
243
+ * building a request URL from it.
244
+ *
245
+ * NEVER throws and NEVER partially guesses: anything that is not one of the
246
+ * shapes above -- including a non-Azure host and a lookalike like
247
+ * `dev.azure.com.evil.example` -- returns null, so the caller can raise its
248
+ * own typed ERROR naming the expected shape (apra-fleet-5co8.1.2) instead of
249
+ * proceeding with half-parsed coordinates.
250
+ *
251
+ * @param {unknown} remoteUrl
252
+ * @returns {{ org: string, project: string, repo: string, canonical: string }|null}
253
+ */
254
+ function parseRepoRef(remoteUrl) {
255
+ if (typeof remoteUrl !== 'string') return null;
256
+ const url = remoteUrl.trim();
257
+ if (!url) return null;
258
+
259
+ const split = splitRemote(url);
260
+ if (!split || !matchesHost(split.host)) return null;
261
+
262
+ const segments = pathSegments(split.path);
263
+ if (segments.length === 0) return null;
264
+
265
+ // ssh v3 form: exactly v3/ORG/PROJECT/REPO -- no _git marker, no
266
+ // project-omitted shorthand (Azure DevOps always emits all three).
267
+ if (segments[0].toLowerCase() === 'v3') {
268
+ if (segments.length !== 4) return null;
269
+ return makeRef(segments[1], segments[2], segments[3]);
270
+ }
271
+
272
+ // https forms: the '_git' marker separates the org/project prefix from
273
+ // the single repo segment. Requiring the marker to be second-from-last is
274
+ // what rejects both a missing repo and any extra trailing segment.
275
+ const marker = segments.indexOf('_git');
276
+ if (marker === -1 || marker !== segments.length - 2) return null;
277
+ const repo = segments[segments.length - 1];
278
+ let prefix = segments.slice(0, marker);
279
+
280
+ const legacy = /visualstudio\.com$/i.test(split.host);
281
+ if (legacy) {
282
+ // Legacy host: the org is the HOSTNAME label, not a path segment, and
283
+ // an explicit collection segment (historically 'DefaultCollection')
284
+ // may precede the project.
285
+ const org = split.host.split('.')[0];
286
+ if (!org || org.toLowerCase() === 'visualstudio') return null;
287
+ if (prefix.length > 0 && prefix[0].toLowerCase() === 'defaultcollection') prefix = prefix.slice(1);
288
+ if (prefix.length > 1) return null;
289
+ return makeRef(org, prefix[0] || repo, repo);
290
+ }
291
+
292
+ if (prefix.length < 1 || prefix.length > 2) return null;
293
+ return makeRef(prefix[0], prefix[1] || repo, repo);
294
+ }
295
+
296
+ /** The documented default credential-store entry holding an Azure DevOps PAT
297
+ * (skills/fleet/auth-azdevops.md, "Storing tokens for reuse":
298
+ * `credential_store_set name=azdevops_pat`).
299
+ * A per-sprint override is passed via runner.js args and threaded
300
+ * through buildProvisionArgs (apra-fleet-5co8.2.3); when unset, this
301
+ * default is used. */
302
+ const DEFAULT_PAT_SECRET = 'azdevops_pat';
303
+
304
+ /** The remote shapes parseRepoRef() expects, quoted into every
305
+ * operator-facing remedy this module produces (see `repoRefHint` below):
306
+ * the modern host an operator copies out of the "Clone" dialog and the
307
+ * legacy per-org host older projects still live on. */
308
+ const REPO_REF_HINT = 'https://dev.azure.com/ORG/PROJECT/_git/REPO or https://ORG.visualstudio.com/[DefaultCollection/]PROJECT/_git/REPO';
309
+
310
+ /** Classify a remote URL parseRepoRef() accepts by the HOST it lands on:
311
+ * which transport git will use (a PAT only applies to https; ssh uses the
312
+ * member's key) and whether it is the legacy `<org>.visualstudio.com` host,
313
+ * which needs the credential bound to that host rather than dev.azure.com.
314
+ * Returns null for anything parseRepoRef() rejects. */
315
+ function classifyRemote(remoteUrl) {
316
+ if (typeof remoteUrl !== 'string' || !remoteUrl.trim()) return null;
317
+ const split = splitRemote(remoteUrl.trim());
318
+ if (!split || !matchesHost(split.host)) return null;
319
+ const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(remoteUrl.trim())
320
+ ? remoteUrl.trim().replace(/:\/\/.*$/, '').toLowerCase()
321
+ : 'ssh';
322
+ const transport = scheme === 'ssh' ? 'ssh' : 'https';
323
+ const legacy = /visualstudio\.com$/i.test(split.host);
324
+ const sshHost = /^(?:ssh\.dev\.azure\.com|vs-ssh\.visualstudio\.com)$/i.test(split.host);
325
+ return { host: split.host, transport, legacy, legacyHttpsHost: legacy && !sshHost && transport === 'https' };
55
326
  }
56
327
 
328
+ /**
329
+ * Build the provision_vcs_auth argument object for an Azure DevOps member
330
+ * (apra-fleet-5co8.2.1).
331
+ *
332
+ * WHY A HOOK: the shared argument shape (`git_access` + a `repos` allowlist)
333
+ * is GitHub-App vocabulary. Azure DevOps has no App/installation model at all
334
+ * -- a PAT is minted by a human against an ORG, so what provision_vcs_auth
335
+ * needs here is `org_url` plus the token, and `git_access`/`repos` are
336
+ * meaningless. Expressing that as a descriptor hook keeps the difference in
337
+ * this file instead of adding a provider branch to the shared caller.
338
+ *
339
+ * SECRET TRANSPORT: the PAT is passed as a `{{secret.NAME}}` PLACEHOLDER, never
340
+ * a value. Resolution happens hub-side inside the fleet server; the orchestrator
341
+ * process that calls this hook never holds, logs or transports the plaintext,
342
+ * and a remote member (which has no secret store of its own) never has to.
343
+ * That is also why a missing store entry is a TYPED ERROR rather than a prompt:
344
+ * an unattended preflight/self-heal has no operator attached, and an
345
+ * out-of-band prompt there would stall the sprint instead of failing it.
346
+ *
347
+ * HOST BINDING: the server binds the PAT's git credential helper to the host
348
+ * named by `scope_url` (default dev.azure.com). git looks credentials up by
349
+ * the remote's OWN hostname, so a member whose remote is on the legacy
350
+ * `<org>.visualstudio.com` host gets `scope_url` set to that host here;
351
+ * otherwise the argument is omitted and the server default applies, which
352
+ * keeps the modern-host call byte-identical to what it was. An ssh remote
353
+ * cannot take a PAT at all: the PAT is still deployed (the REST
354
+ * pull-request call reads it), and `note` says that git push relies on the
355
+ * member's SSH key instead.
356
+ *
357
+ * @param {{ base: object, repoRef: ({ org: string }|null|undefined),
358
+ * availableSecrets: string[]|null, secretName?: string,
359
+ * remoteUrl?: string, remoteReadError?: string|null }} ctx
360
+ * `base` is the shared argument object the caller would otherwise send;
361
+ * `repoRef` is this provider's own parseRepoRef() output for the member's
362
+ * remote; `availableSecrets` is the credential-store entry names the caller
363
+ * observed (null when it could not be read -- then the check is skipped
364
+ * rather than guessed, and a genuinely missing secret still fails loudly
365
+ * server-side). `remoteUrl` is the raw remote the caller read (used only to
366
+ * pick the credential host and to word the error precisely) and
367
+ * `remoteReadError` the reason it could not be read, when that is why
368
+ * `repoRef` is null -- a read failure is NOT a malformed remote and the
369
+ * error must not tell the operator to fix their URL.
370
+ * @returns {{ args: object, note?: string }|{ error: string }}
371
+ */
372
+ function buildProvisionArgs(ctx) {
373
+ const { base = {}, repoRef, availableSecrets, secretName, remoteUrl, remoteReadError } = ctx || {};
374
+ const org = repoRef && typeof repoRef.org === 'string' ? repoRef.org.trim() : '';
375
+ if (!org) {
376
+ const raw = typeof remoteUrl === 'string' ? remoteUrl.trim() : '';
377
+ const why = remoteReadError
378
+ ? `the member's git remote could not be read (${remoteReadError})`
379
+ : raw
380
+ ? `the member's git remote '${raw}' is not a recognized Azure DevOps repository URL`
381
+ : `no organization could be derived from the member's git remote`;
382
+ return {
383
+ error: `ERROR: cannot provision Azure DevOps auth for member '${base.member_name}': ${why}; expected a remote of the shape ${REPO_REF_HINT}`,
384
+ };
385
+ }
386
+
387
+ const name = (typeof secretName === 'string' && secretName.trim()) ? secretName.trim() : DEFAULT_PAT_SECRET;
388
+ if (Array.isArray(availableSecrets) && !availableSecrets.includes(name)) {
389
+ return {
390
+ error: `ERROR: cannot provision Azure DevOps auth for member '${base.member_name}': the credential store has no entry named '${name}'. Store the PAT first with: credential_store_set name=${name}`,
391
+ };
392
+ }
393
+
394
+ const shape = classifyRemote(remoteUrl);
395
+ const args = {
396
+ member_name: base.member_name,
397
+ provider: base.provider,
398
+ // Base org URL with no trailing path -- see auth-azdevops.md's
399
+ // "Org URL must be base URL without trailing path" note and the
400
+ // TF400813 troubleshooting row, which is what a wrong org URL
401
+ // surfaces as. Always the MODERN host: the REST API serves every
402
+ // org there, legacy-hosted or not.
403
+ org_url: `https://dev.azure.com/${org}`,
404
+ // Placeholder, NOT a value. See SECRET TRANSPORT above.
405
+ pat: `{{secret.${name}}}`,
406
+ };
407
+ if (shape && shape.legacyHttpsHost) {
408
+ // See HOST BINDING above: bind the credential helper to the legacy
409
+ // host the member actually pushes to.
410
+ args.scope_url = `https://${shape.host}`;
411
+ }
412
+ const note = shape && shape.transport === 'ssh'
413
+ ? `member '${base.member_name}' pushes over ssh (${shape.host}); the Azure DevOps PAT is deployed for REST pull-request calls only and git push authenticates with the member's own SSH key, which the fleet does not manage`
414
+ : undefined;
415
+ return note ? { args, note } : { args };
416
+ }
417
+
418
+ // ---------------------------------------------------------------------------
419
+ // REST command builders (apra-fleet-lzfv.2)
420
+ // ---------------------------------------------------------------------------
421
+ //
422
+ // PARAMETER CONTRACT (the shape buildVcsCommand() hands a builder, and what
423
+ // apra-fleet-lzfv.3's golden tests and apra-fleet-lzfv.4's response mapping
424
+ // read as this provider's contract):
425
+ //
426
+ // provider 'azure-devops'
427
+ // repoRef OPTIONAL { org, project, repo } -- parseRepoRef()'s own output,
428
+ // passed straight through. Individual org/project/repo params
429
+ // take PRECEDENCE over the matching repoRef field, so a caller can
430
+ // override one coordinate without rebuilding the object.
431
+ // org/project/repo the three coordinates every Azure DevOps REST call
432
+ // needs. All three are required after the repoRef merge; a missing
433
+ // one is a typed ERROR naming the expected remote shape, never a
434
+ // half-built URL.
435
+ // base/head branch names, in GitHub's OWN vocabulary deliberately (`base` =
436
+ // the branch merged INTO -> targetRefName, `head` = the branch
437
+ // merged FROM -> sourceRefName). Keeping github.mjs's field names
438
+ // is what lets runner.js stay provider-agnostic -- see
439
+ // ./index.mjs's "NO OTHER FILE under fleet-sprint/ changes".
440
+ // title/body PR title and description.
441
+ // pull_request_id (comment only) the PR to annotate.
442
+ // token the PAT. REQUIRED -- assertToken() throws the shared typed ERROR.
443
+ // os resolveMemberOs()'s value ('windows'/'linux'/'darwin'). Selects
444
+ // the curl BINARY token via curlBinary() (curl.exe on Windows,
445
+ // which stays OS-keyed because curl.exe is equally resolvable from
446
+ // PowerShell and from Git-for-Windows bash), and is the fallback
447
+ // input to the quoting dialect when `shell` is unresolved.
448
+ // shell the member's registered COMMAND SHELL as resolved by runner.js's
449
+ // resolveMemberTarget() -- 'gitbash' | 'pwsh7' | 'powershell5' |
450
+ // '' -- and the primary input to shQuote()'s quoting DIALECT:
451
+ // gitbash -> POSIX even on Windows, pwsh7/powershell5 -> PowerShell
452
+ // doubling, unresolved + windows -> PowerShell doubling (the
453
+ // historical fallback, byte-identical). Distinct from `os`: a
454
+ // Windows member running gitbash needs curl.exe with POSIX quoting.
455
+ //
456
+ // AUTH: Azure DevOps' REST API takes a PAT as HTTP Basic with an EMPTY
457
+ // username (`-u :PAT`), NOT a bearer token -- the exact form skills/fleet/
458
+ // auth-azdevops.md already documents for its connectivity Test call. The PAT
459
+ // therefore appears in `command` ONLY; `logSafeCommand` is built by the same
460
+ // closure with REDACTED substituted, so no field other than `command` can
461
+ // carry it.
462
+ //
463
+ // URL ENCODING: parseRepoRef() percent-DECODES every field it returns (Azure
464
+ // DevOps project names commonly contain spaces), so each coordinate is
465
+ // re-encoded per segment here -- see parseRepoRef's own doc note.
466
+
467
+ /** api-version pinned to 7.1, matching skills/fleet/auth-azdevops.md's own
468
+ * REST calls. Pinned, never floating: an unversioned Azure DevOps REST call
469
+ * is rejected outright. */
470
+ const API_VERSION = '7.1';
471
+
472
+ /** Same fixed marker github.mjs uses, so a log scrubber/assertion looking for
473
+ * a redacted VCS command matches identically across providers. */
474
+ const REDACTED = '***REDACTED***';
475
+
476
+ /** Merge a `repoRef` object with any explicit org/project/repo overrides and
477
+ * require all three. Throws the typed ERROR (quoting REPO_REF_HINT, the same
478
+ * remedy text repoRefHint publishes) rather than building a partial URL.
479
+ *
480
+ * apra-fleet-5co8.11: an explicit param takes precedence over the matching
481
+ * repoRef field (see the PARAMETER CONTRACT doc block above), but a caller
482
+ * can hand this a three-part canonical (parseRepoRef()'s own
483
+ * `org/project/repo` string, or github.mjs's two-part `owner/name`) as a
484
+ * SINGLE coordinate -- most plausibly `repo` -- instead of splitting it
485
+ * first. repoApiBase() would then percent-encode the whole slash-bearing
486
+ * string into one URL segment, building a silently wrong URL (a 404 at
487
+ * request time) rather than failing at build time. Reject a '/' inside
488
+ * `org` or `repo` with the same typed ERROR raised for a missing
489
+ * coordinate, so the mistake surfaces immediately instead of round-tripping
490
+ * through a live REST call first. `project` is EXCLUDED from this check: an
491
+ * Azure DevOps project name is decoded free-form by parseRepoRef() and a
492
+ * literal '/' inside it is a legitimate value re-encoded per segment by
493
+ * repoApiBase() below (pinned by "each coordinate is percent-encoded per URL
494
+ * segment" in vcs-azure-devops-builders.test.mjs), not a coordinate-mixing
495
+ * mistake -- org and repo, by contrast, are never expected to contain one. */
496
+ function assertRepoCoords(params, action) {
497
+ const ref = (params && typeof params.repoRef === 'object' && params.repoRef) ? params.repoRef : {};
498
+ const pick = (key) => {
499
+ const own = params && params[key] != null ? params[key] : ref[key];
500
+ return String(own ?? '').trim();
501
+ };
502
+ const org = pick('org');
503
+ const project = pick('project');
504
+ const repo = pick('repo');
505
+ const missing = [['org', org], ['project', project], ['repo', repo]].filter(([, v]) => !v).map(([k]) => k);
506
+ if (missing.length > 0) {
507
+ throw new Error(`ERROR: VCSModule: azure-devops "${action}" needs org, project and repo (missing: ${missing.join(', ')}) -- pass them explicitly or as the repoRef parsed from a remote of the shape ${REPO_REF_HINT}.`);
508
+ }
509
+ const slashed = [['org', org], ['repo', repo]].filter(([, v]) => v.includes('/'));
510
+ if (slashed.length > 0) {
511
+ throw new Error(`ERROR: VCSModule: azure-devops "${action}" got a '/' inside ${slashed.map(([k]) => k).join(', ')} -- pass the three org/project/repo coordinates SEPARATELY, not a combined "org/project/repo" string, per the remote shape ${REPO_REF_HINT}.`);
512
+ }
513
+ return { org, project, repo };
514
+ }
515
+
516
+ /** The org/project/repo REST prefix, each coordinate re-encoded per segment. */
517
+ function repoApiBase({ org, project, repo }) {
518
+ return `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_apis/git/repositories/${encodeURIComponent(repo)}`;
519
+ }
520
+
521
+ /** Azure DevOps' pullrequests endpoint takes FULL ref names
522
+ * ('refs/heads/main'), not the bare branch names GitHub's API takes, and
523
+ * rejects a bare name outright. An input that already carries a 'refs/'
524
+ * prefix is passed through untouched so a caller holding a real ref (e.g.
525
+ * 'refs/heads/feat/x') is never double-prefixed. */
526
+ function toFullRef(branch) {
527
+ const value = String(branch).trim();
528
+ return /^refs\//i.test(value) ? value : `refs/heads/${value}`;
529
+ }
530
+
531
+ /**
532
+ * Build the Azure DevOps REST "create pull request" curl command.
533
+ * POST {org}/{project}/_apis/git/repositories/{repo}/pullrequests?api-version=7.1
534
+ * -- see https://learn.microsoft.com/rest/api/azure/devops/git/pull-requests/create
535
+ */
536
+ function buildAzureDevOpsCreatePrCommand(params) {
537
+ const { base, head, title, body, token, os, shell } = params || {};
538
+ const coords = assertRepoCoords(params, 'create-pull-request');
539
+ const safeToken = assertToken(token);
540
+ if (!base) throw new Error('ERROR: VCSModule: "base" branch is required to build a create-pull-request command.');
541
+ if (!head) throw new Error('ERROR: VCSModule: "head" branch is required to build a create-pull-request command.');
542
+ if (!title) throw new Error('ERROR: VCSModule: "title" is required to build a create-pull-request command.');
543
+
544
+ const payload = {
545
+ sourceRefName: toFullRef(head),
546
+ targetRefName: toFullRef(base),
547
+ title,
548
+ };
549
+ if (body !== undefined) payload.description = body;
550
+ const payloadJson = JSON.stringify(payload);
551
+ const url = `${repoApiBase(coords)}/pullrequests?api-version=${API_VERSION}`;
552
+
553
+ const buildCurl = (authToken) => [
554
+ `${curlBinary(os)} -sS -X POST`,
555
+ `-u ${shQuote(`:${authToken}`, os, shell)}`,
556
+ `-H ${shQuote('Content-Type: application/json', os, shell)}`,
557
+ `-H ${shQuote('Accept: application/json', os, shell)}`,
558
+ `-d ${shQuoteJson(payloadJson, os, shell)}`,
559
+ `-w ${shQuote('\n%{http_code}', os, shell)}`,
560
+ url,
561
+ ].join(' ');
562
+
563
+ return {
564
+ provider: 'azure-devops',
565
+ action: 'create-pull-request',
566
+ command: buildCurl(safeToken),
567
+ logSafeCommand: buildCurl(REDACTED),
568
+ // Interpretation contract, same field NAMES github.mjs uses so a
569
+ // consumer reads it generically:
570
+ // - 2xx -> success; body has .pullRequestId
571
+ // - 409 + TF401179 -> an active PR for this source/target
572
+ // pair already exists, which is the
573
+ // idempotent re-run case, so success
574
+ // - anything else -> error
575
+ interpret: {
576
+ successStatusRange: [200, 299],
577
+ alreadyExistsStatus: 409,
578
+ alreadyExistsPattern: 'TF401179',
579
+ },
580
+ };
581
+ }
582
+
583
+ /**
584
+ * Build the Azure DevOps REST "comment on a pull request" curl command, used
585
+ * to annotate an existing PR when a sprint aborts after the PR was already
586
+ * raised (rather than opening a second PR for the same source branch).
587
+ * POST .../pullrequests/{id}/threads?api-version=7.1 -- Azure DevOps has no
588
+ * bare "PR comment" resource: a comment is one entry in a THREAD, so a single
589
+ * text comment is posted as a new active thread carrying exactly one comment.
590
+ * See https://learn.microsoft.com/rest/api/azure/devops/git/pull-request-threads/create
591
+ */
592
+ function buildAzureDevOpsCommentCommand(params) {
593
+ const { pull_request_id: pullRequestId, body, token, os, shell } = params || {};
594
+ const coords = assertRepoCoords(params, 'comment');
595
+ const safeToken = assertToken(token);
596
+ if (!pullRequestId) throw new Error('ERROR: VCSModule: "pull_request_id" is required to build an azure-devops comment command.');
597
+ if (!body) throw new Error('ERROR: VCSModule: "body" is required to build a comment command.');
598
+
599
+ const payloadJson = JSON.stringify({
600
+ comments: [{ parentCommentId: 0, content: body, commentType: 'text' }],
601
+ status: 'active',
602
+ });
603
+ const url = `${repoApiBase(coords)}/pullrequests/${encodeURIComponent(String(pullRequestId))}/threads?api-version=${API_VERSION}`;
604
+
605
+ const buildCurl = (authToken) => [
606
+ `${curlBinary(os)} -sS -X POST`,
607
+ `-u ${shQuote(`:${authToken}`, os, shell)}`,
608
+ `-H ${shQuote('Content-Type: application/json', os, shell)}`,
609
+ `-H ${shQuote('Accept: application/json', os, shell)}`,
610
+ `-d ${shQuoteJson(payloadJson, os, shell)}`,
611
+ `-w ${shQuote('\n%{http_code}', os, shell)}`,
612
+ url,
613
+ ].join(' ');
614
+
615
+ return {
616
+ provider: 'azure-devops',
617
+ action: 'comment',
618
+ command: buildCurl(safeToken),
619
+ logSafeCommand: buildCurl(REDACTED),
620
+ interpret: {
621
+ successStatusRange: [200, 299],
622
+ },
623
+ };
624
+ }
625
+
626
+ // ---------------------------------------------------------------------------
627
+ // Pull-request RESPONSE mapping (apra-fleet-lzfv.4)
628
+ // ---------------------------------------------------------------------------
629
+ //
630
+ // Azure DevOps' create-pull-request 2xx body speaks a DIFFERENT dialect than
631
+ // GitHub's: the identifier is `pullRequestId` (not `number`), and the body
632
+ // carries NO browsable web URL at all -- its `url` field is the REST resource
633
+ // (.../_apis/git/repositories/{id}/pullRequests/{id}), which is not a page an
634
+ // operator can open. The browsable URL therefore has to be CONSTRUCTED from
635
+ // the same org/project/repo coordinates the request was built from plus the
636
+ // returned id. Declaring both here (rather than teaching the caller either
637
+ // dialect) is the whole point of the contract -- see ./index.mjs and
638
+ // ./github.mjs's mirror-image declaration.
639
+
640
+ const PR_ID_FIELD = 'pullRequestId';
641
+
642
+ /** The browsable pull request page Azure DevOps renders for a PR -- the shape
643
+ * the web UI itself uses:
644
+ * https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}
645
+ * (the same org/project/_git/repo prefix as the clone URL REPO_REF_HINT
646
+ * quotes). Published as a template string so a consumer that must mirror this
647
+ * contract elsewhere (canonical VCS types / fleet client) can restate it
648
+ * without re-deriving it. */
649
+ const PR_WEB_URL_TEMPLATE = 'https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}';
650
+
651
+ /** Soft coordinate pick for the response mapping: unlike assertRepoCoords()
652
+ * (which is building a request URL and MUST fail loudly), a response mapping
653
+ * never throws -- a missing coordinate simply yields `url: null`, so a caller
654
+ * reporting an otherwise successful PR is never turned into a crash. */
655
+ function softRepoCoords(ctx) {
656
+ const source = (ctx && typeof ctx === 'object') ? ctx : {};
657
+ const ref = (source.repoRef && typeof source.repoRef === 'object') ? source.repoRef : {};
658
+ const pick = (key) => String((source[key] != null ? source[key] : ref[key]) ?? '').trim();
659
+ return { org: pick('org'), project: pick('project'), repo: pick('repo') };
660
+ }
661
+
662
+ /** Map an Azure DevOps create-pull-request response body to { id, url }.
663
+ * Reads the DECLARED id field above, and builds the web URL from `ctx`'s
664
+ * org/project/repo (each segment re-encoded, same reason repoApiBase() does).
665
+ * `ctx` accepts either explicit org/project/repo or a `repoRef` object -- the
666
+ * same shape the builders take. */
667
+ function mapPullRequestResponse(body, ctx) {
668
+ const source = (body && typeof body === 'object') ? body : {};
669
+ const rawId = source[PR_ID_FIELD];
670
+ let id = null;
671
+ if (typeof rawId === 'number' && Number.isFinite(rawId)) id = rawId;
672
+ else if (typeof rawId === 'string' && /^\d+$/.test(rawId.trim())) id = Number(rawId.trim());
673
+ if (id === null) return { id: null, url: null };
674
+
675
+ const { org, project, repo } = softRepoCoords(ctx);
676
+ if (!org || !project || !repo) return { id, url: null };
677
+ const url = `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}/pullrequest/${encodeURIComponent(String(id))}`;
678
+ return { id, url };
679
+ }
680
+
681
+ const pullRequestResponse = Object.freeze({
682
+ idField: PR_ID_FIELD,
683
+ // No web-URL field exists in the body -- it is constructed, see above.
684
+ webUrlField: null,
685
+ webUrlTemplate: PR_WEB_URL_TEMPLATE,
686
+ map: mapPullRequestResponse,
687
+ });
688
+
689
+ // ---------------------------------------------------------------------------
690
+ // Auth self-heal remedy (apra-fleet-5co8.4.2)
691
+ // ---------------------------------------------------------------------------
692
+ //
693
+ // Unlike a GitHub App installation token (minted fresh, server-side, on every
694
+ // provision_vcs_auth call), an Azure DevOps PAT is a long-lived secret the
695
+ // fleet only ever STORES and REDEPLOYS -- it never mints one. The Azure
696
+ // DevOps PAT lifecycle management API requires an Entra (Azure AD) OAuth
697
+ // token with admin consent the fleet does not hold (skills/fleet/
698
+ // auth-azdevops.md's "PAT Lifetime and Expiry" section). So when the
699
+ // REACTIVE self-heal (runner.js's createVcsAuthSelfHealCallback) fires on an
700
+ // auth-classified failure, calling provision_vcs_auth again just redeploys
701
+ // the SAME dead secret and is expected to fail again -- serverSideReMintable
702
+ // is false, and `hint` is the exact operator-facing remedy runner.js prints
703
+ // alongside the (still-attempted, still-logged) self-heal call, covering
704
+ // both AUTH_EXPIRED (401/TF400813 -- the PAT itself is dead) and AUTH_DENIED
705
+ // (403 -- the PAT is valid but scoped too narrowly; TF401019 is a
706
+ // repo/permission grant, not a scope, and has no PAT-rotation remedy) since
707
+ // the self-heal callback is never told which kind fired -- see
708
+ // ./index.mjs's authRemedy doc.
709
+ const AUTH_REMEDY_HINT =
710
+ 'Azure DevOps PATs cannot be re-minted server-side. If the PAT expired or ' +
711
+ 'was revoked: create a new PAT at https://dev.azure.com/ORG/_settings/tokens, ' +
712
+ 'then credential_store_set the fleet secret and re-run provision_vcs_auth. ' +
713
+ 'If access was denied for insufficient scope: create a PAT with broader ' +
714
+ 'scopes per the role/scope table in skills/fleet/auth-azdevops.md, then ' +
715
+ 'credential_store_set the fleet secret and re-run provision_vcs_auth.';
716
+
717
+ const authRemedy = Object.freeze({
718
+ serverSideReMintable: false,
719
+ hint: AUTH_REMEDY_HINT,
720
+ });
721
+
57
722
  export const AzureDevOpsVCS = Object.freeze({
58
723
  name: 'azure-devops',
59
724
  extends: 'generic-git',
60
725
  rules: Object.freeze({
726
+ [K.AUTH_EXPIRED]: AUTH_EXPIRED,
61
727
  [K.AUTH_DENIED]: AUTH_DENIED,
62
728
  }),
63
729
  extractProviderCode,
730
+ matchesHost,
731
+ capabilitiesForHost,
732
+ // apra-fleet-5co8.1.1: remote-URL -> { org, project, repo, canonical }.
733
+ // An OPTIONAL descriptor hook (see ./index.mjs's REQUIRED EXPORT SHAPE):
734
+ // only providers whose REST identity is not the portable "owner/name"
735
+ // pair need it, which is why it lives here rather than in shared code.
736
+ parseRepoRef,
737
+ // apra-fleet-5co8.1.2: the remedy text for a remote this provider claims
738
+ // but parseRepoRef() rejects. Lives here, not in the caller, so runner.js
739
+ // can raise a provider-specific preflight ERROR with no Azure DevOps
740
+ // literal (or conditional) of its own. The canonical https shape is the
741
+ // one an operator copies out of the Azure DevOps "Clone" dialog; the ssh
742
+ // and legacy visualstudio.com shapes parseRepoRef also accepts are
743
+ // deliberately NOT listed, to keep the remedy a single copyable form.
744
+ repoRefHint: REPO_REF_HINT,
745
+ // apra-fleet-5co8.2.1: OPTIONAL descriptor hook -- see ./index.mjs.
746
+ buildProvisionArgs,
64
747
  defaultAuthMode: null,
65
- builders: null,
748
+ // apra-fleet-lzfv.4: this provider's create-pull-request response dialect
749
+ // (pullRequestId + a CONSTRUCTED web URL) -- see above.
750
+ pullRequestResponse,
751
+ // apra-fleet-5co8.4.2: PATs are never re-minted server-side -- see above.
752
+ authRemedy,
753
+ // apra-fleet-lzfv.2: the REST builders. capabilitiesForHost() above now
754
+ // reports canOpenPullRequest:true (apra-fleet-lzfv.5) -- the publish path
755
+ // can dispatch them. Any action not listed here still fails closed with
756
+ // buildVcsCommand()'s typed ERROR.
757
+ builders: Object.freeze({
758
+ 'create-pull-request': buildAzureDevOpsCreatePrCommand,
759
+ comment: buildAzureDevOpsCommentCommand,
760
+ }),
66
761
  });
67
762
 
68
763
  export default AzureDevOpsVCS;