@interf/compiler 0.5.1 → 0.6.3

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 (353) hide show
  1. package/README.md +160 -201
  2. package/builtin-workflows/interf/README.md +22 -10
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +8 -5
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +3 -0
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -2
  6. package/builtin-workflows/interf/improve/SKILL.md +4 -4
  7. package/builtin-workflows/interf/use/query/SKILL.md +1 -1
  8. package/builtin-workflows/interf/workflow.json +19 -5
  9. package/builtin-workflows/interf/{compiled.schema.json → workflow.schema.json} +10 -3
  10. package/dist/bin.js +2 -28
  11. package/dist/{commands → cli/commands}/check-draft.d.ts +2 -2
  12. package/dist/{commands → cli/commands}/check-draft.js +13 -13
  13. package/dist/{commands → cli/commands}/compile-controller.d.ts +3 -3
  14. package/dist/{commands → cli/commands}/compile-controller.js +39 -44
  15. package/dist/cli/commands/compile.d.ts +33 -0
  16. package/dist/{commands → cli/commands}/compile.js +107 -33
  17. package/dist/{commands → cli/commands}/compiled-flow.d.ts +3 -4
  18. package/dist/{commands → cli/commands}/compiled-flow.js +9 -14
  19. package/dist/{commands → cli/commands}/create-workflow-wizard.d.ts +20 -2
  20. package/dist/cli/commands/create-workflow-wizard.js +288 -0
  21. package/dist/{commands → cli/commands}/create.d.ts +2 -2
  22. package/dist/cli/commands/create.js +166 -0
  23. package/dist/cli/commands/dataset-selection.d.ts +6 -0
  24. package/dist/cli/commands/dataset-selection.js +11 -0
  25. package/dist/{commands → cli/commands}/default.js +5 -5
  26. package/dist/{commands → cli/commands}/doctor.js +12 -13
  27. package/dist/{commands → cli/commands}/executor-flow.d.ts +2 -2
  28. package/dist/{commands → cli/commands}/executor-flow.js +17 -17
  29. package/dist/cli/commands/init.d.ts +11 -0
  30. package/dist/{commands → cli/commands}/init.js +202 -109
  31. package/dist/{commands → cli/commands}/list.js +9 -6
  32. package/dist/{commands → cli/commands}/reset.js +5 -5
  33. package/dist/{commands → cli/commands}/source-config-wizard.d.ts +10 -5
  34. package/dist/{commands → cli/commands}/source-config-wizard.js +202 -95
  35. package/dist/{commands → cli/commands}/status.js +20 -11
  36. package/dist/{commands → cli/commands}/test-flow.d.ts +13 -4
  37. package/dist/{commands → cli/commands}/test-flow.js +30 -26
  38. package/dist/cli/commands/test.d.ts +14 -0
  39. package/dist/{commands → cli/commands}/test.js +48 -40
  40. package/dist/{commands → cli/commands}/verify.js +4 -4
  41. package/dist/cli/index.d.ts +21 -0
  42. package/dist/cli/index.js +33 -0
  43. package/dist/index.d.ts +22 -11
  44. package/dist/index.js +15 -6
  45. package/dist/lib/agent-args.d.ts +1 -3
  46. package/dist/lib/agent-args.js +1 -42
  47. package/dist/lib/agent-constants.d.ts +1 -5
  48. package/dist/lib/agent-constants.js +1 -28
  49. package/dist/lib/agent-detection.d.ts +1 -7
  50. package/dist/lib/agent-detection.js +1 -65
  51. package/dist/lib/agent-execution.d.ts +1 -2
  52. package/dist/lib/agent-execution.js +1 -242
  53. package/dist/lib/agent-logs.d.ts +1 -2
  54. package/dist/lib/agent-logs.js +1 -17
  55. package/dist/lib/agent-preflight.d.ts +1 -7
  56. package/dist/lib/agent-preflight.js +1 -76
  57. package/dist/lib/agent-render.d.ts +1 -8
  58. package/dist/lib/agent-render.js +1 -218
  59. package/dist/lib/agent-shells.d.ts +1 -44
  60. package/dist/lib/agent-shells.js +1 -847
  61. package/dist/lib/agent-status.d.ts +1 -3
  62. package/dist/lib/agent-status.js +1 -58
  63. package/dist/lib/agent-types.d.ts +1 -30
  64. package/dist/lib/agent-types.js +1 -1
  65. package/dist/lib/agents.d.ts +1 -6
  66. package/dist/lib/agents.js +1 -5
  67. package/dist/lib/builtin-compiled-workflow.d.ts +1 -129
  68. package/dist/lib/builtin-compiled-workflow.js +1 -153
  69. package/dist/lib/compiled-compile.d.ts +1 -52
  70. package/dist/lib/compiled-compile.js +1 -274
  71. package/dist/lib/compiled-paths.d.ts +1 -39
  72. package/dist/lib/compiled-paths.js +3 -103
  73. package/dist/lib/compiled-raw.d.ts +1 -49
  74. package/dist/lib/compiled-raw.js +3 -102
  75. package/dist/lib/compiled-reset.d.ts +1 -1
  76. package/dist/lib/compiled-reset.js +3 -44
  77. package/dist/lib/compiled-schema.d.ts +1 -27
  78. package/dist/lib/compiled-schema.js +1 -110
  79. package/dist/lib/discovery.d.ts +1 -1
  80. package/dist/lib/discovery.js +2 -2
  81. package/dist/lib/execution-profile.d.ts +1 -17
  82. package/dist/lib/execution-profile.js +1 -84
  83. package/dist/lib/executors.d.ts +1 -32
  84. package/dist/lib/executors.js +1 -43
  85. package/dist/lib/interf-bootstrap.d.ts +1 -3
  86. package/dist/lib/interf-bootstrap.js +3 -18
  87. package/dist/lib/interf-detect.d.ts +1 -33
  88. package/dist/lib/interf-detect.js +3 -176
  89. package/dist/lib/interf-scaffold.d.ts +1 -2
  90. package/dist/lib/interf-scaffold.js +3 -121
  91. package/dist/lib/interf-workflow-package.d.ts +1 -20
  92. package/dist/lib/interf-workflow-package.js +1 -276
  93. package/dist/lib/interf.d.ts +1 -5
  94. package/dist/lib/interf.js +3 -4
  95. package/dist/lib/local-workflows.d.ts +1 -53
  96. package/dist/lib/local-workflows.js +1 -399
  97. package/dist/lib/package-root.d.ts +1 -0
  98. package/dist/lib/package-root.js +1 -0
  99. package/dist/lib/project-paths.d.ts +1 -11
  100. package/dist/lib/project-paths.js +3 -32
  101. package/dist/lib/runtime-acceptance.d.ts +1 -9
  102. package/dist/lib/runtime-acceptance.js +1 -257
  103. package/dist/lib/runtime-contracts.d.ts +1 -2
  104. package/dist/lib/runtime-contracts.js +1 -47
  105. package/dist/lib/runtime-inventory.d.ts +1 -7
  106. package/dist/lib/runtime-inventory.js +1 -29
  107. package/dist/lib/runtime-paths.d.ts +1 -7
  108. package/dist/lib/runtime-paths.js +1 -23
  109. package/dist/lib/runtime-prompt.d.ts +1 -2
  110. package/dist/lib/runtime-prompt.js +1 -46
  111. package/dist/lib/runtime-reconcile.d.ts +1 -2
  112. package/dist/lib/runtime-reconcile.js +1 -156
  113. package/dist/lib/runtime-runs.d.ts +1 -11
  114. package/dist/lib/runtime-runs.js +1 -250
  115. package/dist/lib/runtime-types.d.ts +1 -43
  116. package/dist/lib/runtime-types.js +1 -1
  117. package/dist/lib/runtime.d.ts +1 -6
  118. package/dist/lib/runtime.js +1 -5
  119. package/dist/lib/schema.d.ts +4 -1016
  120. package/dist/lib/schema.js +6 -539
  121. package/dist/lib/source-config.d.ts +1 -39
  122. package/dist/lib/source-config.js +3 -293
  123. package/dist/lib/state-artifacts.d.ts +1 -8
  124. package/dist/lib/state-artifacts.js +1 -13
  125. package/dist/lib/state-health.d.ts +1 -4
  126. package/dist/lib/state-health.js +1 -132
  127. package/dist/lib/state-io.d.ts +1 -10
  128. package/dist/lib/state-io.js +1 -76
  129. package/dist/lib/state-paths.d.ts +1 -4
  130. package/dist/lib/state-paths.js +1 -13
  131. package/dist/lib/state-view.d.ts +1 -4
  132. package/dist/lib/state-view.js +1 -103
  133. package/dist/lib/state.d.ts +1 -6
  134. package/dist/lib/state.js +1 -5
  135. package/dist/lib/test-execution.d.ts +1 -14
  136. package/dist/lib/test-execution.js +3 -525
  137. package/dist/lib/test-matrices.d.ts +1 -90
  138. package/dist/lib/test-matrices.js +3 -96
  139. package/dist/lib/test-paths.d.ts +1 -12
  140. package/dist/lib/test-paths.js +3 -59
  141. package/dist/lib/test-profile-presets.d.ts +1 -57
  142. package/dist/lib/test-profile-presets.js +3 -50
  143. package/dist/lib/test-sandbox.d.ts +1 -11
  144. package/dist/lib/test-sandbox.js +3 -105
  145. package/dist/lib/test-specs.d.ts +1 -7
  146. package/dist/lib/test-specs.js +3 -114
  147. package/dist/lib/test-targets.d.ts +1 -5
  148. package/dist/lib/test-targets.js +3 -38
  149. package/dist/lib/test-types.d.ts +1 -17
  150. package/dist/lib/test-types.js +3 -1
  151. package/dist/lib/test.d.ts +1 -4
  152. package/dist/lib/test.js +3 -3
  153. package/dist/lib/validate-compiled.d.ts +1 -27
  154. package/dist/lib/validate-compiled.js +1 -238
  155. package/dist/lib/validate-helpers.d.ts +1 -12
  156. package/dist/lib/validate-helpers.js +1 -41
  157. package/dist/lib/validate.d.ts +1 -19
  158. package/dist/lib/validate.js +1 -256
  159. package/dist/lib/workflow-authoring.d.ts +1 -0
  160. package/dist/lib/workflow-authoring.js +1 -0
  161. package/dist/lib/workflow-definitions.d.ts +1 -68
  162. package/dist/lib/workflow-definitions.js +1 -206
  163. package/dist/lib/workflow-edit-session.d.ts +1 -0
  164. package/dist/lib/workflow-edit-session.js +1 -0
  165. package/dist/lib/workflow-edit-utils.d.ts +1 -0
  166. package/dist/lib/workflow-edit-utils.js +1 -0
  167. package/dist/lib/workflow-helpers.d.ts +1 -38
  168. package/dist/lib/workflow-helpers.js +1 -167
  169. package/dist/lib/workflow-improvement.d.ts +1 -22
  170. package/dist/lib/workflow-improvement.js +1 -396
  171. package/dist/lib/workflow-primitives.d.ts +1 -2
  172. package/dist/lib/workflow-primitives.js +1 -5
  173. package/dist/lib/workflow-review-paths.d.ts +1 -10
  174. package/dist/lib/workflow-review-paths.js +1 -27
  175. package/dist/lib/workflow-stage-policy.d.ts +1 -0
  176. package/dist/lib/workflow-stage-policy.js +1 -0
  177. package/dist/lib/workflow-stage-runner.d.ts +1 -41
  178. package/dist/lib/workflow-stage-runner.js +1 -109
  179. package/dist/lib/workflows.d.ts +1 -15
  180. package/dist/lib/workflows.js +1 -31
  181. package/dist/packages/agents/index.d.ts +17 -0
  182. package/dist/packages/agents/index.js +15 -0
  183. package/dist/packages/agents/lib/agents.d.ts +6 -0
  184. package/dist/packages/agents/lib/agents.js +5 -0
  185. package/dist/packages/agents/lib/args.d.ts +4 -0
  186. package/dist/packages/agents/lib/args.js +52 -0
  187. package/dist/packages/agents/lib/constants.d.ts +5 -0
  188. package/dist/packages/agents/lib/constants.js +28 -0
  189. package/dist/packages/agents/lib/detection.d.ts +7 -0
  190. package/dist/packages/agents/lib/detection.js +65 -0
  191. package/dist/packages/agents/lib/execution-profile.d.ts +17 -0
  192. package/dist/packages/agents/lib/execution-profile.js +84 -0
  193. package/dist/packages/agents/lib/execution.d.ts +2 -0
  194. package/dist/packages/agents/lib/execution.js +243 -0
  195. package/dist/packages/agents/lib/executors.d.ts +32 -0
  196. package/dist/packages/agents/lib/executors.js +45 -0
  197. package/dist/packages/agents/lib/logs.d.ts +2 -0
  198. package/dist/packages/agents/lib/logs.js +17 -0
  199. package/dist/packages/agents/lib/preflight.d.ts +7 -0
  200. package/dist/packages/agents/lib/preflight.js +77 -0
  201. package/dist/packages/agents/lib/render.d.ts +8 -0
  202. package/dist/packages/agents/lib/render.js +218 -0
  203. package/dist/packages/agents/lib/schema.d.ts +8 -0
  204. package/dist/packages/agents/lib/schema.js +7 -0
  205. package/dist/packages/agents/lib/shells.d.ts +69 -0
  206. package/dist/packages/agents/lib/shells.js +1021 -0
  207. package/dist/packages/agents/lib/status.d.ts +3 -0
  208. package/dist/packages/agents/lib/status.js +58 -0
  209. package/dist/packages/agents/lib/types.d.ts +30 -0
  210. package/dist/packages/agents/lib/types.js +1 -0
  211. package/dist/{lib → packages/agents/lib}/user-config.d.ts +1 -0
  212. package/dist/{lib → packages/agents/lib}/user-config.js +3 -2
  213. package/dist/packages/compiler/compiled-compile.d.ts +48 -0
  214. package/dist/packages/compiler/compiled-compile.js +256 -0
  215. package/dist/packages/compiler/compiled-schema.d.ts +31 -0
  216. package/dist/packages/compiler/compiled-schema.js +141 -0
  217. package/dist/packages/compiler/index.d.ts +24 -0
  218. package/dist/packages/compiler/index.js +23 -0
  219. package/dist/packages/compiler/lib/schema.d.ts +684 -0
  220. package/dist/packages/compiler/lib/schema.js +361 -0
  221. package/dist/packages/compiler/runtime-acceptance.d.ts +9 -0
  222. package/dist/packages/compiler/runtime-acceptance.js +269 -0
  223. package/dist/packages/compiler/runtime-contracts.d.ts +2 -0
  224. package/dist/packages/compiler/runtime-contracts.js +48 -0
  225. package/dist/packages/compiler/runtime-inventory.d.ts +7 -0
  226. package/dist/packages/compiler/runtime-inventory.js +29 -0
  227. package/dist/packages/compiler/runtime-paths.d.ts +8 -0
  228. package/dist/packages/compiler/runtime-paths.js +26 -0
  229. package/dist/packages/compiler/runtime-prompt.d.ts +2 -0
  230. package/dist/packages/compiler/runtime-prompt.js +48 -0
  231. package/dist/packages/compiler/runtime-reconcile.d.ts +2 -0
  232. package/dist/packages/compiler/runtime-reconcile.js +193 -0
  233. package/dist/packages/compiler/runtime-runs.d.ts +11 -0
  234. package/dist/packages/compiler/runtime-runs.js +262 -0
  235. package/dist/packages/compiler/runtime-types.d.ts +43 -0
  236. package/dist/packages/compiler/runtime-types.js +1 -0
  237. package/dist/packages/compiler/runtime.d.ts +6 -0
  238. package/dist/packages/compiler/runtime.js +5 -0
  239. package/dist/packages/compiler/state-artifacts.d.ts +8 -0
  240. package/dist/packages/compiler/state-artifacts.js +13 -0
  241. package/dist/packages/compiler/state-health.d.ts +4 -0
  242. package/dist/packages/compiler/state-health.js +132 -0
  243. package/dist/packages/compiler/state-io.d.ts +10 -0
  244. package/dist/packages/compiler/state-io.js +76 -0
  245. package/dist/packages/compiler/state-paths.d.ts +4 -0
  246. package/dist/packages/compiler/state-paths.js +13 -0
  247. package/dist/packages/compiler/state-view.d.ts +4 -0
  248. package/dist/packages/compiler/state-view.js +103 -0
  249. package/dist/packages/compiler/state.d.ts +7 -0
  250. package/dist/packages/compiler/state.js +12 -0
  251. package/dist/packages/compiler/validate-compiled.d.ts +27 -0
  252. package/dist/packages/compiler/validate-compiled.js +241 -0
  253. package/dist/packages/compiler/validate-helpers.d.ts +12 -0
  254. package/dist/packages/compiler/validate-helpers.js +41 -0
  255. package/dist/packages/compiler/validate.d.ts +21 -0
  256. package/dist/packages/compiler/validate.js +249 -0
  257. package/dist/packages/compiler/workflow-primitives.d.ts +2 -0
  258. package/dist/packages/compiler/workflow-primitives.js +5 -0
  259. package/dist/packages/compiler/workflows.d.ts +15 -0
  260. package/dist/packages/compiler/workflows.js +31 -0
  261. package/dist/packages/project-model/compiled-paths.d.ts +40 -0
  262. package/dist/packages/project-model/compiled-paths.js +106 -0
  263. package/dist/packages/project-model/compiled-raw.d.ts +49 -0
  264. package/dist/packages/project-model/compiled-raw.js +102 -0
  265. package/dist/packages/project-model/compiled-reset.d.ts +2 -0
  266. package/dist/packages/project-model/compiled-reset.js +72 -0
  267. package/dist/packages/project-model/index.d.ts +11 -0
  268. package/dist/packages/project-model/index.js +10 -0
  269. package/dist/packages/project-model/interf-bootstrap.d.ts +3 -0
  270. package/dist/packages/project-model/interf-bootstrap.js +18 -0
  271. package/dist/packages/project-model/interf-detect.d.ts +33 -0
  272. package/dist/packages/project-model/interf-detect.js +176 -0
  273. package/dist/packages/project-model/interf-scaffold.d.ts +2 -0
  274. package/dist/packages/project-model/interf-scaffold.js +124 -0
  275. package/dist/packages/project-model/interf.d.ts +5 -0
  276. package/dist/packages/project-model/interf.js +4 -0
  277. package/dist/packages/project-model/lib/schema.d.ts +125 -0
  278. package/dist/packages/project-model/lib/schema.js +62 -0
  279. package/dist/packages/project-model/project-paths.d.ts +11 -0
  280. package/dist/packages/project-model/project-paths.js +32 -0
  281. package/dist/packages/project-model/source-config.d.ts +38 -0
  282. package/dist/packages/project-model/source-config.js +297 -0
  283. package/dist/packages/testing/index.d.ts +13 -0
  284. package/dist/packages/testing/index.js +10 -0
  285. package/dist/packages/testing/lib/schema.d.ts +261 -0
  286. package/dist/packages/testing/lib/schema.js +119 -0
  287. package/dist/packages/testing/test-execution.d.ts +14 -0
  288. package/dist/packages/testing/test-execution.js +525 -0
  289. package/dist/packages/testing/test-matrices.d.ts +90 -0
  290. package/dist/packages/testing/test-matrices.js +96 -0
  291. package/dist/packages/testing/test-paths.d.ts +12 -0
  292. package/dist/packages/testing/test-paths.js +59 -0
  293. package/dist/packages/testing/test-profile-presets.d.ts +57 -0
  294. package/dist/packages/testing/test-profile-presets.js +50 -0
  295. package/dist/packages/testing/test-sandbox.d.ts +11 -0
  296. package/dist/packages/testing/test-sandbox.js +105 -0
  297. package/dist/packages/testing/test-specs.d.ts +7 -0
  298. package/dist/packages/testing/test-specs.js +114 -0
  299. package/dist/packages/testing/test-targets.d.ts +5 -0
  300. package/dist/packages/testing/test-targets.js +38 -0
  301. package/dist/packages/testing/test-types.d.ts +16 -0
  302. package/dist/packages/testing/test-types.js +1 -0
  303. package/dist/packages/testing/test.d.ts +4 -0
  304. package/dist/packages/testing/test.js +3 -0
  305. package/dist/packages/workflow-authoring/index.d.ts +4 -0
  306. package/dist/packages/workflow-authoring/index.js +4 -0
  307. package/dist/packages/workflow-authoring/lib/workflow-edit-utils.d.ts +10 -0
  308. package/dist/packages/workflow-authoring/lib/workflow-edit-utils.js +39 -0
  309. package/dist/packages/workflow-authoring/workflow-authoring.d.ts +26 -0
  310. package/dist/packages/workflow-authoring/workflow-authoring.js +120 -0
  311. package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +16 -0
  312. package/dist/packages/workflow-authoring/workflow-edit-session.js +57 -0
  313. package/dist/packages/workflow-authoring/workflow-improvement.d.ts +23 -0
  314. package/dist/packages/workflow-authoring/workflow-improvement.js +209 -0
  315. package/dist/packages/workflow-package/builtin-compiled-workflow.d.ts +38 -0
  316. package/dist/packages/workflow-package/builtin-compiled-workflow.js +94 -0
  317. package/dist/packages/workflow-package/index.d.ts +9 -0
  318. package/dist/packages/workflow-package/index.js +9 -0
  319. package/dist/packages/workflow-package/interf-workflow-package.d.ts +25 -0
  320. package/dist/packages/workflow-package/interf-workflow-package.js +342 -0
  321. package/dist/{lib/config.d.ts → packages/workflow-package/lib/package-root.d.ts} +0 -1
  322. package/dist/packages/workflow-package/lib/package-root.js +6 -0
  323. package/dist/packages/workflow-package/local-workflows.d.ts +54 -0
  324. package/dist/packages/workflow-package/local-workflows.js +422 -0
  325. package/dist/packages/workflow-package/workflow-definitions.d.ts +78 -0
  326. package/dist/packages/workflow-package/workflow-definitions.js +203 -0
  327. package/dist/packages/workflow-package/workflow-helpers.d.ts +38 -0
  328. package/dist/packages/workflow-package/workflow-helpers.js +167 -0
  329. package/dist/packages/workflow-package/workflow-review-paths.d.ts +10 -0
  330. package/dist/packages/workflow-package/workflow-review-paths.js +27 -0
  331. package/dist/packages/workflow-package/workflow-stage-policy.d.ts +5 -0
  332. package/dist/packages/workflow-package/workflow-stage-policy.js +31 -0
  333. package/dist/packages/workflow-package/workflow-stage-runner.d.ts +41 -0
  334. package/dist/packages/workflow-package/workflow-stage-runner.js +109 -0
  335. package/package.json +44 -21
  336. package/dist/commands/compile.d.ts +0 -15
  337. package/dist/commands/create-workflow-wizard.js +0 -125
  338. package/dist/commands/create.js +0 -162
  339. package/dist/commands/init.d.ts +0 -3
  340. package/dist/commands/test.d.ts +0 -9
  341. package/dist/lib/compiled-home.d.ts +0 -5
  342. package/dist/lib/compiled-home.js +0 -32
  343. package/dist/lib/config.js +0 -9
  344. package/dist/lib/obsidian.d.ts +0 -1
  345. package/dist/lib/obsidian.js +0 -15
  346. package/dist/lib/summarize-plan.d.ts +0 -17
  347. package/dist/lib/summarize-plan.js +0 -120
  348. /package/dist/{commands → cli/commands}/default.d.ts +0 -0
  349. /package/dist/{commands → cli/commands}/doctor.d.ts +0 -0
  350. /package/dist/{commands → cli/commands}/list.d.ts +0 -0
  351. /package/dist/{commands → cli/commands}/reset.d.ts +0 -0
  352. /package/dist/{commands → cli/commands}/status.d.ts +0 -0
  353. /package/dist/{commands → cli/commands}/verify.d.ts +0 -0
@@ -1,399 +1 @@
1
- import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from "node:fs";
2
- import { dirname, join, relative } from "node:path";
3
- import { z } from "zod";
4
- import { PACKAGE_ROOT } from "./config.js";
5
- import { isMarkdownFile } from "./util.js";
6
- import { listFilesRecursive } from "./filesystem.js";
7
- import { warnInterf } from "./logger.js";
8
- import { readJsonFileUnchecked, readJsonFileWithSchema } from "./parse.js";
9
- import { listBuiltinCompiledZoneSpecs, } from "./builtin-compiled-workflow.js";
10
- import { WorkflowCompilerApiSchema, RuntimeContractTypeSchema, RuntimeStageAcceptanceSchema, WorkflowStageZoneAccessSchema, WorkflowCompiledSchemaSchema, WorkflowIdPattern, } from "./schema.js";
11
- import { writeCompiledSchemaFile, compiledSchemaFilePath } from "./compiled-schema.js";
12
- const LocalWorkflowStageDefinitionSchema = z.object({
13
- id: z.string().regex(WorkflowIdPattern),
14
- label: z.string().min(1),
15
- contract_type: RuntimeContractTypeSchema,
16
- skill_dir: z.string().regex(WorkflowIdPattern).optional(),
17
- description: z.string().min(1).optional(),
18
- reads: WorkflowStageZoneAccessSchema,
19
- writes: WorkflowStageZoneAccessSchema,
20
- acceptance: RuntimeStageAcceptanceSchema.optional(),
21
- });
22
- const LocalWorkflowDefinitionSchema = z.object({
23
- id: z.string().regex(WorkflowIdPattern),
24
- type: z.literal("compiled"),
25
- compiler_api: WorkflowCompilerApiSchema.optional(),
26
- label: z.string().min(1),
27
- hint: z.string().min(1),
28
- extends: z.string().regex(WorkflowIdPattern).optional(),
29
- stages: z.array(LocalWorkflowStageDefinitionSchema).min(1).optional(),
30
- stage_policy_notes: z.record(z.string(), z.array(z.string())).optional(),
31
- });
32
- function workflowRootPath(sourcePath) {
33
- return join(sourcePath, "interf", "workflows");
34
- }
35
- function builtinWorkflowRootPath(workflowId) {
36
- return join(PACKAGE_ROOT, "builtin-workflows", workflowId);
37
- }
38
- export function workflowDefinitionPath(sourcePath, id) {
39
- return join(workflowRootPath(sourcePath), id);
40
- }
41
- function collectStarterDocs(dirPath) {
42
- return listFilesRecursive(dirPath, isMarkdownFile)
43
- .filter((filePath) => relative(dirPath, filePath).replaceAll("\\", "/") !== "workflow.json")
44
- .map((filePath) => ({
45
- relativePath: relative(dirPath, filePath).replaceAll("\\", "/"),
46
- content: readFileSync(filePath, "utf8"),
47
- }))
48
- .sort((a, b) => a.relativePath.localeCompare(b.relativePath));
49
- }
50
- export function loadWorkflowDefinitionFromDir(dirPath) {
51
- const workflowPath = existsSync(join(dirPath, "workflow.json"))
52
- ? join(dirPath, "workflow.json")
53
- : null;
54
- if (!workflowPath)
55
- return null;
56
- const definition = readJsonFileWithSchema(workflowPath, "local workflow definition", LocalWorkflowDefinitionSchema);
57
- if (!definition)
58
- return null;
59
- const schemaPath = compiledSchemaFilePath(dirPath);
60
- const compiledSchema = readJsonFileWithSchema(schemaPath, "compiled schema", WorkflowCompiledSchemaSchema);
61
- if (!compiledSchema)
62
- return null;
63
- if (definition.type !== "compiled") {
64
- warnInterf(`Warning: local workflow definition at ${workflowPath} has unexpected type "${definition.type}".`);
65
- return null;
66
- }
67
- return {
68
- ...definition,
69
- compiled_schema: compiledSchema,
70
- starter_docs: collectStarterDocs(dirPath),
71
- directoryPath: dirPath,
72
- workflowPath,
73
- compiledSchemaPath: schemaPath,
74
- };
75
- }
76
- export function listLocalWorkflowDefinitions(sourcePath) {
77
- const root = workflowRootPath(sourcePath);
78
- if (!existsSync(root))
79
- return [];
80
- return readdirSync(root)
81
- .map((entry) => join(root, entry))
82
- .filter((entryPath) => {
83
- try {
84
- return statSync(entryPath).isDirectory();
85
- }
86
- catch {
87
- return false;
88
- }
89
- })
90
- .map((entryPath) => loadWorkflowDefinitionFromDir(entryPath))
91
- .filter((definition) => definition !== null)
92
- .sort((a, b) => a.label.localeCompare(b.label));
93
- }
94
- export function loadLocalWorkflowDefinition(sourcePath, id) {
95
- return loadWorkflowDefinitionFromDir(workflowDefinitionPath(sourcePath, id));
96
- }
97
- export function resolveWorkflowPackageSourcePath(sourcePath, workflowId) {
98
- const builtinPath = builtinWorkflowRootPath(workflowId);
99
- if (workflowId === "interf" && existsSync(join(builtinPath, "workflow.json")))
100
- return builtinPath;
101
- const localPath = workflowDefinitionPath(sourcePath, workflowId);
102
- if (existsSync(join(localPath, "workflow.json")))
103
- return localPath;
104
- if (existsSync(join(builtinPath, "workflow.json")))
105
- return builtinPath;
106
- return null;
107
- }
108
- export function isWorkflowId(value) {
109
- return WorkflowIdPattern.test(value);
110
- }
111
- function normalizeStagePolicyNotes(value) {
112
- if (!value || typeof value !== "object" || Array.isArray(value))
113
- return undefined;
114
- const normalized = {};
115
- for (const [stageId, notes] of Object.entries(value)) {
116
- if (!Array.isArray(notes))
117
- continue;
118
- const cleaned = Array.from(new Set(notes
119
- .filter((note) => typeof note === "string")
120
- .map((note) => note.trim())
121
- .filter((note) => note.length > 0)));
122
- if (cleaned.length > 0) {
123
- normalized[stageId] = cleaned;
124
- }
125
- }
126
- return Object.keys(normalized).length > 0 ? normalized : undefined;
127
- }
128
- function mergeStagePolicyNotes(currentValue, nextValue) {
129
- const current = normalizeStagePolicyNotes(currentValue);
130
- if (!nextValue || Object.keys(nextValue).length === 0)
131
- return current;
132
- const merged = { ...(current ?? {}) };
133
- for (const [stageId, notes] of Object.entries(nextValue)) {
134
- merged[stageId] = Array.from(new Set([
135
- ...(merged[stageId] ?? []),
136
- ...notes.map((note) => note.trim()).filter((note) => note.length > 0),
137
- ]));
138
- }
139
- return Object.keys(merged).length > 0 ? merged : undefined;
140
- }
141
- function readWorkflowJsonObject(dirPath) {
142
- const workflowPath = join(dirPath, "workflow.json");
143
- const raw = readJsonFileUnchecked(workflowPath, "workflow package");
144
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
145
- throw new Error(`Workflow package at ${dirPath} is missing a valid workflow.json.`);
146
- }
147
- return { ...raw };
148
- }
149
- export function patchWorkflowPackageMetadata(dirPath, options = {}) {
150
- const workflowPath = join(dirPath, "workflow.json");
151
- const schemaPath = compiledSchemaFilePath(dirPath);
152
- const workflowJson = readWorkflowJsonObject(dirPath);
153
- const normalizedStages = Array.isArray(workflowJson.stages) && workflowJson.stages.length > 0
154
- ? workflowJson.stages
155
- : null;
156
- if (!normalizedStages) {
157
- throw new Error(`Cannot patch workflow package at ${dirPath}: workflow.json must declare explicit stages before it can be copied or rewritten.`);
158
- }
159
- const nextWorkflowJson = {
160
- ...workflowJson,
161
- type: "compiled",
162
- compiler_api: workflowJson.compiler_api ?? {
163
- kind: "compiled",
164
- version: 1,
165
- },
166
- stages: normalizedStages,
167
- ...(options.id ? { id: options.id } : {}),
168
- ...(options.label ? { label: options.label } : {}),
169
- ...(options.hint ? { hint: options.hint } : {}),
170
- };
171
- delete nextWorkflowJson.extends;
172
- const mergedStagePolicyNotes = mergeStagePolicyNotes(workflowJson.stage_policy_notes, options.stagePolicyNotes);
173
- if (mergedStagePolicyNotes) {
174
- nextWorkflowJson.stage_policy_notes = mergedStagePolicyNotes;
175
- }
176
- else {
177
- delete nextWorkflowJson.stage_policy_notes;
178
- }
179
- writeFileSync(workflowPath, JSON.stringify(nextWorkflowJson, null, 2) + "\n");
180
- const schemaLabel = `${String(nextWorkflowJson.label ?? workflowJson.label ?? options.id ?? "Workflow")} compiled schema`;
181
- if (!existsSync(schemaPath)) {
182
- writeCompiledSchemaFile(dirPath, normalizedStages, schemaLabel);
183
- return;
184
- }
185
- const rawSchema = readJsonFileUnchecked(schemaPath, "compiled schema");
186
- if (!rawSchema || typeof rawSchema !== "object" || Array.isArray(rawSchema))
187
- return;
188
- writeFileSync(schemaPath, JSON.stringify({
189
- ...rawSchema,
190
- label: schemaLabel,
191
- }, null, 2) + "\n");
192
- }
193
- export function describeWorkflowPackagePortability(dirPath) {
194
- const issues = [];
195
- const workflowPath = join(dirPath, "workflow.json");
196
- const schemaPath = compiledSchemaFilePath(dirPath);
197
- if (!existsSync(workflowPath))
198
- issues.push("missing workflow.json");
199
- if (!existsSync(schemaPath))
200
- issues.push("missing compiled.schema.json");
201
- if (!existsSync(join(dirPath, "README.md")))
202
- issues.push("missing README.md");
203
- if (!existsSync(join(dirPath, "improve", "SKILL.md")))
204
- issues.push("missing improve/SKILL.md");
205
- if (!existsSync(join(dirPath, "use", "query", "SKILL.md")))
206
- issues.push("missing use/query/SKILL.md");
207
- if (issues.length > 0)
208
- return issues;
209
- let workflowJson;
210
- try {
211
- workflowJson = readWorkflowJsonObject(dirPath);
212
- }
213
- catch (error) {
214
- issues.push(error instanceof Error ? error.message : String(error));
215
- return issues;
216
- }
217
- const parsed = LocalWorkflowDefinitionSchema.safeParse(workflowJson);
218
- if (!parsed.success) {
219
- issues.push(...parsed.error.issues.map((issue) => issue.path.length > 0
220
- ? `workflow.json ${issue.path.join(".")}: ${issue.message}`
221
- : `workflow.json: ${issue.message}`));
222
- return issues;
223
- }
224
- if (typeof parsed.data.extends === "string" && parsed.data.extends.trim().length > 0) {
225
- issues.push("workflow.json uses legacy extends; portable workflow packages must be materialized standalone");
226
- }
227
- if (!parsed.data.stages || parsed.data.stages.length === 0) {
228
- issues.push("workflow.json must declare explicit stages for a portable workflow package");
229
- return issues;
230
- }
231
- for (const stage of parsed.data.stages) {
232
- const skillDir = typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
233
- ? stage.skill_dir
234
- : stage.id;
235
- if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
236
- issues.push(`missing compile/stages/${skillDir}/SKILL.md`);
237
- }
238
- }
239
- return issues;
240
- }
241
- export function isPortableWorkflowPackage(dirPath) {
242
- return describeWorkflowPackagePortability(dirPath).length === 0;
243
- }
244
- export function copyWorkflowPackageDirectory(sourceWorkflowPath, targetWorkflowPath) {
245
- const portabilityIssues = describeWorkflowPackagePortability(sourceWorkflowPath);
246
- if (portabilityIssues.length > 0) {
247
- throw new Error(`Workflow package at ${sourceWorkflowPath} is not directly copyable: ${portabilityIssues.join("; ")}.`);
248
- }
249
- rmSync(targetWorkflowPath, { recursive: true, force: true });
250
- mkdirSync(dirname(targetWorkflowPath), { recursive: true });
251
- cpSync(sourceWorkflowPath, targetWorkflowPath, { recursive: true });
252
- }
253
- export function validateWorkflowPackage(dirPath) {
254
- const workflowPath = join(dirPath, "workflow.json");
255
- const schemaPath = compiledSchemaFilePath(dirPath);
256
- if (!existsSync(workflowPath)) {
257
- return {
258
- ok: false,
259
- summary: `No workflow.json found at ${dirPath}`,
260
- errors: ["Missing workflow.json"],
261
- counts: {},
262
- };
263
- }
264
- const raw = readJsonFileUnchecked(workflowPath, "workflow package");
265
- if (!raw) {
266
- return {
267
- ok: false,
268
- summary: `Failed to parse workflow.json at ${workflowPath}`,
269
- errors: ["Invalid JSON in workflow.json"],
270
- counts: {},
271
- };
272
- }
273
- const parsed = LocalWorkflowDefinitionSchema.safeParse(raw);
274
- if (!parsed.success) {
275
- const issues = parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`);
276
- return {
277
- ok: false,
278
- summary: `workflow.json failed validation: ${issues.length} issue(s)`,
279
- errors: issues,
280
- counts: {},
281
- };
282
- }
283
- const def = parsed.data;
284
- const errors = [];
285
- if (typeof def.extends === "string" && def.extends.trim().length > 0) {
286
- errors.push("workflow.json uses legacy extends. Portable workflow packages must be materialized as standalone packages.");
287
- }
288
- if (!def.stages || def.stages.length === 0) {
289
- errors.push("workflow.json must declare explicit stages. Legacy inherited packages are not portable.");
290
- }
291
- if (!existsSync(schemaPath)) {
292
- errors.push("Missing compiled.schema.json.");
293
- }
294
- if (!existsSync(join(dirPath, "README.md"))) {
295
- errors.push("Missing README.md.");
296
- }
297
- if (!existsSync(join(dirPath, "improve", "SKILL.md"))) {
298
- errors.push("Missing improve/SKILL.md.");
299
- }
300
- if (!existsSync(join(dirPath, "use", "query", "SKILL.md"))) {
301
- errors.push("Missing use/query/SKILL.md.");
302
- }
303
- const compiledSchema = readJsonFileWithSchema(schemaPath, "compiled schema", WorkflowCompiledSchemaSchema);
304
- if (!compiledSchema) {
305
- errors.push("compiled.schema.json is missing or invalid.");
306
- }
307
- if (def.stages && def.stages.length > 0) {
308
- for (const stage of def.stages) {
309
- const skillDir = typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
310
- ? stage.skill_dir
311
- : stage.id;
312
- if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
313
- errors.push(`Missing compile/stages/${skillDir}/SKILL.md.`);
314
- }
315
- }
316
- }
317
- if (compiledSchema) {
318
- const stages = def.stages ?? [];
319
- const stageIds = new Set(stages.map((stage) => stage.id));
320
- const seenPaths = new Map();
321
- const seenZoneIds = new Set();
322
- const zoneById = new Map(compiledSchema.zones.map((zone) => [zone.id, zone]));
323
- const normalizedParts = (value) => value.replaceAll("\\", "/").split("/").filter(Boolean);
324
- const hasOverlappingPath = (value, other) => {
325
- const a = normalizedParts(value);
326
- const b = normalizedParts(other);
327
- const shorter = a.length <= b.length ? a : b;
328
- const longer = a.length <= b.length ? b : a;
329
- return shorter.every((part, index) => longer[index] === part);
330
- };
331
- for (const zone of compiledSchema.zones) {
332
- if (seenZoneIds.has(zone.id)) {
333
- errors.push(`compiled.schema.json repeats zone id "${zone.id}".`);
334
- }
335
- seenZoneIds.add(zone.id);
336
- const existingPathOwner = seenPaths.get(zone.path);
337
- if (existingPathOwner) {
338
- errors.push(`compiled.schema.json repeats zone path "${zone.path}".`);
339
- }
340
- for (const [existingPath, existingZoneId] of seenPaths.entries()) {
341
- if (existingPath === zone.path)
342
- continue;
343
- if (hasOverlappingPath(zone.path, existingPath)) {
344
- errors.push(`compiled.schema.json zones "${zone.id}" and "${existingZoneId}" overlap on path "${zone.path}" / "${existingPath}".`);
345
- }
346
- }
347
- seenPaths.set(zone.path, zone.id);
348
- for (const owner of zone.owned_by) {
349
- if (!stageIds.has(owner)) {
350
- errors.push(`compiled.schema.json references unknown stage "${owner}" for zone "${zone.path}".`);
351
- }
352
- }
353
- }
354
- for (const stage of stages) {
355
- for (const zoneId of stage.reads) {
356
- if (!zoneById.has(zoneId)) {
357
- errors.push(`Stage "${stage.id}" reads unknown zone "${zoneId}".`);
358
- }
359
- }
360
- for (const zoneId of stage.writes) {
361
- const zone = zoneById.get(zoneId);
362
- if (!zone) {
363
- errors.push(`Stage "${stage.id}" writes unknown zone "${zoneId}".`);
364
- continue;
365
- }
366
- if (!zone.owned_by.includes(stage.id)) {
367
- errors.push(`Stage "${stage.id}" writes zone "${zoneId}" but that zone is not owned by the stage in compiled.schema.json.`);
368
- }
369
- }
370
- }
371
- for (const requiredZone of listBuiltinCompiledZoneSpecs().filter((zone) => zone.id === "raw" || zone.id === "runtime")) {
372
- const match = zoneById.get(requiredZone.id);
373
- if (!match) {
374
- errors.push(`compiled.schema.json is missing required zone "${requiredZone.id}".`);
375
- continue;
376
- }
377
- if (match.kind !== requiredZone.kind) {
378
- errors.push(`compiled.schema.json zone "${requiredZone.id}" should be kind "${requiredZone.kind}".`);
379
- }
380
- }
381
- }
382
- const stageDirs = existsSync(join(dirPath, "compile", "stages"))
383
- ? listFilesRecursive(join(dirPath, "compile", "stages"), (filePath) => basename(filePath) === "SKILL.md")
384
- : [];
385
- const counts = {
386
- starter_docs: collectStarterDocs(dirPath).length,
387
- compile_stage_docs: stageDirs.length,
388
- compiled_zones: compiledSchema?.zones.length ?? 0,
389
- };
390
- return {
391
- ok: errors.length === 0,
392
- summary: errors.length === 0 ? "Workflow package is valid." : `Workflow package has ${errors.length} issue(s).`,
393
- errors,
394
- counts,
395
- };
396
- }
397
- function basename(filePath) {
398
- return filePath.split(/[\\/]/).pop() ?? filePath;
399
- }
1
+ export * from "../packages/workflow-package/local-workflows.js";
@@ -0,0 +1 @@
1
+ export * from "../packages/workflow-package/lib/package-root.js";
@@ -0,0 +1 @@
1
+ export * from "../packages/workflow-package/lib/package-root.js";
@@ -1,11 +1 @@
1
- export declare const PROJECT_INTERF_DIR = "interf";
2
- export declare const PROJECT_TESTS_DIR = "tests";
3
- export declare function projectInterfRoot(projectPath: string): string;
4
- export declare function compiledCompiledPathForDataset(projectPath: string, datasetName: string): string;
5
- export declare function datasetTestsRoot(projectPath: string, datasetName: string): string;
6
- export type DatasetTestTargetLabel = "file-as-is" | "compiled";
7
- export declare function datasetTestRunsRoot(projectPath: string, datasetName: string, target: DatasetTestTargetLabel): string;
8
- export declare function datasetLatestTestStatePath(projectPath: string, datasetName: string): string;
9
- export declare function datasetLatestTestSummaryPath(projectPath: string, datasetName: string): string;
10
- export declare function normalizeDatasetTestRunId(input: string): string;
11
- export declare function datasetTestRunPath(projectPath: string, datasetName: string, target: DatasetTestTargetLabel, generatedAt: string, runId: string, runSuffix?: string | null): string;
1
+ export * from "../packages/project-model/project-paths.js";
@@ -1,32 +1,3 @@
1
- import { join } from "node:path";
2
- export const PROJECT_INTERF_DIR = "interf";
3
- export const PROJECT_TESTS_DIR = "tests";
4
- export function projectInterfRoot(projectPath) {
5
- return join(projectPath, PROJECT_INTERF_DIR);
6
- }
7
- export function compiledCompiledPathForDataset(projectPath, datasetName) {
8
- return join(projectInterfRoot(projectPath), datasetName);
9
- }
10
- export function datasetTestsRoot(projectPath, datasetName) {
11
- return join(projectInterfRoot(projectPath), PROJECT_TESTS_DIR, datasetName);
12
- }
13
- export function datasetTestRunsRoot(projectPath, datasetName, target) {
14
- return join(datasetTestsRoot(projectPath, datasetName), target, "runs");
15
- }
16
- export function datasetLatestTestStatePath(projectPath, datasetName) {
17
- return join(datasetTestsRoot(projectPath, datasetName), "latest.json");
18
- }
19
- export function datasetLatestTestSummaryPath(projectPath, datasetName) {
20
- return join(datasetTestsRoot(projectPath, datasetName), "latest.md");
21
- }
22
- export function normalizeDatasetTestRunId(input) {
23
- return input
24
- .toLowerCase()
25
- .trim()
26
- .replace(/[^a-z0-9]+/g, "-")
27
- .replace(/^-+|-+$/g, "")
28
- .slice(0, 80);
29
- }
30
- export function datasetTestRunPath(projectPath, datasetName, target, generatedAt, runId, runSuffix) {
31
- return join(datasetTestRunsRoot(projectPath, datasetName, target), `${generatedAt.replace(/[:.]/g, "-")}-${runId}${runSuffix ? `-${normalizeDatasetTestRunId(runSuffix)}` : ""}.json`);
32
- }
1
+ // Compatibility shim for historical `src/lib/project-paths.ts` imports.
2
+ // Source of truth: `src/packages/project-model/project-paths.ts`.
3
+ export * from "../packages/project-model/project-paths.js";
@@ -1,9 +1 @@
1
- import { type CompiledState, type RuntimeStageAcceptance, type RuntimeStageContract } from "./schema.js";
2
- import { type RuntimeStageAcceptanceValidation } from "./runtime-types.js";
3
- export declare function stageRecordFromState(state: CompiledState | null, stageId: string): Record<string, unknown> | null;
4
- export declare function validateResolvedStageAcceptance(dirPath: string, options: {
5
- stageId: string;
6
- acceptance?: RuntimeStageAcceptance;
7
- counts?: Record<string, number>;
8
- }): RuntimeStageAcceptanceValidation;
9
- export declare function validateStageContractAcceptance(dirPath: string, contract?: RuntimeStageContract | null): RuntimeStageAcceptanceValidation;
1
+ export * from "../packages/compiler/runtime-acceptance.js";