wingfoil 0.2.2 → 0.3.0

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 (454) hide show
  1. package/README.md +83 -43
  2. package/dist/agent/discovery.d.ts +72 -0
  3. package/dist/agent/discovery.d.ts.map +1 -0
  4. package/dist/agent/discovery.js +210 -0
  5. package/dist/agent/discovery.js.map +1 -0
  6. package/dist/agent/execute.d.ts +206 -0
  7. package/dist/agent/execute.d.ts.map +1 -0
  8. package/dist/agent/execute.js +581 -0
  9. package/dist/agent/execute.js.map +1 -0
  10. package/dist/agent/index.d.ts +23 -0
  11. package/dist/agent/index.d.ts.map +1 -0
  12. package/dist/agent/index.js +85 -0
  13. package/dist/agent/index.js.map +1 -0
  14. package/dist/agent/launch.d.ts +133 -0
  15. package/dist/agent/launch.d.ts.map +1 -0
  16. package/dist/agent/launch.js +380 -0
  17. package/dist/agent/launch.js.map +1 -0
  18. package/dist/agent/manifest.d.ts +30 -0
  19. package/dist/agent/manifest.d.ts.map +1 -0
  20. package/dist/agent/manifest.js +93 -0
  21. package/dist/agent/manifest.js.map +1 -0
  22. package/dist/agent/placeholders.d.ts +49 -0
  23. package/dist/agent/placeholders.d.ts.map +1 -0
  24. package/dist/agent/placeholders.js +177 -0
  25. package/dist/agent/placeholders.js.map +1 -0
  26. package/dist/agent/run-log.d.ts +254 -0
  27. package/dist/agent/run-log.d.ts.map +1 -0
  28. package/dist/agent/run-log.js +612 -0
  29. package/dist/agent/run-log.js.map +1 -0
  30. package/dist/agent/schema.d.ts +100 -0
  31. package/dist/agent/schema.d.ts.map +1 -0
  32. package/dist/agent/schema.js +89 -0
  33. package/dist/agent/schema.js.map +1 -0
  34. package/dist/agent/step.d.ts +41 -0
  35. package/dist/agent/step.d.ts.map +1 -0
  36. package/dist/agent/step.js +95 -0
  37. package/dist/agent/step.js.map +1 -0
  38. package/dist/build-info.json +4 -0
  39. package/dist/cli/error.d.ts +11 -2
  40. package/dist/cli/error.d.ts.map +1 -1
  41. package/dist/cli/error.js +27 -6
  42. package/dist/cli/error.js.map +1 -1
  43. package/dist/cli/exit.d.ts +33 -3
  44. package/dist/cli/exit.d.ts.map +1 -1
  45. package/dist/cli/exit.js +54 -3
  46. package/dist/cli/exit.js.map +1 -1
  47. package/dist/cli/index.d.ts +1 -1
  48. package/dist/cli/index.d.ts.map +1 -1
  49. package/dist/cli/index.js +2 -1
  50. package/dist/cli/index.js.map +1 -1
  51. package/dist/cli/init-command.d.ts.map +1 -1
  52. package/dist/cli/init-command.js +4 -2
  53. package/dist/cli/init-command.js.map +1 -1
  54. package/dist/cli/mcp-command.d.ts +13 -4
  55. package/dist/cli/mcp-command.d.ts.map +1 -1
  56. package/dist/cli/mcp-command.js +25 -8
  57. package/dist/cli/mcp-command.js.map +1 -1
  58. package/dist/cli/output.d.ts +12 -4
  59. package/dist/cli/output.d.ts.map +1 -1
  60. package/dist/cli/output.js +15 -4
  61. package/dist/cli/output.js.map +1 -1
  62. package/dist/cli/program.d.ts +1 -1
  63. package/dist/cli/program.d.ts.map +1 -1
  64. package/dist/cli/program.js +162 -40
  65. package/dist/cli/program.js.map +1 -1
  66. package/dist/cli/registrar.d.ts +1 -1
  67. package/dist/cli/registrar.d.ts.map +1 -1
  68. package/dist/cli/registrar.js +67 -6
  69. package/dist/cli/registrar.js.map +1 -1
  70. package/dist/cli/suggest.d.ts +20 -0
  71. package/dist/cli/suggest.d.ts.map +1 -0
  72. package/dist/cli/suggest.js +49 -0
  73. package/dist/cli/suggest.js.map +1 -0
  74. package/dist/cli/warning.d.ts +26 -0
  75. package/dist/cli/warning.d.ts.map +1 -0
  76. package/dist/cli/warning.js +66 -0
  77. package/dist/cli/warning.js.map +1 -0
  78. package/dist/cli.js +11 -2
  79. package/dist/cli.js.map +1 -1
  80. package/dist/core/agent-execute.d.ts +44 -0
  81. package/dist/core/agent-execute.d.ts.map +1 -0
  82. package/dist/core/agent-execute.js +71 -0
  83. package/dist/core/agent-execute.js.map +1 -0
  84. package/dist/core/agent-list.d.ts +95 -0
  85. package/dist/core/agent-list.d.ts.map +1 -0
  86. package/dist/core/agent-list.js +207 -0
  87. package/dist/core/agent-list.js.map +1 -0
  88. package/dist/core/agent-show.d.ts +44 -0
  89. package/dist/core/agent-show.d.ts.map +1 -0
  90. package/dist/core/agent-show.js +188 -0
  91. package/dist/core/agent-show.js.map +1 -0
  92. package/dist/core/approval-authority.d.ts +17 -14
  93. package/dist/core/approval-authority.d.ts.map +1 -1
  94. package/dist/core/approval-authority.js +9 -9
  95. package/dist/core/approval-authority.js.map +1 -1
  96. package/dist/core/builtin-asset.d.ts +18 -15
  97. package/dist/core/builtin-asset.d.ts.map +1 -1
  98. package/dist/core/builtin-asset.js +17 -14
  99. package/dist/core/builtin-asset.js.map +1 -1
  100. package/dist/core/builtin-integrity.d.ts +12 -2
  101. package/dist/core/builtin-integrity.d.ts.map +1 -1
  102. package/dist/core/builtin-integrity.js +85 -9
  103. package/dist/core/builtin-integrity.js.map +1 -1
  104. package/dist/core/confinement.d.ts +3 -1
  105. package/dist/core/confinement.d.ts.map +1 -1
  106. package/dist/core/confinement.js +7 -4
  107. package/dist/core/confinement.js.map +1 -1
  108. package/dist/core/context.d.ts +150 -98
  109. package/dist/core/context.d.ts.map +1 -1
  110. package/dist/core/context.js +602 -66
  111. package/dist/core/context.js.map +1 -1
  112. package/dist/core/directive-assign.d.ts +33 -7
  113. package/dist/core/directive-assign.d.ts.map +1 -1
  114. package/dist/core/directive-assign.js +67 -27
  115. package/dist/core/directive-assign.js.map +1 -1
  116. package/dist/core/directive-scope.d.ts +36 -0
  117. package/dist/core/directive-scope.d.ts.map +1 -0
  118. package/dist/core/directive-scope.js +34 -0
  119. package/dist/core/directive-scope.js.map +1 -0
  120. package/dist/core/directives-list.d.ts +13 -3
  121. package/dist/core/directives-list.d.ts.map +1 -1
  122. package/dist/core/directives-list.js +18 -6
  123. package/dist/core/directives-list.js.map +1 -1
  124. package/dist/core/dry-run.d.ts +33 -0
  125. package/dist/core/dry-run.d.ts.map +1 -0
  126. package/dist/core/dry-run.js +45 -0
  127. package/dist/core/dry-run.js.map +1 -0
  128. package/dist/core/element-ref.d.ts +23 -0
  129. package/dist/core/element-ref.d.ts.map +1 -0
  130. package/dist/core/element-ref.js +24 -0
  131. package/dist/core/element-ref.js.map +1 -0
  132. package/dist/core/error-details.d.ts +20 -0
  133. package/dist/core/error-details.d.ts.map +1 -0
  134. package/dist/core/error-details.js +65 -0
  135. package/dist/core/error-details.js.map +1 -0
  136. package/dist/core/exit-code.d.ts.map +1 -1
  137. package/dist/core/exit-code.js +6 -7
  138. package/dist/core/exit-code.js.map +1 -1
  139. package/dist/core/git-identity.d.ts +46 -11
  140. package/dist/core/git-identity.d.ts.map +1 -1
  141. package/dist/core/git-identity.js +140 -27
  142. package/dist/core/git-identity.js.map +1 -1
  143. package/dist/core/index.d.ts +184 -10
  144. package/dist/core/index.d.ts.map +1 -1
  145. package/dist/core/index.js +1045 -185
  146. package/dist/core/index.js.map +1 -1
  147. package/dist/core/init.d.ts +45 -5
  148. package/dist/core/init.d.ts.map +1 -1
  149. package/dist/core/init.js +134 -24
  150. package/dist/core/init.js.map +1 -1
  151. package/dist/core/loaders.d.ts +170 -14
  152. package/dist/core/loaders.d.ts.map +1 -1
  153. package/dist/core/loaders.js +570 -89
  154. package/dist/core/loaders.js.map +1 -1
  155. package/dist/core/memory-add-link.d.ts +28 -0
  156. package/dist/core/memory-add-link.d.ts.map +1 -0
  157. package/dist/core/memory-add-link.js +67 -0
  158. package/dist/core/memory-add-link.js.map +1 -0
  159. package/dist/core/memory-add-type.d.ts +25 -1
  160. package/dist/core/memory-add-type.d.ts.map +1 -1
  161. package/dist/core/memory-add-type.js +59 -1
  162. package/dist/core/memory-add-type.js.map +1 -1
  163. package/dist/core/memory-amend.d.ts +80 -0
  164. package/dist/core/memory-amend.d.ts.map +1 -0
  165. package/dist/core/memory-amend.js +160 -0
  166. package/dist/core/memory-amend.js.map +1 -0
  167. package/dist/core/memory-supersede.d.ts +28 -0
  168. package/dist/core/memory-supersede.d.ts.map +1 -0
  169. package/dist/core/memory-supersede.js +79 -0
  170. package/dist/core/memory-supersede.js.map +1 -0
  171. package/dist/core/memory-transition.d.ts +190 -30
  172. package/dist/core/memory-transition.d.ts.map +1 -1
  173. package/dist/core/memory-transition.js +480 -59
  174. package/dist/core/memory-transition.js.map +1 -1
  175. package/dist/core/registry.d.ts +82 -10
  176. package/dist/core/registry.d.ts.map +1 -1
  177. package/dist/core/registry.js +50 -0
  178. package/dist/core/registry.js.map +1 -1
  179. package/dist/core/relevance.d.ts +74 -12
  180. package/dist/core/relevance.d.ts.map +1 -1
  181. package/dist/core/relevance.js +45 -27
  182. package/dist/core/relevance.js.map +1 -1
  183. package/dist/core/require-reason.d.ts.map +1 -1
  184. package/dist/core/require-reason.js +6 -5
  185. package/dist/core/require-reason.js.map +1 -1
  186. package/dist/core/required-fields.d.ts +28 -0
  187. package/dist/core/required-fields.d.ts.map +1 -0
  188. package/dist/core/required-fields.js +60 -0
  189. package/dist/core/required-fields.js.map +1 -0
  190. package/dist/core/revision.d.ts +82 -0
  191. package/dist/core/revision.d.ts.map +1 -0
  192. package/dist/core/revision.js +144 -0
  193. package/dist/core/revision.js.map +1 -0
  194. package/dist/core/types.d.ts +28 -2
  195. package/dist/core/types.d.ts.map +1 -1
  196. package/dist/core/types.js +12 -3
  197. package/dist/core/types.js.map +1 -1
  198. package/dist/core/workflow-core-checks.d.ts +34 -0
  199. package/dist/core/workflow-core-checks.d.ts.map +1 -0
  200. package/dist/core/workflow-core-checks.js +403 -0
  201. package/dist/core/workflow-core-checks.js.map +1 -0
  202. package/dist/core/workflow-create-remove.d.ts +65 -0
  203. package/dist/core/workflow-create-remove.d.ts.map +1 -0
  204. package/dist/core/workflow-create-remove.js +277 -0
  205. package/dist/core/workflow-create-remove.js.map +1 -0
  206. package/dist/core/workflow-deduction.d.ts +48 -0
  207. package/dist/core/workflow-deduction.d.ts.map +1 -0
  208. package/dist/core/workflow-deduction.js +523 -0
  209. package/dist/core/workflow-deduction.js.map +1 -0
  210. package/dist/core/workflow-diagnostics.d.ts +83 -0
  211. package/dist/core/workflow-diagnostics.d.ts.map +1 -0
  212. package/dist/core/workflow-diagnostics.js +375 -0
  213. package/dist/core/workflow-diagnostics.js.map +1 -0
  214. package/dist/core/workflow-exit-state.d.ts +125 -0
  215. package/dist/core/workflow-exit-state.d.ts.map +1 -0
  216. package/dist/core/workflow-exit-state.js +243 -0
  217. package/dist/core/workflow-exit-state.js.map +1 -0
  218. package/dist/core/workflow-finalize.d.ts +37 -0
  219. package/dist/core/workflow-finalize.d.ts.map +1 -0
  220. package/dist/core/workflow-finalize.js +153 -0
  221. package/dist/core/workflow-finalize.js.map +1 -0
  222. package/dist/core/workflow-list-show.d.ts +176 -0
  223. package/dist/core/workflow-list-show.d.ts.map +1 -0
  224. package/dist/core/workflow-list-show.js +268 -0
  225. package/dist/core/workflow-list-show.js.map +1 -0
  226. package/dist/core/workflow-next.d.ts +268 -0
  227. package/dist/core/workflow-next.d.ts.map +1 -0
  228. package/dist/core/workflow-next.js +503 -0
  229. package/dist/core/workflow-next.js.map +1 -0
  230. package/dist/core/workflow-registry.d.ts +52 -0
  231. package/dist/core/workflow-registry.d.ts.map +1 -0
  232. package/dist/core/workflow-registry.js +158 -0
  233. package/dist/core/workflow-registry.js.map +1 -0
  234. package/dist/core/workflow-start-end.d.ts +71 -0
  235. package/dist/core/workflow-start-end.d.ts.map +1 -0
  236. package/dist/core/workflow-start-end.js +298 -0
  237. package/dist/core/workflow-start-end.js.map +1 -0
  238. package/dist/core/workflow-status.d.ts +83 -0
  239. package/dist/core/workflow-status.d.ts.map +1 -0
  240. package/dist/core/workflow-status.js +125 -0
  241. package/dist/core/workflow-status.js.map +1 -0
  242. package/dist/core/write-guard.d.ts +51 -8
  243. package/dist/core/write-guard.d.ts.map +1 -1
  244. package/dist/core/write-guard.js +139 -9
  245. package/dist/core/write-guard.js.map +1 -1
  246. package/dist/directives/index.d.ts +3 -2
  247. package/dist/directives/index.d.ts.map +1 -1
  248. package/dist/directives/index.js +5 -3
  249. package/dist/directives/index.js.map +1 -1
  250. package/dist/directives/schema.d.ts +34 -29
  251. package/dist/directives/schema.d.ts.map +1 -1
  252. package/dist/directives/schema.js +35 -29
  253. package/dist/directives/schema.js.map +1 -1
  254. package/dist/directives/version.d.ts +28 -0
  255. package/dist/directives/version.d.ts.map +1 -0
  256. package/dist/directives/version.js +51 -0
  257. package/dist/directives/version.js.map +1 -0
  258. package/dist/dna/edit.d.ts +7 -6
  259. package/dist/dna/edit.d.ts.map +1 -1
  260. package/dist/dna/edit.js +96 -41
  261. package/dist/dna/edit.js.map +1 -1
  262. package/dist/dna/mutate.js +18 -3
  263. package/dist/dna/mutate.js.map +1 -1
  264. package/dist/dna/path.d.ts +2 -2
  265. package/dist/dna/roles.d.ts +1 -1
  266. package/dist/dna/schema.d.ts +61 -3
  267. package/dist/dna/schema.d.ts.map +1 -1
  268. package/dist/dna/schema.js +121 -6
  269. package/dist/dna/schema.js.map +1 -1
  270. package/dist/mcp/dna-resource.d.ts.map +1 -1
  271. package/dist/mcp/dna-resource.js +4 -4
  272. package/dist/mcp/dna-resource.js.map +1 -1
  273. package/dist/mcp/index.d.ts +8 -4
  274. package/dist/mcp/index.d.ts.map +1 -1
  275. package/dist/mcp/index.js +13 -2
  276. package/dist/mcp/index.js.map +1 -1
  277. package/dist/mcp/memory-resource.d.ts.map +1 -1
  278. package/dist/mcp/memory-resource.js +30 -19
  279. package/dist/mcp/memory-resource.js.map +1 -1
  280. package/dist/mcp/prompt.d.ts +61 -24
  281. package/dist/mcp/prompt.d.ts.map +1 -1
  282. package/dist/mcp/prompt.js +176 -47
  283. package/dist/mcp/prompt.js.map +1 -1
  284. package/dist/mcp/read-only.d.ts +39 -0
  285. package/dist/mcp/read-only.d.ts.map +1 -1
  286. package/dist/mcp/read-only.js +61 -0
  287. package/dist/mcp/read-only.js.map +1 -1
  288. package/dist/mcp/registrar.d.ts +10 -0
  289. package/dist/mcp/registrar.d.ts.map +1 -1
  290. package/dist/mcp/registrar.js +48 -12
  291. package/dist/mcp/registrar.js.map +1 -1
  292. package/dist/mcp/server.d.ts +21 -14
  293. package/dist/mcp/server.d.ts.map +1 -1
  294. package/dist/mcp/server.js +41 -15
  295. package/dist/mcp/server.js.map +1 -1
  296. package/dist/mcp/session-resource.d.ts +13 -0
  297. package/dist/mcp/session-resource.d.ts.map +1 -0
  298. package/dist/mcp/session-resource.js +65 -0
  299. package/dist/mcp/session-resource.js.map +1 -0
  300. package/dist/mcp/workflow-resource.d.ts +18 -0
  301. package/dist/mcp/workflow-resource.d.ts.map +1 -1
  302. package/dist/mcp/workflow-resource.js +37 -8
  303. package/dist/mcp/workflow-resource.js.map +1 -1
  304. package/dist/memory/add.d.ts +110 -24
  305. package/dist/memory/add.d.ts.map +1 -1
  306. package/dist/memory/add.js +251 -64
  307. package/dist/memory/add.js.map +1 -1
  308. package/dist/memory/audit.d.ts +152 -39
  309. package/dist/memory/audit.d.ts.map +1 -1
  310. package/dist/memory/audit.js +257 -103
  311. package/dist/memory/audit.js.map +1 -1
  312. package/dist/memory/commit-message.d.ts +60 -38
  313. package/dist/memory/commit-message.d.ts.map +1 -1
  314. package/dist/memory/commit-message.js +167 -21
  315. package/dist/memory/commit-message.js.map +1 -1
  316. package/dist/memory/entry.d.ts.map +1 -1
  317. package/dist/memory/entry.js +1 -2
  318. package/dist/memory/entry.js.map +1 -1
  319. package/dist/memory/frontmatter-edit.d.ts +16 -4
  320. package/dist/memory/frontmatter-edit.d.ts.map +1 -1
  321. package/dist/memory/frontmatter-edit.js +13 -1
  322. package/dist/memory/frontmatter-edit.js.map +1 -1
  323. package/dist/memory/git-log.d.ts +18 -6
  324. package/dist/memory/git-log.d.ts.map +1 -1
  325. package/dist/memory/git-log.js +40 -13
  326. package/dist/memory/git-log.js.map +1 -1
  327. package/dist/memory/history.d.ts +73 -12
  328. package/dist/memory/history.d.ts.map +1 -1
  329. package/dist/memory/history.js +128 -44
  330. package/dist/memory/history.js.map +1 -1
  331. package/dist/memory/index.d.ts +13 -11
  332. package/dist/memory/index.d.ts.map +1 -1
  333. package/dist/memory/index.js +34 -3
  334. package/dist/memory/index.js.map +1 -1
  335. package/dist/memory/query.d.ts +161 -19
  336. package/dist/memory/query.d.ts.map +1 -1
  337. package/dist/memory/query.js +435 -55
  338. package/dist/memory/query.js.map +1 -1
  339. package/dist/memory/schema.d.ts +52 -3
  340. package/dist/memory/schema.d.ts.map +1 -1
  341. package/dist/memory/schema.js +132 -8
  342. package/dist/memory/schema.js.map +1 -1
  343. package/dist/memory/state-machine.d.ts +65 -10
  344. package/dist/memory/state-machine.d.ts.map +1 -1
  345. package/dist/memory/state-machine.js +134 -46
  346. package/dist/memory/state-machine.js.map +1 -1
  347. package/dist/memory/submit.d.ts +52 -3
  348. package/dist/memory/submit.d.ts.map +1 -1
  349. package/dist/memory/submit.js +118 -11
  350. package/dist/memory/submit.js.map +1 -1
  351. package/dist/storage/build-stamp.d.ts +18 -0
  352. package/dist/storage/build-stamp.d.ts.map +1 -0
  353. package/dist/storage/build-stamp.js +68 -0
  354. package/dist/storage/build-stamp.js.map +1 -0
  355. package/dist/storage/builtin-adapters.d.ts +32 -0
  356. package/dist/storage/builtin-adapters.d.ts.map +1 -0
  357. package/dist/storage/builtin-adapters.js +100 -0
  358. package/dist/storage/builtin-adapters.js.map +1 -0
  359. package/dist/storage/builtin-directives.d.ts +0 -29
  360. package/dist/storage/builtin-directives.d.ts.map +1 -1
  361. package/dist/storage/builtin-directives.js +9 -4
  362. package/dist/storage/builtin-directives.js.map +1 -1
  363. package/dist/storage/commit.d.ts +310 -3
  364. package/dist/storage/commit.d.ts.map +1 -1
  365. package/dist/storage/commit.js +807 -33
  366. package/dist/storage/commit.js.map +1 -1
  367. package/dist/storage/document.d.ts +6 -0
  368. package/dist/storage/document.d.ts.map +1 -1
  369. package/dist/storage/document.js +10 -1
  370. package/dist/storage/document.js.map +1 -1
  371. package/dist/storage/dry-run.d.ts +65 -0
  372. package/dist/storage/dry-run.d.ts.map +1 -0
  373. package/dist/storage/dry-run.js +150 -0
  374. package/dist/storage/dry-run.js.map +1 -0
  375. package/dist/storage/errors.d.ts +26 -0
  376. package/dist/storage/errors.d.ts.map +1 -1
  377. package/dist/storage/errors.js +27 -1
  378. package/dist/storage/errors.js.map +1 -1
  379. package/dist/storage/frontmatter.d.ts +1 -1
  380. package/dist/storage/frontmatter.js +1 -1
  381. package/dist/storage/git-read.d.ts +64 -0
  382. package/dist/storage/git-read.d.ts.map +1 -0
  383. package/dist/storage/git-read.js +107 -0
  384. package/dist/storage/git-read.js.map +1 -0
  385. package/dist/storage/index.d.ts +13 -5
  386. package/dist/storage/index.d.ts.map +1 -1
  387. package/dist/storage/index.js +39 -2
  388. package/dist/storage/index.js.map +1 -1
  389. package/dist/storage/layout.d.ts +2 -2
  390. package/dist/storage/layout.d.ts.map +1 -1
  391. package/dist/storage/layout.js +2 -7
  392. package/dist/storage/layout.js.map +1 -1
  393. package/dist/storage/memory-path.d.ts +18 -5
  394. package/dist/storage/memory-path.d.ts.map +1 -1
  395. package/dist/storage/memory-path.js +41 -5
  396. package/dist/storage/memory-path.js.map +1 -1
  397. package/dist/storage/snapshot.js +1 -1
  398. package/dist/storage/templates.d.ts +33 -6
  399. package/dist/storage/templates.d.ts.map +1 -1
  400. package/dist/storage/templates.js +170 -16
  401. package/dist/storage/templates.js.map +1 -1
  402. package/dist/validation/config-version.d.ts +19 -0
  403. package/dist/validation/config-version.d.ts.map +1 -0
  404. package/dist/validation/config-version.js +53 -0
  405. package/dist/validation/config-version.js.map +1 -0
  406. package/dist/validation/diagnostic.d.ts +40 -0
  407. package/dist/validation/diagnostic.d.ts.map +1 -0
  408. package/dist/validation/diagnostic.js +41 -0
  409. package/dist/validation/diagnostic.js.map +1 -0
  410. package/dist/validation/format.d.ts +74 -0
  411. package/dist/validation/format.d.ts.map +1 -0
  412. package/dist/validation/format.js +104 -0
  413. package/dist/validation/format.js.map +1 -0
  414. package/dist/validation/id.d.ts +14 -0
  415. package/dist/validation/id.d.ts.map +1 -1
  416. package/dist/validation/id.js +35 -11
  417. package/dist/validation/id.js.map +1 -1
  418. package/dist/validation/identity.d.ts +40 -0
  419. package/dist/validation/identity.d.ts.map +1 -0
  420. package/dist/validation/identity.js +78 -0
  421. package/dist/validation/identity.js.map +1 -0
  422. package/dist/validation/index.d.ts +9 -3
  423. package/dist/validation/index.d.ts.map +1 -1
  424. package/dist/validation/index.js +30 -1
  425. package/dist/validation/index.js.map +1 -1
  426. package/dist/validation/secret-scan.d.ts +3 -2
  427. package/dist/validation/secret-scan.d.ts.map +1 -1
  428. package/dist/validation/secret-scan.js +32 -11
  429. package/dist/validation/secret-scan.js.map +1 -1
  430. package/dist/validation/warning.d.ts +30 -16
  431. package/dist/validation/warning.d.ts.map +1 -1
  432. package/dist/validation/warning.js +74 -7
  433. package/dist/validation/warning.js.map +1 -1
  434. package/dist/workflow/bindings.d.ts +152 -0
  435. package/dist/workflow/bindings.d.ts.map +1 -0
  436. package/dist/workflow/bindings.js +249 -0
  437. package/dist/workflow/bindings.js.map +1 -0
  438. package/dist/workflow/create.d.ts +13 -0
  439. package/dist/workflow/create.d.ts.map +1 -0
  440. package/dist/workflow/create.js +41 -0
  441. package/dist/workflow/create.js.map +1 -0
  442. package/dist/workflow/deduce.d.ts +400 -0
  443. package/dist/workflow/deduce.d.ts.map +1 -0
  444. package/dist/workflow/deduce.js +1109 -0
  445. package/dist/workflow/deduce.js.map +1 -0
  446. package/dist/workflow/manifest-edit.d.ts +19 -0
  447. package/dist/workflow/manifest-edit.d.ts.map +1 -0
  448. package/dist/workflow/manifest-edit.js +124 -0
  449. package/dist/workflow/manifest-edit.js.map +1 -0
  450. package/dist/workflow/schema.d.ts +158 -19
  451. package/dist/workflow/schema.d.ts.map +1 -1
  452. package/dist/workflow/schema.js +163 -15
  453. package/dist/workflow/schema.js.map +1 -1
  454. package/package.json +18 -8
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The agent adapter manifest schema (`spec-016-agent-execution` §2.2, task-177): how to launch one
3
+ * agent CLI, declared in `.wingfoil/agents/{built-in,custom}/<name>.yaml`.
4
+ *
5
+ * Unlike every pillar file, each object node is **strict** (`z.strictObject`), so an unknown key is a
6
+ * Pass-1 validation error rather than `spec-009` §2's tolerated warning: a misspelt `args` would
7
+ * otherwise launch the agent without its MCP registration (§2.2). This is the one structural layer.
8
+ * The rules that cross fields — what a value of one field makes required in another (§2.2's "Req."
9
+ * column), and where each placeholder is legal (§2.3) — are Pass-2 checks in `./manifest.ts`, because
10
+ * they read several fields at once and must name the field they fault.
11
+ *
12
+ * There is deliberately no `env:` field (§2.2): credentials stay inside the agent CLI (`adr-012` point 1).
13
+ * The TypeScript type is derived with `z.infer`.
14
+ */
15
+ import { z } from 'zod';
16
+ import { ADAPTER_MANIFEST_FORMAT } from '../validation/format';
17
+ /**
18
+ * The manifest format this build reads (`spec-016` §2.2 `format`). A new manifest field bumps it.
19
+ * Declared in `src/validation/format.ts` beside every other file kind's format (task-251, `dl-149`).
20
+ */
21
+ export { ADAPTER_MANIFEST_FORMAT };
22
+ /**
23
+ * One adapter manifest, `spec-016` §2.2, field for field. A field the table marks "required with"
24
+ * another field's value is optional here and enforced in Pass 2 (`adapterManifestIssues`,
25
+ * `./manifest.ts`).
26
+ */
27
+ export declare const AdapterManifest: z.ZodObject<{
28
+ name: z.ZodString;
29
+ format: z.ZodLiteral<1>;
30
+ command: z.ZodString;
31
+ verified_with: z.ZodOptional<z.ZodString>;
32
+ version_args: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ launch: z.ZodObject<{
34
+ interactive: z.ZodObject<{
35
+ args: z.ZodArray<z.ZodString>;
36
+ terminal: z.ZodDefault<z.ZodEnum<{
37
+ optional: "optional";
38
+ required: "required";
39
+ }>>;
40
+ }, z.core.$strict>;
41
+ headless: z.ZodOptional<z.ZodObject<{
42
+ args: z.ZodArray<z.ZodString>;
43
+ output: z.ZodEnum<{
44
+ none: "none";
45
+ json: "json";
46
+ }>;
47
+ }, z.core.$strict>>;
48
+ }, z.core.$strict>;
49
+ prompt: z.ZodObject<{
50
+ via: z.ZodEnum<{
51
+ file: "file";
52
+ arg: "arg";
53
+ stdin: "stdin";
54
+ }>;
55
+ }, z.core.$strict>;
56
+ mcp: z.ZodObject<{
57
+ via: z.ZodEnum<{
58
+ args: "args";
59
+ "config-file": "config-file";
60
+ "config-arg": "config-arg";
61
+ }>;
62
+ template: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strict>;
64
+ session: z.ZodObject<{
65
+ id: z.ZodEnum<{
66
+ output: "output";
67
+ assign: "assign";
68
+ none: "none";
69
+ lookup: "lookup";
70
+ }>;
71
+ assign_args: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ lookup_args: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ field: z.ZodOptional<z.ZodString>;
74
+ resume: z.ZodObject<{
75
+ supported: z.ZodBoolean;
76
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
77
+ }, z.core.$strict>;
78
+ }, z.core.$strict>;
79
+ usage: z.ZodObject<{
80
+ from: z.ZodEnum<{
81
+ output: "output";
82
+ none: "none";
83
+ lookup: "lookup";
84
+ }>;
85
+ lookup_args: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ fields: z.ZodOptional<z.ZodObject<{
87
+ model: z.ZodOptional<z.ZodString>;
88
+ input: z.ZodOptional<z.ZodString>;
89
+ output: z.ZodOptional<z.ZodString>;
90
+ cache_read: z.ZodOptional<z.ZodString>;
91
+ cache_write: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strict>>;
93
+ }, z.core.$strict>;
94
+ summary: z.ZodOptional<z.ZodObject<{
95
+ export_args: z.ZodOptional<z.ZodArray<z.ZodString>>;
96
+ }, z.core.$strict>>;
97
+ }, z.core.$strict>;
98
+ /** A validated adapter manifest (`spec-016` §2.2), `launch.interactive.terminal` defaulted. */
99
+ export type AdapterManifest = z.infer<typeof AdapterManifest>;
100
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/agent/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;GAGG;AACH,OAAO,EAAE,uBAAuB,EAAE,CAAC;AA8BnC;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsC1B,CAAC;AAEH,+FAA+F;AAC/F,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdapterManifest = exports.ADAPTER_MANIFEST_FORMAT = void 0;
4
+ /**
5
+ * The agent adapter manifest schema (`spec-016-agent-execution` §2.2, task-177): how to launch one
6
+ * agent CLI, declared in `.wingfoil/agents/{built-in,custom}/<name>.yaml`.
7
+ *
8
+ * Unlike every pillar file, each object node is **strict** (`z.strictObject`), so an unknown key is a
9
+ * Pass-1 validation error rather than `spec-009` §2's tolerated warning: a misspelt `args` would
10
+ * otherwise launch the agent without its MCP registration (§2.2). This is the one structural layer.
11
+ * The rules that cross fields — what a value of one field makes required in another (§2.2's "Req."
12
+ * column), and where each placeholder is legal (§2.3) — are Pass-2 checks in `./manifest.ts`, because
13
+ * they read several fields at once and must name the field they fault.
14
+ *
15
+ * There is deliberately no `env:` field (§2.2): credentials stay inside the agent CLI (`adr-012` point 1).
16
+ * The TypeScript type is derived with `z.infer`.
17
+ */
18
+ const zod_1 = require("zod");
19
+ const format_1 = require("../validation/format");
20
+ Object.defineProperty(exports, "ADAPTER_MANIFEST_FORMAT", { enumerable: true, get: function () { return format_1.ADAPTER_MANIFEST_FORMAT; } });
21
+ const id_1 = require("../validation/id");
22
+ /** An argv template: a list of whole arguments, never a shell string (`dl-090` Q3 (a)). */
23
+ const Argv = zod_1.z.array(zod_1.z.string());
24
+ /** A non-empty string: a field whose empty value could only be a mistake. */
25
+ const NonEmpty = zod_1.z.string().min(1, 'must not be empty');
26
+ /** `launch.interactive` — the v0.3 launch, the agent owning the terminal (`adr-012` point 4). */
27
+ const InteractiveLaunch = zod_1.z.strictObject({
28
+ args: Argv,
29
+ /** Whether the launch needs a terminal on stdin and stdout (§3.3 step 12); `required` when absent. */
30
+ terminal: zod_1.z.enum(['required', 'optional']).default('required'),
31
+ });
32
+ /** `launch.headless` — no terminal, a structured result; read from v1.0 (§3.5). */
33
+ const HeadlessLaunch = zod_1.z.strictObject({
34
+ args: Argv,
35
+ output: zod_1.z.enum(['json', 'none']),
36
+ });
37
+ /** The JSON paths `usage.fields` may declare (§2.2); an undeclared one yields `not-reported`. */
38
+ const UsageFields = zod_1.z.strictObject({
39
+ model: NonEmpty.optional(),
40
+ input: NonEmpty.optional(),
41
+ output: NonEmpty.optional(),
42
+ cache_read: NonEmpty.optional(),
43
+ cache_write: NonEmpty.optional(),
44
+ });
45
+ /**
46
+ * One adapter manifest, `spec-016` §2.2, field for field. A field the table marks "required with"
47
+ * another field's value is optional here and enforced in Pass 2 (`adapterManifestIssues`,
48
+ * `./manifest.ts`).
49
+ */
50
+ exports.AdapterManifest = zod_1.z.strictObject({
51
+ name: zod_1.z.string().refine(id_1.isIdPiece, { message: `must be an id: characters [${id_1.ID_CHAR_CLASS}] only (spec-009 §1)` }),
52
+ format: zod_1.z.literal(format_1.ADAPTER_MANIFEST_FORMAT),
53
+ command: NonEmpty,
54
+ verified_with: NonEmpty.optional(),
55
+ version_args: Argv.optional(),
56
+ launch: zod_1.z.strictObject({
57
+ interactive: InteractiveLaunch,
58
+ headless: HeadlessLaunch.optional(),
59
+ }),
60
+ prompt: zod_1.z.strictObject({
61
+ via: zod_1.z.enum(['arg', 'stdin', 'file']),
62
+ }),
63
+ mcp: zod_1.z.strictObject({
64
+ // No `none`: an adapter that cannot register the `wingfoil` MCP server is refused (`adr-012`).
65
+ via: zod_1.z.enum(['config-file', 'config-arg', 'args']),
66
+ template: NonEmpty.optional(),
67
+ }),
68
+ session: zod_1.z.strictObject({
69
+ id: zod_1.z.enum(['assign', 'output', 'lookup', 'none']),
70
+ assign_args: Argv.optional(),
71
+ lookup_args: Argv.optional(),
72
+ field: NonEmpty.optional(),
73
+ resume: zod_1.z.strictObject({
74
+ supported: zod_1.z.boolean(),
75
+ args: Argv.optional(),
76
+ }),
77
+ }),
78
+ usage: zod_1.z.strictObject({
79
+ from: zod_1.z.enum(['output', 'lookup', 'none']),
80
+ lookup_args: Argv.optional(),
81
+ fields: UsageFields.optional(),
82
+ }),
83
+ summary: zod_1.z
84
+ .strictObject({
85
+ export_args: Argv.optional(),
86
+ })
87
+ .optional(),
88
+ });
89
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/agent/schema.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,6BAAwB;AAExB,iDAA+D;AAOtD,wGAPA,gCAAuB,OAOA;AANhC,yCAA4D;AAQ5D,2FAA2F;AAC3F,MAAM,IAAI,GAAG,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAEjC,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAExD,iGAAiG;AACjG,MAAM,iBAAiB,GAAG,OAAC,CAAC,YAAY,CAAC;IACvC,IAAI,EAAE,IAAI;IACV,sGAAsG;IACtG,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,E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C;QAClB,+FAA+F;QAC/F,GAAG,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAClD,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;KAC9B,CAAC;IACF,OAAO,EAAE,OAAC,CAAC,YAAY,CAAC;QACtB,EAAE,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClD,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE;QAC5B,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE;QAC5B,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE;QAC1B,MAAM,EAAE,OAAC,CAAC,YAAY,CAAC;YACrB,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;SACtB,CAAC;KACH,CAAC;IACF,KAAK,EAAE,OAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1C,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE;QAC5B,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE;KAC/B,CAAC;IACF,OAAO,EAAE,OAAC;SACP,YAAY,CAAC;QACZ,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE;KAC7B,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { DnaYaml } from '../dna/schema';
2
+ import type { ExecutionContextElement } from '../core/context';
3
+ import { type CoreResult } from '../core/types';
4
+ import { type NextResult, type Step } from '../core/workflow-next';
5
+ import type { Instance } from '../workflow/deduce';
6
+ /** P5.3.1 sc. 3, verbatim (§3.7 `NO_NEXT_STEP`). */
7
+ export declare const NO_NEXT_STEP_MESSAGE = "no next step to execute";
8
+ /** Which step a run takes (§3.1): absent fields select the active instance and its next step. */
9
+ export interface StepSelector {
10
+ /** `--workflow <ref>`: a workflow name (its most recently started open instance) or an open instance id. */
11
+ readonly workflow?: string;
12
+ /** `--step <key>`: a `spec-017` §4.9 step key on the selected instance's frontier. */
13
+ readonly key?: string;
14
+ }
15
+ /**
16
+ * `workflow next`'s deduction for `ref` at `HEAD` (`workflowNextAtHead`), its throws mapped as `workflow
17
+ * next` maps them: a `spec-003` error in the registry is `VALIDATION`, its first error the message and every
18
+ * diagnostic in `details.diagnostics`; another invalid committed file (`roles.yaml`, a directive) is
19
+ * `VALIDATION` with its issues. A `ref` naming no workflow, or no open instance, is the `NOT_FOUND` it returns.
20
+ */
21
+ export declare function readNextAtHead(root: string, ref: string | undefined): CoreResult<NextResult>;
22
+ /**
23
+ * §3.2 step 1: the frontier step `key` names — `NextResult.next` or one of the further ready steps — else,
24
+ * without `key`, `NextResult.next`. No open instance, or an empty frontier without `key`, is `NO_NEXT_STEP`;
25
+ * a `key` that is not on the selected instance's frontier is `spec-017` §10's `CONFLICT`.
26
+ */
27
+ export declare function selectFrontierStep(next: NextResult, key: string | undefined): CoreResult<Step>;
28
+ /**
29
+ * §3.2 step 2: `--element` if given, else the step's scope element, else the instance's bound element
30
+ * (`spec-017` §3.4). A step with none of the three — a collection-entry or empty scope on an instance with no
31
+ * bound element — is `NO_STEP_ELEMENT`. Whether the element exists at `HEAD` is the pipeline's check.
32
+ */
33
+ export declare function stepTargetElement(step: Step, instance: Instance | null, override: ExecutionContextElement | undefined): CoreResult<ExecutionContextElement>;
34
+ /**
35
+ * §3.2 step 3 (P5.3.2): `--role` if given — the pipeline checks it as it checks every `--role` — else the
36
+ * step's role. A step with no role is `NO_STEP_ROLE`; a step role `dna.yaml` does not define is refused here as a
37
+ * defence only: the registry refuses such a role at load (`E_PHASE_ROLE_UNKNOWN`, task-194, P5.3.2 sc. 3) against
38
+ * the same `dna.yaml`, so this check holds only for a step deduced from a registry that did not check it.
39
+ */
40
+ export declare function resolveStepRole(dna: DnaYaml, step: Step, override: string | undefined): CoreResult<string>;
41
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/agent/step.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAsB,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,oDAAoD;AACpD,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,4GAA4G;IAC5G,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sFAAsF;IACtF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,CAQ5F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAQ9F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAK3J;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,CAK1G"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_NEXT_STEP_MESSAGE = void 0;
4
+ exports.readNextAtHead = readNextAtHead;
5
+ exports.selectFrontierStep = selectFrontierStep;
6
+ exports.stepTargetElement = stepTargetElement;
7
+ exports.resolveStepRole = resolveStepRole;
8
+ /**
9
+ * `agent execute`'s step forms (task-235; `spec-016-agent-execution` §3.1 `--next`, `--workflow <ref>`,
10
+ * `--step <key>`; §3.2 steps 1–3; §3.7's step rows; approver ruling R16): the step comes from `spec-017`'s
11
+ * `workflow next` deduction (`NextResult`, task-216), and gives the run its workflow, phase, element and
12
+ * role.
13
+ *
14
+ * - {@link readNextAtHead}: the deduction for the instance `--workflow <ref>` selects, else the active
15
+ * instance (`spec-017` §3.3), at `HEAD`; a `spec-003` error in the registry is `VALIDATION` with every
16
+ * diagnostic in `details`, as `workflow next` refuses it (§3.7's second row).
17
+ * - {@link selectFrontierStep}: `--step <key>` on that instance's frontier, else `NextResult.next`.
18
+ * - {@link stepTargetElement}: `--element`, else the step's scope element, else the instance's bound element.
19
+ * - {@link resolveStepRole}: `--role`, else the step's role, which `dna.yaml` must define.
20
+ *
21
+ * All four are pure but the first, which reads `HEAD` only (`dl-080` (B)): the step a run takes is a
22
+ * function of committed state and the request (`REQ-SYS-07`). The phase's separation of executors is not
23
+ * checked (P4.12, v1.0) and every v0.3 run is `fresh` whatever the phase allows (§3.2 step 6, `dl-135`
24
+ * point 3): neither executor attribute of the step is read here.
25
+ */
26
+ const roles_1 = require("../dna/roles");
27
+ const types_1 = require("../core/types");
28
+ const workflow_next_1 = require("../core/workflow-next");
29
+ const validation_1 = require("../validation");
30
+ /** P5.3.1 sc. 3, verbatim (§3.7 `NO_NEXT_STEP`). */
31
+ exports.NO_NEXT_STEP_MESSAGE = 'no next step to execute';
32
+ /**
33
+ * `workflow next`'s deduction for `ref` at `HEAD` (`workflowNextAtHead`), its throws mapped as `workflow
34
+ * next` maps them: a `spec-003` error in the registry is `VALIDATION`, its first error the message and every
35
+ * diagnostic in `details.diagnostics`; another invalid committed file (`roles.yaml`, a directive) is
36
+ * `VALIDATION` with its issues. A `ref` naming no workflow, or no open instance, is the `NOT_FOUND` it returns.
37
+ */
38
+ function readNextAtHead(root, ref) {
39
+ try {
40
+ return (0, workflow_next_1.workflowNextAtHead)(root, ref);
41
+ }
42
+ catch (error) {
43
+ if (error instanceof validation_1.DiagnosticsError)
44
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: error.message, details: { diagnostics: error.diagnostics } });
45
+ if (error instanceof validation_1.ValidationError)
46
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: error.message, details: { issues: error.issues } });
47
+ throw error;
48
+ }
49
+ }
50
+ /**
51
+ * §3.2 step 1: the frontier step `key` names — `NextResult.next` or one of the further ready steps — else,
52
+ * without `key`, `NextResult.next`. No open instance, or an empty frontier without `key`, is `NO_NEXT_STEP`;
53
+ * a `key` that is not on the selected instance's frontier is `spec-017` §10's `CONFLICT`.
54
+ */
55
+ function selectFrontierStep(next, key) {
56
+ const noNextStep = (0, types_1.coreErr)({ code: 'NOT_FOUND', message: exports.NO_NEXT_STEP_MESSAGE });
57
+ if (next.instance === null)
58
+ return noNextStep;
59
+ if (key === undefined)
60
+ return next.next === null ? noNextStep : (0, types_1.coreOk)(next.next);
61
+ const found = [...(next.next === null ? [] : [next.next]), ...next.more].find((step) => step.key === key);
62
+ if (found !== undefined)
63
+ return (0, types_1.coreOk)(found);
64
+ const instance = next.instance.id;
65
+ return (0, types_1.coreErr)({ code: 'CONFLICT', message: `step '${key}' is not on the frontier of ${instance}`, details: { step: key, instance } });
66
+ }
67
+ /**
68
+ * §3.2 step 2: `--element` if given, else the step's scope element, else the instance's bound element
69
+ * (`spec-017` §3.4). A step with none of the three — a collection-entry or empty scope on an instance with no
70
+ * bound element — is `NO_STEP_ELEMENT`. Whether the element exists at `HEAD` is the pipeline's check.
71
+ */
72
+ function stepTargetElement(step, instance, override) {
73
+ if (override !== undefined)
74
+ return (0, types_1.coreOk)(override);
75
+ const scope = step.scope !== null && 'element' in step.scope ? step.scope.element : (instance?.element ?? null);
76
+ if (scope !== null)
77
+ return (0, types_1.coreOk)({ type: scope.type, id: scope.id });
78
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: `step '${step.key}' has no element: give --element <type>:<id>` });
79
+ }
80
+ /**
81
+ * §3.2 step 3 (P5.3.2): `--role` if given — the pipeline checks it as it checks every `--role` — else the
82
+ * step's role. A step with no role is `NO_STEP_ROLE`; a step role `dna.yaml` does not define is refused here as a
83
+ * defence only: the registry refuses such a role at load (`E_PHASE_ROLE_UNKNOWN`, task-194, P5.3.2 sc. 3) against
84
+ * the same `dna.yaml`, so this check holds only for a step deduced from a registry that did not check it.
85
+ */
86
+ function resolveStepRole(dna, step, override) {
87
+ if (override !== undefined)
88
+ return (0, types_1.coreOk)(override);
89
+ if (step.role === null)
90
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: `step '${step.key}' declares no role: give --role <role>` });
91
+ if (!(0, roles_1.isRoleDefined)(dna, step.role))
92
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: `step role '${step.role}' not defined in dna.yaml` });
93
+ return (0, types_1.coreOk)(step.role);
94
+ }
95
+ //# sourceMappingURL=step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/agent/step.ts"],"names":[],"mappings":";;;AA2CA,wCAQC;AAOD,gDAQC;AAOD,8CAKC;AAQD,0CAKC;AA3FD;;;;;;;;;;;;;;;;;GAiBG;AACH,wCAA6C;AAG7C,yCAAiE;AACjE,yDAAuF;AACvF,8CAAkE;AAGlE,oDAAoD;AACvC,QAAA,oBAAoB,GAAG,yBAAyB,CAAC;AAU9D;;;;;GAKG;AACH,SAAgB,cAAc,CAAC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A,eAAO,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC,GAAG,wCAAwC,EAAE,CAAC,CAAC;IACnI,IAAI,CAAC,IAAA,qBAAa,EAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAA,eAAO,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,IAAI,CAAC,IAAI,2BAA2B,EAAE,CAAC,CAAC;IACxI,OAAO,IAAA,cAAM,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": "0.3.0",
3
+ "commit": "cc31d7a8ca3940c6ec96dca4e0ef77f32f52dfb1"
4
+ }
@@ -1,11 +1,20 @@
1
+ import type { ErrorDetail } from '../core/error-details';
1
2
  import type { OutputFormat } from './output';
2
3
  /**
3
4
  * Write an error to stderr in the consistent spec-005 §3 format for the active `--format`: a
4
- * `{error, hint?}` object for `json`/`yaml`, or `error: <reason>` (+ optional `hint:` line) for
5
- * `console`. Writes only; the caller terminates via {@link exitWith}.
5
+ * `{error, hint?, details?}` object for `json`/`yaml`, or `error: <reason>` (+ optional `hint:` line,
6
+ * + one indented line per detail) for `console`. Writes only; the caller terminates via
7
+ * {@link exitWith}.
8
+ *
9
+ * `details` (task-130, `dl-055` option 1) is additive in every format: the `error:` line stays the
10
+ * first line and byte-identical, and the structured `details` key is omitted when the list is empty,
11
+ * so a consumer that reads only `error` is unaffected. A detail line is indented, and so is every
12
+ * continuation line of a multi-line detail, so no line of it can begin with the greppable `error: `
13
+ * or `hint: ` token.
6
14
  */
7
15
  export declare function emitError(reason: string, opts: {
8
16
  format: OutputFormat;
9
17
  hint?: string;
18
+ details?: readonly ErrorDetail[];
10
19
  }): void;
11
20
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/cli/error.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAS7F"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/cli/error.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,GAC9E,IAAI,CAgBN"}
package/dist/cli/error.js CHANGED
@@ -2,26 +2,47 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.emitError = emitError;
4
4
  /**
5
- * The consistent error format (spec-005-cli-command-contract §3, REQ-INT-08). Written verbatim
6
- * from the spec's own code listing so `src/cli` and the spec cannot drift.
5
+ * The consistent error format (spec-005-cli-command-contract §3, REQ-INT-08). Written from the
6
+ * spec's own code listing so `src/cli` and the spec cannot drift.
7
7
  */
8
8
  const js_yaml_1 = require("js-yaml");
9
9
  /**
10
10
  * Write an error to stderr in the consistent spec-005 §3 format for the active `--format`: a
11
- * `{error, hint?}` object for `json`/`yaml`, or `error: <reason>` (+ optional `hint:` line) for
12
- * `console`. Writes only; the caller terminates via {@link exitWith}.
11
+ * `{error, hint?, details?}` object for `json`/`yaml`, or `error: <reason>` (+ optional `hint:` line,
12
+ * + one indented line per detail) for `console`. Writes only; the caller terminates via
13
+ * {@link exitWith}.
14
+ *
15
+ * `details` (task-130, `dl-055` option 1) is additive in every format: the `error:` line stays the
16
+ * first line and byte-identical, and the structured `details` key is omitted when the list is empty,
17
+ * so a consumer that reads only `error` is unaffected. A detail line is indented, and so is every
18
+ * continuation line of a multi-line detail, so no line of it can begin with the greppable `error: `
19
+ * or `hint: ` token.
13
20
  */
14
21
  function emitError(reason, opts) {
22
+ const details = opts.details ?? [];
23
+ const payload = {
24
+ error: reason,
25
+ ...(opts.hint ? { hint: opts.hint } : {}),
26
+ ...(details.length > 0 ? { details } : {}),
27
+ };
15
28
  if (opts.format === 'json') {
16
- process.stderr.write(JSON.stringify({ error: reason, ...(opts.hint ? { hint: opts.hint } : {}) }) + '\n');
29
+ process.stderr.write(JSON.stringify(payload) + '\n');
17
30
  }
18
31
  else if (opts.format === 'yaml') {
19
- process.stderr.write((0, js_yaml_1.dump)({ error: reason, ...(opts.hint ? { hint: opts.hint } : {}) }));
32
+ process.stderr.write((0, js_yaml_1.dump)(payload));
20
33
  }
21
34
  else {
22
35
  process.stderr.write(`error: ${reason}\n`);
23
36
  if (opts.hint)
24
37
  process.stderr.write(`hint: ${opts.hint}\n`);
38
+ for (const detail of details)
39
+ process.stderr.write(` ${detailLine(detail).replace(/\n/g, '\n ')}\n`);
25
40
  }
26
41
  }
42
+ /** One console detail line: `<file>: <detail>`, or whichever of the two the entry has. */
43
+ function detailLine(detail) {
44
+ if (detail.file !== undefined && detail.detail !== undefined)
45
+ return `${detail.file}: ${detail.detail}`;
46
+ return detail.file ?? detail.detail ?? '';
47
+ }
27
48
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/cli/error.ts"],"names":[],"mappings":";;AAaA,8BASC;AAtBD;;;GAGG;AACH,qCAA2C;AAI3C;;;;GAIG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,IAA6C;IACrF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,CA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G,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3C,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACvD,CAAC;SAAM,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,cAAQ,EAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,MAAM,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;QAC5D,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3G,CAAC;AACH,CAAC;AAED,0FAA0F;AAC1F,SAAS,UAAU,CAAC,MAAmB;IACrC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;IACxG,OAAO,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;AAC5C,CAAC"}
@@ -7,13 +7,43 @@
7
7
  * which outcome maps to which code — lives in `src/core` (`exitCodeForError`/`exitCodeForResult`),
8
8
  * shared with the MCP surface per REQ-SYS-05 (task-012); `ExitCode` is re-exported from there so the
9
9
  * CLI never redeclares the contract's shape.
10
+ *
11
+ * The mechanism lets the output drain first (task-249, `bug-222`). A write to a pipe is asynchronous
12
+ * in Node: the kernel takes what fits in the pipe buffer (64 KiB on Linux) and the rest stays queued
13
+ * in the stream. `process.exit` drops whatever is queued, so a payload larger than the buffer reached
14
+ * a `| jq` cut short while the process still exited `0`. A file or a TTY is written synchronously and
15
+ * never has anything queued, which is why the same command redirected to a file was complete.
10
16
  */
11
17
  import type { ExitCode } from '../core';
12
18
  export type { ExitCode };
19
+ /**
20
+ * Thrown by a caller that cannot simply return after {@link exitWith} deferred the exit — today only
21
+ * the Commander `exitOverride` in `./program.ts`, because Commander calls `process.exit` itself, with
22
+ * its own code, as soon as that callback returns. The entry points (`src/cli.ts`, the test harness)
23
+ * recognise it by its `name` (a copy of this module loaded elsewhere throws the same name) and let the
24
+ * deferred exit happen instead of reporting an error.
25
+ */
26
+ export declare class DeferredExit extends Error {
27
+ readonly code: ExitCode;
28
+ constructor(code: ExitCode);
29
+ }
13
30
  /**
14
31
  * The single process-exit mechanism for the CLI (spec-005 §1, REQ-INT-04): optionally write
15
- * `message` to stderr, then `process.exit(code)`. Every invocation terminates through here so the
16
- * `0`/`1`/`2` contract cannot be bypassed. Returns `never`.
32
+ * `message` to stderr, then end the process with `code` through the one `process.exit` call.
33
+ *
34
+ * When stdout and stderr have nothing queued — a file, a TTY, or a pipe that took everything — the
35
+ * process ends here and now. When either still holds output for a pipe (task-249, `bug-222`), the exit
36
+ * is deferred until each has written it: `process.exitCode` is set to `code` at once, and
37
+ * `process.exit(code)` runs when the last queued write completes — or fails, as when the reader has
38
+ * gone away (`EPIPE`), which ends the process with the same `code` rather than an unhandled stream
39
+ * error. Either way the code is the one passed here, and the exit is the single `process.exit` call.
40
+ *
41
+ * Every caller returns right after this call, so which of the two happened does not matter to it; the
42
+ * one caller that cannot return normally reads the result.
43
+ *
44
+ * @returns `true` when the exit is deferred until the output drains — the process is still running
45
+ * only to finish writing, and the caller must do nothing else. (When the exit happened, nothing returns
46
+ * at all outside a test that stubs `process.exit`.)
17
47
  */
18
- export declare function exitWith(code: ExitCode, message?: string): never;
48
+ export declare function exitWith(code: ExitCode, message?: string): boolean;
19
49
  //# sourceMappingURL=exit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/cli/exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAGhE"}
1
+ {"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/cli/exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBAAd,IAAI,EAAE,QAAQ;CAIpC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAsBlE"}
package/dist/cli/exit.js CHANGED
@@ -1,14 +1,65 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeferredExit = void 0;
3
4
  exports.exitWith = exitWith;
5
+ /**
6
+ * Thrown by a caller that cannot simply return after {@link exitWith} deferred the exit — today only
7
+ * the Commander `exitOverride` in `./program.ts`, because Commander calls `process.exit` itself, with
8
+ * its own code, as soon as that callback returns. The entry points (`src/cli.ts`, the test harness)
9
+ * recognise it by its `name` (a copy of this module loaded elsewhere throws the same name) and let the
10
+ * deferred exit happen instead of reporting an error.
11
+ */
12
+ class DeferredExit extends Error {
13
+ code;
14
+ constructor(code) {
15
+ super(`exit ${String(code)} deferred until the output drains`);
16
+ this.code = code;
17
+ this.name = 'DeferredExit';
18
+ }
19
+ }
20
+ exports.DeferredExit = DeferredExit;
4
21
  /**
5
22
  * The single process-exit mechanism for the CLI (spec-005 §1, REQ-INT-04): optionally write
6
- * `message` to stderr, then `process.exit(code)`. Every invocation terminates through here so the
7
- * `0`/`1`/`2` contract cannot be bypassed. Returns `never`.
23
+ * `message` to stderr, then end the process with `code` through the one `process.exit` call.
24
+ *
25
+ * When stdout and stderr have nothing queued — a file, a TTY, or a pipe that took everything — the
26
+ * process ends here and now. When either still holds output for a pipe (task-249, `bug-222`), the exit
27
+ * is deferred until each has written it: `process.exitCode` is set to `code` at once, and
28
+ * `process.exit(code)` runs when the last queued write completes — or fails, as when the reader has
29
+ * gone away (`EPIPE`), which ends the process with the same `code` rather than an unhandled stream
30
+ * error. Either way the code is the one passed here, and the exit is the single `process.exit` call.
31
+ *
32
+ * Every caller returns right after this call, so which of the two happened does not matter to it; the
33
+ * one caller that cannot return normally reads the result.
34
+ *
35
+ * @returns `true` when the exit is deferred until the output drains — the process is still running
36
+ * only to finish writing, and the caller must do nothing else. (When the exit happened, nothing returns
37
+ * at all outside a test that stubs `process.exit`.)
8
38
  */
9
39
  function exitWith(code, message) {
10
40
  if (message)
11
41
  process.stderr.write(message + '\n');
12
- process.exit(code);
42
+ const queued = [process.stdout, process.stderr].filter((stream) => stream.writableLength > 0);
43
+ if (queued.length === 0) {
44
+ process.exit(code);
45
+ return false;
46
+ }
47
+ process.exitCode = code;
48
+ let waiting = queued.length;
49
+ for (const stream of queued) {
50
+ let settled = false;
51
+ const settle = () => {
52
+ if (settled)
53
+ return;
54
+ settled = true;
55
+ waiting -= 1;
56
+ if (waiting === 0)
57
+ process.exit(code);
58
+ };
59
+ // An empty write completes after every write queued before it; an `error` (EPIPE) ends the wait too.
60
+ stream.once('error', settle);
61
+ stream.write('', settle);
62
+ }
63
+ return true;
13
64
  }
14
65
  //# sourceMappingURL=exit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit.js","sourceRoot":"","sources":["../../src/cli/exit.ts"],"names":[],"mappings":";;AAmBA,4BAGC;AARD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAc,EAAE,OAAgB;IACvD,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"exit.js","sourceRoot":"","sources":["../../src/cli/exit.ts"],"names":[],"mappings":";;;AAoDA,4BAsBC;AAtDD;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,KAAK;IAChB;IAArB,YAAqB,IAAc;QACjC,KAAK,CAAC,QAAQ,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAD5C,SAAI,GAAJ,IAAI,CAAU;QAEjC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,QAAQ,CAAC,IAAc,EAAE,OAAgB;IACvD,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IAC9F,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,OAAO,KAAK,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC,CAAC;QACF,qGAAqG;QACrG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -16,7 +16,7 @@ export declare const MODULE_NAME: "cli";
16
16
  export { buildCliCommands, listRegisteredCliCommands } from './registrar';
17
17
  export type { BuildCommandsOptions, CliCommand } from './registrar';
18
18
  export { buildProgram } from './program';
19
- export { exitWith } from './exit';
19
+ export { DeferredExit, exitWith } from './exit';
20
20
  export type { ExitCode } from './exit';
21
21
  export { isValidFormat, renderSuccess } from './output';
22
22
  export type { OutputFormat } from './output';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,EAAG,KAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC1E,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,YAAY,EAAE,QAAQ,EA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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runMcp = exports.createReadlinePrompt = exports.runInit = exports.emitError = exports.renderSuccess = exports.isValidFormat = exports.exitWith = exports.buildProgram = exports.listRegisteredCliCommands = exports.buildCliCommands = exports.MODULE_NAME = void 0;
3
+ exports.runMcp = exports.createReadlinePrompt = exports.runInit = exports.emitError = exports.renderSuccess = exports.isValidFormat = exports.exitWith = exports.DeferredExit = exports.buildProgram = exports.listRegisteredCliCommands = exports.buildCliCommands = exports.MODULE_NAME = void 0;
4
4
  /**
5
5
  * `cli` module — human interface (Commander.js); the `wingfoil` command surface.
6
6
  *
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "listRegisteredCliCommands", { enumerable: true,
22
22
  var program_1 = require("./program");
23
23
  Object.defineProperty(exports, "buildProgram", { enumerable: true, get: function () { return program_1.buildProgram; } });
24
24
  var exit_1 = require("./exit");
25
+ Object.defineProperty(exports, "DeferredExit", { enumerable: true, get: function () { return exit_1.DeferredExit; } });
25
26
  Object.defineProperty(exports, "exitWith", { enumerable: true, get: function () { return exit_1.exitWith; } });
26
27
  var output_1 = require("./output");
27
28
  Object.defineProperty(exports, "isValidFormat", { enumerable: true, get: function () { return output_1.isValidFormat; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACU,QAAA,WAAW,GAAG,KAAc,CAAC;AAE1C,yCAA0E;AAAjE,6GAAA,gBAAgB,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AAEpD,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,+BAAkC;AAAzB,gGAAA,QAAQ,OAAA;AAEjB,mCAAwD;AAA/C,uGAAA,aAAa,OAAA;AAAE,uGAAA,aAAa,OAAA;AAErC,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAClB,+CAA+D;AAAtD,uGAAA,OAAO,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AAEtC,6CAAuC;AAA9B,qGAAA,MAAM,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACU,QAAA,WAAW,GAAG,KAAc,CAAC;AAE1C,yCAA0E;AAAjE,6GAAA,gBAAgB,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AAEpD,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,+BAAgD;AAAvC,oGAAA,YAAY,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAE/B,mCAAwD;AAA/C,uGAAA,aAAa,OAAA;AAAE,uGAAA,aAAa,OAAA;AAErC,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAClB,+CAA+D;AAAtD,uGAAA,OAAO,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AAEtC,6CAAuC;AAA9B,qGAAA,MAAM,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../src/cli/init-command.ts"],"names":[],"mappings":"AAeA,OAAO,EAA0C,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAWhD,0GAA0G;AAC1G,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yGAAyG;IACzG,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,iGAAiG;IACjG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,iGAAiG;AACjG,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,oGAAoG;IAC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