@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
|
@@ -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,86 @@ 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:
|
|
74
|
-
...(
|
|
75
|
-
...(
|
|
76
|
-
...(
|
|
77
|
-
...(typeof
|
|
78
|
-
|
|
86
|
+
datasets: datasets.map((dataset) => ({
|
|
87
|
+
name: dataset.name,
|
|
88
|
+
...(dataset.path && dataset.path !== "." ? { path: dataset.path } : {}),
|
|
89
|
+
...(dataset.about ? { about: dataset.about } : {}),
|
|
90
|
+
...(dataset.workflow && dataset.workflow !== "interf" ? { workflow: dataset.workflow } : {}),
|
|
91
|
+
...(typeof dataset.max_attempts === "number" ? { max_attempts: dataset.max_attempts } : {}),
|
|
92
|
+
...(typeof dataset.max_loops === "number" ? { max_loops: dataset.max_loops } : {}),
|
|
93
|
+
checks: dataset.checks,
|
|
79
94
|
})),
|
|
80
95
|
};
|
|
81
96
|
}
|
|
82
97
|
return {};
|
|
83
98
|
}
|
|
84
99
|
export function saveSourceFolderConfig(sourcePath, config) {
|
|
85
|
-
writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(
|
|
100
|
+
writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceProjectConfig(config), null, 2) + "\n");
|
|
86
101
|
}
|
|
87
|
-
export function
|
|
102
|
+
export function appendSourceDatasetChecks(sourcePath, datasetName, checks) {
|
|
88
103
|
const existing = loadSourceFolderConfig(sourcePath);
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const currentChecks =
|
|
104
|
+
const currentDataset = findSourceDatasetConfig(existing, datasetName);
|
|
105
|
+
const otherDatasets = listSourceDatasetConfigs(existing).filter((dataset) => dataset.name !== datasetName);
|
|
106
|
+
const currentChecks = currentDataset?.checks ?? [];
|
|
92
107
|
saveSourceFolderConfig(sourcePath, {
|
|
93
|
-
|
|
108
|
+
datasets: [
|
|
94
109
|
{
|
|
95
|
-
name:
|
|
96
|
-
|
|
97
|
-
...(
|
|
98
|
-
...(
|
|
99
|
-
|
|
110
|
+
name: datasetName,
|
|
111
|
+
path: currentDataset?.path ?? ".",
|
|
112
|
+
...(currentDataset?.about ? { about: currentDataset.about } : {}),
|
|
113
|
+
...(currentDataset?.workflow ? { workflow: currentDataset.workflow } : {}),
|
|
114
|
+
...(typeof currentDataset?.max_attempts === "number"
|
|
115
|
+
? { max_attempts: currentDataset.max_attempts }
|
|
100
116
|
: {}),
|
|
101
|
-
...(typeof
|
|
102
|
-
? { max_loops:
|
|
117
|
+
...(typeof currentDataset?.max_loops === "number"
|
|
118
|
+
? { max_loops: currentDataset.max_loops }
|
|
103
119
|
: {}),
|
|
104
120
|
checks: [...currentChecks, ...checks],
|
|
105
121
|
},
|
|
106
|
-
...
|
|
122
|
+
...otherDatasets,
|
|
107
123
|
],
|
|
108
124
|
});
|
|
109
125
|
}
|
|
110
|
-
export function
|
|
126
|
+
export function upsertSourceDatasetConfig(sourcePath, datasetConfig, options = {}) {
|
|
111
127
|
const existing = loadSourceFolderConfig(sourcePath);
|
|
112
|
-
const
|
|
113
|
-
const candidateNames = Array.from(new Set([
|
|
114
|
-
const existingIndex =
|
|
128
|
+
const datasets = listSourceDatasetConfigs(existing);
|
|
129
|
+
const candidateNames = Array.from(new Set([datasetConfig.name, options.matchName].filter((value) => Boolean(value))));
|
|
130
|
+
const existingIndex = datasets.findIndex((entry) => candidateNames.includes(entry.name));
|
|
115
131
|
if (existingIndex >= 0) {
|
|
116
|
-
|
|
132
|
+
datasets[existingIndex] = datasetConfig;
|
|
117
133
|
}
|
|
118
134
|
else {
|
|
119
|
-
|
|
135
|
+
datasets.push(datasetConfig);
|
|
120
136
|
}
|
|
121
137
|
saveSourceFolderConfig(sourcePath, {
|
|
122
|
-
|
|
138
|
+
datasets,
|
|
123
139
|
});
|
|
124
140
|
}
|
|
125
|
-
export function
|
|
141
|
+
export function compiledMaxAttempts(maxAttempts) {
|
|
126
142
|
if (maxAttempts == null)
|
|
127
143
|
return undefined;
|
|
128
|
-
return
|
|
144
|
+
return resolveDatasetCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
|
|
129
145
|
}
|
|
130
|
-
export function
|
|
146
|
+
export function compiledMaxLoops(maxLoops) {
|
|
131
147
|
if (maxLoops == null)
|
|
132
148
|
return undefined;
|
|
133
|
-
return
|
|
149
|
+
return resolveDatasetCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
|
|
134
150
|
}
|
|
135
|
-
export function
|
|
151
|
+
export function sourceDatasetConfigFromInterfConfig(config, datasetPath = ".") {
|
|
136
152
|
return {
|
|
137
153
|
name: config.name,
|
|
154
|
+
path: datasetPath,
|
|
138
155
|
...(config.about ? { about: config.about } : {}),
|
|
139
156
|
...(config.workflow ? { workflow: config.workflow } : {}),
|
|
140
157
|
...(typeof config.max_attempts === "number"
|
|
@@ -146,18 +163,27 @@ export function sourceWorkspaceConfigFromInterfConfig(config) {
|
|
|
146
163
|
checks: config.checks ?? [],
|
|
147
164
|
};
|
|
148
165
|
}
|
|
149
|
-
export function
|
|
150
|
-
const config = readInterfConfig(
|
|
151
|
-
|
|
166
|
+
export function loadCompiledDatasetConfig(compiledPath) {
|
|
167
|
+
const config = readInterfConfig(compiledPath);
|
|
168
|
+
if (!config)
|
|
169
|
+
return null;
|
|
170
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
171
|
+
const datasetPath = typeof config.source?.dataset_path === "string" && config.source.dataset_path.length > 0
|
|
172
|
+
? relative(projectPath, assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Compiled dataset source path")).split(sep).join("/") || "."
|
|
173
|
+
: ".";
|
|
174
|
+
return sourceDatasetConfigFromInterfConfig(config, datasetPath);
|
|
152
175
|
}
|
|
153
|
-
export function
|
|
154
|
-
mkdirSync(
|
|
155
|
-
writeFileSync(
|
|
176
|
+
export function saveCompiledInterfConfig(compiledPath, config) {
|
|
177
|
+
mkdirSync(compiledInterfRoot(compiledPath), { recursive: true });
|
|
178
|
+
writeFileSync(compiledInterfConfigPath(compiledPath), JSON.stringify(config, null, 2) + "\n");
|
|
156
179
|
return config;
|
|
157
180
|
}
|
|
158
|
-
export function
|
|
159
|
-
const current = readInterfConfig(
|
|
160
|
-
const
|
|
181
|
+
export function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig) {
|
|
182
|
+
const current = readInterfConfig(compiledPath);
|
|
183
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
184
|
+
const datasetAbsolutePath = resolve(projectPath, datasetConfig.path ?? ".");
|
|
185
|
+
const datasetRelativePath = relative(compiledPath, datasetAbsolutePath).split(sep).join("/") || ".";
|
|
186
|
+
const workflowId = datasetConfig.workflow ?? current?.workflow ?? "interf";
|
|
161
187
|
const workflowChanged = current?.workflow !== undefined && current.workflow !== workflowId;
|
|
162
188
|
const workflowOrigin = workflowChanged || !current?.workflow_origin
|
|
163
189
|
? {
|
|
@@ -169,88 +195,100 @@ export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath
|
|
|
169
195
|
const nextConfig = {
|
|
170
196
|
...passthrough,
|
|
171
197
|
...(!current ? {
|
|
172
|
-
type: "
|
|
198
|
+
type: "compiled",
|
|
173
199
|
source: {
|
|
174
200
|
path: "./raw",
|
|
175
201
|
},
|
|
176
202
|
} : {}),
|
|
177
|
-
type: "
|
|
178
|
-
name:
|
|
179
|
-
...(
|
|
203
|
+
type: "compiled",
|
|
204
|
+
name: datasetConfig.name,
|
|
205
|
+
...(datasetConfig.about ? { about: datasetConfig.about } : {}),
|
|
180
206
|
workflow: workflowId,
|
|
181
|
-
...(typeof
|
|
182
|
-
? { max_attempts:
|
|
207
|
+
...(typeof datasetConfig.max_attempts === "number"
|
|
208
|
+
? { max_attempts: datasetConfig.max_attempts }
|
|
183
209
|
: {}),
|
|
184
|
-
...(typeof
|
|
185
|
-
? { max_loops:
|
|
210
|
+
...(typeof datasetConfig.max_loops === "number"
|
|
211
|
+
? { max_loops: datasetConfig.max_loops }
|
|
186
212
|
: {}),
|
|
187
|
-
checks:
|
|
213
|
+
checks: datasetConfig.checks,
|
|
188
214
|
workflow_origin: workflowOrigin,
|
|
189
215
|
source: {
|
|
190
216
|
path: current?.source?.path ?? "./raw",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
: { control_path: defaultControlPathForWorkspace(workspacePath) }),
|
|
217
|
+
control_path: defaultControlPathForCompiled(compiledPath),
|
|
218
|
+
dataset_path: datasetRelativePath,
|
|
194
219
|
},
|
|
195
220
|
};
|
|
196
|
-
const saved =
|
|
221
|
+
const saved = saveCompiledInterfConfig(compiledPath, nextConfig);
|
|
197
222
|
if (workflowChanged) {
|
|
198
|
-
const sourcePath =
|
|
199
|
-
const selectedWorkflow =
|
|
200
|
-
|
|
201
|
-
|
|
223
|
+
const sourcePath = projectPath;
|
|
224
|
+
const selectedWorkflow = getCompiledWorkflow(workflowId, { sourcePath });
|
|
225
|
+
seedCompiledWorkflowPackage({
|
|
226
|
+
compiledPath,
|
|
202
227
|
sourcePath,
|
|
203
228
|
workflowId: selectedWorkflow.id,
|
|
204
229
|
});
|
|
205
230
|
}
|
|
206
|
-
|
|
231
|
+
refreshCompiledBootstrapGuidance(compiledPath);
|
|
207
232
|
return saved;
|
|
208
233
|
}
|
|
234
|
+
function buildLoadedTestSpec(options) {
|
|
235
|
+
if (options.checks.length === 0)
|
|
236
|
+
return null;
|
|
237
|
+
const testId = options.id ?? slugify(options.name);
|
|
238
|
+
return {
|
|
239
|
+
id: options.targetType === "raw" ? `${testId}-raw` : testId,
|
|
240
|
+
filePath: options.filePath,
|
|
241
|
+
type: options.targetType,
|
|
242
|
+
name: options.name,
|
|
243
|
+
description: options.about ?? options.fallbackDescription,
|
|
244
|
+
cases: normalizeTruthChecks(options.checks),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
209
247
|
export function buildTestSpecFromSourceFolderConfig(options) {
|
|
210
|
-
const { sourcePath, targetName, targetType = "
|
|
248
|
+
const { sourcePath, targetName, targetType = "compiled" } = options;
|
|
211
249
|
const config = loadSourceFolderConfig(sourcePath);
|
|
212
250
|
if (!config)
|
|
213
251
|
return null;
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
252
|
+
const datasets = listSourceDatasetConfigs(config);
|
|
253
|
+
if (datasets.length === 0)
|
|
216
254
|
return null;
|
|
217
255
|
const match = targetName
|
|
218
|
-
?
|
|
219
|
-
:
|
|
220
|
-
?
|
|
221
|
-
:
|
|
222
|
-
|
|
223
|
-
if (!match || workspaceChecks.length === 0)
|
|
256
|
+
? datasets.find((entry) => entry.name === targetName)
|
|
257
|
+
: datasets.length === 1
|
|
258
|
+
? datasets[0]
|
|
259
|
+
: getDefaultSourceDatasetConfig(config);
|
|
260
|
+
if (!match)
|
|
224
261
|
return null;
|
|
225
262
|
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,
|
|
263
|
+
return buildLoadedTestSpec({
|
|
264
|
+
id: match.id,
|
|
233
265
|
name: match.name,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
266
|
+
about: match.about,
|
|
267
|
+
checks: match.checks,
|
|
268
|
+
targetType,
|
|
269
|
+
filePath: targetType === "raw"
|
|
270
|
+
? `${configPath}#datasets/${match.name}:file-as-is`
|
|
271
|
+
: `${configPath}#datasets/${match.name}:compiled`,
|
|
272
|
+
fallbackDescription: `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
|
|
273
|
+
});
|
|
237
274
|
}
|
|
238
|
-
export function
|
|
239
|
-
const {
|
|
240
|
-
const config = readInterfConfig(
|
|
241
|
-
const
|
|
242
|
-
if (!config
|
|
275
|
+
export function buildTestSpecFromCompiledDatasetConfig(options) {
|
|
276
|
+
const { compiledPath, targetType = "compiled" } = options;
|
|
277
|
+
const config = readInterfConfig(compiledPath);
|
|
278
|
+
const configPath = compiledInterfConfigPath(compiledPath);
|
|
279
|
+
if (!config)
|
|
243
280
|
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,
|
|
281
|
+
return buildLoadedTestSpec({
|
|
252
282
|
name: config.name,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
283
|
+
about: config.about,
|
|
284
|
+
checks: config.checks ?? [],
|
|
285
|
+
targetType,
|
|
286
|
+
filePath: targetType === "raw"
|
|
287
|
+
? `${configPath}#checks:file-as-is`
|
|
288
|
+
: `${configPath}#checks:compiled`,
|
|
289
|
+
fallbackDescription: "Derived from compiled-dataset truth checks.",
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export function resolveSourceDatasetPath(projectPath, datasetConfig) {
|
|
293
|
+
return assertPathWithinRoot(projectPath, resolve(projectPath, datasetConfig.path ?? "."), "Dataset path");
|
|
256
294
|
}
|
|
@@ -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;
|