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,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadWorkflowRegistry = loadWorkflowRegistry;
4
+ exports.loadWorkflowRegistryAtRev = loadWorkflowRegistryAtRev;
5
+ exports.loadWorkflowRegistryAtCommit = loadWorkflowRegistryAtCommit;
6
+ exports.loadWorkflowRegistryAtHead = loadWorkflowRegistryAtHead;
7
+ /**
8
+ * The workflow registry every workflow command reads (task-194, `spec-017` §2): the loader's result
9
+ * (`spec-003` Layers 1–3 and its loader rows, `./loaders.ts`) **plus** the core checks
10
+ * (`./workflow-core-checks.ts`), which also need `memory.yaml` and `dna.yaml`. One function per
11
+ * baseline, each reading every input from that one baseline:
12
+ *
13
+ * - {@link loadWorkflowRegistryAtRev} / {@link loadWorkflowRegistryAtHead} — the committed baseline
14
+ * `spec-017` §1.1 gives every workflow operation (`HEAD`): the workflow files, `bindings.yaml`,
15
+ * `memory.yaml`, `dna.yaml` and the Memory templates are all read at one commit, resolved once;
16
+ * {@link loadWorkflowRegistryAtCommit} is the same read for a commit the caller has already resolved
17
+ * (the workflow deduction's snapshot, task-283);
18
+ * - {@link loadWorkflowRegistry} — the working tree. No workflow command reads it since task-204 moved
19
+ * `workflow list` to `HEAD` (ruling R15); it stays for callers that read the working tree on purpose.
20
+ *
21
+ * The result has the loader's shape — `{ manifest, workflows, bindings, diagnostics }` — with the core
22
+ * warnings appended after the loader's. A core **error** makes the load throw a `DiagnosticsError`
23
+ * (`VALIDATION`, exit `1`) carrying the whole ordered array, exactly as a loader error does; the first
24
+ * error is the reason. The core checks run only on a registry the loader accepted.
25
+ */
26
+ const fs_1 = require("fs");
27
+ const path_1 = require("path");
28
+ const storage_1 = require("../storage");
29
+ const validation_1 = require("../validation");
30
+ const loaders_1 = require("./loaders");
31
+ const revision_1 = require("./revision");
32
+ const workflow_core_checks_1 = require("./workflow-core-checks");
33
+ /** An absent manifest: an empty registry, with no diagnostic (`spec-003` Layer 1). */
34
+ const EMPTY_REGISTRY = { manifest: null, workflows: [], bindings: null, diagnostics: [] };
35
+ /** The template files `memoryYaml` declares, as paths relative to `.wingfoil/`, sorted, each once. */
36
+ function declaredTemplateFiles(memoryYaml) {
37
+ const files = Object.values(memoryYaml?.types ?? {}).flatMap((type) => (type.template?.file === undefined ? [] : [type.template.file]));
38
+ return [...new Set(files)].sort();
39
+ }
40
+ /** `.wingfoil/<relative>` as a repository-relative POSIX path, or `null` when it leaves `.wingfoil/`. */
41
+ function configPath(relative) {
42
+ const normalized = path_1.posix.normalize(`.wingfoil/${relative}`);
43
+ return normalized.startsWith('.wingfoil/') ? normalized : null;
44
+ }
45
+ /** The frontmatter keys of a Memory template, or `null` when it has none that parses as a map. */
46
+ function frontmatterKeys(raw, label) {
47
+ const text = (0, storage_1.extractFrontmatter)(raw);
48
+ if (text === null)
49
+ return null;
50
+ try {
51
+ const data = (0, validation_1.parseYaml)(text, label);
52
+ return typeof data === 'object' && data !== null && !Array.isArray(data) ? new Set(Object.keys(data)) : null;
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ /** Run the core checks on an accepted load, append them, and throw when one is an error. */
59
+ function withCoreChecks(load, source) {
60
+ if (load.manifest === null)
61
+ return load;
62
+ const memoryYaml = source.memoryYaml();
63
+ const dnaYaml = source.dnaYaml();
64
+ // Every template `memory.yaml` declares, read up front in one call (one batch at a commit).
65
+ const files = declaredTemplateFiles(memoryYaml);
66
+ const templates = new Map(source.configFiles(files).map((raw, index) => [files[index], raw]));
67
+ const fieldsByType = new Map();
68
+ const templateFields = (type) => {
69
+ if (!fieldsByType.has(type)) {
70
+ const file = memoryYaml?.types[type]?.template?.file;
71
+ const raw = file === undefined ? null : templates.get(file);
72
+ fieldsByType.set(type, raw === null ? null : frontmatterKeys(raw, `.wingfoil/${file}`));
73
+ }
74
+ return fieldsByType.get(type);
75
+ };
76
+ const core = (0, workflow_core_checks_1.workflowCoreDiagnostics)({ include: load.manifest.include, workflows: load.workflows, bindings: load.bindings }, { memoryYaml, dnaYaml, templateFields });
77
+ const diagnostics = [...load.diagnostics, ...core];
78
+ if (diagnostics.some((diagnostic) => diagnostic.severity === 'error'))
79
+ throw new validation_1.DiagnosticsError(diagnostics);
80
+ return { ...load, diagnostics };
81
+ }
82
+ /** A working-tree config read: `null` when the file is absent, a throw when it is invalid. */
83
+ function absentAsNull(read) {
84
+ try {
85
+ return read();
86
+ }
87
+ catch (error) {
88
+ if (error instanceof loaders_1.ConfigFileMissingError)
89
+ return null;
90
+ throw error;
91
+ }
92
+ }
93
+ /**
94
+ * The workflow registry from the **working tree**: the loader's result and the core checks, every
95
+ * input read from disk. `workflow list` read it until task-204 moved that command to `HEAD`.
96
+ *
97
+ * @throws `DiagnosticsError` (`VALIDATION`) when the loader or a core check reports an error.
98
+ */
99
+ function loadWorkflowRegistry(root) {
100
+ return withCoreChecks((0, loaders_1.loadWorkflowsYaml)(root), {
101
+ memoryYaml: () => absentAsNull(() => (0, loaders_1.loadMemoryYaml)(root)),
102
+ dnaYaml: () => absentAsNull(() => (0, loaders_1.loadDnaYaml)(root)),
103
+ configFiles: (relatives) => relatives.map((relative) => {
104
+ const path = configPath(relative);
105
+ if (path === null)
106
+ return null;
107
+ const full = (0, path_1.join)(root, path);
108
+ // Only a regular file is a template: an absent path, or one that is a directory, reads as absent,
109
+ // as `readPathsAtRev` answers at a commit (task-283 review F3).
110
+ return (0, fs_1.statSync)(full, { throwIfNoEntry: false })?.isFile() === true ? (0, storage_1.readDocument)(full) : null;
111
+ }),
112
+ });
113
+ }
114
+ /**
115
+ * The workflow registry **as commit `rev` holds it** (`spec-017` §1.1): `rev` is resolved once, and the
116
+ * workflow files, `bindings.yaml`, `memory.yaml`, `dna.yaml` and the Memory templates are all read at
117
+ * that commit, so a dirty working tree changes nothing (the `command-baseline` directive).
118
+ *
119
+ * @param overlay - Workflow files (the manifest, an included file) that replace the commit's own, keyed by
120
+ * repository-relative path, `null` for absent: the registry a commit about to be made would leave
121
+ * (`workflow create` / `remove`, task-211). `memory.yaml`, `dna.yaml` and the templates stay the commit's.
122
+ * @throws `RevisionError` for a malformed rev or one naming no commit; `DiagnosticsError`
123
+ * (`VALIDATION`) when the loader or a core check reports an error.
124
+ */
125
+ function loadWorkflowRegistryAtRev(root, rev, overlay) {
126
+ return loadWorkflowRegistryAtCommit(root, (0, revision_1.resolveRevision)(root, rev), overlay);
127
+ }
128
+ /**
129
+ * {@link loadWorkflowRegistryAtRev} for a `sha` already resolved to a commit, read without resolving it
130
+ * again (task-283, `bug-309`): the workflow deduction's snapshot resolves `HEAD` once and reads every
131
+ * pillar at that sha. The Memory templates the core checks read are fetched in one batch.
132
+ *
133
+ * @param sha - The full sha of a commit, as `resolveRevision` returned it.
134
+ * @param overlay - As {@link loadWorkflowRegistryAtRev}'s.
135
+ * @param pillars - `memory.yaml` and `dna.yaml` as the caller already loads them at `sha`
136
+ * ({@link RegistryPillars}); absent, the checks load them at `sha` themselves.
137
+ * @throws `DiagnosticsError` (`VALIDATION`) when the loader or a core check reports an error.
138
+ */
139
+ function loadWorkflowRegistryAtCommit(root, sha, overlay, pillars) {
140
+ return withCoreChecks((0, loaders_1.loadWorkflowsYamlAtCommit)(root, sha, overlay), {
141
+ memoryYaml: pillars?.memoryYaml ?? (() => (0, loaders_1.loadMemoryYamlAtCommit)(root, sha)),
142
+ dnaYaml: pillars?.dnaYaml ?? (() => (0, loaders_1.loadDnaYamlAtCommit)(root, sha)),
143
+ configFiles: (relatives) => {
144
+ const paths = relatives.map(configPath);
145
+ const inside = paths.filter((path) => path !== null);
146
+ const answers = new Map((0, storage_1.readPathsAtRev)(root, sha, inside).map((raw, index) => [inside[index], raw]));
147
+ return paths.map((path) => (path === null ? null : answers.get(path)));
148
+ },
149
+ });
150
+ }
151
+ /**
152
+ * {@link loadWorkflowRegistryAtRev} at `HEAD`; a repository with no commit yet (or no repository)
153
+ * holds no committed manifest, so its registry is empty.
154
+ */
155
+ function loadWorkflowRegistryAtHead(root) {
156
+ return (0, revision_1.atHeadOr)(root, () => loadWorkflowRegistryAtRev(root, 'HEAD'), EMPTY_REGISTRY);
157
+ }
158
+ //# sourceMappingURL=workflow-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-registry.js","sourceRoot":"","sources":["../../src/core/workflow-registry.ts"],"names":[],"mappings":";;AAsIA,oDAcC;AAaD,8DAEC;AAaD,oEAgBC;AAMD,gEAEC;AAxMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,2BAA8B;AAC9B,+BAAmC;AAInC,wCAA8E;AAC9E,8CAA4D;AAE5D,uCASmB;AACnB,yCAAuD;AACvD,iEAAiE;AAEjE,sFAAsF;AACtF,MAAM,cAAc,GAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AA2B/G,sGAAsG;AACtG,SAAS,qBAAqB,CAAC,UAA6B;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxI,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,yGAAyG;AACzG,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,UAAU,GAAG,YAAK,CAAC,SAAS,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;IAC5D,OAAO,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACjE,CAAC;AAED,kGAAkG;AAClG,SAAS,eAAe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,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,gCAAsB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC5E,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,6BAAmB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACnE,WAAW,EAAE,CAAC,SAAS,EAAE,EAAE;YACzB,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACxC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YACrE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAA,wBAAc,EAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAE,EAAE,GAAoB,CAAC,CAAC,CAAC,CAAC;YACvH,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAA,mBAAQ,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { type Baseline, type Instance } from '../workflow/deduce';
2
+ import { type CoreFn } from './registry';
3
+ import { type CoreResult } from './types';
4
+ import { type Step } from './workflow-next';
5
+ /** `spec-017` §10's refusal of a project whose `memory.yaml` declares no `plan` type. */
6
+ export declare const NO_PLAN_TYPE_MESSAGE = "memory type 'plan' is not declared in memory.yaml; workflow start records an instance as a plan element";
7
+ /** `spec-017` §10: `end` with no open instance (BDD P4.3 sc. 3). */
8
+ export declare const NO_ACTIVE_WORKFLOW_MESSAGE = "no active workflow to end";
9
+ /** `wingfoil workflow start <name> [--element <type>:<id>] [--title <t>] [--set phase=<v>] [--set scope=<v>]` params. */
10
+ export interface WorkflowStartParams {
11
+ readonly root: string;
12
+ /** The workflow name (`spec-008` §1: the target is the positional, `dl-082`). */
13
+ readonly positional?: string;
14
+ readonly options?: Readonly<Record<string, string | readonly string[]>>;
15
+ }
16
+ /** `wingfoil workflow end [<ref>]` params: the `<ref>` rides the bare positional. */
17
+ export interface WorkflowEndParams {
18
+ readonly root: string;
19
+ readonly positional?: string;
20
+ }
21
+ /** `workflow start`'s value (`spec-017` §8): the new instance, its first frontier step, and the two commits. */
22
+ export interface StartResult {
23
+ readonly baseline: Baseline;
24
+ readonly instance: Instance;
25
+ readonly next: Step | null;
26
+ /** The add and submit commits, in that order. */
27
+ readonly commits: readonly string[];
28
+ }
29
+ /** `workflow end`'s value (`spec-017` §8): the ended instance, the instance now active (or `null`), the commit. */
30
+ export interface EndResult {
31
+ readonly baseline: Baseline;
32
+ readonly ended: Instance;
33
+ readonly active: Instance | null;
34
+ readonly commit: string;
35
+ }
36
+ /**
37
+ * The two Memory verbs `start` writes through, handed in by `CORE_MODULES` (`memoryAdd`, `memorySubmit`), so
38
+ * the plan is added and submitted by the very operations `wingfoil memory add` / `submit` run — their
39
+ * checks, their commit subjects and their commit-scope post-conditions — and by no copy of them.
40
+ */
41
+ export interface StartVerbs {
42
+ /** `memoryAdd`: `options` as the CLI passes them, `fields` the frontmatter written as given (`element`). */
43
+ readonly add: CoreFn<unknown, {
44
+ id: string;
45
+ path: string;
46
+ }>;
47
+ readonly submit: CoreFn<unknown, unknown>;
48
+ }
49
+ /**
50
+ * `workflow start <name>` (`spec-017` §7.1). Order: the usage checks (exit 2), the git identity (REQ-SEC-01),
51
+ * an initialized project, then every refusal decided at `HEAD` — a `spec-003` error, an unknown or
52
+ * non-startable workflow, no `plan` type, the element, the id — before the first write.
53
+ *
54
+ * @throws `DiagnosticsError` / `ValidationError` as the snapshot reader and the token expansion throw them;
55
+ * `CORE_MODULES` maps them (`VALIDATION`, exit 1).
56
+ */
57
+ export declare function workflowStart(params: WorkflowStartParams, verbs: StartVerbs): Promise<CoreResult<StartResult>>;
58
+ /**
59
+ * `workflow end [<ref>]` (`spec-017` §7.2). Order: the git identity (REQ-SEC-01), an initialized project, the
60
+ * instance `<ref>` selects at `HEAD` (or the active one), a plan still `draft` (`INVALID_TRANSITION`), an
61
+ * incomplete deduction (`CONFLICT`, with the `memory deprecate` hint), then the `active → done` transition,
62
+ * through the transition verbs' own preamble and commit (`beginMemoryTransition`, `commitMemoryTransition`).
63
+ *
64
+ * @throws as {@link readDeductionSnapshotAtHead}.
65
+ */
66
+ export declare function workflowEnd(params: WorkflowEndParams): Promise<CoreResult<EndResult>>;
67
+ /** `workflow start`'s `--format console` rendering (`spec-017` §8): the instance, then its first step as `next` prints it. Pure. */
68
+ export declare function renderStartConsole(value: StartResult): string;
69
+ /** `workflow end`'s `--format console` rendering (`spec-017` §8): the ended instance and the one now active. Pure. */
70
+ export declare function renderEndConsole(value: EndResult): string;
71
+ //# sourceMappingURL=workflow-start-end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-start-end.d.ts","sourceRoot":"","sources":["../../src/core/workflow-start-end.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAsD,KAAK,QAAQ,EAAmC,KAAK,QAAQ,EAA0B,MAAM,oBAAoB,CAAC;AAO/K,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAI3D,OAAO,EAAwD,KAAK,IAAI,EAAE,MAAM,iBAAiB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QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CAC3C;AA+GD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAqDpH;AAmBD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAwC3F;AAOD,oIAAoI;AACpI,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAM7D;AAED,sHAAsH;AACtH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAIzD"}
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_ACTIVE_WORKFLOW_MESSAGE = exports.NO_PLAN_TYPE_MESSAGE = void 0;
4
+ exports.workflowStart = workflowStart;
5
+ exports.workflowEnd = workflowEnd;
6
+ exports.renderStartConsole = renderStartConsole;
7
+ exports.renderEndConsole = renderEndConsole;
8
+ /**
9
+ * `wingfoil workflow start <name>` and `wingfoil workflow end [<ref>]` (task-217; `spec-017` §3.1–§3.5, §7.1,
10
+ * §7.2, §8 `StartResult` / `EndResult`, §10, §11; BDD P4.2, P4.3; REQ-STATE-03).
11
+ *
12
+ * **The record is a `plan` element** (§3.1, OQ-1). A started workflow is an instance recorded as a Memory
13
+ * element of type `plan` whose `workflow` names the workflow, whose `element` holds the bound element's id
14
+ * (or the context element's, §3.5) and whose `parent` is empty. No other store exists (REQ-SYS-03): the
15
+ * instance is open while its plan is `draft` or `active`, and the most recently started open instance is
16
+ * the active one (§3.3), which the deduction already reads (`src/workflow/deduce.ts`).
17
+ *
18
+ * **Baseline: `HEAD`, gating** (§1.1, §11). Both commands decide from one snapshot of the repository as
19
+ * committed at `HEAD` (`readDeductionSnapshotAtHead`): the registry, `memory.yaml`, the element, the open
20
+ * instances and the deduction. `start`'s id collision check reads the wider baseline `dl-101` names — every
21
+ * local branch, remote-tracking ref, `HEAD` and the working tree — which can only refuse more.
22
+ *
23
+ * **`start`** writes two commits through the Memory verbs, each scoped to the plan file: `wf(plan): add <id>`
24
+ * (`memory add`, with the derived tokens and the `element` field) then `wf(plan): submit <id>` (`memory
25
+ * submit`, `draft → active`). A refused second commit leaves the plan `draft`, the instance open, and the
26
+ * error names `wingfoil memory submit <id>`. Under `--dry-run` the plan of the first commit is printed (the
27
+ * dry run stops at a command's first commit, `spec-008` §2).
28
+ *
29
+ * **`end`** refuses a plan still in `draft` and an instance whose deduction is not complete, then moves the
30
+ * plan `active → done` along the `waiting` edge `memory.yaml` declares, writing `wf(plan): finalize <id>
31
+ * [active → done]` (`dl-079` (A)'s `finalize`).
32
+ */
33
+ const memory_1 = require("../memory");
34
+ const storage_1 = require("../storage");
35
+ const validation_1 = require("../validation");
36
+ const deduce_1 = require("../workflow/deduce");
37
+ const schema_1 = require("../workflow/schema");
38
+ const element_ref_1 = require("./element-ref");
39
+ const git_identity_1 = require("./git-identity");
40
+ const init_1 = require("./init");
41
+ const memory_transition_1 = require("./memory-transition");
42
+ const registry_1 = require("./registry");
43
+ const types_1 = require("./types");
44
+ const usage_error_1 = require("./usage-error");
45
+ const workflow_deduction_1 = require("./workflow-deduction");
46
+ const workflow_list_show_1 = require("./workflow-list-show");
47
+ const workflow_next_1 = require("./workflow-next");
48
+ /** The `--set` names `workflow start` accepts (`spec-017` §7.1): the two derived plan tokens it lets a user override. */
49
+ const START_SET_NAMES = ['phase', 'scope'];
50
+ /** The highest `-<n>` suffix `start` tries on a derived `phase` before it gives up (a safeguard; review F1). */
51
+ const MAX_PHASE_SUFFIX = 1000;
52
+ /** `phase` with no bound and no context element (approver ruling R18). */
53
+ const DEFAULT_PHASE = '1';
54
+ /** `spec-017` §10's refusal of a project whose `memory.yaml` declares no `plan` type. */
55
+ exports.NO_PLAN_TYPE_MESSAGE = "memory type 'plan' is not declared in memory.yaml; workflow start records an instance as a plan element";
56
+ /** `spec-017` §10: `end` with no open instance (BDD P4.3 sc. 3). */
57
+ exports.NO_ACTIVE_WORKFLOW_MESSAGE = 'no active workflow to end';
58
+ /** A single-valued option: a repeated occurrence keeps the last. */
59
+ function single(value) {
60
+ return typeof value === 'string' || value === undefined ? value : value[value.length - 1];
61
+ }
62
+ /** The usage half of `start` (`spec-008` §1, §5, §7, §10): every spelling fault, exit 2, before any read. */
63
+ function startUsage(params) {
64
+ const { positional: name, options } = params;
65
+ if (name === undefined || name.trim() === '')
66
+ throw new usage_error_1.UsageError((0, registry_1.missingOperandReason)('name'));
67
+ const elementOption = single(options?.['element']);
68
+ let element = null;
69
+ if (elementOption !== undefined) {
70
+ const parsed = (0, element_ref_1.parseElementRef)(elementOption);
71
+ if (!parsed.ok)
72
+ throw new usage_error_1.UsageError(parsed.error.message);
73
+ element = parsed.value;
74
+ }
75
+ const set = (0, memory_1.parseSetOptions)(options?.['set']);
76
+ if (!set.ok)
77
+ throw new usage_error_1.UsageError(set.message);
78
+ for (const key of Object.keys(set.values)) {
79
+ if (!START_SET_NAMES.includes(key))
80
+ throw new usage_error_1.UsageError(`invalid flag value: --set ${key}: workflow start sets only phase and scope`);
81
+ }
82
+ const title = single(options?.['title']);
83
+ return { name, element, ...(title === undefined ? {} : { title }), set: set.values };
84
+ }
85
+ /**
86
+ * The bound element (§3.4) and the context element (§3.5) of a new instance of `workflow`, or the refusal.
87
+ * A declared element comes from `--element` or, absent it, from the active instance when its bound element
88
+ * is of the declared type; it must exist at `HEAD`. A workflow that declares none takes no `--element`, and
89
+ * records the active instance's bound element, if any, as its context.
90
+ */
91
+ function resolveStartElement(name, declared, given, deduction, exists) {
92
+ const active = deduction.instances[0]?.instance ?? null;
93
+ if (declared === undefined) {
94
+ if (given !== null)
95
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: `workflow '${name}' declares no element: --element is not accepted` });
96
+ return (0, types_1.coreOk)({ bound: null, context: active?.element ?? null });
97
+ }
98
+ const needs = (0, types_1.coreErr)({ code: 'VALIDATION', message: `workflow '${name}' needs a ${declared} element: give --element ${declared}:<id>` });
99
+ if (given === null) {
100
+ const inherited = active?.element ?? null;
101
+ return inherited !== null && inherited.type === declared ? (0, types_1.coreOk)({ bound: inherited, context: null }) : needs;
102
+ }
103
+ if (given.type !== declared)
104
+ return needs;
105
+ if (!exists(given.type, given.id))
106
+ return (0, types_1.coreErr)({ code: 'NOT_FOUND', message: `element not found: ${given.type}:${given.id}`, details: { element: `${given.type}:${given.id}` } });
107
+ return (0, types_1.coreOk)({ bound: given, context: null });
108
+ }
109
+ /**
110
+ * The plan's tokens and id (§7.1, ruling R18): `workflow` = the name; `phase` = the bound element's id, else
111
+ * the context element's, else `1`, with the lowest free `-<n>` (`n ≥ 2`) appended when the id is occupied on
112
+ * any baseline `dl-101` names; `scope` = the name. `--set phase=` / `--set scope=` override them, and a
113
+ * colliding `--set phase=` is `CONFLICT`. Only tokens the committed `id_pattern` or `path` holds are passed
114
+ * on; a `--set` naming none is `memory add`'s refusal. An `id_pattern` with a `{n}` counter is unique by
115
+ * construction and is not checked, nor is a `path` with no `{id}` (one file per other tokens: `memory add`
116
+ * refuses an occupied one). The suffix is tried only when `{phase}` is a token of the `id_pattern` itself —
117
+ * in the `path` alone it cannot change the id — and at most {@link MAX_PHASE_SUFFIX} times.
118
+ */
119
+ function planTokens(root, name, idPattern, pathPattern, set, base, title) {
120
+ const declared = new Set([...(0, validation_1.patternTokens)(idPattern), ...(0, validation_1.patternTokens)(pathPattern)]);
121
+ const derived = { workflow: name, phase: base, scope: name };
122
+ const tokens = {};
123
+ for (const key of Object.keys(derived).sort())
124
+ if (declared.has(key))
125
+ tokens[key] = derived[key];
126
+ Object.assign(tokens, set);
127
+ const titleOf = (phase) => title ?? (phase === undefined ? name : `${name} — ${phase}`);
128
+ // The id `memory add` will generate: its `{slug}` comes from the title it is given (review F1 nit).
129
+ const idOf = (values) => (0, validation_1.generateId)((0, memory_1.expandFieldTokens)(idPattern, values), { slug: (0, memory_1.slugifyTitle)(titleOf(values['phase'])), n: 0 });
130
+ const planned = (values) => ({ id: idOf(values), title: titleOf(values['phase']), tokens: values });
131
+ // A `{n}` id is unique by construction; a `path` with no `{id}` names one file per other tokens, which
132
+ // `memory add`'s absent-target check decides (`idOccupancy` would read every plan as that one).
133
+ if ((0, memory_1.hasNumericToken)(idPattern) || !(0, validation_1.patternTokens)(pathPattern).includes('id'))
134
+ return (0, types_1.coreOk)(planned(tokens));
135
+ // Only a `{phase}` in the id itself can be made unique by the `-<n>` suffix (review F1): otherwise, and for
136
+ // a `--set phase=`, the id is checked once.
137
+ const occupied = (0, memory_1.idOccupancy)(root, pathPattern);
138
+ if (!(0, validation_1.patternTokens)(idPattern).includes('phase') || set['phase'] !== undefined) {
139
+ const plan = planned(tokens);
140
+ if (occupied(plan.id))
141
+ return (0, types_1.coreErr)({ code: 'CONFLICT', message: `plan id already exists: ${plan.id}`, details: { id: plan.id } });
142
+ return (0, types_1.coreOk)(plan);
143
+ }
144
+ for (let n = 1; n <= MAX_PHASE_SUFFIX; n += 1) {
145
+ const plan = planned({ ...tokens, phase: n === 1 ? base : `${base}-${n}` });
146
+ if (!occupied(plan.id))
147
+ return (0, types_1.coreOk)(plan);
148
+ }
149
+ const last = idOf({ ...tokens, phase: `${base}-${MAX_PHASE_SUFFIX}` });
150
+ return (0, types_1.coreErr)({ code: 'CONFLICT', message: `plan id already exists: ${last}`, details: { id: last } });
151
+ }
152
+ /**
153
+ * `workflow start <name>` (`spec-017` §7.1). Order: the usage checks (exit 2), the git identity (REQ-SEC-01),
154
+ * an initialized project, then every refusal decided at `HEAD` — a `spec-003` error, an unknown or
155
+ * non-startable workflow, no `plan` type, the element, the id — before the first write.
156
+ *
157
+ * @throws `DiagnosticsError` / `ValidationError` as the snapshot reader and the token expansion throw them;
158
+ * `CORE_MODULES` maps them (`VALIDATION`, exit 1).
159
+ */
160
+ async function workflowStart(params, verbs) {
161
+ const { root } = params;
162
+ const usage = startUsage(params);
163
+ const identity = (0, git_identity_1.requireGitIdentity)(root);
164
+ if (!identity.ok)
165
+ return identity;
166
+ const initialized = (0, init_1.requireInitializedProject)(root);
167
+ if (!initialized.ok)
168
+ return initialized;
169
+ const snapshot = (0, workflow_deduction_1.readDeductionSnapshotAtHead)(root);
170
+ const workflow = snapshot.workflows.find((candidate) => candidate.name === usage.name);
171
+ if (workflow === undefined)
172
+ return (0, types_1.coreErr)({ code: 'NOT_FOUND', message: (0, workflow_list_show_1.unknownWorkflowMessage)(usage.name), details: { ref: usage.name } });
173
+ if (!(0, schema_1.workflowFacts)(workflow).startable)
174
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: `cannot start a sub workflow directly: ${usage.name}` });
175
+ const planType = snapshot.memoryYaml?.types[deduce_1.PLAN_TYPE];
176
+ if (planType === undefined)
177
+ return (0, types_1.coreErr)({ code: 'VALIDATION', message: exports.NO_PLAN_TYPE_MESSAGE });
178
+ const deduction = (0, deduce_1.deduceWorkflowState)(snapshot);
179
+ const exists = (type, id) => snapshot.documents.some(({ frontmatter }) => frontmatter['type'] === type && frontmatter['id'] === id);
180
+ const resolved = resolveStartElement(usage.name, workflow.element, usage.element, deduction, exists);
181
+ if (!resolved.ok)
182
+ return resolved;
183
+ const recorded = resolved.value.bound ?? resolved.value.context;
184
+ const base = recorded?.id ?? DEFAULT_PHASE;
185
+ const plan = planTokens(root, usage.name, planType.id_pattern ?? '{workflow}-{phase}-plan', planType.path, usage.set, base, usage.title);
186
+ if (!plan.ok)
187
+ return plan;
188
+ const { title, tokens } = plan.value;
189
+ const added = await verbs.add({
190
+ root,
191
+ options: { type: deduce_1.PLAN_TYPE, title, set: Object.keys(tokens).sort().map((key) => `${key}=${tokens[key]}`) },
192
+ ...(recorded === null ? {} : { fields: { element: recorded.id } }),
193
+ });
194
+ if (!added.ok)
195
+ return added;
196
+ // A successful `memoryAdd` / `memorySubmit` always carries its commit (`coreOk(…, { sha, message })`).
197
+ const addCommit = added.commit.sha;
198
+ let submitted;
199
+ try {
200
+ submitted = await verbs.submit({ root, positional: added.value.id });
201
+ }
202
+ catch (error) {
203
+ if (!(error instanceof storage_1.StorageError))
204
+ throw error;
205
+ return (0, types_1.coreErr)(submitFailure(added.value.id, 'IO', (0, storage_1.commitFailureSummary)(error)));
206
+ }
207
+ if (!submitted.ok)
208
+ return (0, types_1.coreErr)(submitFailure(added.value.id, submitted.error.code, submitted.error.message));
209
+ const next = (0, workflow_next_1.workflowNextAtHead)(root, added.value.id);
210
+ if (!next.ok)
211
+ return next;
212
+ return (0, types_1.coreOk)({ baseline: next.value.baseline, instance: next.value.instance, next: next.value.next, commits: [addCommit, submitted.commit.sha] }, submitted.commit, [...(added.warnings ?? []), ...(submitted.warnings ?? [])]);
213
+ }
214
+ /** `spec-017` §10's refusal when the plan was added and its submit commit was not made. */
215
+ function submitFailure(id, code, cause) {
216
+ return {
217
+ code,
218
+ message: `plan ${id} was added but not submitted: run wingfoil memory submit ${id}`,
219
+ details: { id, issues: [{ detail: cause }] },
220
+ };
221
+ }
222
+ /** Why an open instance whose deduction is not complete cannot end (§7.2): its current step, or why it has none. */
223
+ function incompleteReason(selected) {
224
+ const { instance, frontier } = selected;
225
+ if (frontier.length > 0)
226
+ return `current step ${frontier[0].key}`;
227
+ if (instance.abandoned && instance.element !== null)
228
+ return `it is abandoned: its element ${instance.element.type}:${instance.element.id} is ${instance.element.status}`;
229
+ return `workflow '${instance.workflow}' is not loaded`;
230
+ }
231
+ /**
232
+ * `workflow end [<ref>]` (`spec-017` §7.2). Order: the git identity (REQ-SEC-01), an initialized project, the
233
+ * instance `<ref>` selects at `HEAD` (or the active one), a plan still `draft` (`INVALID_TRANSITION`), an
234
+ * incomplete deduction (`CONFLICT`, with the `memory deprecate` hint), then the `active → done` transition,
235
+ * through the transition verbs' own preamble and commit (`beginMemoryTransition`, `commitMemoryTransition`).
236
+ *
237
+ * @throws as {@link readDeductionSnapshotAtHead}.
238
+ */
239
+ async function workflowEnd(params) {
240
+ const { root, positional: ref } = params;
241
+ const identity = (0, git_identity_1.requireGitIdentity)(root);
242
+ if (!identity.ok)
243
+ return identity;
244
+ const initialized = (0, init_1.requireInitializedProject)(root);
245
+ if (!initialized.ok)
246
+ return initialized;
247
+ const snapshot = (0, workflow_deduction_1.readDeductionSnapshotAtHead)(root);
248
+ const deduction = (0, deduce_1.deduceWorkflowState)(snapshot);
249
+ const selected = (0, deduce_1.resolveInstanceRef)(deduction, ref);
250
+ if (selected === null) {
251
+ if (ref === undefined)
252
+ return (0, types_1.coreErr)({ code: 'NOT_FOUND', message: exports.NO_ACTIVE_WORKFLOW_MESSAGE });
253
+ return (0, workflow_next_1.unresolvedRef)({ workflows: snapshot.workflows, plans: (0, workflow_deduction_1.instancePlanIds)(snapshot.documents) }, ref);
254
+ }
255
+ const { instance } = selected;
256
+ if (instance.planStatus === 'draft') {
257
+ return (0, types_1.coreErr)({ code: 'INVALID_TRANSITION', message: `workflow '${instance.workflow}' was not submitted: run wingfoil memory submit ${instance.id}` });
258
+ }
259
+ if (!selected.complete) {
260
+ return (0, types_1.coreErr)({
261
+ code: 'CONFLICT',
262
+ message: `workflow '${instance.workflow}' is not complete: ${incompleteReason(selected)}`,
263
+ hint: `wingfoil memory deprecate ${instance.id} abandons it`,
264
+ details: { instance: instance.id },
265
+ });
266
+ }
267
+ const prepared = (0, memory_transition_1.beginMemoryTransition)(root, instance.id, 'finalize');
268
+ if (!prepared.ok)
269
+ return prepared;
270
+ const { type, from, to, content } = prepared.value;
271
+ const message = (0, memory_1.formatMemoryCommitMessage)({ type, op: 'finalize', ids: [instance.id], transition: { from, to } });
272
+ const committed = (0, memory_transition_1.commitMemoryTransition)(root, prepared.value, (0, memory_1.setFrontmatterField)(content, 'status', to), message);
273
+ if (!committed.ok)
274
+ return committed;
275
+ const after = (0, deduce_1.deduceWorkflowState)((0, workflow_deduction_1.readDeductionSnapshotAtHead)(root));
276
+ return (0, types_1.coreOk)({ baseline: after.baseline, ended: instance, active: after.instances[0]?.instance ?? null, commit: committed.value }, { sha: committed.value, message }, prepared.value.warnings);
277
+ }
278
+ /** Whether `value` is a dry run's plan rather than the command's own result (`spec-008` §2). */
279
+ function isDryRunPlan(value) {
280
+ return typeof value === 'object' && value !== null && value.dryRun === true;
281
+ }
282
+ /** `workflow start`'s `--format console` rendering (`spec-017` §8): the instance, then its first step as `next` prints it. Pure. */
283
+ function renderStartConsole(value) {
284
+ if (isDryRunPlan(value))
285
+ return `${JSON.stringify(value, null, 2)}\n`;
286
+ const { instance, next } = value;
287
+ const head = `started ${instance.workflow} as ${instance.id} (active)\n`;
288
+ const message = next === null ? `no next step: workflow '${instance.workflow}' is complete` : undefined;
289
+ return head + (0, workflow_next_1.renderNextConsole)({ baseline: value.baseline, instance: null, complete: next === null, next, more: [], ...(message === undefined ? {} : { message }), diagnostics: [] });
290
+ }
291
+ /** `workflow end`'s `--format console` rendering (`spec-017` §8): the ended instance and the one now active. Pure. */
292
+ function renderEndConsole(value) {
293
+ if (isDryRunPlan(value))
294
+ return `${JSON.stringify(value, null, 2)}\n`;
295
+ const active = value.active === null ? 'none' : `${value.active.workflow} (${value.active.id})`;
296
+ return `ended ${value.ended.workflow} (${value.ended.id})\nactive: ${active}\n`;
297
+ }
298
+ //# sourceMappingURL=workflow-start-end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-start-end.js","sourceRoot":"","sources":["../../src/core/workflow-start-end.ts"],"names":[],"mappings":";;;AAgOA,sCAqDC;AA2BD,kCAwCC;AAQD,gDAMC;AAGD,4CAIC;AA7WD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,sCAQmB;AACnB,wCAAgE;AAChE,8CAA0D;AAC1D,+CAA+K;AAC/K,+CAAmD;AAEnD,+CAAgD;AAChD,iDAAoD;AACpD,iCAAmD;AACnD,2DAAoF;AACpF,yCAA+D;AAC/D,mCAA2D;AAC3D,+C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