@maiaos/cli 0.1.0-canary.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 (413) hide show
  1. package/README.md +287 -0
  2. package/dist/bin/maia.NOTICES.txt +59 -0
  3. package/dist/bin/maia.cdx.json +145 -0
  4. package/dist/bin/maia.mjs +2 -0
  5. package/dist/bootstrap/index.d.ts +3 -0
  6. package/dist/bootstrap/index.js +3 -0
  7. package/dist/bootstrap/process.d.ts +5 -0
  8. package/dist/bootstrap/process.js +45 -0
  9. package/dist/bootstrap/run.d.ts +25 -0
  10. package/dist/bootstrap/run.js +95 -0
  11. package/dist/bootstrap/stdio.d.ts +4 -0
  12. package/dist/bootstrap/stdio.js +9 -0
  13. package/dist/cli/cli.d.ts +17 -0
  14. package/dist/cli/cli.js +481 -0
  15. package/dist/cli/environment.d.ts +8 -0
  16. package/dist/cli/environment.js +12 -0
  17. package/dist/cli/index.d.ts +2 -0
  18. package/dist/cli/index.js +2 -0
  19. package/dist/cli/services.d.ts +4 -0
  20. package/dist/cli/services.js +4 -0
  21. package/dist/command-line/context.d.ts +178 -0
  22. package/dist/command-line/context.js +2 -0
  23. package/dist/command-line/index.d.ts +7 -0
  24. package/dist/command-line/index.js +6 -0
  25. package/dist/command-line/input/arguments.d.ts +55 -0
  26. package/dist/command-line/input/arguments.js +220 -0
  27. package/dist/command-line/input/index.d.ts +4 -0
  28. package/dist/command-line/input/index.js +4 -0
  29. package/dist/command-line/input/prompt.d.ts +8 -0
  30. package/dist/command-line/input/prompt.js +44 -0
  31. package/dist/command-line/input/stdin-stream.d.ts +4 -0
  32. package/dist/command-line/input/stdin-stream.js +3 -0
  33. package/dist/command-line/input/stdin.d.ts +11 -0
  34. package/dist/command-line/input/stdin.js +23 -0
  35. package/dist/command-line/json-decoder.d.ts +3 -0
  36. package/dist/command-line/json-decoder.js +3 -0
  37. package/dist/command-line/json.d.ts +3 -0
  38. package/dist/command-line/json.js +4 -0
  39. package/dist/command-line/output.d.ts +57 -0
  40. package/dist/command-line/output.js +94 -0
  41. package/dist/command-line/rows.d.ts +10 -0
  42. package/dist/command-line/rows.js +32 -0
  43. package/dist/command-line/two-phase.d.ts +57 -0
  44. package/dist/command-line/two-phase.js +148 -0
  45. package/dist/command-receipt/command.d.ts +4 -0
  46. package/dist/command-receipt/command.js +59 -0
  47. package/dist/command-receipt/compact-list.d.ts +20 -0
  48. package/dist/command-receipt/compact-list.js +29 -0
  49. package/dist/command-receipt/index.d.ts +3 -0
  50. package/dist/command-receipt/index.js +3 -0
  51. package/dist/command-tree/commands.d.ts +17 -0
  52. package/dist/command-tree/commands.js +41 -0
  53. package/dist/command-tree/completion.d.ts +6 -0
  54. package/dist/command-tree/completion.js +36 -0
  55. package/dist/command-tree/grammar.d.ts +18 -0
  56. package/dist/command-tree/grammar.js +160 -0
  57. package/dist/command-tree/help.d.ts +62 -0
  58. package/dist/command-tree/help.js +219 -0
  59. package/dist/command-tree/index.d.ts +8 -0
  60. package/dist/command-tree/index.js +6 -0
  61. package/dist/command-tree/local.d.ts +3 -0
  62. package/dist/command-tree/local.js +126 -0
  63. package/dist/command-tree/placeholder.d.ts +3 -0
  64. package/dist/command-tree/placeholder.js +4 -0
  65. package/dist/command-tree/row.d.ts +29 -0
  66. package/dist/command-tree/row.js +2 -0
  67. package/dist/command-tree/suggest.d.ts +3 -0
  68. package/dist/command-tree/suggest.js +81 -0
  69. package/dist/command-tree/tree.d.ts +34 -0
  70. package/dist/command-tree/tree.js +124 -0
  71. package/dist/connection/client.d.ts +692 -0
  72. package/dist/connection/client.js +28 -0
  73. package/dist/connection/commands.d.ts +15 -0
  74. package/dist/connection/commands.js +118 -0
  75. package/dist/connection/index.d.ts +7 -0
  76. package/dist/connection/index.js +7 -0
  77. package/dist/connection/input.d.ts +50 -0
  78. package/dist/connection/input.js +90 -0
  79. package/dist/connection/login.d.ts +13 -0
  80. package/dist/connection/login.js +69 -0
  81. package/dist/connection/output/format.d.ts +32 -0
  82. package/dist/connection/output/format.js +94 -0
  83. package/dist/connection/output/index.d.ts +2 -0
  84. package/dist/connection/output/index.js +2 -0
  85. package/dist/connection/resolve.d.ts +60 -0
  86. package/dist/connection/resolve.js +30 -0
  87. package/dist/connection/signin.d.ts +4 -0
  88. package/dist/connection/signin.js +32 -0
  89. package/dist/connection/system.d.ts +4 -0
  90. package/dist/connection/system.js +190 -0
  91. package/dist/connection/tree/index.d.ts +2 -0
  92. package/dist/connection/tree/index.js +2 -0
  93. package/dist/connection/tree/tree.d.ts +3 -0
  94. package/dist/connection/tree/tree.js +209 -0
  95. package/dist/container/client.d.ts +142 -0
  96. package/dist/container/client.js +11 -0
  97. package/dist/container/commands.d.ts +7 -0
  98. package/dist/container/commands.js +100 -0
  99. package/dist/container/index.d.ts +3 -0
  100. package/dist/container/index.js +3 -0
  101. package/dist/container/output/format.d.ts +11 -0
  102. package/dist/container/output/format.js +28 -0
  103. package/dist/container/output/index.d.ts +2 -0
  104. package/dist/container/output/index.js +2 -0
  105. package/dist/context/client.d.ts +7 -0
  106. package/dist/context/client.js +21 -0
  107. package/dist/context/commands.d.ts +3 -0
  108. package/dist/context/commands.js +27 -0
  109. package/dist/context/index.d.ts +3 -0
  110. package/dist/context/index.js +3 -0
  111. package/dist/development/cli.d.ts +3 -0
  112. package/dist/development/cli.js +44 -0
  113. package/dist/execution/client.d.ts +25 -0
  114. package/dist/execution/client.js +24 -0
  115. package/dist/execution/index.d.ts +3 -0
  116. package/dist/execution/index.js +3 -0
  117. package/dist/execution/relocation.d.ts +6 -0
  118. package/dist/execution/relocation.js +123 -0
  119. package/dist/execution/tree/index.d.ts +2 -0
  120. package/dist/execution/tree/index.js +2 -0
  121. package/dist/execution/tree/tree.d.ts +3 -0
  122. package/dist/execution/tree/tree.js +137 -0
  123. package/dist/hold/client.d.ts +137 -0
  124. package/dist/hold/client.js +12 -0
  125. package/dist/hold/commands.d.ts +5 -0
  126. package/dist/hold/commands.js +91 -0
  127. package/dist/hold/index.d.ts +3 -0
  128. package/dist/hold/index.js +3 -0
  129. package/dist/hold/output/format.d.ts +11 -0
  130. package/dist/hold/output/format.js +29 -0
  131. package/dist/hold/output/index.d.ts +2 -0
  132. package/dist/hold/output/index.js +2 -0
  133. package/dist/hold/tree/index.d.ts +2 -0
  134. package/dist/hold/tree/index.js +2 -0
  135. package/dist/hold/tree/tree.d.ts +3 -0
  136. package/dist/hold/tree/tree.js +96 -0
  137. package/dist/import/client.d.ts +14 -0
  138. package/dist/import/client.js +16 -0
  139. package/dist/import/commands.d.ts +5 -0
  140. package/dist/import/commands.js +76 -0
  141. package/dist/import/index.d.ts +3 -0
  142. package/dist/import/index.js +3 -0
  143. package/dist/import/input.d.ts +16 -0
  144. package/dist/import/input.js +92 -0
  145. package/dist/import/output.d.ts +6 -0
  146. package/dist/import/output.js +40 -0
  147. package/dist/index.d.ts +2 -0
  148. package/dist/index.js +2 -0
  149. package/dist/integration/client.d.ts +1284 -0
  150. package/dist/integration/client.js +24 -0
  151. package/dist/integration/commands.d.ts +10 -0
  152. package/dist/integration/commands.js +104 -0
  153. package/dist/integration/index.d.ts +3 -0
  154. package/dist/integration/index.js +3 -0
  155. package/dist/integration/output.d.ts +22 -0
  156. package/dist/integration/output.js +20 -0
  157. package/dist/local-node/call.d.ts +7 -0
  158. package/dist/local-node/call.js +13 -0
  159. package/dist/local-node/client.d.ts +67 -0
  160. package/dist/local-node/client.js +241 -0
  161. package/dist/local-node/index.d.ts +3 -0
  162. package/dist/local-node/index.js +3 -0
  163. package/dist/login/agent-provider.d.ts +20 -0
  164. package/dist/login/agent-provider.js +109 -0
  165. package/dist/login/commands.d.ts +4 -0
  166. package/dist/login/commands.js +93 -0
  167. package/dist/login/failure.d.ts +3 -0
  168. package/dist/login/failure.js +14 -0
  169. package/dist/login/gateway.d.ts +12 -0
  170. package/dist/login/gateway.js +71 -0
  171. package/dist/login/index.d.ts +3 -0
  172. package/dist/login/index.js +2 -0
  173. package/dist/login/menu.d.ts +4 -0
  174. package/dist/login/menu.js +105 -0
  175. package/dist/login/output/format.d.ts +16 -0
  176. package/dist/login/output/format.js +31 -0
  177. package/dist/login/output/index.d.ts +2 -0
  178. package/dist/login/output/index.js +2 -0
  179. package/dist/login/vendor-account.d.ts +95 -0
  180. package/dist/login/vendor-account.js +75 -0
  181. package/dist/login/vendor-input.d.ts +14 -0
  182. package/dist/login/vendor-input.js +36 -0
  183. package/dist/mcp/calls.d.ts +7 -0
  184. package/dist/mcp/calls.js +202 -0
  185. package/dist/mcp/commands.d.ts +9 -0
  186. package/dist/mcp/commands.js +21 -0
  187. package/dist/mcp/index.d.ts +2 -0
  188. package/dist/mcp/index.js +2 -0
  189. package/dist/mcp/server.d.ts +11 -0
  190. package/dist/mcp/server.js +57 -0
  191. package/dist/orchestration/client.d.ts +78 -0
  192. package/dist/orchestration/client.js +89 -0
  193. package/dist/orchestration/commands.d.ts +14 -0
  194. package/dist/orchestration/commands.js +312 -0
  195. package/dist/orchestration/index.d.ts +3 -0
  196. package/dist/orchestration/index.js +3 -0
  197. package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
  198. package/dist/orchestration/output/compact-aggregate.js +110 -0
  199. package/dist/orchestration/output/compact-run-list.d.ts +20 -0
  200. package/dist/orchestration/output/compact-run-list.js +16 -0
  201. package/dist/orchestration/output/human.d.ts +80 -0
  202. package/dist/orchestration/output/human.js +252 -0
  203. package/dist/orchestration/output/index.d.ts +4 -0
  204. package/dist/orchestration/output/index.js +4 -0
  205. package/dist/orchestration/tree/index.d.ts +2 -0
  206. package/dist/orchestration/tree/index.js +2 -0
  207. package/dist/orchestration/tree/tree.d.ts +3 -0
  208. package/dist/orchestration/tree/tree.js +142 -0
  209. package/dist/port-lease/client.d.ts +160 -0
  210. package/dist/port-lease/client.js +11 -0
  211. package/dist/port-lease/commands.d.ts +6 -0
  212. package/dist/port-lease/commands.js +17 -0
  213. package/dist/port-lease/index.d.ts +3 -0
  214. package/dist/port-lease/index.js +3 -0
  215. package/dist/port-lease/input.d.ts +65 -0
  216. package/dist/port-lease/input.js +67 -0
  217. package/dist/port-lease/output/format.d.ts +11 -0
  218. package/dist/port-lease/output/format.js +24 -0
  219. package/dist/port-lease/output/index.d.ts +2 -0
  220. package/dist/port-lease/output/index.js +2 -0
  221. package/dist/presentation/client.d.ts +10 -0
  222. package/dist/presentation/client.js +9 -0
  223. package/dist/presentation/commands.d.ts +6 -0
  224. package/dist/presentation/commands.js +78 -0
  225. package/dist/presentation/index.d.ts +4 -0
  226. package/dist/presentation/index.js +3 -0
  227. package/dist/presentation/output/format.d.ts +11 -0
  228. package/dist/presentation/output/format.js +32 -0
  229. package/dist/presentation/output/index.d.ts +3 -0
  230. package/dist/presentation/output/index.js +2 -0
  231. package/dist/project-guard/client.d.ts +88 -0
  232. package/dist/project-guard/client.js +7 -0
  233. package/dist/project-guard/commands.d.ts +4 -0
  234. package/dist/project-guard/commands.js +39 -0
  235. package/dist/project-guard/index.d.ts +3 -0
  236. package/dist/project-guard/index.js +3 -0
  237. package/dist/project-guard/input.d.ts +18 -0
  238. package/dist/project-guard/input.js +47 -0
  239. package/dist/project-guard/output/format.d.ts +11 -0
  240. package/dist/project-guard/output/format.js +35 -0
  241. package/dist/project-guard/output/index.d.ts +2 -0
  242. package/dist/project-guard/output/index.js +2 -0
  243. package/dist/project-workspace/client.d.ts +86 -0
  244. package/dist/project-workspace/client.js +159 -0
  245. package/dist/project-workspace/commands.d.ts +30 -0
  246. package/dist/project-workspace/commands.js +700 -0
  247. package/dist/project-workspace/index.d.ts +5 -0
  248. package/dist/project-workspace/index.js +5 -0
  249. package/dist/project-workspace/metadata-client.d.ts +99 -0
  250. package/dist/project-workspace/metadata-client.js +8 -0
  251. package/dist/project-workspace/metadata-commands.d.ts +4 -0
  252. package/dist/project-workspace/metadata-commands.js +56 -0
  253. package/dist/project-workspace/output/human.d.ts +126 -0
  254. package/dist/project-workspace/output/human.js +103 -0
  255. package/dist/project-workspace/output/index.d.ts +3 -0
  256. package/dist/project-workspace/output/index.js +3 -0
  257. package/dist/project-workspace/output/metadata.d.ts +11 -0
  258. package/dist/project-workspace/output/metadata.js +17 -0
  259. package/dist/project-workspace/tree/index.d.ts +2 -0
  260. package/dist/project-workspace/tree/index.js +2 -0
  261. package/dist/project-workspace/tree/tree.d.ts +3 -0
  262. package/dist/project-workspace/tree/tree.js +197 -0
  263. package/dist/provider/client.d.ts +6 -0
  264. package/dist/provider/client.js +5 -0
  265. package/dist/provider/commands.d.ts +3 -0
  266. package/dist/provider/commands.js +38 -0
  267. package/dist/provider/index.d.ts +3 -0
  268. package/dist/provider/index.js +3 -0
  269. package/dist/reference/commands.d.ts +3 -0
  270. package/dist/reference/commands.js +39 -0
  271. package/dist/reference/index.d.ts +3 -0
  272. package/dist/reference/index.js +3 -0
  273. package/dist/reference/resolve.d.ts +29 -0
  274. package/dist/reference/resolve.js +294 -0
  275. package/dist/reference/tree/index.d.ts +2 -0
  276. package/dist/reference/tree/index.js +2 -0
  277. package/dist/reference/tree/tree.d.ts +3 -0
  278. package/dist/reference/tree/tree.js +17 -0
  279. package/dist/remote-node/client.d.ts +258 -0
  280. package/dist/remote-node/client.js +12 -0
  281. package/dist/remote-node/commands.d.ts +6 -0
  282. package/dist/remote-node/commands.js +264 -0
  283. package/dist/remote-node/connector.d.ts +59 -0
  284. package/dist/remote-node/connector.js +122 -0
  285. package/dist/remote-node/index.d.ts +4 -0
  286. package/dist/remote-node/index.js +4 -0
  287. package/dist/remote-node/reachability.d.ts +22 -0
  288. package/dist/remote-node/reachability.js +34 -0
  289. package/dist/remote-node/text.d.ts +9 -0
  290. package/dist/remote-node/text.js +64 -0
  291. package/dist/remote-node/tree/index.d.ts +2 -0
  292. package/dist/remote-node/tree/index.js +2 -0
  293. package/dist/remote-node/tree/tree.d.ts +3 -0
  294. package/dist/remote-node/tree/tree.js +51 -0
  295. package/dist/run-ledger/client.d.ts +358 -0
  296. package/dist/run-ledger/client.js +13 -0
  297. package/dist/run-ledger/commands.d.ts +8 -0
  298. package/dist/run-ledger/commands.js +19 -0
  299. package/dist/run-ledger/index.d.ts +3 -0
  300. package/dist/run-ledger/index.js +3 -0
  301. package/dist/run-ledger/input.d.ts +42 -0
  302. package/dist/run-ledger/input.js +107 -0
  303. package/dist/run-ledger/output/format.d.ts +11 -0
  304. package/dist/run-ledger/output/format.js +49 -0
  305. package/dist/run-ledger/output/index.d.ts +2 -0
  306. package/dist/run-ledger/output/index.js +2 -0
  307. package/dist/session/agent-permission.d.ts +63 -0
  308. package/dist/session/agent-permission.js +20 -0
  309. package/dist/session/approval/client.d.ts +117 -0
  310. package/dist/session/approval/client.js +7 -0
  311. package/dist/session/approval/commands.d.ts +7 -0
  312. package/dist/session/approval/commands.js +123 -0
  313. package/dist/session/approval/index.d.ts +3 -0
  314. package/dist/session/approval/index.js +3 -0
  315. package/dist/session/approval/output/format.d.ts +12 -0
  316. package/dist/session/approval/output/format.js +25 -0
  317. package/dist/session/approval/output/index.d.ts +2 -0
  318. package/dist/session/approval/output/index.js +2 -0
  319. package/dist/session/attach-client.d.ts +16 -0
  320. package/dist/session/attach-client.js +8 -0
  321. package/dist/session/attach-render.d.ts +16 -0
  322. package/dist/session/attach-render.js +154 -0
  323. package/dist/session/attach.d.ts +5 -0
  324. package/dist/session/attach.js +106 -0
  325. package/dist/session/client.d.ts +132 -0
  326. package/dist/session/client.js +128 -0
  327. package/dist/session/coding-client.d.ts +16 -0
  328. package/dist/session/coding-client.js +15 -0
  329. package/dist/session/coding-commands.d.ts +4 -0
  330. package/dist/session/coding-commands.js +50 -0
  331. package/dist/session/commands.d.ts +13 -0
  332. package/dist/session/commands.js +488 -0
  333. package/dist/session/create-tasks.d.ts +20 -0
  334. package/dist/session/create-tasks.js +110 -0
  335. package/dist/session/index.d.ts +9 -0
  336. package/dist/session/index.js +7 -0
  337. package/dist/session/interaction/client.d.ts +347 -0
  338. package/dist/session/interaction/client.js +15 -0
  339. package/dist/session/interaction/commands.d.ts +7 -0
  340. package/dist/session/interaction/commands.js +101 -0
  341. package/dist/session/interaction/index.d.ts +3 -0
  342. package/dist/session/interaction/index.js +3 -0
  343. package/dist/session/interaction/input.d.ts +15 -0
  344. package/dist/session/interaction/input.js +46 -0
  345. package/dist/session/interaction/output/format.d.ts +11 -0
  346. package/dist/session/interaction/output/format.js +3 -0
  347. package/dist/session/interaction/output/index.d.ts +2 -0
  348. package/dist/session/interaction/output/index.js +2 -0
  349. package/dist/session/output/diff.d.ts +3 -0
  350. package/dist/session/output/diff.js +30 -0
  351. package/dist/session/output/failure.d.ts +11 -0
  352. package/dist/session/output/failure.js +24 -0
  353. package/dist/session/output/human.d.ts +112 -0
  354. package/dist/session/output/human.js +71 -0
  355. package/dist/session/output/index.d.ts +6 -0
  356. package/dist/session/output/index.js +6 -0
  357. package/dist/session/output/observe.d.ts +4 -0
  358. package/dist/session/output/observe.js +46 -0
  359. package/dist/session/output/tasks.d.ts +19 -0
  360. package/dist/session/output/tasks.js +34 -0
  361. package/dist/session/rename.d.ts +3 -0
  362. package/dist/session/rename.js +37 -0
  363. package/dist/session/task-file.d.ts +5 -0
  364. package/dist/session/task-file.js +23 -0
  365. package/dist/session/tree/index.d.ts +2 -0
  366. package/dist/session/tree/index.js +2 -0
  367. package/dist/session/tree/tree.d.ts +3 -0
  368. package/dist/session/tree/tree.js +309 -0
  369. package/dist/session/turn/client.d.ts +25 -0
  370. package/dist/session/turn/client.js +40 -0
  371. package/dist/session/turn/commands.d.ts +6 -0
  372. package/dist/session/turn/commands.js +157 -0
  373. package/dist/session/turn/index.d.ts +4 -0
  374. package/dist/session/turn/index.js +3 -0
  375. package/dist/session/turn/output.d.ts +42 -0
  376. package/dist/session/turn/output.js +38 -0
  377. package/dist/status/client.d.ts +119 -0
  378. package/dist/status/client.js +5 -0
  379. package/dist/status/command.d.ts +4 -0
  380. package/dist/status/command.js +40 -0
  381. package/dist/status/doctor.d.ts +15 -0
  382. package/dist/status/doctor.js +111 -0
  383. package/dist/status/index.d.ts +5 -0
  384. package/dist/status/index.js +4 -0
  385. package/dist/status/output/compact.d.ts +31 -0
  386. package/dist/status/output/compact.js +46 -0
  387. package/dist/status/output/human.d.ts +7 -0
  388. package/dist/status/output/human.js +30 -0
  389. package/dist/status/output/index.d.ts +3 -0
  390. package/dist/status/output/index.js +3 -0
  391. package/dist/terminal/arguments.d.ts +13 -0
  392. package/dist/terminal/arguments.js +79 -0
  393. package/dist/terminal/client.d.ts +79 -0
  394. package/dist/terminal/client.js +68 -0
  395. package/dist/terminal/commands.d.ts +7 -0
  396. package/dist/terminal/commands.js +131 -0
  397. package/dist/terminal/control-commands.d.ts +10 -0
  398. package/dist/terminal/control-commands.js +212 -0
  399. package/dist/terminal/index.d.ts +4 -0
  400. package/dist/terminal/index.js +4 -0
  401. package/dist/terminal/output/compact-list.d.ts +147 -0
  402. package/dist/terminal/output/compact-list.js +152 -0
  403. package/dist/terminal/output/human.d.ts +59 -0
  404. package/dist/terminal/output/human.js +55 -0
  405. package/dist/terminal/output/index.d.ts +3 -0
  406. package/dist/terminal/output/index.js +3 -0
  407. package/dist/terminal/tree/index.d.ts +2 -0
  408. package/dist/terminal/tree/index.js +2 -0
  409. package/dist/terminal/tree/tree.d.ts +3 -0
  410. package/dist/terminal/tree/tree.js +104 -0
  411. package/guidance/maia-cli/SKILL.md +58 -0
  412. package/guidance/maia-orchestration/SKILL.md +54 -0
  413. package/package.json +76 -0
@@ -0,0 +1,700 @@
1
+ import { MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { CliArgumentError, missingArgument, parseOptions, readCursor, readExpectedRevision, readPageSize, readRevisionOption, requirePositionals, } from "../command-line/index.js";
4
+ import { writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./output/index.js";
5
+ const summarizeProjectRegistration = (result) => ({
6
+ checkoutId: result.checkout.id,
7
+ delivery: result.delivery,
8
+ projectId: result.project.id,
9
+ receipt: result.receipt,
10
+ repositoryId: result.repository.id,
11
+ workspaceId: result.workspace.id,
12
+ });
13
+ const summarizeRepositoryAttachment = (result) => ({
14
+ checkoutId: result.checkout.id,
15
+ delivery: result.delivery,
16
+ receipt: result.receipt,
17
+ repositoryId: result.repository.id,
18
+ workspaceId: result.workspace.id,
19
+ workspaceRevision: result.workspace.revision,
20
+ });
21
+ export const runProjectRegister = (tokens, context) => Effect.gen(function* () {
22
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--name"]));
23
+ requirePositionals(parsed.positionals, 1);
24
+ const path = parsed.positionals[0];
25
+ if (path === undefined) {
26
+ throw new CliArgumentError("The repository path is missing.");
27
+ }
28
+ const commandId = parsed.options.get("--command-id");
29
+ const name = parsed.options.get("--name");
30
+ const result = yield* context.dependencies.registerProject({
31
+ path,
32
+ ...(commandId === undefined ? {} : { commandId }),
33
+ ...(name === undefined ? {} : { name }),
34
+ });
35
+ return writeProjectResult(result, context, (value) => ({
36
+ command: "project.register",
37
+ result: summarizeProjectRegistration(value),
38
+ }));
39
+ });
40
+ export const runProjectList = (tokens, context) => Effect.gen(function* () {
41
+ const parsed = parseOptions(tokens, new Set(["--after", "--limit"]));
42
+ requirePositionals(parsed.positionals, 0);
43
+ const result = yield* context.dependencies.listProjects({
44
+ afterCursor: readCursor(parsed.options.get("--after")),
45
+ limit: readPageSize(parsed.options.get("--limit")),
46
+ });
47
+ return writeProjectResult(result, context, (value) => ({
48
+ command: "project.list",
49
+ result: value,
50
+ }));
51
+ });
52
+ export const runProjectShow = (tokens, context) => Effect.gen(function* () {
53
+ const parsed = parseOptions(tokens, new Set());
54
+ requirePositionals(parsed.positionals, 1);
55
+ const projectId = parsed.positionals[0];
56
+ if (projectId === undefined) {
57
+ throw new CliArgumentError("The project identifier is missing.");
58
+ }
59
+ const result = yield* context.dependencies.showProject(projectId);
60
+ return writeProjectResult(result, context, (value) => ({
61
+ command: "project.show",
62
+ result: value,
63
+ }));
64
+ });
65
+ const summarizeProjectContextRecord = (result) => ({
66
+ delivery: result.delivery,
67
+ noteId: result.note.id,
68
+ projectId: result.note.projectId,
69
+ receipt: result.receipt,
70
+ sequence: result.note.sequence,
71
+ });
72
+ const readProjectContextBody = (context) => {
73
+ if (context.io.stdin === undefined)
74
+ throw new CliArgumentError("Project context notes require standard input.");
75
+ return context.io.stdin({
76
+ label: "project context note",
77
+ maxBytes: MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES,
78
+ maxChunks: 256,
79
+ });
80
+ };
81
+ const parseProjectContextRecord = (tokens) => {
82
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--project"]), new Set(["--body-stdin"]));
83
+ requirePositionals(parsed.positionals, 0);
84
+ if (!parsed.flags.has("--body-stdin"))
85
+ throw new CliArgumentError("Option '--body-stdin' is required.");
86
+ const projectId = parsed.options.get("--project");
87
+ if (projectId === undefined) {
88
+ throw new CliArgumentError("Option '--project' is required.");
89
+ }
90
+ const commandId = parsed.options.get("--command-id");
91
+ return {
92
+ projectId,
93
+ ...(commandId === undefined ? {} : { commandId }),
94
+ };
95
+ };
96
+ export const runProjectContextRecord = (tokens, context) => Effect.gen(function* () {
97
+ const parsed = parseProjectContextRecord(tokens);
98
+ const result = yield* context.dependencies.recordProjectContext({
99
+ ...parsed,
100
+ body: yield* readProjectContextBody(context),
101
+ });
102
+ return writeProjectResult(result, context, (value) => ({
103
+ command: "project.context.record",
104
+ result: summarizeProjectContextRecord(value),
105
+ }));
106
+ });
107
+ export const runProjectContextList = (tokens, context) => Effect.gen(function* () {
108
+ const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--project"]));
109
+ requirePositionals(parsed.positionals, 0);
110
+ const projectId = parsed.options.get("--project");
111
+ if (projectId === undefined) {
112
+ throw new CliArgumentError("Option '--project' is required.");
113
+ }
114
+ const result = yield* context.dependencies.listProjectContext({
115
+ afterCursor: readCursor(parsed.options.get("--after")),
116
+ limit: readPageSize(parsed.options.get("--limit")),
117
+ projectId,
118
+ });
119
+ return writeProjectResult(result, context, (value) => ({
120
+ command: "project.context.list",
121
+ result: value,
122
+ }));
123
+ });
124
+ export const runProjectContextShow = (tokens, context) => Effect.gen(function* () {
125
+ const parsed = parseOptions(tokens, new Set());
126
+ requirePositionals(parsed.positionals, 1);
127
+ const noteId = parsed.positionals[0];
128
+ if (noteId === undefined) {
129
+ throw new CliArgumentError("The project context note identifier is missing.");
130
+ }
131
+ const result = yield* context.dependencies.showProjectContext(noteId);
132
+ return writeProjectResult(result, context, (value) => ({
133
+ command: "project.context.show",
134
+ result: value,
135
+ }));
136
+ });
137
+ export const runExecutionCatalogShow = (tokens, context) => Effect.gen(function* () {
138
+ const parsed = parseOptions(tokens, new Set());
139
+ requirePositionals(parsed.positionals, 0);
140
+ const operation = context.dependencies.readExecutionCatalog;
141
+ if (operation === undefined)
142
+ throw new Error("Missing execution client.");
143
+ const result = yield* operation();
144
+ return writeExecutionResult(result, context, (value) => ({
145
+ command: "execution.catalog",
146
+ result: value,
147
+ }));
148
+ });
149
+ const parseExecutionFileRead = (tokens) => {
150
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]));
151
+ requirePositionals(parsed.positionals, 2);
152
+ const [instanceId, relativePath] = parsed.positionals;
153
+ if (instanceId === undefined || relativePath === undefined) {
154
+ throw missingArgument();
155
+ }
156
+ return {
157
+ commandId: parsed.options.get("--command-id"),
158
+ expectedRevision: parsed.options.get("--expected-revision"),
159
+ instanceId,
160
+ relativePath,
161
+ };
162
+ };
163
+ export const runExecutionFileRead = (tokens, context) => Effect.gen(function* () {
164
+ const { commandId, expectedRevision, instanceId, relativePath } = parseExecutionFileRead(tokens);
165
+ const operation = context.dependencies.readExecutionFile;
166
+ if (operation === undefined)
167
+ throw new Error("Missing execution file client.");
168
+ const result = yield* operation({
169
+ expectedRevision: readExpectedRevision(expectedRevision),
170
+ instanceId,
171
+ relativePath,
172
+ ...(commandId === undefined ? {} : { commandId }),
173
+ });
174
+ return writeExecutionResult(result, context, (value) => ({
175
+ command: "execution.file.read",
176
+ result: value,
177
+ }));
178
+ });
179
+ const readExecutionCommandRun = (tokens) => {
180
+ const separator = tokens.indexOf("--");
181
+ if (separator < 0)
182
+ throw missingArgument();
183
+ const parsed = parseOptions(tokens.slice(0, separator), new Set(["--command-id", "--expected-revision"]));
184
+ requirePositionals(parsed.positionals, 1);
185
+ const [instanceId] = parsed.positionals;
186
+ const [executable, ...argv] = tokens.slice(separator + 1);
187
+ if (instanceId === undefined || executable === undefined) {
188
+ throw missingArgument();
189
+ }
190
+ const commandId = parsed.options.get("--command-id");
191
+ return {
192
+ argv,
193
+ executable,
194
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
195
+ instanceId,
196
+ ...(commandId === undefined ? {} : { commandId }),
197
+ };
198
+ };
199
+ export const runExecutionCommandRun = (tokens, context) => Effect.gen(function* () {
200
+ const operation = context.dependencies.runExecutionCommand;
201
+ if (operation === undefined)
202
+ throw new Error("Missing execution client.");
203
+ const result = yield* operation(readExecutionCommandRun(tokens));
204
+ return writeExecutionResult(result, context, (value) => ({
205
+ command: "execution.command.run",
206
+ result: value,
207
+ }));
208
+ });
209
+ const requiredPlacementIdentity = (value, message) => {
210
+ if (value !== undefined)
211
+ return value;
212
+ throw new CliArgumentError(message);
213
+ };
214
+ const PLACEMENT_CREATE_OPTIONS = new Set([
215
+ "--attempt",
216
+ "--command-id",
217
+ "--expected-attempt-revision",
218
+ "--expected-instance-revision",
219
+ "--expected-session-revision",
220
+ "--expected-workspace-revision",
221
+ "--instance",
222
+ "--run",
223
+ "--session",
224
+ "--task",
225
+ ]);
226
+ const readSessionPlacementCreate = (parsed) => {
227
+ const sessionId = parsed.options.get("--session");
228
+ const instanceId = parsed.options.get("--instance");
229
+ if (sessionId === undefined || instanceId === undefined)
230
+ throw new CliArgumentError("The Session placement identity is incomplete.");
231
+ const commandId = parsed.options.get("--command-id");
232
+ return {
233
+ ...(commandId === undefined ? {} : { commandId }),
234
+ expectedFencingEpoch: "0",
235
+ expectedInstanceRevision: readExpectedRevision(parsed.options.get("--expected-instance-revision")),
236
+ expectedPlacementRevision: "0",
237
+ expectedSessionRevision: readExpectedRevision(parsed.options.get("--expected-session-revision")),
238
+ expectedWorkspaceRevision: readExpectedRevision(parsed.options.get("--expected-workspace-revision")),
239
+ instanceId,
240
+ sessionId,
241
+ };
242
+ };
243
+ const readAttemptPlacementIdentity = (options) => {
244
+ const runId = options.get("--run");
245
+ const taskId = options.get("--task");
246
+ const attemptId = options.get("--attempt");
247
+ const instanceId = options.get("--instance");
248
+ return {
249
+ attemptId: requiredPlacementIdentity(attemptId, "The Attempt identifier is missing."),
250
+ instanceId: requiredPlacementIdentity(instanceId, "The instance identifier is missing."),
251
+ runId: requiredPlacementIdentity(runId, "The Run identifier is missing."),
252
+ taskId: requiredPlacementIdentity(taskId, "The Task identifier is missing."),
253
+ };
254
+ };
255
+ const readAttemptPlacementCreate = (parsed) => {
256
+ const identity = readAttemptPlacementIdentity(parsed.options);
257
+ const commandId = parsed.options.get("--command-id");
258
+ return {
259
+ attemptId: identity.attemptId,
260
+ ...(commandId === undefined ? {} : { commandId }),
261
+ expectedAttemptRevision: readExpectedRevision(parsed.options.get("--expected-attempt-revision")),
262
+ expectedFencingEpoch: "0",
263
+ expectedInstanceRevision: readExpectedRevision(parsed.options.get("--expected-instance-revision")),
264
+ expectedPlacementRevision: "0",
265
+ expectedWorkspaceRevision: readExpectedRevision(parsed.options.get("--expected-workspace-revision")),
266
+ instanceId: identity.instanceId,
267
+ runId: identity.runId,
268
+ taskId: identity.taskId,
269
+ };
270
+ };
271
+ const readExecutionPlacementCreate = (tokens) => {
272
+ const parsed = parseOptions(tokens, PLACEMENT_CREATE_OPTIONS);
273
+ requirePositionals(parsed.positionals, 0);
274
+ const session = parsed.options.has("--session");
275
+ if (session === parsed.options.has("--attempt"))
276
+ throw new CliArgumentError("Use one of '--session' or '--attempt'.");
277
+ return session
278
+ ? readSessionPlacementCreate(parsed)
279
+ : readAttemptPlacementCreate(parsed);
280
+ };
281
+ export const runExecutionPlacementCreate = (tokens, context) => Effect.gen(function* () {
282
+ const operation = context.dependencies.createExecutionPlacement;
283
+ if (operation === undefined)
284
+ throw new Error("Missing placement client.");
285
+ const result = yield* operation(readExecutionPlacementCreate(tokens));
286
+ return writeExecutionResult(result, context, (value) => ({
287
+ command: "execution.placement.create",
288
+ result: value,
289
+ }));
290
+ });
291
+ export const runExecutionPlacementShow = (tokens, context) => Effect.gen(function* () {
292
+ const parsed = parseOptions(tokens, new Set(["--attempt", "--session"]));
293
+ requirePositionals(parsed.positionals, 0);
294
+ const session = parsed.options.get("--session");
295
+ const attempt = parsed.options.get("--attempt");
296
+ if ((session === undefined) === (attempt === undefined))
297
+ throw new CliArgumentError("Use one of '--session' or '--attempt'.");
298
+ const kind = session === undefined ? "attempt" : "session";
299
+ const ownerId = session ?? attempt ?? "";
300
+ const operation = context.dependencies.showExecutionPlacement;
301
+ if (operation === undefined)
302
+ throw new Error("Missing placement client.");
303
+ const result = yield* operation({ kind, ownerId });
304
+ return writeExecutionResult(result, context, (value) => ({
305
+ command: "execution.placement.show",
306
+ result: value,
307
+ }));
308
+ });
309
+ const requiredOption = (parsed, name) => {
310
+ const value = parsed.options.get(name);
311
+ if (value === undefined)
312
+ throw missingArgument();
313
+ return value;
314
+ };
315
+ const worktreeCommandId = (parsed) => {
316
+ const commandId = parsed.options.get("--command-id");
317
+ return commandId === undefined ? {} : { commandId };
318
+ };
319
+ const readExecutionWorktreeCreate = (tokens) => {
320
+ const parsed = parseOptions(tokens, new Set([
321
+ "--base",
322
+ "--command-id",
323
+ "--expected-project-revision",
324
+ "--project",
325
+ "--repository",
326
+ ]));
327
+ requirePositionals(parsed.positionals, 0);
328
+ return {
329
+ baseRevision: requiredOption(parsed, "--base"),
330
+ expectedProjectRevision: readRevisionOption(parsed.options.get("--expected-project-revision"), "--expected-project-revision"),
331
+ kind: "git-worktree",
332
+ projectId: requiredOption(parsed, "--project"),
333
+ repositoryId: requiredOption(parsed, "--repository"),
334
+ ...worktreeCommandId(parsed),
335
+ };
336
+ };
337
+ export const runExecutionWorktreeCreate = (tokens, context) => Effect.gen(function* () {
338
+ const operation = context.dependencies.createExecutionWorktree;
339
+ if (operation === undefined)
340
+ throw new Error("Missing worktree client.");
341
+ const result = yield* operation(readExecutionWorktreeCreate(tokens));
342
+ return writeExecutionResult(result, context, (value) => ({
343
+ command: "execution.worktree.create",
344
+ result: value,
345
+ }));
346
+ });
347
+ const readExecutionWorktreeImport = (tokens) => {
348
+ const parsed = parseOptions(tokens, new Set([
349
+ "--command-id",
350
+ "--expected-project-revision",
351
+ "--project",
352
+ "--repository",
353
+ ]));
354
+ requirePositionals(parsed.positionals, 1);
355
+ const [rootPath] = parsed.positionals;
356
+ if (rootPath === undefined)
357
+ throw missingArgument();
358
+ return {
359
+ expectedProjectRevision: readRevisionOption(parsed.options.get("--expected-project-revision"), "--expected-project-revision"),
360
+ kind: "git-worktree",
361
+ projectId: requiredOption(parsed, "--project"),
362
+ repositoryId: requiredOption(parsed, "--repository"),
363
+ rootPath,
364
+ ...worktreeCommandId(parsed),
365
+ };
366
+ };
367
+ export const runExecutionWorktreeImport = (tokens, context) => Effect.gen(function* () {
368
+ const operation = context.dependencies.importExecutionWorktree;
369
+ if (operation === undefined)
370
+ throw new Error("Missing worktree client.");
371
+ const result = yield* operation(readExecutionWorktreeImport(tokens));
372
+ return writeExecutionResult(result, context, (value) => ({
373
+ command: "execution.worktree.import",
374
+ result: value,
375
+ }));
376
+ });
377
+ export const runExecutionWorktreeStatus = (tokens, context) => Effect.gen(function* () {
378
+ const parsed = parseOptions(tokens, new Set());
379
+ requirePositionals(parsed.positionals, 1);
380
+ const workspaceId = parsed.positionals[0];
381
+ if (workspaceId === undefined)
382
+ throw new CliArgumentError("Workspace missing.");
383
+ const operation = context.dependencies.showExecutionWorktreeStatus;
384
+ if (operation === undefined)
385
+ throw new Error("Missing worktree client.");
386
+ const result = yield* operation(workspaceId);
387
+ return writeExecutionResult(result, context, (value) => ({
388
+ command: "execution.worktree.status",
389
+ result: value,
390
+ }));
391
+ });
392
+ const readExecutionWorktreeReconcile = (tokens) => {
393
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-operation-revision"]));
394
+ requirePositionals(parsed.positionals, 1);
395
+ const operationId = parsed.positionals[0];
396
+ if (operationId === undefined)
397
+ throw missingArgument();
398
+ return {
399
+ expectedOperationRevision: readRevisionOption(parsed.options.get("--expected-operation-revision"), "--expected-operation-revision"),
400
+ operationId,
401
+ ...worktreeCommandId(parsed),
402
+ };
403
+ };
404
+ export const runExecutionWorktreeReconcile = (tokens, context) => Effect.gen(function* () {
405
+ const operation = context.dependencies.reconcileExecutionWorktree;
406
+ if (operation === undefined)
407
+ throw new Error("Missing worktree client.");
408
+ const result = yield* operation(readExecutionWorktreeReconcile(tokens));
409
+ return writeExecutionResult(result, context, (value) => ({
410
+ command: "execution.worktree.reconcile",
411
+ result: value,
412
+ }));
413
+ });
414
+ export const runExecutionWorktreeRemovePlan = (tokens, context) => Effect.gen(function* () {
415
+ const parsed = parseOptions(tokens, new Set());
416
+ requirePositionals(parsed.positionals, 1);
417
+ const workspaceId = parsed.positionals[0];
418
+ if (workspaceId === undefined)
419
+ throw new CliArgumentError("Workspace missing.");
420
+ const operation = context.dependencies.planExecutionWorktreeRemove;
421
+ if (operation === undefined)
422
+ throw new Error("Missing worktree client.");
423
+ const result = yield* operation(workspaceId);
424
+ return writeExecutionResult(result, context, (value) => ({
425
+ command: "execution.worktree.remove.plan",
426
+ result: value,
427
+ }));
428
+ });
429
+ const readExecutionWorktreeRemove = (tokens) => {
430
+ const parsed = parseOptions(tokens, new Set([
431
+ "--command-id",
432
+ "--expected-workspace-revision",
433
+ "--plan",
434
+ "--plan-digest",
435
+ ]));
436
+ requirePositionals(parsed.positionals, 1);
437
+ const [workspaceId] = parsed.positionals;
438
+ if (workspaceId === undefined)
439
+ throw missingArgument();
440
+ return {
441
+ expectedWorkspaceRevision: readRevisionOption(parsed.options.get("--expected-workspace-revision"), "--expected-workspace-revision"),
442
+ planDigest: requiredOption(parsed, "--plan-digest"),
443
+ planId: requiredOption(parsed, "--plan"),
444
+ workspaceId,
445
+ ...worktreeCommandId(parsed),
446
+ };
447
+ };
448
+ export const runExecutionWorktreeRemoveApply = (tokens, context) => Effect.gen(function* () {
449
+ const operation = context.dependencies.removeExecutionWorktree;
450
+ if (operation === undefined)
451
+ throw new Error("Missing worktree client.");
452
+ const result = yield* operation(readExecutionWorktreeRemove(tokens));
453
+ return writeExecutionResult(result, context, (value) => ({
454
+ command: "execution.worktree.remove.apply",
455
+ result: value,
456
+ }));
457
+ });
458
+ export const runExecutionCheckpointShow = (tokens, context) => Effect.gen(function* () {
459
+ const parsed = parseOptions(tokens, new Set());
460
+ requirePositionals(parsed.positionals, 1);
461
+ const checkpointId = parsed.positionals[0];
462
+ if (checkpointId === undefined)
463
+ throw new CliArgumentError("Checkpoint missing.");
464
+ const operation = context.dependencies.showExecutionCheckpoint;
465
+ if (operation === undefined)
466
+ throw new Error("Missing checkpoint client.");
467
+ const result = yield* operation(checkpointId);
468
+ return writeExecutionResult(result, context, (value) => ({
469
+ command: "execution.checkpoint.show",
470
+ result: value,
471
+ }));
472
+ });
473
+ export const runExecutionCheckpointCreate = (tokens, context) => Effect.gen(function* () {
474
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-instance-revision", "--instance"]));
475
+ requirePositionals(parsed.positionals, 0);
476
+ const instanceId = parsed.options.get("--instance");
477
+ if (instanceId === undefined)
478
+ throw new CliArgumentError("Option '--instance' is required.");
479
+ const operation = context.dependencies.createExecutionCheckpoint;
480
+ if (operation === undefined)
481
+ throw new Error("Missing checkpoint client.");
482
+ const result = yield* operation({
483
+ expectedInstanceRevision: readRevisionOption(parsed.options.get("--expected-instance-revision"), "--expected-instance-revision"),
484
+ instanceId,
485
+ ...worktreeCommandId(parsed),
486
+ });
487
+ return writeExecutionResult(result, context, (value) => ({
488
+ command: "execution.checkpoint.create",
489
+ result: value,
490
+ }));
491
+ });
492
+ export const runWorkspaceList = (tokens, context) => Effect.gen(function* () {
493
+ const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--project"]));
494
+ requirePositionals(parsed.positionals, 0);
495
+ const projectId = parsed.options.get("--project");
496
+ if (projectId === undefined) {
497
+ throw new CliArgumentError("Option '--project' is required.");
498
+ }
499
+ const result = yield* context.dependencies.listWorkspaces({
500
+ afterCursor: readCursor(parsed.options.get("--after")),
501
+ limit: readPageSize(parsed.options.get("--limit")),
502
+ projectId,
503
+ });
504
+ return writeWorkspaceResult(result, context, (value) => ({
505
+ command: "workspace.list",
506
+ result: value,
507
+ }));
508
+ });
509
+ const WORKSPACE_CONTEXT_REVISION_OPTIONS = new Set([
510
+ "--command-id",
511
+ "--project",
512
+ "--repository",
513
+ "--expected-active-context-revision",
514
+ "--expected-active-workspace-id",
515
+ "--expected-context-revision",
516
+ "--expected-workspace-revision",
517
+ ]);
518
+ const readRequiredStringOption = (options, name) => {
519
+ const value = options.get(name);
520
+ if (value === undefined)
521
+ throw new CliArgumentError(`Option '${name}' is required.`);
522
+ return value;
523
+ };
524
+ const readWorkspaceContextIdentity = (parsed) => {
525
+ requirePositionals(parsed.positionals, 1);
526
+ const [workspaceId] = parsed.positionals;
527
+ const projectId = parsed.options.get("--project");
528
+ const repositoryId = parsed.options.get("--repository");
529
+ if (workspaceId === undefined ||
530
+ projectId === undefined ||
531
+ repositoryId === undefined)
532
+ throw missingArgument();
533
+ return { projectId, repositoryId, workspaceId };
534
+ };
535
+ const parseWorkspaceContextMutation = (tokens) => {
536
+ const parsed = parseOptions(tokens, WORKSPACE_CONTEXT_REVISION_OPTIONS);
537
+ const identity = readWorkspaceContextIdentity(parsed);
538
+ const commandId = parsed.options.get("--command-id");
539
+ return {
540
+ input: {
541
+ ...identity,
542
+ expectedContextRevision: readRevisionOption(parsed.options.get("--expected-context-revision"), "--expected-context-revision"),
543
+ expectedWorkspaceRevision: readRevisionOption(parsed.options.get("--expected-workspace-revision"), "--expected-workspace-revision"),
544
+ ...(commandId === undefined ? {} : { commandId }),
545
+ },
546
+ options: parsed.options,
547
+ };
548
+ };
549
+ const readWorkspaceSelection = (tokens) => {
550
+ const parsed = parseWorkspaceContextMutation(tokens);
551
+ return {
552
+ ...parsed.input,
553
+ expectedActiveContextRevision: readRevisionOption(parsed.options.get("--expected-active-context-revision"), "--expected-active-context-revision"),
554
+ expectedActiveWorkspaceId: readRequiredStringOption(parsed.options, "--expected-active-workspace-id"),
555
+ };
556
+ };
557
+ export const runWorkspaceMembershipAttach = (tokens, context) => Effect.gen(function* () {
558
+ const operation = context.dependencies.attachWorkspaceMembership;
559
+ if (operation === undefined)
560
+ throw new Error("Missing Workspace client.");
561
+ const result = yield* operation(parseWorkspaceContextMutation(tokens).input);
562
+ return writeWorkspaceResult(result, context, (value) => ({
563
+ command: "workspace.membership.attach",
564
+ result: value,
565
+ }));
566
+ });
567
+ export const runWorkspaceSelect = (tokens, context) => Effect.gen(function* () {
568
+ const operation = context.dependencies.selectWorkspace;
569
+ if (operation === undefined)
570
+ throw new Error("Missing Workspace client.");
571
+ const result = yield* operation(readWorkspaceSelection(tokens));
572
+ return writeWorkspaceResult(result, context, (value) => ({
573
+ command: "workspace.select",
574
+ result: value,
575
+ }));
576
+ });
577
+ export const runWorkspaceContextShow = (tokens, context) => Effect.gen(function* () {
578
+ const parsed = parseOptions(tokens, new Set());
579
+ requirePositionals(parsed.positionals, 0);
580
+ const operation = context.dependencies.showWorkspaceContext;
581
+ if (operation === undefined)
582
+ throw new Error("Missing Workspace client.");
583
+ const result = yield* operation();
584
+ return writeWorkspaceResult(result, context, (value) => ({
585
+ command: "workspace.context.show",
586
+ result: value,
587
+ }));
588
+ });
589
+ export const runWorkspaceShow = (tokens, context) => Effect.gen(function* () {
590
+ const parsed = parseOptions(tokens, new Set());
591
+ requirePositionals(parsed.positionals, 1);
592
+ const workspaceId = parsed.positionals[0];
593
+ if (workspaceId === undefined) {
594
+ throw new CliArgumentError("The workspace identifier is missing.");
595
+ }
596
+ const result = yield* context.dependencies.showWorkspace(workspaceId);
597
+ return writeWorkspaceResult(result, context, (value) => ({
598
+ command: "workspace.show",
599
+ result: value,
600
+ }));
601
+ });
602
+ const parseWorkspaceRepositoryAttach = (tokens) => {
603
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--name", "--workspace"]));
604
+ requirePositionals(parsed.positionals, 1);
605
+ const [path] = parsed.positionals;
606
+ const workspaceId = parsed.options.get("--workspace");
607
+ const expectedRevision = readExpectedRevision(parsed.options.get("--expected-revision"));
608
+ if (workspaceId === undefined || path === undefined) {
609
+ throw new CliArgumentError("A repository path and '--workspace' are required.");
610
+ }
611
+ const commandId = parsed.options.get("--command-id");
612
+ const name = parsed.options.get("--name");
613
+ return {
614
+ expectedRevision,
615
+ path,
616
+ workspaceId,
617
+ ...(commandId === undefined ? {} : { commandId }),
618
+ ...(name === undefined ? {} : { name }),
619
+ };
620
+ };
621
+ export const runWorkspaceRepositoryAttach = (tokens, context) => Effect.gen(function* () {
622
+ const input = parseWorkspaceRepositoryAttach(tokens);
623
+ const result = yield* context.dependencies.attachWorkspaceRepository(input);
624
+ return writeWorkspaceResult(result, context, (value) => ({
625
+ command: "workspace.repository.attach",
626
+ result: summarizeRepositoryAttachment(value),
627
+ }));
628
+ });
629
+ const summarizeExecutionConfiguration = (result) => ({
630
+ ...(result.binding === undefined ? {} : { binding: result.binding }),
631
+ delivery: result.delivery,
632
+ receipt: result.receipt,
633
+ resolution: result.resolution,
634
+ workspaceId: result.workspace.id,
635
+ workspaceRevision: result.workspace.revision,
636
+ });
637
+ const readExecutionSelection = (profileId, policyId) => {
638
+ if ((profileId === undefined) === (policyId === undefined)) {
639
+ throw new CliArgumentError("Exactly one of '--execution-profile' or '--policy' is required.");
640
+ }
641
+ return profileId === undefined
642
+ ? { id: policyId ?? "", kind: "policy" }
643
+ : { id: profileId, kind: "profile" };
644
+ };
645
+ const readExecutionMutation = (parsed) => {
646
+ requirePositionals(parsed.positionals, 1);
647
+ const workspaceId = parsed.positionals[0];
648
+ if (workspaceId === undefined) {
649
+ throw new CliArgumentError("The workspace identifier is missing.");
650
+ }
651
+ const commandId = parsed.options.get("--command-id");
652
+ return {
653
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
654
+ workspaceId,
655
+ ...(commandId === undefined ? {} : { commandId }),
656
+ };
657
+ };
658
+ const readExecutionInput = (operation, tokens) => {
659
+ const parsed = parseOptions(tokens, new Set([
660
+ "--command-id",
661
+ "--expected-revision",
662
+ ...(operation === "set" ? ["--execution-profile", "--policy"] : []),
663
+ ]));
664
+ const common = readExecutionMutation(parsed);
665
+ return operation === "clear"
666
+ ? { ...common, operation }
667
+ : {
668
+ ...common,
669
+ operation,
670
+ selection: readExecutionSelection(parsed.options.get("--execution-profile"), parsed.options.get("--policy")),
671
+ };
672
+ };
673
+ export const runWorkspaceExecutionShow = (tokens, context) => Effect.gen(function* () {
674
+ const parsed = parseOptions(tokens, new Set());
675
+ requirePositionals(parsed.positionals, 1);
676
+ const workspaceId = parsed.positionals[0];
677
+ if (workspaceId === undefined) {
678
+ throw new CliArgumentError("The workspace identifier is missing.");
679
+ }
680
+ const operation = context.dependencies.showWorkspaceExecution;
681
+ if (operation === undefined)
682
+ throw new Error("Missing execution client.");
683
+ const result = yield* operation(workspaceId);
684
+ return writeWorkspaceResult(result, context, (value) => ({
685
+ command: "workspace.execution.show",
686
+ result: value,
687
+ }));
688
+ });
689
+ const configureExecution = (operation) => (tokens, context) => {
690
+ const configure = context.dependencies.configureWorkspaceExecution;
691
+ if (configure === undefined)
692
+ throw new Error("Missing execution client.");
693
+ return Effect.map(configure(readExecutionInput(operation, tokens)), (result) => writeWorkspaceResult(result, context, (value) => ({
694
+ command: "workspace.execution.configure",
695
+ result: summarizeExecutionConfiguration(value),
696
+ })));
697
+ };
698
+ export const runWorkspaceExecutionSet = configureExecution("set");
699
+ export const runWorkspaceExecutionClear = configureExecution("clear");
700
+ //# sourceMappingURL=commands.js.map