@apralabs/apra-fleet 0.4.0 → 0.4.2

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 (548) hide show
  1. package/README.md +159 -13
  2. package/dist/agents/backlog-groomer.md +31 -19
  3. package/dist/agents/ci-watcher.md +16 -1
  4. package/dist/agents/deployer.md +37 -47
  5. package/dist/agents/doer.md +147 -114
  6. package/dist/agents/harvester.md +41 -34
  7. package/dist/agents/integ-test-runner.md +98 -114
  8. package/dist/agents/kb-reconciler.md +205 -0
  9. package/dist/agents/plan-reviewer.md +45 -44
  10. package/dist/agents/planner.md +121 -50
  11. package/dist/agents/regression-test-runner.md +84 -81
  12. package/dist/agents/reviewer.md +118 -44
  13. package/dist/agents/schemas/doer-output.json +63 -3
  14. package/dist/agents/schemas/harvester-output.json +59 -2
  15. package/dist/agents/schemas/integ-test-runner-output.json +3 -3
  16. package/dist/agents/schemas/kb-reconciler-output.json +87 -0
  17. package/dist/agents/schemas/planner-output.json +65 -0
  18. package/dist/agents/schemas/regression-test-runner-output.json +4 -17
  19. package/dist/agents/schemas/reviewer-output.json +105 -8
  20. package/dist/cli/auth.d.ts.map +1 -1
  21. package/dist/cli/auth.js +1 -2
  22. package/dist/cli/auth.js.map +1 -1
  23. package/dist/cli/config.d.ts +3 -3
  24. package/dist/cli/config.d.ts.map +1 -1
  25. package/dist/cli/config.js +4 -13
  26. package/dist/cli/config.js.map +1 -1
  27. package/dist/cli/install.d.ts +1 -0
  28. package/dist/cli/install.d.ts.map +1 -1
  29. package/dist/cli/install.js +141 -44
  30. package/dist/cli/install.js.map +1 -1
  31. package/dist/cli/join.js +1 -1
  32. package/dist/cli/join.js.map +1 -1
  33. package/dist/cli/kb-commit.d.ts +12 -0
  34. package/dist/cli/kb-commit.d.ts.map +1 -0
  35. package/dist/cli/kb-commit.js +53 -0
  36. package/dist/cli/kb-commit.js.map +1 -0
  37. package/dist/cli/kb-directives.d.ts +17 -0
  38. package/dist/cli/kb-directives.d.ts.map +1 -0
  39. package/dist/cli/kb-directives.js +146 -0
  40. package/dist/cli/kb-directives.js.map +1 -0
  41. package/dist/cli/kb-import.d.ts +13 -0
  42. package/dist/cli/kb-import.d.ts.map +1 -0
  43. package/dist/cli/kb-import.js +56 -0
  44. package/dist/cli/kb-import.js.map +1 -0
  45. package/dist/cli/register-member.js +1 -1
  46. package/dist/cli/start.d.ts.map +1 -1
  47. package/dist/cli/start.js +7 -0
  48. package/dist/cli/start.js.map +1 -1
  49. package/dist/cli/uninstall.d.ts.map +1 -1
  50. package/dist/cli/uninstall.js +16 -3
  51. package/dist/cli/uninstall.js.map +1 -1
  52. package/dist/cli/watch.d.ts +76 -4
  53. package/dist/cli/watch.d.ts.map +1 -1
  54. package/dist/cli/watch.js +150 -17
  55. package/dist/cli/watch.js.map +1 -1
  56. package/dist/commands/kb-server.d.ts +8 -0
  57. package/dist/commands/kb-server.d.ts.map +1 -0
  58. package/dist/commands/kb-server.js +221 -0
  59. package/dist/commands/kb-server.js.map +1 -0
  60. package/dist/index.js +77 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/os/git-bash-candidates.d.ts +35 -0
  63. package/dist/os/git-bash-candidates.d.ts.map +1 -0
  64. package/dist/os/git-bash-candidates.js +46 -0
  65. package/dist/os/git-bash-candidates.js.map +1 -0
  66. package/dist/os/index.d.ts +13 -4
  67. package/dist/os/index.d.ts.map +1 -1
  68. package/dist/os/index.js +17 -2
  69. package/dist/os/index.js.map +1 -1
  70. package/dist/os/linux.d.ts +1 -0
  71. package/dist/os/linux.d.ts.map +1 -1
  72. package/dist/os/linux.js +19 -2
  73. package/dist/os/linux.js.map +1 -1
  74. package/dist/os/os-commands.d.ts +12 -0
  75. package/dist/os/os-commands.d.ts.map +1 -1
  76. package/dist/os/os-commands.js.map +1 -1
  77. package/dist/os/windows-gitbash.d.ts +93 -0
  78. package/dist/os/windows-gitbash.d.ts.map +1 -0
  79. package/dist/os/windows-gitbash.js +244 -0
  80. package/dist/os/windows-gitbash.js.map +1 -0
  81. package/dist/os/windows.d.ts +35 -0
  82. package/dist/os/windows.d.ts.map +1 -1
  83. package/dist/os/windows.js +93 -35
  84. package/dist/os/windows.js.map +1 -1
  85. package/dist/providers/agy.d.ts +15 -3
  86. package/dist/providers/agy.d.ts.map +1 -1
  87. package/dist/providers/agy.js +145 -11
  88. package/dist/providers/agy.js.map +1 -1
  89. package/dist/providers/claude.d.ts +14 -3
  90. package/dist/providers/claude.d.ts.map +1 -1
  91. package/dist/providers/claude.js +69 -22
  92. package/dist/providers/claude.js.map +1 -1
  93. package/dist/providers/codex.d.ts +14 -3
  94. package/dist/providers/codex.d.ts.map +1 -1
  95. package/dist/providers/codex.js +34 -8
  96. package/dist/providers/codex.js.map +1 -1
  97. package/dist/providers/copilot.d.ts +14 -3
  98. package/dist/providers/copilot.d.ts.map +1 -1
  99. package/dist/providers/copilot.js +33 -8
  100. package/dist/providers/copilot.js.map +1 -1
  101. package/dist/providers/email/headers.d.ts +15 -0
  102. package/dist/providers/email/headers.d.ts.map +1 -0
  103. package/dist/providers/email/headers.js +42 -0
  104. package/dist/providers/email/headers.js.map +1 -0
  105. package/dist/providers/email/index.d.ts +18 -0
  106. package/dist/providers/email/index.d.ts.map +1 -0
  107. package/dist/providers/email/index.js +60 -0
  108. package/dist/providers/email/index.js.map +1 -0
  109. package/dist/providers/email/provider.d.ts +49 -0
  110. package/dist/providers/email/provider.d.ts.map +1 -0
  111. package/dist/providers/email/provider.js +2 -0
  112. package/dist/providers/email/provider.js.map +1 -0
  113. package/dist/providers/email/sendgrid.d.ts +12 -0
  114. package/dist/providers/email/sendgrid.d.ts.map +1 -0
  115. package/dist/providers/email/sendgrid.js +67 -0
  116. package/dist/providers/email/sendgrid.js.map +1 -0
  117. package/dist/providers/email/smtp.d.ts +65 -0
  118. package/dist/providers/email/smtp.d.ts.map +1 -0
  119. package/dist/providers/email/smtp.js +373 -0
  120. package/dist/providers/email/smtp.js.map +1 -0
  121. package/dist/providers/index.d.ts +0 -1
  122. package/dist/providers/index.d.ts.map +1 -1
  123. package/dist/providers/index.js +0 -3
  124. package/dist/providers/index.js.map +1 -1
  125. package/dist/providers/none.d.ts +14 -3
  126. package/dist/providers/none.d.ts.map +1 -1
  127. package/dist/providers/none.js +26 -2
  128. package/dist/providers/none.js.map +1 -1
  129. package/dist/providers/opencode.d.ts +14 -3
  130. package/dist/providers/opencode.d.ts.map +1 -1
  131. package/dist/providers/opencode.js +60 -6
  132. package/dist/providers/opencode.js.map +1 -1
  133. package/dist/providers/provider.d.ts +91 -5
  134. package/dist/providers/provider.d.ts.map +1 -1
  135. package/dist/providers/provider.js +45 -1
  136. package/dist/providers/provider.js.map +1 -1
  137. package/dist/services/agent-provisioner.d.ts.map +1 -1
  138. package/dist/services/agent-provisioner.js +5 -8
  139. package/dist/services/agent-provisioner.js.map +1 -1
  140. package/dist/services/cloud/activity.js +2 -2
  141. package/dist/services/cloud/activity.js.map +1 -1
  142. package/dist/services/cloud/lifecycle.d.ts.map +1 -1
  143. package/dist/services/cloud/lifecycle.js +3 -0
  144. package/dist/services/cloud/lifecycle.js.map +1 -1
  145. package/dist/services/cloud/task-wrapper.d.ts +18 -0
  146. package/dist/services/cloud/task-wrapper.d.ts.map +1 -1
  147. package/dist/services/cloud/task-wrapper.js +157 -0
  148. package/dist/services/cloud/task-wrapper.js.map +1 -1
  149. package/dist/services/context-admission.d.ts.map +1 -1
  150. package/dist/services/context-admission.js +9 -7
  151. package/dist/services/context-admission.js.map +1 -1
  152. package/dist/services/credential-cleanup.d.ts.map +1 -1
  153. package/dist/services/credential-cleanup.js +22 -3
  154. package/dist/services/credential-cleanup.js.map +1 -1
  155. package/dist/services/github-app.d.ts.map +1 -1
  156. package/dist/services/github-app.js +11 -2
  157. package/dist/services/github-app.js.map +1 -1
  158. package/dist/services/knowledge/audn.d.ts +37 -0
  159. package/dist/services/knowledge/audn.d.ts.map +1 -0
  160. package/dist/services/knowledge/audn.js +219 -0
  161. package/dist/services/knowledge/audn.js.map +1 -0
  162. package/dist/services/knowledge/file-hash.d.ts +11 -0
  163. package/dist/services/knowledge/file-hash.d.ts.map +1 -0
  164. package/dist/services/knowledge/file-hash.js +123 -0
  165. package/dist/services/knowledge/file-hash.js.map +1 -0
  166. package/dist/services/knowledge/http-provider.d.ts +46 -0
  167. package/dist/services/knowledge/http-provider.d.ts.map +1 -0
  168. package/dist/services/knowledge/http-provider.js +254 -0
  169. package/dist/services/knowledge/http-provider.js.map +1 -0
  170. package/dist/services/knowledge/kb-providers.d.ts +15 -0
  171. package/dist/services/knowledge/kb-providers.d.ts.map +1 -0
  172. package/dist/services/knowledge/kb-providers.js +92 -0
  173. package/dist/services/knowledge/kb-providers.js.map +1 -0
  174. package/dist/services/knowledge/kb-scope-input.d.ts +5 -0
  175. package/dist/services/knowledge/kb-scope-input.d.ts.map +1 -0
  176. package/dist/services/knowledge/kb-scope-input.js +11 -0
  177. package/dist/services/knowledge/kb-scope-input.js.map +1 -0
  178. package/dist/services/knowledge/kb-service.d.ts +3 -0
  179. package/dist/services/knowledge/kb-service.d.ts.map +1 -0
  180. package/dist/services/knowledge/kb-service.js +2 -0
  181. package/dist/services/knowledge/kb-service.js.map +1 -0
  182. package/dist/services/knowledge/path-validation.d.ts +2 -0
  183. package/dist/services/knowledge/path-validation.d.ts.map +1 -0
  184. package/dist/services/knowledge/path-validation.js +13 -0
  185. package/dist/services/knowledge/path-validation.js.map +1 -0
  186. package/dist/services/knowledge/pre-init.d.ts +14 -0
  187. package/dist/services/knowledge/pre-init.d.ts.map +1 -0
  188. package/dist/services/knowledge/pre-init.js +147 -0
  189. package/dist/services/knowledge/pre-init.js.map +1 -0
  190. package/dist/services/knowledge/project-slug.d.ts +2 -0
  191. package/dist/services/knowledge/project-slug.d.ts.map +1 -0
  192. package/dist/services/knowledge/project-slug.js +49 -0
  193. package/dist/services/knowledge/project-slug.js.map +1 -0
  194. package/dist/services/knowledge/sqlite-provider.d.ts +147 -0
  195. package/dist/services/knowledge/sqlite-provider.d.ts.map +1 -0
  196. package/dist/services/knowledge/sqlite-provider.js +1646 -0
  197. package/dist/services/knowledge/sqlite-provider.js.map +1 -0
  198. package/dist/services/knowledge/types.d.ts +163 -0
  199. package/dist/services/knowledge/types.d.ts.map +1 -0
  200. package/dist/services/knowledge/types.js +9 -0
  201. package/dist/services/knowledge/types.js.map +1 -0
  202. package/dist/services/member-home.d.ts +89 -0
  203. package/dist/services/member-home.d.ts.map +1 -0
  204. package/dist/services/member-home.js +259 -0
  205. package/dist/services/member-home.js.map +1 -0
  206. package/dist/services/member-remote-url.d.ts +34 -0
  207. package/dist/services/member-remote-url.d.ts.map +1 -0
  208. package/dist/services/member-remote-url.js +39 -0
  209. package/dist/services/member-remote-url.js.map +1 -0
  210. package/dist/services/model-pricing.d.ts.map +1 -1
  211. package/dist/services/model-pricing.js +0 -5
  212. package/dist/services/model-pricing.js.map +1 -1
  213. package/dist/services/orphan-recovery.d.ts +9 -3
  214. package/dist/services/orphan-recovery.d.ts.map +1 -1
  215. package/dist/services/orphan-recovery.js +22 -8
  216. package/dist/services/orphan-recovery.js.map +1 -1
  217. package/dist/services/preflight-check.d.ts +56 -0
  218. package/dist/services/preflight-check.d.ts.map +1 -0
  219. package/dist/services/preflight-check.js +277 -0
  220. package/dist/services/preflight-check.js.map +1 -0
  221. package/dist/services/shell-probe.d.ts +131 -0
  222. package/dist/services/shell-probe.d.ts.map +1 -0
  223. package/dist/services/shell-probe.js +210 -0
  224. package/dist/services/shell-probe.js.map +1 -0
  225. package/dist/services/singleton.d.ts +2 -0
  226. package/dist/services/singleton.d.ts.map +1 -1
  227. package/dist/services/singleton.js +1 -1
  228. package/dist/services/singleton.js.map +1 -1
  229. package/dist/services/ssh.js +2 -2
  230. package/dist/services/ssh.js.map +1 -1
  231. package/dist/services/stall/find-log-file.d.ts.map +1 -1
  232. package/dist/services/stall/find-log-file.js +22 -16
  233. package/dist/services/stall/find-log-file.js.map +1 -1
  234. package/dist/services/stall/log-path-resolver.d.ts +11 -8
  235. package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
  236. package/dist/services/stall/log-path-resolver.js +17 -40
  237. package/dist/services/stall/log-path-resolver.js.map +1 -1
  238. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  239. package/dist/services/stall/read-log-tail.js +6 -5
  240. package/dist/services/stall/read-log-tail.js.map +1 -1
  241. package/dist/services/stall/stall-detector.d.ts +32 -0
  242. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  243. package/dist/services/stall/stall-detector.js +149 -6
  244. package/dist/services/stall/stall-detector.js.map +1 -1
  245. package/dist/services/stall/stall-poller.d.ts +34 -0
  246. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  247. package/dist/services/stall/stall-poller.js +160 -35
  248. package/dist/services/stall/stall-poller.js.map +1 -1
  249. package/dist/services/strategy.d.ts +9 -0
  250. package/dist/services/strategy.d.ts.map +1 -1
  251. package/dist/services/strategy.js +41 -7
  252. package/dist/services/strategy.js.map +1 -1
  253. package/dist/services/tool-registry.d.ts.map +1 -1
  254. package/dist/services/tool-registry.js +87 -1
  255. package/dist/services/tool-registry.js.map +1 -1
  256. package/dist/services/user-config.js +1 -1
  257. package/dist/services/user-config.js.map +1 -1
  258. package/dist/services/vcs/azure-devops.d.ts +1 -1
  259. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  260. package/dist/services/vcs/azure-devops.js +105 -10
  261. package/dist/services/vcs/azure-devops.js.map +1 -1
  262. package/dist/services/vcs/bitbucket.d.ts.map +1 -1
  263. package/dist/services/vcs/bitbucket.js +16 -0
  264. package/dist/services/vcs/bitbucket.js.map +1 -1
  265. package/dist/services/vcs/github.d.ts.map +1 -1
  266. package/dist/services/vcs/github.js +56 -1
  267. package/dist/services/vcs/github.js.map +1 -1
  268. package/dist/services/vcs/types.d.ts +123 -2
  269. package/dist/services/vcs/types.d.ts.map +1 -1
  270. package/dist/services/version-check.d.ts +22 -0
  271. package/dist/services/version-check.d.ts.map +1 -0
  272. package/dist/services/version-check.js +103 -0
  273. package/dist/services/version-check.js.map +1 -0
  274. package/dist/skills/fleet-sprint-cli/SKILL.md +15 -3
  275. package/dist/skills/pm/SKILL.md +0 -1
  276. package/dist/skills/pm/beads.md +6 -0
  277. package/dist/skills/pm/cost.md +0 -1
  278. package/dist/skills/pm/fleet-addendum.md +6 -1
  279. package/dist/skills/pm/index.md +56 -0
  280. package/dist/skills/pm/kb-reconcile.md +132 -0
  281. package/dist/skills/pm/kb-review.md +109 -0
  282. package/dist/tools/check-status.d.ts +47 -0
  283. package/dist/tools/check-status.d.ts.map +1 -1
  284. package/dist/tools/check-status.js +245 -3
  285. package/dist/tools/check-status.js.map +1 -1
  286. package/dist/tools/child-id-allocator.d.ts +2 -2
  287. package/dist/tools/cloud-control.js +2 -2
  288. package/dist/tools/cloud-control.js.map +1 -1
  289. package/dist/tools/code-intelligence-codebase-memory.d.ts +11 -0
  290. package/dist/tools/code-intelligence-codebase-memory.d.ts.map +1 -0
  291. package/dist/tools/code-intelligence-codebase-memory.js +270 -0
  292. package/dist/tools/code-intelligence-codebase-memory.js.map +1 -0
  293. package/dist/tools/code-intelligence-freshness.d.ts +2 -0
  294. package/dist/tools/code-intelligence-freshness.d.ts.map +1 -0
  295. package/dist/tools/code-intelligence-freshness.js +26 -0
  296. package/dist/tools/code-intelligence-freshness.js.map +1 -0
  297. package/dist/tools/code-intelligence-gitnexus.d.ts +14 -0
  298. package/dist/tools/code-intelligence-gitnexus.d.ts.map +1 -0
  299. package/dist/tools/code-intelligence-gitnexus.js +475 -0
  300. package/dist/tools/code-intelligence-gitnexus.js.map +1 -0
  301. package/dist/tools/code-intelligence-kb-enrich.d.ts +2 -0
  302. package/dist/tools/code-intelligence-kb-enrich.d.ts.map +1 -0
  303. package/dist/tools/code-intelligence-kb-enrich.js +65 -0
  304. package/dist/tools/code-intelligence-kb-enrich.js.map +1 -0
  305. package/dist/tools/code-intelligence-reindex.d.ts +7 -0
  306. package/dist/tools/code-intelligence-reindex.d.ts.map +1 -0
  307. package/dist/tools/code-intelligence-reindex.js +106 -0
  308. package/dist/tools/code-intelligence-reindex.js.map +1 -0
  309. package/dist/tools/code-intelligence-telemetry.d.ts +5 -0
  310. package/dist/tools/code-intelligence-telemetry.d.ts.map +1 -0
  311. package/dist/tools/code-intelligence-telemetry.js +52 -0
  312. package/dist/tools/code-intelligence-telemetry.js.map +1 -0
  313. package/dist/tools/code-intelligence-tests.d.ts +2 -0
  314. package/dist/tools/code-intelligence-tests.d.ts.map +1 -0
  315. package/dist/tools/code-intelligence-tests.js +24 -0
  316. package/dist/tools/code-intelligence-tests.js.map +1 -0
  317. package/dist/tools/code-intelligence.d.ts +114 -0
  318. package/dist/tools/code-intelligence.d.ts.map +1 -0
  319. package/dist/tools/code-intelligence.js +124 -0
  320. package/dist/tools/code-intelligence.js.map +1 -0
  321. package/dist/tools/compose-permissions.d.ts +26 -0
  322. package/dist/tools/compose-permissions.d.ts.map +1 -1
  323. package/dist/tools/compose-permissions.js +257 -33
  324. package/dist/tools/compose-permissions.js.map +1 -1
  325. package/dist/tools/execute-command.d.ts +2 -0
  326. package/dist/tools/execute-command.d.ts.map +1 -1
  327. package/dist/tools/execute-command.js +114 -28
  328. package/dist/tools/execute-command.js.map +1 -1
  329. package/dist/tools/execute-prompt.d.ts +13 -1
  330. package/dist/tools/execute-prompt.d.ts.map +1 -1
  331. package/dist/tools/execute-prompt.js +310 -61
  332. package/dist/tools/execute-prompt.js.map +1 -1
  333. package/dist/tools/kb-capture.d.ts +53 -0
  334. package/dist/tools/kb-capture.d.ts.map +1 -0
  335. package/dist/tools/kb-capture.js +130 -0
  336. package/dist/tools/kb-capture.js.map +1 -0
  337. package/dist/tools/kb-context.d.ts +17 -0
  338. package/dist/tools/kb-context.d.ts.map +1 -0
  339. package/dist/tools/kb-context.js +29 -0
  340. package/dist/tools/kb-context.js.map +1 -0
  341. package/dist/tools/kb-export.d.ts +19 -0
  342. package/dist/tools/kb-export.d.ts.map +1 -0
  343. package/dist/tools/kb-export.js +344 -0
  344. package/dist/tools/kb-export.js.map +1 -0
  345. package/dist/tools/kb-feedback.d.ts +23 -0
  346. package/dist/tools/kb-feedback.d.ts.map +1 -0
  347. package/dist/tools/kb-feedback.js +43 -0
  348. package/dist/tools/kb-feedback.js.map +1 -0
  349. package/dist/tools/kb-freshness-sweep.d.ts +14 -0
  350. package/dist/tools/kb-freshness-sweep.d.ts.map +1 -0
  351. package/dist/tools/kb-freshness-sweep.js +29 -0
  352. package/dist/tools/kb-freshness-sweep.js.map +1 -0
  353. package/dist/tools/kb-harvest.d.ts +20 -0
  354. package/dist/tools/kb-harvest.d.ts.map +1 -0
  355. package/dist/tools/kb-harvest.js +143 -0
  356. package/dist/tools/kb-harvest.js.map +1 -0
  357. package/dist/tools/kb-import.d.ts +44 -0
  358. package/dist/tools/kb-import.d.ts.map +1 -0
  359. package/dist/tools/kb-import.js +239 -0
  360. package/dist/tools/kb-import.js.map +1 -0
  361. package/dist/tools/kb-invalidate.d.ts +19 -0
  362. package/dist/tools/kb-invalidate.d.ts.map +1 -0
  363. package/dist/tools/kb-invalidate.js +34 -0
  364. package/dist/tools/kb-invalidate.js.map +1 -0
  365. package/dist/tools/kb-list.d.ts +32 -0
  366. package/dist/tools/kb-list.d.ts.map +1 -0
  367. package/dist/tools/kb-list.js +43 -0
  368. package/dist/tools/kb-list.js.map +1 -0
  369. package/dist/tools/kb-promote.d.ts +20 -0
  370. package/dist/tools/kb-promote.d.ts.map +1 -0
  371. package/dist/tools/kb-promote.js +20 -0
  372. package/dist/tools/kb-promote.js.map +1 -0
  373. package/dist/tools/kb-query.d.ts +35 -0
  374. package/dist/tools/kb-query.d.ts.map +1 -0
  375. package/dist/tools/kb-query.js +111 -0
  376. package/dist/tools/kb-query.js.map +1 -0
  377. package/dist/tools/kb-reconcile-prefilter.d.ts +14 -0
  378. package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -0
  379. package/dist/tools/kb-reconcile-prefilter.js +26 -0
  380. package/dist/tools/kb-reconcile-prefilter.js.map +1 -0
  381. package/dist/tools/kb-resolve-contradiction.d.ts +23 -0
  382. package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -0
  383. package/dist/tools/kb-resolve-contradiction.js +37 -0
  384. package/dist/tools/kb-resolve-contradiction.js.map +1 -0
  385. package/dist/tools/kb-session-prime.d.ts +26 -0
  386. package/dist/tools/kb-session-prime.d.ts.map +1 -0
  387. package/dist/tools/kb-session-prime.js +392 -0
  388. package/dist/tools/kb-session-prime.js.map +1 -0
  389. package/dist/tools/kb-setup.d.ts +20 -0
  390. package/dist/tools/kb-setup.d.ts.map +1 -0
  391. package/dist/tools/kb-setup.js +49 -0
  392. package/dist/tools/kb-setup.js.map +1 -0
  393. package/dist/tools/kb-stats.d.ts +20 -0
  394. package/dist/tools/kb-stats.d.ts.map +1 -0
  395. package/dist/tools/kb-stats.js +115 -0
  396. package/dist/tools/kb-stats.js.map +1 -0
  397. package/dist/tools/list-members.d.ts.map +1 -1
  398. package/dist/tools/list-members.js +6 -2
  399. package/dist/tools/list-members.js.map +1 -1
  400. package/dist/tools/member-detail.d.ts.map +1 -1
  401. package/dist/tools/member-detail.js +13 -3
  402. package/dist/tools/member-detail.js.map +1 -1
  403. package/dist/tools/member-reservation.d.ts.map +1 -1
  404. package/dist/tools/member-reservation.js +13 -1
  405. package/dist/tools/member-reservation.js.map +1 -1
  406. package/dist/tools/monitor-task.d.ts.map +1 -1
  407. package/dist/tools/monitor-task.js +38 -5
  408. package/dist/tools/monitor-task.js.map +1 -1
  409. package/dist/tools/provision-auth.d.ts.map +1 -1
  410. package/dist/tools/provision-auth.js +15 -8
  411. package/dist/tools/provision-auth.js.map +1 -1
  412. package/dist/tools/provision-vcs-auth.d.ts +5 -2
  413. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  414. package/dist/tools/provision-vcs-auth.js +58 -52
  415. package/dist/tools/provision-vcs-auth.js.map +1 -1
  416. package/dist/tools/register-member.d.ts +21 -12
  417. package/dist/tools/register-member.d.ts.map +1 -1
  418. package/dist/tools/register-member.js +70 -3
  419. package/dist/tools/register-member.js.map +1 -1
  420. package/dist/tools/remove-member.d.ts.map +1 -1
  421. package/dist/tools/remove-member.js +19 -5
  422. package/dist/tools/remove-member.js.map +1 -1
  423. package/dist/tools/report-status.d.ts.map +1 -1
  424. package/dist/tools/report-status.js +2 -1
  425. package/dist/tools/report-status.js.map +1 -1
  426. package/dist/tools/revoke-vcs-auth.js +2 -2
  427. package/dist/tools/revoke-vcs-auth.js.map +1 -1
  428. package/dist/tools/send-email.d.ts +69 -0
  429. package/dist/tools/send-email.d.ts.map +1 -0
  430. package/dist/tools/send-email.js +177 -0
  431. package/dist/tools/send-email.js.map +1 -0
  432. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  433. package/dist/tools/setup-ssh-key.js +4 -1
  434. package/dist/tools/setup-ssh-key.js.map +1 -1
  435. package/dist/tools/stop-prompt.js +2 -2
  436. package/dist/tools/stop-prompt.js.map +1 -1
  437. package/dist/tools/update-agent-cli.js +2 -2
  438. package/dist/tools/update-agent-cli.js.map +1 -1
  439. package/dist/tools/update-member.d.ts +21 -12
  440. package/dist/tools/update-member.d.ts.map +1 -1
  441. package/dist/tools/update-member.js +43 -2
  442. package/dist/tools/update-member.js.map +1 -1
  443. package/dist/types.d.ts +12 -1
  444. package/dist/types.d.ts.map +1 -1
  445. package/dist/utils/agent-helpers.d.ts +36 -0
  446. package/dist/utils/agent-helpers.d.ts.map +1 -1
  447. package/dist/utils/agent-helpers.js +39 -1
  448. package/dist/utils/agent-helpers.js.map +1 -1
  449. package/dist/utils/platform.d.ts +7 -0
  450. package/dist/utils/platform.d.ts.map +1 -1
  451. package/dist/utils/platform.js +11 -1
  452. package/dist/utils/platform.js.map +1 -1
  453. package/dist/utils/prompt-errors.js +1 -1
  454. package/dist/utils/prompt-errors.js.map +1 -1
  455. package/dist/utils/session-caller.d.ts +28 -0
  456. package/dist/utils/session-caller.d.ts.map +1 -0
  457. package/dist/utils/session-caller.js +24 -0
  458. package/dist/utils/session-caller.js.map +1 -0
  459. package/dist/utils/work-folder-validation.d.ts +39 -0
  460. package/dist/utils/work-folder-validation.d.ts.map +1 -0
  461. package/dist/utils/work-folder-validation.js +60 -0
  462. package/dist/utils/work-folder-validation.js.map +1 -0
  463. package/dist/utils/workspace-trust.d.ts.map +1 -1
  464. package/dist/utils/workspace-trust.js +5 -1
  465. package/dist/utils/workspace-trust.js.map +1 -1
  466. package/dist/workflows/auto-sprint.js +550 -23
  467. package/package.json +7 -4
  468. package/packages/apra-fleet-client/src/client/api.mjs +210 -7
  469. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +31 -19
  470. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +16 -1
  471. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -47
  472. package/packages/apra-fleet-se/apra-pm/agents/doer.md +147 -114
  473. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +41 -34
  474. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +98 -114
  475. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +205 -0
  476. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +45 -44
  477. package/packages/apra-fleet-se/apra-pm/agents/planner.md +121 -50
  478. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +84 -81
  479. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +118 -44
  480. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +63 -3
  481. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +59 -2
  482. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +3 -3
  483. package/packages/apra-fleet-se/apra-pm/agents/schemas/kb-reconciler-output.json +87 -0
  484. package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +65 -0
  485. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
  486. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +105 -8
  487. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
  488. package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +6 -0
  489. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
  490. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +6 -1
  491. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +56 -0
  492. package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +132 -0
  493. package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +109 -0
  494. package/packages/apra-fleet-se/bin/cli.mjs +139 -3
  495. package/packages/apra-fleet-se/bin/serve.mjs +49 -2
  496. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +182 -38
  497. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +23 -8
  498. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +258 -0
  499. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +1487 -0
  500. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +908 -0
  501. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +399 -0
  502. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
  503. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +1148 -0
  504. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +229 -112
  505. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +91 -6
  506. package/packages/apra-fleet-se/fleet-sprint/runner.js +2469 -238
  507. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
  508. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
  509. package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
  510. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
  511. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +15 -3
  512. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +350 -0
  513. package/packages/apra-fleet-se/fleet-sprint/sprint-progress.mjs +101 -0
  514. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
  515. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
  516. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
  517. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -30
  518. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
  519. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
  520. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +141 -26
  521. package/packages/apra-fleet-se/package.json +1 -0
  522. package/packages/apra-fleet-workflow/src/viewer/index.mjs +294 -14
  523. package/packages/apra-fleet-workflow/src/viewer/run-title.mjs +60 -0
  524. package/packages/apra-fleet-workflow/src/workflow/index.mjs +443 -35
  525. package/skills/fleet/SKILL.md +20 -9
  526. package/skills/fleet/auth-azdevops.md +44 -5
  527. package/skills/fleet/auth-bitbucket.md +3 -3
  528. package/skills/fleet/auth-github.md +2 -2
  529. package/skills/fleet/beads-conflict-resolution.md +141 -0
  530. package/skills/fleet/beads.md +16 -12
  531. package/skills/fleet/knowledge-agent.md +66 -0
  532. package/skills/fleet/onboarding.md +4 -4
  533. package/skills/fleet/permissions.md +32 -8
  534. package/skills/fleet/profiles/base-dev.json +10 -1
  535. package/skills/fleet/profiles/base-reviewer.json +8 -1
  536. package/skills/fleet/profiles/tag-kb-reconciler.json +20 -0
  537. package/skills/fleet/skill-matrix.md +1 -1
  538. package/skills/fleet/troubleshooting.md +2 -1
  539. package/version.json +1 -1
  540. package/dist/providers/gemini.d.ts +0 -42
  541. package/dist/providers/gemini.d.ts.map +0 -1
  542. package/dist/providers/gemini.js +0 -202
  543. package/dist/providers/gemini.js.map +0 -1
  544. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -151
  545. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md +0 -127
  546. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-path-b.mjs +0 -339
  547. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-tier2.mjs +0 -360
  548. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery.mjs +0 -363
@@ -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,674 @@
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 canonical remote shape parseRepoRef() expects, quoted into every
305
+ * operator-facing remedy this module produces (see `repoRefHint` below). */
306
+ const REPO_REF_HINT = 'https://dev.azure.com/ORG/PROJECT/_git/REPO';
307
+
308
+ /**
309
+ * Build the provision_vcs_auth argument object for an Azure DevOps member
310
+ * (apra-fleet-5co8.2.1).
311
+ *
312
+ * WHY A HOOK: the shared argument shape (`git_access` + a `repos` allowlist)
313
+ * is GitHub-App vocabulary. Azure DevOps has no App/installation model at all
314
+ * -- a PAT is minted by a human against an ORG, so what provision_vcs_auth
315
+ * needs here is `org_url` plus the token, and `git_access`/`repos` are
316
+ * meaningless. Expressing that as a descriptor hook keeps the difference in
317
+ * this file instead of adding a provider branch to the shared caller.
318
+ *
319
+ * SECRET TRANSPORT: the PAT is passed as a `{{secure.NAME}}` PLACEHOLDER, never
320
+ * a value. Resolution happens hub-side inside the fleet server; the orchestrator
321
+ * process that calls this hook never holds, logs or transports the plaintext,
322
+ * and a remote member (which has no secret store of its own) never has to.
323
+ * That is also why a missing store entry is a TYPED ERROR rather than a prompt:
324
+ * an unattended preflight/self-heal has no operator attached, and an
325
+ * out-of-band prompt there would stall the sprint instead of failing it.
326
+ *
327
+ * @param {{ base: object, repoRef: ({ org: string }|null|undefined),
328
+ * availableSecrets: string[]|null, secretName?: string }} ctx
329
+ * `base` is the shared argument object the caller would otherwise send;
330
+ * `repoRef` is this provider's own parseRepoRef() output for the member's
331
+ * remote; `availableSecrets` is the credential-store entry names the caller
332
+ * observed (null when it could not be read -- then the check is skipped
333
+ * rather than guessed, and a genuinely missing secret still fails loudly
334
+ * server-side).
335
+ * @returns {{ args: object }|{ error: string }}
336
+ */
337
+ function buildProvisionArgs(ctx) {
338
+ const { base = {}, repoRef, availableSecrets, secretName } = ctx || {};
339
+ const org = repoRef && typeof repoRef.org === 'string' ? repoRef.org.trim() : '';
340
+ if (!org) {
341
+ return {
342
+ error: `ERROR: cannot provision Azure DevOps auth for member '${base.member_name}': no organization could be derived from the member's git remote; expected a remote of the shape ${REPO_REF_HINT}`,
343
+ };
344
+ }
345
+
346
+ const name = (typeof secretName === 'string' && secretName.trim()) ? secretName.trim() : DEFAULT_PAT_SECRET;
347
+ if (Array.isArray(availableSecrets) && !availableSecrets.includes(name)) {
348
+ return {
349
+ 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}`,
350
+ };
351
+ }
352
+
353
+ return {
354
+ args: {
355
+ member_name: base.member_name,
356
+ provider: base.provider,
357
+ // Base org URL with no trailing path -- see auth-azdevops.md's
358
+ // "Org URL must be base URL without trailing path" note and the
359
+ // TF400813 troubleshooting row, which is what a wrong org URL
360
+ // surfaces as.
361
+ org_url: `https://dev.azure.com/${org}`,
362
+ // Placeholder, NOT a value. See SECRET TRANSPORT above.
363
+ pat: `{{secure.${name}}}`,
364
+ },
365
+ };
366
+ }
367
+
368
+ // ---------------------------------------------------------------------------
369
+ // REST command builders (apra-fleet-lzfv.2)
370
+ // ---------------------------------------------------------------------------
371
+ //
372
+ // PARAMETER CONTRACT (the shape buildVcsCommand() hands a builder, and what
373
+ // apra-fleet-lzfv.3's golden tests and apra-fleet-lzfv.4's response mapping
374
+ // read as this provider's contract):
375
+ //
376
+ // provider 'azure-devops'
377
+ // repoRef OPTIONAL { org, project, repo } -- parseRepoRef()'s own output,
378
+ // passed straight through. Individual org/project/repo params
379
+ // take PRECEDENCE over the matching repoRef field, so a caller can
380
+ // override one coordinate without rebuilding the object.
381
+ // org/project/repo the three coordinates every Azure DevOps REST call
382
+ // needs. All three are required after the repoRef merge; a missing
383
+ // one is a typed ERROR naming the expected remote shape, never a
384
+ // half-built URL.
385
+ // base/head branch names, in GitHub's OWN vocabulary deliberately (`base` =
386
+ // the branch merged INTO -> targetRefName, `head` = the branch
387
+ // merged FROM -> sourceRefName). Keeping github.mjs's field names
388
+ // is what lets runner.js stay provider-agnostic -- see
389
+ // ./index.mjs's "NO OTHER FILE under fleet-sprint/ changes".
390
+ // title/body PR title and description.
391
+ // pull_request_id (comment only) the PR to annotate.
392
+ // token the PAT. REQUIRED -- assertToken() throws the shared typed ERROR.
393
+ // os resolveMemberOs()'s value ('windows'/'linux'/'darwin'). Selects
394
+ // the curl BINARY token via curlBinary() (curl.exe on Windows,
395
+ // which stays OS-keyed because curl.exe is equally resolvable from
396
+ // PowerShell and from Git-for-Windows bash), and is the fallback
397
+ // input to the quoting dialect when `shell` is unresolved.
398
+ // shell the member's registered COMMAND SHELL as resolved by runner.js's
399
+ // resolveMemberTarget() -- 'gitbash' | 'pwsh7' | 'powershell5' |
400
+ // '' -- and the primary input to shQuote()'s quoting DIALECT:
401
+ // gitbash -> POSIX even on Windows, pwsh7/powershell5 -> PowerShell
402
+ // doubling, unresolved + windows -> PowerShell doubling (the
403
+ // historical fallback, byte-identical). Distinct from `os`: a
404
+ // Windows member running gitbash needs curl.exe with POSIX quoting.
405
+ //
406
+ // AUTH: Azure DevOps' REST API takes a PAT as HTTP Basic with an EMPTY
407
+ // username (`-u :PAT`), NOT a bearer token -- the exact form skills/fleet/
408
+ // auth-azdevops.md already documents for its connectivity Test call. The PAT
409
+ // therefore appears in `command` ONLY; `logSafeCommand` is built by the same
410
+ // closure with REDACTED substituted, so no field other than `command` can
411
+ // carry it.
412
+ //
413
+ // URL ENCODING: parseRepoRef() percent-DECODES every field it returns (Azure
414
+ // DevOps project names commonly contain spaces), so each coordinate is
415
+ // re-encoded per segment here -- see parseRepoRef's own doc note.
416
+
417
+ /** api-version pinned to 7.1, matching skills/fleet/auth-azdevops.md's own
418
+ * REST calls. Pinned, never floating: an unversioned Azure DevOps REST call
419
+ * is rejected outright. */
420
+ const API_VERSION = '7.1';
421
+
422
+ /** Same fixed marker github.mjs uses, so a log scrubber/assertion looking for
423
+ * a redacted VCS command matches identically across providers. */
424
+ const REDACTED = '***REDACTED***';
425
+
426
+ /** Merge a `repoRef` object with any explicit org/project/repo overrides and
427
+ * require all three. Throws the typed ERROR (quoting REPO_REF_HINT, the same
428
+ * remedy text repoRefHint publishes) rather than building a partial URL.
429
+ *
430
+ * apra-fleet-5co8.11: an explicit param takes precedence over the matching
431
+ * repoRef field (see the PARAMETER CONTRACT doc block above), but a caller
432
+ * can hand this a three-part canonical (parseRepoRef()'s own
433
+ * `org/project/repo` string, or github.mjs's two-part `owner/name`) as a
434
+ * SINGLE coordinate -- most plausibly `repo` -- instead of splitting it
435
+ * first. repoApiBase() would then percent-encode the whole slash-bearing
436
+ * string into one URL segment, building a silently wrong URL (a 404 at
437
+ * request time) rather than failing at build time. Reject a '/' inside
438
+ * `org` or `repo` with the same typed ERROR raised for a missing
439
+ * coordinate, so the mistake surfaces immediately instead of round-tripping
440
+ * through a live REST call first. `project` is EXCLUDED from this check: an
441
+ * Azure DevOps project name is decoded free-form by parseRepoRef() and a
442
+ * literal '/' inside it is a legitimate value re-encoded per segment by
443
+ * repoApiBase() below (pinned by "each coordinate is percent-encoded per URL
444
+ * segment" in vcs-azure-devops-builders.test.mjs), not a coordinate-mixing
445
+ * mistake -- org and repo, by contrast, are never expected to contain one. */
446
+ function assertRepoCoords(params, action) {
447
+ const ref = (params && typeof params.repoRef === 'object' && params.repoRef) ? params.repoRef : {};
448
+ const pick = (key) => {
449
+ const own = params && params[key] != null ? params[key] : ref[key];
450
+ return String(own ?? '').trim();
451
+ };
452
+ const org = pick('org');
453
+ const project = pick('project');
454
+ const repo = pick('repo');
455
+ const missing = [['org', org], ['project', project], ['repo', repo]].filter(([, v]) => !v).map(([k]) => k);
456
+ if (missing.length > 0) {
457
+ 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}.`);
458
+ }
459
+ const slashed = [['org', org], ['repo', repo]].filter(([, v]) => v.includes('/'));
460
+ if (slashed.length > 0) {
461
+ 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}.`);
462
+ }
463
+ return { org, project, repo };
464
+ }
465
+
466
+ /** The org/project/repo REST prefix, each coordinate re-encoded per segment. */
467
+ function repoApiBase({ org, project, repo }) {
468
+ return `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_apis/git/repositories/${encodeURIComponent(repo)}`;
469
+ }
470
+
471
+ /** Azure DevOps' pullrequests endpoint takes FULL ref names
472
+ * ('refs/heads/main'), not the bare branch names GitHub's API takes, and
473
+ * rejects a bare name outright. An input that already carries a 'refs/'
474
+ * prefix is passed through untouched so a caller holding a real ref (e.g.
475
+ * 'refs/heads/feat/x') is never double-prefixed. */
476
+ function toFullRef(branch) {
477
+ const value = String(branch).trim();
478
+ return /^refs\//i.test(value) ? value : `refs/heads/${value}`;
479
+ }
480
+
481
+ /**
482
+ * Build the Azure DevOps REST "create pull request" curl command.
483
+ * POST {org}/{project}/_apis/git/repositories/{repo}/pullrequests?api-version=7.1
484
+ * -- see https://learn.microsoft.com/rest/api/azure/devops/git/pull-requests/create
485
+ */
486
+ function buildAzureDevOpsCreatePrCommand(params) {
487
+ const { base, head, title, body, token, os, shell } = params || {};
488
+ const coords = assertRepoCoords(params, 'create-pull-request');
489
+ const safeToken = assertToken(token);
490
+ if (!base) throw new Error('ERROR: VCSModule: "base" branch is required to build a create-pull-request command.');
491
+ if (!head) throw new Error('ERROR: VCSModule: "head" branch is required to build a create-pull-request command.');
492
+ if (!title) throw new Error('ERROR: VCSModule: "title" is required to build a create-pull-request command.');
493
+
494
+ const payload = {
495
+ sourceRefName: toFullRef(head),
496
+ targetRefName: toFullRef(base),
497
+ title,
498
+ };
499
+ if (body !== undefined) payload.description = body;
500
+ const payloadJson = JSON.stringify(payload);
501
+ const url = `${repoApiBase(coords)}/pullrequests?api-version=${API_VERSION}`;
502
+
503
+ const buildCurl = (authToken) => [
504
+ `${curlBinary(os)} -sS -X POST`,
505
+ `-u ${shQuote(`:${authToken}`, os, shell)}`,
506
+ `-H ${shQuote('Content-Type: application/json', os, shell)}`,
507
+ `-H ${shQuote('Accept: application/json', os, shell)}`,
508
+ `-d ${shQuoteJson(payloadJson, os, shell)}`,
509
+ `-w ${shQuote('\n%{http_code}', os, shell)}`,
510
+ url,
511
+ ].join(' ');
512
+
513
+ return {
514
+ provider: 'azure-devops',
515
+ action: 'create-pull-request',
516
+ command: buildCurl(safeToken),
517
+ logSafeCommand: buildCurl(REDACTED),
518
+ // Interpretation contract, same field NAMES github.mjs uses so a
519
+ // consumer reads it generically:
520
+ // - 2xx -> success; body has .pullRequestId
521
+ // - 409 + TF401179 -> an active PR for this source/target
522
+ // pair already exists, which is the
523
+ // idempotent re-run case, so success
524
+ // - anything else -> error
525
+ interpret: {
526
+ successStatusRange: [200, 299],
527
+ alreadyExistsStatus: 409,
528
+ alreadyExistsPattern: 'TF401179',
529
+ },
530
+ };
55
531
  }
56
532
 
533
+ /**
534
+ * Build the Azure DevOps REST "comment on a pull request" curl command, used
535
+ * to annotate an existing PR when a sprint aborts after the PR was already
536
+ * raised (rather than opening a second PR for the same source branch).
537
+ * POST .../pullrequests/{id}/threads?api-version=7.1 -- Azure DevOps has no
538
+ * bare "PR comment" resource: a comment is one entry in a THREAD, so a single
539
+ * text comment is posted as a new active thread carrying exactly one comment.
540
+ * See https://learn.microsoft.com/rest/api/azure/devops/git/pull-request-threads/create
541
+ */
542
+ function buildAzureDevOpsCommentCommand(params) {
543
+ const { pull_request_id: pullRequestId, body, token, os, shell } = params || {};
544
+ const coords = assertRepoCoords(params, 'comment');
545
+ const safeToken = assertToken(token);
546
+ if (!pullRequestId) throw new Error('ERROR: VCSModule: "pull_request_id" is required to build an azure-devops comment command.');
547
+ if (!body) throw new Error('ERROR: VCSModule: "body" is required to build a comment command.');
548
+
549
+ const payloadJson = JSON.stringify({
550
+ comments: [{ parentCommentId: 0, content: body, commentType: 'text' }],
551
+ status: 'active',
552
+ });
553
+ const url = `${repoApiBase(coords)}/pullrequests/${encodeURIComponent(String(pullRequestId))}/threads?api-version=${API_VERSION}`;
554
+
555
+ const buildCurl = (authToken) => [
556
+ `${curlBinary(os)} -sS -X POST`,
557
+ `-u ${shQuote(`:${authToken}`, os, shell)}`,
558
+ `-H ${shQuote('Content-Type: application/json', os, shell)}`,
559
+ `-H ${shQuote('Accept: application/json', os, shell)}`,
560
+ `-d ${shQuoteJson(payloadJson, os, shell)}`,
561
+ `-w ${shQuote('\n%{http_code}', os, shell)}`,
562
+ url,
563
+ ].join(' ');
564
+
565
+ return {
566
+ provider: 'azure-devops',
567
+ action: 'comment',
568
+ command: buildCurl(safeToken),
569
+ logSafeCommand: buildCurl(REDACTED),
570
+ interpret: {
571
+ successStatusRange: [200, 299],
572
+ },
573
+ };
574
+ }
575
+
576
+ // ---------------------------------------------------------------------------
577
+ // Pull-request RESPONSE mapping (apra-fleet-lzfv.4)
578
+ // ---------------------------------------------------------------------------
579
+ //
580
+ // Azure DevOps' create-pull-request 2xx body speaks a DIFFERENT dialect than
581
+ // GitHub's: the identifier is `pullRequestId` (not `number`), and the body
582
+ // carries NO browsable web URL at all -- its `url` field is the REST resource
583
+ // (.../_apis/git/repositories/{id}/pullRequests/{id}), which is not a page an
584
+ // operator can open. The browsable URL therefore has to be CONSTRUCTED from
585
+ // the same org/project/repo coordinates the request was built from plus the
586
+ // returned id. Declaring both here (rather than teaching the caller either
587
+ // dialect) is the whole point of the contract -- see ./index.mjs and
588
+ // ./github.mjs's mirror-image declaration.
589
+
590
+ const PR_ID_FIELD = 'pullRequestId';
591
+
592
+ /** The browsable pull request page Azure DevOps renders for a PR -- the shape
593
+ * the web UI itself uses:
594
+ * https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}
595
+ * (the same org/project/_git/repo prefix as the clone URL REPO_REF_HINT
596
+ * quotes). Published as a template string so a consumer that must mirror this
597
+ * contract elsewhere (canonical VCS types / fleet client) can restate it
598
+ * without re-deriving it. */
599
+ const PR_WEB_URL_TEMPLATE = 'https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}';
600
+
601
+ /** Soft coordinate pick for the response mapping: unlike assertRepoCoords()
602
+ * (which is building a request URL and MUST fail loudly), a response mapping
603
+ * never throws -- a missing coordinate simply yields `url: null`, so a caller
604
+ * reporting an otherwise successful PR is never turned into a crash. */
605
+ function softRepoCoords(ctx) {
606
+ const source = (ctx && typeof ctx === 'object') ? ctx : {};
607
+ const ref = (source.repoRef && typeof source.repoRef === 'object') ? source.repoRef : {};
608
+ const pick = (key) => String((source[key] != null ? source[key] : ref[key]) ?? '').trim();
609
+ return { org: pick('org'), project: pick('project'), repo: pick('repo') };
610
+ }
611
+
612
+ /** Map an Azure DevOps create-pull-request response body to { id, url }.
613
+ * Reads the DECLARED id field above, and builds the web URL from `ctx`'s
614
+ * org/project/repo (each segment re-encoded, same reason repoApiBase() does).
615
+ * `ctx` accepts either explicit org/project/repo or a `repoRef` object -- the
616
+ * same shape the builders take. */
617
+ function mapPullRequestResponse(body, ctx) {
618
+ const source = (body && typeof body === 'object') ? body : {};
619
+ const rawId = source[PR_ID_FIELD];
620
+ let id = null;
621
+ if (typeof rawId === 'number' && Number.isFinite(rawId)) id = rawId;
622
+ else if (typeof rawId === 'string' && /^\d+$/.test(rawId.trim())) id = Number(rawId.trim());
623
+ if (id === null) return { id: null, url: null };
624
+
625
+ const { org, project, repo } = softRepoCoords(ctx);
626
+ if (!org || !project || !repo) return { id, url: null };
627
+ const url = `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}/pullrequest/${encodeURIComponent(String(id))}`;
628
+ return { id, url };
629
+ }
630
+
631
+ const pullRequestResponse = Object.freeze({
632
+ idField: PR_ID_FIELD,
633
+ // No web-URL field exists in the body -- it is constructed, see above.
634
+ webUrlField: null,
635
+ webUrlTemplate: PR_WEB_URL_TEMPLATE,
636
+ map: mapPullRequestResponse,
637
+ });
638
+
639
+ // ---------------------------------------------------------------------------
640
+ // Auth self-heal remedy (apra-fleet-5co8.4.2)
641
+ // ---------------------------------------------------------------------------
642
+ //
643
+ // Unlike a GitHub App installation token (minted fresh, server-side, on every
644
+ // provision_vcs_auth call), an Azure DevOps PAT is a long-lived secret the
645
+ // fleet only ever STORES and REDEPLOYS -- it never mints one. The Azure
646
+ // DevOps PAT lifecycle management API requires an Entra (Azure AD) OAuth
647
+ // token with admin consent the fleet does not hold (skills/fleet/
648
+ // auth-azdevops.md's "PAT Lifetime and Expiry" section). So when the
649
+ // REACTIVE self-heal (runner.js's createVcsAuthSelfHealCallback) fires on an
650
+ // auth-classified failure, calling provision_vcs_auth again just redeploys
651
+ // the SAME dead secret and is expected to fail again -- serverSideReMintable
652
+ // is false, and `hint` is the exact operator-facing remedy runner.js prints
653
+ // alongside the (still-attempted, still-logged) self-heal call, covering
654
+ // both AUTH_EXPIRED (401/TF400813 -- the PAT itself is dead) and AUTH_DENIED
655
+ // (403 -- the PAT is valid but scoped too narrowly; TF401019 is a
656
+ // repo/permission grant, not a scope, and has no PAT-rotation remedy) since
657
+ // the self-heal callback is never told which kind fired -- see
658
+ // ./index.mjs's authRemedy doc.
659
+ const AUTH_REMEDY_HINT =
660
+ 'Azure DevOps PATs cannot be re-minted server-side. If the PAT expired or ' +
661
+ 'was revoked: create a new PAT at https://dev.azure.com/ORG/_settings/tokens, ' +
662
+ 'then credential_store_set the fleet secret and re-run provision_vcs_auth. ' +
663
+ 'If access was denied for insufficient scope: create a PAT with broader ' +
664
+ 'scopes per the role/scope table in skills/fleet/auth-azdevops.md, then ' +
665
+ 'credential_store_set the fleet secret and re-run provision_vcs_auth.';
666
+
667
+ const authRemedy = Object.freeze({
668
+ serverSideReMintable: false,
669
+ hint: AUTH_REMEDY_HINT,
670
+ });
671
+
57
672
  export const AzureDevOpsVCS = Object.freeze({
58
673
  name: 'azure-devops',
59
674
  extends: 'generic-git',
60
675
  rules: Object.freeze({
676
+ [K.AUTH_EXPIRED]: AUTH_EXPIRED,
61
677
  [K.AUTH_DENIED]: AUTH_DENIED,
62
678
  }),
63
679
  extractProviderCode,
680
+ matchesHost,
681
+ capabilitiesForHost,
682
+ // apra-fleet-5co8.1.1: remote-URL -> { org, project, repo, canonical }.
683
+ // An OPTIONAL descriptor hook (see ./index.mjs's REQUIRED EXPORT SHAPE):
684
+ // only providers whose REST identity is not the portable "owner/name"
685
+ // pair need it, which is why it lives here rather than in shared code.
686
+ parseRepoRef,
687
+ // apra-fleet-5co8.1.2: the remedy text for a remote this provider claims
688
+ // but parseRepoRef() rejects. Lives here, not in the caller, so runner.js
689
+ // can raise a provider-specific preflight ERROR with no Azure DevOps
690
+ // literal (or conditional) of its own. The canonical https shape is the
691
+ // one an operator copies out of the Azure DevOps "Clone" dialog; the ssh
692
+ // and legacy visualstudio.com shapes parseRepoRef also accepts are
693
+ // deliberately NOT listed, to keep the remedy a single copyable form.
694
+ repoRefHint: REPO_REF_HINT,
695
+ // apra-fleet-5co8.2.1: OPTIONAL descriptor hook -- see ./index.mjs.
696
+ buildProvisionArgs,
64
697
  defaultAuthMode: null,
65
- builders: null,
698
+ // apra-fleet-lzfv.4: this provider's create-pull-request response dialect
699
+ // (pullRequestId + a CONSTRUCTED web URL) -- see above.
700
+ pullRequestResponse,
701
+ // apra-fleet-5co8.4.2: PATs are never re-minted server-side -- see above.
702
+ authRemedy,
703
+ // apra-fleet-lzfv.2: the REST builders. capabilitiesForHost() above now
704
+ // reports canOpenPullRequest:true (apra-fleet-lzfv.5) -- the publish path
705
+ // can dispatch them. Any action not listed here still fails closed with
706
+ // buildVcsCommand()'s typed ERROR.
707
+ builders: Object.freeze({
708
+ 'create-pull-request': buildAzureDevOpsCreatePrCommand,
709
+ comment: buildAzureDevOpsCommentCommand,
710
+ }),
66
711
  });
67
712
 
68
713
  export default AzureDevOpsVCS;