@interf/compiler 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +71 -69
  2. package/builtin-workflows/interf/README.md +6 -6
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
  6. package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
  7. package/builtin-workflows/interf/improve/SKILL.md +3 -3
  8. package/builtin-workflows/interf/use/query/SKILL.md +2 -2
  9. package/builtin-workflows/interf/workflow.json +42 -31
  10. package/dist/commands/check-draft.d.ts +19 -0
  11. package/dist/commands/check-draft.js +110 -0
  12. package/dist/commands/compile-controller.d.ts +4 -4
  13. package/dist/commands/compile-controller.js +117 -81
  14. package/dist/commands/compile.d.ts +5 -5
  15. package/dist/commands/compile.js +61 -62
  16. package/dist/commands/compiled-flow.d.ts +23 -0
  17. package/dist/commands/compiled-flow.js +112 -0
  18. package/dist/commands/create-workflow-wizard.d.ts +3 -3
  19. package/dist/commands/create-workflow-wizard.js +11 -11
  20. package/dist/commands/create.d.ts +2 -2
  21. package/dist/commands/create.js +50 -57
  22. package/dist/commands/default.js +2 -2
  23. package/dist/commands/executor-flow.d.ts +20 -1
  24. package/dist/commands/executor-flow.js +67 -7
  25. package/dist/commands/init.js +242 -289
  26. package/dist/commands/list.js +14 -10
  27. package/dist/commands/reset.js +6 -6
  28. package/dist/commands/source-config-wizard.d.ts +12 -8
  29. package/dist/commands/source-config-wizard.js +356 -119
  30. package/dist/commands/status.js +49 -26
  31. package/dist/commands/test-flow.d.ts +23 -10
  32. package/dist/commands/test-flow.js +278 -58
  33. package/dist/commands/test.d.ts +7 -1
  34. package/dist/commands/test.js +264 -65
  35. package/dist/commands/verify.js +23 -14
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +4 -4
  38. package/dist/lib/agent-args.js +2 -1
  39. package/dist/lib/agent-constants.js +1 -1
  40. package/dist/lib/agent-render.js +4 -4
  41. package/dist/lib/agent-shells.d.ts +8 -8
  42. package/dist/lib/agent-shells.js +231 -142
  43. package/dist/lib/compiled-compile.d.ts +52 -0
  44. package/dist/lib/compiled-compile.js +274 -0
  45. package/dist/lib/compiled-home.d.ts +5 -0
  46. package/dist/lib/compiled-home.js +32 -0
  47. package/dist/lib/compiled-layout.d.ts +2 -0
  48. package/dist/lib/compiled-layout.js +60 -0
  49. package/dist/lib/compiled-paths.d.ts +41 -0
  50. package/dist/lib/compiled-paths.js +111 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
  52. package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
  53. package/dist/lib/compiled-reset.d.ts +1 -0
  54. package/dist/lib/compiled-reset.js +44 -0
  55. package/dist/lib/compiled-schema.d.ts +27 -0
  56. package/dist/lib/compiled-schema.js +110 -0
  57. package/dist/lib/config.d.ts +0 -1
  58. package/dist/lib/config.js +0 -1
  59. package/dist/lib/discovery.d.ts +1 -1
  60. package/dist/lib/discovery.js +3 -3
  61. package/dist/lib/interf-bootstrap.d.ts +1 -1
  62. package/dist/lib/interf-bootstrap.js +4 -4
  63. package/dist/lib/interf-detect.d.ts +10 -10
  64. package/dist/lib/interf-detect.js +78 -56
  65. package/dist/lib/interf-scaffold.d.ts +2 -2
  66. package/dist/lib/interf-scaffold.js +90 -57
  67. package/dist/lib/interf-workflow-package.d.ts +3 -3
  68. package/dist/lib/interf-workflow-package.js +30 -30
  69. package/dist/lib/interf.d.ts +5 -5
  70. package/dist/lib/interf.js +4 -4
  71. package/dist/lib/local-workflows.d.ts +4 -4
  72. package/dist/lib/local-workflows.js +35 -70
  73. package/dist/lib/obsidian.d.ts +1 -1
  74. package/dist/lib/parse.js +92 -1
  75. package/dist/lib/project-paths.d.ts +13 -0
  76. package/dist/lib/project-paths.js +29 -0
  77. package/dist/lib/runtime-acceptance.d.ts +7 -1
  78. package/dist/lib/runtime-acceptance.js +194 -59
  79. package/dist/lib/runtime-contracts.d.ts +2 -4
  80. package/dist/lib/runtime-contracts.js +17 -161
  81. package/dist/lib/runtime-inventory.d.ts +7 -0
  82. package/dist/lib/runtime-inventory.js +29 -0
  83. package/dist/lib/runtime-paths.js +5 -5
  84. package/dist/lib/runtime-prompt.js +9 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +92 -171
  87. package/dist/lib/runtime-runs.js +30 -39
  88. package/dist/lib/runtime-types.d.ts +10 -19
  89. package/dist/lib/runtime.d.ts +2 -2
  90. package/dist/lib/runtime.js +1 -1
  91. package/dist/lib/schema.d.ts +163 -140
  92. package/dist/lib/schema.js +163 -124
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +154 -116
  95. package/dist/lib/state-artifacts.d.ts +5 -5
  96. package/dist/lib/state-artifacts.js +8 -8
  97. package/dist/lib/state-health.d.ts +4 -4
  98. package/dist/lib/state-health.js +108 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +77 -50
  101. package/dist/lib/state-paths.js +5 -5
  102. package/dist/lib/state-view.d.ts +4 -4
  103. package/dist/lib/state-view.js +52 -55
  104. package/dist/lib/state.d.ts +5 -5
  105. package/dist/lib/state.js +4 -4
  106. package/dist/lib/summarize-plan.d.ts +3 -2
  107. package/dist/lib/summarize-plan.js +18 -16
  108. package/dist/lib/test-execution.js +9 -9
  109. package/dist/lib/test-matrices.d.ts +3 -3
  110. package/dist/lib/test-matrices.js +6 -6
  111. package/dist/lib/test-paths.d.ts +4 -4
  112. package/dist/lib/test-paths.js +16 -10
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +38 -31
  115. package/dist/lib/test-targets.d.ts +2 -2
  116. package/dist/lib/test-targets.js +11 -11
  117. package/dist/lib/test-types.d.ts +1 -1
  118. package/dist/lib/test.d.ts +1 -1
  119. package/dist/lib/test.js +1 -1
  120. package/dist/lib/util.d.ts +2 -0
  121. package/dist/lib/util.js +14 -1
  122. package/dist/lib/validate-compiled.d.ts +27 -0
  123. package/dist/lib/validate-compiled.js +236 -0
  124. package/dist/lib/validate-helpers.d.ts +0 -8
  125. package/dist/lib/validate-helpers.js +0 -30
  126. package/dist/lib/validate.d.ts +4 -4
  127. package/dist/lib/validate.js +49 -15
  128. package/dist/lib/workflow-abi.d.ts +37 -46
  129. package/dist/lib/workflow-abi.js +51 -76
  130. package/dist/lib/workflow-definitions.d.ts +11 -11
  131. package/dist/lib/workflow-definitions.js +36 -53
  132. package/dist/lib/workflow-helpers.d.ts +2 -3
  133. package/dist/lib/workflow-helpers.js +9 -13
  134. package/dist/lib/workflow-improvement.d.ts +3 -3
  135. package/dist/lib/workflow-improvement.js +48 -48
  136. package/dist/lib/workflow-review-paths.d.ts +3 -3
  137. package/dist/lib/workflow-review-paths.js +11 -11
  138. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  139. package/dist/lib/workflow-stage-runner.js +8 -8
  140. package/dist/lib/workflows.d.ts +9 -9
  141. package/dist/lib/workflows.js +15 -17
  142. package/package.json +10 -9
  143. package/dist/commands/workspace-flow.d.ts +0 -23
  144. package/dist/commands/workspace-flow.js +0 -109
  145. package/dist/lib/registry.d.ts +0 -16
  146. package/dist/lib/registry.js +0 -65
  147. package/dist/lib/validate-workspace.d.ts +0 -121
  148. package/dist/lib/validate-workspace.js +0 -407
  149. package/dist/lib/workspace-compile.d.ts +0 -54
  150. package/dist/lib/workspace-compile.js +0 -476
  151. package/dist/lib/workspace-home.d.ts +0 -5
  152. package/dist/lib/workspace-home.js +0 -32
  153. package/dist/lib/workspace-layout.d.ts +0 -2
  154. package/dist/lib/workspace-layout.js +0 -60
  155. package/dist/lib/workspace-paths.d.ts +0 -41
  156. package/dist/lib/workspace-paths.js +0 -107
  157. package/dist/lib/workspace-reset.d.ts +0 -1
  158. package/dist/lib/workspace-reset.js +0 -43
  159. package/dist/lib/workspace-schema.d.ts +0 -17
  160. package/dist/lib/workspace-schema.js +0 -74
@@ -1,23 +1,22 @@
1
1
  import chalk from "chalk";
2
2
  import * as p from "@clack/prompts";
3
3
  import { detectInterf, readInterfConfig, resolveSourceControlPath, } from "../lib/interf.js";
4
- import { sourceWorkspaceConfigFromInterfConfig, } from "../lib/source-config.js";
4
+ import { sourceDatasetConfigFromInterfConfig, } from "../lib/source-config.js";
5
5
  import { addExecutionProfileOptions, executionProfileFromArgv, } from "../lib/execution-profile.js";
6
- import { chooseWorkspaceConfigToBuild, ensureWorkspaceFromConfig, } from "./workspace-flow.js";
6
+ import { chooseCompiledConfigToBuild, ensureCompiledFromConfig, } from "./compiled-flow.js";
7
7
  import { promptCompileLoopSelection, } from "./source-config-wizard.js";
8
8
  import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
9
- import { runConfiguredWorkspaceCompile } from "./compile-controller.js";
10
- export { runConfiguredWorkspaceCompile } from "./compile-controller.js";
9
+ import { runConfiguredCompiledCompile } from "./compile-controller.js";
10
+ export { runConfiguredCompiledCompile } from "./compile-controller.js";
11
11
  export const compileCommand = {
12
12
  command: "compile",
13
- describe: "Build a workspace for this dataset",
13
+ describe: "Build the compiled dataset for the selected dataset",
14
14
  builder: (yargs) => addExecutionProfileOptions(yargs).option("max-attempts", {
15
- alias: "max-retries",
16
15
  type: "number",
17
- describe: "Retry compile + test for the same workflow until the workspace passes or reaches this total attempt limit",
16
+ describe: "Retry compile + test for the same workflow until the dataset passes or reaches this total attempt limit",
18
17
  }).option("max-loops", {
19
18
  type: "number",
20
- describe: "After retries fail, let Interf edit the workflow and test new workflow variations up to this loop limit",
19
+ describe: "After retries fail, let Interf edit the workflow and test new workflow variations for this dataset up to this loop limit",
21
20
  }).option("keep-stage-shells", {
22
21
  type: "boolean",
23
22
  default: false,
@@ -28,17 +27,17 @@ export const compileCommand = {
28
27
  },
29
28
  };
30
29
  export async function runCompileCommand(argv = {}) {
31
- let workspacePath = null;
30
+ let compiledPath = null;
32
31
  let sourcePath = process.cwd();
33
- let workspaceConfig = null;
32
+ let compiledConfig = null;
34
33
  const detected = detectInterf(process.cwd());
35
34
  if (detected) {
36
- workspacePath = detected.path;
35
+ compiledPath = detected.path;
37
36
  sourcePath = resolveSourceControlPath(detected.path);
38
- workspaceConfig = sourceWorkspaceConfigFromInterfConfig(detected.config);
37
+ compiledConfig = sourceDatasetConfigFromInterfConfig(detected.config);
39
38
  if (process.stdin.isTTY && process.stdout.isTTY) {
40
39
  const confirmed = await p.confirm({
41
- message: `Compile workspace "${detected.config.name}" now?`,
40
+ message: `Compile dataset "${detected.config.name}" now?`,
42
41
  initialValue: true,
43
42
  });
44
43
  if (p.isCancel(confirmed) || !confirmed)
@@ -46,29 +45,29 @@ export async function runCompileCommand(argv = {}) {
46
45
  }
47
46
  }
48
47
  else {
49
- const selectedWorkspace = await chooseWorkspaceConfigToBuild({
48
+ const selectedCompiled = await chooseCompiledConfigToBuild({
50
49
  sourcePath: process.cwd(),
51
- selectMessage: "Which workspace do you want to compile?",
50
+ selectMessage: "Which dataset do you want to compile?",
52
51
  });
53
- if (selectedWorkspace === undefined)
52
+ if (selectedCompiled === undefined)
54
53
  return;
55
- if (!selectedWorkspace) {
54
+ if (!selectedCompiled) {
56
55
  process.exitCode = 1;
57
- console.log(chalk.red(" No workspaces are set up for this folder yet."));
56
+ console.log(chalk.red(" No datasets are set up for this folder yet."));
58
57
  console.log(chalk.dim(" Start with `interf` or `interf init` to set up this folder."));
59
58
  return;
60
59
  }
61
60
  if (process.stdin.isTTY && process.stdout.isTTY) {
62
61
  const confirmed = await p.confirm({
63
- message: `Compile workspace "${selectedWorkspace.name}" now?`,
62
+ message: `Compile dataset "${selectedCompiled.name}" now?`,
64
63
  initialValue: true,
65
64
  });
66
65
  if (p.isCancel(confirmed) || !confirmed)
67
66
  return;
68
67
  }
69
- workspaceConfig = selectedWorkspace;
70
- workspacePath = ensureWorkspaceFromConfig(process.cwd(), selectedWorkspace);
71
- console.log(chalk.dim(` Workspace: ${selectedWorkspace.name}`));
68
+ compiledConfig = selectedCompiled;
69
+ compiledPath = ensureCompiledFromConfig(process.cwd(), selectedCompiled);
70
+ console.log(chalk.dim(` Dataset: ${selectedCompiled.name}`));
72
71
  }
73
72
  let maxAttemptsOverride = null;
74
73
  let maxLoopsOverride = null;
@@ -82,14 +81,14 @@ export async function runCompileCommand(argv = {}) {
82
81
  return;
83
82
  }
84
83
  const interactiveOverrides = await resolveInteractiveCompileLoopOverrides({
85
- workspacePath,
86
- workspaceConfig,
84
+ compiledPath,
85
+ compiledConfig,
87
86
  maxAttemptsOverride,
88
87
  maxLoopsOverride,
89
88
  });
90
89
  if (!interactiveOverrides)
91
90
  return;
92
- workspaceConfig = interactiveOverrides.workspaceConfig;
91
+ compiledConfig = interactiveOverrides.compiledConfig;
93
92
  maxAttemptsOverride = interactiveOverrides.maxAttemptsOverride;
94
93
  maxLoopsOverride = interactiveOverrides.maxLoopsOverride;
95
94
  const executionProfile = executionProfileFromArgv(argv);
@@ -104,11 +103,11 @@ export async function runCompileCommand(argv = {}) {
104
103
  console.log(chalk.red(error ?? "No coding agent detected."));
105
104
  return;
106
105
  }
107
- await runConfiguredWorkspaceCompile({
106
+ await runConfiguredCompiledCompile({
108
107
  executor,
109
- workspacePath,
108
+ compiledPath,
110
109
  sourcePath,
111
- workspaceConfig,
110
+ compiledConfig,
112
111
  executionProfile,
113
112
  maxAttemptsOverride,
114
113
  maxLoopsOverride,
@@ -118,56 +117,56 @@ export async function runCompileCommand(argv = {}) {
118
117
  export async function resolveInteractiveCompileLoopOverrides(options) {
119
118
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
120
119
  return {
121
- workspaceConfig: options.workspaceConfig,
120
+ compiledConfig: options.compiledConfig,
122
121
  maxAttemptsOverride: options.maxAttemptsOverride,
123
122
  maxLoopsOverride: options.maxLoopsOverride,
124
123
  };
125
124
  }
126
125
  if (options.maxAttemptsOverride != null || options.maxLoopsOverride != null) {
127
126
  return {
128
- workspaceConfig: options.workspaceConfig,
127
+ compiledConfig: options.compiledConfig,
129
128
  maxAttemptsOverride: options.maxAttemptsOverride,
130
129
  maxLoopsOverride: options.maxLoopsOverride,
131
130
  };
132
131
  }
133
- const currentConfig = readInterfConfig(options.workspacePath);
134
- const checks = options.workspaceConfig?.checks.length
135
- ? options.workspaceConfig.checks
132
+ const currentConfig = readInterfConfig(options.compiledPath);
133
+ const checks = options.compiledConfig?.checks.length
134
+ ? options.compiledConfig.checks
136
135
  : (currentConfig?.checks ?? []);
137
136
  if (checks.length === 0) {
138
137
  return {
139
- workspaceConfig: options.workspaceConfig,
138
+ compiledConfig: options.compiledConfig,
140
139
  maxAttemptsOverride: options.maxAttemptsOverride,
141
140
  maxLoopsOverride: options.maxLoopsOverride,
142
141
  };
143
142
  }
144
- const savedWorkspaceConfig = options.workspaceConfig
145
- ?? (currentConfig ? sourceWorkspaceConfigFromInterfConfig(currentConfig) : null);
146
- if (!savedWorkspaceConfig) {
143
+ const savedCompiledConfig = options.compiledConfig
144
+ ?? (currentConfig ? sourceDatasetConfigFromInterfConfig(currentConfig) : null);
145
+ if (!savedCompiledConfig) {
147
146
  return {
148
- workspaceConfig: options.workspaceConfig,
147
+ compiledConfig: options.compiledConfig,
149
148
  maxAttemptsOverride: options.maxAttemptsOverride,
150
149
  maxLoopsOverride: options.maxLoopsOverride,
151
150
  };
152
151
  }
153
- const hasSavedPolicy = typeof savedWorkspaceConfig.max_attempts === "number" ||
154
- typeof savedWorkspaceConfig.max_loops === "number";
152
+ const hasSavedPolicy = typeof savedCompiledConfig.max_attempts === "number" ||
153
+ typeof savedCompiledConfig.max_loops === "number";
155
154
  if (!hasSavedPolicy) {
156
155
  const overrideSelection = await promptCompileLoopSelection({
157
156
  hasChecks: true,
158
- initialMaxAttempts: savedWorkspaceConfig.max_attempts,
159
- initialMaxLoops: savedWorkspaceConfig.max_loops,
157
+ initialMaxAttempts: savedCompiledConfig.max_attempts,
158
+ initialMaxLoops: savedCompiledConfig.max_loops,
160
159
  intro: [
161
- `Workflow: ${savedWorkspaceConfig.workflow ?? currentConfig?.workflow ?? "interf"}`,
162
- "This selection applies to this compile run only. It does not change the saved workspace setup.",
160
+ `Workflow: ${savedCompiledConfig.workflow ?? currentConfig?.workflow ?? "interf"}`,
161
+ "This selection applies to this compile run only. It does not change the saved dataset setup.",
163
162
  ],
164
163
  message: "How should this compile run?",
165
164
  });
166
165
  if (overrideSelection === null)
167
166
  return null;
168
167
  return {
169
- workspaceConfig: {
170
- ...savedWorkspaceConfig,
168
+ compiledConfig: {
169
+ ...savedCompiledConfig,
171
170
  max_attempts: undefined,
172
171
  max_loops: undefined,
173
172
  },
@@ -181,12 +180,12 @@ export async function resolveInteractiveCompileLoopOverrides(options) {
181
180
  {
182
181
  value: "saved",
183
182
  label: "Use saved compile mode (Recommended)",
184
- hint: `${savedWorkspaceConfig.max_loops ? "Self-improving" : savedWorkspaceConfig.max_attempts && savedWorkspaceConfig.max_attempts > 1 ? "Retry" : "Single attempt"} · ${formatCompileModeHint(savedWorkspaceConfig)}`,
183
+ hint: `${savedCompiledConfig.max_loops ? "Self-improving" : savedCompiledConfig.max_attempts && savedCompiledConfig.max_attempts > 1 ? "Retry" : "Single attempt"} · ${formatCompileModeHint(savedCompiledConfig)}`,
185
184
  },
186
185
  {
187
186
  value: "override",
188
187
  label: "Change it for this run only",
189
- hint: "Keep the saved workspace setup unchanged",
188
+ hint: "Keep the saved dataset setup unchanged",
190
189
  },
191
190
  ],
192
191
  });
@@ -194,27 +193,27 @@ export async function resolveInteractiveCompileLoopOverrides(options) {
194
193
  return null;
195
194
  if (savedMode === "saved") {
196
195
  return {
197
- workspaceConfig: savedWorkspaceConfig,
196
+ compiledConfig: savedCompiledConfig,
198
197
  maxAttemptsOverride: null,
199
198
  maxLoopsOverride: null,
200
199
  };
201
200
  }
202
201
  const selection = await promptCompileLoopSelection({
203
202
  hasChecks: true,
204
- initialMaxAttempts: savedWorkspaceConfig.max_attempts,
205
- initialMaxLoops: savedWorkspaceConfig.max_loops,
203
+ initialMaxAttempts: savedCompiledConfig.max_attempts,
204
+ initialMaxLoops: savedCompiledConfig.max_loops,
206
205
  intro: [
207
- `Workflow: ${savedWorkspaceConfig.workflow ?? currentConfig?.workflow ?? "interf"}`,
208
- "This applies to this compile run only. It does not change the saved workspace setup.",
206
+ `Workflow: ${savedCompiledConfig.workflow ?? currentConfig?.workflow ?? "interf"}`,
207
+ "This applies to this compile run only. It does not change the saved dataset setup.",
209
208
  ],
210
209
  message: "Override the compile mode for this run",
211
210
  });
212
211
  if (selection === null)
213
212
  return null;
214
213
  return {
215
- ...savedWorkspaceConfig,
216
- workspaceConfig: {
217
- ...savedWorkspaceConfig,
214
+ ...savedCompiledConfig,
215
+ compiledConfig: {
216
+ ...savedCompiledConfig,
218
217
  max_attempts: undefined,
219
218
  max_loops: undefined,
220
219
  },
@@ -222,13 +221,13 @@ export async function resolveInteractiveCompileLoopOverrides(options) {
222
221
  maxLoopsOverride: selection.max_loops ?? null,
223
222
  };
224
223
  }
225
- function formatCompileModeHint(workspaceConfig) {
226
- if (typeof workspaceConfig.max_loops === "number" && workspaceConfig.max_loops > 0) {
227
- const attempts = workspaceConfig.max_attempts ?? 1;
228
- return `${attempts} attempt${attempts === 1 ? "" : "s"} per variation, ${workspaceConfig.max_loops} loop${workspaceConfig.max_loops === 1 ? "" : "s"}`;
224
+ function formatCompileModeHint(compiledConfig) {
225
+ if (typeof compiledConfig.max_loops === "number" && compiledConfig.max_loops > 0) {
226
+ const attempts = compiledConfig.max_attempts ?? 1;
227
+ return `${attempts} attempt${attempts === 1 ? "" : "s"} per variation, ${compiledConfig.max_loops} loop${compiledConfig.max_loops === 1 ? "" : "s"}`;
229
228
  }
230
- if (typeof workspaceConfig.max_attempts === "number" && workspaceConfig.max_attempts > 1) {
231
- return `${workspaceConfig.max_attempts} attempts`;
229
+ if (typeof compiledConfig.max_attempts === "number" && compiledConfig.max_attempts > 1) {
230
+ return `${compiledConfig.max_attempts} attempts`;
232
231
  }
233
232
  return "1 attempt";
234
233
  }
@@ -0,0 +1,23 @@
1
+ import type { SourceDatasetConfig } from "../lib/schema.js";
2
+ import { type StageShellRetentionMode } from "../lib/workflows.js";
3
+ import type { WorkflowExecutor } from "../lib/executors.js";
4
+ import type { CompiledCompileResult } from "../lib/workflows.js";
5
+ export interface SavedDatasetEntry {
6
+ config: SourceDatasetConfig;
7
+ path: string | null;
8
+ localDraft: boolean;
9
+ }
10
+ export declare function listSavedCompiledEntries(sourcePath: string): SavedDatasetEntry[];
11
+ export declare function findBuiltCompiledPath(sourcePath: string, compiledName: string): string | null;
12
+ export declare function findSavedCompiledConfig(sourcePath: string, compiledName: string): SourceDatasetConfig | null;
13
+ export declare function chooseCompiledConfigToBuild(options: {
14
+ sourcePath: string;
15
+ selectMessage: string;
16
+ }): Promise<SourceDatasetConfig | null | undefined>;
17
+ export declare function createCompiledFromConfig(sourcePath: string, datasetConfig: SourceDatasetConfig): string;
18
+ export declare function ensureCompiledFromConfig(sourcePath: string, datasetConfig: SourceDatasetConfig): string;
19
+ export declare function compileCompiledWithReporter(executor: WorkflowExecutor, compiledPath: string, options?: {
20
+ heading?: string;
21
+ successMessage?: string;
22
+ preserveStageShells?: StageShellRetentionMode;
23
+ }): Promise<CompiledCompileResult>;
@@ -0,0 +1,112 @@
1
+ import chalk from "chalk";
2
+ import * as p from "@clack/prompts";
3
+ import { listCompiledDatasetsForSourceFolder } from "../lib/interf.js";
4
+ import { listSourceDatasetConfigs, loadCompiledDatasetConfig, loadSourceFolderConfig, resolveSourceDatasetPath, sourceDatasetConfigFromInterfConfig, syncCompiledInterfConfigFromSourceDatasetConfig, } from "../lib/source-config.js";
5
+ import { compileCompiled, createCompiled, } from "../lib/workflows.js";
6
+ import { formatWorkflowExecutionProfile } from "../lib/execution-profile.js";
7
+ function formatSavedDatasetHint(entry) {
8
+ const config = entry.config;
9
+ const checkCount = config.checks.length;
10
+ const workflowHint = `workflow ${config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`;
11
+ if (config.about)
12
+ return `${config.about} · ${workflowHint}`;
13
+ if (checkCount === 0)
14
+ return "No saved truth checks yet";
15
+ return `${checkCount} saved truth check${checkCount === 1 ? "" : "s"} · ${workflowHint}`;
16
+ }
17
+ export function listSavedCompiledEntries(sourcePath) {
18
+ const builtEntries = new Map();
19
+ for (const builtCompiled of listCompiledDatasetsForSourceFolder(sourcePath)) {
20
+ const datasetConfig = loadCompiledDatasetConfig(builtCompiled.path)
21
+ ?? sourceDatasetConfigFromInterfConfig(builtCompiled.config);
22
+ builtEntries.set(builtCompiled.config.name, {
23
+ config: datasetConfig,
24
+ path: builtCompiled.path,
25
+ localDraft: builtCompiled.config.workflow_origin?.local_draft === true,
26
+ });
27
+ }
28
+ const entries = new Map();
29
+ for (const config of listSourceDatasetConfigs(loadSourceFolderConfig(sourcePath))) {
30
+ const built = builtEntries.get(config.name);
31
+ entries.set(config.name, {
32
+ config,
33
+ path: built?.path ?? null,
34
+ localDraft: built?.localDraft ?? false,
35
+ });
36
+ }
37
+ for (const [name, built] of builtEntries.entries()) {
38
+ if (entries.has(name))
39
+ continue;
40
+ entries.set(name, built);
41
+ }
42
+ return Array.from(entries.values()).sort((left, right) => left.config.name.localeCompare(right.config.name));
43
+ }
44
+ export function findBuiltCompiledPath(sourcePath, compiledName) {
45
+ return listSavedCompiledEntries(sourcePath).find((entry) => entry.config.name === compiledName)?.path ?? null;
46
+ }
47
+ export function findSavedCompiledConfig(sourcePath, compiledName) {
48
+ return listSavedCompiledEntries(sourcePath).find((entry) => entry.config.name === compiledName)?.config ?? null;
49
+ }
50
+ export async function chooseCompiledConfigToBuild(options) {
51
+ const savedEntries = listSavedCompiledEntries(options.sourcePath);
52
+ if (savedEntries.length === 0) {
53
+ return null;
54
+ }
55
+ if (savedEntries.length === 1) {
56
+ return savedEntries[0]?.config ?? null;
57
+ }
58
+ const selected = await p.select({
59
+ message: options.selectMessage,
60
+ options: savedEntries.map((entry) => ({
61
+ value: entry.config.name,
62
+ label: entry.config.name,
63
+ hint: [
64
+ formatSavedDatasetHint(entry),
65
+ entry.path ? "built" : "not built yet",
66
+ ].join(" · "),
67
+ })),
68
+ });
69
+ if (p.isCancel(selected))
70
+ return undefined;
71
+ return savedEntries.find((entry) => entry.config.name === selected)?.config ?? null;
72
+ }
73
+ export function createCompiledFromConfig(sourcePath, datasetConfig) {
74
+ const workflowId = datasetConfig.workflow ?? "interf";
75
+ const datasetSourcePath = resolveSourceDatasetPath(sourcePath, datasetConfig);
76
+ const compiledPath = createCompiled(datasetConfig.name, sourcePath, workflowId, datasetConfig.about, datasetSourcePath);
77
+ syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig);
78
+ return compiledPath;
79
+ }
80
+ export function ensureCompiledFromConfig(sourcePath, datasetConfig) {
81
+ const existingPath = findBuiltCompiledPath(sourcePath, datasetConfig.name);
82
+ if (existingPath) {
83
+ syncCompiledInterfConfigFromSourceDatasetConfig(existingPath, datasetConfig);
84
+ return existingPath;
85
+ }
86
+ return createCompiledFromConfig(sourcePath, datasetConfig);
87
+ }
88
+ export async function compileCompiledWithReporter(executor, compiledPath, options = {}) {
89
+ console.log();
90
+ console.log(chalk.bold(` ${options.heading ?? "Building compiled dataset..."}`));
91
+ const profileLabel = formatWorkflowExecutionProfile(executor.executionProfile);
92
+ if (profileLabel) {
93
+ console.log(chalk.dim(` Execution profile: ${profileLabel}`));
94
+ }
95
+ console.log();
96
+ const reporter = {
97
+ line: (message) => console.log(chalk.dim(` ${message}`)),
98
+ blankLine: () => console.log(),
99
+ };
100
+ const result = await compileCompiled({
101
+ executor,
102
+ compiledPath,
103
+ reporter,
104
+ preserveStageShells: options.preserveStageShells,
105
+ });
106
+ if (!result.ok) {
107
+ return result;
108
+ }
109
+ console.log();
110
+ console.log(chalk.green(` ✓ ${options.successMessage ?? "Compiled dataset ready."}`));
111
+ return result;
112
+ }
@@ -30,12 +30,12 @@ export declare function formatWorkflowLabel(workflow: {
30
30
  label: string;
31
31
  hint: string;
32
32
  };
33
- export declare function buildWorkspaceWorkflowOptions(sourcePath: string): {
33
+ export declare function buildCompiledWorkflowOptions(sourcePath: string): {
34
34
  value: string;
35
35
  label: string;
36
36
  hint: string;
37
37
  }[];
38
- export declare function chooseWorkspaceWorkflow(sourcePath: string, options?: {
38
+ export declare function chooseCompiledWorkflow(sourcePath: string, options?: {
39
39
  currentWorkflowId?: string;
40
40
  message?: string;
41
41
  }): Promise<string | symbol>;
@@ -43,4 +43,4 @@ export declare function createWorkflowWizard(options?: {
43
43
  intro?: boolean;
44
44
  sourcePath?: string;
45
45
  }, prompts?: WorkflowWizardPrompts): Promise<string | symbol>;
46
- export declare function createWorkspaceWorkflowWizard(sourcePath: string, prompts?: WorkflowWizardPrompts): Promise<string | symbol>;
46
+ export declare function createCompiledWorkflowWizard(sourcePath: string, prompts?: WorkflowWizardPrompts): Promise<string | symbol>;
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import * as p from "@clack/prompts";
3
- import { listWorkspaceWorkflowChoices, } from "../lib/workflow-definitions.js";
3
+ import { listCompiledWorkflowChoices, } from "../lib/workflow-definitions.js";
4
4
  import { createLocalWorkflowPackageFromTemplate } from "../lib/interf-workflow-package.js";
5
5
  import { isWorkflowId, } from "../lib/local-workflows.js";
6
6
  import { slugify } from "../lib/util.js";
@@ -20,12 +20,12 @@ export function formatWorkflowLabel(workflow) {
20
20
  hint: workflow.hint,
21
21
  };
22
22
  }
23
- export function buildWorkspaceWorkflowOptions(sourcePath) {
24
- return listWorkspaceWorkflowChoices(sourcePath).map(formatWorkflowLabel);
23
+ export function buildCompiledWorkflowOptions(sourcePath) {
24
+ return listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel);
25
25
  }
26
- export async function chooseWorkspaceWorkflow(sourcePath, options = {}) {
26
+ export async function chooseCompiledWorkflow(sourcePath, options = {}) {
27
27
  const currentWorkflowId = options.currentWorkflowId;
28
- const workflowOptions = buildWorkspaceWorkflowOptions(sourcePath);
28
+ const workflowOptions = buildCompiledWorkflowOptions(sourcePath);
29
29
  const orderedOptions = workflowOptions
30
30
  .map((option) => option.value === currentWorkflowId
31
31
  ? {
@@ -45,7 +45,7 @@ export async function chooseWorkspaceWorkflow(sourcePath, options = {}) {
45
45
  return orderedOptions[0]?.value ?? "interf";
46
46
  }
47
47
  return p.select({
48
- message: options.message ?? "Workspace workflow?",
48
+ message: options.message ?? "Dataset workflow?",
49
49
  options: orderedOptions,
50
50
  });
51
51
  }
@@ -54,12 +54,12 @@ export async function createWorkflowWizard(options = {}, prompts = clackWorkflow
54
54
  prompts.intro(chalk.bold("Create a workflow"));
55
55
  }
56
56
  const sourcePath = options.sourcePath ?? process.cwd();
57
- return createWorkspaceWorkflowWizard(sourcePath, prompts);
57
+ return createCompiledWorkflowWizard(sourcePath, prompts);
58
58
  }
59
- export async function createWorkspaceWorkflowWizard(sourcePath, prompts = clackWorkflowPrompts) {
59
+ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWorkflowPrompts) {
60
60
  const baseWorkflow = await prompts.select({
61
61
  message: "Start from which existing workflow?",
62
- options: listWorkspaceWorkflowChoices(sourcePath).map(formatWorkflowLabel),
62
+ options: listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel),
63
63
  });
64
64
  if (prompts.isCancel(baseWorkflow))
65
65
  return baseWorkflow;
@@ -72,7 +72,7 @@ export async function createWorkspaceWorkflowWizard(sourcePath, prompts = clackW
72
72
  const workflowId = slugify(value);
73
73
  if (!isWorkflowId(workflowId))
74
74
  return "Use letters, numbers, and dashes only";
75
- if (listWorkspaceWorkflowChoices(sourcePath).some((workflow) => workflow.id === workflowId)) {
75
+ if (listCompiledWorkflowChoices(sourcePath).some((workflow) => workflow.id === workflowId)) {
76
76
  return "That workflow name already exists";
77
77
  }
78
78
  return undefined;
@@ -105,7 +105,7 @@ export async function createWorkspaceWorkflowWizard(sourcePath, prompts = clackW
105
105
  return structureBias;
106
106
  const shapeBias = await prompts.text({
107
107
  message: "What should shape emphasize?",
108
- placeholder: "Bias home.md and navigation toward the questions this workspace should answer best",
108
+ placeholder: "Bias home.md and navigation toward the questions this dataset should answer best",
109
109
  validate: (value) => (value.trim().length === 0 ? "Shape guidance is required" : undefined),
110
110
  });
111
111
  if (prompts.isCancel(shapeBias))
@@ -1,8 +1,8 @@
1
1
  import type { CommandModule } from "yargs";
2
2
  import type { WorkflowExecutionProfile } from "../lib/executors.js";
3
3
  export declare const createCommand: CommandModule;
4
- export declare function createWorkspaceWizard(options?: {
4
+ export declare function createCompiledWizard(options?: {
5
5
  intro?: boolean;
6
6
  executionProfile?: WorkflowExecutionProfile;
7
7
  }): Promise<void>;
8
- export { type WorkflowWizardPrompts, formatWorkflowLabel, chooseWorkspaceWorkflow, createWorkflowWizard, createWorkspaceWorkflowWizard, } from "./create-workflow-wizard.js";
8
+ export { type WorkflowWizardPrompts, formatWorkflowLabel, chooseCompiledWorkflow, createWorkflowWizard, createCompiledWorkflowWizard, } from "./create-workflow-wizard.js";