@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.
- package/README.md +71 -69
- package/builtin-workflows/interf/README.md +6 -6
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
- package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
- package/builtin-workflows/interf/improve/SKILL.md +3 -3
- package/builtin-workflows/interf/use/query/SKILL.md +2 -2
- package/builtin-workflows/interf/workflow.json +42 -31
- package/dist/commands/check-draft.d.ts +19 -0
- package/dist/commands/check-draft.js +110 -0
- package/dist/commands/compile-controller.d.ts +4 -4
- package/dist/commands/compile-controller.js +117 -81
- package/dist/commands/compile.d.ts +5 -5
- package/dist/commands/compile.js +61 -62
- package/dist/commands/compiled-flow.d.ts +23 -0
- package/dist/commands/compiled-flow.js +112 -0
- package/dist/commands/create-workflow-wizard.d.ts +3 -3
- package/dist/commands/create-workflow-wizard.js +11 -11
- package/dist/commands/create.d.ts +2 -2
- package/dist/commands/create.js +50 -57
- package/dist/commands/default.js +2 -2
- package/dist/commands/executor-flow.d.ts +20 -1
- package/dist/commands/executor-flow.js +67 -7
- package/dist/commands/init.js +242 -289
- package/dist/commands/list.js +14 -10
- package/dist/commands/reset.js +6 -6
- package/dist/commands/source-config-wizard.d.ts +12 -8
- package/dist/commands/source-config-wizard.js +356 -119
- package/dist/commands/status.js +49 -26
- package/dist/commands/test-flow.d.ts +23 -10
- package/dist/commands/test-flow.js +278 -58
- package/dist/commands/test.d.ts +7 -1
- package/dist/commands/test.js +264 -65
- package/dist/commands/verify.js +23 -14
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/lib/agent-args.js +2 -1
- package/dist/lib/agent-constants.js +1 -1
- package/dist/lib/agent-render.js +4 -4
- package/dist/lib/agent-shells.d.ts +8 -8
- package/dist/lib/agent-shells.js +231 -142
- package/dist/lib/compiled-compile.d.ts +52 -0
- package/dist/lib/compiled-compile.js +274 -0
- package/dist/lib/compiled-home.d.ts +5 -0
- package/dist/lib/compiled-home.js +32 -0
- package/dist/lib/compiled-layout.d.ts +2 -0
- package/dist/lib/compiled-layout.js +60 -0
- package/dist/lib/compiled-paths.d.ts +41 -0
- package/dist/lib/compiled-paths.js +111 -0
- package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
- package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
- package/dist/lib/compiled-reset.d.ts +1 -0
- package/dist/lib/compiled-reset.js +44 -0
- package/dist/lib/compiled-schema.d.ts +27 -0
- package/dist/lib/compiled-schema.js +110 -0
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +0 -1
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +3 -3
- package/dist/lib/interf-bootstrap.d.ts +1 -1
- package/dist/lib/interf-bootstrap.js +4 -4
- package/dist/lib/interf-detect.d.ts +10 -10
- package/dist/lib/interf-detect.js +78 -56
- package/dist/lib/interf-scaffold.d.ts +2 -2
- package/dist/lib/interf-scaffold.js +90 -57
- package/dist/lib/interf-workflow-package.d.ts +3 -3
- package/dist/lib/interf-workflow-package.js +30 -30
- package/dist/lib/interf.d.ts +5 -5
- package/dist/lib/interf.js +4 -4
- package/dist/lib/local-workflows.d.ts +4 -4
- package/dist/lib/local-workflows.js +35 -70
- package/dist/lib/obsidian.d.ts +1 -1
- package/dist/lib/parse.js +92 -1
- package/dist/lib/project-paths.d.ts +13 -0
- package/dist/lib/project-paths.js +29 -0
- package/dist/lib/runtime-acceptance.d.ts +7 -1
- package/dist/lib/runtime-acceptance.js +194 -59
- package/dist/lib/runtime-contracts.d.ts +2 -4
- package/dist/lib/runtime-contracts.js +17 -161
- package/dist/lib/runtime-inventory.d.ts +7 -0
- package/dist/lib/runtime-inventory.js +29 -0
- package/dist/lib/runtime-paths.js +5 -5
- package/dist/lib/runtime-prompt.js +9 -6
- package/dist/lib/runtime-reconcile.d.ts +2 -3
- package/dist/lib/runtime-reconcile.js +92 -171
- package/dist/lib/runtime-runs.js +30 -39
- package/dist/lib/runtime-types.d.ts +10 -19
- package/dist/lib/runtime.d.ts +2 -2
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/schema.d.ts +163 -140
- package/dist/lib/schema.js +163 -124
- package/dist/lib/source-config.d.ts +24 -20
- package/dist/lib/source-config.js +154 -116
- package/dist/lib/state-artifacts.d.ts +5 -5
- package/dist/lib/state-artifacts.js +8 -8
- package/dist/lib/state-health.d.ts +4 -4
- package/dist/lib/state-health.js +108 -126
- package/dist/lib/state-io.d.ts +8 -8
- package/dist/lib/state-io.js +77 -50
- package/dist/lib/state-paths.js +5 -5
- package/dist/lib/state-view.d.ts +4 -4
- package/dist/lib/state-view.js +52 -55
- package/dist/lib/state.d.ts +5 -5
- package/dist/lib/state.js +4 -4
- package/dist/lib/summarize-plan.d.ts +3 -2
- package/dist/lib/summarize-plan.js +18 -16
- package/dist/lib/test-execution.js +9 -9
- package/dist/lib/test-matrices.d.ts +3 -3
- package/dist/lib/test-matrices.js +6 -6
- package/dist/lib/test-paths.d.ts +4 -4
- package/dist/lib/test-paths.js +16 -10
- package/dist/lib/test-sandbox.d.ts +1 -1
- package/dist/lib/test-sandbox.js +38 -31
- package/dist/lib/test-targets.d.ts +2 -2
- package/dist/lib/test-targets.js +11 -11
- package/dist/lib/test-types.d.ts +1 -1
- package/dist/lib/test.d.ts +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/util.d.ts +2 -0
- package/dist/lib/util.js +14 -1
- package/dist/lib/validate-compiled.d.ts +27 -0
- package/dist/lib/validate-compiled.js +236 -0
- package/dist/lib/validate-helpers.d.ts +0 -8
- package/dist/lib/validate-helpers.js +0 -30
- package/dist/lib/validate.d.ts +4 -4
- package/dist/lib/validate.js +49 -15
- package/dist/lib/workflow-abi.d.ts +37 -46
- package/dist/lib/workflow-abi.js +51 -76
- package/dist/lib/workflow-definitions.d.ts +11 -11
- package/dist/lib/workflow-definitions.js +36 -53
- package/dist/lib/workflow-helpers.d.ts +2 -3
- package/dist/lib/workflow-helpers.js +9 -13
- package/dist/lib/workflow-improvement.d.ts +3 -3
- package/dist/lib/workflow-improvement.js +48 -48
- package/dist/lib/workflow-review-paths.d.ts +3 -3
- package/dist/lib/workflow-review-paths.js +11 -11
- package/dist/lib/workflow-stage-runner.d.ts +1 -1
- package/dist/lib/workflow-stage-runner.js +8 -8
- package/dist/lib/workflows.d.ts +9 -9
- package/dist/lib/workflows.js +15 -17
- package/package.json +10 -9
- package/dist/commands/workspace-flow.d.ts +0 -23
- package/dist/commands/workspace-flow.js +0 -109
- package/dist/lib/registry.d.ts +0 -16
- package/dist/lib/registry.js +0 -65
- package/dist/lib/validate-workspace.d.ts +0 -121
- package/dist/lib/validate-workspace.js +0 -407
- package/dist/lib/workspace-compile.d.ts +0 -54
- package/dist/lib/workspace-compile.js +0 -476
- package/dist/lib/workspace-home.d.ts +0 -5
- package/dist/lib/workspace-home.js +0 -32
- package/dist/lib/workspace-layout.d.ts +0 -2
- package/dist/lib/workspace-layout.js +0 -60
- package/dist/lib/workspace-paths.d.ts +0 -41
- package/dist/lib/workspace-paths.js +0 -107
- package/dist/lib/workspace-reset.d.ts +0 -1
- package/dist/lib/workspace-reset.js +0 -43
- package/dist/lib/workspace-schema.d.ts +0 -17
- package/dist/lib/workspace-schema.js +0 -74
package/dist/commands/compile.js
CHANGED
|
@@ -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 {
|
|
4
|
+
import { sourceDatasetConfigFromInterfConfig, } from "../lib/source-config.js";
|
|
5
5
|
import { addExecutionProfileOptions, executionProfileFromArgv, } from "../lib/execution-profile.js";
|
|
6
|
-
import {
|
|
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 {
|
|
10
|
-
export {
|
|
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
|
|
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
|
|
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
|
|
30
|
+
let compiledPath = null;
|
|
32
31
|
let sourcePath = process.cwd();
|
|
33
|
-
let
|
|
32
|
+
let compiledConfig = null;
|
|
34
33
|
const detected = detectInterf(process.cwd());
|
|
35
34
|
if (detected) {
|
|
36
|
-
|
|
35
|
+
compiledPath = detected.path;
|
|
37
36
|
sourcePath = resolveSourceControlPath(detected.path);
|
|
38
|
-
|
|
37
|
+
compiledConfig = sourceDatasetConfigFromInterfConfig(detected.config);
|
|
39
38
|
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
40
39
|
const confirmed = await p.confirm({
|
|
41
|
-
message: `Compile
|
|
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
|
|
48
|
+
const selectedCompiled = await chooseCompiledConfigToBuild({
|
|
50
49
|
sourcePath: process.cwd(),
|
|
51
|
-
selectMessage: "Which
|
|
50
|
+
selectMessage: "Which dataset do you want to compile?",
|
|
52
51
|
});
|
|
53
|
-
if (
|
|
52
|
+
if (selectedCompiled === undefined)
|
|
54
53
|
return;
|
|
55
|
-
if (!
|
|
54
|
+
if (!selectedCompiled) {
|
|
56
55
|
process.exitCode = 1;
|
|
57
|
-
console.log(chalk.red(" No
|
|
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
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
console.log(chalk.dim(`
|
|
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
|
-
|
|
86
|
-
|
|
84
|
+
compiledPath,
|
|
85
|
+
compiledConfig,
|
|
87
86
|
maxAttemptsOverride,
|
|
88
87
|
maxLoopsOverride,
|
|
89
88
|
});
|
|
90
89
|
if (!interactiveOverrides)
|
|
91
90
|
return;
|
|
92
|
-
|
|
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
|
|
106
|
+
await runConfiguredCompiledCompile({
|
|
108
107
|
executor,
|
|
109
|
-
|
|
108
|
+
compiledPath,
|
|
110
109
|
sourcePath,
|
|
111
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
+
compiledConfig: options.compiledConfig,
|
|
129
128
|
maxAttemptsOverride: options.maxAttemptsOverride,
|
|
130
129
|
maxLoopsOverride: options.maxLoopsOverride,
|
|
131
130
|
};
|
|
132
131
|
}
|
|
133
|
-
const currentConfig = readInterfConfig(options.
|
|
134
|
-
const checks = options.
|
|
135
|
-
? options.
|
|
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
|
-
|
|
138
|
+
compiledConfig: options.compiledConfig,
|
|
140
139
|
maxAttemptsOverride: options.maxAttemptsOverride,
|
|
141
140
|
maxLoopsOverride: options.maxLoopsOverride,
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
|
-
const
|
|
145
|
-
?? (currentConfig ?
|
|
146
|
-
if (!
|
|
143
|
+
const savedCompiledConfig = options.compiledConfig
|
|
144
|
+
?? (currentConfig ? sourceDatasetConfigFromInterfConfig(currentConfig) : null);
|
|
145
|
+
if (!savedCompiledConfig) {
|
|
147
146
|
return {
|
|
148
|
-
|
|
147
|
+
compiledConfig: options.compiledConfig,
|
|
149
148
|
maxAttemptsOverride: options.maxAttemptsOverride,
|
|
150
149
|
maxLoopsOverride: options.maxLoopsOverride,
|
|
151
150
|
};
|
|
152
151
|
}
|
|
153
|
-
const hasSavedPolicy = typeof
|
|
154
|
-
typeof
|
|
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:
|
|
159
|
-
initialMaxLoops:
|
|
157
|
+
initialMaxAttempts: savedCompiledConfig.max_attempts,
|
|
158
|
+
initialMaxLoops: savedCompiledConfig.max_loops,
|
|
160
159
|
intro: [
|
|
161
|
-
`Workflow: ${
|
|
162
|
-
"This selection applies to this compile run only. It does not change the saved
|
|
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
|
-
|
|
170
|
-
...
|
|
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: `${
|
|
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
|
|
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
|
-
|
|
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:
|
|
205
|
-
initialMaxLoops:
|
|
203
|
+
initialMaxAttempts: savedCompiledConfig.max_attempts,
|
|
204
|
+
initialMaxLoops: savedCompiledConfig.max_loops,
|
|
206
205
|
intro: [
|
|
207
|
-
`Workflow: ${
|
|
208
|
-
"This applies to this compile run only. It does not change the saved
|
|
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
|
-
...
|
|
216
|
-
|
|
217
|
-
...
|
|
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(
|
|
226
|
-
if (typeof
|
|
227
|
-
const attempts =
|
|
228
|
-
return `${attempts} attempt${attempts === 1 ? "" : "s"} per variation, ${
|
|
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
|
|
231
|
-
return `${
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
24
|
-
return
|
|
23
|
+
export function buildCompiledWorkflowOptions(sourcePath) {
|
|
24
|
+
return listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel);
|
|
25
25
|
}
|
|
26
|
-
export async function
|
|
26
|
+
export async function chooseCompiledWorkflow(sourcePath, options = {}) {
|
|
27
27
|
const currentWorkflowId = options.currentWorkflowId;
|
|
28
|
-
const workflowOptions =
|
|
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 ?? "
|
|
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
|
|
57
|
+
return createCompiledWorkflowWizard(sourcePath, prompts);
|
|
58
58
|
}
|
|
59
|
-
export async function
|
|
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:
|
|
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 (
|
|
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
|
|
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
|
|
4
|
+
export declare function createCompiledWizard(options?: {
|
|
5
5
|
intro?: boolean;
|
|
6
6
|
executionProfile?: WorkflowExecutionProfile;
|
|
7
7
|
}): Promise<void>;
|
|
8
|
-
export { type WorkflowWizardPrompts, formatWorkflowLabel,
|
|
8
|
+
export { type WorkflowWizardPrompts, formatWorkflowLabel, chooseCompiledWorkflow, createWorkflowWizard, createCompiledWorkflowWizard, } from "./create-workflow-wizard.js";
|