@interf/compiler 0.7.3 → 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 (302) hide show
  1. package/README.md +123 -89
  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 +4 -4
  33. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +1 -1
  34. package/builtin-workflows/interf/improve/SKILL.md +1 -1
  35. package/builtin-workflows/interf/use/query/SKILL.md +1 -1
  36. package/builtin-workflows/interf/workflow.json +8 -8
  37. package/builtin-workflows/interf/workflow.schema.json +1 -1
  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 +6 -0
  48. package/dist/cli/commands/create-workflow-wizard.js +191 -77
  49. package/dist/cli/commands/create.js +54 -40
  50. package/dist/cli/commands/default.js +4 -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 +326 -76
  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 -3
  59. package/dist/cli/commands/source-config-wizard.js +175 -197
  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 +31 -31
  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 +45 -96
  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 +7 -1
  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 +6 -6
  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 +25 -10
  129. package/dist/packages/project-model/interf-scaffold.js +9 -6
  130. package/dist/packages/project-model/interf.d.ts +1 -1
  131. package/dist/packages/project-model/interf.js +1 -1
  132. package/dist/packages/project-model/lib/schema.d.ts +80 -6
  133. package/dist/packages/project-model/lib/schema.js +29 -19
  134. package/dist/packages/project-model/source-config.d.ts +22 -13
  135. package/dist/packages/project-model/source-config.js +140 -123
  136. package/dist/packages/project-model/source-folders.d.ts +11 -0
  137. package/dist/packages/project-model/source-folders.js +110 -0
  138. package/dist/packages/testing/test-execution.js +5 -5
  139. package/dist/packages/testing/test-paths.js +1 -3
  140. package/dist/packages/workflow-authoring/workflow-authoring.d.ts +4 -6
  141. package/dist/packages/workflow-authoring/workflow-authoring.js +45 -86
  142. package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +2 -0
  143. package/dist/packages/workflow-authoring/workflow-edit-session.js +80 -49
  144. package/dist/packages/workflow-authoring/workflow-improvement.js +2 -1
  145. package/dist/packages/workflow-package/context-interface.js +1 -1
  146. package/dist/packages/workflow-package/interf-workflow-package.d.ts +6 -0
  147. package/dist/packages/workflow-package/interf-workflow-package.js +115 -8
  148. package/dist/packages/workflow-package/local-workflows.js +33 -17
  149. package/dist/packages/workflow-package/workflow-definitions.d.ts +5 -5
  150. package/dist/packages/workflow-package/workflow-definitions.js +23 -22
  151. package/dist/packages/workflow-package/workflow-helpers.js +10 -6
  152. package/dist/packages/workflow-package/workflow-stage-runner.d.ts +1 -0
  153. package/dist/packages/workflow-package/workflow-stage-runner.js +2 -0
  154. package/package.json +17 -1
  155. package/dist/cli/commands/dataset-selection.d.ts +0 -6
  156. package/dist/cli/commands/dataset-selection.js +0 -11
  157. package/dist/lib/agent-args.d.ts +0 -1
  158. package/dist/lib/agent-args.js +0 -1
  159. package/dist/lib/agent-constants.d.ts +0 -1
  160. package/dist/lib/agent-constants.js +0 -1
  161. package/dist/lib/agent-detection.d.ts +0 -1
  162. package/dist/lib/agent-detection.js +0 -1
  163. package/dist/lib/agent-execution.d.ts +0 -1
  164. package/dist/lib/agent-execution.js +0 -1
  165. package/dist/lib/agent-logs.d.ts +0 -1
  166. package/dist/lib/agent-logs.js +0 -1
  167. package/dist/lib/agent-preflight.d.ts +0 -1
  168. package/dist/lib/agent-preflight.js +0 -1
  169. package/dist/lib/agent-render.d.ts +0 -1
  170. package/dist/lib/agent-render.js +0 -1
  171. package/dist/lib/agent-shells.d.ts +0 -1
  172. package/dist/lib/agent-shells.js +0 -1
  173. package/dist/lib/agent-status.d.ts +0 -1
  174. package/dist/lib/agent-status.js +0 -1
  175. package/dist/lib/agent-types.d.ts +0 -1
  176. package/dist/lib/agent-types.js +0 -1
  177. package/dist/lib/agents.d.ts +0 -1
  178. package/dist/lib/agents.js +0 -1
  179. package/dist/lib/builtin-compiled-workflow.d.ts +0 -1
  180. package/dist/lib/builtin-compiled-workflow.js +0 -1
  181. package/dist/lib/chart-guidance.d.ts +0 -1
  182. package/dist/lib/chart-guidance.js +0 -1
  183. package/dist/lib/compiled-compile.d.ts +0 -1
  184. package/dist/lib/compiled-compile.js +0 -1
  185. package/dist/lib/compiled-paths.d.ts +0 -1
  186. package/dist/lib/compiled-paths.js +0 -3
  187. package/dist/lib/compiled-raw.d.ts +0 -1
  188. package/dist/lib/compiled-raw.js +0 -3
  189. package/dist/lib/compiled-reset.d.ts +0 -1
  190. package/dist/lib/compiled-reset.js +0 -3
  191. package/dist/lib/compiled-schema.d.ts +0 -1
  192. package/dist/lib/compiled-schema.js +0 -1
  193. package/dist/lib/discovery.d.ts +0 -1
  194. package/dist/lib/discovery.js +0 -1
  195. package/dist/lib/execution-profile.d.ts +0 -1
  196. package/dist/lib/execution-profile.js +0 -1
  197. package/dist/lib/executors.d.ts +0 -1
  198. package/dist/lib/executors.js +0 -1
  199. package/dist/lib/filesystem.d.ts +0 -1
  200. package/dist/lib/filesystem.js +0 -1
  201. package/dist/lib/interf-bootstrap.d.ts +0 -1
  202. package/dist/lib/interf-bootstrap.js +0 -3
  203. package/dist/lib/interf-detect.d.ts +0 -1
  204. package/dist/lib/interf-detect.js +0 -3
  205. package/dist/lib/interf-scaffold.d.ts +0 -1
  206. package/dist/lib/interf-scaffold.js +0 -3
  207. package/dist/lib/interf-workflow-package.d.ts +0 -1
  208. package/dist/lib/interf-workflow-package.js +0 -1
  209. package/dist/lib/interf.d.ts +0 -1
  210. package/dist/lib/interf.js +0 -3
  211. package/dist/lib/local-workflows.d.ts +0 -1
  212. package/dist/lib/local-workflows.js +0 -1
  213. package/dist/lib/logger.d.ts +0 -1
  214. package/dist/lib/logger.js +0 -1
  215. package/dist/lib/package-root.d.ts +0 -1
  216. package/dist/lib/package-root.js +0 -1
  217. package/dist/lib/parse.d.ts +0 -1
  218. package/dist/lib/parse.js +0 -1
  219. package/dist/lib/project-paths.d.ts +0 -1
  220. package/dist/lib/project-paths.js +0 -3
  221. package/dist/lib/runtime-acceptance.d.ts +0 -1
  222. package/dist/lib/runtime-acceptance.js +0 -1
  223. package/dist/lib/runtime-contracts.d.ts +0 -1
  224. package/dist/lib/runtime-contracts.js +0 -1
  225. package/dist/lib/runtime-inventory.d.ts +0 -1
  226. package/dist/lib/runtime-inventory.js +0 -1
  227. package/dist/lib/runtime-paths.d.ts +0 -1
  228. package/dist/lib/runtime-paths.js +0 -1
  229. package/dist/lib/runtime-prompt.d.ts +0 -1
  230. package/dist/lib/runtime-prompt.js +0 -1
  231. package/dist/lib/runtime-reconcile.d.ts +0 -1
  232. package/dist/lib/runtime-reconcile.js +0 -1
  233. package/dist/lib/runtime-runs.d.ts +0 -1
  234. package/dist/lib/runtime-runs.js +0 -1
  235. package/dist/lib/runtime-types.d.ts +0 -1
  236. package/dist/lib/runtime-types.js +0 -1
  237. package/dist/lib/runtime.d.ts +0 -1
  238. package/dist/lib/runtime.js +0 -1
  239. package/dist/lib/schema.d.ts +0 -4
  240. package/dist/lib/schema.js +0 -6
  241. package/dist/lib/source-config.d.ts +0 -1
  242. package/dist/lib/source-config.js +0 -3
  243. package/dist/lib/state-artifacts.d.ts +0 -1
  244. package/dist/lib/state-artifacts.js +0 -1
  245. package/dist/lib/state-health.d.ts +0 -1
  246. package/dist/lib/state-health.js +0 -1
  247. package/dist/lib/state-io.d.ts +0 -1
  248. package/dist/lib/state-io.js +0 -1
  249. package/dist/lib/state-paths.d.ts +0 -1
  250. package/dist/lib/state-paths.js +0 -1
  251. package/dist/lib/state-view.d.ts +0 -1
  252. package/dist/lib/state-view.js +0 -1
  253. package/dist/lib/state.d.ts +0 -1
  254. package/dist/lib/state.js +0 -1
  255. package/dist/lib/test-execution.d.ts +0 -1
  256. package/dist/lib/test-execution.js +0 -3
  257. package/dist/lib/test-matrices.d.ts +0 -1
  258. package/dist/lib/test-matrices.js +0 -3
  259. package/dist/lib/test-paths.d.ts +0 -1
  260. package/dist/lib/test-paths.js +0 -3
  261. package/dist/lib/test-profile-presets.d.ts +0 -1
  262. package/dist/lib/test-profile-presets.js +0 -3
  263. package/dist/lib/test-sandbox.d.ts +0 -1
  264. package/dist/lib/test-sandbox.js +0 -3
  265. package/dist/lib/test-specs.d.ts +0 -1
  266. package/dist/lib/test-specs.js +0 -3
  267. package/dist/lib/test-targets.d.ts +0 -1
  268. package/dist/lib/test-targets.js +0 -3
  269. package/dist/lib/test-types.d.ts +0 -1
  270. package/dist/lib/test-types.js +0 -3
  271. package/dist/lib/test.d.ts +0 -1
  272. package/dist/lib/test.js +0 -3
  273. package/dist/lib/util.d.ts +0 -1
  274. package/dist/lib/util.js +0 -1
  275. package/dist/lib/validate-compiled.d.ts +0 -1
  276. package/dist/lib/validate-compiled.js +0 -1
  277. package/dist/lib/validate-helpers.d.ts +0 -1
  278. package/dist/lib/validate-helpers.js +0 -1
  279. package/dist/lib/validate.d.ts +0 -1
  280. package/dist/lib/validate.js +0 -1
  281. package/dist/lib/workflow-authoring.d.ts +0 -1
  282. package/dist/lib/workflow-authoring.js +0 -1
  283. package/dist/lib/workflow-definitions.d.ts +0 -1
  284. package/dist/lib/workflow-definitions.js +0 -1
  285. package/dist/lib/workflow-edit-session.d.ts +0 -1
  286. package/dist/lib/workflow-edit-session.js +0 -1
  287. package/dist/lib/workflow-edit-utils.d.ts +0 -1
  288. package/dist/lib/workflow-edit-utils.js +0 -1
  289. package/dist/lib/workflow-helpers.d.ts +0 -1
  290. package/dist/lib/workflow-helpers.js +0 -1
  291. package/dist/lib/workflow-improvement.d.ts +0 -1
  292. package/dist/lib/workflow-improvement.js +0 -1
  293. package/dist/lib/workflow-primitives.d.ts +0 -1
  294. package/dist/lib/workflow-primitives.js +0 -1
  295. package/dist/lib/workflow-review-paths.d.ts +0 -1
  296. package/dist/lib/workflow-review-paths.js +0 -1
  297. package/dist/lib/workflow-stage-policy.d.ts +0 -1
  298. package/dist/lib/workflow-stage-policy.js +0 -1
  299. package/dist/lib/workflow-stage-runner.d.ts +0 -1
  300. package/dist/lib/workflow-stage-runner.js +0 -1
  301. package/dist/lib/workflows.d.ts +0 -1
  302. 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, ensurePortableContextScaffold, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
5
- import { SOURCE_FOLDER_CONFIG_PATH, migrateLegacySourceFolderConfig, syncCompiledInterfConfigFromSourceDatasetConfig, upsertSourceDatasetConfig, } from "../../packages/project-model/source-config.js";
6
- import { DEFAULT_COMPILED_NAME, describeCompileLoopSelection, promptSingleCompiledConfig, } from "./source-config-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";
7
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 ${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) {
@@ -69,30 +221,30 @@ async function promptDatasetAction(dataset, built, latestComparison) {
69
221
  latestComparison.raw.passed_cases === latestComparison.raw.total_cases;
70
222
  const compileOption = {
71
223
  value: "compile",
72
- label: built ? "Rebuild portable context agents can use" : "Build portable context agents can use (Recommended)",
224
+ label: built ? "Prepare again and refresh Portable Context" : "Prepare files and write Portable Context (Recommended)",
73
225
  hint: built
74
226
  ? "Refresh it from the current source files"
75
227
  : dataset.checks.length > 0
76
228
  ? latestRawPasses
77
- ? "Build portable context agents can use for a side-by-side comparison with the latest saved source-files run"
229
+ ? "Prepare files for a side-by-side comparison with the latest saved source-files run"
78
230
  : hasSavedRawBaseline
79
- ? "Some questions still fail on the source files. Build portable context agents can use and compare it on the same questions"
80
- : "Run the selected workflow and write portable context agents can use"
81
- : "Build it for agents first, then measure it",
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",
82
234
  };
83
235
  if (dataset.checks.length > 0) {
84
236
  const testOption = {
85
237
  value: "test",
86
238
  label: built
87
- ? "Compare source files and portable context (Recommended)"
239
+ ? "Run readiness checks on source files and Portable Context (Recommended)"
88
240
  : hasSavedRawBaseline
89
241
  ? "Rerun the source-files baseline"
90
242
  : "Measure the source-files baseline",
91
243
  hint: built
92
- ? "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"
93
245
  : hasSavedRawBaseline
94
- ? "Refresh the saved source-files baseline on the current questions"
95
- : "Optional benchmark before Interf builds portable context",
246
+ ? "Refresh the saved source-files baseline on the current readiness checks"
247
+ : "Optional source-files readiness baseline before Interf builds Portable Context",
96
248
  };
97
249
  if (built) {
98
250
  options.push(testOption, compileOption);
@@ -106,16 +258,16 @@ async function promptDatasetAction(dataset, built, latestComparison) {
106
258
  }
107
259
  options.push({
108
260
  value: "dataset",
109
- label: "Add another setup",
110
- 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",
111
263
  }, {
112
264
  value: "edit",
113
- label: "Edit questions and settings",
114
- 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",
115
267
  }, {
116
268
  value: "workflow",
117
- label: "Create workflow",
118
- hint: "Advanced: customize the compile method",
269
+ label: "Create Method",
270
+ hint: "Advanced: customize how Interf prepares files",
119
271
  }, {
120
272
  value: "done",
121
273
  label: "Done",
@@ -131,20 +283,20 @@ async function promptDatasetAction(dataset, built, latestComparison) {
131
283
  }
132
284
  function printDatasetRecommendation(dataset, built, latestComparison) {
133
285
  if (dataset.checks.length === 0) {
134
- 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.");
135
287
  return;
136
288
  }
137
289
  if (!built) {
138
290
  if (latestComparison?.raw) {
139
291
  p.log.info(latestComparison.raw.passed_cases === latestComparison.raw.total_cases
140
- ? `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Build portable context agents can use if you want a side-by-side comparison.`
141
- : `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Some questions still fail on the source files. Build portable context agents can use if you want Interf to process this data 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.`);
142
294
  return;
143
295
  }
144
- p.log.info("Recommended first step: choose a workflow and build portable context agents can use.");
296
+ p.log.info("Recommended first step: choose a Method and prepare files.");
145
297
  return;
146
298
  }
147
- p.log.info("Recommended first step: compare the source-files baseline and portable context.");
299
+ p.log.info("Recommended first step: compare the source-files baseline and Portable Context.");
148
300
  }
149
301
  async function promptPostBaselineAction(rows) {
150
302
  const status = currentRunTargetStatus(rows, "raw");
@@ -165,28 +317,28 @@ async function promptPostBaselineAction(rows) {
165
317
  {
166
318
  value: "compile",
167
319
  label: compileRecommended
168
- ? "Build portable context agents can use (Recommended)"
169
- : "Build portable context agents can use",
320
+ ? "Prepare files and write Portable Context (Recommended)"
321
+ : "Prepare files and write Portable Context",
170
322
  hint: compileRecommended
171
323
  ? status === "mixed"
172
- ? "Some selected agents still failed on the source files. Build portable context agents can use and compare it on the same questions"
173
- : "Build portable context agents can use and compare it on the same questions"
174
- : "Build portable context agents can use 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",
175
327
  },
176
328
  {
177
329
  value: "edit",
178
- label: "Change questions and settings",
179
- 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",
180
332
  },
181
333
  {
182
334
  value: "rerun",
183
335
  label: "Rerun the source-files baseline",
184
- 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",
185
337
  },
186
338
  {
187
339
  value: "done",
188
340
  label: "Stop here",
189
- hint: "Leave the dataset as-is for now",
341
+ hint: "Leave the Preparation as-is for now",
190
342
  },
191
343
  ],
192
344
  });
@@ -204,22 +356,22 @@ async function chooseCompiledForWizard(options) {
204
356
  if (savedEntries.length === 1)
205
357
  return savedEntries[0]?.config ?? null;
206
358
  const selected = await p.select({
207
- message: "Which source folder setup do you want to work with?",
359
+ message: "Which saved Preparation do you want to work with?",
208
360
  options: [
209
361
  ...savedEntries.map((entry) => ({
210
362
  value: entry.config.name,
211
363
  label: entry.config.name,
212
364
  hint: [
213
365
  `path ${entry.config.path}`,
214
- entry.config.about ?? describeSavedQuestions(entry.config),
215
- `workflow ${entry.config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`,
216
- 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",
217
369
  ].join(" · "),
218
370
  })),
219
371
  {
220
372
  value: "__new__",
221
- label: "Add another setup",
222
- 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",
223
375
  },
224
376
  ],
225
377
  });
@@ -230,10 +382,14 @@ async function chooseCompiledForWizard(options) {
230
382
  return findSavedCompiledConfig(options.sourcePath, String(selected));
231
383
  }
232
384
  async function promptCompiledSetup(options) {
385
+ const savedConfig = loadSourceFolderConfig(options.sourcePath);
386
+ const fixedPath = options.fixedPath
387
+ ?? (options.fixedName ? options.initial?.path : configuredSourceFolderPath(savedConfig) ?? undefined);
233
388
  const compiledConfig = await promptSingleCompiledConfig({
234
389
  projectPath: options.sourcePath,
235
390
  initial: options.initial,
236
391
  ...(options.fixedName ? { fixedName: options.fixedName } : {}),
392
+ ...(fixedPath ? { fixedPath } : {}),
237
393
  introStyle: options.introStyle,
238
394
  });
239
395
  if (!compiledConfig)
@@ -247,6 +403,7 @@ async function promptCompiledSetup(options) {
247
403
  const workflowId = String(workflowChoice);
248
404
  const compiledConfigWithWorkflow = {
249
405
  ...compiledConfig,
406
+ method: workflowId,
250
407
  workflow: workflowId,
251
408
  };
252
409
  upsertSourceDatasetConfig(options.sourcePath, compiledConfigWithWorkflow, {
@@ -260,12 +417,12 @@ async function promptCompiledSetup(options) {
260
417
  ensurePortableContextScaffold(options.sourcePath, compiledConfigWithWorkflow.name, compiledConfigWithWorkflow.workflow ?? "interf-default");
261
418
  }
262
419
  console.log();
263
- console.log(chalk.green(` ✓ Saved setup in ${SOURCE_FOLDER_CONFIG_PATH}`));
264
- console.log(chalk.dim(` Project folder: ${options.sourcePath}`));
265
- 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}`));
266
423
  console.log(chalk.dim(` Source folder: ${compiledConfigWithWorkflow.path}`));
267
- console.log(chalk.dim(` Workflow: ${workflowId} · interf/workflows/${workflowId}/`));
268
- 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({
269
426
  maxAttempts: compiledConfigWithWorkflow.max_attempts,
270
427
  maxLoops: compiledConfigWithWorkflow.max_loops,
271
428
  })}`));
@@ -300,7 +457,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
300
457
  if (!action)
301
458
  return;
302
459
  if (action === "done") {
303
- p.outro(options.justConfigured ? "Saved dataset setup." : "Nothing changed.");
460
+ p.outro(options.justConfigured ? "Saved Preparation." : "Nothing changed.");
304
461
  return;
305
462
  }
306
463
  if (action === "workflow") {
@@ -314,6 +471,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
314
471
  if (typeof workflowId === "string") {
315
472
  const nextConfig = {
316
473
  ...compiledConfig,
474
+ method: workflowId,
317
475
  workflow: workflowId,
318
476
  };
319
477
  upsertSourceDatasetConfig(sourcePath, nextConfig, {
@@ -326,7 +484,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
326
484
  else {
327
485
  ensurePortableContextScaffold(sourcePath, nextConfig.name, nextConfig.workflow ?? "interf-default");
328
486
  }
329
- p.log.info(`Assigned workflow "${workflowId}" to dataset "${compiledConfig.name}".`);
487
+ p.log.info(`Assigned Method "${workflowId}" to Preparation "${compiledConfig.name}".`);
330
488
  p.log.info("Next: run `interf compile`, then `interf test`.");
331
489
  }
332
490
  return;
@@ -357,8 +515,8 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
357
515
  if (action === "test") {
358
516
  if (compiledConfig.checks.length === 0) {
359
517
  process.exitCode = 1;
360
- console.log(chalk.red(` Setup "${compiledConfig.name}" does not have any questions yet.`));
361
- 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."));
362
520
  console.log(chalk.dim(" Then rerun `interf test`."));
363
521
  return;
364
522
  }
@@ -416,7 +574,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
416
574
  return;
417
575
  }
418
576
  if (compileResult.testedDuringCompile) {
419
- p.log.info("This compile run already checked the portable context on the saved questions.");
577
+ p.log.info("This prepare run already checked the Portable Context on the saved readiness checks.");
420
578
  p.log.info("Run `interf test` later if you want a fresh side-by-side comparison summary.");
421
579
  return;
422
580
  }
@@ -435,14 +593,14 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
435
593
  if (compiledConfig.checks.length === 0)
436
594
  return;
437
595
  if (compileResult.testedDuringCompile) {
438
- p.log.info("This compile run already checked the portable context on the compile agent.");
596
+ p.log.info("This prepare run already checked the Portable Context on the compile agent.");
439
597
  }
440
598
  const runCompiledTest = await p.confirm({
441
599
  message: compileResult.testedDuringCompile
442
- ? "Run a fresh source-files versus portable-context comparison now?"
600
+ ? "Run a fresh source-files versus Portable Context comparison now?"
443
601
  : builtCompiledPath
444
- ? "Run source files and portable context on the saved questions now?"
445
- : "Compare source files and portable context 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?",
446
604
  initialValue: true,
447
605
  });
448
606
  if (p.isCancel(runCompiledTest) || !runCompiledTest)
@@ -458,7 +616,7 @@ async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
458
616
  }
459
617
  export const initCommand = {
460
618
  command: "init",
461
- describe: "Open the dataset wizard for this folder",
619
+ describe: "Set up Interf or open the Preparation wizard",
462
620
  handler: async () => {
463
621
  await runInitCommand();
464
622
  },
@@ -466,25 +624,111 @@ export const initCommand = {
466
624
  export async function runInitCommand() {
467
625
  p.intro(chalk.bold("Interf"));
468
626
  p.log.info("Interf prepares data for agent work.");
469
- p.log.info("Run locally, process files, show evidence that your data is ready, and write verifiable outputs as portable context for agents.");
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.");
470
628
  const cwd = process.cwd();
471
629
  const detected = detectInterf(cwd);
472
- 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;
473
638
  if (detected) {
474
- p.log.info(`Working from the project folder: ${sourcePath}`);
639
+ p.log.info(`Working from Interf Workspace: ${sourcePath}`);
475
640
  }
476
- if (migrateLegacySourceFolderConfig(sourcePath)) {
477
- p.log.info(`Moved saved setup to ${SOURCE_FOLDER_CONFIG_PATH}.`);
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
+ };
478
656
  }
479
- const seeded = seedLocalDefaultWorkflow({ sourcePath });
480
- if (!seeded.alreadyExisted) {
481
- p.log.info(`Copied built-in workflow package to interf/workflows/${seeded.workflowId}/ — inspect or fork it anytime.`);
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;
482
703
  }
483
704
  const savedEntries = listSavedCompiledEntries(sourcePath);
484
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
+ }
485
723
  const compiledConfig = await promptCompiledSetup({
486
724
  sourcePath,
487
- 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 } : {}),
488
732
  introStyle: "first",
489
733
  });
490
734
  if (!compiledConfig)
@@ -501,7 +745,13 @@ export async function runInitCommand() {
501
745
  if (selectedCompiled === "__new__") {
502
746
  const compiledConfig = await promptCompiledSetup({
503
747
  sourcePath,
504
- 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 } : {}),
505
755
  introStyle: "additional",
506
756
  });
507
757
  if (!compiledConfig)