@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/init.js
CHANGED
|
@@ -1,76 +1,94 @@
|
|
|
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 { SOURCE_FOLDER_CONFIG_FILE,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { SOURCE_FOLDER_CONFIG_FILE, resolveDatasetCompileMaxAttempts, resolveDatasetCompileMaxLoops, syncCompiledInterfConfigFromSourceDatasetConfig, upsertSourceDatasetConfig, } from "../lib/source-config.js";
|
|
5
|
+
import { DEFAULT_COMPILED_NAME, describeCompileLoopSelection, promptSingleCompiledConfig, } from "./source-config-wizard.js";
|
|
6
|
+
import { buildCompiledWorkflowOptions, chooseCompiledWorkflow, createWorkflowWizard, } from "./create-workflow-wizard.js";
|
|
7
|
+
import { findBuiltCompiledPath, findSavedCompiledConfig, listSavedCompiledEntries, ensureCompiledFromConfig, } from "./compiled-flow.js";
|
|
8
|
+
import { readSavedTestComparison } from "./test-flow.js";
|
|
9
9
|
import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { runConfiguredCompiledCompile } from "./compile.js";
|
|
11
|
+
import { runTestCommand } from "./test.js";
|
|
12
|
+
function describeSavedQuestions(dataset) {
|
|
13
|
+
const count = dataset.checks.length;
|
|
13
14
|
if (count === 0)
|
|
14
15
|
return "No saved truth checks yet";
|
|
15
16
|
return `${count} saved truth check${count === 1 ? "" : "s"}`;
|
|
16
17
|
}
|
|
17
|
-
function compileModeAlreadyRanSavedTests(
|
|
18
|
-
if (
|
|
18
|
+
function compileModeAlreadyRanSavedTests(dataset) {
|
|
19
|
+
if (dataset.checks.length === 0)
|
|
19
20
|
return false;
|
|
20
|
-
return (
|
|
21
|
-
|
|
21
|
+
return (resolveDatasetCompileMaxAttempts(dataset) != null ||
|
|
22
|
+
resolveDatasetCompileMaxLoops(dataset) != null);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
? readInterfConfig(options.
|
|
24
|
+
function printDatasetSummary(options) {
|
|
25
|
+
const compiledConfig = options.builtCompiledPath
|
|
26
|
+
? readInterfConfig(options.builtCompiledPath)
|
|
26
27
|
: null;
|
|
27
|
-
const workflowLabel = `${options.
|
|
28
|
-
p.log.info(`
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const workflowLabel = `${options.dataset.workflow ?? "interf"}${compiledConfig?.workflow_origin?.local_draft === true ? " (local draft)" : ""}`;
|
|
29
|
+
p.log.info(`Dataset: ${options.dataset.name}`);
|
|
30
|
+
p.log.info(`Path: ${options.dataset.path === "." ? "project root" : options.dataset.path}`);
|
|
31
|
+
if (options.dataset.about) {
|
|
32
|
+
p.log.info(`About: ${options.dataset.about}`);
|
|
31
33
|
}
|
|
32
34
|
p.log.info(`Workflow: ${workflowLabel}`);
|
|
33
35
|
p.log.info(describeCompileLoopSelection({
|
|
34
|
-
maxAttempts: options.
|
|
35
|
-
maxLoops: options.
|
|
36
|
+
maxAttempts: options.dataset.max_attempts,
|
|
37
|
+
maxLoops: options.dataset.max_loops,
|
|
36
38
|
}));
|
|
37
|
-
p.log.info(describeSavedQuestions(options.
|
|
38
|
-
p.log.info(options.built ? "Compiled
|
|
39
|
+
p.log.info(describeSavedQuestions(options.dataset));
|
|
40
|
+
p.log.info(options.built ? "Compiled dataset is available." : "Compiled dataset has not been built yet.");
|
|
41
|
+
if (options.latestComparison?.raw && options.latestComparison?.compiled) {
|
|
42
|
+
p.log.info(`Latest saved comparison: files-as-is ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}, compiled ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
|
|
43
|
+
}
|
|
44
|
+
else if (options.latestComparison?.raw) {
|
|
45
|
+
p.log.info(`Latest files-as-is baseline: ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}.`);
|
|
46
|
+
}
|
|
47
|
+
else if (options.latestComparison?.compiled) {
|
|
48
|
+
p.log.info(`Latest compiled run: ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
|
|
49
|
+
}
|
|
39
50
|
if (options.sourcePath !== process.cwd()) {
|
|
40
51
|
p.log.info(`Source folder: ${options.sourcePath}`);
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
|
-
async function
|
|
44
|
-
const options = [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
if (workspace.checks.length > 0) {
|
|
52
|
-
options.push({
|
|
53
|
-
value: "raw",
|
|
54
|
-
label: "Run a baseline test on the raw files",
|
|
55
|
-
hint: "Measure current performance before compilation",
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
options.push({
|
|
59
|
-
value: "compile",
|
|
60
|
-
label: built ? "Refresh the compiled workspace" : "Compile the workspace",
|
|
61
|
-
hint: built ? "Rebuild it from the current files" : "Build it for the first time",
|
|
62
|
-
});
|
|
63
|
-
if (workspace.checks.length > 0 && built) {
|
|
54
|
+
async function promptDatasetAction(dataset, built, latestComparison) {
|
|
55
|
+
const options = [];
|
|
56
|
+
const hasSavedRawBaseline = Boolean(latestComparison?.raw);
|
|
57
|
+
const rawAlreadyPasses = latestComparison?.raw &&
|
|
58
|
+
latestComparison.raw.passed_cases === latestComparison.raw.total_cases;
|
|
59
|
+
if (dataset.checks.length > 0) {
|
|
64
60
|
options.push({
|
|
65
61
|
value: "test",
|
|
66
|
-
label:
|
|
67
|
-
|
|
62
|
+
label: built
|
|
63
|
+
? "Measure files-as-is and compiled accuracy (Recommended)"
|
|
64
|
+
: hasSavedRawBaseline
|
|
65
|
+
? "Rerun the files-as-is baseline"
|
|
66
|
+
: "Measure the files-as-is baseline (Recommended)",
|
|
67
|
+
hint: built
|
|
68
|
+
? "Compare whether the compiled dataset is actually better on the saved checks"
|
|
69
|
+
: hasSavedRawBaseline
|
|
70
|
+
? "Refresh the saved raw baseline on the current checks"
|
|
71
|
+
: "See whether the raw dataset is already good enough before compiling",
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
options.push({
|
|
71
|
-
value: "
|
|
72
|
-
label: "
|
|
73
|
-
hint:
|
|
75
|
+
value: "compile",
|
|
76
|
+
label: built ? "Rebuild the compiled dataset" : "Build the compiled dataset",
|
|
77
|
+
hint: built
|
|
78
|
+
? "Refresh it from the current dataset files"
|
|
79
|
+
: dataset.checks.length > 0
|
|
80
|
+
? rawAlreadyPasses
|
|
81
|
+
? "Optional: compare a compiled dataset against the already-passing baseline"
|
|
82
|
+
: "Compile only if the baseline is not good enough"
|
|
83
|
+
: "Build it first, then measure it later",
|
|
84
|
+
}, {
|
|
85
|
+
value: "dataset",
|
|
86
|
+
label: "Add another dataset",
|
|
87
|
+
hint: "Add a separate folder, focus, or question set",
|
|
88
|
+
}, {
|
|
89
|
+
value: "edit",
|
|
90
|
+
label: "Edit truth checks and settings",
|
|
91
|
+
hint: "Update checks, focus, workflow, or compile mode",
|
|
74
92
|
}, {
|
|
75
93
|
value: "workflow",
|
|
76
94
|
label: "Create workflow",
|
|
@@ -88,22 +106,42 @@ async function promptWorkspaceAction(workspace, built) {
|
|
|
88
106
|
return null;
|
|
89
107
|
return selected;
|
|
90
108
|
}
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
109
|
+
function printDatasetRecommendation(dataset, built, latestComparison) {
|
|
110
|
+
if (dataset.checks.length === 0) {
|
|
111
|
+
p.log.info("Recommended first step: save a few truth checks for this dataset.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!built) {
|
|
115
|
+
if (latestComparison?.raw) {
|
|
116
|
+
if (latestComparison.raw.passed_cases === latestComparison.raw.total_cases) {
|
|
117
|
+
p.log.info("Files-as-is already passes the saved checks. Compile only if you want a side-by-side comparison or a stronger compiled surface.");
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
p.log.info(`Latest files-as-is baseline: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Compile if you want to improve it.`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
p.log.info("Recommended first step: measure the files-as-is baseline before compiling.");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
p.log.info("Recommended first step: compare the files-as-is baseline and the compiled dataset.");
|
|
127
|
+
}
|
|
128
|
+
async function chooseCompiledForWizard(options) {
|
|
129
|
+
if (options.fixedCompiledName) {
|
|
130
|
+
return findSavedCompiledConfig(options.sourcePath, options.fixedCompiledName);
|
|
94
131
|
}
|
|
95
|
-
const savedEntries =
|
|
132
|
+
const savedEntries = listSavedCompiledEntries(options.sourcePath);
|
|
96
133
|
if (savedEntries.length === 0)
|
|
97
134
|
return null;
|
|
98
135
|
if (savedEntries.length === 1)
|
|
99
136
|
return savedEntries[0]?.config ?? null;
|
|
100
137
|
const selected = await p.select({
|
|
101
|
-
message: "Which
|
|
138
|
+
message: "Which dataset do you want to work with?",
|
|
102
139
|
options: [
|
|
103
140
|
...savedEntries.map((entry) => ({
|
|
104
141
|
value: entry.config.name,
|
|
105
142
|
label: entry.config.name,
|
|
106
143
|
hint: [
|
|
144
|
+
`path ${entry.config.path}`,
|
|
107
145
|
entry.config.about ?? describeSavedQuestions(entry.config),
|
|
108
146
|
`workflow ${entry.config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`,
|
|
109
147
|
entry.path ? "built" : "not built yet",
|
|
@@ -111,8 +149,8 @@ async function chooseWorkspaceForWizard(options) {
|
|
|
111
149
|
})),
|
|
112
150
|
{
|
|
113
151
|
value: "__new__",
|
|
114
|
-
label: "
|
|
115
|
-
hint: "Add a separate focus or question set",
|
|
152
|
+
label: "Add another dataset",
|
|
153
|
+
hint: "Add a separate folder, focus, or question set",
|
|
116
154
|
},
|
|
117
155
|
],
|
|
118
156
|
});
|
|
@@ -120,52 +158,55 @@ async function chooseWorkspaceForWizard(options) {
|
|
|
120
158
|
return null;
|
|
121
159
|
if (selected === "__new__")
|
|
122
160
|
return "__new__";
|
|
123
|
-
return
|
|
161
|
+
return findSavedCompiledConfig(options.sourcePath, String(selected));
|
|
124
162
|
}
|
|
125
|
-
async function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
: "Which workflow should this
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
163
|
+
async function promptCompiledSetup(options) {
|
|
164
|
+
let workflowId = options.initial?.workflow ?? "interf";
|
|
165
|
+
if (options.introStyle === "edit") {
|
|
166
|
+
const workflowChoice = await chooseCompiledWorkflow(options.sourcePath, {
|
|
167
|
+
currentWorkflowId: workflowId,
|
|
168
|
+
message: "Which workflow should this dataset use?",
|
|
169
|
+
});
|
|
170
|
+
if (p.isCancel(workflowChoice))
|
|
171
|
+
return null;
|
|
172
|
+
workflowId = workflowChoice;
|
|
173
|
+
}
|
|
174
|
+
const workflowLabel = buildCompiledWorkflowOptions(options.sourcePath)
|
|
136
175
|
.find((option) => option.value === workflowId)?.label ?? workflowId;
|
|
137
|
-
const
|
|
176
|
+
const compiledConfig = await promptSingleCompiledConfig({
|
|
177
|
+
projectPath: options.sourcePath,
|
|
138
178
|
initial: options.initial,
|
|
139
179
|
...(options.fixedName ? { fixedName: options.fixedName } : {}),
|
|
140
180
|
skipNamePrompt: !options.fixedName && options.introStyle === "first",
|
|
141
181
|
introStyle: options.introStyle,
|
|
142
182
|
selectedWorkflowLabel: workflowLabel,
|
|
143
183
|
});
|
|
144
|
-
if (!
|
|
184
|
+
if (!compiledConfig)
|
|
145
185
|
return null;
|
|
146
|
-
const
|
|
147
|
-
...
|
|
186
|
+
const compiledConfigWithWorkflow = {
|
|
187
|
+
...compiledConfig,
|
|
148
188
|
workflow: workflowId,
|
|
149
189
|
};
|
|
150
|
-
|
|
190
|
+
upsertSourceDatasetConfig(options.sourcePath, compiledConfigWithWorkflow, {
|
|
151
191
|
...(options.fixedName ? { matchName: options.fixedName } : {}),
|
|
152
192
|
});
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
193
|
+
const builtCompiledPath = findBuiltCompiledPath(options.sourcePath, compiledConfigWithWorkflow.name);
|
|
194
|
+
if (builtCompiledPath) {
|
|
195
|
+
syncCompiledInterfConfigFromSourceDatasetConfig(builtCompiledPath, compiledConfigWithWorkflow);
|
|
156
196
|
}
|
|
157
197
|
console.log();
|
|
158
|
-
console.log(chalk.green(` ✓ Saved
|
|
198
|
+
console.log(chalk.green(` ✓ Saved dataset setup in ${SOURCE_FOLDER_CONFIG_FILE}`));
|
|
159
199
|
console.log(chalk.dim(` Source folder: ${options.sourcePath}`));
|
|
160
|
-
console.log(chalk.dim(`
|
|
200
|
+
console.log(chalk.dim(` Dataset: ${compiledConfigWithWorkflow.name}`));
|
|
201
|
+
console.log(chalk.dim(` Path: ${compiledConfigWithWorkflow.path}`));
|
|
161
202
|
console.log(chalk.dim(` Workflow: ${workflowLabel}`));
|
|
162
203
|
console.log(chalk.dim(` Compile mode: ${describeCompileLoopSelection({
|
|
163
|
-
maxAttempts:
|
|
164
|
-
maxLoops:
|
|
204
|
+
maxAttempts: compiledConfigWithWorkflow.max_attempts,
|
|
205
|
+
maxLoops: compiledConfigWithWorkflow.max_loops,
|
|
165
206
|
})}`));
|
|
166
|
-
return
|
|
207
|
+
return compiledConfigWithWorkflow;
|
|
167
208
|
}
|
|
168
|
-
async function
|
|
209
|
+
async function compileSelectedCompiled(sourcePath, compiledConfig) {
|
|
169
210
|
const { executor, error } = await resolveOrConfigureLocalExecutor({
|
|
170
211
|
purpose: "compile",
|
|
171
212
|
});
|
|
@@ -177,274 +218,186 @@ async function compileSelectedWorkspace(sourcePath, workspaceConfig) {
|
|
|
177
218
|
console.log(chalk.red(error ?? "No coding agent detected."));
|
|
178
219
|
return null;
|
|
179
220
|
}
|
|
180
|
-
const
|
|
181
|
-
const compiled = await
|
|
221
|
+
const compiledPath = ensureCompiledFromConfig(sourcePath, compiledConfig);
|
|
222
|
+
const compiled = await runConfiguredCompiledCompile({
|
|
182
223
|
executor,
|
|
183
|
-
|
|
224
|
+
compiledPath,
|
|
184
225
|
sourcePath,
|
|
185
|
-
|
|
226
|
+
compiledConfig,
|
|
186
227
|
maxAttemptsOverride: null,
|
|
187
228
|
maxLoopsOverride: null,
|
|
188
229
|
});
|
|
189
230
|
if (!compiled) {
|
|
190
231
|
return null;
|
|
191
232
|
}
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
async function runFirstWorkspaceFlow(sourcePath, workspaceConfig) {
|
|
195
|
-
let rawOutcome = null;
|
|
196
|
-
let workspaceOutcome = null;
|
|
197
|
-
let rawOutcomeShown = false;
|
|
198
|
-
if (workspaceConfig.checks.length > 0) {
|
|
199
|
-
const runRawFirst = await p.confirm({
|
|
200
|
-
message: "Run a baseline test on the raw files now? (Recommended)",
|
|
201
|
-
initialValue: true,
|
|
202
|
-
});
|
|
203
|
-
if (p.isCancel(runRawFirst))
|
|
204
|
-
return;
|
|
205
|
-
if (runRawFirst) {
|
|
206
|
-
rawOutcome = await runSavedRawTest({
|
|
207
|
-
sourcePath,
|
|
208
|
-
workspaceConfig,
|
|
209
|
-
});
|
|
210
|
-
if (rawOutcome) {
|
|
211
|
-
console.log();
|
|
212
|
-
printSavedTestOutcome("Raw files", rawOutcome);
|
|
213
|
-
rawOutcomeShown = true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
p.log.info("You can compile this workspace now and add questions later when you want to test it.");
|
|
219
|
-
}
|
|
220
|
-
const compileAndTest = workspaceConfig.checks.length > 0 && rawOutcome
|
|
221
|
-
? await p.confirm({
|
|
222
|
-
message: "Compile the workspace with this workflow and run the same test now? (Recommended)",
|
|
223
|
-
initialValue: true,
|
|
224
|
-
})
|
|
225
|
-
: await p.confirm({
|
|
226
|
-
message: "Compile the workspace with this workflow now? (Recommended)",
|
|
227
|
-
initialValue: true,
|
|
228
|
-
});
|
|
229
|
-
if (p.isCancel(compileAndTest) || !compileAndTest) {
|
|
230
|
-
if (rawOutcome && !rawOutcomeShown) {
|
|
231
|
-
printSavedTestOutcome("Raw files", rawOutcome);
|
|
232
|
-
}
|
|
233
|
-
console.log();
|
|
234
|
-
console.log(chalk.dim(" Next:"));
|
|
235
|
-
console.log(chalk.dim(" interf compile"));
|
|
236
|
-
if (workspaceConfig.checks.length > 0) {
|
|
237
|
-
console.log(chalk.dim(" interf test"));
|
|
238
|
-
}
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const workspacePath = await compileSelectedWorkspace(sourcePath, workspaceConfig);
|
|
242
|
-
if (!workspacePath) {
|
|
243
|
-
if (rawOutcome && !rawOutcomeShown) {
|
|
244
|
-
printSavedTestOutcome("Raw files", rawOutcome);
|
|
245
|
-
}
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
if (workspaceConfig.checks.length === 0) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (compileModeAlreadyRanSavedTests(workspaceConfig)) {
|
|
252
|
-
p.log.info("Saved compile mode already ran the workspace test.");
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (!rawOutcome) {
|
|
256
|
-
const runWorkspaceTest = await p.confirm({
|
|
257
|
-
message: "Run the saved test on the compiled workspace now? (Recommended)",
|
|
258
|
-
initialValue: true,
|
|
259
|
-
});
|
|
260
|
-
if (p.isCancel(runWorkspaceTest) || !runWorkspaceTest)
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
workspaceOutcome = await runSavedWorkspaceTest({
|
|
264
|
-
sourcePath,
|
|
265
|
-
workspaceConfig,
|
|
266
|
-
workspacePath,
|
|
267
|
-
});
|
|
268
|
-
if (rawOutcomeShown) {
|
|
269
|
-
if (workspaceOutcome) {
|
|
270
|
-
console.log();
|
|
271
|
-
printSavedTestOutcome("Compiled workspace", workspaceOutcome);
|
|
272
|
-
if (rawOutcome) {
|
|
273
|
-
const rawQuestions = questionPassRate(rawOutcome);
|
|
274
|
-
const workspaceQuestions = questionPassRate(workspaceOutcome);
|
|
275
|
-
const delta = workspaceQuestions - rawQuestions;
|
|
276
|
-
const color = delta >= 0 ? chalk.green : chalk.red;
|
|
277
|
-
const direction = delta >= 0 ? "improved" : "decreased";
|
|
278
|
-
console.log();
|
|
279
|
-
console.log(color(` Truth-check pass rate ${direction} from ${rawQuestions}% to ${workspaceQuestions}%.`));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
printSavedTestComparison(rawOutcome, workspaceOutcome);
|
|
285
|
-
}
|
|
233
|
+
return compiledPath;
|
|
286
234
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
await runInitCommand();
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
export async function runInitCommand() {
|
|
295
|
-
p.intro(chalk.bold("Interf Compiler"));
|
|
296
|
-
p.log.info("Measure and improve how accurately your local agent answers questions from the dataset in this folder.");
|
|
297
|
-
const cwd = process.cwd();
|
|
298
|
-
const detected = detectInterf(cwd);
|
|
299
|
-
const sourcePath = detected ? resolveSourceControlPath(detected.path) : cwd;
|
|
300
|
-
if (detected) {
|
|
301
|
-
p.log.info(`Working from the dataset control plane: ${sourcePath}`);
|
|
302
|
-
}
|
|
303
|
-
const savedEntries = listSavedWorkspaceEntries(sourcePath);
|
|
304
|
-
if (savedEntries.length === 0) {
|
|
305
|
-
const workspaceConfig = await promptWorkspaceSetup({
|
|
306
|
-
sourcePath,
|
|
307
|
-
initial: { name: DEFAULT_WORKSPACE_NAME },
|
|
308
|
-
introStyle: "first",
|
|
309
|
-
});
|
|
310
|
-
if (!workspaceConfig)
|
|
311
|
-
return;
|
|
312
|
-
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const selectedWorkspace = await chooseWorkspaceForWizard({
|
|
316
|
-
sourcePath,
|
|
317
|
-
fixedWorkspaceName: detected?.config.name ?? null,
|
|
318
|
-
});
|
|
319
|
-
if (!selectedWorkspace)
|
|
320
|
-
return;
|
|
321
|
-
if (selectedWorkspace === "__new__") {
|
|
322
|
-
const workspaceConfig = await promptWorkspaceSetup({
|
|
323
|
-
sourcePath,
|
|
324
|
-
initial: { name: DEFAULT_WORKSPACE_NAME },
|
|
325
|
-
introStyle: "additional",
|
|
326
|
-
});
|
|
327
|
-
if (!workspaceConfig)
|
|
328
|
-
return;
|
|
329
|
-
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const builtWorkspacePath = findBuiltWorkspacePath(sourcePath, selectedWorkspace.name);
|
|
333
|
-
printWorkspaceSummary({
|
|
235
|
+
async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
|
|
236
|
+
const builtCompiledPath = findBuiltCompiledPath(sourcePath, compiledConfig.name);
|
|
237
|
+
const latestComparison = readSavedTestComparison(sourcePath, compiledConfig.name);
|
|
238
|
+
printDatasetSummary({
|
|
334
239
|
sourcePath,
|
|
335
|
-
|
|
336
|
-
built: Boolean(
|
|
337
|
-
|
|
240
|
+
dataset: compiledConfig,
|
|
241
|
+
built: Boolean(builtCompiledPath),
|
|
242
|
+
builtCompiledPath,
|
|
243
|
+
latestComparison,
|
|
338
244
|
});
|
|
339
|
-
|
|
245
|
+
printDatasetRecommendation(compiledConfig, Boolean(builtCompiledPath), latestComparison);
|
|
246
|
+
const action = await promptDatasetAction(compiledConfig, Boolean(builtCompiledPath), latestComparison);
|
|
340
247
|
if (!action)
|
|
341
248
|
return;
|
|
342
249
|
if (action === "done") {
|
|
343
|
-
p.outro("Nothing changed.");
|
|
250
|
+
p.outro(options.justConfigured ? "Saved dataset setup." : "Nothing changed.");
|
|
344
251
|
return;
|
|
345
252
|
}
|
|
346
253
|
if (action === "workflow") {
|
|
347
254
|
await createWorkflowWizard({ sourcePath });
|
|
348
255
|
return;
|
|
349
256
|
}
|
|
350
|
-
if (action === "
|
|
351
|
-
const
|
|
257
|
+
if (action === "dataset") {
|
|
258
|
+
const nextCompiled = await promptCompiledSetup({
|
|
352
259
|
sourcePath,
|
|
353
|
-
initial: { name:
|
|
260
|
+
initial: { name: DEFAULT_COMPILED_NAME },
|
|
354
261
|
introStyle: "additional",
|
|
355
262
|
});
|
|
356
|
-
if (!
|
|
263
|
+
if (!nextCompiled)
|
|
357
264
|
return;
|
|
358
|
-
await
|
|
265
|
+
await runCompiledActionMenu(sourcePath, nextCompiled, { justConfigured: true });
|
|
359
266
|
return;
|
|
360
267
|
}
|
|
361
268
|
if (action === "edit") {
|
|
362
|
-
const
|
|
269
|
+
const nextCompiled = await promptCompiledSetup({
|
|
363
270
|
sourcePath,
|
|
364
|
-
initial:
|
|
365
|
-
fixedName:
|
|
271
|
+
initial: compiledConfig,
|
|
272
|
+
fixedName: compiledConfig.name,
|
|
366
273
|
introStyle: "edit",
|
|
367
274
|
});
|
|
368
|
-
if (!
|
|
275
|
+
if (!nextCompiled)
|
|
369
276
|
return;
|
|
370
|
-
|
|
371
|
-
printWorkspaceSummary({
|
|
372
|
-
sourcePath,
|
|
373
|
-
workspace: workspaceConfig,
|
|
374
|
-
built: Boolean(refreshedBuiltWorkspacePath),
|
|
375
|
-
builtWorkspacePath: refreshedBuiltWorkspacePath,
|
|
376
|
-
});
|
|
377
|
-
p.log.info("Saved workspace setup updated.");
|
|
277
|
+
await runCompiledActionMenu(sourcePath, nextCompiled, { justConfigured: true });
|
|
378
278
|
return;
|
|
379
279
|
}
|
|
380
|
-
if (action === "
|
|
381
|
-
if (
|
|
280
|
+
if (action === "test") {
|
|
281
|
+
if (compiledConfig.checks.length === 0) {
|
|
382
282
|
process.exitCode = 1;
|
|
383
|
-
console.log(chalk.red(`
|
|
384
|
-
console.log(chalk.dim(" Run `interf
|
|
283
|
+
console.log(chalk.red(` Dataset "${compiledConfig.name}" does not have any saved truth checks yet.`));
|
|
284
|
+
console.log(chalk.dim(" Run `interf`, edit this dataset, and add a few truth checks first."));
|
|
285
|
+
console.log(chalk.dim(" Then rerun `interf test`."));
|
|
385
286
|
return;
|
|
386
287
|
}
|
|
387
|
-
const
|
|
288
|
+
const baselineRan = await runTestCommand({
|
|
388
289
|
sourcePath,
|
|
389
|
-
|
|
290
|
+
dataset: compiledConfig.name,
|
|
291
|
+
datasetConfig: compiledConfig,
|
|
292
|
+
...(builtCompiledPath ? {} : { target: "raw" }),
|
|
390
293
|
});
|
|
391
|
-
if (!
|
|
294
|
+
if (!baselineRan) {
|
|
392
295
|
return;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
initialValue: true,
|
|
396
|
-
});
|
|
397
|
-
if (p.isCancel(compileAndCompare) || !compileAndCompare) {
|
|
398
|
-
printSavedTestComparison(rawOutcome, null);
|
|
296
|
+
}
|
|
297
|
+
if (builtCompiledPath) {
|
|
399
298
|
return;
|
|
400
299
|
}
|
|
401
|
-
const
|
|
402
|
-
if (
|
|
403
|
-
|
|
300
|
+
const latestComparison = readSavedTestComparison(sourcePath, compiledConfig.name);
|
|
301
|
+
if (latestComparison?.raw?.passed_cases === latestComparison?.raw?.total_cases) {
|
|
302
|
+
const compileAnyway = await p.confirm({
|
|
303
|
+
message: "The files-as-is baseline already passed. Compile this dataset anyway?",
|
|
304
|
+
initialValue: false,
|
|
305
|
+
});
|
|
306
|
+
if (p.isCancel(compileAnyway) || !compileAnyway) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
const compileAndCompare = await p.confirm({
|
|
312
|
+
message: "Compile this dataset now and compare it on the same checks? (Recommended)",
|
|
313
|
+
initialValue: true,
|
|
314
|
+
});
|
|
315
|
+
if (p.isCancel(compileAndCompare) || !compileAndCompare) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const compiledPath = await compileSelectedCompiled(sourcePath, compiledConfig);
|
|
320
|
+
if (!compiledPath) {
|
|
404
321
|
return;
|
|
405
322
|
}
|
|
406
|
-
|
|
323
|
+
await runTestCommand({
|
|
407
324
|
sourcePath,
|
|
408
|
-
|
|
409
|
-
|
|
325
|
+
dataset: compiledConfig.name,
|
|
326
|
+
datasetConfig: compiledConfig,
|
|
327
|
+
target: "both",
|
|
410
328
|
});
|
|
411
|
-
printSavedTestComparison(rawOutcome, workspaceOutcome);
|
|
412
329
|
return;
|
|
413
330
|
}
|
|
414
331
|
if (action === "compile") {
|
|
415
|
-
|
|
416
|
-
if (!workspacePath)
|
|
332
|
+
if (!await compileSelectedCompiled(sourcePath, compiledConfig))
|
|
417
333
|
return;
|
|
418
|
-
if (
|
|
334
|
+
if (compiledConfig.checks.length === 0)
|
|
419
335
|
return;
|
|
420
|
-
if (compileModeAlreadyRanSavedTests(
|
|
421
|
-
p.log.info("Saved compile mode already ran the
|
|
336
|
+
if (compileModeAlreadyRanSavedTests(compiledConfig)) {
|
|
337
|
+
p.log.info("Saved compile mode already ran the compiled-dataset test.");
|
|
422
338
|
return;
|
|
423
339
|
}
|
|
424
|
-
const
|
|
425
|
-
message:
|
|
340
|
+
const runCompiledTest = await p.confirm({
|
|
341
|
+
message: builtCompiledPath
|
|
342
|
+
? "Run files-as-is and compiled on the saved checks now?"
|
|
343
|
+
: "Compare files-as-is and compiled on the saved checks now?",
|
|
426
344
|
initialValue: true,
|
|
427
345
|
});
|
|
428
|
-
if (p.isCancel(
|
|
346
|
+
if (p.isCancel(runCompiledTest) || !runCompiledTest)
|
|
429
347
|
return;
|
|
430
|
-
|
|
348
|
+
await runTestCommand({
|
|
431
349
|
sourcePath,
|
|
432
|
-
|
|
433
|
-
|
|
350
|
+
dataset: compiledConfig.name,
|
|
351
|
+
datasetConfig: compiledConfig,
|
|
352
|
+
target: "both",
|
|
434
353
|
});
|
|
435
|
-
printSavedTestComparison(null, workspaceOutcome);
|
|
436
354
|
return;
|
|
437
355
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
356
|
+
}
|
|
357
|
+
export const initCommand = {
|
|
358
|
+
command: "init",
|
|
359
|
+
describe: "Open the root-folder wizard for this folder",
|
|
360
|
+
handler: async () => {
|
|
361
|
+
await runInitCommand();
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
export async function runInitCommand() {
|
|
365
|
+
p.intro(chalk.bold("Interf Compiler"));
|
|
366
|
+
p.log.info("Measure how accurately your local agents answer from the dataset in this folder, then compile only if it helps.");
|
|
367
|
+
const cwd = process.cwd();
|
|
368
|
+
const detected = detectInterf(cwd);
|
|
369
|
+
const sourcePath = detected ? resolveSourceControlPath(detected.path) : cwd;
|
|
370
|
+
if (detected) {
|
|
371
|
+
p.log.info(`Working from the dataset control plane: ${sourcePath}`);
|
|
372
|
+
}
|
|
373
|
+
const savedEntries = listSavedCompiledEntries(sourcePath);
|
|
374
|
+
if (savedEntries.length === 0) {
|
|
375
|
+
const compiledConfig = await promptCompiledSetup({
|
|
376
|
+
sourcePath,
|
|
377
|
+
initial: { name: DEFAULT_COMPILED_NAME },
|
|
378
|
+
introStyle: "first",
|
|
379
|
+
});
|
|
380
|
+
if (!compiledConfig)
|
|
381
|
+
return;
|
|
382
|
+
await runCompiledActionMenu(sourcePath, compiledConfig, { justConfigured: true });
|
|
442
383
|
return;
|
|
443
384
|
}
|
|
444
|
-
const
|
|
385
|
+
const selectedCompiled = await chooseCompiledForWizard({
|
|
445
386
|
sourcePath,
|
|
446
|
-
|
|
447
|
-
workspacePath: builtWorkspacePath,
|
|
387
|
+
fixedCompiledName: detected?.config.name ?? null,
|
|
448
388
|
});
|
|
449
|
-
|
|
389
|
+
if (!selectedCompiled)
|
|
390
|
+
return;
|
|
391
|
+
if (selectedCompiled === "__new__") {
|
|
392
|
+
const compiledConfig = await promptCompiledSetup({
|
|
393
|
+
sourcePath,
|
|
394
|
+
initial: { name: DEFAULT_COMPILED_NAME },
|
|
395
|
+
introStyle: "additional",
|
|
396
|
+
});
|
|
397
|
+
if (!compiledConfig)
|
|
398
|
+
return;
|
|
399
|
+
await runCompiledActionMenu(sourcePath, compiledConfig, { justConfigured: true });
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
await runCompiledActionMenu(sourcePath, selectedCompiled);
|
|
450
403
|
}
|