@interf/compiler 0.7.2 → 0.9.1

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 (306) hide show
  1. package/README.md +141 -99
  2. package/TRADEMARKS.md +1 -1
  3. package/agent-skills/interf-actions/SKILL.md +71 -0
  4. package/agent-skills/interf-actions/references/cli.md +190 -0
  5. package/apps/compiler-ui/.next/server/app/index.html +1 -0
  6. package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_buildManifest.js +11 -0
  7. package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_clientMiddlewareManifest.js +1 -0
  8. package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_ssgManifest.js +1 -0
  9. package/apps/compiler-ui/.next/static/chunks/03~yq9q893hmn.js +1 -0
  10. package/apps/compiler-ui/.next/static/chunks/06z~l3kwb891e.js +1 -0
  11. package/apps/compiler-ui/.next/static/chunks/08g7lvje.te.u.js +1 -0
  12. package/apps/compiler-ui/.next/static/chunks/08m7vf5asqlsm.js +91 -0
  13. package/apps/compiler-ui/.next/static/chunks/0_i-3_5l9t2qe.js +1 -0
  14. package/apps/compiler-ui/.next/static/chunks/0b-ywny_j0g~0.js +1 -0
  15. package/apps/compiler-ui/.next/static/chunks/0b52v41o1gixx.js +1 -0
  16. package/apps/compiler-ui/.next/static/chunks/0fgt_8knmicoz.js +124 -0
  17. package/apps/compiler-ui/.next/static/chunks/0gpzgsv0w.q~m.js +31 -0
  18. package/apps/compiler-ui/.next/static/chunks/0ilwfezfvu6~-.js +1 -0
  19. package/apps/compiler-ui/.next/static/chunks/0n51hrfoufc7g.js +1 -0
  20. package/apps/compiler-ui/.next/static/chunks/0ti_66mx7~w2-.js +5 -0
  21. package/apps/compiler-ui/.next/static/chunks/0xxmf45eskdt~.css +1 -0
  22. package/apps/compiler-ui/.next/static/chunks/0y5z3t-z1c8ks.js.map +5 -0
  23. package/apps/compiler-ui/.next/static/chunks/13g~4mamjft.c.css +3 -0
  24. package/apps/compiler-ui/.next/static/chunks/14wtz~vq25~qq.js +1 -0
  25. package/apps/compiler-ui/.next/static/chunks/turbopack-109rtik40vwh5.js +1 -0
  26. package/apps/compiler-ui/.next/static/chunks/turbopack-10e~t1yzi4svj.js +1 -0
  27. package/apps/compiler-ui/.next/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +1 -0
  28. package/apps/compiler-ui/.next/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
  29. package/apps/compiler-ui/.next/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
  30. package/apps/compiler-ui/.next/static/media/worker.102zas1s52_pf.js +109 -0
  31. package/builtin-workflows/interf/README.md +8 -8
  32. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +6 -6
  33. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +1 -1
  34. package/builtin-workflows/interf/improve/SKILL.md +2 -2
  35. package/builtin-workflows/interf/use/query/SKILL.md +2 -2
  36. package/builtin-workflows/interf/workflow.json +9 -9
  37. package/builtin-workflows/interf/workflow.schema.json +2 -2
  38. package/dist/cli/commands/check-draft.d.ts +5 -4
  39. package/dist/cli/commands/check-draft.js +18 -17
  40. package/dist/cli/commands/compile-controller.d.ts +3 -0
  41. package/dist/cli/commands/compile-controller.js +53 -45
  42. package/dist/cli/commands/compile.js +83 -27
  43. package/dist/cli/commands/compiled-flow.d.ts +3 -0
  44. package/dist/cli/commands/compiled-flow.js +9 -7
  45. package/dist/cli/commands/control-path.d.ts +11 -0
  46. package/dist/cli/commands/control-path.js +72 -0
  47. package/dist/cli/commands/create-workflow-wizard.d.ts +12 -0
  48. package/dist/cli/commands/create-workflow-wizard.js +232 -66
  49. package/dist/cli/commands/create.js +70 -46
  50. package/dist/cli/commands/default.js +5 -3
  51. package/dist/cli/commands/doctor.js +5 -5
  52. package/dist/cli/commands/executor-flow.js +1 -1
  53. package/dist/cli/commands/init.js +362 -101
  54. package/dist/cli/commands/list.js +8 -7
  55. package/dist/cli/commands/preparation-selection.d.ts +6 -0
  56. package/dist/cli/commands/preparation-selection.js +11 -0
  57. package/dist/cli/commands/reset.js +3 -3
  58. package/dist/cli/commands/source-config-wizard.d.ts +4 -4
  59. package/dist/cli/commands/source-config-wizard.js +175 -200
  60. package/dist/cli/commands/status.js +116 -8
  61. package/dist/cli/commands/test-flow.d.ts +1 -1
  62. package/dist/cli/commands/test-flow.js +35 -33
  63. package/dist/cli/commands/test.d.ts +4 -0
  64. package/dist/cli/commands/test.js +95 -58
  65. package/dist/cli/commands/verify.js +7 -7
  66. package/dist/cli/commands/web.d.ts +11 -0
  67. package/dist/cli/commands/web.js +373 -0
  68. package/dist/cli/index.d.ts +2 -1
  69. package/dist/cli/index.js +3 -1
  70. package/dist/index.d.ts +4 -2
  71. package/dist/index.js +3 -1
  72. package/dist/packages/agents/lib/execution.js +4 -2
  73. package/dist/packages/agents/lib/executors.d.ts +1 -0
  74. package/dist/packages/agents/lib/executors.js +1 -0
  75. package/dist/packages/agents/lib/render.d.ts +2 -2
  76. package/dist/packages/agents/lib/render.js +10 -9
  77. package/dist/packages/agents/lib/shells.d.ts +3 -11
  78. package/dist/packages/agents/lib/shells.js +58 -106
  79. package/dist/packages/agents/lib/types.d.ts +1 -0
  80. package/dist/packages/compiler/compiled-paths.d.ts +4 -1
  81. package/dist/packages/compiler/compiled-paths.js +8 -2
  82. package/dist/packages/compiler/compiled-pipeline.d.ts +7 -0
  83. package/dist/packages/compiler/compiled-pipeline.js +15 -4
  84. package/dist/packages/compiler/compiled-schema.js +1 -1
  85. package/dist/packages/compiler/compiled-stage-plan.d.ts +2 -2
  86. package/dist/packages/compiler/compiled-stage-plan.js +4 -4
  87. package/dist/packages/compiler/compiled-stage-runner.d.ts +5 -0
  88. package/dist/packages/compiler/compiled-stage-runner.js +50 -2
  89. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  90. package/dist/packages/compiler/compiled-target.js +2 -2
  91. package/dist/packages/compiler/lib/schema.d.ts +161 -1
  92. package/dist/packages/compiler/lib/schema.js +87 -1
  93. package/dist/packages/compiler/raw-snapshot.d.ts +9 -2
  94. package/dist/packages/compiler/runtime-acceptance.js +1 -1
  95. package/dist/packages/compiler/runtime-contracts.js +2 -2
  96. package/dist/packages/compiler/runtime-prompt.js +7 -7
  97. package/dist/packages/compiler/runtime-reconcile.js +3 -3
  98. package/dist/packages/compiler/runtime-runs.js +3 -0
  99. package/dist/packages/compiler/runtime-types.d.ts +1 -0
  100. package/dist/packages/compiler/state-health.js +1 -1
  101. package/dist/packages/compiler/state-view.js +2 -2
  102. package/dist/packages/compiler/validate-compiled.js +11 -9
  103. package/dist/packages/execution/adapters.d.ts +15 -0
  104. package/dist/packages/execution/adapters.js +1 -0
  105. package/dist/packages/execution/events.d.ts +8 -0
  106. package/dist/packages/execution/events.js +16 -0
  107. package/dist/packages/execution/index.d.ts +9 -0
  108. package/dist/packages/execution/index.js +6 -0
  109. package/dist/packages/execution/lib/schema.d.ts +1554 -0
  110. package/dist/packages/execution/lib/schema.js +319 -0
  111. package/dist/packages/local-service/action-values.d.ts +23 -0
  112. package/dist/packages/local-service/action-values.js +31 -0
  113. package/dist/packages/local-service/client.d.ts +119 -0
  114. package/dist/packages/local-service/client.js +356 -0
  115. package/dist/packages/local-service/index.d.ts +15 -0
  116. package/dist/packages/local-service/index.js +11 -0
  117. package/dist/packages/local-service/lib/schema.d.ts +7355 -0
  118. package/dist/packages/local-service/lib/schema.js +636 -0
  119. package/dist/packages/local-service/routes.d.ts +27 -0
  120. package/dist/packages/local-service/routes.js +32 -0
  121. package/dist/packages/local-service/runtime.d.ts +134 -0
  122. package/dist/packages/local-service/runtime.js +2841 -0
  123. package/dist/packages/local-service/server.d.ts +17 -0
  124. package/dist/packages/local-service/server.js +572 -0
  125. package/dist/packages/project-model/index.d.ts +2 -1
  126. package/dist/packages/project-model/index.js +1 -0
  127. package/dist/packages/project-model/interf-detect.d.ts +6 -2
  128. package/dist/packages/project-model/interf-detect.js +48 -19
  129. package/dist/packages/project-model/interf-scaffold.d.ts +1 -0
  130. package/dist/packages/project-model/interf-scaffold.js +39 -17
  131. package/dist/packages/project-model/interf.d.ts +2 -2
  132. package/dist/packages/project-model/interf.js +2 -2
  133. package/dist/packages/project-model/lib/schema.d.ts +80 -6
  134. package/dist/packages/project-model/lib/schema.js +29 -19
  135. package/dist/packages/project-model/project-paths.d.ts +3 -1
  136. package/dist/packages/project-model/project-paths.js +6 -2
  137. package/dist/packages/project-model/source-config.d.ts +25 -11
  138. package/dist/packages/project-model/source-config.js +152 -82
  139. package/dist/packages/project-model/source-folders.d.ts +11 -0
  140. package/dist/packages/project-model/source-folders.js +110 -0
  141. package/dist/packages/testing/test-execution.js +5 -5
  142. package/dist/packages/testing/test-paths.js +4 -3
  143. package/dist/packages/workflow-authoring/workflow-authoring.d.ts +4 -6
  144. package/dist/packages/workflow-authoring/workflow-authoring.js +46 -85
  145. package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +2 -0
  146. package/dist/packages/workflow-authoring/workflow-edit-session.js +83 -49
  147. package/dist/packages/workflow-authoring/workflow-improvement.js +2 -1
  148. package/dist/packages/workflow-package/context-interface.js +2 -2
  149. package/dist/packages/workflow-package/interf-workflow-package.d.ts +6 -0
  150. package/dist/packages/workflow-package/interf-workflow-package.js +115 -8
  151. package/dist/packages/workflow-package/local-workflows.js +33 -17
  152. package/dist/packages/workflow-package/workflow-definitions.d.ts +5 -5
  153. package/dist/packages/workflow-package/workflow-definitions.js +23 -22
  154. package/dist/packages/workflow-package/workflow-helpers.js +10 -6
  155. package/dist/packages/workflow-package/workflow-review-paths.js +5 -1
  156. package/dist/packages/workflow-package/workflow-stage-runner.d.ts +1 -0
  157. package/dist/packages/workflow-package/workflow-stage-runner.js +2 -0
  158. package/package.json +18 -4
  159. package/dist/cli/commands/dataset-selection.d.ts +0 -6
  160. package/dist/cli/commands/dataset-selection.js +0 -11
  161. package/dist/lib/agent-args.d.ts +0 -1
  162. package/dist/lib/agent-args.js +0 -1
  163. package/dist/lib/agent-constants.d.ts +0 -1
  164. package/dist/lib/agent-constants.js +0 -1
  165. package/dist/lib/agent-detection.d.ts +0 -1
  166. package/dist/lib/agent-detection.js +0 -1
  167. package/dist/lib/agent-execution.d.ts +0 -1
  168. package/dist/lib/agent-execution.js +0 -1
  169. package/dist/lib/agent-logs.d.ts +0 -1
  170. package/dist/lib/agent-logs.js +0 -1
  171. package/dist/lib/agent-preflight.d.ts +0 -1
  172. package/dist/lib/agent-preflight.js +0 -1
  173. package/dist/lib/agent-render.d.ts +0 -1
  174. package/dist/lib/agent-render.js +0 -1
  175. package/dist/lib/agent-shells.d.ts +0 -1
  176. package/dist/lib/agent-shells.js +0 -1
  177. package/dist/lib/agent-status.d.ts +0 -1
  178. package/dist/lib/agent-status.js +0 -1
  179. package/dist/lib/agent-types.d.ts +0 -1
  180. package/dist/lib/agent-types.js +0 -1
  181. package/dist/lib/agents.d.ts +0 -1
  182. package/dist/lib/agents.js +0 -1
  183. package/dist/lib/builtin-compiled-workflow.d.ts +0 -1
  184. package/dist/lib/builtin-compiled-workflow.js +0 -1
  185. package/dist/lib/chart-guidance.d.ts +0 -1
  186. package/dist/lib/chart-guidance.js +0 -1
  187. package/dist/lib/compiled-compile.d.ts +0 -1
  188. package/dist/lib/compiled-compile.js +0 -1
  189. package/dist/lib/compiled-paths.d.ts +0 -1
  190. package/dist/lib/compiled-paths.js +0 -3
  191. package/dist/lib/compiled-raw.d.ts +0 -1
  192. package/dist/lib/compiled-raw.js +0 -3
  193. package/dist/lib/compiled-reset.d.ts +0 -1
  194. package/dist/lib/compiled-reset.js +0 -3
  195. package/dist/lib/compiled-schema.d.ts +0 -1
  196. package/dist/lib/compiled-schema.js +0 -1
  197. package/dist/lib/discovery.d.ts +0 -1
  198. package/dist/lib/discovery.js +0 -1
  199. package/dist/lib/execution-profile.d.ts +0 -1
  200. package/dist/lib/execution-profile.js +0 -1
  201. package/dist/lib/executors.d.ts +0 -1
  202. package/dist/lib/executors.js +0 -1
  203. package/dist/lib/filesystem.d.ts +0 -1
  204. package/dist/lib/filesystem.js +0 -1
  205. package/dist/lib/interf-bootstrap.d.ts +0 -1
  206. package/dist/lib/interf-bootstrap.js +0 -3
  207. package/dist/lib/interf-detect.d.ts +0 -1
  208. package/dist/lib/interf-detect.js +0 -3
  209. package/dist/lib/interf-scaffold.d.ts +0 -1
  210. package/dist/lib/interf-scaffold.js +0 -3
  211. package/dist/lib/interf-workflow-package.d.ts +0 -1
  212. package/dist/lib/interf-workflow-package.js +0 -1
  213. package/dist/lib/interf.d.ts +0 -1
  214. package/dist/lib/interf.js +0 -3
  215. package/dist/lib/local-workflows.d.ts +0 -1
  216. package/dist/lib/local-workflows.js +0 -1
  217. package/dist/lib/logger.d.ts +0 -1
  218. package/dist/lib/logger.js +0 -1
  219. package/dist/lib/package-root.d.ts +0 -1
  220. package/dist/lib/package-root.js +0 -1
  221. package/dist/lib/parse.d.ts +0 -1
  222. package/dist/lib/parse.js +0 -1
  223. package/dist/lib/project-paths.d.ts +0 -1
  224. package/dist/lib/project-paths.js +0 -3
  225. package/dist/lib/runtime-acceptance.d.ts +0 -1
  226. package/dist/lib/runtime-acceptance.js +0 -1
  227. package/dist/lib/runtime-contracts.d.ts +0 -1
  228. package/dist/lib/runtime-contracts.js +0 -1
  229. package/dist/lib/runtime-inventory.d.ts +0 -1
  230. package/dist/lib/runtime-inventory.js +0 -1
  231. package/dist/lib/runtime-paths.d.ts +0 -1
  232. package/dist/lib/runtime-paths.js +0 -1
  233. package/dist/lib/runtime-prompt.d.ts +0 -1
  234. package/dist/lib/runtime-prompt.js +0 -1
  235. package/dist/lib/runtime-reconcile.d.ts +0 -1
  236. package/dist/lib/runtime-reconcile.js +0 -1
  237. package/dist/lib/runtime-runs.d.ts +0 -1
  238. package/dist/lib/runtime-runs.js +0 -1
  239. package/dist/lib/runtime-types.d.ts +0 -1
  240. package/dist/lib/runtime-types.js +0 -1
  241. package/dist/lib/runtime.d.ts +0 -1
  242. package/dist/lib/runtime.js +0 -1
  243. package/dist/lib/schema.d.ts +0 -4
  244. package/dist/lib/schema.js +0 -6
  245. package/dist/lib/source-config.d.ts +0 -1
  246. package/dist/lib/source-config.js +0 -3
  247. package/dist/lib/state-artifacts.d.ts +0 -1
  248. package/dist/lib/state-artifacts.js +0 -1
  249. package/dist/lib/state-health.d.ts +0 -1
  250. package/dist/lib/state-health.js +0 -1
  251. package/dist/lib/state-io.d.ts +0 -1
  252. package/dist/lib/state-io.js +0 -1
  253. package/dist/lib/state-paths.d.ts +0 -1
  254. package/dist/lib/state-paths.js +0 -1
  255. package/dist/lib/state-view.d.ts +0 -1
  256. package/dist/lib/state-view.js +0 -1
  257. package/dist/lib/state.d.ts +0 -1
  258. package/dist/lib/state.js +0 -1
  259. package/dist/lib/test-execution.d.ts +0 -1
  260. package/dist/lib/test-execution.js +0 -3
  261. package/dist/lib/test-matrices.d.ts +0 -1
  262. package/dist/lib/test-matrices.js +0 -3
  263. package/dist/lib/test-paths.d.ts +0 -1
  264. package/dist/lib/test-paths.js +0 -3
  265. package/dist/lib/test-profile-presets.d.ts +0 -1
  266. package/dist/lib/test-profile-presets.js +0 -3
  267. package/dist/lib/test-sandbox.d.ts +0 -1
  268. package/dist/lib/test-sandbox.js +0 -3
  269. package/dist/lib/test-specs.d.ts +0 -1
  270. package/dist/lib/test-specs.js +0 -3
  271. package/dist/lib/test-targets.d.ts +0 -1
  272. package/dist/lib/test-targets.js +0 -3
  273. package/dist/lib/test-types.d.ts +0 -1
  274. package/dist/lib/test-types.js +0 -3
  275. package/dist/lib/test.d.ts +0 -1
  276. package/dist/lib/test.js +0 -3
  277. package/dist/lib/util.d.ts +0 -1
  278. package/dist/lib/util.js +0 -1
  279. package/dist/lib/validate-compiled.d.ts +0 -1
  280. package/dist/lib/validate-compiled.js +0 -1
  281. package/dist/lib/validate-helpers.d.ts +0 -1
  282. package/dist/lib/validate-helpers.js +0 -1
  283. package/dist/lib/validate.d.ts +0 -1
  284. package/dist/lib/validate.js +0 -1
  285. package/dist/lib/workflow-authoring.d.ts +0 -1
  286. package/dist/lib/workflow-authoring.js +0 -1
  287. package/dist/lib/workflow-definitions.d.ts +0 -1
  288. package/dist/lib/workflow-definitions.js +0 -1
  289. package/dist/lib/workflow-edit-session.d.ts +0 -1
  290. package/dist/lib/workflow-edit-session.js +0 -1
  291. package/dist/lib/workflow-edit-utils.d.ts +0 -1
  292. package/dist/lib/workflow-edit-utils.js +0 -1
  293. package/dist/lib/workflow-helpers.d.ts +0 -1
  294. package/dist/lib/workflow-helpers.js +0 -1
  295. package/dist/lib/workflow-improvement.d.ts +0 -1
  296. package/dist/lib/workflow-improvement.js +0 -1
  297. package/dist/lib/workflow-primitives.d.ts +0 -1
  298. package/dist/lib/workflow-primitives.js +0 -1
  299. package/dist/lib/workflow-review-paths.d.ts +0 -1
  300. package/dist/lib/workflow-review-paths.js +0 -1
  301. package/dist/lib/workflow-stage-policy.d.ts +0 -1
  302. package/dist/lib/workflow-stage-policy.js +0 -1
  303. package/dist/lib/workflow-stage-runner.d.ts +0 -1
  304. package/dist/lib/workflow-stage-runner.js +0 -1
  305. package/dist/lib/workflows.d.ts +0 -1
  306. package/dist/lib/workflows.js +0 -1
@@ -1,15 +1,167 @@
1
1
  import chalk from "chalk";
2
2
  import * as p from "@clack/prompts";
3
- import { resolve } from "node:path";
4
- import { detectInterf, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
5
- import { SOURCE_FOLDER_CONFIG_FILE, syncCompiledInterfConfigFromSourceDatasetConfig, upsertSourceDatasetConfig, } from "../../packages/project-model/source-config.js";
6
- import { DEFAULT_COMPILED_NAME, describeCompileLoopSelection, promptSingleCompiledConfig, } from "./source-config-wizard.js";
7
- import { buildCompiledWorkflowOptions, chooseCompiledWorkflow, createWorkflowWizard, } from "./create-workflow-wizard.js";
3
+ import { existsSync, statSync } from "node:fs";
4
+ import { basename, isAbsolute, relative, resolve } from "node:path";
5
+ import { assertCompiledContainer, detectInterf, ensurePortableContextScaffold, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
6
+ import { SOURCE_FOLDER_CONFIG_PATH, configuredSourceFolderPath, loadSourceFolderConfig, resolveConfiguredSourceFolderPath, saveSourceFolderConfig, syncCompiledInterfConfigFromSourceDatasetConfig, upsertSourceDatasetConfig, } from "../../packages/project-model/source-config.js";
7
+ import { defaultDatasetNameForPath, } from "../../packages/project-model/source-folders.js";
8
+ import { DEFAULT_COMPILED_NAME, describeCompileLoopSelection, listDatasetFolderChoices, promptSingleCompiledConfig, } from "./source-config-wizard.js";
9
+ import { chooseOrCreateCompiledWorkflowForDataset, createWorkflowWizard, } from "./create-workflow-wizard.js";
8
10
  import { seedLocalDefaultWorkflow } from "../../packages/workflow-package/local-workflows.js";
9
11
  import { findBuiltCompiledPath, findSavedCompiledConfig, listSavedCompiledEntries, } from "./compiled-flow.js";
10
12
  import { readCurrentSavedTestComparison, } from "./test-flow.js";
11
13
  import { runCompileCommand } from "./compile.js";
12
14
  import { runTestCommand } from "./test.js";
15
+ import { defaultInterfInstanceRoot, relativeSourceFolderPath, resolveInterfInstanceContext, } from "./control-path.js";
16
+ import { runWebCommand } from "./web.js";
17
+ function isPathInside(parentPath, childPath) {
18
+ const relativePath = relative(parentPath, childPath);
19
+ return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
20
+ }
21
+ function normalizeSourceFolderInput(cwd, input) {
22
+ const trimmed = input.trim();
23
+ if (trimmed.length === 0) {
24
+ throw new Error("Source Folder is required.");
25
+ }
26
+ const sourceFolderPath = resolve(cwd, trimmed);
27
+ if (!existsSync(sourceFolderPath)) {
28
+ throw new Error("Pick an existing Source Folder.");
29
+ }
30
+ if (!statSync(sourceFolderPath).isDirectory()) {
31
+ throw new Error("Source Folder must be a directory.");
32
+ }
33
+ return sourceFolderPath;
34
+ }
35
+ function normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, input) {
36
+ const trimmed = input.trim();
37
+ if (trimmed.length === 0) {
38
+ throw new Error("Interf Workspace folder is required.");
39
+ }
40
+ const controlPath = resolve(cwd, trimmed);
41
+ if (isPathInside(sourceFolderPath, controlPath)) {
42
+ throw new Error("Choose an Interf Workspace folder outside the Source Folder so Interf does not write generated state into your source files.");
43
+ }
44
+ assertCompiledContainer(controlPath);
45
+ return controlPath;
46
+ }
47
+ async function promptSourceFolderForInstance(cwd) {
48
+ const folderChoices = listDatasetFolderChoices(cwd);
49
+ const selected = await p.select({
50
+ message: "Which Source Folder should Interf prepare?",
51
+ options: [
52
+ ...folderChoices,
53
+ {
54
+ value: "__current__",
55
+ label: `Use current folder (${basename(cwd)})`,
56
+ hint: cwd,
57
+ },
58
+ {
59
+ value: "__manual__",
60
+ label: "Enter a different path",
61
+ hint: "Use an absolute path or a path relative to this folder",
62
+ },
63
+ ],
64
+ initialValue: folderChoices.length === 1 ? folderChoices[0]?.value : "__current__",
65
+ });
66
+ if (p.isCancel(selected))
67
+ return null;
68
+ if (selected === "__manual__") {
69
+ const sourceInput = await p.text({
70
+ message: "Source Folder path?",
71
+ placeholder: cwd,
72
+ initialValue: cwd,
73
+ validate: (value) => {
74
+ try {
75
+ normalizeSourceFolderInput(cwd, value);
76
+ return undefined;
77
+ }
78
+ catch (error) {
79
+ return error instanceof Error ? error.message : String(error);
80
+ }
81
+ },
82
+ });
83
+ if (p.isCancel(sourceInput))
84
+ return null;
85
+ return normalizeSourceFolderInput(cwd, String(sourceInput));
86
+ }
87
+ return normalizeSourceFolderInput(cwd, selected === "__current__" ? "." : String(selected));
88
+ }
89
+ async function promptInterfInstanceFolder(cwd, sourceFolderPath) {
90
+ const defaultControlPath = defaultInterfInstanceRoot(sourceFolderPath);
91
+ p.log.info("Interf stores config, Methods, runs, and portable context outside the Source Folder.");
92
+ const controlInput = await p.text({
93
+ message: "Where should Interf store this Interf Workspace?",
94
+ placeholder: defaultControlPath,
95
+ initialValue: defaultControlPath,
96
+ validate: (value) => {
97
+ try {
98
+ normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, value);
99
+ return undefined;
100
+ }
101
+ catch (error) {
102
+ return error instanceof Error ? error.message : String(error);
103
+ }
104
+ },
105
+ });
106
+ if (p.isCancel(controlInput))
107
+ return null;
108
+ return normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, String(controlInput));
109
+ }
110
+ async function setupInterfInstance(cwd) {
111
+ const sourceFolderPath = await promptSourceFolderForInstance(cwd);
112
+ if (!sourceFolderPath)
113
+ return null;
114
+ const controlPath = await promptInterfInstanceFolder(cwd, sourceFolderPath);
115
+ if (!controlPath)
116
+ return null;
117
+ const sourceFolderConfigPath = relativeSourceFolderPath(controlPath, sourceFolderPath);
118
+ saveSourceFolderConfig(controlPath, {
119
+ source_folder: { path: sourceFolderConfigPath },
120
+ preparations: [],
121
+ });
122
+ const seeded = seedLocalDefaultWorkflow({ sourcePath: controlPath });
123
+ p.log.info(`Source Folder: ${sourceFolderPath}`);
124
+ p.log.info(`Interf Workspace: ${controlPath}`);
125
+ p.log.info(`Source Folder path in Interf config: ${sourceFolderConfigPath}`);
126
+ if (!seeded.alreadyExisted) {
127
+ p.log.info(`Copied built-in Method package to interf/methods/${seeded.workflowId}/. Inspect or fork it anytime.`);
128
+ }
129
+ return {
130
+ sourceFolderPath,
131
+ controlPath,
132
+ sourceFolderConfigPath,
133
+ };
134
+ }
135
+ async function promptEmptyInstanceAction() {
136
+ const selected = await p.select({
137
+ message: "What do you want to do next?",
138
+ options: [
139
+ {
140
+ value: "web",
141
+ label: "Open Interf UI (Recommended)",
142
+ hint: "Start the local UI and API for this Source Folder",
143
+ },
144
+ {
145
+ value: "preparation",
146
+ label: "Create Preparation",
147
+ hint: "Describe the agent work, choose a Method, and save readiness checks",
148
+ },
149
+ {
150
+ value: "method",
151
+ label: "Create Method",
152
+ hint: "Create or draft a reusable way to process files",
153
+ },
154
+ {
155
+ value: "done",
156
+ label: "Done",
157
+ hint: `Leave the empty Interf Workspace at ${SOURCE_FOLDER_CONFIG_PATH}`,
158
+ },
159
+ ],
160
+ });
161
+ if (p.isCancel(selected))
162
+ return null;
163
+ return selected;
164
+ }
13
165
  export function currentRunTargetStatus(rows, target) {
14
166
  const outcomes = rows
15
167
  .map((row) => (target === "raw" ? row.rawOutcome : row.compiledOutcome))
@@ -23,43 +175,43 @@ export function currentRunTargetStatus(rows, target) {
23
175
  return "mixed";
24
176
  return "fail";
25
177
  }
26
- function describeSavedQuestions(dataset) {
178
+ function describeSavedReadinessChecks(dataset) {
27
179
  const count = dataset.checks.length;
28
180
  if (count === 0)
29
- return "No questions yet";
30
- return `${count} question${count === 1 ? "" : "s"}`;
181
+ return "No readiness checks yet";
182
+ return `${count} readiness check${count === 1 ? "" : "s"}`;
31
183
  }
32
184
  function printDatasetSummary(options) {
33
185
  const compiledConfig = options.builtCompiledPath
34
186
  ? readInterfConfig(options.builtCompiledPath)
35
187
  : null;
36
- const workflowLabel = `${options.dataset.workflow ?? "interf"}${compiledConfig?.workflow_origin?.local_draft === true ? " (local draft)" : ""}`;
37
- p.log.info(`Dataset: ${options.dataset.name}`);
188
+ const workflowLabel = `${options.dataset.method ?? options.dataset.workflow ?? "interf-default"}${compiledConfig?.workflow_origin?.local_draft === true ? " (local draft)" : ""}`;
189
+ p.log.info(`Preparation: ${options.dataset.name}`);
38
190
  p.log.info(`Source folder: ${options.dataset.path}`);
39
191
  if (options.dataset.about) {
40
192
  p.log.info(`About: ${options.dataset.about}`);
41
193
  }
42
- p.log.info(`Workflow: ${workflowLabel}`);
194
+ p.log.info(`Method: ${workflowLabel}`);
43
195
  p.log.info(describeCompileLoopSelection({
44
196
  maxAttempts: options.dataset.max_attempts,
45
197
  maxLoops: options.dataset.max_loops,
46
198
  }));
47
- p.log.info(describeSavedQuestions(options.dataset));
48
- p.log.info(options.built ? "Portable context is available." : "Portable context has not been built yet.");
199
+ p.log.info(describeSavedReadinessChecks(options.dataset));
200
+ p.log.info(options.built ? "Portable Context is available." : "Portable Context has not been built yet.");
49
201
  if (options.latestComparison?.raw && options.latestComparison?.compiled) {
50
- p.log.info(`Latest saved comparison: source files ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}, portable context for your agents ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
202
+ p.log.info(`Latest saved comparison: source files ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}, Portable Context ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
51
203
  }
52
204
  else if (options.latestComparison?.raw) {
53
205
  p.log.info(`Latest saved source-files run: ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}.`);
54
206
  }
55
207
  else if (options.latestComparison?.compiled) {
56
- p.log.info(`Latest portable-context run: ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
208
+ p.log.info(`Latest Portable Context run: ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
57
209
  }
58
210
  else if (options.latestComparisonStale) {
59
- p.log.info("Saved test results are stale for the current questions.");
211
+ p.log.info("Saved readiness results are stale for the current checks.");
60
212
  }
61
213
  if (options.sourcePath !== process.cwd()) {
62
- p.log.info(`Project folder: ${options.sourcePath}`);
214
+ p.log.info(`Interf Workspace: ${options.sourcePath}`);
63
215
  }
64
216
  }
65
217
  async function promptDatasetAction(dataset, built, latestComparison) {
@@ -67,45 +219,55 @@ async function promptDatasetAction(dataset, built, latestComparison) {
67
219
  const hasSavedRawBaseline = Boolean(latestComparison?.raw);
68
220
  const latestRawPasses = latestComparison?.raw &&
69
221
  latestComparison.raw.passed_cases === latestComparison.raw.total_cases;
222
+ const compileOption = {
223
+ value: "compile",
224
+ label: built ? "Prepare again and refresh Portable Context" : "Prepare files and write Portable Context (Recommended)",
225
+ hint: built
226
+ ? "Refresh it from the current source files"
227
+ : dataset.checks.length > 0
228
+ ? latestRawPasses
229
+ ? "Prepare files for a side-by-side comparison with the latest saved source-files run"
230
+ : hasSavedRawBaseline
231
+ ? "Some readiness checks still fail on the source files. Prepare files and run the same checks"
232
+ : "Run the selected Method and write the output folder agents can use"
233
+ : "Run the selected Method and create the output folder agents can use",
234
+ };
70
235
  if (dataset.checks.length > 0) {
71
- options.push({
236
+ const testOption = {
72
237
  value: "test",
73
238
  label: built
74
- ? "Compare source files and the portable context your agents would use (Recommended)"
239
+ ? "Run readiness checks on source files and Portable Context (Recommended)"
75
240
  : hasSavedRawBaseline
76
241
  ? "Rerun the source-files baseline"
77
- : "Measure the source-files baseline (Recommended)",
242
+ : "Measure the source-files baseline",
78
243
  hint: built
79
- ? "See whether the portable context helps your agents on the saved questions"
244
+ ? "See whether the Portable Context is ready for your agents on the saved checks"
80
245
  : hasSavedRawBaseline
81
- ? "Refresh the saved source-files baseline on the current questions"
82
- : "See whether the source files are already good enough before compiling",
83
- });
246
+ ? "Refresh the saved source-files baseline on the current readiness checks"
247
+ : "Optional source-files readiness baseline before Interf builds Portable Context",
248
+ };
249
+ if (built) {
250
+ options.push(testOption, compileOption);
251
+ }
252
+ else {
253
+ options.push(compileOption, testOption);
254
+ }
255
+ }
256
+ else {
257
+ options.push(compileOption);
84
258
  }
85
259
  options.push({
86
- value: "compile",
87
- label: built ? "Rebuild portable context for your agents" : "Build portable context for your agents",
88
- hint: built
89
- ? "Refresh it from the current source files"
90
- : dataset.checks.length > 0
91
- ? latestRawPasses
92
- ? "Optional: build portable context for your agents for a side-by-side comparison with the latest saved source-files run"
93
- : hasSavedRawBaseline
94
- ? "Some questions still fail on the source files. Build portable context for your agents and compare it on the same questions"
95
- : "Build portable context for your agents and compare it on the same questions"
96
- : "Build it for your agents first, then measure it",
97
- }, {
98
260
  value: "dataset",
99
- label: "Add another setup",
100
- hint: "Add a separate folder, focus, or question set",
261
+ label: "Add another Preparation",
262
+ hint: "Add a separate folder, focus, or readiness-check set",
101
263
  }, {
102
264
  value: "edit",
103
- label: "Edit questions and settings",
104
- hint: "Update questions, focus, workflow, or compile mode",
265
+ label: "Edit readiness checks and settings",
266
+ hint: "Update readiness checks, focus, Method, or prepare mode",
105
267
  }, {
106
268
  value: "workflow",
107
- label: "Create workflow",
108
- hint: "Advanced: customize the compile method",
269
+ label: "Create Method",
270
+ hint: "Advanced: customize how Interf prepares files",
109
271
  }, {
110
272
  value: "done",
111
273
  label: "Done",
@@ -121,20 +283,20 @@ async function promptDatasetAction(dataset, built, latestComparison) {
121
283
  }
122
284
  function printDatasetRecommendation(dataset, built, latestComparison) {
123
285
  if (dataset.checks.length === 0) {
124
- p.log.info("Recommended first step: save a few questions for this dataset.");
286
+ p.log.info("No readiness checks yet. You can prepare files first, then add checks when you know what evidence matters.");
125
287
  return;
126
288
  }
127
289
  if (!built) {
128
290
  if (latestComparison?.raw) {
129
291
  p.log.info(latestComparison.raw.passed_cases === latestComparison.raw.total_cases
130
- ? `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Rerun the baseline if you want current numbers for a different agent set, or build portable context for your agents if you want a side-by-side comparison.`
131
- : `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Some questions still fail on the source files. Build portable context for your agents if you want Interf to prepare context for this work and compare it on the same questions.`);
292
+ ? `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Prepare files if you want a side-by-side comparison.`
293
+ : `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Some readiness checks still fail on the source files. Prepare files if you want Interf to process this data and run the same checks.`);
132
294
  return;
133
295
  }
134
- p.log.info("Recommended first step: measure the source-files baseline before compiling.");
296
+ p.log.info("Recommended first step: choose a Method and prepare files.");
135
297
  return;
136
298
  }
137
- p.log.info("Recommended first step: compare the source-files baseline and the portable context your agents would use.");
299
+ p.log.info("Recommended first step: compare the source-files baseline and Portable Context.");
138
300
  }
139
301
  async function promptPostBaselineAction(rows) {
140
302
  const status = currentRunTargetStatus(rows, "raw");
@@ -155,28 +317,28 @@ async function promptPostBaselineAction(rows) {
155
317
  {
156
318
  value: "compile",
157
319
  label: compileRecommended
158
- ? "Build portable context for your agents (Recommended)"
159
- : "Build portable context for your agents",
320
+ ? "Prepare files and write Portable Context (Recommended)"
321
+ : "Prepare files and write Portable Context",
160
322
  hint: compileRecommended
161
323
  ? status === "mixed"
162
- ? "Some selected agents still failed on the source files. Build portable context for your agents and compare it on the same questions"
163
- : "Build portable context for your agents and compare it on the same questions"
164
- : "Build portable context for your agents and compare it on the same questions",
324
+ ? "Some selected agents still failed on the source files. Prepare files and run the same readiness checks"
325
+ : "Prepare files and run the same readiness checks"
326
+ : "Prepare files and run the same readiness checks",
165
327
  },
166
328
  {
167
329
  value: "edit",
168
- label: "Change questions and settings",
169
- hint: "Revise the questions or setup settings before the next run",
330
+ label: "Change readiness checks and settings",
331
+ hint: "Revise the readiness checks or Preparation settings before the next run",
170
332
  },
171
333
  {
172
334
  value: "rerun",
173
335
  label: "Rerun the source-files baseline",
174
- hint: "Run the same questions again, including different local agents if you want",
336
+ hint: "Run the same readiness checks again, including different local agents if you want",
175
337
  },
176
338
  {
177
339
  value: "done",
178
340
  label: "Stop here",
179
- hint: "Leave the dataset as-is for now",
341
+ hint: "Leave the Preparation as-is for now",
180
342
  },
181
343
  ],
182
344
  });
@@ -194,22 +356,22 @@ async function chooseCompiledForWizard(options) {
194
356
  if (savedEntries.length === 1)
195
357
  return savedEntries[0]?.config ?? null;
196
358
  const selected = await p.select({
197
- message: "Which source folder setup do you want to work with?",
359
+ message: "Which saved Preparation do you want to work with?",
198
360
  options: [
199
361
  ...savedEntries.map((entry) => ({
200
362
  value: entry.config.name,
201
363
  label: entry.config.name,
202
364
  hint: [
203
365
  `path ${entry.config.path}`,
204
- entry.config.about ?? describeSavedQuestions(entry.config),
205
- `workflow ${entry.config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`,
206
- entry.path ? "built" : "not built yet",
366
+ entry.config.about ?? describeSavedReadinessChecks(entry.config),
367
+ `Method ${entry.config.method ?? entry.config.workflow ?? "interf-default"}${entry.localDraft ? " (local draft)" : ""}`,
368
+ entry.path ? "Portable Context available" : "Portable Context not built yet",
207
369
  ].join(" · "),
208
370
  })),
209
371
  {
210
372
  value: "__new__",
211
- label: "Add another setup",
212
- hint: "Add a separate folder, focus, or question set",
373
+ label: "Add another Preparation",
374
+ hint: "Add a separate folder, focus, or readiness-check set",
213
375
  },
214
376
  ],
215
377
  });
@@ -220,31 +382,28 @@ async function chooseCompiledForWizard(options) {
220
382
  return findSavedCompiledConfig(options.sourcePath, String(selected));
221
383
  }
222
384
  async function promptCompiledSetup(options) {
223
- let workflowId = options.initial?.workflow ?? "interf-default";
224
- let workflowLabel = buildCompiledWorkflowOptions(options.sourcePath)
225
- .find((option) => option.value === workflowId)?.label ?? workflowId;
226
- if (options.introStyle === "edit") {
227
- const workflowChoice = await chooseCompiledWorkflow(options.sourcePath, {
228
- currentWorkflowId: workflowId,
229
- message: "Which workflow should this dataset use?",
230
- });
231
- if (p.isCancel(workflowChoice))
232
- return null;
233
- workflowId = workflowChoice;
234
- workflowLabel = buildCompiledWorkflowOptions(options.sourcePath)
235
- .find((option) => option.value === workflowId)?.label ?? workflowId;
236
- }
385
+ const savedConfig = loadSourceFolderConfig(options.sourcePath);
386
+ const fixedPath = options.fixedPath
387
+ ?? (options.fixedName ? options.initial?.path : configuredSourceFolderPath(savedConfig) ?? undefined);
237
388
  const compiledConfig = await promptSingleCompiledConfig({
238
389
  projectPath: options.sourcePath,
239
390
  initial: options.initial,
240
391
  ...(options.fixedName ? { fixedName: options.fixedName } : {}),
392
+ ...(fixedPath ? { fixedPath } : {}),
241
393
  introStyle: options.introStyle,
242
- selectedWorkflowLabel: workflowLabel,
243
394
  });
244
395
  if (!compiledConfig)
245
396
  return null;
397
+ const workflowChoice = await chooseOrCreateCompiledWorkflowForDataset(options.sourcePath, compiledConfig, {
398
+ currentWorkflowId: options.initial?.workflow ?? "interf-default",
399
+ executionProfile: options.executionProfile,
400
+ });
401
+ if (!workflowChoice || p.isCancel(workflowChoice))
402
+ return null;
403
+ const workflowId = String(workflowChoice);
246
404
  const compiledConfigWithWorkflow = {
247
405
  ...compiledConfig,
406
+ method: workflowId,
248
407
  workflow: workflowId,
249
408
  };
250
409
  upsertSourceDatasetConfig(options.sourcePath, compiledConfigWithWorkflow, {
@@ -254,13 +413,16 @@ async function promptCompiledSetup(options) {
254
413
  if (builtCompiledPath) {
255
414
  syncCompiledInterfConfigFromSourceDatasetConfig(builtCompiledPath, compiledConfigWithWorkflow);
256
415
  }
416
+ else {
417
+ ensurePortableContextScaffold(options.sourcePath, compiledConfigWithWorkflow.name, compiledConfigWithWorkflow.workflow ?? "interf-default");
418
+ }
257
419
  console.log();
258
- console.log(chalk.green(` ✓ Saved setup in ${SOURCE_FOLDER_CONFIG_FILE}`));
259
- console.log(chalk.dim(` Project folder: ${options.sourcePath}`));
260
- console.log(chalk.dim(` Setup: ${compiledConfigWithWorkflow.name}`));
420
+ console.log(chalk.green(` ✓ Saved Preparation in ${SOURCE_FOLDER_CONFIG_PATH}`));
421
+ console.log(chalk.dim(` Interf Workspace: ${options.sourcePath}`));
422
+ console.log(chalk.dim(` Preparation: ${compiledConfigWithWorkflow.name}`));
261
423
  console.log(chalk.dim(` Source folder: ${compiledConfigWithWorkflow.path}`));
262
- console.log(chalk.dim(` Workflow: ${workflowLabel} · interf/workflows/${workflowId}/`));
263
- console.log(chalk.dim(` Compile mode: ${describeCompileLoopSelection({
424
+ console.log(chalk.dim(` Method: ${workflowId} · interf/methods/${workflowId}/`));
425
+ console.log(chalk.dim(` Prepare mode: ${describeCompileLoopSelection({
264
426
  maxAttempts: compiledConfigWithWorkflow.max_attempts,
265
427
  maxLoops: compiledConfigWithWorkflow.max_loops,
266
428
  })}`));
@@ -295,7 +457,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
295
457
  if (!action)
296
458
  return;
297
459
  if (action === "done") {
298
- p.outro(options.justConfigured ? "Saved dataset setup." : "Nothing changed.");
460
+ p.outro(options.justConfigured ? "Saved Preparation." : "Nothing changed.");
299
461
  return;
300
462
  }
301
463
  if (action === "workflow") {
@@ -309,6 +471,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
309
471
  if (typeof workflowId === "string") {
310
472
  const nextConfig = {
311
473
  ...compiledConfig,
474
+ method: workflowId,
312
475
  workflow: workflowId,
313
476
  };
314
477
  upsertSourceDatasetConfig(sourcePath, nextConfig, {
@@ -318,7 +481,10 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
318
481
  if (builtCompiledPath) {
319
482
  syncCompiledInterfConfigFromSourceDatasetConfig(builtCompiledPath, nextConfig);
320
483
  }
321
- p.log.info(`Assigned workflow "${workflowId}" to dataset "${compiledConfig.name}".`);
484
+ else {
485
+ ensurePortableContextScaffold(sourcePath, nextConfig.name, nextConfig.workflow ?? "interf-default");
486
+ }
487
+ p.log.info(`Assigned Method "${workflowId}" to Preparation "${compiledConfig.name}".`);
322
488
  p.log.info("Next: run `interf compile`, then `interf test`.");
323
489
  }
324
490
  return;
@@ -349,8 +515,8 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
349
515
  if (action === "test") {
350
516
  if (compiledConfig.checks.length === 0) {
351
517
  process.exitCode = 1;
352
- console.log(chalk.red(` Setup "${compiledConfig.name}" does not have any questions yet.`));
353
- console.log(chalk.dim(" Run `interf`, edit this setup, and add a few questions first."));
518
+ console.log(chalk.red(` Preparation "${compiledConfig.name}" does not have any readiness checks yet.`));
519
+ console.log(chalk.dim(" Run `interf`, edit this Preparation, and add a few readiness checks first."));
354
520
  console.log(chalk.dim(" Then rerun `interf test`."));
355
521
  return;
356
522
  }
@@ -408,7 +574,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
408
574
  return;
409
575
  }
410
576
  if (compileResult.testedDuringCompile) {
411
- p.log.info("This compile run already checked the portable context for your agents on the saved questions.");
577
+ p.log.info("This prepare run already checked the Portable Context on the saved readiness checks.");
412
578
  p.log.info("Run `interf test` later if you want a fresh side-by-side comparison summary.");
413
579
  return;
414
580
  }
@@ -427,14 +593,14 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
427
593
  if (compiledConfig.checks.length === 0)
428
594
  return;
429
595
  if (compileResult.testedDuringCompile) {
430
- p.log.info("This compile run already checked the portable context for your agents on the compile agent.");
596
+ p.log.info("This prepare run already checked the Portable Context on the compile agent.");
431
597
  }
432
598
  const runCompiledTest = await p.confirm({
433
599
  message: compileResult.testedDuringCompile
434
- ? "Run a fresh source-files versus portable-context comparison now?"
600
+ ? "Run a fresh source-files versus Portable Context comparison now?"
435
601
  : builtCompiledPath
436
- ? "Run source files and the portable context your agents would use on the saved questions now?"
437
- : "Compare source files and the portable context your agents would use on the saved questions now?",
602
+ ? "Run readiness checks on source files and Portable Context now?"
603
+ : "Run readiness checks on source files and Portable Context now?",
438
604
  initialValue: true,
439
605
  });
440
606
  if (p.isCancel(runCompiledTest) || !runCompiledTest)
@@ -450,30 +616,119 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
450
616
  }
451
617
  export const initCommand = {
452
618
  command: "init",
453
- describe: "Open the dataset wizard for this folder",
619
+ describe: "Set up Interf or open the Preparation wizard",
454
620
  handler: async () => {
455
621
  await runInitCommand();
456
622
  },
457
623
  };
458
624
  export async function runInitCommand() {
459
625
  p.intro(chalk.bold("Interf"));
460
- p.log.info("Interf prepares portable context for your agents.");
461
- p.log.info("Pick a source folder, review the suggested questions, and build when the files need more structure.");
626
+ p.log.info("Interf prepares data for agent work.");
627
+ p.log.info("It runs locally to process files, show evidence that your data is ready, and write verifiable outputs as Portable Context for agents.");
462
628
  const cwd = process.cwd();
463
629
  const detected = detectInterf(cwd);
464
- const sourcePath = detected ? resolveSourceControlPath(detected.path) : cwd;
630
+ let initContext = detected
631
+ ? {
632
+ controlPath: resolveSourceControlPath(detected.path),
633
+ defaultSourceFolderPath: null,
634
+ defaultPreparationPath: null,
635
+ }
636
+ : resolveInterfInstanceContext(cwd);
637
+ let sourcePath = initContext.controlPath;
465
638
  if (detected) {
466
- p.log.info(`Working from the project folder: ${sourcePath}`);
639
+ p.log.info(`Working from Interf Workspace: ${sourcePath}`);
467
640
  }
468
- const seeded = seedLocalDefaultWorkflow({ sourcePath });
469
- if (!seeded.alreadyExisted) {
470
- p.log.info(`Copied built-in compilation workflow to interf/workflows/${seeded.workflowId}/ — inspect or fork it anytime.`);
641
+ const hasConfig = Boolean(loadSourceFolderConfig(sourcePath));
642
+ let initialSourceFolderPath = initContext.defaultSourceFolderPath;
643
+ let initialSourceFolderConfigPath = initContext.defaultPreparationPath;
644
+ if (!detected && !hasConfig) {
645
+ const setup = await setupInterfInstance(cwd);
646
+ if (!setup)
647
+ return;
648
+ sourcePath = setup.controlPath;
649
+ initialSourceFolderPath = setup.sourceFolderPath;
650
+ initialSourceFolderConfigPath = setup.sourceFolderConfigPath;
651
+ initContext = {
652
+ controlPath: sourcePath,
653
+ defaultSourceFolderPath: initialSourceFolderPath,
654
+ defaultPreparationPath: initialSourceFolderConfigPath,
655
+ };
656
+ }
657
+ else {
658
+ const seeded = seedLocalDefaultWorkflow({ sourcePath });
659
+ if (!seeded.alreadyExisted) {
660
+ p.log.info(`Copied built-in Method package to interf/methods/${seeded.workflowId}/. Inspect or fork it anytime.`);
661
+ }
662
+ }
663
+ let currentConfig = loadSourceFolderConfig(sourcePath);
664
+ if (!currentConfig?.source_folder && !detected) {
665
+ const currentEntries = currentConfig?.preparations ?? currentConfig?.datasets ?? [];
666
+ if (initialSourceFolderPath && initialSourceFolderConfigPath) {
667
+ saveSourceFolderConfig(sourcePath, {
668
+ source_folder: { path: initialSourceFolderConfigPath },
669
+ preparations: currentEntries,
670
+ });
671
+ currentConfig = loadSourceFolderConfig(sourcePath);
672
+ }
673
+ else if (currentConfig && currentEntries.length === 0) {
674
+ const sourceFolderPath = await promptSourceFolderForInstance(cwd);
675
+ if (!sourceFolderPath)
676
+ return;
677
+ const sourceFolderConfigPath = relativeSourceFolderPath(sourcePath, sourceFolderPath);
678
+ saveSourceFolderConfig(sourcePath, {
679
+ source_folder: { path: sourceFolderConfigPath },
680
+ preparations: [],
681
+ });
682
+ initialSourceFolderPath = sourceFolderPath;
683
+ initialSourceFolderConfigPath = sourceFolderConfigPath;
684
+ currentConfig = loadSourceFolderConfig(sourcePath);
685
+ p.log.info(`Source Folder: ${sourceFolderPath}`);
686
+ p.log.info(`Source Folder path in Interf config: ${sourceFolderConfigPath}`);
687
+ }
688
+ else if (!currentConfig) {
689
+ const setup = await setupInterfInstance(cwd);
690
+ if (!setup)
691
+ return;
692
+ sourcePath = setup.controlPath;
693
+ initialSourceFolderPath = setup.sourceFolderPath;
694
+ initialSourceFolderConfigPath = setup.sourceFolderConfigPath;
695
+ currentConfig = loadSourceFolderConfig(sourcePath);
696
+ }
697
+ }
698
+ const configuredSourcePath = resolveConfiguredSourceFolderPath(sourcePath, currentConfig);
699
+ const configuredSourceConfigPath = configuredSourceFolderPath(currentConfig);
700
+ if (configuredSourcePath && configuredSourceConfigPath) {
701
+ initialSourceFolderPath = configuredSourcePath;
702
+ initialSourceFolderConfigPath = configuredSourceConfigPath;
471
703
  }
472
704
  const savedEntries = listSavedCompiledEntries(sourcePath);
473
705
  if (savedEntries.length === 0) {
706
+ p.log.info("No Preparations yet. Create one when you are ready to describe the agent work.");
707
+ const action = await promptEmptyInstanceAction();
708
+ if (!action || action === "done") {
709
+ p.outro("Interf Workspace is ready. Next: run `interf web` or `interf create preparation`.");
710
+ return;
711
+ }
712
+ if (action === "web") {
713
+ await runWebCommand({ "control-path": sourcePath });
714
+ return;
715
+ }
716
+ if (action === "method") {
717
+ const workflowId = await createWorkflowWizard({ sourcePath });
718
+ if (typeof workflowId === "string") {
719
+ p.outro(`Saved Method "${workflowId}". Next: create a Preparation and assign this Method.`);
720
+ }
721
+ return;
722
+ }
474
723
  const compiledConfig = await promptCompiledSetup({
475
724
  sourcePath,
476
- initial: { name: DEFAULT_COMPILED_NAME },
725
+ initial: initialSourceFolderPath && initialSourceFolderConfigPath
726
+ ? {
727
+ name: defaultDatasetNameForPath(initialSourceFolderPath),
728
+ path: initialSourceFolderConfigPath,
729
+ }
730
+ : { name: DEFAULT_COMPILED_NAME },
731
+ ...(initialSourceFolderConfigPath ? { fixedPath: initialSourceFolderConfigPath } : {}),
477
732
  introStyle: "first",
478
733
  });
479
734
  if (!compiledConfig)
@@ -490,7 +745,13 @@ export async function runInitCommand() {
490
745
  if (selectedCompiled === "__new__") {
491
746
  const compiledConfig = await promptCompiledSetup({
492
747
  sourcePath,
493
- initial: { name: DEFAULT_COMPILED_NAME },
748
+ initial: initialSourceFolderPath && initialSourceFolderConfigPath
749
+ ? {
750
+ name: defaultDatasetNameForPath(initialSourceFolderPath),
751
+ path: initialSourceFolderConfigPath,
752
+ }
753
+ : { name: DEFAULT_COMPILED_NAME },
754
+ ...(initialSourceFolderConfigPath ? { fixedPath: initialSourceFolderConfigPath } : {}),
494
755
  introStyle: "additional",
495
756
  });
496
757
  if (!compiledConfig)