@apralabs/apra-fleet 0.4.1 → 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 (276) hide show
  1. package/README.md +16 -8
  2. package/dist/agents/backlog-groomer.md +17 -21
  3. package/dist/agents/ci-watcher.md +3 -0
  4. package/dist/agents/deployer.md +22 -44
  5. package/dist/agents/doer.md +131 -132
  6. package/dist/agents/harvester.md +20 -32
  7. package/dist/agents/integ-test-runner.md +81 -113
  8. package/dist/agents/kb-reconciler.md +31 -42
  9. package/dist/agents/plan-reviewer.md +32 -44
  10. package/dist/agents/planner.md +51 -63
  11. package/dist/agents/regression-test-runner.md +65 -80
  12. package/dist/agents/reviewer.md +56 -83
  13. package/dist/agents/schemas/integ-test-runner-output.json +1 -1
  14. package/dist/agents/schemas/regression-test-runner-output.json +4 -17
  15. package/dist/cli/auth.d.ts.map +1 -1
  16. package/dist/cli/auth.js +1 -2
  17. package/dist/cli/auth.js.map +1 -1
  18. package/dist/cli/config.d.ts +3 -3
  19. package/dist/cli/config.d.ts.map +1 -1
  20. package/dist/cli/config.js +4 -13
  21. package/dist/cli/config.js.map +1 -1
  22. package/dist/cli/install.d.ts.map +1 -1
  23. package/dist/cli/install.js +5 -39
  24. package/dist/cli/install.js.map +1 -1
  25. package/dist/cli/register-member.js +1 -1
  26. package/dist/cli/start.d.ts.map +1 -1
  27. package/dist/cli/start.js +7 -0
  28. package/dist/cli/start.js.map +1 -1
  29. package/dist/cli/uninstall.d.ts.map +1 -1
  30. package/dist/cli/uninstall.js +5 -3
  31. package/dist/cli/uninstall.js.map +1 -1
  32. package/dist/cli/watch.d.ts +26 -3
  33. package/dist/cli/watch.d.ts.map +1 -1
  34. package/dist/cli/watch.js +41 -9
  35. package/dist/cli/watch.js.map +1 -1
  36. package/dist/os/git-bash-candidates.d.ts +35 -0
  37. package/dist/os/git-bash-candidates.d.ts.map +1 -0
  38. package/dist/os/git-bash-candidates.js +46 -0
  39. package/dist/os/git-bash-candidates.js.map +1 -0
  40. package/dist/os/index.d.ts +13 -4
  41. package/dist/os/index.d.ts.map +1 -1
  42. package/dist/os/index.js +17 -2
  43. package/dist/os/index.js.map +1 -1
  44. package/dist/os/linux.js +1 -1
  45. package/dist/os/linux.js.map +1 -1
  46. package/dist/os/os-commands.d.ts +7 -0
  47. package/dist/os/os-commands.d.ts.map +1 -1
  48. package/dist/os/os-commands.js.map +1 -1
  49. package/dist/os/windows-gitbash.d.ts +93 -0
  50. package/dist/os/windows-gitbash.d.ts.map +1 -0
  51. package/dist/os/windows-gitbash.js +244 -0
  52. package/dist/os/windows-gitbash.js.map +1 -0
  53. package/dist/os/windows.d.ts.map +1 -1
  54. package/dist/os/windows.js +27 -5
  55. package/dist/os/windows.js.map +1 -1
  56. package/dist/providers/agy.d.ts +3 -2
  57. package/dist/providers/agy.d.ts.map +1 -1
  58. package/dist/providers/agy.js +11 -2
  59. package/dist/providers/agy.js.map +1 -1
  60. package/dist/providers/claude.d.ts +3 -2
  61. package/dist/providers/claude.d.ts.map +1 -1
  62. package/dist/providers/claude.js +22 -3
  63. package/dist/providers/claude.js.map +1 -1
  64. package/dist/providers/codex.d.ts +3 -2
  65. package/dist/providers/codex.d.ts.map +1 -1
  66. package/dist/providers/codex.js +5 -2
  67. package/dist/providers/codex.js.map +1 -1
  68. package/dist/providers/copilot.d.ts +3 -2
  69. package/dist/providers/copilot.d.ts.map +1 -1
  70. package/dist/providers/copilot.js +7 -2
  71. package/dist/providers/copilot.js.map +1 -1
  72. package/dist/providers/index.d.ts +0 -1
  73. package/dist/providers/index.d.ts.map +1 -1
  74. package/dist/providers/index.js +0 -3
  75. package/dist/providers/index.js.map +1 -1
  76. package/dist/providers/none.d.ts +3 -2
  77. package/dist/providers/none.d.ts.map +1 -1
  78. package/dist/providers/none.js +5 -2
  79. package/dist/providers/none.js.map +1 -1
  80. package/dist/providers/opencode.d.ts +3 -2
  81. package/dist/providers/opencode.d.ts.map +1 -1
  82. package/dist/providers/opencode.js +5 -2
  83. package/dist/providers/opencode.js.map +1 -1
  84. package/dist/providers/provider.d.ts +16 -7
  85. package/dist/providers/provider.d.ts.map +1 -1
  86. package/dist/providers/provider.js +2 -2
  87. package/dist/providers/provider.js.map +1 -1
  88. package/dist/services/agent-provisioner.js +2 -2
  89. package/dist/services/agent-provisioner.js.map +1 -1
  90. package/dist/services/cloud/activity.js +2 -2
  91. package/dist/services/cloud/activity.js.map +1 -1
  92. package/dist/services/context-admission.d.ts.map +1 -1
  93. package/dist/services/context-admission.js +9 -7
  94. package/dist/services/context-admission.js.map +1 -1
  95. package/dist/services/credential-cleanup.d.ts.map +1 -1
  96. package/dist/services/credential-cleanup.js +22 -3
  97. package/dist/services/credential-cleanup.js.map +1 -1
  98. package/dist/services/member-home.d.ts +1 -1
  99. package/dist/services/member-home.d.ts.map +1 -1
  100. package/dist/services/member-home.js +15 -12
  101. package/dist/services/member-home.js.map +1 -1
  102. package/dist/services/model-pricing.d.ts.map +1 -1
  103. package/dist/services/model-pricing.js +0 -5
  104. package/dist/services/model-pricing.js.map +1 -1
  105. package/dist/services/orphan-recovery.d.ts +6 -3
  106. package/dist/services/orphan-recovery.d.ts.map +1 -1
  107. package/dist/services/orphan-recovery.js +17 -14
  108. package/dist/services/orphan-recovery.js.map +1 -1
  109. package/dist/services/preflight-check.js +2 -2
  110. package/dist/services/preflight-check.js.map +1 -1
  111. package/dist/services/shell-probe.d.ts +131 -0
  112. package/dist/services/shell-probe.d.ts.map +1 -0
  113. package/dist/services/shell-probe.js +210 -0
  114. package/dist/services/shell-probe.js.map +1 -0
  115. package/dist/services/singleton.d.ts +2 -0
  116. package/dist/services/singleton.d.ts.map +1 -1
  117. package/dist/services/singleton.js +1 -1
  118. package/dist/services/singleton.js.map +1 -1
  119. package/dist/services/ssh.js +2 -2
  120. package/dist/services/ssh.js.map +1 -1
  121. package/dist/services/stall/find-log-file.d.ts.map +1 -1
  122. package/dist/services/stall/find-log-file.js +22 -16
  123. package/dist/services/stall/find-log-file.js.map +1 -1
  124. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  125. package/dist/services/stall/read-log-tail.js +6 -5
  126. package/dist/services/stall/read-log-tail.js.map +1 -1
  127. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  128. package/dist/services/stall/stall-poller.js +35 -42
  129. package/dist/services/stall/stall-poller.js.map +1 -1
  130. package/dist/services/strategy.d.ts +9 -0
  131. package/dist/services/strategy.d.ts.map +1 -1
  132. package/dist/services/strategy.js +40 -6
  133. package/dist/services/strategy.js.map +1 -1
  134. package/dist/services/user-config.js +1 -1
  135. package/dist/services/user-config.js.map +1 -1
  136. package/dist/services/vcs/azure-devops.d.ts +1 -1
  137. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  138. package/dist/services/vcs/azure-devops.js +105 -10
  139. package/dist/services/vcs/azure-devops.js.map +1 -1
  140. package/dist/services/vcs/bitbucket.d.ts.map +1 -1
  141. package/dist/services/vcs/bitbucket.js +16 -0
  142. package/dist/services/vcs/bitbucket.js.map +1 -1
  143. package/dist/services/vcs/github.d.ts.map +1 -1
  144. package/dist/services/vcs/github.js +24 -0
  145. package/dist/services/vcs/github.js.map +1 -1
  146. package/dist/services/vcs/types.d.ts +123 -2
  147. package/dist/services/vcs/types.d.ts.map +1 -1
  148. package/dist/skills/fleet-sprint-cli/SKILL.md +2 -1
  149. package/dist/skills/pm/SKILL.md +0 -1
  150. package/dist/skills/pm/cost.md +0 -1
  151. package/dist/skills/pm/fleet-addendum.md +0 -1
  152. package/dist/tools/check-status.js +3 -3
  153. package/dist/tools/check-status.js.map +1 -1
  154. package/dist/tools/cloud-control.js +2 -2
  155. package/dist/tools/cloud-control.js.map +1 -1
  156. package/dist/tools/compose-permissions.d.ts.map +1 -1
  157. package/dist/tools/compose-permissions.js +37 -24
  158. package/dist/tools/compose-permissions.js.map +1 -1
  159. package/dist/tools/execute-command.d.ts.map +1 -1
  160. package/dist/tools/execute-command.js +28 -12
  161. package/dist/tools/execute-command.js.map +1 -1
  162. package/dist/tools/execute-prompt.d.ts.map +1 -1
  163. package/dist/tools/execute-prompt.js +55 -18
  164. package/dist/tools/execute-prompt.js.map +1 -1
  165. package/dist/tools/list-members.d.ts.map +1 -1
  166. package/dist/tools/list-members.js +6 -2
  167. package/dist/tools/list-members.js.map +1 -1
  168. package/dist/tools/member-detail.d.ts.map +1 -1
  169. package/dist/tools/member-detail.js +5 -3
  170. package/dist/tools/member-detail.js.map +1 -1
  171. package/dist/tools/member-reservation.d.ts.map +1 -1
  172. package/dist/tools/member-reservation.js +13 -1
  173. package/dist/tools/member-reservation.js.map +1 -1
  174. package/dist/tools/monitor-task.d.ts.map +1 -1
  175. package/dist/tools/monitor-task.js +17 -2
  176. package/dist/tools/monitor-task.js.map +1 -1
  177. package/dist/tools/provision-auth.js +5 -5
  178. package/dist/tools/provision-auth.js.map +1 -1
  179. package/dist/tools/provision-vcs-auth.d.ts +5 -2
  180. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  181. package/dist/tools/provision-vcs-auth.js +58 -52
  182. package/dist/tools/provision-vcs-auth.js.map +1 -1
  183. package/dist/tools/register-member.d.ts +18 -12
  184. package/dist/tools/register-member.d.ts.map +1 -1
  185. package/dist/tools/register-member.js +42 -4
  186. package/dist/tools/register-member.js.map +1 -1
  187. package/dist/tools/remove-member.js +2 -2
  188. package/dist/tools/remove-member.js.map +1 -1
  189. package/dist/tools/revoke-vcs-auth.js +2 -2
  190. package/dist/tools/revoke-vcs-auth.js.map +1 -1
  191. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  192. package/dist/tools/setup-ssh-key.js +2 -1
  193. package/dist/tools/setup-ssh-key.js.map +1 -1
  194. package/dist/tools/stop-prompt.js +2 -2
  195. package/dist/tools/stop-prompt.js.map +1 -1
  196. package/dist/tools/update-agent-cli.js +2 -2
  197. package/dist/tools/update-agent-cli.js.map +1 -1
  198. package/dist/tools/update-member.d.ts +18 -12
  199. package/dist/tools/update-member.d.ts.map +1 -1
  200. package/dist/tools/update-member.js +18 -1
  201. package/dist/tools/update-member.js.map +1 -1
  202. package/dist/types.d.ts +11 -1
  203. package/dist/types.d.ts.map +1 -1
  204. package/dist/utils/agent-helpers.d.ts +36 -0
  205. package/dist/utils/agent-helpers.d.ts.map +1 -1
  206. package/dist/utils/agent-helpers.js +39 -1
  207. package/dist/utils/agent-helpers.js.map +1 -1
  208. package/dist/utils/platform.d.ts +7 -0
  209. package/dist/utils/platform.d.ts.map +1 -1
  210. package/dist/utils/platform.js +11 -1
  211. package/dist/utils/platform.js.map +1 -1
  212. package/dist/utils/workspace-trust.d.ts.map +1 -1
  213. package/dist/utils/workspace-trust.js +5 -1
  214. package/dist/utils/workspace-trust.js.map +1 -1
  215. package/dist/workflows/auto-sprint.js +4 -17
  216. package/package.json +2 -2
  217. package/packages/apra-fleet-client/src/client/api.mjs +92 -3
  218. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +17 -21
  219. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +3 -0
  220. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +22 -44
  221. package/packages/apra-fleet-se/apra-pm/agents/doer.md +131 -132
  222. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +20 -32
  223. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +81 -113
  224. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +31 -42
  225. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +32 -44
  226. package/packages/apra-fleet-se/apra-pm/agents/planner.md +51 -63
  227. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +65 -80
  228. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +56 -83
  229. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
  230. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
  231. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
  232. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
  233. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +0 -1
  234. package/packages/apra-fleet-se/bin/cli.mjs +132 -3
  235. package/packages/apra-fleet-se/bin/serve.mjs +36 -1
  236. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +151 -33
  237. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +22 -7
  238. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
  239. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +9 -4
  240. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +2 -2
  241. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
  242. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
  243. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
  244. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +67 -16
  245. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +41 -0
  246. package/packages/apra-fleet-se/fleet-sprint/runner.js +1140 -209
  247. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
  248. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
  249. package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
  250. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
  251. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +2 -1
  252. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
  253. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
  254. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
  255. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -43
  256. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
  257. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
  258. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +92 -37
  259. package/packages/apra-fleet-workflow/src/viewer/index.mjs +167 -1
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +435 -31
  261. package/skills/fleet/SKILL.md +20 -9
  262. package/skills/fleet/auth-azdevops.md +44 -5
  263. package/skills/fleet/auth-bitbucket.md +3 -3
  264. package/skills/fleet/auth-github.md +2 -2
  265. package/skills/fleet/beads-conflict-resolution.md +141 -0
  266. package/skills/fleet/beads.md +16 -12
  267. package/skills/fleet/onboarding.md +4 -4
  268. package/skills/fleet/permissions.md +6 -6
  269. package/skills/fleet/skill-matrix.md +1 -1
  270. package/skills/fleet/troubleshooting.md +2 -1
  271. package/version.json +1 -1
  272. package/dist/providers/gemini.d.ts +0 -52
  273. package/dist/providers/gemini.d.ts.map +0 -1
  274. package/dist/providers/gemini.js +0 -236
  275. package/dist/providers/gemini.js.map +0 -1
  276. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
@@ -0,0 +1,134 @@
1
+ // se-os-commands.mjs -- the one place fleet-sprint and the supervisor ask
2
+ // "what does a command string look like for THIS member?".
3
+ //
4
+ // Same package as its callers, imported directly: no REST hop, no IPC, no
5
+ // build step, and no dependency on apra-fleet core (which ships as a compiled
6
+ // binary, while these files ship as open user-copyable source).
7
+ //
8
+ // ---------------------------------------------------------------------------
9
+ // WHY THESE PRIMITIVES AND NO OTHERS
10
+ //
11
+ // The set is derived from the member-bound strings this package actually
12
+ // builds today, not from a general model of a shell:
13
+ //
14
+ // wrapForMember runner.js's local PowerShell envelope builder (the
15
+ // only ad-hoc PowerShell builder in the runner) and
16
+ // its git-credential call site.
17
+ // readCredentialHelper runner.js buildCredentialReadCommand(os, label) --
18
+ // the runner's only OS-branched member-bound command.
19
+ // credentialHelperPath the readable descriptor that same function returns
20
+ // for its error messages.
21
+ // homePath dolt-settle.mjs's member-side dolt path
22
+ // ("$env:USERPROFILE\.apra-fleet\bin\dolt.exe" vs
23
+ // "$HOME/.apra-fleet/bin/dolt").
24
+ // invoke dolt-settle.mjs's invokeBinary(): PowerShell needs
25
+ // the call operator, POSIX must not have it.
26
+ // escapeSqlArg dolt-settle.mjs's escapeSqlForShell(): quotes a SQL
27
+ // string as one double-quoted shell argument. Added
28
+ // (apra-fleet-7dir.20) as a narrow exception to the
29
+ // "no argument quoting" exclusion below, because its
30
+ // call site picked dialect off a bare `platform ===
31
+ // 'win32'` flag -- wrong for a Windows member whose
32
+ // registered shell is gitbash, which needs bash
33
+ // escaping, not PowerShell's. Unlike the excluded
34
+ // GitHub-provider quoting, this call site is
35
+ // genuinely shell-shaped (its two dialects differ
36
+ // because bash and PowerShell disagree about `,
37
+ // $ and \\ inside double quotes) and has exactly the
38
+ // shape every other primitive in this module has:
39
+ // one member-bound string, two dialects, resolved
40
+ // through getSeCommands. General argument quoting
41
+ // otherwise stays out for the reasons below.
42
+ // wrapPowerShellScript dolt-settle.mjs's installPinnedDolt/
43
+ // killProcessAtPath/spawnEphemeralServer (Sections
44
+ // 3/4): whole PowerShell SCRIPTS with no safe bash
45
+ // equivalent worth inventing (Invoke-WebRequest/
46
+ // Expand-Archive install, Get-Process/Stop-Process
47
+ // kill, Invoke-CimMethod Win32_Process spawn --
48
+ // the last one's own header records that
49
+ // Start-Process/schtasks were verified live to die
50
+ // with the SSH session, so the script body itself
51
+ // is not something to casually replace). Added
52
+ // (apra-fleet-7dir.21) because a Windows member
53
+ // whose registered shell is gitbash still HAS a
54
+ // PowerShell interpreter available -- per the repo
55
+ // CLAUDE.md rule ("Wrap PowerShell commands
56
+ // explicitly... rather than assuming the member's
57
+ // shell"), the fix is to keep the live-verified
58
+ // PowerShell script bodies unchanged and invoke
59
+ // them FROM bash via `-EncodedCommand`, not to
60
+ // rewrite them in bash. SeWindowsCommands returns
61
+ // the script unchanged (its own shell already IS
62
+ // PowerShell); SeWindowsGitbashCommands wraps it as
63
+ // a bash-invocable `powershell -EncodedCommand
64
+ // <base64 utf16le>` string; SePosixCommands throws
65
+ // (a true POSIX member has no PowerShell to hand
66
+ // the script to at all).
67
+ //
68
+ // Deliberately NOT included, so this stays an interface rather than a
69
+ // catalogue:
70
+ // - argument quoting and the curl/curl.exe binary choice: their only call
71
+ // site is the GitHub VCS provider, and provider-specific logic belongs
72
+ // behind the provider descriptor hooks, never in a shared module.
73
+ // - work-folder wrapping and PID capture: apra-fleet core's execute_command
74
+ // applies both server-side. No file in this package builds either -- the
75
+ // runner only MENTIONS them in comments describing what core does. A
76
+ // primitive here would have no caller.
77
+ // - credential file WRITE: core's provision_vcs_auth owns the write side;
78
+ // this package only ever reads the deployed helper back.
79
+ //
80
+ // The supervisor was audited too: its only shell text is a local
81
+ // process-inspection call on the supervisor's OWN host (wmic / Get-CimInstance
82
+ // / ps, chosen from process.platform), never a member-bound command string, so
83
+ // it needs nothing of its own from this module.
84
+ // ---------------------------------------------------------------------------
85
+
86
+ import { SePosixCommands } from './se-posix.mjs';
87
+ import { SeWindowsCommands } from './se-windows.mjs';
88
+ import { SeWindowsGitbashCommands } from './se-windows-gitbash.mjs';
89
+
90
+ export { SePosixCommands } from './se-posix.mjs';
91
+ export { SeWindowsCommands } from './se-windows.mjs';
92
+ export { SeWindowsGitbashCommands } from './se-windows-gitbash.mjs';
93
+
94
+ const posix = new SePosixCommands();
95
+ const windowsPowerShell = new SeWindowsCommands();
96
+ const windowsGitbash = new SeWindowsGitbashCommands();
97
+
98
+ /** Normalize whatever a caller has to hand into { os, shell }. */
99
+ function normalizeTarget(target) {
100
+ if (typeof target === 'string') return { os: target.trim().toLowerCase(), shell: '' };
101
+ const os = String((target && target.os) || '').trim().toLowerCase();
102
+ const shell = String((target && target.shell) || '').trim().toLowerCase();
103
+ return { os, shell };
104
+ }
105
+
106
+ /**
107
+ * Resolve the command primitives for a member.
108
+ *
109
+ * Accepts either a member record shape ({ os, shell } -- exactly the two
110
+ * fields member_detail exposes) or a bare OS string, so existing callers that
111
+ * only know the OS can adopt this without first widening their resolver.
112
+ *
113
+ * A member whose OS cannot be determined resolves to POSIX: that is the
114
+ * historical behaviour of every string this module replaces, and keeping it
115
+ * means an unresolvable member degrades exactly as it does today rather than
116
+ * silently switching dialect.
117
+ *
118
+ * @param {{ os?: string, shell?: string }|string} target
119
+ * @returns {SePosixCommands|SeWindowsCommands}
120
+ */
121
+ export function getSeCommands(target) {
122
+ const { os, shell } = normalizeTarget(target);
123
+ if (os === 'windows' || os === 'win32') {
124
+ if (shell === 'gitbash') return windowsGitbash;
125
+ // A Windows member with no recorded shell (or any shell other than
126
+ // gitbash) is a PowerShell member: that is what every Windows member was
127
+ // assumed to be before shells were recorded, so it must stay
128
+ // byte-identical.
129
+ return windowsPowerShell;
130
+ }
131
+ return posix;
132
+ }
133
+
134
+ export default getSeCommands;
@@ -0,0 +1,154 @@
1
+ // se-posix.mjs -- POSIX (linux/darwin) member-bound command primitives for
2
+ // fleet-sprint and the supervisor.
3
+ //
4
+ // This is fleet-sprint's OWN shell layer, deliberately NOT shared with
5
+ // apra-fleet core's src/os/*.ts: core ships as a compiled binary while these
6
+ // files ship as open, user-copyable source, and fleet-sprint is meant to stay
7
+ // apra-fleet-agnostic. The `se-` filename prefix keeps them from being
8
+ // confused with the core-side modules. Nothing here imports apra-fleet core,
9
+ // and nothing here needs a build step -- plain ESM that Node runs as-is.
10
+ //
11
+ // SCOPE OF THE PRIMITIVE SET: every method below exists because a real
12
+ // member-bound call site in this package builds that string today. See
13
+ // se-os-commands.mjs's header for the call-site inventory. Primitives are
14
+ // added when a call site needs one, never speculatively.
15
+ //
16
+ // HOUSE RULE THIS LAYER ENFORCES: a member-bound command string must not rely
17
+ // on the ORCHESTRATOR's shell or filesystem -- paths are resolved in
18
+ // JavaScript, and the only shell-level expansion that survives is the member's
19
+ // own home-directory token ($HOME here, $env:USERPROFILE on the PowerShell
20
+ // side). That single exception is deliberate and load-bearing: the credential
21
+ // helper file was WRITTEN by apra-fleet core using exactly that token, so the
22
+ // read must resolve the home directory the same way the write did rather than
23
+ // through an independently probed path.
24
+
25
+ /**
26
+ * POSIX command primitives. Also the base class the Git-for-Windows bash
27
+ * implementation extends -- a gitbash member receives bash strings, so the
28
+ * whole surface below is correct for it apart from genuinely Windows-native
29
+ * details.
30
+ */
31
+ export class SePosixCommands {
32
+ /** Stable identifier for logging/tests. */
33
+ get shell() {
34
+ return 'posix';
35
+ }
36
+
37
+ /**
38
+ * Suffix of the deployed git-credential-helper file. Empty on POSIX: core's
39
+ * linux implementation writes an extensionless executable script. Overridden
40
+ * where the helper is a Windows .bat.
41
+ */
42
+ get credentialHelperSuffix() {
43
+ return '';
44
+ }
45
+
46
+ /**
47
+ * Envelope for a command dispatched to the member. POSIX needs none -- the
48
+ * string is already in the member's own dialect -- so this is deliberately
49
+ * the identity function, which is what keeps every historical POSIX command
50
+ * string byte-identical.
51
+ * @param {string} script
52
+ * @returns {string}
53
+ */
54
+ wrapForMember(script) {
55
+ return String(script);
56
+ }
57
+
58
+ /**
59
+ * A path under the MEMBER's home directory. `$HOME` (not `~`) matches what
60
+ * core's linux gitCredentialHelperWrite() wrote.
61
+ * @param {string} relative
62
+ * @returns {string}
63
+ */
64
+ homePath(relative) {
65
+ const rel = String(relative).replace(/^[\\/]+/, '');
66
+ return `$HOME/${rel}`;
67
+ }
68
+
69
+ /**
70
+ * Invoke an executable at `path` with `args`.
71
+ *
72
+ * QUOTING CONTRACT (differs per implementation on purpose -- pass `path`
73
+ * UNQUOTED): POSIX emits the path token verbatim, adding no quoting, because
74
+ * the historical credential-read command is a bare unquoted `$HOME/...`
75
+ * string that must stay byte-identical. The PowerShell implementation adds
76
+ * both the call operator and double quotes, without which PowerShell merely
77
+ * echoes the path back as a string and the failure looks like success.
78
+ * @param {string} path unquoted; POSIX callers needing quotes add them
79
+ * @param {string} [args]
80
+ * @returns {string}
81
+ */
82
+ invoke(path, args = '') {
83
+ const suffix = String(args || '').trim();
84
+ return suffix ? `${path} ${suffix}` : String(path);
85
+ }
86
+
87
+ /**
88
+ * Member-side path of the git-credential-helper file apra-fleet core's
89
+ * provision_vcs_auth deployed. fleet-sprint only ever READS this file; the
90
+ * write side belongs to core.
91
+ * @param {string} label
92
+ * @returns {string}
93
+ */
94
+ credentialHelperPath(label) {
95
+ return this.homePath(`.fleet-git-credential-${label}${this.credentialHelperSuffix}`);
96
+ }
97
+
98
+ /**
99
+ * The command that RUNS the credential helper (so its "password=<token>"
100
+ * line reaches stdout) plus a human-readable descriptor for error messages
101
+ * -- on the PowerShell side the command itself is an opaque base64 blob, so
102
+ * the descriptor has to carry the readable path.
103
+ *
104
+ * NOTE: the POSIX label is intentionally NOT validated. The historical
105
+ * string is a bare, unquoted `$HOME/...` path and must stay byte-identical
106
+ * for every non-Windows member; adding validation here would change
107
+ * behaviour for callers that have worked for a long time. The PowerShell
108
+ * implementation, which is newer, does validate.
109
+ * @param {string} label
110
+ * @returns {{ command: string, descriptor: string }}
111
+ */
112
+ readCredentialHelper(label) {
113
+ const descriptor = this.credentialHelperPath(label);
114
+ return { command: this.wrapForMember(this.invoke(descriptor)), descriptor };
115
+ }
116
+
117
+ /**
118
+ * Escape a SQL string so it survives as ONE double-quoted argument in the
119
+ * member's shell. Backticks and `$` are the dangerous characters: bash
120
+ * treats a backtick inside double quotes as command substitution, so both
121
+ * backslash and backtick are backslash-escaped, along with `$` and `"`.
122
+ * Byte-identical to dolt-settle.mjs's escapeSqlForShell('linux', sql).
123
+ * @param {string} sql
124
+ * @returns {string}
125
+ */
126
+ escapeSqlArg(sql) {
127
+ const bq = String.fromCharCode(96);
128
+ return String(sql)
129
+ .replace(/\\/g, '\\\\')
130
+ .split(bq).join('\\' + bq)
131
+ .replace(/\$/g, '\\$')
132
+ .replace(/"/g, '\\"');
133
+ }
134
+
135
+ /**
136
+ * A POSIX member has no PowerShell -- there is nothing this method could
137
+ * correctly return (returning the script unchanged would hand a bash
138
+ * interpreter raw PowerShell text and fail confusingly; inventing a bash
139
+ * translation would violate the design decision pinned on this primitive,
140
+ * which is to keep the live-verified PowerShell body and only change how
141
+ * it is INVOKED). So the base implementation throws a clear, loud error
142
+ * naming the caller, rather than silently returning something that runs
143
+ * the wrong interpreter (apra-fleet-7dir.21). SeWindowsCommands and
144
+ * SeWindowsGitbashCommands both override this with a real implementation.
145
+ * @param {string} _script
146
+ * @param {string} [callerName] name of the calling function/site, for the error message
147
+ * @returns {never}
148
+ */
149
+ wrapPowerShellScript(_script, callerName = 'wrapPowerShellScript caller') {
150
+ throw new Error(`${callerName}: cannot wrap a PowerShell script for a POSIX member -- this member has no PowerShell interpreter to invoke it with.`);
151
+ }
152
+ }
153
+
154
+ export default SePosixCommands;
@@ -0,0 +1,97 @@
1
+ // se-windows-gitbash.mjs -- member-bound command primitives for a Windows
2
+ // member whose registered shell is Git-for-Windows bash (`shell: 'gitbash'`).
3
+ //
4
+ // EXTENDS SePosixCommands (not SeWindowsCommands): what this member's shell
5
+ // actually receives is a *bash* command string, so the whole POSIX surface
6
+ // (wrapForMember's identity passthrough, homePath's `$HOME/...` form, invoke's
7
+ // unquoted-path contract, readCredentialHelper's unvalidated label) is correct
8
+ // as-is and is inherited verbatim -- Git for Windows sets `$HOME` to the same
9
+ // user-profile directory `$env:USERPROFILE` resolves to, so no path-root
10
+ // override is needed. This mirrors the extends-based reuse shape used on the
11
+ // core side by src/os/windows-gitbash.ts (which extends LinuxCommands for the
12
+ // identical reason), even though the two implementations share no code.
13
+ //
14
+ // The ONLY genuinely Windows-native detail left is the deployed
15
+ // git-credential-helper's file suffix: apra-fleet core's Windows
16
+ // gitCredentialHelperWrite (both the PowerShell and the gitbash variant --
17
+ // see src/os/windows-gitbash.ts's gitCredentialHelperWrite, which writes
18
+ // "$HOME/${credFileName}.bat") always writes a native Windows `.bat` helper,
19
+ // never the extensionless POSIX script SePosixCommands assumes. Everything
20
+ // else -- wrapForMember, homePath, invoke, credentialHelperPath,
21
+ // readCredentialHelper -- inherits unchanged from se-posix.mjs; duplicating
22
+ // any of those bodies here would just be bash-string-building drift waiting
23
+ // to happen.
24
+ //
25
+ // PID capture is deliberately NOT overridden here: se-os-commands.mjs's
26
+ // header audit found no call site in this package that builds a PID-capture
27
+ // command string (apra-fleet core's execute_command applies that server-side
28
+ // for every member OS), so there is no primitive to override.
29
+ //
30
+ // wrapPowerShellScript IS overridden here, even though this class extends
31
+ // SePosixCommands: a handful of member-bound scripts (dolt-settle.mjs's
32
+ // installPinnedDolt/killProcessAtPath/spawnEphemeralServer) are whole
33
+ // PowerShell scripts with no safe bash equivalent, so this member -- despite
34
+ // its own shell being bash -- still needs a way to invoke real PowerShell
35
+ // for them (apra-fleet-7dir.21). See that method's own doc comment for the
36
+ // full design rationale.
37
+
38
+ import { SePosixCommands } from './se-posix.mjs';
39
+
40
+ /**
41
+ * Bash command primitives for a Windows member running Git-for-Windows bash.
42
+ */
43
+ export class SeWindowsGitbashCommands extends SePosixCommands {
44
+ /** Stable identifier for logging/tests. */
45
+ get shell() {
46
+ return 'gitbash';
47
+ }
48
+
49
+ /**
50
+ * The deployed git-credential helper on ANY Windows member is a native
51
+ * `.bat` (git.exe execs it directly), even when the member's own shell is
52
+ * bash -- see src/os/windows-gitbash.ts's gitCredentialHelperWrite, which
53
+ * writes "$HOME/${credFileName}.bat" rather than the extensionless
54
+ * `#!/bin/sh` script SePosixCommands.credentialHelperSuffix assumes.
55
+ */
56
+ get credentialHelperSuffix() {
57
+ return '.bat';
58
+ }
59
+
60
+ /**
61
+ * Wrap a whole PowerShell SCRIPT (not a single command string) into a
62
+ * bash-invocable form, for the handful of member-bound scripts that have
63
+ * no safe bash equivalent (installPinnedDolt's Invoke-WebRequest/
64
+ * Expand-Archive install, killProcessAtPath's Get-Process/Stop-Process
65
+ * pipeline, spawnEphemeralServer's Invoke-CimMethod Win32_Process spawn --
66
+ * see dolt-settle.mjs). This member's OWN shell is bash (that is what
67
+ * `shell: 'gitbash'` means), but per the repo CLAUDE.md rule ("Wrap
68
+ * PowerShell commands explicitly... rather than assuming the member's
69
+ * shell") a Windows gitbash member still HAS a PowerShell interpreter
70
+ * available, so the live-verified PowerShell script bodies are kept
71
+ * as-is and invoked FROM bash, never rewritten in bash.
72
+ *
73
+ * `-EncodedCommand` (base64 UTF-16LE) is used rather than `-Command`
74
+ * specifically because it removes every quoting interaction between bash
75
+ * and PowerShell -- a script containing double quotes, `$` or backticks
76
+ * would otherwise need bash-safe AND PowerShell-safe quoting
77
+ * simultaneously, which the two dialects cannot agree on (see
78
+ * dolt-settle.mjs's own Section 1b header for concrete examples of that
79
+ * disagreement). Decoding the base64 blob as UTF-16LE reproduces the
80
+ * original script exactly.
81
+ *
82
+ * NON-OBVIOUS: inside the wrapped script the dialect is STILL PowerShell,
83
+ * never this member's own bash -- paths and escaping inside `script` must
84
+ * keep the PowerShell form ($env:USERPROFILE\..., backtick escaping) even
85
+ * though this member's shell is bash. This override only changes how the
86
+ * script is INVOKED, never what it contains.
87
+ *
88
+ * @param {string} script a whole PowerShell script body
89
+ * @returns {string} a bash-safe command line that runs it via PowerShell
90
+ */
91
+ wrapPowerShellScript(script) {
92
+ const encoded = Buffer.from(String(script), 'utf16le').toString('base64');
93
+ return `powershell -NoProfile -EncodedCommand ${encoded}`;
94
+ }
95
+ }
96
+
97
+ export default SeWindowsGitbashCommands;
@@ -0,0 +1,143 @@
1
+ // se-windows.mjs -- PowerShell member-bound command primitives for a Windows
2
+ // member with no Git-for-Windows bash shell recorded.
3
+ //
4
+ // Deliberately NOT a subclass of SePosixCommands: what this member's shell
5
+ // receives is PowerShell text, so essentially nothing on the POSIX surface is
6
+ // reusable. (The Git-for-Windows implementation is the opposite case -- it
7
+ // receives bash text and therefore does extend the POSIX base.)
8
+ //
9
+ // Like its sibling, this file imports nothing from apra-fleet core and needs
10
+ // no build step. The PowerShell envelope below is a deliberate MIRROR of
11
+ // core's src/os/windows.ts wrapPowerShellEncoded(), not a reuse of it: this
12
+ // package cannot import core.
13
+
14
+ /**
15
+ * PowerShell command primitives for a Windows member.
16
+ */
17
+ export class SeWindowsCommands {
18
+ /** Stable identifier for logging/tests. */
19
+ get shell() {
20
+ return 'powershell';
21
+ }
22
+
23
+ /**
24
+ * The deployed git-credential helper is a .bat on a PowerShell Windows
25
+ * member (core's windows gitCredentialHelperWrite writes
26
+ * "$env:USERPROFILE\.fleet-git-credential-<label>.bat").
27
+ */
28
+ get credentialHelperSuffix() {
29
+ return '.bat';
30
+ }
31
+
32
+ /**
33
+ * Wrap a PowerShell script into the envelope this package dispatches to a
34
+ * Windows member.
35
+ *
36
+ * Every part of this shape is load-bearing:
37
+ * - `$ErrorActionPreference = 'Stop'` + try/catch makes a NON-TERMINATING
38
+ * PowerShell failure surface as a non-zero exit instead of a false
39
+ * success;
40
+ * - `-EncodedCommand` (base64 UTF-16LE) removes every quoting question
41
+ * about which shell the transport hands the string to -- it is valid to
42
+ * launch from PowerShell or from cmd.exe;
43
+ * - the `$LASTEXITCODE` check before the trailing `exit 0` preserves a
44
+ * NATIVE command's exit code (e.g. the credential-helper .bat invoked
45
+ * below) that the trailing `exit 0` would otherwise mask -- without it a
46
+ * broken helper reports success with no `password=` line.
47
+ *
48
+ * Byte-identical to the string runner.js builds today.
49
+ * @param {string} script
50
+ * @returns {string}
51
+ */
52
+ wrapForMember(script) {
53
+ const guarded = `$ErrorActionPreference = 'Stop'; try { ${script}; if ($LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; exit 0 } catch { Write-Error $_; exit 1 }`;
54
+ return `powershell -EncodedCommand ${Buffer.from(guarded, 'utf16le').toString('base64')}`;
55
+ }
56
+
57
+ /**
58
+ * A path under the MEMBER's home directory, expanded ON THE MEMBER.
59
+ * `$env:USERPROFILE` rather than a JavaScript-resolved home path is
60
+ * deliberate and is the one shell expansion this layer permits: core's
61
+ * Windows credential write used exactly this token, so an independently
62
+ * probed home could point somewhere the file was never written.
63
+ * @param {string} relative
64
+ * @returns {string}
65
+ */
66
+ homePath(relative) {
67
+ const rel = String(relative).replace(/^[\\/]+/, '').replace(/\//g, '\\');
68
+ return `$env:USERPROFILE\\${rel}`;
69
+ }
70
+
71
+ /**
72
+ * Invoke an executable with PowerShell's call operator, so PowerShell
73
+ * EXECUTES it instead of echoing the quoted path back as a string (which
74
+ * exits 0 and looks like success).
75
+ *
76
+ * Pass `path` UNQUOTED: this adds the double quotes itself (the POSIX
77
+ * implementation deliberately adds none -- see its quoting contract).
78
+ * @param {string} path unquoted
79
+ * @param {string} [args]
80
+ * @returns {string}
81
+ */
82
+ invoke(path, args = '') {
83
+ const suffix = String(args || '').trim();
84
+ return suffix ? `& "${path}" ${suffix}` : `& "${path}"`;
85
+ }
86
+
87
+ /**
88
+ * @param {string} label
89
+ * @returns {string}
90
+ */
91
+ credentialHelperPath(label) {
92
+ return this.homePath(`.fleet-git-credential-${label}${this.credentialHelperSuffix}`);
93
+ }
94
+
95
+ /**
96
+ * Unlike the POSIX branch (kept unvalidated for byte-identical
97
+ * back-compat), the label here is interpolated into a PowerShell
98
+ * double-quoted string and a filename, so shell metacharacters are refused
99
+ * outright.
100
+ * @param {string} label
101
+ * @returns {{ command: string, descriptor: string }}
102
+ */
103
+ readCredentialHelper(label) {
104
+ if (!/^[A-Za-z0-9._-]+$/.test(String(label))) {
105
+ throw new Error(`Refusing to build a Windows credential-read command for unsafe VCS credential label '${label}' (allowed: letters, digits, '.', '_', '-').`);
106
+ }
107
+ const descriptor = this.credentialHelperPath(label);
108
+ return { command: this.wrapForMember(this.invoke(descriptor)), descriptor };
109
+ }
110
+
111
+ /**
112
+ * Escape a SQL string so it survives as ONE double-quoted argument in
113
+ * PowerShell. A backtick is PowerShell's escape character: a literal
114
+ * backtick is a doubled backtick, a literal quote is `` `" ``, and a
115
+ * literal `$` is `` `$ `` (otherwise PowerShell expands it as a variable).
116
+ * Byte-identical to dolt-settle.mjs's escapeSqlForShell('win32', sql).
117
+ * @param {string} sql
118
+ * @returns {string}
119
+ */
120
+ escapeSqlArg(sql) {
121
+ const bq = String.fromCharCode(96);
122
+ return String(sql)
123
+ .split(bq).join(bq + bq)
124
+ .replace(/\$/g, `${bq}$`)
125
+ .replace(/"/g, `${bq}"`);
126
+ }
127
+
128
+ /**
129
+ * This member's OWN shell already IS PowerShell, so a script destined for
130
+ * it needs no envelope at all -- returning it unchanged is what keeps
131
+ * every non-gitbash Windows member's dispatched script byte-identical to
132
+ * today (apra-fleet-7dir.21). Contrast with SeWindowsGitbashCommands'
133
+ * override, which DOES need to wrap the same script for a bash shell to
134
+ * invoke it.
135
+ * @param {string} script
136
+ * @returns {string}
137
+ */
138
+ wrapPowerShellScript(script) {
139
+ return String(script);
140
+ }
141
+ }
142
+
143
+ export default SeWindowsCommands;
@@ -36,7 +36,8 @@ on this list -- flags evolve and this skill can drift.
36
36
  ## Flag notes
37
37
 
38
38
  - `--issue` takes comma-separated **beads parent/epic IDs**. Scope is
39
- resolved internally via `bd list --parent <id>`, so it only ever
39
+ resolved internally by walking the parent-child tree down from each target
40
+ id (every descendant at any depth, any status), so it only ever
40
41
  understands the parent-child hierarchy. A `blocked-by`-only manifest bead
41
42
  is invisible to the scope filter no matter what you pass -- only true
42
43
  children are picked up. See the epics/manifest-bead guidance in
@@ -404,8 +404,59 @@ export function capabilities(remoteUrl) {
404
404
  return { hasRemote: true, canOpenPullRequest: !!providerCaps.canOpenPullRequest, host: parsed.host };
405
405
  }
406
406
 
407
+ /**
408
+ * Resolve a git remote URL into the repository coordinates its OWN provider
409
+ * defines, by dispatching to that provider's optional parseRepoRef() hook
410
+ * (apra-fleet-5co8.1.2). This is the shared half of the remote-URL axis: the
411
+ * host is parsed here, the provider is chosen by the registry, and every
412
+ * provider-specific rule -- which URL shapes are legal, what the coordinates
413
+ * are called, what shape to tell the operator to use -- lives in the provider
414
+ * file, so no caller (runner.js in particular) needs a provider conditional.
415
+ *
416
+ * Three outcomes, deliberately distinct so a caller can tell "not my business"
417
+ * apart from "your remote is wrong":
418
+ * - null no provider claims this host, or the claiming provider
419
+ * has no parseRepoRef hook. The caller keeps its own
420
+ * generic owner/repo parse -- behavior unchanged for
421
+ * GitHub and every other provider.
422
+ * - { canonical, ref, provider }
423
+ * the provider recognized the remote; `canonical` is its
424
+ * display/identity key (e.g. org/project/repo for Azure
425
+ * DevOps) and `ref` the full coordinate object.
426
+ * - { error } the provider CLAIMS this host but does not recognize the
427
+ * URL -- a malformed remote, not an unknown one. A typed
428
+ * 'ERROR: ' string naming the shape the provider expects
429
+ * (its optional `repoRefHint`), for the caller to surface
430
+ * as a preflight failure rather than proceeding with
431
+ * half-parsed coordinates.
432
+ *
433
+ * @param {unknown} remoteUrl
434
+ * @returns {{ canonical: string, ref: object, provider: string }|{ error: string }|null}
435
+ */
436
+ export function parseProviderRepoRef(remoteUrl) {
437
+ const url = String(remoteUrl ?? '').trim();
438
+ const parsed = parseRemote(url);
439
+ if (!parsed || !parsed.host) return null;
440
+
441
+ const provider = resolveVcsProviderForHost(parsed.host);
442
+ if (!provider || typeof provider.parseRepoRef !== 'function') return null;
443
+
444
+ const ref = provider.parseRepoRef(url);
445
+ if (ref && typeof ref.canonical === 'string' && ref.canonical) {
446
+ return { canonical: ref.canonical, ref, provider: provider.name };
447
+ }
448
+
449
+ const hint = (typeof provider.repoRefHint === 'string' && provider.repoRefHint.trim())
450
+ ? provider.repoRefHint.trim()
451
+ : '(this provider documents no expected remote shape)';
452
+ return {
453
+ error: `ERROR: git remote '${url}' is claimed by VCS provider '${provider.name}' but is not a repository URL it recognizes; expected the shape ${hint}`,
454
+ };
455
+ }
456
+
407
457
  export const VCSModule = {
408
458
  buildCreatePrCommand,
459
+ parseProviderRepoRef,
409
460
  buildCommentCommand,
410
461
  classifyFailure,
411
462
  toGitVerdict,