@software-dlc/cli 0.157.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 (701) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +105 -0
  3. package/README.md +31 -0
  4. package/dist/checkout.d.ts +43 -0
  5. package/dist/checkout.d.ts.map +1 -0
  6. package/dist/checkout.js +92 -0
  7. package/dist/checkout.js.map +1 -0
  8. package/dist/cli-arguments.d.ts +13 -0
  9. package/dist/cli-arguments.d.ts.map +1 -0
  10. package/dist/cli-arguments.js +67 -0
  11. package/dist/cli-arguments.js.map +1 -0
  12. package/dist/cli-branch-history.d.ts +48 -0
  13. package/dist/cli-branch-history.d.ts.map +1 -0
  14. package/dist/cli-branch-history.js +319 -0
  15. package/dist/cli-branch-history.js.map +1 -0
  16. package/dist/cli-branches.d.ts +22 -0
  17. package/dist/cli-branches.d.ts.map +1 -0
  18. package/dist/cli-branches.js +59 -0
  19. package/dist/cli-branches.js.map +1 -0
  20. package/dist/cli-deploy.d.ts +14 -0
  21. package/dist/cli-deploy.d.ts.map +1 -0
  22. package/dist/cli-deploy.js +164 -0
  23. package/dist/cli-deploy.js.map +1 -0
  24. package/dist/cli-health.d.ts +3 -0
  25. package/dist/cli-health.d.ts.map +1 -0
  26. package/dist/cli-health.js +73 -0
  27. package/dist/cli-health.js.map +1 -0
  28. package/dist/cli-help.d.ts +21 -0
  29. package/dist/cli-help.d.ts.map +1 -0
  30. package/dist/cli-help.js +176 -0
  31. package/dist/cli-help.js.map +1 -0
  32. package/dist/cli-login.d.ts +76 -0
  33. package/dist/cli-login.d.ts.map +1 -0
  34. package/dist/cli-login.js +634 -0
  35. package/dist/cli-login.js.map +1 -0
  36. package/dist/cli-operation.d.ts +2 -0
  37. package/dist/cli-operation.d.ts.map +1 -0
  38. package/dist/cli-operation.js +66 -0
  39. package/dist/cli-operation.js.map +1 -0
  40. package/dist/cli-org.d.ts +12 -0
  41. package/dist/cli-org.d.ts.map +1 -0
  42. package/dist/cli-org.js +218 -0
  43. package/dist/cli-org.js.map +1 -0
  44. package/dist/cli-rebuild.d.ts +20 -0
  45. package/dist/cli-rebuild.d.ts.map +1 -0
  46. package/dist/cli-rebuild.js +29 -0
  47. package/dist/cli-rebuild.js.map +1 -0
  48. package/dist/cli-reset.d.ts +27 -0
  49. package/dist/cli-reset.d.ts.map +1 -0
  50. package/dist/cli-reset.js +44 -0
  51. package/dist/cli-reset.js.map +1 -0
  52. package/dist/cli-snapshot.d.ts +398 -0
  53. package/dist/cli-snapshot.d.ts.map +1 -0
  54. package/dist/cli-snapshot.js +45 -0
  55. package/dist/cli-snapshot.js.map +1 -0
  56. package/dist/cli-task-context.d.ts +3 -0
  57. package/dist/cli-task-context.d.ts.map +1 -0
  58. package/dist/cli-task-context.js +112 -0
  59. package/dist/cli-task-context.js.map +1 -0
  60. package/dist/cli.d.ts +3 -0
  61. package/dist/cli.d.ts.map +1 -0
  62. package/dist/cli.js +1004 -0
  63. package/dist/cli.js.map +1 -0
  64. package/dist/graph-packages-lock.d.ts +169 -0
  65. package/dist/graph-packages-lock.d.ts.map +1 -0
  66. package/dist/graph-packages-lock.js +503 -0
  67. package/dist/graph-packages-lock.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +2 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/local/aggregate-preflight.d.ts +12 -0
  73. package/dist/local/aggregate-preflight.d.ts.map +1 -0
  74. package/dist/local/aggregate-preflight.js +22 -0
  75. package/dist/local/aggregate-preflight.js.map +1 -0
  76. package/dist/local/allow-mcp.d.ts +77 -0
  77. package/dist/local/allow-mcp.d.ts.map +1 -0
  78. package/dist/local/allow-mcp.js +394 -0
  79. package/dist/local/allow-mcp.js.map +1 -0
  80. package/dist/local/api-client.d.ts +15 -0
  81. package/dist/local/api-client.d.ts.map +1 -0
  82. package/dist/local/api-client.js +87 -0
  83. package/dist/local/api-client.js.map +1 -0
  84. package/dist/local/app-contract-readers.d.ts +229 -0
  85. package/dist/local/app-contract-readers.d.ts.map +1 -0
  86. package/dist/local/app-contract-readers.js +450 -0
  87. package/dist/local/app-contract-readers.js.map +1 -0
  88. package/dist/local/app-org-reader.d.ts +21 -0
  89. package/dist/local/app-org-reader.d.ts.map +1 -0
  90. package/dist/local/app-org-reader.js +66 -0
  91. package/dist/local/app-org-reader.js.map +1 -0
  92. package/dist/local/app-shell-readers.d.ts +96 -0
  93. package/dist/local/app-shell-readers.d.ts.map +1 -0
  94. package/dist/local/app-shell-readers.js +381 -0
  95. package/dist/local/app-shell-readers.js.map +1 -0
  96. package/dist/local/app-tasks-read.d.ts +202 -0
  97. package/dist/local/app-tasks-read.d.ts.map +1 -0
  98. package/dist/local/app-tasks-read.js +290 -0
  99. package/dist/local/app-tasks-read.js.map +1 -0
  100. package/dist/local/app-worktrees.d.ts +69 -0
  101. package/dist/local/app-worktrees.d.ts.map +1 -0
  102. package/dist/local/app-worktrees.js +554 -0
  103. package/dist/local/app-worktrees.js.map +1 -0
  104. package/dist/local/base-sync-manifest.d.ts +12 -0
  105. package/dist/local/base-sync-manifest.d.ts.map +1 -0
  106. package/dist/local/base-sync-manifest.js +57 -0
  107. package/dist/local/base-sync-manifest.js.map +1 -0
  108. package/dist/local/blast-radius.d.ts +191 -0
  109. package/dist/local/blast-radius.d.ts.map +1 -0
  110. package/dist/local/blast-radius.js +585 -0
  111. package/dist/local/blast-radius.js.map +1 -0
  112. package/dist/local/canonical.d.ts +2 -0
  113. package/dist/local/canonical.d.ts.map +1 -0
  114. package/dist/local/canonical.js +2 -0
  115. package/dist/local/canonical.js.map +1 -0
  116. package/dist/local/config.d.ts +22 -0
  117. package/dist/local/config.d.ts.map +1 -0
  118. package/dist/local/config.js +57 -0
  119. package/dist/local/config.js.map +1 -0
  120. package/dist/local/document-commands.d.ts +163 -0
  121. package/dist/local/document-commands.d.ts.map +1 -0
  122. package/dist/local/document-commands.js +620 -0
  123. package/dist/local/document-commands.js.map +1 -0
  124. package/dist/local/document-embeds.d.ts +21 -0
  125. package/dist/local/document-embeds.d.ts.map +1 -0
  126. package/dist/local/document-embeds.js +38 -0
  127. package/dist/local/document-embeds.js.map +1 -0
  128. package/dist/local/environment-context.d.ts +39 -0
  129. package/dist/local/environment-context.d.ts.map +1 -0
  130. package/dist/local/environment-context.js +193 -0
  131. package/dist/local/environment-context.js.map +1 -0
  132. package/dist/local/environment-exclude.d.ts +7 -0
  133. package/dist/local/environment-exclude.d.ts.map +1 -0
  134. package/dist/local/environment-exclude.js +82 -0
  135. package/dist/local/environment-exclude.js.map +1 -0
  136. package/dist/local/environment-sidecar.d.ts +126 -0
  137. package/dist/local/environment-sidecar.d.ts.map +1 -0
  138. package/dist/local/environment-sidecar.js +442 -0
  139. package/dist/local/environment-sidecar.js.map +1 -0
  140. package/dist/local/environment-switch.d.ts +22 -0
  141. package/dist/local/environment-switch.d.ts.map +1 -0
  142. package/dist/local/environment-switch.js +385 -0
  143. package/dist/local/environment-switch.js.map +1 -0
  144. package/dist/local/exact-remote-projection.d.ts +17 -0
  145. package/dist/local/exact-remote-projection.d.ts.map +1 -0
  146. package/dist/local/exact-remote-projection.js +53 -0
  147. package/dist/local/exact-remote-projection.js.map +1 -0
  148. package/dist/local/experimental/path-object-store.d.ts +66 -0
  149. package/dist/local/experimental/path-object-store.d.ts.map +1 -0
  150. package/dist/local/experimental/path-object-store.js +135 -0
  151. package/dist/local/experimental/path-object-store.js.map +1 -0
  152. package/dist/local/external-worktree-binding.d.ts +21 -0
  153. package/dist/local/external-worktree-binding.d.ts.map +1 -0
  154. package/dist/local/external-worktree-binding.js +56 -0
  155. package/dist/local/external-worktree-binding.js.map +1 -0
  156. package/dist/local/folder-members.d.ts +34 -0
  157. package/dist/local/folder-members.d.ts.map +1 -0
  158. package/dist/local/folder-members.js +168 -0
  159. package/dist/local/folder-members.js.map +1 -0
  160. package/dist/local/git-ref-authority.d.ts +11 -0
  161. package/dist/local/git-ref-authority.d.ts.map +1 -0
  162. package/dist/local/git-ref-authority.js +76 -0
  163. package/dist/local/git-ref-authority.js.map +1 -0
  164. package/dist/local/git.d.ts +88 -0
  165. package/dist/local/git.d.ts.map +1 -0
  166. package/dist/local/git.js +413 -0
  167. package/dist/local/git.js.map +1 -0
  168. package/dist/local/graph-read.d.ts +168 -0
  169. package/dist/local/graph-read.d.ts.map +1 -0
  170. package/dist/local/graph-read.js +360 -0
  171. package/dist/local/graph-read.js.map +1 -0
  172. package/dist/local/graph-sync.d.ts +39 -0
  173. package/dist/local/graph-sync.d.ts.map +1 -0
  174. package/dist/local/graph-sync.js +186 -0
  175. package/dist/local/graph-sync.js.map +1 -0
  176. package/dist/local/guide-commands.d.ts +79 -0
  177. package/dist/local/guide-commands.d.ts.map +1 -0
  178. package/dist/local/guide-commands.js +247 -0
  179. package/dist/local/guide-commands.js.map +1 -0
  180. package/dist/local/health-files.d.ts +24 -0
  181. package/dist/local/health-files.d.ts.map +1 -0
  182. package/dist/local/health-files.js +133 -0
  183. package/dist/local/health-files.js.map +1 -0
  184. package/dist/local/health-inspection.d.ts +12 -0
  185. package/dist/local/health-inspection.d.ts.map +1 -0
  186. package/dist/local/health-inspection.js +407 -0
  187. package/dist/local/health-inspection.js.map +1 -0
  188. package/dist/local/health-policy.d.ts +11 -0
  189. package/dist/local/health-policy.d.ts.map +1 -0
  190. package/dist/local/health-policy.js +257 -0
  191. package/dist/local/health-policy.js.map +1 -0
  192. package/dist/local/health-projection.d.ts +14 -0
  193. package/dist/local/health-projection.d.ts.map +1 -0
  194. package/dist/local/health-projection.js +102 -0
  195. package/dist/local/health-projection.js.map +1 -0
  196. package/dist/local/health-schema.d.ts +338 -0
  197. package/dist/local/health-schema.d.ts.map +1 -0
  198. package/dist/local/health-schema.js +213 -0
  199. package/dist/local/health-schema.js.map +1 -0
  200. package/dist/local/health-store.d.ts +61 -0
  201. package/dist/local/health-store.d.ts.map +1 -0
  202. package/dist/local/health-store.js +218 -0
  203. package/dist/local/health-store.js.map +1 -0
  204. package/dist/local/index.d.ts +66 -0
  205. package/dist/local/index.d.ts.map +1 -0
  206. package/dist/local/index.js +66 -0
  207. package/dist/local/index.js.map +1 -0
  208. package/dist/local/journey-commands.d.ts +65 -0
  209. package/dist/local/journey-commands.d.ts.map +1 -0
  210. package/dist/local/journey-commands.js +138 -0
  211. package/dist/local/journey-commands.js.map +1 -0
  212. package/dist/local/local-org-store.d.ts +46 -0
  213. package/dist/local/local-org-store.d.ts.map +1 -0
  214. package/dist/local/local-org-store.js +132 -0
  215. package/dist/local/local-org-store.js.map +1 -0
  216. package/dist/local/local-org.d.ts +389 -0
  217. package/dist/local/local-org.d.ts.map +1 -0
  218. package/dist/local/local-org.js +855 -0
  219. package/dist/local/local-org.js.map +1 -0
  220. package/dist/local/media-upload.d.ts +5 -0
  221. package/dist/local/media-upload.d.ts.map +1 -0
  222. package/dist/local/media-upload.js +41 -0
  223. package/dist/local/media-upload.js.map +1 -0
  224. package/dist/local/operation.d.ts +155 -0
  225. package/dist/local/operation.d.ts.map +1 -0
  226. package/dist/local/operation.js +340 -0
  227. package/dist/local/operation.js.map +1 -0
  228. package/dist/local/ownership-reader-schema.d.ts +117 -0
  229. package/dist/local/ownership-reader-schema.d.ts.map +1 -0
  230. package/dist/local/ownership-reader-schema.js +105 -0
  231. package/dist/local/ownership-reader-schema.js.map +1 -0
  232. package/dist/local/ownership-reader-worker.d.ts +2 -0
  233. package/dist/local/ownership-reader-worker.d.ts.map +1 -0
  234. package/dist/local/ownership-reader-worker.js +341 -0
  235. package/dist/local/ownership-reader-worker.js.map +1 -0
  236. package/dist/local/ownership-reader.d.ts +10 -0
  237. package/dist/local/ownership-reader.d.ts.map +1 -0
  238. package/dist/local/ownership-reader.js +93 -0
  239. package/dist/local/ownership-reader.js.map +1 -0
  240. package/dist/local/package-uses-check.d.ts +33 -0
  241. package/dist/local/package-uses-check.d.ts.map +1 -0
  242. package/dist/local/package-uses-check.js +62 -0
  243. package/dist/local/package-uses-check.js.map +1 -0
  244. package/dist/local/pending-recovery.d.ts +22 -0
  245. package/dist/local/pending-recovery.d.ts.map +1 -0
  246. package/dist/local/pending-recovery.js +171 -0
  247. package/dist/local/pending-recovery.js.map +1 -0
  248. package/dist/local/portable-commit-store.d.ts +28 -0
  249. package/dist/local/portable-commit-store.d.ts.map +1 -0
  250. package/dist/local/portable-commit-store.js +187 -0
  251. package/dist/local/portable-commit-store.js.map +1 -0
  252. package/dist/local/portable-commit.d.ts +109 -0
  253. package/dist/local/portable-commit.d.ts.map +1 -0
  254. package/dist/local/portable-commit.js +209 -0
  255. package/dist/local/portable-commit.js.map +1 -0
  256. package/dist/local/portable-remote.d.ts +432 -0
  257. package/dist/local/portable-remote.d.ts.map +1 -0
  258. package/dist/local/portable-remote.js +280 -0
  259. package/dist/local/portable-remote.js.map +1 -0
  260. package/dist/local/project-deleted.d.ts +4 -0
  261. package/dist/local/project-deleted.d.ts.map +1 -0
  262. package/dist/local/project-deleted.js +13 -0
  263. package/dist/local/project-deleted.js.map +1 -0
  264. package/dist/local/projection.d.ts +166 -0
  265. package/dist/local/projection.d.ts.map +1 -0
  266. package/dist/local/projection.js +709 -0
  267. package/dist/local/projection.js.map +1 -0
  268. package/dist/local/read-operation.d.ts +3 -0
  269. package/dist/local/read-operation.d.ts.map +1 -0
  270. package/dist/local/read-operation.js +19 -0
  271. package/dist/local/read-operation.js.map +1 -0
  272. package/dist/local/rebuild.d.ts +11 -0
  273. package/dist/local/rebuild.d.ts.map +1 -0
  274. package/dist/local/rebuild.js +42 -0
  275. package/dist/local/rebuild.js.map +1 -0
  276. package/dist/local/remote-base.d.ts +25 -0
  277. package/dist/local/remote-base.d.ts.map +1 -0
  278. package/dist/local/remote-base.js +68 -0
  279. package/dist/local/remote-base.js.map +1 -0
  280. package/dist/local/save-layout-worker.d.ts +19 -0
  281. package/dist/local/save-layout-worker.d.ts.map +1 -0
  282. package/dist/local/save-layout-worker.js +28 -0
  283. package/dist/local/save-layout-worker.js.map +1 -0
  284. package/dist/local/save-layout.d.ts +84 -0
  285. package/dist/local/save-layout.d.ts.map +1 -0
  286. package/dist/local/save-layout.js +221 -0
  287. package/dist/local/save-layout.js.map +1 -0
  288. package/dist/local/scope-impact.d.ts +31 -0
  289. package/dist/local/scope-impact.d.ts.map +1 -0
  290. package/dist/local/scope-impact.js +32 -0
  291. package/dist/local/scope-impact.js.map +1 -0
  292. package/dist/local/source-evidence/filesystem-worker.d.ts +2 -0
  293. package/dist/local/source-evidence/filesystem-worker.d.ts.map +1 -0
  294. package/dist/local/source-evidence/filesystem-worker.js +139 -0
  295. package/dist/local/source-evidence/filesystem-worker.js.map +1 -0
  296. package/dist/local/source-evidence/processes.d.ts +20 -0
  297. package/dist/local/source-evidence/processes.d.ts.map +1 -0
  298. package/dist/local/source-evidence/processes.js +133 -0
  299. package/dist/local/source-evidence/processes.js.map +1 -0
  300. package/dist/local/source-evidence/protocol.d.ts +52 -0
  301. package/dist/local/source-evidence/protocol.d.ts.map +1 -0
  302. package/dist/local/source-evidence/protocol.js +72 -0
  303. package/dist/local/source-evidence/protocol.js.map +1 -0
  304. package/dist/local/source-evidence/reader.d.ts +14 -0
  305. package/dist/local/source-evidence/reader.d.ts.map +1 -0
  306. package/dist/local/source-evidence/reader.js +308 -0
  307. package/dist/local/source-evidence/reader.js.map +1 -0
  308. package/dist/local/source-evidence/schema.d.ts +2504 -0
  309. package/dist/local/source-evidence/schema.d.ts.map +1 -0
  310. package/dist/local/source-evidence/schema.js +99 -0
  311. package/dist/local/source-evidence/schema.js.map +1 -0
  312. package/dist/local/source-policy/loader.d.ts +29 -0
  313. package/dist/local/source-policy/loader.d.ts.map +1 -0
  314. package/dist/local/source-policy/loader.js +209 -0
  315. package/dist/local/source-policy/loader.js.map +1 -0
  316. package/dist/local/source-policy/process.d.ts +7 -0
  317. package/dist/local/source-policy/process.d.ts.map +1 -0
  318. package/dist/local/source-policy/process.js +53 -0
  319. package/dist/local/source-policy/process.js.map +1 -0
  320. package/dist/local/source-policy/protocol.d.ts +27 -0
  321. package/dist/local/source-policy/protocol.d.ts.map +1 -0
  322. package/dist/local/source-policy/protocol.js +48 -0
  323. package/dist/local/source-policy/protocol.js.map +1 -0
  324. package/dist/local/source-policy/worker.d.ts +2 -0
  325. package/dist/local/source-policy/worker.d.ts.map +1 -0
  326. package/dist/local/source-policy/worker.js +100 -0
  327. package/dist/local/source-policy/worker.js.map +1 -0
  328. package/dist/local/state-directory.d.ts +17 -0
  329. package/dist/local/state-directory.d.ts.map +1 -0
  330. package/dist/local/state-directory.js +68 -0
  331. package/dist/local/state-directory.js.map +1 -0
  332. package/dist/local/store-database.d.ts +13 -0
  333. package/dist/local/store-database.d.ts.map +1 -0
  334. package/dist/local/store-database.js +187 -0
  335. package/dist/local/store-database.js.map +1 -0
  336. package/dist/local/store.d.ts +181 -0
  337. package/dist/local/store.d.ts.map +1 -0
  338. package/dist/local/store.js +585 -0
  339. package/dist/local/store.js.map +1 -0
  340. package/dist/local/sync.d.ts +47 -0
  341. package/dist/local/sync.d.ts.map +1 -0
  342. package/dist/local/sync.js +518 -0
  343. package/dist/local/sync.js.map +1 -0
  344. package/dist/local/task-context-inspection.d.ts +23 -0
  345. package/dist/local/task-context-inspection.d.ts.map +1 -0
  346. package/dist/local/task-context-inspection.js +165 -0
  347. package/dist/local/task-context-inspection.js.map +1 -0
  348. package/dist/local/task-context-observations.d.ts +9553 -0
  349. package/dist/local/task-context-observations.d.ts.map +1 -0
  350. package/dist/local/task-context-observations.js +232 -0
  351. package/dist/local/task-context-observations.js.map +1 -0
  352. package/dist/local/task-context-provider.d.ts +18 -0
  353. package/dist/local/task-context-provider.d.ts.map +1 -0
  354. package/dist/local/task-context-provider.js +231 -0
  355. package/dist/local/task-context-provider.js.map +1 -0
  356. package/dist/local/task-context-schema.d.ts +847 -0
  357. package/dist/local/task-context-schema.d.ts.map +1 -0
  358. package/dist/local/task-context-schema.js +305 -0
  359. package/dist/local/task-context-schema.js.map +1 -0
  360. package/dist/local/task-context-source.d.ts +16 -0
  361. package/dist/local/task-context-source.d.ts.map +1 -0
  362. package/dist/local/task-context-source.js +45 -0
  363. package/dist/local/task-context-source.js.map +1 -0
  364. package/dist/local/task-context.d.ts +14 -0
  365. package/dist/local/task-context.d.ts.map +1 -0
  366. package/dist/local/task-context.js +570 -0
  367. package/dist/local/task-context.js.map +1 -0
  368. package/dist/local/test-commands.d.ts +71 -0
  369. package/dist/local/test-commands.d.ts.map +1 -0
  370. package/dist/local/test-commands.js +292 -0
  371. package/dist/local/test-commands.js.map +1 -0
  372. package/dist/local/tree-save.d.ts +117 -0
  373. package/dist/local/tree-save.d.ts.map +1 -0
  374. package/dist/local/tree-save.js +615 -0
  375. package/dist/local/tree-save.js.map +1 -0
  376. package/dist/local/variants.d.ts +125 -0
  377. package/dist/local/variants.d.ts.map +1 -0
  378. package/dist/local/variants.js +267 -0
  379. package/dist/local/variants.js.map +1 -0
  380. package/dist/local/workspace-admission.d.ts +61 -0
  381. package/dist/local/workspace-admission.d.ts.map +1 -0
  382. package/dist/local/workspace-admission.js +112 -0
  383. package/dist/local/workspace-admission.js.map +1 -0
  384. package/dist/local/workspace-authority-guard.d.ts +18 -0
  385. package/dist/local/workspace-authority-guard.d.ts.map +1 -0
  386. package/dist/local/workspace-authority-guard.js +69 -0
  387. package/dist/local/workspace-authority-guard.js.map +1 -0
  388. package/dist/local/workspace-authority.d.ts +33 -0
  389. package/dist/local/workspace-authority.d.ts.map +1 -0
  390. package/dist/local/workspace-authority.js +33 -0
  391. package/dist/local/workspace-authority.js.map +1 -0
  392. package/dist/local/workspace-branch-runtime.d.ts +61 -0
  393. package/dist/local/workspace-branch-runtime.d.ts.map +1 -0
  394. package/dist/local/workspace-branch-runtime.js +216 -0
  395. package/dist/local/workspace-branch-runtime.js.map +1 -0
  396. package/dist/local/workspace-built-content.d.ts +137 -0
  397. package/dist/local/workspace-built-content.d.ts.map +1 -0
  398. package/dist/local/workspace-built-content.js +393 -0
  399. package/dist/local/workspace-built-content.js.map +1 -0
  400. package/dist/local/workspace-claim-status-read.d.ts +53 -0
  401. package/dist/local/workspace-claim-status-read.d.ts.map +1 -0
  402. package/dist/local/workspace-claim-status-read.js +118 -0
  403. package/dist/local/workspace-claim-status-read.js.map +1 -0
  404. package/dist/local/workspace-claim-status.d.ts +172 -0
  405. package/dist/local/workspace-claim-status.d.ts.map +1 -0
  406. package/dist/local/workspace-claim-status.js +721 -0
  407. package/dist/local/workspace-claim-status.js.map +1 -0
  408. package/dist/local/workspace-claim-views.d.ts +45 -0
  409. package/dist/local/workspace-claim-views.d.ts.map +1 -0
  410. package/dist/local/workspace-claim-views.js +45 -0
  411. package/dist/local/workspace-claim-views.js.map +1 -0
  412. package/dist/local/workspace-cli.d.ts +46 -0
  413. package/dist/local/workspace-cli.d.ts.map +1 -0
  414. package/dist/local/workspace-cli.js +1524 -0
  415. package/dist/local/workspace-cli.js.map +1 -0
  416. package/dist/local/workspace-commit-resolver.d.ts +19 -0
  417. package/dist/local/workspace-commit-resolver.d.ts.map +1 -0
  418. package/dist/local/workspace-commit-resolver.js +47 -0
  419. package/dist/local/workspace-commit-resolver.js.map +1 -0
  420. package/dist/local/workspace-decision-store.d.ts +184 -0
  421. package/dist/local/workspace-decision-store.d.ts.map +1 -0
  422. package/dist/local/workspace-decision-store.js +510 -0
  423. package/dist/local/workspace-decision-store.js.map +1 -0
  424. package/dist/local/workspace-environment-runtime.d.ts +107 -0
  425. package/dist/local/workspace-environment-runtime.d.ts.map +1 -0
  426. package/dist/local/workspace-environment-runtime.js +135 -0
  427. package/dist/local/workspace-environment-runtime.js.map +1 -0
  428. package/dist/local/workspace-evidence-drop.d.ts +21 -0
  429. package/dist/local/workspace-evidence-drop.d.ts.map +1 -0
  430. package/dist/local/workspace-evidence-drop.js +58 -0
  431. package/dist/local/workspace-evidence-drop.js.map +1 -0
  432. package/dist/local/workspace-evidence-sign-tool.d.ts +20 -0
  433. package/dist/local/workspace-evidence-sign-tool.d.ts.map +1 -0
  434. package/dist/local/workspace-evidence-sign-tool.js +85 -0
  435. package/dist/local/workspace-evidence-sign-tool.js.map +1 -0
  436. package/dist/local/workspace-evidence-status.d.ts +89 -0
  437. package/dist/local/workspace-evidence-status.d.ts.map +1 -0
  438. package/dist/local/workspace-evidence-status.js +141 -0
  439. package/dist/local/workspace-evidence-status.js.map +1 -0
  440. package/dist/local/workspace-evidence.d.ts +145 -0
  441. package/dist/local/workspace-evidence.d.ts.map +1 -0
  442. package/dist/local/workspace-evidence.js +347 -0
  443. package/dist/local/workspace-evidence.js.map +1 -0
  444. package/dist/local/workspace-graph-store.d.ts +32 -0
  445. package/dist/local/workspace-graph-store.d.ts.map +1 -0
  446. package/dist/local/workspace-graph-store.js +249 -0
  447. package/dist/local/workspace-graph-store.js.map +1 -0
  448. package/dist/local/workspace-handoff.d.ts +32 -0
  449. package/dist/local/workspace-handoff.d.ts.map +1 -0
  450. package/dist/local/workspace-handoff.js +144 -0
  451. package/dist/local/workspace-handoff.js.map +1 -0
  452. package/dist/local/workspace-history-journal.d.ts +70 -0
  453. package/dist/local/workspace-history-journal.d.ts.map +1 -0
  454. package/dist/local/workspace-history-journal.js +131 -0
  455. package/dist/local/workspace-history-journal.js.map +1 -0
  456. package/dist/local/workspace-history-store.d.ts +98 -0
  457. package/dist/local/workspace-history-store.d.ts.map +1 -0
  458. package/dist/local/workspace-history-store.js +632 -0
  459. package/dist/local/workspace-history-store.js.map +1 -0
  460. package/dist/local/workspace-history-types.d.ts +307 -0
  461. package/dist/local/workspace-history-types.d.ts.map +1 -0
  462. package/dist/local/workspace-history-types.js +2 -0
  463. package/dist/local/workspace-history-types.js.map +1 -0
  464. package/dist/local/workspace-integration-runtime.d.ts +48 -0
  465. package/dist/local/workspace-integration-runtime.d.ts.map +1 -0
  466. package/dist/local/workspace-integration-runtime.js +419 -0
  467. package/dist/local/workspace-integration-runtime.js.map +1 -0
  468. package/dist/local/workspace-lock.d.ts +7 -0
  469. package/dist/local/workspace-lock.d.ts.map +1 -0
  470. package/dist/local/workspace-lock.js +211 -0
  471. package/dist/local/workspace-lock.js.map +1 -0
  472. package/dist/local/workspace-merge.d.ts +77 -0
  473. package/dist/local/workspace-merge.d.ts.map +1 -0
  474. package/dist/local/workspace-merge.js +703 -0
  475. package/dist/local/workspace-merge.js.map +1 -0
  476. package/dist/local/workspace-mixed-history.d.ts +33 -0
  477. package/dist/local/workspace-mixed-history.d.ts.map +1 -0
  478. package/dist/local/workspace-mixed-history.js +107 -0
  479. package/dist/local/workspace-mixed-history.js.map +1 -0
  480. package/dist/local/workspace-overlap-allocation.d.ts +33 -0
  481. package/dist/local/workspace-overlap-allocation.d.ts.map +1 -0
  482. package/dist/local/workspace-overlap-allocation.js +69 -0
  483. package/dist/local/workspace-overlap-allocation.js.map +1 -0
  484. package/dist/local/workspace-overlap-impact.d.ts +46 -0
  485. package/dist/local/workspace-overlap-impact.d.ts.map +1 -0
  486. package/dist/local/workspace-overlap-impact.js +162 -0
  487. package/dist/local/workspace-overlap-impact.js.map +1 -0
  488. package/dist/local/workspace-overlap.d.ts +109 -0
  489. package/dist/local/workspace-overlap.d.ts.map +1 -0
  490. package/dist/local/workspace-overlap.js +327 -0
  491. package/dist/local/workspace-overlap.js.map +1 -0
  492. package/dist/local/workspace-paths.d.ts +4 -0
  493. package/dist/local/workspace-paths.d.ts.map +1 -0
  494. package/dist/local/workspace-paths.js +8 -0
  495. package/dist/local/workspace-paths.js.map +1 -0
  496. package/dist/local/workspace-pick-runtime.d.ts +70 -0
  497. package/dist/local/workspace-pick-runtime.d.ts.map +1 -0
  498. package/dist/local/workspace-pick-runtime.js +177 -0
  499. package/dist/local/workspace-pick-runtime.js.map +1 -0
  500. package/dist/local/workspace-pick-store.d.ts +33 -0
  501. package/dist/local/workspace-pick-store.d.ts.map +1 -0
  502. package/dist/local/workspace-pick-store.js +43 -0
  503. package/dist/local/workspace-pick-store.js.map +1 -0
  504. package/dist/local/workspace-pick.d.ts +73 -0
  505. package/dist/local/workspace-pick.d.ts.map +1 -0
  506. package/dist/local/workspace-pick.js +253 -0
  507. package/dist/local/workspace-pick.js.map +1 -0
  508. package/dist/local/workspace-portable-authoring.d.ts +43 -0
  509. package/dist/local/workspace-portable-authoring.d.ts.map +1 -0
  510. package/dist/local/workspace-portable-authoring.js +128 -0
  511. package/dist/local/workspace-portable-authoring.js.map +1 -0
  512. package/dist/local/workspace-prune.d.ts +63 -0
  513. package/dist/local/workspace-prune.d.ts.map +1 -0
  514. package/dist/local/workspace-prune.js +267 -0
  515. package/dist/local/workspace-prune.js.map +1 -0
  516. package/dist/local/workspace-remote-fetch.d.ts +82 -0
  517. package/dist/local/workspace-remote-fetch.d.ts.map +1 -0
  518. package/dist/local/workspace-remote-fetch.js +409 -0
  519. package/dist/local/workspace-remote-fetch.js.map +1 -0
  520. package/dist/local/workspace-remote-provider.d.ts +97 -0
  521. package/dist/local/workspace-remote-provider.d.ts.map +1 -0
  522. package/dist/local/workspace-remote-provider.js +400 -0
  523. package/dist/local/workspace-remote-provider.js.map +1 -0
  524. package/dist/local/workspace-remote-pull-request-journal.d.ts +49 -0
  525. package/dist/local/workspace-remote-pull-request-journal.d.ts.map +1 -0
  526. package/dist/local/workspace-remote-pull-request-journal.js +63 -0
  527. package/dist/local/workspace-remote-pull-request-journal.js.map +1 -0
  528. package/dist/local/workspace-remote-pull-request.d.ts +36 -0
  529. package/dist/local/workspace-remote-pull-request.d.ts.map +1 -0
  530. package/dist/local/workspace-remote-pull-request.js +158 -0
  531. package/dist/local/workspace-remote-pull-request.js.map +1 -0
  532. package/dist/local/workspace-remote-push.d.ts +88 -0
  533. package/dist/local/workspace-remote-push.d.ts.map +1 -0
  534. package/dist/local/workspace-remote-push.js +297 -0
  535. package/dist/local/workspace-remote-push.js.map +1 -0
  536. package/dist/local/workspace-remote-topic-journal.d.ts +56 -0
  537. package/dist/local/workspace-remote-topic-journal.d.ts.map +1 -0
  538. package/dist/local/workspace-remote-topic-journal.js +121 -0
  539. package/dist/local/workspace-remote-topic-journal.js.map +1 -0
  540. package/dist/local/workspace-remote-topic.d.ts +45 -0
  541. package/dist/local/workspace-remote-topic.d.ts.map +1 -0
  542. package/dist/local/workspace-remote-topic.js +204 -0
  543. package/dist/local/workspace-remote-topic.js.map +1 -0
  544. package/dist/local/workspace-remote-transfer.d.ts +76 -0
  545. package/dist/local/workspace-remote-transfer.d.ts.map +1 -0
  546. package/dist/local/workspace-remote-transfer.js +270 -0
  547. package/dist/local/workspace-remote-transfer.js.map +1 -0
  548. package/dist/local/workspace-resolution.d.ts +145 -0
  549. package/dist/local/workspace-resolution.d.ts.map +1 -0
  550. package/dist/local/workspace-resolution.js +479 -0
  551. package/dist/local/workspace-resolution.js.map +1 -0
  552. package/dist/local/workspace-resolver-provider.d.ts +72 -0
  553. package/dist/local/workspace-resolver-provider.d.ts.map +1 -0
  554. package/dist/local/workspace-resolver-provider.js +312 -0
  555. package/dist/local/workspace-resolver-provider.js.map +1 -0
  556. package/dist/local/workspace-runtime-handoff.d.ts +52 -0
  557. package/dist/local/workspace-runtime-handoff.d.ts.map +1 -0
  558. package/dist/local/workspace-runtime-handoff.js +237 -0
  559. package/dist/local/workspace-runtime-handoff.js.map +1 -0
  560. package/dist/local/workspace-runtime-lease.d.ts +26 -0
  561. package/dist/local/workspace-runtime-lease.d.ts.map +1 -0
  562. package/dist/local/workspace-runtime-lease.js +123 -0
  563. package/dist/local/workspace-runtime-lease.js.map +1 -0
  564. package/dist/local/workspace-runtime.d.ts +690 -0
  565. package/dist/local/workspace-runtime.d.ts.map +1 -0
  566. package/dist/local/workspace-runtime.js +2124 -0
  567. package/dist/local/workspace-runtime.js.map +1 -0
  568. package/dist/local/workspace-scope.d.ts +70 -0
  569. package/dist/local/workspace-scope.d.ts.map +1 -0
  570. package/dist/local/workspace-scope.js +206 -0
  571. package/dist/local/workspace-scope.js.map +1 -0
  572. package/dist/local/workspace-sources.d.ts +159 -0
  573. package/dist/local/workspace-sources.d.ts.map +1 -0
  574. package/dist/local/workspace-sources.js +570 -0
  575. package/dist/local/workspace-sources.js.map +1 -0
  576. package/dist/local/workspace-store-database.d.ts +5 -0
  577. package/dist/local/workspace-store-database.d.ts.map +1 -0
  578. package/dist/local/workspace-store-database.js +726 -0
  579. package/dist/local/workspace-store-database.js.map +1 -0
  580. package/dist/local/workspace-store.d.ts +261 -0
  581. package/dist/local/workspace-store.d.ts.map +1 -0
  582. package/dist/local/workspace-store.js +831 -0
  583. package/dist/local/workspace-store.js.map +1 -0
  584. package/dist/local/workspace-topology-runtime.d.ts +27 -0
  585. package/dist/local/workspace-topology-runtime.d.ts.map +1 -0
  586. package/dist/local/workspace-topology-runtime.js +396 -0
  587. package/dist/local/workspace-topology-runtime.js.map +1 -0
  588. package/dist/local/workspace-topology.d.ts +140 -0
  589. package/dist/local/workspace-topology.d.ts.map +1 -0
  590. package/dist/local/workspace-topology.js +359 -0
  591. package/dist/local/workspace-topology.js.map +1 -0
  592. package/dist/local/workspace-upstream-inspection.d.ts +60 -0
  593. package/dist/local/workspace-upstream-inspection.d.ts.map +1 -0
  594. package/dist/local/workspace-upstream-inspection.js +189 -0
  595. package/dist/local/workspace-upstream-inspection.js.map +1 -0
  596. package/dist/local/workspace-upstream-runtime.d.ts +91 -0
  597. package/dist/local/workspace-upstream-runtime.d.ts.map +1 -0
  598. package/dist/local/workspace-upstream-runtime.js +270 -0
  599. package/dist/local/workspace-upstream-runtime.js.map +1 -0
  600. package/dist/local/workspace-upstream-store.d.ts +51 -0
  601. package/dist/local/workspace-upstream-store.d.ts.map +1 -0
  602. package/dist/local/workspace-upstream-store.js +475 -0
  603. package/dist/local/workspace-upstream-store.js.map +1 -0
  604. package/dist/local/workspace-viewer-server.d.ts +136 -0
  605. package/dist/local/workspace-viewer-server.d.ts.map +1 -0
  606. package/dist/local/workspace-viewer-server.js +1097 -0
  607. package/dist/local/workspace-viewer-server.js.map +1 -0
  608. package/dist/local/workspace-viewer-snapshot.d.ts +49 -0
  609. package/dist/local/workspace-viewer-snapshot.d.ts.map +1 -0
  610. package/dist/local/workspace-viewer-snapshot.js +91 -0
  611. package/dist/local/workspace-viewer-snapshot.js.map +1 -0
  612. package/dist/local/worktree-projection.d.ts +76 -0
  613. package/dist/local/worktree-projection.d.ts.map +1 -0
  614. package/dist/local/worktree-projection.js +470 -0
  615. package/dist/local/worktree-projection.js.map +1 -0
  616. package/dist/mcp/client-identity.d.ts +8 -0
  617. package/dist/mcp/client-identity.d.ts.map +1 -0
  618. package/dist/mcp/client-identity.js +33 -0
  619. package/dist/mcp/client-identity.js.map +1 -0
  620. package/dist/mcp/graph-to-code.d.ts +53 -0
  621. package/dist/mcp/graph-to-code.d.ts.map +1 -0
  622. package/dist/mcp/graph-to-code.js +1624 -0
  623. package/dist/mcp/graph-to-code.js.map +1 -0
  624. package/dist/mcp/index.d.ts +3 -0
  625. package/dist/mcp/index.d.ts.map +1 -0
  626. package/dist/mcp/index.js +3 -0
  627. package/dist/mcp/index.js.map +1 -0
  628. package/dist/mcp/stdio/graph-to-code.d.ts +3 -0
  629. package/dist/mcp/stdio/graph-to-code.d.ts.map +1 -0
  630. package/dist/mcp/stdio/graph-to-code.js +55 -0
  631. package/dist/mcp/stdio/graph-to-code.js.map +1 -0
  632. package/dist/mcp/stdio/worktree.d.ts +3 -0
  633. package/dist/mcp/stdio/worktree.d.ts.map +1 -0
  634. package/dist/mcp/stdio/worktree.js +67 -0
  635. package/dist/mcp/stdio/worktree.js.map +1 -0
  636. package/dist/mcp/worktree-claim-status.d.ts +162 -0
  637. package/dist/mcp/worktree-claim-status.d.ts.map +1 -0
  638. package/dist/mcp/worktree-claim-status.js +113 -0
  639. package/dist/mcp/worktree-claim-status.js.map +1 -0
  640. package/dist/mcp/worktree-dispatch.d.ts +13 -0
  641. package/dist/mcp/worktree-dispatch.d.ts.map +1 -0
  642. package/dist/mcp/worktree-dispatch.js +52 -0
  643. package/dist/mcp/worktree-dispatch.js.map +1 -0
  644. package/dist/mcp/worktree-errors.d.ts +15 -0
  645. package/dist/mcp/worktree-errors.d.ts.map +1 -0
  646. package/dist/mcp/worktree-errors.js +17 -0
  647. package/dist/mcp/worktree-errors.js.map +1 -0
  648. package/dist/mcp/worktree-health.d.ts +12 -0
  649. package/dist/mcp/worktree-health.d.ts.map +1 -0
  650. package/dist/mcp/worktree-health.js +32 -0
  651. package/dist/mcp/worktree-health.js.map +1 -0
  652. package/dist/mcp/worktree-results.d.ts +15 -0
  653. package/dist/mcp/worktree-results.d.ts.map +1 -0
  654. package/dist/mcp/worktree-results.js +12 -0
  655. package/dist/mcp/worktree-results.js.map +1 -0
  656. package/dist/mcp/worktree-task-context.d.ts +57 -0
  657. package/dist/mcp/worktree-task-context.d.ts.map +1 -0
  658. package/dist/mcp/worktree-task-context.js +45 -0
  659. package/dist/mcp/worktree-task-context.js.map +1 -0
  660. package/dist/mcp/worktree-tools.d.ts +2648 -0
  661. package/dist/mcp/worktree-tools.d.ts.map +1 -0
  662. package/dist/mcp/worktree-tools.js +192 -0
  663. package/dist/mcp/worktree-tools.js.map +1 -0
  664. package/dist/mcp/worktree.d.ts +33 -0
  665. package/dist/mcp/worktree.d.ts.map +1 -0
  666. package/dist/mcp/worktree.js +551 -0
  667. package/dist/mcp/worktree.js.map +1 -0
  668. package/dist/own-package.d.ts +13 -0
  669. package/dist/own-package.d.ts.map +1 -0
  670. package/dist/own-package.js +32 -0
  671. package/dist/own-package.js.map +1 -0
  672. package/dist/packages-browse.d.ts +107 -0
  673. package/dist/packages-browse.d.ts.map +1 -0
  674. package/dist/packages-browse.js +646 -0
  675. package/dist/packages-browse.js.map +1 -0
  676. package/dist/packages-cli.d.ts +8 -0
  677. package/dist/packages-cli.d.ts.map +1 -0
  678. package/dist/packages-cli.js +184 -0
  679. package/dist/packages-cli.js.map +1 -0
  680. package/dist/packages-uses.d.ts +46 -0
  681. package/dist/packages-uses.d.ts.map +1 -0
  682. package/dist/packages-uses.js +737 -0
  683. package/dist/packages-uses.js.map +1 -0
  684. package/dist/portable.d.ts +7 -0
  685. package/dist/portable.d.ts.map +1 -0
  686. package/dist/portable.js +14 -0
  687. package/dist/portable.js.map +1 -0
  688. package/dist/quiet-warnings.d.ts +3 -0
  689. package/dist/quiet-warnings.d.ts.map +1 -0
  690. package/dist/quiet-warnings.js +21 -0
  691. package/dist/quiet-warnings.js.map +1 -0
  692. package/dist/view-seam.d.ts +62 -0
  693. package/dist/view-seam.d.ts.map +1 -0
  694. package/dist/view-seam.js +70 -0
  695. package/dist/view-seam.js.map +1 -0
  696. package/generated/graph-packages/index.json +5 -0
  697. package/graph-packages.lock.json +4 -0
  698. package/package.json +81 -0
  699. package/viewer/assets/index-BZKGDARF.css +1 -0
  700. package/viewer/assets/index-DWu0CbZZ.js +272 -0
  701. package/viewer/index.html +13 -0
@@ -0,0 +1,1524 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { createDocumentNode, documentOutlineForNode, exportDocumentNode, linkDocumentNode, loadDocumentOutline, readDocumentNodeBounded, updateDocumentNode } from './document-commands.js';
4
+ import { parseFileList } from './blast-radius.js';
5
+ import { createGuide, exportGuide, listGuides, parseGuideExport, updateGuide, validateGuide } from './guide-commands.js';
6
+ import { linkJourneyTest, listJourneys, showJourney } from './journey-commands.js';
7
+ import { importTestNodes, linkTestCriterion, linkTestNode } from './test-commands.js';
8
+ import { LocalWorkspaceRuntime } from './workspace-runtime.js';
9
+ import { checkGraphAdmission } from './workspace-admission.js';
10
+ import { parseClaimView } from './workspace-claim-views.js';
11
+ import { gitClaimStatusReader, parseClaimStatus, parseClaimStatusEnvironment, parseClaimStatusView } from './workspace-claim-status.js';
12
+ import { parseSourcesFile, sourceReferenceFailures } from './workspace-evidence.js';
13
+ import { checkSources, coverageSources, gitCoverageReader, limitProblem, lookupSources, ofRepository, parseLookupTarget } from './workspace-sources.js';
14
+ import { integrationBranch, repositoryNames } from './git.js';
15
+ import { local_workspace_task_scope_schema } from './workspace-scope.js';
16
+ import { formatVariantsReport } from './variants.js';
17
+ import { startLocalWorkspaceViewer } from './workspace-viewer-server.js';
18
+ import { appShellReader } from './app-shell-readers.js';
19
+ import { worktreesProvider } from './app-worktrees.js';
20
+ import { loadViewModule, viewerProviders } from '../view-seam.js';
21
+ import { localEnvironmentRemoteConfiguration } from './workspace-remote-provider.js';
22
+ import { applyWorkspaceStorageRelocation, cloneWorkspaceStorage, exportWorkspaceStorage, inspectWorkspaceTopology, planWorkspaceStorageRelocation, recoverWorkspaceStorageRelocation } from './workspace-topology-runtime.js';
23
+ import { LOCAL_WORKSPACE_STORAGE_MODES } from './workspace-topology.js';
24
+ function argumentValue(args, name) {
25
+ const index = args.indexOf(name);
26
+ if (index >= 0)
27
+ return args[index + 1] ?? null;
28
+ const inline = args.find((argument) => argument.startsWith(`${name}=`));
29
+ return inline ? inline.slice(name.length + 1) : null;
30
+ }
31
+ function requiredArgument(args, name) {
32
+ const value = argumentValue(args, name);
33
+ if (!value)
34
+ throw new Error(`Missing required ${name} value.`);
35
+ return value;
36
+ }
37
+ function hasFlag(args, name) {
38
+ return args.includes(name);
39
+ }
40
+ /** Every value of a repeatable argument, in order. */
41
+ function argumentValues(args, name) {
42
+ const values = [];
43
+ args.forEach((argument, index) => {
44
+ if (argument === name && args[index + 1] !== undefined) {
45
+ values.push(args[index + 1]);
46
+ }
47
+ else if (argument.startsWith(`${name}=`)) {
48
+ values.push(argument.slice(name.length + 1));
49
+ }
50
+ });
51
+ return values;
52
+ }
53
+ /** The gate a commit is queued under; a landing when `--gate` is left out. */
54
+ function gateArgument(args) {
55
+ const gate = argumentValue(args, '--gate');
56
+ if (gate === null)
57
+ return undefined;
58
+ if (gate === 'plan' || gate === 'design')
59
+ return gate;
60
+ throw new Error(`Unknown gate ${gate}: use plan or design.`);
61
+ }
62
+ async function taskScopeArgument(args) {
63
+ const scope_file = resolve(requiredArgument(args, '--scope-file'));
64
+ const input = JSON.parse(await readFile(scope_file, 'utf8'));
65
+ return local_workspace_task_scope_schema.parse(input);
66
+ }
67
+ async function jsonFileArgument(args, name) {
68
+ const file_path = resolve(requiredArgument(args, name));
69
+ return JSON.parse(await readFile(file_path, 'utf8'));
70
+ }
71
+ function currentWorkspaceId(runtime) {
72
+ const workspace = runtime.store.getWorkspaceByGitWorktreePath(runtime.git.repository_root);
73
+ if (!workspace || workspace.status !== 'active') {
74
+ throw new Error('The current Git worktree is not an active local workspace. Run sdlc workspace init first.');
75
+ }
76
+ return workspace.id;
77
+ }
78
+ const FIND_USAGE = 'Usage: sdlc workspace find <term>... [--type <type>[,<type>]] [--origin built|shelf] [--limit <n>] [--workspace <workspace-id>] [--view <view>]';
79
+ const SHOW_USAGE = 'Usage: sdlc workspace show <id>... [--budget <chars>] [--full] [--workspace <workspace-id>] [--view <view>]';
80
+ /** The flags of find and show that take a value, the global ones included, so no value is read as a term or id. */
81
+ const READ_VALUE_FLAGS = [
82
+ '--type',
83
+ '--origin',
84
+ '--limit',
85
+ '--budget',
86
+ '--workspace',
87
+ '--view',
88
+ '--repository-state-dir',
89
+ '--graph-repository-id'
90
+ ];
91
+ /** The arguments before `--`, the only ones find and show read flags from. */
92
+ function optionArguments(args) {
93
+ const end = args.indexOf('--');
94
+ return end < 0 ? args : args.slice(0, end);
95
+ }
96
+ /**
97
+ * The terms or ids of a find or show argument list. Refuses, with `usage`, a
98
+ * flag the command does not read, a value flag with no value, or a switch
99
+ * written with a value, rather than reading them as words. After `--`, every
100
+ * argument is a word, so a term may start with dashes.
101
+ */
102
+ function readArguments(args, switches, usage) {
103
+ const out = [];
104
+ for (let index = 0; index < args.length; index++) {
105
+ const argument = args[index];
106
+ if (argument === '--') {
107
+ out.push(...args.slice(index + 1));
108
+ break;
109
+ }
110
+ if (!argument.startsWith('--')) {
111
+ out.push(argument);
112
+ }
113
+ else if (READ_VALUE_FLAGS.some((flag) => argument.startsWith(`${flag}=`))) {
114
+ continue;
115
+ }
116
+ else if (READ_VALUE_FLAGS.includes(argument)) {
117
+ const value = args[index + 1];
118
+ if (value === undefined || value.startsWith('--')) {
119
+ throw new Error(`${argument} needs a value. ${usage}`);
120
+ }
121
+ index++;
122
+ }
123
+ else if (!switches.includes(argument)) {
124
+ throw new Error(`Unknown flag ${argument}. ${usage}`);
125
+ }
126
+ }
127
+ return out;
128
+ }
129
+ function positiveInteger(value, name) {
130
+ const parsed = Number(value);
131
+ if (!Number.isInteger(parsed) || parsed < 1) {
132
+ throw new Error(`${name} takes a positive whole number, not ${value}.`);
133
+ }
134
+ return parsed;
135
+ }
136
+ function workspaceArgument(runtime, args, name = '--workspace') {
137
+ return argumentValue(args, name) ?? currentWorkspaceId(runtime);
138
+ }
139
+ function printJson(value) {
140
+ console.log(JSON.stringify(value, null, 2));
141
+ }
142
+ /**
143
+ * The line `sdlc viewer` prints once it listens. The viewer makes no graph mutation. It writes
144
+ * view state, the pins, named in view_writes when the Threads panel can pin, and coordination
145
+ * records named in coordination_writes when the engine has them: the user's Done on a task (status
146
+ * user-done), and the Worktrees page's Merge (promote join main) and Remove (archive.py worktrees
147
+ * --apply --only). page says which page answers the url: the React viewer, or the classic page when
148
+ * no bundle is built.
149
+ */
150
+ export function viewerStartLine(url, pins, page, userDone = false, worktrees = false) {
151
+ return {
152
+ version: 1,
153
+ status: 'listening',
154
+ url,
155
+ binding: 'loopback',
156
+ mutations: 'unavailable',
157
+ view_writes: pins ? ['pins'] : [],
158
+ coordination_writes: [...(userDone ? ['user-done'] : []), ...(worktrees ? ['worktree-merge', 'worktree-remove'] : [])],
159
+ ...(page === 'classic'
160
+ ? {
161
+ page,
162
+ note: 'The React viewer is not built here (pnpm --dir packages/viewer-web build); serving the classic page.'
163
+ }
164
+ : page
165
+ ? { page, classic: `${url}classic/` }
166
+ : {})
167
+ };
168
+ }
169
+ async function readStream(stream) {
170
+ let text = '';
171
+ for await (const chunk of stream)
172
+ text += String(chunk);
173
+ return text;
174
+ }
175
+ function actorArgument(args) {
176
+ const actor = argumentValue(args, '--actor');
177
+ if (actor === null)
178
+ return undefined;
179
+ if (actor !== 'human' && actor !== 'ai') {
180
+ throw new Error('--actor must be human or ai.');
181
+ }
182
+ return actor;
183
+ }
184
+ function storageModeArgument(args, required = false) {
185
+ const mode = argumentValue(args, '--storage-mode');
186
+ if (mode === null) {
187
+ if (required)
188
+ throw new Error('Missing required --storage-mode value.');
189
+ return undefined;
190
+ }
191
+ if (!LOCAL_WORKSPACE_STORAGE_MODES.includes(mode)) {
192
+ throw new Error('--storage-mode must be machine_shared or self_contained.');
193
+ }
194
+ return mode;
195
+ }
196
+ async function resolverArguments(runtime, args) {
197
+ const resolve_conflicts = hasFlag(args, '--resolve-conflicts');
198
+ const allow_network_resolver = hasFlag(args, '--allow-network-resolver');
199
+ if (!resolve_conflicts) {
200
+ if (allow_network_resolver) {
201
+ throw new Error('--allow-network-resolver requires --resolve-conflicts.');
202
+ }
203
+ return {};
204
+ }
205
+ const loaded = await runtime.loadResolver({
206
+ actor_workspace_id: currentWorkspaceId(runtime),
207
+ allow_network_resolver
208
+ });
209
+ return {
210
+ conflict_resolver: loaded.resolver,
211
+ resolution_budget: loaded.budget,
212
+ allow_network_resolver
213
+ };
214
+ }
215
+ export function isLocalWorkspaceCommand(command, subcommand) {
216
+ return (!(command === 'branch' &&
217
+ (subcommand === 'bind' ||
218
+ subcommand === 'commit' ||
219
+ subcommand === 'apply')) &&
220
+ (command === 'workspace' ||
221
+ command === 'topology' ||
222
+ command === 'integrate' ||
223
+ command === 'handoff' ||
224
+ command === 'resolver' ||
225
+ command === 'portable' ||
226
+ command === 'branch' ||
227
+ command === 'merge' ||
228
+ command === 'viewer' ||
229
+ command === 'variants' ||
230
+ command === 'remote'));
231
+ }
232
+ async function runEnvironmentCommand(runtime, input) {
233
+ const actor_workspace_id = currentWorkspaceId(runtime);
234
+ const key = `${input.command}:${input.subcommand ?? ''}`;
235
+ if (key === 'remote:set') {
236
+ const credential_variable = argumentValue(input.args, '--credential-env');
237
+ const local_defaults = hasFlag(input.args, '--local');
238
+ if (local_defaults && credential_variable !== null) {
239
+ throw new Error('--local always uses SDLC_LOCAL_API_KEY and does not accept --credential-env.');
240
+ }
241
+ const remote = local_defaults
242
+ ? localEnvironmentRemoteConfiguration({
243
+ name: argumentValue(input.args, '--name') ?? undefined,
244
+ url: argumentValue(input.args, '--url') ?? undefined,
245
+ project_id: argumentValue(input.args, '--project-id') ?? undefined
246
+ })
247
+ : {
248
+ name: requiredArgument(input.args, '--name'),
249
+ url: requiredArgument(input.args, '--url'),
250
+ association: {
251
+ kind: 'project',
252
+ project_id: requiredArgument(input.args, '--project-id')
253
+ },
254
+ credential: credential_variable === null
255
+ ? null
256
+ : { kind: 'environment', variable: credential_variable }
257
+ };
258
+ printJson(await runtime.setRemote({
259
+ actor_workspace_id,
260
+ remote
261
+ }));
262
+ }
263
+ else if (key === 'remote:list') {
264
+ printJson({ version: 1, remotes: await runtime.listRemotes() });
265
+ }
266
+ else if (key === 'remote:inspect') {
267
+ printJson(await runtime.inspectRemote(requiredArgument(input.args, '--name')));
268
+ }
269
+ else if (key === 'remote:remove') {
270
+ printJson(await runtime.removeRemote({
271
+ actor_workspace_id,
272
+ name: requiredArgument(input.args, '--name')
273
+ }));
274
+ }
275
+ else if (key === 'remote:discover' || key === 'remote:fetch') {
276
+ const timeout_value = argumentValue(input.args, '--timeout-ms');
277
+ const common = {
278
+ actor_workspace_id,
279
+ name: requiredArgument(input.args, '--name'),
280
+ timeout_ms: timeout_value === null ? undefined : Number(timeout_value)
281
+ };
282
+ printJson(key === 'remote:discover'
283
+ ? await runtime.discoverRemote(common)
284
+ : await runtime.fetchRemote({
285
+ ...common,
286
+ source_ref: requiredArgument(input.args, '--ref')
287
+ }));
288
+ }
289
+ else if (key === 'remote:refs') {
290
+ printJson({
291
+ version: 1,
292
+ refs: runtime.listRemoteTrackingRefs(argumentValue(input.args, '--name') ?? undefined)
293
+ });
294
+ }
295
+ else if (key === 'remote:push') {
296
+ const timeout_value = argumentValue(input.args, '--timeout-ms');
297
+ printJson(await runtime.pushRemote({
298
+ actor_workspace_id,
299
+ name: requiredArgument(input.args, '--name'),
300
+ destination_ref: requiredArgument(input.args, '--ref'),
301
+ new_commit_id: argumentValue(input.args, '--commit') ?? undefined,
302
+ timeout_ms: timeout_value === null ? undefined : Number(timeout_value)
303
+ }));
304
+ }
305
+ else if (key === 'remote:push-journals') {
306
+ printJson({
307
+ version: 1,
308
+ journals: runtime.listRemotePushJournals(argumentValue(input.args, '--name') ?? undefined)
309
+ });
310
+ }
311
+ else if (key === 'remote:topic') {
312
+ const timeout_value = argumentValue(input.args, '--timeout-ms');
313
+ printJson(await runtime.publishRemoteTopic({
314
+ actor_workspace_id,
315
+ name: requiredArgument(input.args, '--name'),
316
+ topic_ref: requiredArgument(input.args, '--ref'),
317
+ target_ref: requiredArgument(input.args, '--target-ref'),
318
+ new_commit_id: argumentValue(input.args, '--commit') ?? undefined,
319
+ timeout_ms: timeout_value === null ? undefined : Number(timeout_value)
320
+ }));
321
+ }
322
+ else if (key === 'remote:topic-journals') {
323
+ printJson({
324
+ version: 1,
325
+ journals: runtime.listRemoteTopicJournals(argumentValue(input.args, '--name') ?? undefined)
326
+ });
327
+ }
328
+ else if (key === 'remote:pr') {
329
+ const timeout_value = argumentValue(input.args, '--timeout-ms');
330
+ printJson(await runtime.createRemotePullRequest({
331
+ actor_workspace_id,
332
+ name: requiredArgument(input.args, '--name'),
333
+ source_ref: requiredArgument(input.args, '--source-ref'),
334
+ target_ref: requiredArgument(input.args, '--target-ref'),
335
+ title: requiredArgument(input.args, '--title'),
336
+ description: argumentValue(input.args, '--description'),
337
+ timeout_ms: timeout_value === null ? undefined : Number(timeout_value)
338
+ }));
339
+ }
340
+ else if (key === 'remote:pr-journals') {
341
+ printJson({
342
+ version: 1,
343
+ journals: runtime.listRemotePullRequestJournals(argumentValue(input.args, '--name') ?? undefined)
344
+ });
345
+ }
346
+ else if (key === 'portable:plan') {
347
+ printJson(await runtime.planPortableHistory({
348
+ actor_workspace_id,
349
+ local_commit_id: argumentValue(input.args, '--commit') ?? undefined
350
+ }));
351
+ }
352
+ else if (key === 'portable:convert') {
353
+ const identity_file = argumentValue(input.args, '--identity-file');
354
+ printJson(await runtime.convertPortableHistory({
355
+ actor_workspace_id,
356
+ local_commit_id: argumentValue(input.args, '--commit') ?? undefined,
357
+ identity_file: identity_file === null
358
+ ? undefined
359
+ : await jsonFileArgument(input.args, '--identity-file'),
360
+ base_remote_name: argumentValue(input.args, '--base-remote') ?? undefined,
361
+ base_source_ref: argumentValue(input.args, '--base-ref') ?? undefined
362
+ }));
363
+ }
364
+ else if (key === 'branch:list') {
365
+ printJson({ version: 1, branches: runtime.listLocalBranches() });
366
+ }
367
+ else if (key === 'branch:create') {
368
+ printJson(await runtime.createLocalBranchFromTrackingRef({
369
+ actor_workspace_id,
370
+ local_ref: requiredArgument(input.args, '--ref'),
371
+ remote_name: requiredArgument(input.args, '--from-remote'),
372
+ source_ref: requiredArgument(input.args, '--from-ref')
373
+ }));
374
+ }
375
+ else if (key === 'branch:select') {
376
+ printJson(await runtime.selectLocalBranch({ actor_workspace_id }));
377
+ }
378
+ else if (key === 'merge:upstream') {
379
+ const result = await runtime.integrateBranchUpstream({
380
+ actor_workspace_id,
381
+ ...(await resolverArguments(runtime, input.args))
382
+ });
383
+ printJson(result);
384
+ if (result.status !== 'already_integrated' &&
385
+ result.status !== 'fast_forwarded' &&
386
+ result.status !== 'merged') {
387
+ process.exitCode = 2;
388
+ }
389
+ }
390
+ else if (key === 'merge:status') {
391
+ printJson(await runtime.inspectBranchUpstream({ actor_workspace_id }));
392
+ }
393
+ else if (key === 'merge:revert') {
394
+ const result = await runtime.revertBranchUpstream({
395
+ actor_workspace_id,
396
+ branch_integration_attempt_id: requiredArgument(input.args, '--attempt'),
397
+ message: argumentValue(input.args, '--message') ?? undefined
398
+ });
399
+ printJson(result);
400
+ if (result.status !== 'reverted')
401
+ process.exitCode = 2;
402
+ }
403
+ else if (key === 'merge:attempts') {
404
+ printJson({
405
+ version: 1,
406
+ attempts: runtime.listBranchIntegrationAttempts(argumentValue(input.args, '--ref') ?? undefined)
407
+ });
408
+ }
409
+ else if (key === 'merge:resolution-attempts') {
410
+ printJson({
411
+ version: 1,
412
+ attempts: runtime.listBranchIntegrationResolutionAttempts(requiredArgument(input.args, '--attempt'))
413
+ });
414
+ }
415
+ else if (key === 'merge:reverts') {
416
+ printJson({
417
+ version: 1,
418
+ attempts: runtime.listBranchIntegrationRevertAttempts(argumentValue(input.args, '--ref') ?? undefined)
419
+ });
420
+ }
421
+ else if (key === 'resolver:configure') {
422
+ printJson(await runtime.configureResolverFromFile({
423
+ actor_workspace_id,
424
+ path: requiredArgument(input.args, '--file')
425
+ }));
426
+ }
427
+ else if (key === 'resolver:status') {
428
+ printJson(await runtime.resolverStatus());
429
+ }
430
+ else if (key === 'resolver:clear') {
431
+ printJson(await runtime.clearResolver({ actor_workspace_id }));
432
+ }
433
+ else {
434
+ return false;
435
+ }
436
+ return true;
437
+ }
438
+ const DOCUMENT_USAGE = 'Usage: sdlc workspace doc new [<uuid>] --outline <file> | update <node> --outline <file> | outline <node> [--output <file>] | export <node> | read <node> --outline|--section <block>|--search <text> [--max-results <n>] | link <node> --describes <node> [--id <uuid>] [--description <text>]';
439
+ /**
440
+ * `sdlc workspace doc`: Document nodes in the current workspace's
441
+ * projection, under the workspace's authority check and operation lock.
442
+ */
443
+ async function runDocumentCommand(runtime, args) {
444
+ const [action, positional] = args;
445
+ return runtime.withDocumentProjection({
446
+ actor_workspace_id: currentWorkspaceId(runtime),
447
+ operation: action ?? 'doc',
448
+ run: (projection_dir) => documentCommand(projection_dir, action, positional, args)
449
+ });
450
+ }
451
+ async function documentCommand(projection_dir, action, positional, args) {
452
+ const node_id = positional && !positional.startsWith('--') ? positional : null;
453
+ const requiredNode = () => {
454
+ if (!node_id)
455
+ throw new Error(DOCUMENT_USAGE);
456
+ return node_id;
457
+ };
458
+ const outlineFile = () => loadDocumentOutline(resolve(requiredArgument(args, '--outline')));
459
+ switch (action) {
460
+ case 'new': {
461
+ // The node id may be given like every other doc command, or as --id.
462
+ const flag_id = argumentValue(args, '--id');
463
+ if (node_id && flag_id && node_id !== flag_id) {
464
+ throw new Error(`Two node ids given: ${node_id} and --id ${flag_id}.`);
465
+ }
466
+ return createDocumentNode({
467
+ projection_dir,
468
+ outline: await outlineFile(),
469
+ node_id: node_id ?? flag_id ?? undefined
470
+ });
471
+ }
472
+ case 'update':
473
+ return updateDocumentNode({
474
+ projection_dir,
475
+ node_id: requiredNode(),
476
+ outline: await outlineFile()
477
+ });
478
+ case 'outline': {
479
+ const outline = await documentOutlineForNode(projection_dir, requiredNode());
480
+ const output = argumentValue(args, '--output');
481
+ if (!output)
482
+ return outline;
483
+ await writeFile(resolve(output), `${JSON.stringify(outline, null, 2)}\n`);
484
+ return {
485
+ version: 1,
486
+ status: 'written',
487
+ path: resolve(output),
488
+ source_hash: outline.source_hash
489
+ };
490
+ }
491
+ case 'export':
492
+ return exportDocumentNode(projection_dir, requiredNode());
493
+ case 'read': {
494
+ const section = argumentValue(args, '--section');
495
+ const search = argumentValue(args, '--search');
496
+ const max_results = argumentValue(args, '--max-results');
497
+ const request = hasFlag(args, '--outline')
498
+ ? { read: 'outline' }
499
+ : section !== null
500
+ ? { read: 'section', heading_id: section }
501
+ : search !== null
502
+ ? {
503
+ read: 'search',
504
+ query: search,
505
+ ...(max_results !== null
506
+ ? { max_results: Number(max_results) }
507
+ : {})
508
+ }
509
+ : null;
510
+ if (!request)
511
+ throw new Error(DOCUMENT_USAGE);
512
+ return readDocumentNodeBounded(projection_dir, requiredNode(), request);
513
+ }
514
+ case 'link':
515
+ return linkDocumentNode({
516
+ projection_dir,
517
+ node_id: requiredNode(),
518
+ target_id: requiredArgument(args, '--describes'),
519
+ edge_id: argumentValue(args, '--id') ?? undefined,
520
+ description: argumentValue(args, '--description') ?? undefined
521
+ });
522
+ default:
523
+ throw new Error(DOCUMENT_USAGE);
524
+ }
525
+ }
526
+ const DECISION_USAGE = 'Usage: sdlc workspace decision open --question <text> --criterion <text>... [--evaluation <text>...] --decider <who> [--base <commit>] | list | show <decision> | attach <decision> --workspace <id> [--label <text>] | detach <decision> --workspace <id> --reason <text> | digest <decision> --winner <workspace> [--part <workspace>@<pick receipt>=<entity>[,<entity>...]...] | select <decision> --winner <workspace> [--part ...] --digest <sha256> --reason <text> | close <decision> --reason <text> | abandon <decision> --reason <text> | reopen <decision> --reason <text> [--candidate <closed workspace> --path <new worktree>]';
527
+ /**
528
+ * `--part <workspace>@<receipt>=<kind>:<id>,<kind>:<id>` names entities the
529
+ * winner picked from another candidate, and the receipt of that pick.
530
+ */
531
+ function decisionParts(args) {
532
+ return argumentValues(args, '--part').map((value) => {
533
+ const separator = value.indexOf('=');
534
+ const receipt = value.lastIndexOf('@', separator);
535
+ if (receipt <= 0 || separator <= receipt + 1) {
536
+ throw new Error(DECISION_USAGE);
537
+ }
538
+ return {
539
+ candidate_workspace_id: value.slice(0, receipt),
540
+ pick_receipt_id: value.slice(receipt + 1, separator),
541
+ entities: value
542
+ .slice(separator + 1)
543
+ .split(',')
544
+ .map((entity) => entity.trim())
545
+ .filter(Boolean)
546
+ };
547
+ });
548
+ }
549
+ const PICK_USAGE = 'Usage: sdlc workspace pick --from <workspace> [--commit <id>] --entity <kind>:<id>... [--with-dependencies] [--dry-run] [--message <text>] [--workspace <id>] | pick list [--workspace <id>] | pick show <receipt>';
550
+ const PICK_ENTITY_KINDS = ['node', 'edge', 'path', 'path_relation'];
551
+ /** `--entity <kind>:<id>`, repeatable. */
552
+ function pickEntities(args) {
553
+ return argumentValues(args, '--entity').map((value) => {
554
+ const separator = value.indexOf(':');
555
+ const entity_kind = PICK_ENTITY_KINDS.find((kind) => kind === value.slice(0, separator));
556
+ const entity_id = value.slice(separator + 1);
557
+ if (separator < 1 || !entity_kind || !entity_id) {
558
+ throw new Error(`--entity is <kind>:<id> with kind ${PICK_ENTITY_KINDS.join(', ')}; got ${value}.`);
559
+ }
560
+ return { entity_kind, entity_id };
561
+ });
562
+ }
563
+ const PICK_VALUE_FLAGS = [
564
+ '--from',
565
+ '--commit',
566
+ '--entity',
567
+ '--message',
568
+ '--workspace',
569
+ '--repository-state-dir',
570
+ '--graph-repository-id'
571
+ ];
572
+ const PICK_SWITCHES = ['--with-dependencies', '--dry-run'];
573
+ /**
574
+ * Rejects a pick argument list that would otherwise be read wrongly: a value
575
+ * flag with no value or with another flag as its value, an unknown flag, or a
576
+ * stray word. A value that starts with `--` is written `--flag=value`.
577
+ */
578
+ function assertPickArguments(args) {
579
+ for (let index = 0; index < args.length; index += 1) {
580
+ const argument = args[index];
581
+ if (PICK_SWITCHES.includes(argument))
582
+ continue;
583
+ if (PICK_VALUE_FLAGS.some((flag) => argument.startsWith(`${flag}=`))) {
584
+ continue;
585
+ }
586
+ const value = args[index + 1];
587
+ if (!PICK_VALUE_FLAGS.includes(argument) ||
588
+ value === undefined ||
589
+ value.startsWith('--')) {
590
+ throw new Error(PICK_USAGE);
591
+ }
592
+ index += 1;
593
+ }
594
+ }
595
+ /**
596
+ * `sdlc workspace pick`: copy chosen entities from another workspace
597
+ * (docs/specs/local-ai-multi-worktree-integration.md, Pick).
598
+ */
599
+ async function runPickCommand(runtime, args) {
600
+ const [action, positional] = args;
601
+ if (action === 'list') {
602
+ return {
603
+ version: 1,
604
+ receipts: runtime.store.picks.listReceipts(workspaceArgument(runtime, args))
605
+ };
606
+ }
607
+ if (action === 'show') {
608
+ if (!positional || positional.startsWith('--'))
609
+ throw new Error(PICK_USAGE);
610
+ return runtime.store.picks.getReceipt(positional);
611
+ }
612
+ assertPickArguments(args);
613
+ const result = await runtime.pickEntities({
614
+ actor_workspace_id: workspaceArgument(runtime, args),
615
+ source_workspace_id: requiredArgument(args, '--from'),
616
+ source_commit_id: argumentValue(args, '--commit') ?? undefined,
617
+ selection: pickEntities(args),
618
+ with_dependencies: hasFlag(args, '--with-dependencies'),
619
+ dry_run: hasFlag(args, '--dry-run'),
620
+ message: argumentValue(args, '--message') ?? undefined
621
+ });
622
+ if (result.status.startsWith('blocked_') ||
623
+ result.status === 'picked_recovery_required') {
624
+ process.exitCode = 2;
625
+ }
626
+ return result;
627
+ }
628
+ /**
629
+ * `sdlc workspace decision`: local Decisions over candidate plan workspaces
630
+ * (docs/specs/graph-variants.md, Decisions, Local first). The only writer of
631
+ * Decision records.
632
+ */
633
+ async function runDecisionCommand(runtime, args) {
634
+ const [action, positional] = args;
635
+ const decisions = runtime.store.decisions;
636
+ const actor = await runtime.decisionActor();
637
+ const decision_id = () => {
638
+ if (!positional || positional.startsWith('--')) {
639
+ throw new Error(DECISION_USAGE);
640
+ }
641
+ return positional;
642
+ };
643
+ const selection = () => ({
644
+ decision_id: decision_id(),
645
+ winner_workspace_id: requiredArgument(args, '--winner'),
646
+ parts: decisionParts(args)
647
+ });
648
+ switch (action) {
649
+ case 'open':
650
+ return decisions.openDecision({
651
+ actor_workspace_id: actor.id,
652
+ question: requiredArgument(args, '--question'),
653
+ criteria: argumentValues(args, '--criterion'),
654
+ evaluations: argumentValues(args, '--evaluation'),
655
+ decider: requiredArgument(args, '--decider'),
656
+ base_commit_id: argumentValue(args, '--base') ?? undefined
657
+ });
658
+ case 'list':
659
+ return { version: 1, decisions: decisions.listDecisions() };
660
+ case 'show':
661
+ return decisions.getDecision(decision_id());
662
+ case 'attach':
663
+ return decisions.attachCandidate({
664
+ decision_id: decision_id(),
665
+ workspace_id: requiredArgument(args, '--workspace'),
666
+ label: argumentValue(args, '--label') ?? undefined
667
+ });
668
+ case 'detach':
669
+ return decisions.detachCandidate({
670
+ decision_id: decision_id(),
671
+ workspace_id: requiredArgument(args, '--workspace'),
672
+ reason: requiredArgument(args, '--reason')
673
+ });
674
+ case 'digest':
675
+ return decisions.selectionDigest(selection());
676
+ case 'select':
677
+ return decisions.select({
678
+ ...selection(),
679
+ digest: requiredArgument(args, '--digest'),
680
+ reason: requiredArgument(args, '--reason')
681
+ });
682
+ case 'close':
683
+ return decisions.closeDecision({
684
+ decision_id: decision_id(),
685
+ reason: requiredArgument(args, '--reason')
686
+ });
687
+ case 'abandon':
688
+ return decisions.abandon({
689
+ decision_id: decision_id(),
690
+ reason: requiredArgument(args, '--reason')
691
+ });
692
+ case 'reopen':
693
+ return runtime.reopenDecision({
694
+ decision_id: decision_id(),
695
+ reason: requiredArgument(args, '--reason'),
696
+ revive_workspace_id: argumentValue(args, '--candidate') ?? undefined,
697
+ target_path: argumentValue(args, '--path') ?? undefined
698
+ });
699
+ default:
700
+ throw new Error(DECISION_USAGE);
701
+ }
702
+ }
703
+ const TEST_USAGE = 'Usage: sdlc workspace test import [--parent <feature or story>] [--dry-run] | link <test> --verifies <node> [--id <uuid>] | link <test> --criterion <node>#<criterion> [--id <uuid>] | link <test> --journey <entry story> [--via <story,...>]';
704
+ const JOURNEY_USAGE = 'Usage: sdlc workspace journey list | show <entry story>';
705
+ const GUIDE_USAGE = 'Usage: sdlc workspace guide create --journey <entry story> --label <title> [--description <summary>] [--id <uuid>] | export <guide> [--output <file>] | update <guide> --file <file> | validate <guide> | list';
706
+ const ADMISSION_USAGE = 'Usage: sdlc workspace admission show | record --origin <origin> [--capability <name>]... --evidence <text> | check --graph-file <file>';
707
+ /**
708
+ * `sdlc workspace admission`: the repository's vocabulary admission record
709
+ * (Local Vocabulary Admission Gate). promote publish records what its origin
710
+ * advertised and checks its export before saving; check exits 1 when the
711
+ * graph holds an item the record does not admit.
712
+ */
713
+ async function runAdmissionCommand(runtime, args) {
714
+ const [action] = args;
715
+ if (action === 'show') {
716
+ return { version: 1, admission: runtime.store.admissions.get() };
717
+ }
718
+ if (action === 'record') {
719
+ return {
720
+ version: 1,
721
+ status: 'recorded',
722
+ admission: runtime.store.admissions.record({
723
+ origin: requiredArgument(args, '--origin'),
724
+ capabilities: argumentValues(args, '--capability'),
725
+ evidence: requiredArgument(args, '--evidence')
726
+ })
727
+ };
728
+ }
729
+ if (action === 'check') {
730
+ const file = requiredArgument(args, '--graph-file');
731
+ const graph = JSON.parse(await readFile(resolve(file), 'utf8'));
732
+ if (!Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
733
+ throw new Error(`${file} is not a graph with nodes and edges.`);
734
+ }
735
+ const result = checkGraphAdmission({
736
+ graph: graph,
737
+ admission: runtime.store.admissions.get()
738
+ });
739
+ if (result.status === 'refused')
740
+ process.exitCode = 1;
741
+ return result;
742
+ }
743
+ throw new Error(ADMISSION_USAGE);
744
+ }
745
+ const EVIDENCE_USAGE = 'Usage: sdlc workspace evidence status [--behind] [--node <id>]... [--edge <id>]... | verify --sources <file> [--commit <commit>] | sign [--node <id>]... [--edge <id>]... [--changed] [--reference <id>]... [--commit <commit>] [--repository <dir>] | record --sources <file> [--commit <commit>] [--sign] | lookup <path>[:<line>]|<directory>/ [--symbol <name>] | check [--commit <commit>] | coverage [--commit <commit>] [--under <dir>] [--files]\n' +
746
+ 'Every evidence command but verify takes --graph <dir>, the worktree of the local workspace whose graph it writes or reads (default: here); record, lookup, check and coverage take --repository <dir>, the Git repository whose code the references cite (default: here). check and coverage default --commit to the integration branch, record to HEAD. lookup, check and coverage read the projection as it stands, with each pending claim at its built content. record exits 4 when some references did not hold and only the rest were recorded, and needs a remote that names <owner>/<name> (the tracked remote, else origin): references name their repository by it.';
747
+ /** The flags of the evidence readers that take a value. */
748
+ const EVIDENCE_VALUE_FLAGS = [
749
+ '--symbol',
750
+ '--commit',
751
+ '--under',
752
+ '--repository',
753
+ '--graph',
754
+ '--repository-state-dir',
755
+ '--graph-repository-id'
756
+ ];
757
+ /** The first argument that is neither a flag nor a value flag's value: lookup's target. */
758
+ function evidenceTarget(args) {
759
+ for (let index = 0; index < args.length; index++) {
760
+ const argument = args[index];
761
+ if (EVIDENCE_VALUE_FLAGS.includes(argument))
762
+ index++;
763
+ else if (!argument.startsWith('--'))
764
+ return argument;
765
+ }
766
+ return null;
767
+ }
768
+ /**
769
+ * `sdlc workspace evidence record`: a sources file's references, verified at
770
+ * a commit of --repository by the landing's rule set, written into the
771
+ * projection of --graph's workspace (sources.py record). The references that
772
+ * hold are written and the rest listed under not_recorded, with every
773
+ * reference of a node that would pass 100 references; nothing is written
774
+ * when none holds. With --sign, exactly those references are signed under the
775
+ * same workspace lock, or nothing is left written.
776
+ */
777
+ async function runEvidenceRecord(runtime, args) {
778
+ const file = requiredArgument(args, '--sources');
779
+ const nodes = parseSourcesFile(JSON.parse(await readFile(resolve(file), 'utf8')), file);
780
+ const repository = resolve(argumentValue(args, '--repository') ?? '.');
781
+ const git = gitClaimStatusReader(repository);
782
+ const asked = argumentValue(args, '--commit') ?? 'HEAD';
783
+ const commit = await git.resolve(asked);
784
+ if (commit === null)
785
+ throw new Error(`${asked} is not a commit in ${repository}.`);
786
+ const failures = await sourceReferenceFailures({ git, commit, nodes });
787
+ const failing = new Set(failures.map((failure) => `${failure.node}\u0000${failure.index}`));
788
+ const held = {};
789
+ for (const [node, specs] of Object.entries(nodes)) {
790
+ const kept = specs.filter((_, index) => !failing.has(`${node}\u0000${index}`));
791
+ if (kept.length)
792
+ held[node] = kept;
793
+ }
794
+ if (!Object.keys(held).length)
795
+ throw new Error(`no reference holds, so nothing was recorded: ${failures
796
+ .map((failure) => `node ${failure.node}: ${failure.problem}`)
797
+ .join('; ')}`);
798
+ const { over_limit, ...result } = await runtime.recordSourceReferences({
799
+ actor_workspace_id: currentWorkspaceId(runtime),
800
+ nodes: held,
801
+ commit,
802
+ repository,
803
+ sign: hasFlag(args, '--sign')
804
+ });
805
+ // A node over the reference limit is left out whole (iss-525), each of its references listed.
806
+ const too_many = Object.entries(over_limit).map(([node, count]) => ({
807
+ node,
808
+ specs: held[node],
809
+ problem: limitProblem(count, held[node].map((spec) => spec.path))
810
+ }));
811
+ if (!result.recorded.length)
812
+ throw new Error(`no node could be recorded, so nothing was: ${[
813
+ ...failures.map((failure) => `node ${failure.node}: ${failure.problem}`),
814
+ ...too_many.map(({ node, problem }) => `node ${node}: ${problem}`)
815
+ ].join('; ')}`);
816
+ const not_recorded = [
817
+ ...failures.map((failure) => ({
818
+ node: failure.node,
819
+ ...nodes[failure.node][failure.index],
820
+ problem: failure.problem
821
+ })),
822
+ ...too_many.flatMap(({ node, specs, problem }) => specs.map((spec) => ({ node, ...spec, problem })))
823
+ ];
824
+ // 4: the references that hold were written, and the listed ones need fixing.
825
+ if (not_recorded.length)
826
+ process.exitCode = 4;
827
+ return {
828
+ version: 1,
829
+ status: not_recorded.length ? 'partial' : 'recorded',
830
+ commit,
831
+ ...result,
832
+ not_recorded,
833
+ ...(result.signed
834
+ ? { widened_scope: result.signed.widened_scope ?? [] }
835
+ : {}),
836
+ then: 'Run sdlc workspace commit in the graph worktree so blast radius and readiness read the references.'
837
+ };
838
+ }
839
+ /** `sdlc workspace evidence lookup|check|coverage`: the graph as built read against --repository's code. */
840
+ async function runEvidenceReader(runtime, action, args) {
841
+ const repository = resolve(argumentValue(args, '--repository') ?? '.');
842
+ const index = await runtime.workspaceSourceIndex({
843
+ workspace_id: currentWorkspaceId(runtime)
844
+ });
845
+ const entries = ofRepository(index.entries, await repositoryNames(repository));
846
+ const git = gitClaimStatusReader(repository);
847
+ const commit = argumentValue(args, '--commit') ?? (await integrationBranch(repository));
848
+ if (action === 'lookup') {
849
+ const target = evidenceTarget(args.slice(1));
850
+ if (!target)
851
+ throw new Error(EVIDENCE_USAGE);
852
+ const { path, line } = parseLookupTarget(target);
853
+ const symbol = argumentValue(args, '--symbol');
854
+ return {
855
+ version: 1,
856
+ status: 'ok',
857
+ path,
858
+ line,
859
+ symbol,
860
+ matches: lookupSources(entries, path, line, symbol)
861
+ };
862
+ }
863
+ if (action === 'check')
864
+ return {
865
+ version: 1,
866
+ status: 'ok',
867
+ ...(await checkSources(git, commit, entries, index.nodes))
868
+ };
869
+ const { unnamed, ...coverage } = await coverageSources(gitCoverageReader(repository, git), commit, entries, argumentValue(args, '--under') ?? '');
870
+ return {
871
+ version: 1,
872
+ status: 'ok',
873
+ ...coverage,
874
+ ...(hasFlag(args, '--files')
875
+ ? { unnamed }
876
+ : { unnamed_count: unnamed.length })
877
+ };
878
+ }
879
+ /**
880
+ * `sdlc workspace evidence verify`: a sources file's references checked at a
881
+ * commit by the landing's rule set. It reads Git only, so it runs in any
882
+ * repository, with or without a local workspace store. Exits 1 when a
883
+ * reference does not hold.
884
+ */
885
+ async function runEvidenceVerify(args) {
886
+ const file = requiredArgument(args, '--sources');
887
+ const nodes = parseSourcesFile(JSON.parse(await readFile(resolve(file), 'utf8')), file);
888
+ const git = gitClaimStatusReader(process.cwd());
889
+ const asked = argumentValue(args, '--commit') ?? 'HEAD';
890
+ const commit = await git.resolve(asked);
891
+ if (commit === null)
892
+ throw new Error(`${asked} is not a commit in this repository.`);
893
+ const failures = await sourceReferenceFailures({ git, commit, nodes });
894
+ const problems = failures.map((failure) => `node ${failure.node}: ${failure.problem}`);
895
+ printJson({
896
+ version: 1,
897
+ status: problems.length ? 'refused' : 'holds',
898
+ commit,
899
+ problems,
900
+ // Each reference that does not hold, by its node and place in the node's list.
901
+ failures
902
+ });
903
+ if (problems.length)
904
+ process.exitCode = 1;
905
+ }
906
+ /** `sdlc workspace evidence status|sign`: claim freshness in, and sign-off of, the current workspace's projection. */
907
+ async function runEvidenceCommand(runtime, args) {
908
+ const [action] = args;
909
+ const nodes = argumentValues(args, '--node');
910
+ const edges = argumentValues(args, '--edge');
911
+ if (action === 'status') {
912
+ return runtime.workspaceEvidenceStatus({
913
+ actor_workspace_id: currentWorkspaceId(runtime),
914
+ nodes,
915
+ edges,
916
+ behind_only: hasFlag(args, '--behind')
917
+ });
918
+ }
919
+ if (action === 'sign') {
920
+ const references = argumentValues(args, '--reference');
921
+ const changed = hasFlag(args, '--changed');
922
+ if (!nodes.length && !edges.length && !references.length && !changed)
923
+ throw new Error('Name what to sign: --node, --edge, --reference, or --changed.');
924
+ const result = await runtime.signEvidence({
925
+ actor_workspace_id: currentWorkspaceId(runtime),
926
+ nodes,
927
+ edges,
928
+ references,
929
+ changed,
930
+ commit: argumentValue(args, '--commit') ?? undefined,
931
+ repository: argumentValue(args, '--repository') ?? undefined
932
+ });
933
+ if (result.status === 'refused')
934
+ process.exitCode = 1;
935
+ return result;
936
+ }
937
+ if (action === 'record')
938
+ return runEvidenceRecord(runtime, args);
939
+ if (action === 'lookup' || action === 'check' || action === 'coverage')
940
+ return runEvidenceReader(runtime, action, args);
941
+ throw new Error(EVIDENCE_USAGE);
942
+ }
943
+ /** `sdlc workspace journey`: journeys derived in the current workspace's projection. */
944
+ async function runJourneyCommand(runtime, args) {
945
+ const [action, positional] = args;
946
+ return runtime.withDocumentProjection({
947
+ actor_workspace_id: currentWorkspaceId(runtime),
948
+ operation: `journey-${action ?? 'journey'}`,
949
+ run: async (projection_dir) => {
950
+ if (action === 'list')
951
+ return listJourneys({ projection_dir });
952
+ if (action === 'show' && positional && !positional.startsWith('--')) {
953
+ return showJourney({ projection_dir, entry: positional });
954
+ }
955
+ throw new Error(JOURNEY_USAGE);
956
+ }
957
+ });
958
+ }
959
+ /**
960
+ * `sdlc workspace guide`: guides in the current workspace's projection
961
+ * (docs/specs/maintain-guides.md). validate exits 1 when the guide is not
962
+ * publishable.
963
+ */
964
+ async function runGuideCommand(runtime, args) {
965
+ const [action, positional] = args;
966
+ const node_id = positional && !positional.startsWith('--') ? positional : null;
967
+ const requiredGuide = () => {
968
+ if (!node_id)
969
+ throw new Error(GUIDE_USAGE);
970
+ return node_id;
971
+ };
972
+ return runtime.withDocumentProjection({
973
+ actor_workspace_id: currentWorkspaceId(runtime),
974
+ operation: `guide-${action ?? 'guide'}`,
975
+ run: async (projection_dir) => {
976
+ switch (action) {
977
+ case 'create':
978
+ return createGuide({
979
+ projection_dir,
980
+ journey: requiredArgument(args, '--journey'),
981
+ label: requiredArgument(args, '--label'),
982
+ description: argumentValue(args, '--description') ?? undefined,
983
+ node_id: argumentValue(args, '--id') ?? undefined
984
+ });
985
+ case 'export': {
986
+ const file = await exportGuide({ projection_dir, node_id: requiredGuide() });
987
+ const output = argumentValue(args, '--output');
988
+ if (!output)
989
+ return file;
990
+ await writeFile(resolve(output), `${JSON.stringify(file, null, 2)}\n`);
991
+ return {
992
+ version: 1,
993
+ status: 'written',
994
+ path: resolve(output),
995
+ source_hash: file.source_hash
996
+ };
997
+ }
998
+ case 'update':
999
+ return updateGuide({
1000
+ projection_dir,
1001
+ node_id: requiredGuide(),
1002
+ file: parseGuideExport(JSON.parse(await readFile(resolve(requiredArgument(args, '--file')), 'utf8')))
1003
+ });
1004
+ case 'validate': {
1005
+ const result = await validateGuide({ projection_dir, node_id: requiredGuide() });
1006
+ if (!result.publishable)
1007
+ process.exitCode = 1;
1008
+ return result;
1009
+ }
1010
+ case 'list':
1011
+ return listGuides({ projection_dir });
1012
+ default:
1013
+ throw new Error(GUIDE_USAGE);
1014
+ }
1015
+ }
1016
+ });
1017
+ }
1018
+ /**
1019
+ * `sdlc workspace test`: test nodes in the current workspace's projection,
1020
+ * proposed from the spec files of the workspace's own checkout.
1021
+ */
1022
+ async function runTestCommand(runtime, args) {
1023
+ const [action, positional] = args;
1024
+ return runtime.withDocumentProjection({
1025
+ actor_workspace_id: currentWorkspaceId(runtime),
1026
+ operation: `test-${action ?? 'test'}`,
1027
+ run: async (projection_dir) => {
1028
+ if (action === 'import') {
1029
+ return importTestNodes({
1030
+ projection_dir,
1031
+ repository_root: dirname(projection_dir),
1032
+ parent_id: argumentValue(args, '--parent') ?? undefined,
1033
+ dry_run: hasFlag(args, '--dry-run')
1034
+ });
1035
+ }
1036
+ if (action === 'link' &&
1037
+ ['--verifies', '--criterion', '--journey'].filter((flag) => argumentValue(args, flag)).length > 1) {
1038
+ throw new Error('Give one of --verifies, --criterion or --journey.');
1039
+ }
1040
+ if (action === 'link' &&
1041
+ positional &&
1042
+ !positional.startsWith('--') &&
1043
+ argumentValue(args, '--journey')) {
1044
+ const via = argumentValue(args, '--via');
1045
+ return linkJourneyTest({
1046
+ projection_dir,
1047
+ node_id: positional,
1048
+ entry: requiredArgument(args, '--journey'),
1049
+ via: via
1050
+ ? via
1051
+ .split(',')
1052
+ .map((id) => id.trim())
1053
+ .filter(Boolean)
1054
+ : undefined
1055
+ });
1056
+ }
1057
+ if (action === 'link' &&
1058
+ positional &&
1059
+ !positional.startsWith('--') &&
1060
+ argumentValue(args, '--criterion')) {
1061
+ return linkTestCriterion({
1062
+ projection_dir,
1063
+ node_id: positional,
1064
+ criterion: requiredArgument(args, '--criterion'),
1065
+ edge_id: argumentValue(args, '--id') ?? undefined
1066
+ });
1067
+ }
1068
+ if (action === 'link' && positional && !positional.startsWith('--')) {
1069
+ return linkTestNode({
1070
+ projection_dir,
1071
+ node_id: positional,
1072
+ target_id: requiredArgument(args, '--verifies'),
1073
+ edge_id: argumentValue(args, '--id') ?? undefined
1074
+ });
1075
+ }
1076
+ throw new Error(TEST_USAGE);
1077
+ }
1078
+ });
1079
+ }
1080
+ async function runWorkspaceCommand(runtime, input) {
1081
+ if (input.command !== 'workspace')
1082
+ return false;
1083
+ const subcommand = input.subcommand;
1084
+ if (subcommand === 'init') {
1085
+ printJson(await runtime.initializeCurrentWorkspace({
1086
+ actor_kind: actorArgument(input.args) ?? 'human',
1087
+ source_repository_association_id: argumentValue(input.args, '--source-association') ?? undefined,
1088
+ source_remote_name: argumentValue(input.args, '--source-remote') ?? undefined,
1089
+ storage_mode: storageModeArgument(input.args)
1090
+ }));
1091
+ }
1092
+ else if (subcommand === 'attach' && hasFlag(input.args, '--all-members')) {
1093
+ const given = [
1094
+ '--source-workspace',
1095
+ '--expected-graph-head',
1096
+ '--source-association',
1097
+ '--source-remote',
1098
+ '--scope-file'
1099
+ ].filter((flag) => argumentValue(input.args, flag) !== null);
1100
+ if (given.length > 0) {
1101
+ throw new Error(`attach --all-members attaches every member from this workspace's head with the entities citing it, so it takes no ${given.join(', ')}.`);
1102
+ }
1103
+ printJson(await runtime.attachFolderMembers({
1104
+ actor_kind: actorArgument(input.args) ?? 'human',
1105
+ storage_mode: storageModeArgument(input.args),
1106
+ full_projection: hasFlag(input.args, '--full-projection')
1107
+ }));
1108
+ }
1109
+ else if (subcommand === 'attach') {
1110
+ printJson(await runtime.attachCurrentSourceWorkspace({
1111
+ source_workspace_id: requiredArgument(input.args, '--source-workspace'),
1112
+ expected_source_sdlc_head_commit_id: requiredArgument(input.args, '--expected-graph-head'),
1113
+ source_repository_association_id: requiredArgument(input.args, '--source-association'),
1114
+ source_remote_name: argumentValue(input.args, '--source-remote') ?? undefined,
1115
+ actor_kind: actorArgument(input.args) ?? 'human',
1116
+ storage_mode: storageModeArgument(input.args),
1117
+ task_scope: await taskScopeArgument(input.args),
1118
+ full_projection: hasFlag(input.args, '--full-projection')
1119
+ }));
1120
+ }
1121
+ else if (subcommand === 'context') {
1122
+ printJson(await runtime.getMultiRepositoryContext());
1123
+ }
1124
+ else if (subcommand === 'detach') {
1125
+ printJson(await runtime.detachCurrentSourceWorkspace());
1126
+ }
1127
+ else if (subcommand === 'list') {
1128
+ printJson({ version: 1, workspaces: runtime.listWorkspaces() });
1129
+ }
1130
+ else if (subcommand === 'overlap') {
1131
+ printJson(await runtime.compareChildWorkspacePlans({
1132
+ coordinator_workspace_id: workspaceArgument(runtime, input.args, '--coordinator')
1133
+ }));
1134
+ }
1135
+ else if (subcommand === 'scope') {
1136
+ const actor_workspace_id = currentWorkspaceId(runtime);
1137
+ printJson(await runtime.replaceTaskScope({
1138
+ actor_workspace_id,
1139
+ workspace_id: argumentValue(input.args, '--workspace') ?? actor_workspace_id,
1140
+ task_scope: await taskScopeArgument(input.args)
1141
+ }));
1142
+ }
1143
+ else if (subcommand === 'export') {
1144
+ printJson(await runtime.exportWorkspaceGraph({
1145
+ workspace_id: workspaceArgument(runtime, input.args),
1146
+ output_path: requiredArgument(input.args, '--output'),
1147
+ commit_id: argumentValue(input.args, '--commit') ?? undefined,
1148
+ view: parseClaimView(argumentValue(input.args, '--view'))
1149
+ }));
1150
+ }
1151
+ else if (subcommand === 'claims') {
1152
+ printJson(runtime.listPendingClaims({
1153
+ workspace_id: workspaceArgument(runtime, input.args)
1154
+ }));
1155
+ }
1156
+ else if (subcommand === 'claim-status') {
1157
+ const status = argumentValue(input.args, '--status');
1158
+ const cites_code = argumentValue(input.args, '--cites-code');
1159
+ printJson(await runtime.workspaceClaimStatus({
1160
+ workspace_id: workspaceArgument(runtime, input.args),
1161
+ view: parseClaimStatusView(argumentValue(input.args, '--view')),
1162
+ commit: argumentValue(input.args, '--commit') ?? undefined,
1163
+ environments: argumentValues(input.args, '--environment').map(parseClaimStatusEnvironment),
1164
+ cites_code: cites_code
1165
+ ? cites_code
1166
+ .split(',')
1167
+ .map((type) => type.trim())
1168
+ .filter(Boolean)
1169
+ : [],
1170
+ nodes: argumentValues(input.args, '--node'),
1171
+ status: status ? parseClaimStatus(status) : undefined,
1172
+ stale_only: hasFlag(input.args, '--stale'),
1173
+ behind_only: hasFlag(input.args, '--behind')
1174
+ }));
1175
+ }
1176
+ else if (subcommand === 'evidence') {
1177
+ printJson(await runEvidenceCommand(runtime, input.args));
1178
+ }
1179
+ else if (subcommand === 'rm') {
1180
+ const relative_path = input.args.find((argument) => !argument.startsWith('--'));
1181
+ if (!relative_path) {
1182
+ throw new Error('Usage: sdlc workspace rm <entity-relative-path>');
1183
+ }
1184
+ printJson(await runtime.removeEntity({
1185
+ actor_workspace_id: currentWorkspaceId(runtime),
1186
+ relative_path
1187
+ }));
1188
+ }
1189
+ else if (subcommand === 'doc') {
1190
+ printJson(await runDocumentCommand(runtime, input.args));
1191
+ }
1192
+ else if (subcommand === 'test') {
1193
+ printJson(await runTestCommand(runtime, input.args));
1194
+ }
1195
+ else if (subcommand === 'journey') {
1196
+ printJson(await runJourneyCommand(runtime, input.args));
1197
+ }
1198
+ else if (subcommand === 'guide') {
1199
+ printJson(await runGuideCommand(runtime, input.args));
1200
+ }
1201
+ else if (subcommand === 'admission') {
1202
+ printJson(await runAdmissionCommand(runtime, input.args));
1203
+ }
1204
+ else if (subcommand === 'decision') {
1205
+ printJson(await runDecisionCommand(runtime, input.args));
1206
+ }
1207
+ else if (subcommand === 'pick') {
1208
+ printJson(await runPickCommand(runtime, input.args));
1209
+ }
1210
+ else if (subcommand === 'blast-radius') {
1211
+ const source = requiredArgument(input.args, '--files-from');
1212
+ const result = await runtime.workspaceBlastRadius({
1213
+ workspace_id: workspaceArgument(runtime, input.args),
1214
+ files: parseFileList(source === '-'
1215
+ ? await readStream(process.stdin)
1216
+ : await readFile(resolve(source), 'utf8')),
1217
+ view: parseClaimView(argumentValue(input.args, '--view'))
1218
+ });
1219
+ for (const warning of result.warnings ?? []) {
1220
+ process.stderr.write(`warning: ${warning}\n`);
1221
+ }
1222
+ printJson(result);
1223
+ }
1224
+ else if (subcommand === 'find') {
1225
+ const options = optionArguments(input.args);
1226
+ const terms = readArguments(input.args, [], FIND_USAGE);
1227
+ if (terms.length === 0)
1228
+ throw new Error(FIND_USAGE);
1229
+ const types = argumentValue(options, '--type');
1230
+ if (types !== null && !types.split(',').some((type) => type.trim())) {
1231
+ throw new Error(`--type needs a value. ${FIND_USAGE}`);
1232
+ }
1233
+ const origin = argumentValue(options, '--origin');
1234
+ if (origin !== null && origin !== 'built' && origin !== 'shelf') {
1235
+ throw new Error(`--origin takes built or shelf. ${FIND_USAGE}`);
1236
+ }
1237
+ const limit = argumentValue(options, '--limit');
1238
+ const result = await runtime.workspaceFind({
1239
+ workspace_id: workspaceArgument(runtime, options),
1240
+ terms,
1241
+ types: types
1242
+ ? types
1243
+ .split(',')
1244
+ .map((type) => type.trim())
1245
+ .filter(Boolean)
1246
+ : undefined,
1247
+ origin: origin ?? undefined,
1248
+ limit: limit === null ? undefined : positiveInteger(limit, '--limit'),
1249
+ view: parseClaimView(argumentValue(options, '--view'))
1250
+ });
1251
+ for (const warning of result.warnings ?? []) {
1252
+ process.stderr.write(`warning: ${warning}\n`);
1253
+ }
1254
+ printJson(result);
1255
+ }
1256
+ else if (subcommand === 'show') {
1257
+ const options = optionArguments(input.args);
1258
+ const ids = readArguments(input.args, ['--full'], SHOW_USAGE);
1259
+ if (ids.length === 0)
1260
+ throw new Error(SHOW_USAGE);
1261
+ const budget = argumentValue(options, '--budget');
1262
+ if (budget !== null && hasFlag(options, '--full')) {
1263
+ throw new Error(`--full shows each entity whole; leave out --budget. ${SHOW_USAGE}`);
1264
+ }
1265
+ const result = await runtime.workspaceShow({
1266
+ workspace_id: workspaceArgument(runtime, options),
1267
+ ids,
1268
+ budget: hasFlag(options, '--full')
1269
+ ? null
1270
+ : budget === null
1271
+ ? undefined
1272
+ : positiveInteger(budget, '--budget'),
1273
+ view: parseClaimView(argumentValue(options, '--view'))
1274
+ });
1275
+ for (const warning of result.warnings ?? []) {
1276
+ process.stderr.write(`warning: ${warning}\n`);
1277
+ }
1278
+ printJson(result);
1279
+ }
1280
+ else if (subcommand === 'status') {
1281
+ printJson(await runtime.getWorkspaceStatus(workspaceArgument(runtime, input.args)));
1282
+ }
1283
+ else if (subcommand === 'authority') {
1284
+ printJson(runtime.inspectAuthority());
1285
+ }
1286
+ else if (subcommand === 'create') {
1287
+ printJson(await runtime.createChildWorkspace({
1288
+ actor_workspace_id: workspaceArgument(runtime, input.args, '--from'),
1289
+ target_path: resolve(requiredArgument(input.args, '--path')),
1290
+ actor_kind: actorArgument(input.args) ?? 'ai',
1291
+ task_scope: await taskScopeArgument(input.args)
1292
+ }));
1293
+ }
1294
+ else if (subcommand === 'commit') {
1295
+ printJson(await runtime.commitCurrentProjection({
1296
+ actor_workspace_id: workspaceArgument(runtime, input.args),
1297
+ message: requiredArgument(input.args, '--message')
1298
+ }));
1299
+ }
1300
+ else if (subcommand === 'recover') {
1301
+ printJson(await runtime.recoverCurrentProjection({
1302
+ actor_workspace_id: workspaceArgument(runtime, input.args),
1303
+ expected_head_commit_id: requiredArgument(input.args, '--expected-head'),
1304
+ expected_projection_root_hash: argumentValue(input.args, '--expected-projection-root') ?? undefined,
1305
+ discard_unreadable_projection: hasFlag(input.args, '--discard-unreadable')
1306
+ }));
1307
+ }
1308
+ else if (subcommand === 'close') {
1309
+ const actor_workspace_id = currentWorkspaceId(runtime);
1310
+ printJson({
1311
+ version: 1,
1312
+ workspace: await runtime.closeWorkspace({
1313
+ actor_workspace_id,
1314
+ workspace_id: argumentValue(input.args, '--workspace') ?? actor_workspace_id
1315
+ })
1316
+ });
1317
+ }
1318
+ else if (subcommand === 'prune') {
1319
+ const min_age_value = argumentValue(input.args, '--min-age-hours');
1320
+ const min_age_hours = min_age_value === null ? undefined : Number(min_age_value);
1321
+ printJson(hasFlag(input.args, '--apply')
1322
+ ? await runtime.applyPrune({
1323
+ expected_plan_hash: requiredArgument(input.args, '--expected-plan-hash'),
1324
+ min_age_hours
1325
+ })
1326
+ : await runtime.planPrune({ min_age_hours }));
1327
+ }
1328
+ else {
1329
+ return false;
1330
+ }
1331
+ return true;
1332
+ }
1333
+ async function runCoordinationCommand(runtime, input) {
1334
+ const key = `${input.command}:${input.subcommand ?? ''}`;
1335
+ if (key === 'integrate:enqueue') {
1336
+ printJson({
1337
+ version: 1,
1338
+ queue_entry: await runtime.enqueueChildCommit({
1339
+ actor_workspace_id: workspaceArgument(runtime, input.args, '--coordinator'),
1340
+ child_workspace_id: requiredArgument(input.args, '--workspace'),
1341
+ child_commit_id: argumentValue(input.args, '--commit') ?? undefined,
1342
+ gate: gateArgument(input.args)
1343
+ })
1344
+ });
1345
+ }
1346
+ else if (key === 'integrate:run' || key === 'integrate:reconcile') {
1347
+ const retry_value = argumentValue(input.args, '--max-retries');
1348
+ const common = {
1349
+ actor_workspace_id: workspaceArgument(runtime, input.args, '--coordinator'),
1350
+ max_retries: retry_value === null ? undefined : Number(retry_value),
1351
+ ...(await resolverArguments(runtime, input.args))
1352
+ };
1353
+ const result = key === 'integrate:run'
1354
+ ? await runtime.integrateNext(common)
1355
+ : await runtime.reconcileSource({
1356
+ ...common,
1357
+ source_workspace_id: requiredArgument(input.args, '--source')
1358
+ });
1359
+ printJson(result);
1360
+ if (result.status === 'blocked_conflict' ||
1361
+ result.status === 'blocked_validation') {
1362
+ process.exitCode = 2;
1363
+ }
1364
+ }
1365
+ else if (key === 'handoff:prepare') {
1366
+ const retry_value = argumentValue(input.args, '--max-retries');
1367
+ const result = await runtime.prepareHandoff({
1368
+ actor_workspace_id: workspaceArgument(runtime, input.args),
1369
+ source_workspace_id: requiredArgument(input.args, '--source'),
1370
+ max_retries: retry_value === null ? undefined : Number(retry_value),
1371
+ ...(await resolverArguments(runtime, input.args))
1372
+ });
1373
+ printJson(result);
1374
+ if (result.status !== 'ready')
1375
+ process.exitCode = 2;
1376
+ }
1377
+ else if (key === 'handoff:list') {
1378
+ printJson({
1379
+ version: 1,
1380
+ handoffs: await runtime.listHandoffs(workspaceArgument(runtime, input.args))
1381
+ });
1382
+ }
1383
+ else if (key === 'handoff:inspect' || key === 'handoff:apply') {
1384
+ const common = {
1385
+ actor_workspace_id: workspaceArgument(runtime, input.args),
1386
+ handoff_id: requiredArgument(input.args, '--handoff')
1387
+ };
1388
+ const result = key === 'handoff:inspect'
1389
+ ? await runtime.inspectHandoff(common)
1390
+ : await runtime.applyHandoff(common);
1391
+ printJson(result);
1392
+ if (key === 'handoff:apply' && result.status !== 'applied')
1393
+ process.exitCode = 2;
1394
+ }
1395
+ else {
1396
+ return false;
1397
+ }
1398
+ return true;
1399
+ }
1400
+ export async function runLocalWorkspaceCommand(input) {
1401
+ if (input.command === 'topology') {
1402
+ if (input.subcommand === 'inspect') {
1403
+ printJson(await inspectWorkspaceTopology());
1404
+ }
1405
+ else if (input.subcommand === 'relocate') {
1406
+ const relocation = {
1407
+ target_state_dir: resolve(requiredArgument(input.args, '--state-dir')),
1408
+ target_storage_mode: storageModeArgument(input.args, true)
1409
+ };
1410
+ printJson(hasFlag(input.args, '--apply')
1411
+ ? await applyWorkspaceStorageRelocation({
1412
+ ...relocation,
1413
+ expected_plan_hash: requiredArgument(input.args, '--expected-plan-hash')
1414
+ })
1415
+ : await planWorkspaceStorageRelocation(relocation));
1416
+ }
1417
+ else if (input.subcommand === 'export') {
1418
+ printJson(await exportWorkspaceStorage({
1419
+ bundle_dir: resolve(requiredArgument(input.args, '--path'))
1420
+ }));
1421
+ }
1422
+ else if (input.subcommand === 'recover') {
1423
+ printJson(await recoverWorkspaceStorageRelocation());
1424
+ }
1425
+ else if (input.subcommand === 'clone') {
1426
+ printJson(await cloneWorkspaceStorage({
1427
+ bundle_dir: resolve(requiredArgument(input.args, '--from')),
1428
+ target_state_dir: resolve(requiredArgument(input.args, '--state-dir')),
1429
+ expected_graph_repository_id: requiredArgument(input.args, '--graph-repository-id')
1430
+ }));
1431
+ }
1432
+ else {
1433
+ throw new Error('Usage: sdlc topology inspect | relocate --state-dir <path> --storage-mode <machine_shared|self_contained> [--apply --expected-plan-hash <sha256>] | export --path <directory> | recover | clone --from <directory> --state-dir <path> --graph-repository-id <uuid>');
1434
+ }
1435
+ return;
1436
+ }
1437
+ if (input.command === 'workspace' &&
1438
+ input.subcommand === 'evidence' &&
1439
+ input.args[0] === 'verify') {
1440
+ await runEvidenceVerify(input.args);
1441
+ return;
1442
+ }
1443
+ // `sdlc variants` takes no subcommand, so its first flag arrives as one.
1444
+ const open_args = input.command === 'variants'
1445
+ ? [input.subcommand, ...input.args].filter((value) => typeof value === 'string')
1446
+ : input.command === 'workspace' &&
1447
+ (input.subcommand === 'find' || input.subcommand === 'show')
1448
+ ? optionArguments(input.args)
1449
+ : input.args;
1450
+ // The evidence writer and readers name the workspace by its worktree (--graph).
1451
+ const graph_worktree = input.command === 'workspace' && input.subcommand === 'evidence'
1452
+ ? argumentValue(open_args, '--graph')
1453
+ : null;
1454
+ const runtime = await LocalWorkspaceRuntime.open({
1455
+ ...(graph_worktree ? { cwd: resolve(graph_worktree) } : {}),
1456
+ state_dir: argumentValue(open_args, '--repository-state-dir') ?? undefined,
1457
+ graph_repository_id: argumentValue(open_args, '--graph-repository-id') ?? undefined
1458
+ });
1459
+ try {
1460
+ if (input.command === 'variants') {
1461
+ // sdlc variants [--workspace <id>] [--commit <ref>] [--environment <key>=<ref>]... [--json]
1462
+ const args = open_args;
1463
+ const report = await runtime.workspaceVariants({
1464
+ workspace_id: workspaceArgument(runtime, args),
1465
+ commit: argumentValue(args, '--commit') ?? undefined,
1466
+ environments: argumentValues(args, '--environment').map(parseClaimStatusEnvironment)
1467
+ });
1468
+ if (hasFlag(args, '--json'))
1469
+ printJson(report);
1470
+ else
1471
+ console.log(formatVariantsReport(report));
1472
+ return;
1473
+ }
1474
+ if (input.command === 'viewer') {
1475
+ const port_value = argumentValue(input.args, '--port');
1476
+ // The engine panels come from sdlc view's code, which the public CLI ships without
1477
+ // (view-seam.ts): without it they are absent and the domain pages answer engine_missing.
1478
+ // Pins are view state and Done a coordination record (status user-done), both beside the
1479
+ // Threads panel; the Releases (rl-ui-viewer) and Work queues (qv-viewer) panels read on their own.
1480
+ const { threads, pin, taskDone, releaseLinks, queues, domains } = viewerProviders(await loadViewModule(), process.cwd());
1481
+ // The shared pages' contract reads (api/app/…): the shell's own in any Git repository
1482
+ // (la-shell), and the domain reads through the engine's readers where it resolves (la-contracts).
1483
+ // The Worktrees page reads and writes through the main checkout's engine (la-worktrees).
1484
+ const worktrees = worktreesProvider(process.cwd()) ?? undefined;
1485
+ const app = appShellReader({ cwd: process.cwd(), domains, worktrees });
1486
+ const viewer = await startLocalWorkspaceViewer({
1487
+ runtime,
1488
+ port: port_value === null ? undefined : Number(port_value),
1489
+ threads,
1490
+ pin,
1491
+ taskDone,
1492
+ releaseLinks,
1493
+ queues,
1494
+ app,
1495
+ worktrees: worktrees?.current ? worktrees : undefined
1496
+ });
1497
+ printJson(viewerStartLine(viewer.url, Boolean(pin), viewer.page, Boolean(taskDone), Boolean(worktrees?.current)));
1498
+ const stop = () => void viewer.close();
1499
+ process.once('SIGINT', stop);
1500
+ process.once('SIGTERM', stop);
1501
+ try {
1502
+ await viewer.closed;
1503
+ }
1504
+ finally {
1505
+ process.off('SIGINT', stop);
1506
+ process.off('SIGTERM', stop);
1507
+ }
1508
+ return;
1509
+ }
1510
+ if (['remote', 'portable', 'branch', 'merge', 'resolver'].includes(input.command) &&
1511
+ (await runEnvironmentCommand(runtime, input))) {
1512
+ return;
1513
+ }
1514
+ if ((await runWorkspaceCommand(runtime, input)) ||
1515
+ (await runCoordinationCommand(runtime, input))) {
1516
+ return;
1517
+ }
1518
+ throw new Error('Usage: sdlc viewer [--port <0..65535>] | sdlc topology inspect|relocate|export|recover|clone | sdlc remote set|list|inspect|remove|discover|refs|fetch|push|push-journals|topic|topic-journals|pr|pr-journals | sdlc branch create|list|select | sdlc merge upstream|status|revert|attempts|resolution-attempts|reverts | sdlc portable plan|convert | sdlc workspace init|attach|context|list|overlap|scope|export|claims|claim-status|find|show|evidence|rm|doc|decision|pick|status|authority|create|commit|recover|close|detach|prune | sdlc resolver configure|status|clear | sdlc integrate enqueue|run|reconcile | sdlc handoff prepare|list|inspect|apply');
1519
+ }
1520
+ finally {
1521
+ runtime.close();
1522
+ }
1523
+ }
1524
+ //# sourceMappingURL=workspace-cli.js.map