@interf/compiler 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -66
- 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 +274 -65
- 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/{workflow-abi.d.ts → builtin-compiled-workflow.d.ts} +37 -46
- package/dist/lib/builtin-compiled-workflow.js +153 -0
- 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-paths.d.ts +39 -0
- package/dist/lib/compiled-paths.js +103 -0
- package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +9 -8
- 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 +9 -10
- package/dist/lib/interf-detect.js +70 -59
- 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 +11 -0
- package/dist/lib/project-paths.js +32 -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 +7 -6
- package/dist/lib/runtime-reconcile.d.ts +2 -3
- package/dist/lib/runtime-reconcile.js +94 -184
- package/dist/lib/runtime-runs.js +25 -119
- 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 +169 -153
- package/dist/lib/schema.js +116 -164
- package/dist/lib/source-config.d.ts +24 -20
- package/dist/lib/source-config.js +159 -122
- 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 +110 -126
- package/dist/lib/state-io.d.ts +8 -8
- package/dist/lib/state-io.js +21 -102
- 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 +19 -21
- 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 +26 -11
- package/dist/lib/test-sandbox.d.ts +1 -1
- package/dist/lib/test-sandbox.js +32 -38
- package/dist/lib/test-specs.js +1 -1
- 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 +238 -0
- package/dist/lib/validate-helpers.d.ts +0 -8
- package/dist/lib/validate-helpers.js +0 -30
- package/dist/lib/validate.d.ts +6 -4
- package/dist/lib/validate.js +76 -27
- package/dist/lib/workflow-definitions.d.ts +12 -11
- package/dist/lib/workflow-definitions.js +45 -55
- 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-primitives.d.ts +2 -0
- package/dist/lib/workflow-primitives.js +5 -0
- 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 +13 -12
- 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/workflow-abi.js +0 -181
- 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
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { readInterfConfig,
|
|
4
|
-
import {
|
|
3
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { readInterfConfig, refreshCompiledBootstrapGuidance, } from "./interf.js";
|
|
5
|
+
import { seedCompiledWorkflowPackage } from "./interf-workflow-package.js";
|
|
5
6
|
import { readJsonFileWithSchema } from "./parse.js";
|
|
6
|
-
import {
|
|
7
|
+
import { getCompiledWorkflow } from "./workflow-definitions.js";
|
|
7
8
|
import { SourceFolderConfigSchema, } from "./schema.js";
|
|
8
9
|
import { slugify } from "./util.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
10
|
+
import { assertPathWithinRoot } from "./util.js";
|
|
11
|
+
import { defaultControlPathForCompiled, resolveSourceControlPathForCompiled, compiledInterfConfigPath, compiledInterfRoot, } from "./compiled-paths.js";
|
|
12
|
+
export const SOURCE_FOLDER_CONFIG_FILE = "interf.json";
|
|
11
13
|
function sourceConfigPath(sourcePath) {
|
|
12
14
|
return join(sourcePath, SOURCE_FOLDER_CONFIG_FILE);
|
|
13
15
|
}
|
|
@@ -31,17 +33,29 @@ function normalizeTruthChecks(cases) {
|
|
|
31
33
|
};
|
|
32
34
|
});
|
|
33
35
|
}
|
|
36
|
+
export function fingerprintTruthChecks(checks) {
|
|
37
|
+
const normalized = checks.map((check) => ({
|
|
38
|
+
question: check.question.trim(),
|
|
39
|
+
...(check.answer ? { answer: check.answer.trim() } : {}),
|
|
40
|
+
...(check.strictness ? { strictness: check.strictness.trim() } : {}),
|
|
41
|
+
...(check.expect ? { expect: check.expect } : {}),
|
|
42
|
+
}));
|
|
43
|
+
return createHash("sha256")
|
|
44
|
+
.update(JSON.stringify(normalized))
|
|
45
|
+
.digest("hex")
|
|
46
|
+
.slice(0, 16);
|
|
47
|
+
}
|
|
34
48
|
export function loadSourceFolderConfig(sourcePath) {
|
|
35
49
|
const filePath = sourceConfigPath(sourcePath);
|
|
36
50
|
if (!existsSync(filePath))
|
|
37
51
|
return null;
|
|
38
|
-
return readJsonFileWithSchema(filePath, "
|
|
52
|
+
return readJsonFileWithSchema(filePath, "Interf project config", SourceFolderConfigSchema);
|
|
39
53
|
}
|
|
40
|
-
export function
|
|
41
|
-
return config?.
|
|
54
|
+
export function listSourceDatasetConfigs(config) {
|
|
55
|
+
return config?.datasets ?? [];
|
|
42
56
|
}
|
|
43
|
-
export function
|
|
44
|
-
const configured = override ??
|
|
57
|
+
export function resolveDatasetCompileMaxAttempts(datasetConfig, override = null) {
|
|
58
|
+
const configured = override ?? datasetConfig.max_attempts ?? null;
|
|
45
59
|
if (configured == null)
|
|
46
60
|
return null;
|
|
47
61
|
const normalized = Math.trunc(configured);
|
|
@@ -49,8 +63,8 @@ export function resolveWorkspaceCompileMaxAttempts(workspaceConfig, override = n
|
|
|
49
63
|
return 1;
|
|
50
64
|
return Math.min(5, normalized);
|
|
51
65
|
}
|
|
52
|
-
export function
|
|
53
|
-
const configured = override ??
|
|
66
|
+
export function resolveDatasetCompileMaxLoops(datasetConfig, override = null) {
|
|
67
|
+
const configured = override ?? datasetConfig.max_loops ?? null;
|
|
54
68
|
if (configured == null)
|
|
55
69
|
return null;
|
|
56
70
|
const normalized = Math.trunc(configured);
|
|
@@ -58,83 +72,85 @@ export function resolveWorkspaceCompileMaxLoops(workspaceConfig, override = null
|
|
|
58
72
|
return 1;
|
|
59
73
|
return Math.min(3, normalized);
|
|
60
74
|
}
|
|
61
|
-
export function
|
|
62
|
-
const
|
|
63
|
-
return
|
|
75
|
+
export function getDefaultSourceDatasetConfig(config) {
|
|
76
|
+
const datasets = listSourceDatasetConfigs(config);
|
|
77
|
+
return datasets[0] ?? null;
|
|
64
78
|
}
|
|
65
|
-
export function
|
|
66
|
-
return
|
|
79
|
+
export function findSourceDatasetConfig(config, datasetName) {
|
|
80
|
+
return listSourceDatasetConfigs(config).find((dataset) => dataset.name === datasetName) ?? null;
|
|
67
81
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
82
|
+
function toWritableSourceProjectConfig(config) {
|
|
83
|
+
const datasets = config?.datasets ?? [];
|
|
84
|
+
if (datasets.length > 0) {
|
|
71
85
|
return {
|
|
72
|
-
|
|
73
|
-
name: workspace.name,
|
|
74
|
-
...(workspace.about ? { about: workspace.about } : {}),
|
|
75
|
-
...(workspace.workflow && workspace.workflow !== "interf" ? { workflow: workspace.workflow } : {}),
|
|
76
|
-
...(typeof workspace.max_attempts === "number" ? { max_attempts: workspace.max_attempts } : {}),
|
|
77
|
-
...(typeof workspace.max_loops === "number" ? { max_loops: workspace.max_loops } : {}),
|
|
78
|
-
checks: workspace.checks,
|
|
79
|
-
})),
|
|
86
|
+
datasets: datasets.map((dataset) => toWritableSourceDatasetConfig(dataset)),
|
|
80
87
|
};
|
|
81
88
|
}
|
|
82
89
|
return {};
|
|
83
90
|
}
|
|
91
|
+
function toWritableSourceDatasetConfig(dataset) {
|
|
92
|
+
return {
|
|
93
|
+
name: dataset.name,
|
|
94
|
+
...(dataset.path && dataset.path !== "." ? { path: dataset.path } : {}),
|
|
95
|
+
...(dataset.about ? { about: dataset.about } : {}),
|
|
96
|
+
...(dataset.workflow && dataset.workflow !== "interf" ? { workflow: dataset.workflow } : {}),
|
|
97
|
+
...(typeof dataset.max_attempts === "number" ? { max_attempts: dataset.max_attempts } : {}),
|
|
98
|
+
...(typeof dataset.max_loops === "number" ? { max_loops: dataset.max_loops } : {}),
|
|
99
|
+
checks: dataset.checks,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
84
102
|
export function saveSourceFolderConfig(sourcePath, config) {
|
|
85
|
-
writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(
|
|
103
|
+
writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceProjectConfig(config), null, 2) + "\n");
|
|
86
104
|
}
|
|
87
|
-
export function
|
|
105
|
+
export function appendSourceDatasetChecks(sourcePath, datasetName, checks) {
|
|
88
106
|
const existing = loadSourceFolderConfig(sourcePath);
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const currentChecks =
|
|
107
|
+
const currentDataset = findSourceDatasetConfig(existing, datasetName);
|
|
108
|
+
const otherDatasets = listSourceDatasetConfigs(existing).filter((dataset) => dataset.name !== datasetName);
|
|
109
|
+
const currentChecks = currentDataset?.checks ?? [];
|
|
110
|
+
const nextDataset = {
|
|
111
|
+
...toWritableSourceDatasetConfig(currentDataset ?? {
|
|
112
|
+
name: datasetName,
|
|
113
|
+
path: ".",
|
|
114
|
+
checks: [],
|
|
115
|
+
}),
|
|
116
|
+
checks: [...currentChecks, ...checks],
|
|
117
|
+
};
|
|
92
118
|
saveSourceFolderConfig(sourcePath, {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
...(currentWorkspace?.about ? { about: currentWorkspace.about } : {}),
|
|
97
|
-
...(currentWorkspace?.workflow ? { workflow: currentWorkspace.workflow } : {}),
|
|
98
|
-
...(typeof currentWorkspace?.max_attempts === "number"
|
|
99
|
-
? { max_attempts: currentWorkspace.max_attempts }
|
|
100
|
-
: {}),
|
|
101
|
-
...(typeof currentWorkspace?.max_loops === "number"
|
|
102
|
-
? { max_loops: currentWorkspace.max_loops }
|
|
103
|
-
: {}),
|
|
104
|
-
checks: [...currentChecks, ...checks],
|
|
105
|
-
},
|
|
106
|
-
...otherWorkspaces,
|
|
119
|
+
datasets: [
|
|
120
|
+
nextDataset,
|
|
121
|
+
...otherDatasets,
|
|
107
122
|
],
|
|
108
123
|
});
|
|
109
124
|
}
|
|
110
|
-
export function
|
|
125
|
+
export function upsertSourceDatasetConfig(sourcePath, datasetConfig, options = {}) {
|
|
111
126
|
const existing = loadSourceFolderConfig(sourcePath);
|
|
112
|
-
const
|
|
113
|
-
const candidateNames = Array.from(new Set([
|
|
114
|
-
const existingIndex =
|
|
127
|
+
const datasets = listSourceDatasetConfigs(existing);
|
|
128
|
+
const candidateNames = Array.from(new Set([datasetConfig.name, options.matchName].filter((value) => Boolean(value))));
|
|
129
|
+
const existingIndex = datasets.findIndex((entry) => candidateNames.includes(entry.name));
|
|
115
130
|
if (existingIndex >= 0) {
|
|
116
|
-
|
|
131
|
+
datasets[existingIndex] = datasetConfig;
|
|
117
132
|
}
|
|
118
133
|
else {
|
|
119
|
-
|
|
134
|
+
datasets.push(datasetConfig);
|
|
120
135
|
}
|
|
121
136
|
saveSourceFolderConfig(sourcePath, {
|
|
122
|
-
|
|
137
|
+
datasets,
|
|
123
138
|
});
|
|
124
139
|
}
|
|
125
|
-
export function
|
|
140
|
+
export function compiledMaxAttempts(maxAttempts) {
|
|
126
141
|
if (maxAttempts == null)
|
|
127
142
|
return undefined;
|
|
128
|
-
return
|
|
143
|
+
return resolveDatasetCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
|
|
129
144
|
}
|
|
130
|
-
export function
|
|
145
|
+
export function compiledMaxLoops(maxLoops) {
|
|
131
146
|
if (maxLoops == null)
|
|
132
147
|
return undefined;
|
|
133
|
-
return
|
|
148
|
+
return resolveDatasetCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
|
|
134
149
|
}
|
|
135
|
-
export function
|
|
150
|
+
export function sourceDatasetConfigFromInterfConfig(config, datasetPath = ".") {
|
|
136
151
|
return {
|
|
137
152
|
name: config.name,
|
|
153
|
+
path: datasetPath,
|
|
138
154
|
...(config.about ? { about: config.about } : {}),
|
|
139
155
|
...(config.workflow ? { workflow: config.workflow } : {}),
|
|
140
156
|
...(typeof config.max_attempts === "number"
|
|
@@ -146,18 +162,27 @@ export function sourceWorkspaceConfigFromInterfConfig(config) {
|
|
|
146
162
|
checks: config.checks ?? [],
|
|
147
163
|
};
|
|
148
164
|
}
|
|
149
|
-
export function
|
|
150
|
-
const config = readInterfConfig(
|
|
151
|
-
|
|
165
|
+
export function loadCompiledDatasetConfig(compiledPath) {
|
|
166
|
+
const config = readInterfConfig(compiledPath);
|
|
167
|
+
if (!config)
|
|
168
|
+
return null;
|
|
169
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
170
|
+
const datasetPath = typeof config.source?.dataset_path === "string" && config.source.dataset_path.length > 0
|
|
171
|
+
? relative(projectPath, assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Compiled dataset source path")).split(sep).join("/") || "."
|
|
172
|
+
: ".";
|
|
173
|
+
return sourceDatasetConfigFromInterfConfig(config, datasetPath);
|
|
152
174
|
}
|
|
153
|
-
export function
|
|
154
|
-
mkdirSync(
|
|
155
|
-
writeFileSync(
|
|
175
|
+
export function saveCompiledInterfConfig(compiledPath, config) {
|
|
176
|
+
mkdirSync(compiledInterfRoot(compiledPath), { recursive: true });
|
|
177
|
+
writeFileSync(compiledInterfConfigPath(compiledPath), JSON.stringify(config, null, 2) + "\n");
|
|
156
178
|
return config;
|
|
157
179
|
}
|
|
158
|
-
export function
|
|
159
|
-
const current = readInterfConfig(
|
|
160
|
-
const
|
|
180
|
+
export function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig) {
|
|
181
|
+
const current = readInterfConfig(compiledPath);
|
|
182
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
183
|
+
const datasetAbsolutePath = resolve(projectPath, datasetConfig.path ?? ".");
|
|
184
|
+
const datasetRelativePath = relative(compiledPath, datasetAbsolutePath).split(sep).join("/") || ".";
|
|
185
|
+
const workflowId = datasetConfig.workflow ?? current?.workflow ?? "interf";
|
|
161
186
|
const workflowChanged = current?.workflow !== undefined && current.workflow !== workflowId;
|
|
162
187
|
const workflowOrigin = workflowChanged || !current?.workflow_origin
|
|
163
188
|
? {
|
|
@@ -169,88 +194,100 @@ export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath
|
|
|
169
194
|
const nextConfig = {
|
|
170
195
|
...passthrough,
|
|
171
196
|
...(!current ? {
|
|
172
|
-
type: "
|
|
197
|
+
type: "compiled",
|
|
173
198
|
source: {
|
|
174
199
|
path: "./raw",
|
|
175
200
|
},
|
|
176
201
|
} : {}),
|
|
177
|
-
type: "
|
|
178
|
-
name:
|
|
179
|
-
...(
|
|
202
|
+
type: "compiled",
|
|
203
|
+
name: datasetConfig.name,
|
|
204
|
+
...(datasetConfig.about ? { about: datasetConfig.about } : {}),
|
|
180
205
|
workflow: workflowId,
|
|
181
|
-
...(typeof
|
|
182
|
-
? { max_attempts:
|
|
206
|
+
...(typeof datasetConfig.max_attempts === "number"
|
|
207
|
+
? { max_attempts: datasetConfig.max_attempts }
|
|
183
208
|
: {}),
|
|
184
|
-
...(typeof
|
|
185
|
-
? { max_loops:
|
|
209
|
+
...(typeof datasetConfig.max_loops === "number"
|
|
210
|
+
? { max_loops: datasetConfig.max_loops }
|
|
186
211
|
: {}),
|
|
187
|
-
checks:
|
|
212
|
+
checks: datasetConfig.checks,
|
|
188
213
|
workflow_origin: workflowOrigin,
|
|
189
214
|
source: {
|
|
190
215
|
path: current?.source?.path ?? "./raw",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
: { control_path: defaultControlPathForWorkspace(workspacePath) }),
|
|
216
|
+
control_path: defaultControlPathForCompiled(compiledPath),
|
|
217
|
+
dataset_path: datasetRelativePath,
|
|
194
218
|
},
|
|
195
219
|
};
|
|
196
|
-
const saved =
|
|
220
|
+
const saved = saveCompiledInterfConfig(compiledPath, nextConfig);
|
|
197
221
|
if (workflowChanged) {
|
|
198
|
-
const sourcePath =
|
|
199
|
-
const selectedWorkflow =
|
|
200
|
-
|
|
201
|
-
|
|
222
|
+
const sourcePath = projectPath;
|
|
223
|
+
const selectedWorkflow = getCompiledWorkflow(workflowId, { sourcePath });
|
|
224
|
+
seedCompiledWorkflowPackage({
|
|
225
|
+
compiledPath,
|
|
202
226
|
sourcePath,
|
|
203
227
|
workflowId: selectedWorkflow.id,
|
|
204
228
|
});
|
|
205
229
|
}
|
|
206
|
-
|
|
230
|
+
refreshCompiledBootstrapGuidance(compiledPath);
|
|
207
231
|
return saved;
|
|
208
232
|
}
|
|
233
|
+
function buildLoadedTestSpec(options) {
|
|
234
|
+
if (options.checks.length === 0)
|
|
235
|
+
return null;
|
|
236
|
+
const testId = options.id ?? slugify(options.name);
|
|
237
|
+
return {
|
|
238
|
+
id: options.targetType === "raw" ? `${testId}-raw` : testId,
|
|
239
|
+
filePath: options.filePath,
|
|
240
|
+
type: options.targetType,
|
|
241
|
+
name: options.name,
|
|
242
|
+
description: options.about ?? options.fallbackDescription,
|
|
243
|
+
cases: normalizeTruthChecks(options.checks),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
209
246
|
export function buildTestSpecFromSourceFolderConfig(options) {
|
|
210
|
-
const { sourcePath, targetName, targetType = "
|
|
247
|
+
const { sourcePath, targetName, targetType = "compiled" } = options;
|
|
211
248
|
const config = loadSourceFolderConfig(sourcePath);
|
|
212
249
|
if (!config)
|
|
213
250
|
return null;
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
251
|
+
const datasets = listSourceDatasetConfigs(config);
|
|
252
|
+
if (datasets.length === 0)
|
|
216
253
|
return null;
|
|
217
254
|
const match = targetName
|
|
218
|
-
?
|
|
219
|
-
:
|
|
220
|
-
?
|
|
221
|
-
:
|
|
222
|
-
|
|
223
|
-
if (!match || workspaceChecks.length === 0)
|
|
255
|
+
? datasets.find((entry) => entry.name === targetName)
|
|
256
|
+
: datasets.length === 1
|
|
257
|
+
? datasets[0]
|
|
258
|
+
: getDefaultSourceDatasetConfig(config);
|
|
259
|
+
if (!match)
|
|
224
260
|
return null;
|
|
225
261
|
const configPath = sourceConfigPath(sourcePath);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
id: targetType === "raw" ? `${testId}-raw` : testId,
|
|
229
|
-
filePath: targetType === "raw"
|
|
230
|
-
? `${configPath}#workspaces/${match.name}:raw`
|
|
231
|
-
: `${configPath}#workspaces/${match.name}`,
|
|
232
|
-
type: targetType,
|
|
262
|
+
return buildLoadedTestSpec({
|
|
263
|
+
id: match.id,
|
|
233
264
|
name: match.name,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
265
|
+
about: match.about,
|
|
266
|
+
checks: match.checks,
|
|
267
|
+
targetType,
|
|
268
|
+
filePath: targetType === "raw"
|
|
269
|
+
? `${configPath}#datasets/${match.name}:file-as-is`
|
|
270
|
+
: `${configPath}#datasets/${match.name}:compiled`,
|
|
271
|
+
fallbackDescription: `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
|
|
272
|
+
});
|
|
237
273
|
}
|
|
238
|
-
export function
|
|
239
|
-
const {
|
|
240
|
-
const config = readInterfConfig(
|
|
241
|
-
const
|
|
242
|
-
if (!config
|
|
274
|
+
export function buildTestSpecFromCompiledDatasetConfig(options) {
|
|
275
|
+
const { compiledPath, targetType = "compiled" } = options;
|
|
276
|
+
const config = readInterfConfig(compiledPath);
|
|
277
|
+
const configPath = compiledInterfConfigPath(compiledPath);
|
|
278
|
+
if (!config)
|
|
243
279
|
return null;
|
|
244
|
-
|
|
245
|
-
const configPath = workspaceInterfConfigPath(workspacePath);
|
|
246
|
-
return {
|
|
247
|
-
id: targetType === "raw" ? `${testId}-raw` : testId,
|
|
248
|
-
filePath: targetType === "raw"
|
|
249
|
-
? `${configPath}#checks:raw`
|
|
250
|
-
: `${configPath}#checks:workspace`,
|
|
251
|
-
type: targetType,
|
|
280
|
+
return buildLoadedTestSpec({
|
|
252
281
|
name: config.name,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
282
|
+
about: config.about,
|
|
283
|
+
checks: config.checks ?? [],
|
|
284
|
+
targetType,
|
|
285
|
+
filePath: targetType === "raw"
|
|
286
|
+
? `${configPath}#checks:file-as-is`
|
|
287
|
+
: `${configPath}#checks:compiled`,
|
|
288
|
+
fallbackDescription: "Derived from compiled-dataset truth checks.",
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
export function resolveSourceDatasetPath(projectPath, datasetConfig) {
|
|
292
|
+
return assertPathWithinRoot(projectPath, resolve(projectPath, datasetConfig.path ?? "."), "Dataset path");
|
|
256
293
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function
|
|
1
|
+
import { type CompiledHealth, type CompiledRawSnapshot, type CompiledViewSpec } from "./schema.js";
|
|
2
|
+
export declare function refreshCompiledArtifacts(dirPath: string, options?: {
|
|
3
3
|
ensureViewSpec?: boolean;
|
|
4
4
|
}): {
|
|
5
|
-
health:
|
|
6
|
-
viewSpec?:
|
|
7
|
-
rawSnapshot:
|
|
5
|
+
health: CompiledHealth;
|
|
6
|
+
viewSpec?: CompiledViewSpec;
|
|
7
|
+
rawSnapshot: CompiledRawSnapshot;
|
|
8
8
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export function
|
|
5
|
-
const health =
|
|
6
|
-
|
|
7
|
-
const rawSnapshot =
|
|
1
|
+
import { saveCompiledHealth, } from "./state-io.js";
|
|
2
|
+
import { computeCompiledHealth, } from "./state-health.js";
|
|
3
|
+
import { ensureCompiledRawSnapshot, ensureCompiledViewSpec, } from "./state-view.js";
|
|
4
|
+
export function refreshCompiledArtifacts(dirPath, options) {
|
|
5
|
+
const health = computeCompiledHealth(dirPath);
|
|
6
|
+
saveCompiledHealth(dirPath, health);
|
|
7
|
+
const rawSnapshot = ensureCompiledRawSnapshot(dirPath);
|
|
8
8
|
let viewSpec;
|
|
9
9
|
if (options?.ensureViewSpec) {
|
|
10
|
-
viewSpec =
|
|
10
|
+
viewSpec = ensureCompiledViewSpec(dirPath);
|
|
11
11
|
}
|
|
12
12
|
return { health, viewSpec, rawSnapshot };
|
|
13
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
1
|
+
import { type CompiledHealth, type CompiledStage, type RuntimeStatus } from "./schema.js";
|
|
2
|
+
export declare function computeCompiledHealth(dirPath: string): CompiledHealth;
|
|
3
|
+
export declare function resolveCompiledStatus(..._args: unknown[]): RuntimeStatus;
|
|
4
|
+
export declare function resolveCompiledStage(...args: unknown[]): CompiledStage;
|