@interf/compiler 0.9.1 → 0.9.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 (250) hide show
  1. package/README.md +9 -9
  2. package/agent-skills/interf-actions/SKILL.md +3 -0
  3. package/agent-skills/interf-actions/references/cli.md +13 -13
  4. package/{builtin-workflows/interf → builtin-methods/interf-default}/README.md +2 -2
  5. package/builtin-methods/interf-default/improve/SKILL.md +18 -0
  6. package/{builtin-workflows/interf/workflow.json → builtin-methods/interf-default/method.json} +4 -4
  7. package/{builtin-workflows/interf/workflow.schema.json → builtin-methods/interf-default/method.schema.json} +2 -2
  8. package/dist/cli/commands/check-draft.d.ts +6 -6
  9. package/dist/cli/commands/check-draft.js +5 -5
  10. package/dist/cli/commands/compile-controller.d.ts +7 -7
  11. package/dist/cli/commands/compile-controller.js +35 -38
  12. package/dist/cli/commands/compile.d.ts +3 -3
  13. package/dist/cli/commands/compile.js +23 -21
  14. package/dist/cli/commands/compiled-flow.d.ts +11 -11
  15. package/dist/cli/commands/compiled-flow.js +33 -30
  16. package/dist/cli/commands/create-method-wizard.d.ts +76 -0
  17. package/dist/cli/commands/{create-workflow-wizard.js → create-method-wizard.js} +153 -163
  18. package/dist/cli/commands/create.d.ts +3 -3
  19. package/dist/cli/commands/create.js +44 -45
  20. package/dist/cli/commands/default.js +1 -1
  21. package/dist/cli/commands/executor-flow.d.ts +6 -6
  22. package/dist/cli/commands/executor-flow.js +1 -1
  23. package/dist/cli/commands/init.d.ts +2 -2
  24. package/dist/cli/commands/init.js +139 -118
  25. package/dist/cli/commands/list.js +11 -10
  26. package/dist/cli/commands/preparation-selection.d.ts +3 -3
  27. package/dist/cli/commands/source-config-wizard.d.ts +9 -9
  28. package/dist/cli/commands/source-config-wizard.js +43 -43
  29. package/dist/cli/commands/status.js +36 -9
  30. package/dist/cli/commands/test-flow.d.ts +15 -15
  31. package/dist/cli/commands/test-flow.js +29 -219
  32. package/dist/cli/commands/test.d.ts +2 -2
  33. package/dist/cli/commands/test.js +50 -51
  34. package/dist/cli/commands/verify.js +7 -7
  35. package/dist/cli/commands/web.js +41 -28
  36. package/dist/compiler-ui/404.html +1 -0
  37. package/dist/compiler-ui/__next.__PAGE__.txt +10 -0
  38. package/dist/compiler-ui/__next._full.txt +20 -0
  39. package/dist/compiler-ui/__next._head.txt +5 -0
  40. package/dist/compiler-ui/__next._index.txt +5 -0
  41. package/dist/compiler-ui/__next._tree.txt +5 -0
  42. package/dist/compiler-ui/_next/static/chunks/06yhdspx~ca5-.js +5 -0
  43. package/{apps/compiler-ui/.next/static/chunks/13g~4mamjft.c.css → dist/compiler-ui/_next/static/chunks/0c9mu7yldxyyg.css} +1 -1
  44. package/{apps/compiler-ui/.next/static/chunks/0fgt_8knmicoz.js → dist/compiler-ui/_next/static/chunks/15mks7ry_cupt.js} +15 -21
  45. package/{apps/compiler-ui/.next/static/chunks/turbopack-109rtik40vwh5.js → dist/compiler-ui/_next/static/chunks/turbopack-0.uq1k8c0j4s..js} +1 -1
  46. package/dist/compiler-ui/_not-found/__next._full.txt +15 -0
  47. package/dist/compiler-ui/_not-found/__next._head.txt +5 -0
  48. package/dist/compiler-ui/_not-found/__next._index.txt +5 -0
  49. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +5 -0
  50. package/dist/compiler-ui/_not-found/__next._not-found.txt +5 -0
  51. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -0
  52. package/dist/compiler-ui/_not-found.html +1 -0
  53. package/dist/compiler-ui/_not-found.txt +15 -0
  54. package/{apps/compiler-ui/.next/server/app → dist/compiler-ui}/index.html +1 -1
  55. package/dist/compiler-ui/index.txt +20 -0
  56. package/dist/index.d.ts +8 -6
  57. package/dist/index.js +5 -3
  58. package/dist/packages/agents/index.d.ts +1 -1
  59. package/dist/packages/agents/lib/args.d.ts +2 -2
  60. package/dist/packages/agents/lib/compiled-bootstrap.js +7 -6
  61. package/dist/packages/agents/lib/execution-profile.d.ts +5 -5
  62. package/dist/packages/agents/lib/execution-profile.js +7 -6
  63. package/dist/packages/agents/lib/executors.d.ts +13 -13
  64. package/dist/packages/agents/lib/preflight.d.ts +1 -0
  65. package/dist/packages/agents/lib/preflight.js +32 -9
  66. package/dist/packages/agents/lib/shells.d.ts +25 -24
  67. package/dist/packages/agents/lib/shells.js +161 -154
  68. package/dist/packages/agents/lib/types.d.ts +2 -2
  69. package/dist/packages/compiler/artifact-counts.d.ts +1 -0
  70. package/dist/packages/compiler/artifact-counts.js +30 -0
  71. package/dist/packages/compiler/compiled-paths.d.ts +4 -7
  72. package/dist/packages/compiler/compiled-paths.js +9 -15
  73. package/dist/packages/compiler/compiled-pipeline.d.ts +11 -12
  74. package/dist/packages/compiler/compiled-pipeline.js +22 -22
  75. package/dist/packages/compiler/compiled-schema.d.ts +20 -20
  76. package/dist/packages/compiler/compiled-schema.js +29 -29
  77. package/dist/packages/compiler/compiled-stage-plan.d.ts +4 -4
  78. package/dist/packages/compiler/compiled-stage-plan.js +8 -8
  79. package/dist/packages/compiler/compiled-stage-runner.d.ts +5 -5
  80. package/dist/packages/compiler/compiled-stage-runner.js +7 -7
  81. package/dist/packages/compiler/compiled-target.d.ts +5 -5
  82. package/dist/packages/compiler/compiled-target.js +5 -5
  83. package/dist/packages/compiler/index.d.ts +3 -3
  84. package/dist/packages/compiler/index.js +2 -2
  85. package/dist/packages/compiler/lib/schema.d.ts +62 -247
  86. package/dist/packages/compiler/lib/schema.js +56 -174
  87. package/dist/packages/compiler/{workflows.d.ts → method-runs.d.ts} +4 -4
  88. package/dist/packages/compiler/{workflows.js → method-runs.js} +4 -3
  89. package/dist/packages/compiler/raw-snapshot.d.ts +0 -7
  90. package/dist/packages/compiler/raw-snapshot.js +0 -1
  91. package/dist/packages/compiler/reset.js +3 -3
  92. package/dist/packages/compiler/runtime-acceptance.js +9 -16
  93. package/dist/packages/compiler/runtime-contracts.js +9 -9
  94. package/dist/packages/compiler/runtime-prompt.js +4 -4
  95. package/dist/packages/compiler/runtime-reconcile.d.ts +2 -2
  96. package/dist/packages/compiler/runtime-reconcile.js +3 -3
  97. package/dist/packages/compiler/runtime-runs.js +9 -9
  98. package/dist/packages/compiler/runtime-types.d.ts +8 -7
  99. package/dist/packages/compiler/state-health.js +26 -35
  100. package/dist/packages/compiler/state-view.js +6 -6
  101. package/dist/packages/compiler/validate-compiled.d.ts +5 -5
  102. package/dist/packages/compiler/validate-compiled.js +56 -64
  103. package/dist/packages/compiler/validate.d.ts +2 -2
  104. package/dist/packages/compiler/validate.js +22 -14
  105. package/dist/packages/contracts/index.d.ts +2 -0
  106. package/dist/packages/contracts/index.js +1 -0
  107. package/dist/packages/contracts/lib/schema.d.ts +205 -0
  108. package/dist/packages/contracts/lib/schema.js +101 -0
  109. package/dist/packages/execution/index.d.ts +2 -2
  110. package/dist/packages/execution/index.js +1 -1
  111. package/dist/packages/execution/lib/schema.d.ts +80 -83
  112. package/dist/packages/execution/lib/schema.js +25 -48
  113. package/dist/packages/local-service/action-values.d.ts +0 -1
  114. package/dist/packages/local-service/action-values.js +0 -1
  115. package/dist/packages/local-service/client.d.ts +4 -4
  116. package/dist/packages/local-service/client.js +4 -4
  117. package/dist/packages/local-service/index.d.ts +3 -3
  118. package/dist/packages/local-service/index.js +2 -2
  119. package/dist/packages/local-service/lib/schema.d.ts +536 -974
  120. package/dist/packages/local-service/lib/schema.js +43 -160
  121. package/dist/packages/local-service/run-observability.d.ts +6 -0
  122. package/dist/packages/local-service/run-observability.js +592 -0
  123. package/dist/packages/local-service/runtime.d.ts +19 -23
  124. package/dist/packages/local-service/runtime.js +302 -880
  125. package/dist/packages/local-service/server.d.ts +1 -0
  126. package/dist/packages/local-service/server.js +25 -20
  127. package/dist/packages/method-authoring/index.d.ts +4 -0
  128. package/dist/packages/method-authoring/index.js +4 -0
  129. package/dist/packages/{workflow-authoring/lib/workflow-edit-utils.d.ts → method-authoring/lib/method-edit-utils.d.ts} +3 -3
  130. package/dist/packages/method-authoring/method-authoring.d.ts +24 -0
  131. package/dist/packages/method-authoring/method-authoring.js +116 -0
  132. package/dist/packages/method-authoring/method-edit-session.d.ts +18 -0
  133. package/dist/packages/method-authoring/method-edit-session.js +125 -0
  134. package/dist/packages/method-authoring/method-improvement.d.ts +23 -0
  135. package/dist/packages/{workflow-authoring/workflow-improvement.js → method-authoring/method-improvement.js} +63 -63
  136. package/dist/packages/{workflow-package/builtin-compiled-workflow.d.ts → method-package/builtin-compiled-method.d.ts} +1 -1
  137. package/dist/packages/{workflow-package/builtin-compiled-workflow.js → method-package/builtin-compiled-method.js} +17 -17
  138. package/dist/packages/{workflow-package → method-package}/context-interface.d.ts +12 -12
  139. package/dist/packages/{workflow-package → method-package}/context-interface.js +19 -19
  140. package/dist/packages/method-package/index.d.ts +11 -0
  141. package/dist/packages/method-package/index.js +11 -0
  142. package/dist/packages/method-package/interf-method-package.d.ts +31 -0
  143. package/dist/packages/{workflow-package/interf-workflow-package.js → method-package/interf-method-package.js} +145 -145
  144. package/dist/packages/{workflow-package → method-package}/lib/package-root.js +1 -1
  145. package/dist/packages/method-package/local-methods.d.ts +64 -0
  146. package/dist/packages/method-package/local-methods.js +466 -0
  147. package/dist/packages/method-package/method-definitions.d.ts +83 -0
  148. package/dist/packages/method-package/method-definitions.js +205 -0
  149. package/dist/packages/{workflow-package/workflow-helpers.d.ts → method-package/method-helpers.d.ts} +10 -10
  150. package/dist/packages/{workflow-package/workflow-helpers.js → method-package/method-helpers.js} +22 -26
  151. package/dist/packages/method-package/method-review-paths.d.ts +10 -0
  152. package/dist/packages/{workflow-package/workflow-review-paths.js → method-package/method-review-paths.js} +4 -4
  153. package/dist/packages/{workflow-package/workflow-stage-runner.d.ts → method-package/method-stage-runner.d.ts} +12 -11
  154. package/dist/packages/{workflow-package/workflow-stage-runner.js → method-package/method-stage-runner.js} +6 -6
  155. package/dist/packages/methods/index.d.ts +2 -0
  156. package/dist/packages/methods/index.js +2 -0
  157. package/dist/packages/methods/method-resolution.d.ts +6 -0
  158. package/dist/packages/methods/method-resolution.js +7 -0
  159. package/dist/packages/project-model/index.d.ts +1 -4
  160. package/dist/packages/project-model/index.js +0 -3
  161. package/dist/packages/project-model/interf-detect.d.ts +1 -5
  162. package/dist/packages/project-model/interf-detect.js +7 -18
  163. package/dist/packages/project-model/interf-scaffold.d.ts +2 -2
  164. package/dist/packages/project-model/interf-scaffold.js +38 -39
  165. package/dist/packages/project-model/interf.d.ts +1 -2
  166. package/dist/packages/project-model/interf.js +1 -2
  167. package/dist/packages/project-model/lib/schema.d.ts +2 -66
  168. package/dist/packages/project-model/lib/schema.js +5 -23
  169. package/dist/packages/project-model/project-paths.d.ts +9 -10
  170. package/dist/packages/project-model/project-paths.js +14 -17
  171. package/dist/packages/project-model/source-config.d.ts +11 -18
  172. package/dist/packages/project-model/source-config.js +42 -60
  173. package/dist/packages/project-model/source-folders.d.ts +4 -4
  174. package/dist/packages/project-model/source-folders.js +10 -10
  175. package/dist/packages/testing/index.d.ts +2 -2
  176. package/dist/packages/testing/index.js +1 -1
  177. package/dist/packages/testing/lib/schema.d.ts +11 -11
  178. package/dist/packages/testing/lib/schema.js +8 -9
  179. package/dist/packages/testing/readiness-check-run.d.ts +67 -0
  180. package/dist/packages/testing/readiness-check-run.js +258 -0
  181. package/dist/packages/testing/test-execution.d.ts +3 -3
  182. package/dist/packages/testing/test-execution.js +5 -5
  183. package/dist/packages/testing/test-paths.js +6 -6
  184. package/dist/packages/testing/test-profile-presets.js +2 -2
  185. package/dist/packages/testing/test-sandbox.js +10 -11
  186. package/dist/packages/testing/test-targets.d.ts +1 -1
  187. package/dist/packages/testing/test-targets.js +8 -7
  188. package/dist/packages/testing/test-types.d.ts +1 -1
  189. package/package.json +16 -33
  190. package/apps/compiler-ui/.next/static/chunks/0ti_66mx7~w2-.js +0 -5
  191. package/builtin-workflows/interf/improve/SKILL.md +0 -18
  192. package/dist/cli/commands/create-workflow-wizard.d.ts +0 -76
  193. package/dist/packages/project-model/compiled-paths.d.ts +0 -1
  194. package/dist/packages/project-model/compiled-paths.js +0 -1
  195. package/dist/packages/project-model/compiled-raw.d.ts +0 -1
  196. package/dist/packages/project-model/compiled-raw.js +0 -1
  197. package/dist/packages/project-model/compiled-reset.d.ts +0 -1
  198. package/dist/packages/project-model/compiled-reset.js +0 -1
  199. package/dist/packages/shared/index.d.ts +0 -7
  200. package/dist/packages/shared/index.js +0 -7
  201. package/dist/packages/shared/util.d.ts +0 -3
  202. package/dist/packages/shared/util.js +0 -3
  203. package/dist/packages/testing/test-matrices.d.ts +0 -90
  204. package/dist/packages/testing/test-matrices.js +0 -96
  205. package/dist/packages/workflow-authoring/index.d.ts +0 -4
  206. package/dist/packages/workflow-authoring/index.js +0 -4
  207. package/dist/packages/workflow-authoring/workflow-authoring.d.ts +0 -24
  208. package/dist/packages/workflow-authoring/workflow-authoring.js +0 -82
  209. package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +0 -18
  210. package/dist/packages/workflow-authoring/workflow-edit-session.js +0 -91
  211. package/dist/packages/workflow-authoring/workflow-improvement.d.ts +0 -23
  212. package/dist/packages/workflow-package/index.d.ts +0 -11
  213. package/dist/packages/workflow-package/index.js +0 -11
  214. package/dist/packages/workflow-package/interf-workflow-package.d.ts +0 -31
  215. package/dist/packages/workflow-package/local-workflows.d.ts +0 -64
  216. package/dist/packages/workflow-package/local-workflows.js +0 -457
  217. package/dist/packages/workflow-package/workflow-definitions.d.ts +0 -82
  218. package/dist/packages/workflow-package/workflow-definitions.js +0 -211
  219. package/dist/packages/workflow-package/workflow-review-paths.d.ts +0 -10
  220. /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/shape/SKILL.md +0 -0
  221. /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/structure/SKILL.md +0 -0
  222. /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/summarize/SKILL.md +0 -0
  223. /package/{builtin-workflows/interf → builtin-methods/interf-default}/use/query/SKILL.md +0 -0
  224. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/03~yq9q893hmn.js +0 -0
  225. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/06z~l3kwb891e.js +0 -0
  226. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/08g7lvje.te.u.js +0 -0
  227. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/08m7vf5asqlsm.js +0 -0
  228. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0_i-3_5l9t2qe.js +0 -0
  229. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0b-ywny_j0g~0.js +0 -0
  230. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0b52v41o1gixx.js +0 -0
  231. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0gpzgsv0w.q~m.js +0 -0
  232. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0ilwfezfvu6~-.js +0 -0
  233. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0n51hrfoufc7g.js +0 -0
  234. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0xxmf45eskdt~.css +0 -0
  235. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0y5z3t-z1c8ks.js.map +0 -0
  236. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/14wtz~vq25~qq.js +0 -0
  237. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/turbopack-10e~t1yzi4svj.js +0 -0
  238. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +0 -0
  239. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
  240. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
  241. /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/worker.102zas1s52_pf.js +0 -0
  242. /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_buildManifest.js +0 -0
  243. /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_clientMiddlewareManifest.js +0 -0
  244. /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_ssgManifest.js +0 -0
  245. /package/dist/packages/compiler/{workflow-primitives.d.ts → method-primitives.d.ts} +0 -0
  246. /package/dist/packages/compiler/{workflow-primitives.js → method-primitives.js} +0 -0
  247. /package/dist/packages/{workflow-authoring/lib/workflow-edit-utils.js → method-authoring/lib/method-edit-utils.js} +0 -0
  248. /package/dist/packages/{workflow-package → method-package}/lib/package-root.d.ts +0 -0
  249. /package/dist/packages/{workflow-package/workflow-stage-policy.d.ts → method-package/method-stage-policy.d.ts} +0 -0
  250. /package/dist/packages/{workflow-package/workflow-stage-policy.js → method-package/method-stage-policy.js} +0 -0
@@ -1,457 +0,0 @@
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 { listFilesRecursive } from "../shared/filesystem.js";
5
- import { warnInterf } from "../shared/logger.js";
6
- import { readJsonFileUnchecked, readJsonFileWithSchema } from "../shared/parse.js";
7
- import { isMarkdownFile } from "../shared/file-types.js";
8
- import { WorkflowCompilerApiSchema, RuntimeContractTypeSchema, RuntimeStageAcceptanceSchema, WorkflowPurposeSchema, WorkflowStageZoneAccessSchema, WorkflowIdPattern, } from "../compiler/lib/schema.js";
9
- import { listBuiltinCompiledZoneSpecs, } from "./builtin-compiled-workflow.js";
10
- import { CONTEXT_INTERFACE_FILE, contextInterfaceExists, contextInterfaceFilePath, readContextInterface, WorkflowInputSpecSchema, writeContextInterface, } from "./context-interface.js";
11
- import { PACKAGE_ROOT } from "./lib/package-root.js";
12
- import { mergeStagePolicyNotesForStages } from "./workflow-stage-policy.js";
13
- const LocalWorkflowStageDefinitionSchema = z.object({
14
- id: z.string().regex(WorkflowIdPattern),
15
- label: z.string().min(1),
16
- contract_type: RuntimeContractTypeSchema,
17
- skill_dir: z.string().regex(WorkflowIdPattern).optional(),
18
- description: z.string().min(1).optional(),
19
- reads: WorkflowStageZoneAccessSchema,
20
- writes: WorkflowStageZoneAccessSchema,
21
- acceptance: RuntimeStageAcceptanceSchema.optional(),
22
- });
23
- const LocalWorkflowDefinitionSchema = z.object({
24
- id: z.string().regex(WorkflowIdPattern),
25
- type: z.literal("compiled"),
26
- compiler_api: WorkflowCompilerApiSchema.optional(),
27
- purpose: WorkflowPurposeSchema.optional(),
28
- inputs: z.array(WorkflowInputSpecSchema).min(1).optional(),
29
- label: z.string().min(1),
30
- hint: z.string().min(1),
31
- extends: z.string().regex(WorkflowIdPattern).optional(),
32
- stages: z.array(LocalWorkflowStageDefinitionSchema).min(1).optional(),
33
- stage_policy_notes: z.record(z.string(), z.array(z.string())).optional(),
34
- });
35
- function workflowRootPath(sourcePath) {
36
- return join(sourcePath, "interf", "methods");
37
- }
38
- function legacyWorkflowRootPath(sourcePath) {
39
- return join(sourcePath, "interf", "workflows");
40
- }
41
- function builtinWorkflowRootPath(workflowId) {
42
- return join(PACKAGE_ROOT, "builtin-workflows", workflowId);
43
- }
44
- export function workflowDefinitionPath(sourcePath, id) {
45
- return join(workflowRootPath(sourcePath), id);
46
- }
47
- function legacyWorkflowDefinitionPath(sourcePath, id) {
48
- return join(legacyWorkflowRootPath(sourcePath), id);
49
- }
50
- function isSupportedWorkflowStarterDocPath(relativePath) {
51
- if (relativePath === "README.md")
52
- return true;
53
- if (relativePath.startsWith("improve/"))
54
- return true;
55
- if (relativePath.startsWith("use/query/"))
56
- return true;
57
- if (relativePath.startsWith("compile/stages/"))
58
- return true;
59
- return false;
60
- }
61
- function collectStarterDocs(dirPath) {
62
- return listFilesRecursive(dirPath, isMarkdownFile)
63
- .map((filePath) => relative(dirPath, filePath).replaceAll("\\", "/"))
64
- .filter((relativePath) => isSupportedWorkflowStarterDocPath(relativePath))
65
- .map((relativePath) => ({
66
- relativePath,
67
- content: readFileSync(join(dirPath, relativePath), "utf8"),
68
- }))
69
- .sort((a, b) => a.relativePath.localeCompare(b.relativePath));
70
- }
71
- function workflowPackageCopyPaths(dirPath) {
72
- return [
73
- "workflow.json",
74
- CONTEXT_INTERFACE_FILE,
75
- ...collectStarterDocs(dirPath).map((doc) => doc.relativePath),
76
- ];
77
- }
78
- function copyRelativeFile(sourceRoot, targetRoot, relativePath) {
79
- const sourcePath = join(sourceRoot, relativePath);
80
- if (!existsSync(sourcePath))
81
- return;
82
- const targetPath = join(targetRoot, relativePath);
83
- mkdirSync(dirname(targetPath), { recursive: true });
84
- cpSync(sourcePath, targetPath, { force: true });
85
- }
86
- function copyWorkflowPackageFiles(sourceWorkflowPath, targetWorkflowPath) {
87
- rmSync(targetWorkflowPath, { recursive: true, force: true });
88
- mkdirSync(targetWorkflowPath, { recursive: true });
89
- for (const relativePath of workflowPackageCopyPaths(sourceWorkflowPath)) {
90
- copyRelativeFile(sourceWorkflowPath, targetWorkflowPath, relativePath);
91
- }
92
- }
93
- export function loadWorkflowDefinitionFromDir(dirPath) {
94
- const workflowPath = existsSync(join(dirPath, "workflow.json"))
95
- ? join(dirPath, "workflow.json")
96
- : null;
97
- if (!workflowPath)
98
- return null;
99
- const definition = readJsonFileWithSchema(workflowPath, "local workflow definition", LocalWorkflowDefinitionSchema);
100
- if (!definition)
101
- return null;
102
- const workflowSchema = readContextInterface(dirPath);
103
- if (!workflowSchema)
104
- return null;
105
- if (definition.type !== "compiled") {
106
- warnInterf(`Warning: local workflow definition at ${workflowPath} has unexpected type "${definition.type}".`);
107
- return null;
108
- }
109
- return {
110
- ...definition,
111
- workflow_schema: workflowSchema,
112
- starter_docs: collectStarterDocs(dirPath),
113
- directoryPath: dirPath,
114
- workflowPath,
115
- workflowSchemaPath: contextInterfaceFilePath(dirPath),
116
- };
117
- }
118
- export function listLocalWorkflowDefinitions(sourcePath) {
119
- const definitions = new Map();
120
- for (const root of [legacyWorkflowRootPath(sourcePath), workflowRootPath(sourcePath)]) {
121
- if (!existsSync(root))
122
- continue;
123
- for (const entryPath of readdirSync(root).map((entry) => join(root, entry))) {
124
- try {
125
- if (!statSync(entryPath).isDirectory())
126
- continue;
127
- }
128
- catch {
129
- continue;
130
- }
131
- const definition = loadWorkflowDefinitionFromDir(entryPath);
132
- if (definition)
133
- definitions.set(definition.id, definition);
134
- }
135
- }
136
- return [...definitions.values()].sort((a, b) => a.label.localeCompare(b.label));
137
- }
138
- export function loadLocalWorkflowDefinition(sourcePath, id) {
139
- return (loadWorkflowDefinitionFromDir(workflowDefinitionPath(sourcePath, id)) ??
140
- loadWorkflowDefinitionFromDir(legacyWorkflowDefinitionPath(sourcePath, id)));
141
- }
142
- export function resolveWorkflowPackageSourcePath(sourcePath, workflowId) {
143
- const localPath = workflowDefinitionPath(sourcePath, workflowId);
144
- if (existsSync(join(localPath, "workflow.json")))
145
- return localPath;
146
- const legacyLocalPath = legacyWorkflowDefinitionPath(sourcePath, workflowId);
147
- if (existsSync(join(legacyLocalPath, "workflow.json")))
148
- return legacyLocalPath;
149
- const builtinPath = builtinWorkflowRootPath(workflowId);
150
- if (existsSync(join(builtinPath, "workflow.json")))
151
- return builtinPath;
152
- if (workflowId === "interf-default") {
153
- const builtinInterfPath = builtinWorkflowRootPath("interf");
154
- if (existsSync(join(builtinInterfPath, "workflow.json")))
155
- return builtinInterfPath;
156
- }
157
- return null;
158
- }
159
- export function seedLocalDefaultWorkflow(options) {
160
- const workflowId = "interf-default";
161
- const targetPath = workflowDefinitionPath(options.sourcePath, workflowId);
162
- if (existsSync(join(targetPath, "workflow.json"))) {
163
- return { workflowId, targetPath, alreadyExisted: true };
164
- }
165
- const builtinInterfPath = builtinWorkflowRootPath("interf");
166
- if (!existsSync(join(builtinInterfPath, "workflow.json"))) {
167
- throw new Error(`Built-in "interf" workflow not found at ${builtinInterfPath}.`);
168
- }
169
- copyWorkflowPackageDirectory(builtinInterfPath, targetPath);
170
- patchWorkflowPackageMetadata(targetPath, {
171
- id: workflowId,
172
- label: "Built-in Interf Workflow",
173
- hint: "Built-in file-processing workflow: summarize source-grounded evidence, structure cross-file connections, and shape portable context around the saved readiness checks.",
174
- });
175
- return { workflowId, targetPath, alreadyExisted: false };
176
- }
177
- export function isWorkflowId(value) {
178
- return WorkflowIdPattern.test(value);
179
- }
180
- function readWorkflowJsonObject(dirPath) {
181
- const workflowPath = join(dirPath, "workflow.json");
182
- const raw = readJsonFileUnchecked(workflowPath, "workflow package");
183
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
184
- throw new Error(`Workflow package at ${dirPath} is missing a valid workflow.json.`);
185
- }
186
- return { ...raw };
187
- }
188
- export function patchWorkflowPackageMetadata(dirPath, options = {}) {
189
- const workflowPath = join(dirPath, "workflow.json");
190
- const workflowJson = readWorkflowJsonObject(dirPath);
191
- const normalizedStages = Array.isArray(workflowJson.stages) && workflowJson.stages.length > 0
192
- ? workflowJson.stages
193
- : null;
194
- if (!normalizedStages) {
195
- throw new Error(`Cannot patch workflow package at ${dirPath}: workflow.json must declare explicit stages before it can be copied or rewritten.`);
196
- }
197
- const nextWorkflowJson = {
198
- ...workflowJson,
199
- type: "compiled",
200
- compiler_api: workflowJson.compiler_api ?? {
201
- kind: "compiled",
202
- version: 1,
203
- },
204
- stages: normalizedStages,
205
- ...(options.id ? { id: options.id } : {}),
206
- ...(options.inputs && options.inputs.length > 0 ? { inputs: options.inputs } : {}),
207
- ...(options.label ? { label: options.label } : {}),
208
- ...(options.hint ? { hint: options.hint } : {}),
209
- };
210
- delete nextWorkflowJson.extends;
211
- const mergedStagePolicyNotes = mergeStagePolicyNotesForStages(normalizedStages, workflowJson.stage_policy_notes, options.stagePolicyNotes);
212
- if (mergedStagePolicyNotes) {
213
- nextWorkflowJson.stage_policy_notes = mergedStagePolicyNotes;
214
- }
215
- else {
216
- delete nextWorkflowJson.stage_policy_notes;
217
- }
218
- writeFileSync(workflowPath, JSON.stringify(nextWorkflowJson, null, 2) + "\n");
219
- const schemaLabel = `${String(nextWorkflowJson.label ?? workflowJson.label ?? options.id ?? "Workflow")} workflow schema`;
220
- const existingSchema = readContextInterface(dirPath);
221
- if (!existingSchema) {
222
- throw new Error(`Cannot patch workflow package at ${dirPath}: missing ${CONTEXT_INTERFACE_FILE}. Restore or reseed the package instead of regenerating a schema from workflow.json.`);
223
- }
224
- writeContextInterface(dirPath, {
225
- ...existingSchema,
226
- label: schemaLabel,
227
- });
228
- }
229
- function collectWorkflowPackageStructureIssues(dirPath, stages) {
230
- const issues = [];
231
- const workflowPath = join(dirPath, "workflow.json");
232
- if (!existsSync(workflowPath))
233
- issues.push("missing workflow.json");
234
- if (!contextInterfaceExists(dirPath))
235
- issues.push("missing workflow.schema.json");
236
- if (!existsSync(join(dirPath, "README.md")))
237
- issues.push("missing README.md");
238
- if (!existsSync(join(dirPath, "improve", "SKILL.md")))
239
- issues.push("missing improve/SKILL.md");
240
- if (!existsSync(join(dirPath, "use", "query", "SKILL.md")))
241
- issues.push("missing use/query/SKILL.md");
242
- if (!stages)
243
- return issues;
244
- for (const stage of stages) {
245
- const skillDir = typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
246
- ? stage.skill_dir
247
- : stage.id;
248
- if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
249
- issues.push(`missing compile/stages/${skillDir}/SKILL.md`);
250
- }
251
- }
252
- return issues;
253
- }
254
- function collectWorkflowStageSkillIssues(dirPath, stages) {
255
- if (!stages)
256
- return [];
257
- const issues = [];
258
- for (const stage of stages) {
259
- const skillDir = typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
260
- ? stage.skill_dir
261
- : stage.id;
262
- if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
263
- issues.push(`missing compile/stages/${skillDir}/SKILL.md`);
264
- }
265
- }
266
- return issues;
267
- }
268
- export function describeWorkflowPackagePortability(dirPath) {
269
- const issues = collectWorkflowPackageStructureIssues(dirPath, null);
270
- if (issues.length > 0)
271
- return issues;
272
- let workflowJson;
273
- try {
274
- workflowJson = readWorkflowJsonObject(dirPath);
275
- }
276
- catch (error) {
277
- issues.push(error instanceof Error ? error.message : String(error));
278
- return issues;
279
- }
280
- const parsed = LocalWorkflowDefinitionSchema.safeParse(workflowJson);
281
- if (!parsed.success) {
282
- issues.push(...parsed.error.issues.map((issue) => issue.path.length > 0
283
- ? `workflow.json ${issue.path.join(".")}: ${issue.message}`
284
- : `workflow.json: ${issue.message}`));
285
- return issues;
286
- }
287
- if (typeof parsed.data.extends === "string" && parsed.data.extends.trim().length > 0) {
288
- issues.push("workflow.json uses legacy extends; portable workflow packages must be materialized standalone");
289
- }
290
- if (!parsed.data.stages || parsed.data.stages.length === 0) {
291
- issues.push("workflow.json must declare explicit stages for a portable workflow package");
292
- return issues;
293
- }
294
- return [
295
- ...issues,
296
- ...collectWorkflowStageSkillIssues(dirPath, parsed.data.stages ?? null),
297
- ];
298
- }
299
- export function isPortableWorkflowPackage(dirPath) {
300
- return describeWorkflowPackagePortability(dirPath).length === 0;
301
- }
302
- export function copyWorkflowPackageDirectory(sourceWorkflowPath, targetWorkflowPath) {
303
- const portabilityIssues = describeWorkflowPackagePortability(sourceWorkflowPath);
304
- if (portabilityIssues.length > 0) {
305
- throw new Error(`Workflow package at ${sourceWorkflowPath} is not directly copyable: ${portabilityIssues.join("; ")}.`);
306
- }
307
- mkdirSync(dirname(targetWorkflowPath), { recursive: true });
308
- copyWorkflowPackageFiles(sourceWorkflowPath, targetWorkflowPath);
309
- }
310
- export function validateWorkflowPackage(dirPath) {
311
- const workflowPath = join(dirPath, "workflow.json");
312
- if (!existsSync(workflowPath)) {
313
- return {
314
- ok: false,
315
- summary: `No workflow.json found at ${dirPath}`,
316
- errors: ["Missing workflow.json"],
317
- counts: {},
318
- };
319
- }
320
- const raw = readJsonFileUnchecked(workflowPath, "workflow package");
321
- if (!raw) {
322
- return {
323
- ok: false,
324
- summary: `Failed to parse workflow.json at ${workflowPath}`,
325
- errors: ["Invalid JSON in workflow.json"],
326
- counts: {},
327
- };
328
- }
329
- const parsed = LocalWorkflowDefinitionSchema.safeParse(raw);
330
- if (!parsed.success) {
331
- const issues = parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`);
332
- return {
333
- ok: false,
334
- summary: `workflow.json failed validation: ${issues.length} issue(s)`,
335
- errors: issues,
336
- counts: {},
337
- };
338
- }
339
- const def = parsed.data;
340
- const errors = [];
341
- if (typeof def.extends === "string" && def.extends.trim().length > 0) {
342
- errors.push("workflow.json uses legacy extends. Portable workflow packages must be materialized as standalone packages.");
343
- }
344
- if (!def.stages || def.stages.length === 0) {
345
- errors.push("workflow.json must declare explicit stages. Legacy inherited packages are not portable.");
346
- }
347
- if (def.stage_policy_notes && def.stages) {
348
- const stageIds = new Set(def.stages.map((stage) => stage.id));
349
- for (const stageId of Object.keys(def.stage_policy_notes)) {
350
- if (!stageIds.has(stageId)) {
351
- errors.push(`workflow.json stage_policy_notes references unknown stage "${stageId}".`);
352
- }
353
- }
354
- }
355
- for (const issue of collectWorkflowPackageStructureIssues(dirPath, def.stages ?? null)) {
356
- const formatted = issue.startsWith("missing ")
357
- ? `Missing ${issue.slice("missing ".length)}.`
358
- : issue;
359
- errors.push(formatted);
360
- }
361
- const workflowSchema = readContextInterface(dirPath);
362
- if (!workflowSchema) {
363
- errors.push("workflow.schema.json is missing or invalid.");
364
- }
365
- if (workflowSchema) {
366
- const stages = def.stages ?? [];
367
- const stageIds = new Set(stages.map((stage) => stage.id));
368
- const seenPaths = new Map();
369
- const seenZoneIds = new Set();
370
- const zoneById = new Map(workflowSchema.zones.map((zone) => [zone.id, zone]));
371
- const normalizedParts = (value) => value.replaceAll("\\", "/").split("/").filter(Boolean);
372
- const hasOverlappingPath = (value, other) => {
373
- const a = normalizedParts(value);
374
- const b = normalizedParts(other);
375
- const shorter = a.length <= b.length ? a : b;
376
- const longer = a.length <= b.length ? b : a;
377
- return shorter.every((part, index) => longer[index] === part);
378
- };
379
- for (const zone of workflowSchema.zones) {
380
- if (seenZoneIds.has(zone.id)) {
381
- errors.push(`workflow.schema.json repeats zone id "${zone.id}".`);
382
- }
383
- seenZoneIds.add(zone.id);
384
- const existingPathOwner = seenPaths.get(zone.path);
385
- if (existingPathOwner) {
386
- errors.push(`workflow.schema.json repeats zone path "${zone.path}".`);
387
- }
388
- for (const [existingPath, existingZoneId] of seenPaths.entries()) {
389
- if (existingPath === zone.path)
390
- continue;
391
- if (hasOverlappingPath(zone.path, existingPath)) {
392
- errors.push(`workflow.schema.json zones "${zone.id}" and "${existingZoneId}" overlap on path "${zone.path}" / "${existingPath}".`);
393
- }
394
- }
395
- seenPaths.set(zone.path, zone.id);
396
- if ((zone.role === "input" || zone.role === "runtime") && zone.owned_by.length > 0) {
397
- errors.push(`workflow.schema.json zone "${zone.id}" cannot declare owners because its role is "${zone.role}".`);
398
- }
399
- for (const owner of zone.owned_by) {
400
- if (!stageIds.has(owner)) {
401
- errors.push(`workflow.schema.json references unknown stage "${owner}" for zone "${zone.path}".`);
402
- }
403
- }
404
- }
405
- for (const stage of stages) {
406
- for (const zoneId of stage.reads) {
407
- if (!zoneById.has(zoneId)) {
408
- errors.push(`Stage "${stage.id}" reads unknown zone "${zoneId}".`);
409
- }
410
- }
411
- for (const zoneId of stage.writes) {
412
- const zone = zoneById.get(zoneId);
413
- if (!zone) {
414
- errors.push(`Stage "${stage.id}" writes unknown zone "${zoneId}".`);
415
- continue;
416
- }
417
- if (zone.role === "input" || zone.role === "runtime") {
418
- errors.push(`Stage "${stage.id}" writes zone "${zoneId}" but zones with role "${zone.role}" are engine-owned inputs, not writable stage outputs.`);
419
- }
420
- if (!zone.owned_by.includes(stage.id)) {
421
- errors.push(`Stage "${stage.id}" writes zone "${zoneId}" but that zone is not owned by the stage in workflow.schema.json.`);
422
- }
423
- }
424
- }
425
- for (const requiredZone of listBuiltinCompiledZoneSpecs().filter((zone) => zone.id === "raw" || zone.id === "runtime")) {
426
- const match = zoneById.get(requiredZone.id);
427
- if (!match) {
428
- errors.push(`workflow.schema.json is missing required zone "${requiredZone.id}".`);
429
- continue;
430
- }
431
- if (match.kind !== requiredZone.kind) {
432
- errors.push(`workflow.schema.json zone "${requiredZone.id}" should be kind "${requiredZone.kind}".`);
433
- }
434
- if (match.role !== requiredZone.role) {
435
- errors.push(`workflow.schema.json zone "${requiredZone.id}" should have role "${requiredZone.role}".`);
436
- }
437
- }
438
- }
439
- const stageDirs = existsSync(join(dirPath, "compile", "stages"))
440
- ? listFilesRecursive(join(dirPath, "compile", "stages"), (filePath) => basename(filePath) === "SKILL.md")
441
- : [];
442
- const counts = {
443
- starter_docs: collectStarterDocs(dirPath).length,
444
- compile_stage_docs: stageDirs.length,
445
- compiled_zones: workflowSchema?.zones.length ?? 0,
446
- workflow_zones: workflowSchema?.zones.length ?? 0,
447
- };
448
- return {
449
- ok: errors.length === 0,
450
- summary: errors.length === 0 ? "Workflow package is valid." : `Workflow package has ${errors.length} issue(s).`,
451
- errors,
452
- counts,
453
- };
454
- }
455
- function basename(filePath) {
456
- return filePath.split(/[\\/]/).pop() ?? filePath;
457
- }
@@ -1,82 +0,0 @@
1
- import type { RuntimeContractType, RuntimeStageAcceptance, WorkflowCompilerApi, WorkflowId } from "../compiler/lib/schema.js";
2
- import { type ContextInterface, type ContextInterfaceZoneId, type WorkflowInputSpec } from "./context-interface.js";
3
- export interface WorkflowStarterDoc {
4
- relativePath: string;
5
- content: string;
6
- }
7
- export interface WorkflowStageDefinition {
8
- id: string;
9
- label: string;
10
- description: string;
11
- contractType: RuntimeContractType;
12
- skillDir: string;
13
- reads: ContextInterfaceZoneId[];
14
- writes: ContextInterfaceZoneId[];
15
- acceptance?: RuntimeStageAcceptance;
16
- }
17
- export interface WorkflowDefinition<TId extends string> {
18
- id: TId;
19
- compilerApi?: WorkflowCompilerApi;
20
- purpose?: {
21
- label: string;
22
- taskHint: string;
23
- };
24
- inputs?: WorkflowInputSpec[];
25
- label: string;
26
- hint: string;
27
- recommended?: boolean;
28
- contextInterface?: ContextInterface;
29
- schema?: ContextInterface;
30
- stages: WorkflowStageDefinition[];
31
- stagePolicyNotes?: Record<string, string[]>;
32
- starterDocs?: WorkflowStarterDoc[];
33
- scope?: "builtin" | "local";
34
- }
35
- export type CompiledWorkflowId = string;
36
- export declare function standaloneWorkflowDefinitionFromLocalPackage(local: {
37
- id: string;
38
- compiler_api?: WorkflowCompilerApi;
39
- purpose?: {
40
- label: string;
41
- task_hint: string;
42
- };
43
- inputs?: WorkflowInputSpec[];
44
- label: string;
45
- hint: string;
46
- stages?: Array<{
47
- id: string;
48
- label: string;
49
- description?: string;
50
- contract_type: RuntimeContractType;
51
- skill_dir?: string;
52
- reads: ContextInterfaceZoneId[];
53
- writes: ContextInterfaceZoneId[];
54
- acceptance?: RuntimeStageAcceptance;
55
- }>;
56
- stage_policy_notes?: Record<string, string[]>;
57
- workflow_schema?: ContextInterface;
58
- starter_docs: WorkflowStarterDoc[];
59
- }): WorkflowDefinition<string>;
60
- export declare function listCompiledWorkflowChoices(sourcePath?: string): WorkflowDefinition<string>[];
61
- export declare function getCompiledWorkflow(workflowId: CompiledWorkflowId, options?: {
62
- sourcePath?: string;
63
- }): WorkflowDefinition<string>;
64
- export declare function getActiveCompiledWorkflow(compiledPath: string): WorkflowDefinition<string>;
65
- export declare function resolveCompiledWorkflowId(value: unknown): CompiledWorkflowId | null;
66
- export declare function resolveCompiledWorkflowFromConfig(config: unknown): CompiledWorkflowId | null;
67
- export declare function resolveRequiredCompiledWorkflowFromConfig(config: unknown, label?: string): CompiledWorkflowId;
68
- export declare function formatCompiledWorkflowStageStep(workflowId: CompiledWorkflowId, stage: string, options?: {
69
- sourcePath?: string;
70
- }): string;
71
- export declare function getWorkflowStageDefinition(workflowId: WorkflowId, stage: string, sourcePath?: string): WorkflowStageDefinition | null;
72
- export declare function getWorkflowStagePosition(workflowId: WorkflowId, stage: string, sourcePath?: string): {
73
- stageIndex: number;
74
- stageTotal: number;
75
- stages: string[];
76
- } | null;
77
- export declare function getWorkflowStages(workflowId: WorkflowId, sourcePath?: string): string[];
78
- export declare function getActiveCompiledStages(compiledPath: string): string[];
79
- export declare function getWorkflowStagePolicyNotes(workflowId: WorkflowId, stage: string, sourcePath?: string): string[];
80
- export declare function getActiveCompiledStagePolicyNotes(compiledPath: string, stage: string): string[];
81
- export declare function resolveActiveCompiledStageAcceptance(compiledPath: string, stage: string): WorkflowStageDefinition["acceptance"] | undefined;
82
- export declare function formatActiveCompiledWorkflowStageStep(compiledPath: string, stage: string): string;