@apralabs/apra-fleet 0.4.2 → 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 (370) hide show
  1. package/README.md +38 -5
  2. package/dist/agents/backlog-groomer.md +25 -0
  3. package/dist/agents/ci-watcher.md +11 -0
  4. package/dist/agents/deployer.md +37 -2
  5. package/dist/agents/doer.md +36 -12
  6. package/dist/agents/harvester.md +11 -0
  7. package/dist/agents/integ-test-runner.md +11 -0
  8. package/dist/agents/kb-reconciler.md +9 -0
  9. package/dist/agents/plan-reviewer.md +110 -22
  10. package/dist/agents/planner.md +125 -37
  11. package/dist/agents/regression-test-runner.md +11 -0
  12. package/dist/agents/reviewer.md +13 -2
  13. package/dist/agents/schemas/plan-reviewer-output.json +37 -0
  14. package/dist/cli/agent-transform.d.ts +83 -2
  15. package/dist/cli/agent-transform.d.ts.map +1 -1
  16. package/dist/cli/agent-transform.js +266 -21
  17. package/dist/cli/agent-transform.js.map +1 -1
  18. package/dist/cli/auth.d.ts.map +1 -1
  19. package/dist/cli/auth.js +28 -9
  20. package/dist/cli/auth.js.map +1 -1
  21. package/dist/cli/config.d.ts +7 -5
  22. package/dist/cli/config.d.ts.map +1 -1
  23. package/dist/cli/config.js +44 -34
  24. package/dist/cli/config.js.map +1 -1
  25. package/dist/cli/install.d.ts +33 -0
  26. package/dist/cli/install.d.ts.map +1 -1
  27. package/dist/cli/install.js +290 -23
  28. package/dist/cli/install.js.map +1 -1
  29. package/dist/cli/kb-directives.d.ts.map +1 -1
  30. package/dist/cli/kb-directives.js +2 -1
  31. package/dist/cli/kb-directives.js.map +1 -1
  32. package/dist/cli/register-member.d.ts.map +1 -1
  33. package/dist/cli/register-member.js +6 -2
  34. package/dist/cli/register-member.js.map +1 -1
  35. package/dist/commands/kb-server.d.ts +3 -0
  36. package/dist/commands/kb-server.d.ts.map +1 -1
  37. package/dist/commands/kb-server.js +43 -3
  38. package/dist/commands/kb-server.js.map +1 -1
  39. package/dist/index.js +3 -3
  40. package/dist/os/linux.d.ts +6 -0
  41. package/dist/os/linux.d.ts.map +1 -1
  42. package/dist/os/linux.js +35 -2
  43. package/dist/os/linux.js.map +1 -1
  44. package/dist/os/os-commands.d.ts +61 -2
  45. package/dist/os/os-commands.d.ts.map +1 -1
  46. package/dist/os/windows-gitbash.d.ts +5 -0
  47. package/dist/os/windows-gitbash.d.ts.map +1 -1
  48. package/dist/os/windows-gitbash.js +15 -0
  49. package/dist/os/windows-gitbash.js.map +1 -1
  50. package/dist/os/windows.d.ts +6 -0
  51. package/dist/os/windows.d.ts.map +1 -1
  52. package/dist/os/windows.js +46 -3
  53. package/dist/os/windows.js.map +1 -1
  54. package/dist/providers/agy.d.ts +115 -6
  55. package/dist/providers/agy.d.ts.map +1 -1
  56. package/dist/providers/agy.js +569 -53
  57. package/dist/providers/agy.js.map +1 -1
  58. package/dist/providers/claude.d.ts +81 -3
  59. package/dist/providers/claude.d.ts.map +1 -1
  60. package/dist/providers/claude.js +344 -10
  61. package/dist/providers/claude.js.map +1 -1
  62. package/dist/providers/codex.d.ts +4 -2
  63. package/dist/providers/codex.d.ts.map +1 -1
  64. package/dist/providers/codex.js +19 -2
  65. package/dist/providers/codex.js.map +1 -1
  66. package/dist/providers/copilot.d.ts +4 -2
  67. package/dist/providers/copilot.d.ts.map +1 -1
  68. package/dist/providers/copilot.js +20 -2
  69. package/dist/providers/copilot.js.map +1 -1
  70. package/dist/providers/none.d.ts +4 -2
  71. package/dist/providers/none.d.ts.map +1 -1
  72. package/dist/providers/none.js +17 -2
  73. package/dist/providers/none.js.map +1 -1
  74. package/dist/providers/opencode.d.ts +3 -1
  75. package/dist/providers/opencode.d.ts.map +1 -1
  76. package/dist/providers/opencode.js +22 -2
  77. package/dist/providers/opencode.js.map +1 -1
  78. package/dist/providers/provider.d.ts +201 -6
  79. package/dist/providers/provider.d.ts.map +1 -1
  80. package/dist/providers/provider.js +56 -0
  81. package/dist/providers/provider.js.map +1 -1
  82. package/dist/services/agy-project.d.ts +102 -0
  83. package/dist/services/agy-project.d.ts.map +1 -0
  84. package/dist/services/agy-project.js +356 -0
  85. package/dist/services/agy-project.js.map +1 -0
  86. package/dist/services/auth-socket.js +4 -4
  87. package/dist/services/auth-web.js +1 -1
  88. package/dist/services/cloud/lifecycle.d.ts.map +1 -1
  89. package/dist/services/cloud/lifecycle.js +33 -4
  90. package/dist/services/cloud/lifecycle.js.map +1 -1
  91. package/dist/services/credential-cleanup.d.ts.map +1 -1
  92. package/dist/services/credential-cleanup.js +35 -17
  93. package/dist/services/credential-cleanup.js.map +1 -1
  94. package/dist/services/exit-drain.d.ts +44 -0
  95. package/dist/services/exit-drain.d.ts.map +1 -0
  96. package/dist/services/exit-drain.js +52 -0
  97. package/dist/services/exit-drain.js.map +1 -0
  98. package/dist/services/github-app.d.ts.map +1 -1
  99. package/dist/services/github-app.js +32 -4
  100. package/dist/services/github-app.js.map +1 -1
  101. package/dist/services/http-transport.d.ts +1 -0
  102. package/dist/services/http-transport.d.ts.map +1 -1
  103. package/dist/services/http-transport.js +48 -1
  104. package/dist/services/http-transport.js.map +1 -1
  105. package/dist/services/knowledge/kb-config.d.ts +42 -0
  106. package/dist/services/knowledge/kb-config.d.ts.map +1 -0
  107. package/dist/services/knowledge/kb-config.js +54 -0
  108. package/dist/services/knowledge/kb-config.js.map +1 -0
  109. package/dist/services/knowledge/kb-providers.d.ts +7 -1
  110. package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
  111. package/dist/services/knowledge/kb-providers.js +191 -17
  112. package/dist/services/knowledge/kb-providers.js.map +1 -1
  113. package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
  114. package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
  115. package/dist/services/knowledge/require-sqlite-project.js +38 -0
  116. package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
  117. package/dist/services/model-pricing.d.ts.map +1 -1
  118. package/dist/services/model-pricing.js +7 -3
  119. package/dist/services/model-pricing.js.map +1 -1
  120. package/dist/services/secret-token.d.ts +38 -0
  121. package/dist/services/secret-token.d.ts.map +1 -0
  122. package/dist/services/secret-token.js +51 -0
  123. package/dist/services/secret-token.js.map +1 -0
  124. package/dist/services/service-manager/types.d.ts +3 -1
  125. package/dist/services/service-manager/types.d.ts.map +1 -1
  126. package/dist/services/service-manager/windows.d.ts +14 -2
  127. package/dist/services/service-manager/windows.d.ts.map +1 -1
  128. package/dist/services/service-manager/windows.js +65 -7
  129. package/dist/services/service-manager/windows.js.map +1 -1
  130. package/dist/services/ssh.d.ts.map +1 -1
  131. package/dist/services/ssh.js +58 -2
  132. package/dist/services/ssh.js.map +1 -1
  133. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  134. package/dist/services/stall/read-log-tail.js +20 -10
  135. package/dist/services/stall/read-log-tail.js.map +1 -1
  136. package/dist/services/stall/stall-detector.d.ts +53 -4
  137. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  138. package/dist/services/stall/stall-detector.js +212 -34
  139. package/dist/services/stall/stall-detector.js.map +1 -1
  140. package/dist/services/strategy.d.ts.map +1 -1
  141. package/dist/services/strategy.js +79 -2
  142. package/dist/services/strategy.js.map +1 -1
  143. package/dist/services/substitution-engine.js +2 -2
  144. package/dist/services/substitution-engine.js.map +1 -1
  145. package/dist/services/tool-registry.d.ts.map +1 -1
  146. package/dist/services/tool-registry.js +5 -3
  147. package/dist/services/tool-registry.js.map +1 -1
  148. package/dist/services/vcs/azure-devops.d.ts +66 -1
  149. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  150. package/dist/services/vcs/azure-devops.js +192 -21
  151. package/dist/services/vcs/azure-devops.js.map +1 -1
  152. package/dist/services/vcs/types.d.ts +1 -1
  153. package/dist/skills/fleet-sprint-cli/SKILL.md +18 -0
  154. package/dist/skills/pm/SKILL.md +1 -1
  155. package/dist/skills/pm/cost.md +0 -3
  156. package/dist/skills/pm/fleet-addendum.md +2 -2
  157. package/dist/tools/check-status.d.ts +7 -4
  158. package/dist/tools/check-status.d.ts.map +1 -1
  159. package/dist/tools/check-status.js +2 -0
  160. package/dist/tools/check-status.js.map +1 -1
  161. package/dist/tools/compose-permissions.d.ts +6 -0
  162. package/dist/tools/compose-permissions.d.ts.map +1 -1
  163. package/dist/tools/compose-permissions.js +182 -34
  164. package/dist/tools/compose-permissions.js.map +1 -1
  165. package/dist/tools/credential-store-set.js +1 -1
  166. package/dist/tools/execute-command.d.ts.map +1 -1
  167. package/dist/tools/execute-command.js +31 -20
  168. package/dist/tools/execute-command.js.map +1 -1
  169. package/dist/tools/execute-prompt.d.ts +15 -2
  170. package/dist/tools/execute-prompt.d.ts.map +1 -1
  171. package/dist/tools/execute-prompt.js +1196 -892
  172. package/dist/tools/execute-prompt.js.map +1 -1
  173. package/dist/tools/kb-capture.d.ts +2 -2
  174. package/dist/tools/kb-capture.d.ts.map +1 -1
  175. package/dist/tools/kb-capture.js +29 -5
  176. package/dist/tools/kb-capture.js.map +1 -1
  177. package/dist/tools/kb-export.d.ts +2 -2
  178. package/dist/tools/kb-export.d.ts.map +1 -1
  179. package/dist/tools/kb-export.js +3 -28
  180. package/dist/tools/kb-export.js.map +1 -1
  181. package/dist/tools/kb-feedback.d.ts.map +1 -1
  182. package/dist/tools/kb-feedback.js +3 -1
  183. package/dist/tools/kb-feedback.js.map +1 -1
  184. package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
  185. package/dist/tools/kb-freshness-sweep.js +3 -1
  186. package/dist/tools/kb-freshness-sweep.js.map +1 -1
  187. package/dist/tools/kb-import.d.ts.map +1 -1
  188. package/dist/tools/kb-import.js +2 -1
  189. package/dist/tools/kb-import.js.map +1 -1
  190. package/dist/tools/kb-list.d.ts.map +1 -1
  191. package/dist/tools/kb-list.js +3 -1
  192. package/dist/tools/kb-list.js.map +1 -1
  193. package/dist/tools/kb-query.d.ts +2 -2
  194. package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
  195. package/dist/tools/kb-reconcile-prefilter.js +3 -1
  196. package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
  197. package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
  198. package/dist/tools/kb-resolve-contradiction.js +3 -1
  199. package/dist/tools/kb-resolve-contradiction.js.map +1 -1
  200. package/dist/tools/kb-setup.d.ts.map +1 -1
  201. package/dist/tools/kb-setup.js +125 -20
  202. package/dist/tools/kb-setup.js.map +1 -1
  203. package/dist/tools/kb-stats.d.ts.map +1 -1
  204. package/dist/tools/kb-stats.js +64 -43
  205. package/dist/tools/kb-stats.js.map +1 -1
  206. package/dist/tools/list-members.d.ts +2 -2
  207. package/dist/tools/list-members.d.ts.map +1 -1
  208. package/dist/tools/list-members.js +1 -0
  209. package/dist/tools/list-members.js.map +1 -1
  210. package/dist/tools/member-detail.d.ts +2 -2
  211. package/dist/tools/member-detail.d.ts.map +1 -1
  212. package/dist/tools/member-detail.js +17 -0
  213. package/dist/tools/member-detail.js.map +1 -1
  214. package/dist/tools/member-reservation.d.ts +58 -1
  215. package/dist/tools/member-reservation.d.ts.map +1 -1
  216. package/dist/tools/member-reservation.js +61 -20
  217. package/dist/tools/member-reservation.js.map +1 -1
  218. package/dist/tools/provision-auth.d.ts +80 -1
  219. package/dist/tools/provision-auth.d.ts.map +1 -1
  220. package/dist/tools/provision-auth.js +142 -54
  221. package/dist/tools/provision-auth.js.map +1 -1
  222. package/dist/tools/provision-vcs-auth.d.ts +91 -1
  223. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  224. package/dist/tools/provision-vcs-auth.js +209 -49
  225. package/dist/tools/provision-vcs-auth.js.map +1 -1
  226. package/dist/tools/register-member.d.ts +12 -9
  227. package/dist/tools/register-member.d.ts.map +1 -1
  228. package/dist/tools/register-member.js +99 -12
  229. package/dist/tools/register-member.js.map +1 -1
  230. package/dist/tools/remove-member.d.ts.map +1 -1
  231. package/dist/tools/remove-member.js +27 -2
  232. package/dist/tools/remove-member.js.map +1 -1
  233. package/dist/tools/send-email.d.ts +2 -2
  234. package/dist/tools/setup-git-app.d.ts.map +1 -1
  235. package/dist/tools/setup-git-app.js +11 -7
  236. package/dist/tools/setup-git-app.js.map +1 -1
  237. package/dist/tools/shutdown-server.d.ts +2 -0
  238. package/dist/tools/shutdown-server.d.ts.map +1 -1
  239. package/dist/tools/shutdown-server.js +23 -1
  240. package/dist/tools/shutdown-server.js.map +1 -1
  241. package/dist/tools/update-member.d.ts +12 -9
  242. package/dist/tools/update-member.d.ts.map +1 -1
  243. package/dist/tools/update-member.js +43 -11
  244. package/dist/tools/update-member.js.map +1 -1
  245. package/dist/tools/vcs-credential-exec.d.ts +127 -0
  246. package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
  247. package/dist/tools/vcs-credential-exec.js +197 -0
  248. package/dist/tools/vcs-credential-exec.js.map +1 -0
  249. package/dist/types.d.ts +13 -0
  250. package/dist/types.d.ts.map +1 -1
  251. package/dist/utils/log-helpers.d.ts.map +1 -1
  252. package/dist/utils/log-helpers.js +2 -2
  253. package/dist/utils/log-helpers.js.map +1 -1
  254. package/dist/utils/prompt-errors.d.ts.map +1 -1
  255. package/dist/utils/prompt-errors.js +7 -1
  256. package/dist/utils/prompt-errors.js.map +1 -1
  257. package/dist/utils/shell-escape.d.ts +16 -0
  258. package/dist/utils/shell-escape.d.ts.map +1 -1
  259. package/dist/utils/shell-escape.js +22 -2
  260. package/dist/utils/shell-escape.js.map +1 -1
  261. package/dist/utils/vcs-provider-detect.d.ts +65 -0
  262. package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
  263. package/dist/utils/vcs-provider-detect.js +109 -0
  264. package/dist/utils/vcs-provider-detect.js.map +1 -0
  265. package/dist/utils/workspace-trust.d.ts +20 -17
  266. package/dist/utils/workspace-trust.d.ts.map +1 -1
  267. package/dist/utils/workspace-trust.js +87 -1
  268. package/dist/utils/workspace-trust.js.map +1 -1
  269. package/dist/workflows/auto-sprint.js +176 -15
  270. package/package.json +6 -4
  271. package/packages/apra-fleet-client/src/client/api.mjs +319 -17
  272. package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
  273. package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
  274. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +25 -0
  275. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +11 -0
  276. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -2
  277. package/packages/apra-fleet-se/apra-pm/agents/doer.md +36 -12
  278. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +11 -0
  279. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +11 -0
  280. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +9 -0
  281. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +110 -22
  282. package/packages/apra-fleet-se/apra-pm/agents/planner.md +125 -37
  283. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +11 -0
  284. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +13 -2
  285. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
  286. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -1
  287. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -3
  288. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -2
  289. package/packages/apra-fleet-se/bin/cli.mjs +149 -1
  290. package/packages/apra-fleet-se/bin/serve.mjs +78 -4
  291. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
  292. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
  293. package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
  294. package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
  295. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
  296. package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
  297. package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
  298. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
  299. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +61 -14
  300. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
  301. package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
  302. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
  303. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
  304. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +1 -1
  305. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +276 -0
  306. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
  307. package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
  308. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
  309. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +996 -32
  310. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +267 -0
  311. package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
  312. package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
  313. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
  314. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
  315. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
  316. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
  317. package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
  318. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
  319. package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
  320. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
  321. package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
  322. package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
  323. package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
  324. package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
  325. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
  326. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
  327. package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
  328. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
  329. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
  330. package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
  331. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
  332. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
  333. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
  334. package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
  335. package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
  336. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
  337. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
  338. package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
  339. package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
  340. package/packages/apra-fleet-se/fleet-sprint/runner.js +1467 -9798
  341. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +17 -12
  342. package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
  343. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +18 -0
  344. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
  345. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
  346. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
  347. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
  348. package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
  349. package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
  350. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
  351. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +153 -19
  352. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +71 -21
  353. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
  354. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +131 -0
  355. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +140 -16
  356. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +1 -0
  357. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +77 -2
  358. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
  359. package/packages/apra-fleet-se/package.json +1 -1
  360. package/packages/apra-fleet-workflow/src/viewer/index.mjs +17 -6
  361. package/packages/apra-fleet-workflow/src/workflow/index.mjs +49 -7
  362. package/skills/fleet/SKILL.md +8 -8
  363. package/skills/fleet/auth-azdevops.md +14 -3
  364. package/skills/fleet/auth-bitbucket.md +2 -2
  365. package/skills/fleet/auth-github.md +5 -4
  366. package/skills/fleet/onboarding.md +3 -3
  367. package/skills/fleet/permissions.md +5 -1
  368. package/skills/fleet/profiles/node.json +1 -1
  369. package/skills/fleet/troubleshooting.md +3 -3
  370. package/version.json +1 -1
@@ -0,0 +1,305 @@
1
+ // =============================================================================
2
+ // PHASE MODULE: Review (apra-fleet-3swo.6.5).
3
+ //
4
+ // The FIFTH of runSprintCycle's twelve phase() boundaries -- the per-round
5
+ // REVIEW of the work the Develop phase just produced: gather the round's
6
+ // acceptance criteria, dispatch the reviewer, and then have the ORCHESTRATOR
7
+ // (never the LLM) apply every structured transition the verdict asks for --
8
+ // guarded reopens, the in-cycle replan fold-in, and validated newTask
9
+ // creation -- before D-pushing the beads it just mutated. Moved verbatim out
10
+ // of runner.js: every prompt, log line, dispatch option, validation branch and
11
+ // sync call is byte-identical to the inline version, so the golden transcript
12
+ // is unchanged. Move-only, no behaviour change.
13
+ //
14
+ // WHERE THIS PHASE STARTS AND STOPS. It starts at its own phase() call and
15
+ // ends at the post-mutation `gitSync.syncBeadsAfter(...)` that closes the
16
+ // `assignedBeadIds.length > 0` branch. The `await updateDashboard()` and the
17
+ // `readyLeafBeads()` still-open check that follow it in runner.js are NOT part
18
+ // of this phase: they are the round loop's own continue/break decision (the
19
+ // second one `break`s, which cannot be expressed from inside a function), and
20
+ // they run identically whether or not a review was dispatched this round.
21
+ //
22
+ // WHY devRounds IS PASSED IN ALREADY INCREMENTED. Same reason as
23
+ // ./replan.mjs and ./develop.mjs: `devRounds` is the round loop's own counter,
24
+ // so the increment stays next to the loop and the incremented value arrives
25
+ // here only to build the `Review C{cycle} R{devRounds}` label.
26
+ //
27
+ // EXPLICIT STATE, NOT A CLOSURE -- AND WHY THREE VALUES COME BACK. The inline
28
+ // version read its inputs off the enclosing runSprintCycle/round-loop scope.
29
+ // They arrive as one explicit state argument now. Most of what this phase
30
+ // writes is MUTATED IN PLACE on objects the caller still holds -- `replanIds`
31
+ // and `replannedThisCycle` (Sets), `perBeadFeedback` (a Map, written through
32
+ // applyGuardedReopens' onReopened hook) and `rejectedNewTasks` (an array) --
33
+ // which is exactly equivalent to the closure it replaces, because runner.js
34
+ // never reassigns those bindings either.
35
+ //
36
+ // Three values are genuinely REASSIGNED rather than mutated, so they cannot
37
+ // travel that way and are returned instead: `lastReviewVerdict` and
38
+ // `reviewedThisCycle`, which the Cycle Evaluation section reads to decide
39
+ // whether a real review happened this cycle and what it concluded, and
40
+ // `pendingRejectedNewTasks`, which trackRejectedNewTaskForResurfacing()/
41
+ // clearResubmittedNewTask() return a NEW list from every time. They are also
42
+ // passed IN, so the round where the empty-guard skips the review dispatch
43
+ // returns them unchanged and the caller's single destructuring assignment is
44
+ // a no-op -- which is what keeps the call site free of an `if`.
45
+ //
46
+ // WHY SOME HELPERS ARE INJECTED RATHER THAN IMPORTED. dispatchReview,
47
+ // bdListScoped, goalMax, recordReopen, childIdAllocator and sprintMutexId are
48
+ // runSprintCycle-scoped locals, so there is nothing to import. computeChildFloor,
49
+ // createChildBeadWithAllocatedId, trackRejectedNewTaskForResurfacing and
50
+ // clearResubmittedNewTask are exported BY runner.js; importing them here would
51
+ // make phases/review.mjs <-> runner.js a circular pair for the sake of four
52
+ // helpers, so they come through the state argument instead -- the same rule
53
+ // phases/plan.mjs's and phases/develop.mjs's headers state. The dependencies
54
+ // that live in real sibling modules (applyGuardedReopens/foldReplanIds from
55
+ // ../beads-transitions.mjs, validateNewTask/appendRejectedFindingToParentNotes/
56
+ // persistNewTaskBestEffort from ../abort.mjs) are imported directly.
57
+ //
58
+ // GUARD COVERAGE: registered as 'phases/review.mjs' in ../guarded-modules.mjs.
59
+ // It took ONE member_name-bearing command() call site out of runner.js (the
60
+ // `bd show <ids> --json` acceptance-criteria read); the reopen and newTask
61
+ // writes reach bd through injected helpers that issue their own command()
62
+ // calls in the modules that already own them, and its only push is the shared
63
+ // gitSync bracket at the end. It carries NO dispatchRole() call site of its
64
+ // own: the reviewer ladder runs through runner.js's dispatchReview() helper,
65
+ // which stays there because the Re-Review and Final Review phases call it too.
66
+ // =============================================================================
67
+
68
+ import { applyGuardedReopens, foldReplanIds } from '../beads-transitions.mjs';
69
+ import {
70
+ validateNewTask, appendRejectedFindingToParentNotes, persistNewTaskBestEffort,
71
+ } from '../abort.mjs';
72
+
73
+ /**
74
+ * Runs ONE Review round: reviewer dispatch plus the orchestrator-applied
75
+ * transitions its verdict asks for.
76
+ *
77
+ * @param {object} state Explicit phase state; see this file's header.
78
+ * @returns {Promise<{
79
+ * lastReviewVerdict: string|undefined,
80
+ * reviewedThisCycle: boolean,
81
+ * pendingRejectedNewTasks: object[],
82
+ * }>} The three REASSIGNED values described in the header. Every other output
83
+ * of this phase is an in-place mutation of a Set/Map/array the caller still
84
+ * holds. On the empty-scope round (every streak failed) all three come back
85
+ * exactly as they were passed in.
86
+ */
87
+ export async function runReviewPhase({
88
+ // Presentation + dispatch seams.
89
+ phase,
90
+ log,
91
+ command,
92
+ // Sprint identity/config.
93
+ cycle,
94
+ validated,
95
+ targetIssues,
96
+ orchestratorMember,
97
+ // The git/beads sync bracket this phase's post-mutation D-push goes
98
+ // through.
99
+ gitSync,
100
+ // Per-cycle state. `replanIds`, `replannedThisCycle`, `perBeadFeedback` and
101
+ // `rejectedNewTasks` are mutated in place (see header).
102
+ replanIds,
103
+ replannedThisCycle,
104
+ perBeadFeedback,
105
+ rejectedNewTasks,
106
+ // Per-round inputs. `devRounds` arrives already incremented (see header);
107
+ // the other two are this round's Develop phase output.
108
+ devRounds,
109
+ streakOutcomes,
110
+ readyTitleById,
111
+ // Reassigned, so passed in and returned (see header).
112
+ lastReviewVerdict,
113
+ reviewedThisCycle,
114
+ pendingRejectedNewTasks,
115
+ // runSprintCycle-scoped locals and runner.js-exported helpers, injected
116
+ // rather than imported (see header).
117
+ dispatchReview,
118
+ bdListScoped,
119
+ goalMax,
120
+ recordReopen,
121
+ childIdAllocator,
122
+ sprintMutexId,
123
+ computeChildFloor,
124
+ createChildBeadWithAllocatedId,
125
+ trackRejectedNewTaskForResurfacing,
126
+ clearResubmittedNewTask,
127
+ }) {
128
+ // --- Review: self-contained, schema-validated, orchestrator-applied ---
129
+ phase(`Review C${cycle} R${devRounds}`);
130
+ // Sort by (title, id) -- not raw outcome-recording order -- so this
131
+ // evidence-gathering step is deterministic. See the readyTitleById
132
+ // comment just above.
133
+ // Failed streaks' beadIds are excluded from this round's review
134
+ // scope.
135
+ const assignedBeadIds = streakOutcomes.filter((o) => o.outcome !== 'failed').flatMap((o) => o.beadIds)
136
+ .slice().sort((a, b) => {
137
+ const ta = readyTitleById.get(a) || a;
138
+ const tb = readyTitleById.get(b) || b;
139
+ return ta.localeCompare(tb) || a.localeCompare(b);
140
+ });
141
+ const acceptanceCriteriaJson = assignedBeadIds.length > 0
142
+ ? await command(`bd show ${assignedBeadIds.join(' ')} --json`, { member_name: orchestratorMember, silent: true })
143
+ : '[]';
144
+
145
+ // Empty-guard: when EVERY streak this round failed, assignedBeadIds
146
+ // is [] and there is nothing for the Reviewer to look at. Skip the
147
+ // dispatch entirely rather than sending an empty-scope review: an
148
+ // empty review is prone to returning CHANGES_NEEDED with empty
149
+ // reopenIds+newTasks, which trips the contract-violation check below
150
+ // and, after the retry-once path, throws
151
+ // ReviewerContractViolationError -- a hard sprint abort over a round
152
+ // where no work happened at all. The `stillOpen` check just below
153
+ // still runs, so the loop correctly continues instead of prematurely
154
+ // treating the cycle as organically complete.
155
+ if (assignedBeadIds.length === 0) {
156
+ log(`Develop C${cycle} R${devRounds}: all streaks this round failed with no beadIds assigned -- skipping Review dispatch (nothing to review). Failed-streak beads remain ready for the next Develop round.`);
157
+ } else {
158
+ // dispatchReview() applies the shared contract-violation
159
+ // retry-once-then-throw rule (see its own doc comment and
160
+ // ReviewerContractViolationError) -- a CHANGES_NEEDED verdict with
161
+ // both reopenIds and newTasks empty is self-contradictory and must
162
+ // never be treated as an ordinary "more work needed" round.
163
+ const verdict = await dispatchReview({ beadIds: assignedBeadIds, acceptanceCriteriaJson });
164
+ // KB trust pipeline Phase 2: the reviewer decides, the engine
165
+ // executes. Reviewer is the ONLY role whose kb_promotions are
166
+ // honoured. apra-fleet-3swo.5.7: performed by the 'reviewer' row's
167
+ // 'kb-apply' postResult step inside dispatchReview, so BOTH of its
168
+ // call sites get it and a degraded round (which fabricates a
169
+ // verdict carrying no KB fields) does not.
170
+ // A5: the last reviewer verdict seen THIS cycle feeds the Cycle
171
+ // Evaluation section's completion check below -- goal-priority
172
+ // completion requires this to be exactly 'APPROVED', not just
173
+ // an empty ready-bead list.
174
+ lastReviewVerdict = verdict.verdict;
175
+ // A review genuinely ran THIS cycle -- the Cycle Evaluation section
176
+ // below only trusts `lastReviewVerdict` when this is true (see the
177
+ // `reviewedThisCycle` reset at the top of the cycle loop and the
178
+ // re-review dispatch it guards).
179
+ reviewedThisCycle = true;
180
+
181
+ // Orchestrator (this code) -- NOT the LLM -- applies every
182
+ // structured transition: reopenIds via `bd update --status=open`,
183
+ // newTasks via `bd create`. The reviewer's dispatch prompt above
184
+ // explicitly forbade it from mutating beads itself; this is the
185
+ // enforcement side of that contract (SKILL.md).
186
+ // Deterministic goal-scope guard on reopenIds: the prompt-side
187
+ // instruction (buildReviewerPrompt) asks the reviewer not to reopen
188
+ // below-goal beads, but the orchestrator enforces it -- reopening a
189
+ // DEFERRED P3 feature in a P1/P2 sprint injects out-of-scope work and
190
+ // pins the verdict at CHANGES_NEEDED forever.
191
+ // Ids actually reopened this round (survived the goal-scope
192
+ // allowlist) -- gates which `replanIds` entries below are trusted,
193
+ // so a reviewer naming a replanIds id that was never really
194
+ // reopened (out of scope, or simply absent from reopenIds) can
195
+ // never short-circuit the loop.
196
+ const reopenedIds = new Set(await applyGuardedReopens({
197
+ entries: verdict.reopenIds,
198
+ bdListScoped, goalMax, goal: validated.goal, log, command,
199
+ member: orchestratorMember,
200
+ logPrefix: 'Reviewer reopenIds',
201
+ buildReopenCommand: ({ id }) => ({
202
+ cmd: `bd update ${id} --status=open`,
203
+ label: `Reopen ${id} per reviewer verdict`,
204
+ }),
205
+ onReopened: ({ id }) => {
206
+ // Track per-bead reopen counts for reopen-thrash detection.
207
+ recordReopen(id);
208
+ // Per-bead feedback routing: only beads named in reopenIds
209
+ // carry this round's feedback into the next round's doer
210
+ // prompt -- never a blanket broadcast.
211
+ perBeadFeedback.set(id, verdict.notes);
212
+ },
213
+ }));
214
+ // Fold this round's reviewer `replanIds` (absent/undefined on
215
+ // verdicts that do not use it, so a no-op then) into the cycle's
216
+ // running union, consulted at the top of the next iteration's
217
+ // currentReady computation above. Only ids that were ACTUALLY
218
+ // reopened this round are tracked -- an id the reviewer named in
219
+ // replanIds without ALSO naming it in reopenIds (contrary to the
220
+ // buildReviewerPrompt instruction above) is dropped rather than
221
+ // silently ignored: logged here so the drop is visible in the run
222
+ // log instead of vanishing with no trace.
223
+ // This is the replan loop guard's single enforcement point. A bead
224
+ // that has ALREADY been through one in-cycle scoped replan this cycle
225
+ // (replannedThisCycle) is refused a SECOND: it stays reopened (real
226
+ // dev feedback still applies) but is NOT re-added to replanIds, so
227
+ // the develop loop above never dispatches a second scoped planner
228
+ // pass for it -- it is handed to the next cycle's planner instead.
229
+ // This is what makes "max one scoped replan per bead per cycle" hold
230
+ // regardless of the round budget.
231
+ for (const id of foldReplanIds({
232
+ replanIds: verdict.replanIds, reopenedIds, replannedThisCycle, cycle, log,
233
+ })) {
234
+ replanIds.add(id);
235
+ }
236
+ for (const newTask of verdict.newTasks) {
237
+ // Validate BEFORE interpolation -- see validateNewTask() above
238
+ // for why this is an allowlist, not escaping. A rejection is
239
+ // logged, recorded for the final-review evidence summary, and
240
+ // skipped; it must never abort the sprint over one bad newTask.
241
+ const validation = validateNewTask(newTask);
242
+ if (!validation.ok) {
243
+ log(`Reviewer newTasks: REJECTED (not sent to bd create) -- ${validation.reason}`);
244
+ rejectedNewTasks.push({ cycle, reason: validation.reason, raw: newTask });
245
+ // Track it for resurfacing into the NEXT planning-phase
246
+ // dispatch too -- see trackRejectedNewTaskForResurfacing()'s
247
+ // doc comment.
248
+ pendingRejectedNewTasks = trackRejectedNewTaskForResurfacing(pendingRejectedNewTasks, {
249
+ title: newTask && newTask.title, description: newTask && newTask.description,
250
+ reason: validation.reason, cycle,
251
+ });
252
+ // A rejected finding must never simply vanish -- persist it
253
+ // verbatim to the parent bead's notes as a fallback (itself
254
+ // non-fatal: a notes write failure degrades to the run log,
255
+ // never an abort).
256
+ try {
257
+ await appendRejectedFindingToParentNotes({
258
+ command, member: orchestratorMember, parentId: targetIssues[0],
259
+ newTask, reason: validation.reason, cycle, log,
260
+ });
261
+ } catch (noteErr) {
262
+ log(`[fleet-sprint] rejected-finding notes fallback FAILED (non-fatal): ${noteErr.message}; finding preserved VERBATIM in this run log: ${JSON.stringify(newTask)}`);
263
+ }
264
+ continue;
265
+ }
266
+ const { title, description, priority } = validation;
267
+ // A bead can only have one parent -- see the matching
268
+ // comment on the re-review newTasks site below.
269
+ //
270
+ // Mint the child id through the supervisor-owned allocator so two
271
+ // concurrent sprints creating follow-up work under the SAME
272
+ // parent never derive the same child id. Under the null client
273
+ // (lone sprint) childId is null and bd derives the id as before.
274
+ const persisted = await persistNewTaskBestEffort({
275
+ command, member: orchestratorMember, parentId: targetIssues[0],
276
+ newTask, cycle, log, stage: 'develop-review',
277
+ createFn: async () => {
278
+ const floor = await computeChildFloor({ command, member: orchestratorMember, parentId: targetIssues[0], log });
279
+ await createChildBeadWithAllocatedId({
280
+ command, allocator: childIdAllocator, member: orchestratorMember,
281
+ title, description, priority, parentId: targetIssues[0],
282
+ sprintId: sprintMutexId, floor, log,
283
+ label: `Create follow-up task from reviewer newTasks: ${title}`,
284
+ });
285
+ },
286
+ });
287
+ // This title just landed as a real bead -- if it was a
288
+ // resubmission of an earlier rejected item, drop it from the
289
+ // pending resurface list so it stops reappearing in future
290
+ // planning prompts. Pass title+description (not just title) so a
291
+ // resubmission that also corrected its title still clears via its
292
+ // unchanged description.
293
+ if (persisted) {
294
+ pendingRejectedNewTasks = clearResubmittedNewTask(pendingRejectedNewTasks, { title, description });
295
+ }
296
+ }
297
+
298
+ // The orchestrator just MUTATED beads (reopens + newTask creates) in
299
+ // its own clone -- D-push so members observe them on their next
300
+ // dispatch's D-pull.
301
+ await gitSync.syncBeadsAfter(orchestratorMember, { pushBeads: true });
302
+ } // end assignedBeadIds.length > 0 (Review dispatch + orchestrator-applied transitions)
303
+
304
+ return { lastReviewVerdict, reviewedThisCycle, pendingRejectedNewTasks };
305
+ }