@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
|
@@ -4,10 +4,10 @@ import { createWorkflowImprovementShell, freezeWorkflowImprovementShell, } from
|
|
|
4
4
|
import { readInterfConfig } from "./interf.js";
|
|
5
5
|
import { validateWorkflowPackage } from "./local-workflows.js";
|
|
6
6
|
import { readJsonFileWithSchema } from "./parse.js";
|
|
7
|
-
import {
|
|
7
|
+
import { saveCompiledInterfConfig } from "./source-config.js";
|
|
8
8
|
import { WorkflowImprovementRunLedgerSchema, } from "./schema.js";
|
|
9
9
|
import { resolveWorkflowImprovementReviewPaths } from "./workflow-review-paths.js";
|
|
10
|
-
import {
|
|
10
|
+
import { targetTestRunsRootForCompiled, targetTestSandboxesRootForCompiled, workflowImprovementRunRoot, workflowPackagePathForCompiled, } from "./compiled-paths.js";
|
|
11
11
|
function copyDirectory(sourcePath, targetPath) {
|
|
12
12
|
rmSync(targetPath, { recursive: true, force: true });
|
|
13
13
|
mkdirSync(targetPath, { recursive: true });
|
|
@@ -55,31 +55,31 @@ function toShellArtifactPath(absolutePath, sourceRoot, shellRoot) {
|
|
|
55
55
|
const relativePath = relative(sourceRoot, absolutePath);
|
|
56
56
|
return join(shellRoot, relativePath);
|
|
57
57
|
}
|
|
58
|
-
function mapLoopSummaryForShell(summary,
|
|
58
|
+
function mapLoopSummaryForShell(summary, compiledPath) {
|
|
59
59
|
const shellTestRunsRoot = "artifacts/test-runs";
|
|
60
60
|
const shellTestSandboxesRoot = "artifacts/test-sandboxes";
|
|
61
61
|
return {
|
|
62
62
|
...summary,
|
|
63
|
-
test_run_path: toShellArtifactPath(summary.test_run_path,
|
|
64
|
-
test_sandbox_path: toShellArtifactPath(summary.test_sandbox_path,
|
|
63
|
+
test_run_path: toShellArtifactPath(summary.test_run_path, targetTestRunsRootForCompiled(compiledPath), shellTestRunsRoot) ?? summary.test_run_path ?? null,
|
|
64
|
+
test_sandbox_path: toShellArtifactPath(summary.test_sandbox_path, targetTestSandboxesRootForCompiled(compiledPath), shellTestSandboxesRoot) ?? summary.test_sandbox_path ?? null,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
function buildLoopContext(options) {
|
|
68
|
-
const previousVariations = options.previousVariations.map((summary) => mapLoopSummaryForShell(summary, options.
|
|
68
|
+
const previousVariations = options.previousVariations.map((summary) => mapLoopSummaryForShell(summary, options.compiledPath));
|
|
69
69
|
const latestFailure = previousVariations.at(-1) ?? null;
|
|
70
70
|
return {
|
|
71
71
|
kind: "interf-workflow-improvement-loop",
|
|
72
72
|
version: 1,
|
|
73
73
|
generated_at: new Date().toISOString(),
|
|
74
|
-
target_name: readInterfConfig(options.
|
|
74
|
+
target_name: readInterfConfig(options.compiledPath)?.name ?? "compiled",
|
|
75
75
|
workflow_id: options.workflowId,
|
|
76
76
|
loop_index: options.loopIndex,
|
|
77
77
|
max_loops: options.maxLoops,
|
|
78
78
|
max_attempts: options.maxAttempts,
|
|
79
|
-
review_paths: resolveWorkflowImprovementReviewPaths(options.
|
|
79
|
+
review_paths: resolveWorkflowImprovementReviewPaths(options.compiledPath),
|
|
80
80
|
truth_checks: {
|
|
81
|
-
count: options.
|
|
82
|
-
questions: options.
|
|
81
|
+
count: options.compiledConfig.checks.length,
|
|
82
|
+
questions: options.compiledConfig.checks.map((check, index) => ({
|
|
83
83
|
id: check.id ?? `check-${index + 1}`,
|
|
84
84
|
question: check.question,
|
|
85
85
|
})),
|
|
@@ -93,21 +93,21 @@ function buildWorkflowImprovementPrompt() {
|
|
|
93
93
|
"This is an automated Interf Compiler workflow-improvement run, not an open-ended chat session.",
|
|
94
94
|
"The user already invoked this through `interf compile` with self-improving loops enabled. Execute it now.",
|
|
95
95
|
"Read `runtime/loop-context.json` first.",
|
|
96
|
-
"Then read `workflow/README.md`, `workflow/workflow.json`, `workflow/
|
|
96
|
+
"Then read `workflow/README.md`, `workflow/workflow.json`, `workflow/compiled.schema.json`, and `workflow/improve/SKILL.md` if it exists.",
|
|
97
97
|
"Review preserved evidence from earlier failures under `artifacts/` before you edit the workflow.",
|
|
98
98
|
"Treat `workflow/improve/SKILL.md` as guidance for how to improve the workflow, not as the default file to edit.",
|
|
99
99
|
"Prefer editing the stage docs, workflow contract, or schema ownership that actually change compiled outputs.",
|
|
100
100
|
"Edit only files under `workflow/`.",
|
|
101
|
-
"Do not edit truth checks, test specs, raw dataset files, or generated
|
|
102
|
-
"Keep the workflow valid for the current compiler API and
|
|
101
|
+
"Do not edit truth checks, test specs, raw dataset files, or generated compiled outputs.",
|
|
102
|
+
"Keep the workflow valid for the current compiler API and compiled schema.",
|
|
103
103
|
"Prefer small, defensible changes to workflow docs, stage docs, stage policies, or schema ownership over random churn.",
|
|
104
104
|
"Do not narrate plans or ask follow-up questions.",
|
|
105
105
|
"Only emit user-visible updates that begin with STATUS:, DONE:, BLOCKED:, or ERROR:.",
|
|
106
106
|
"As soon as the workflow edits are complete, stop.",
|
|
107
107
|
].join("\n");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
const current = readInterfConfig(options.
|
|
109
|
+
function updateCompiledWorkflowOrigin(options) {
|
|
110
|
+
const current = readInterfConfig(options.compiledPath);
|
|
111
111
|
if (!current)
|
|
112
112
|
return;
|
|
113
113
|
const nextConfig = {
|
|
@@ -118,27 +118,27 @@ function updateWorkspaceWorkflowOrigin(options) {
|
|
|
118
118
|
...(options.localDraft ? { local_draft: true } : {}),
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
|
-
|
|
121
|
+
saveCompiledInterfConfig(options.compiledPath, nextConfig);
|
|
122
122
|
}
|
|
123
|
-
function workflowImprovementRunLedgerPath(
|
|
124
|
-
return join(workflowImprovementRunRoot(
|
|
123
|
+
function workflowImprovementRunLedgerPath(compiledPath, runId) {
|
|
124
|
+
return join(workflowImprovementRunRoot(compiledPath, runId), "run.json");
|
|
125
125
|
}
|
|
126
|
-
function workflowImprovementLoopHistoryPath(
|
|
127
|
-
return join(workflowImprovementRunRoot(
|
|
126
|
+
function workflowImprovementLoopHistoryPath(compiledPath, runId) {
|
|
127
|
+
return join(workflowImprovementRunRoot(compiledPath, runId), "loop-history.jsonl");
|
|
128
128
|
}
|
|
129
129
|
function workflowImprovementLoopRecordPath(loopRootPath) {
|
|
130
130
|
return join(loopRootPath, "loop.json");
|
|
131
131
|
}
|
|
132
|
-
function readWorkflowImprovementRunLedger(
|
|
133
|
-
const ledgerPath = workflowImprovementRunLedgerPath(
|
|
132
|
+
function readWorkflowImprovementRunLedger(compiledPath, runId) {
|
|
133
|
+
const ledgerPath = workflowImprovementRunLedgerPath(compiledPath, runId);
|
|
134
134
|
if (!existsSync(ledgerPath))
|
|
135
135
|
return null;
|
|
136
136
|
return readJsonFileWithSchema(ledgerPath, "workflow improvement run ledger", WorkflowImprovementRunLedgerSchema);
|
|
137
137
|
}
|
|
138
|
-
function writeWorkflowImprovementRunLedger(
|
|
139
|
-
const runRoot = workflowImprovementRunRoot(
|
|
138
|
+
function writeWorkflowImprovementRunLedger(compiledPath, runId, record, options) {
|
|
139
|
+
const runRoot = workflowImprovementRunRoot(compiledPath, runId);
|
|
140
140
|
mkdirSync(runRoot, { recursive: true });
|
|
141
|
-
const existing = readWorkflowImprovementRunLedger(
|
|
141
|
+
const existing = readWorkflowImprovementRunLedger(compiledPath, runId);
|
|
142
142
|
const generatedAt = existing?.generated_at ?? new Date().toISOString();
|
|
143
143
|
const ledger = {
|
|
144
144
|
kind: "interf-workflow-improvement-run",
|
|
@@ -152,9 +152,9 @@ function writeWorkflowImprovementRunLedger(workspacePath, runId, record, options
|
|
|
152
152
|
max_attempts: options.maxAttempts,
|
|
153
153
|
loops: [...(existing?.loops ?? []), record],
|
|
154
154
|
};
|
|
155
|
-
writeFileSync(workflowImprovementRunLedgerPath(
|
|
155
|
+
writeFileSync(workflowImprovementRunLedgerPath(compiledPath, runId), `${JSON.stringify(ledger, null, 2)}\n`);
|
|
156
156
|
writeFileSync(workflowImprovementLoopRecordPath(record.loop_root_path), `${JSON.stringify(record, null, 2)}\n`);
|
|
157
|
-
appendFileSync(workflowImprovementLoopHistoryPath(
|
|
157
|
+
appendFileSync(workflowImprovementLoopHistoryPath(compiledPath, runId), `${JSON.stringify(record)}\n`);
|
|
158
158
|
}
|
|
159
159
|
function buildWorkflowImprovementLoopRecord(options) {
|
|
160
160
|
return {
|
|
@@ -182,17 +182,17 @@ function buildWorkflowImprovementLoopRecord(options) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
export async function runWorkflowImprovementLoop(options) {
|
|
185
|
-
const
|
|
185
|
+
const compiledName = readInterfConfig(options.compiledPath)?.name ?? "compiled";
|
|
186
186
|
const context = buildLoopContext(options);
|
|
187
187
|
const shell = createWorkflowImprovementShell({
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
compiledPath: options.compiledPath,
|
|
189
|
+
compiledName,
|
|
190
190
|
workflowId: options.workflowId,
|
|
191
191
|
runId: options.runId,
|
|
192
192
|
loopIndex: options.loopIndex,
|
|
193
193
|
context,
|
|
194
194
|
});
|
|
195
|
-
const workflowRoot =
|
|
195
|
+
const workflowRoot = workflowPackagePathForCompiled(options.compiledPath);
|
|
196
196
|
copyDirectory(workflowRoot, shell.workflowBeforePath);
|
|
197
197
|
const prompt = buildWorkflowImprovementPrompt();
|
|
198
198
|
writeFileSync(shell.promptLogPath, `${prompt}\n`);
|
|
@@ -213,8 +213,8 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
213
213
|
if (executeError) {
|
|
214
214
|
copyDirectory(shell.workflowBeforePath, workflowRoot);
|
|
215
215
|
const summary = `Workflow improver failed before completing: ${executeError}`;
|
|
216
|
-
writeWorkflowImprovementRunLedger(options.
|
|
217
|
-
targetName:
|
|
216
|
+
writeWorkflowImprovementRunLedger(options.compiledPath, options.runId, buildWorkflowImprovementLoopRecord({
|
|
217
|
+
targetName: compiledName,
|
|
218
218
|
workflowId: options.workflowId,
|
|
219
219
|
runId: options.runId,
|
|
220
220
|
loopIndex: options.loopIndex,
|
|
@@ -231,7 +231,7 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
231
231
|
result: "executor-failed",
|
|
232
232
|
summary,
|
|
233
233
|
}), {
|
|
234
|
-
targetName:
|
|
234
|
+
targetName: compiledName,
|
|
235
235
|
workflowId: options.workflowId,
|
|
236
236
|
maxLoops: options.maxLoops,
|
|
237
237
|
maxAttempts: options.maxAttempts,
|
|
@@ -248,8 +248,8 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
248
248
|
if (code !== 0) {
|
|
249
249
|
copyDirectory(shell.workflowBeforePath, workflowRoot);
|
|
250
250
|
const summary = `Workflow improver exited with code ${code}.`;
|
|
251
|
-
writeWorkflowImprovementRunLedger(options.
|
|
252
|
-
targetName:
|
|
251
|
+
writeWorkflowImprovementRunLedger(options.compiledPath, options.runId, buildWorkflowImprovementLoopRecord({
|
|
252
|
+
targetName: compiledName,
|
|
253
253
|
workflowId: options.workflowId,
|
|
254
254
|
runId: options.runId,
|
|
255
255
|
loopIndex: options.loopIndex,
|
|
@@ -266,7 +266,7 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
266
266
|
result: "executor-failed",
|
|
267
267
|
summary,
|
|
268
268
|
}), {
|
|
269
|
-
targetName:
|
|
269
|
+
targetName: compiledName,
|
|
270
270
|
workflowId: options.workflowId,
|
|
271
271
|
maxLoops: options.maxLoops,
|
|
272
272
|
maxAttempts: options.maxAttempts,
|
|
@@ -289,8 +289,8 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
289
289
|
const summary = validation.ok
|
|
290
290
|
? "Workflow improver made no workflow edits."
|
|
291
291
|
: `Workflow variation is invalid without any workflow edits: ${validation.summary}`;
|
|
292
|
-
writeWorkflowImprovementRunLedger(options.
|
|
293
|
-
targetName:
|
|
292
|
+
writeWorkflowImprovementRunLedger(options.compiledPath, options.runId, buildWorkflowImprovementLoopRecord({
|
|
293
|
+
targetName: compiledName,
|
|
294
294
|
workflowId: options.workflowId,
|
|
295
295
|
runId: options.runId,
|
|
296
296
|
loopIndex: options.loopIndex,
|
|
@@ -307,7 +307,7 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
307
307
|
result,
|
|
308
308
|
summary,
|
|
309
309
|
}), {
|
|
310
|
-
targetName:
|
|
310
|
+
targetName: compiledName,
|
|
311
311
|
workflowId: options.workflowId,
|
|
312
312
|
maxLoops: options.maxLoops,
|
|
313
313
|
maxAttempts: options.maxAttempts,
|
|
@@ -325,8 +325,8 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
325
325
|
if (!validation.ok) {
|
|
326
326
|
copyDirectory(shell.workflowBeforePath, workflowRoot);
|
|
327
327
|
const summary = `Workflow variation failed validation: ${validation.summary}`;
|
|
328
|
-
writeWorkflowImprovementRunLedger(options.
|
|
329
|
-
targetName:
|
|
328
|
+
writeWorkflowImprovementRunLedger(options.compiledPath, options.runId, buildWorkflowImprovementLoopRecord({
|
|
329
|
+
targetName: compiledName,
|
|
330
330
|
workflowId: options.workflowId,
|
|
331
331
|
runId: options.runId,
|
|
332
332
|
loopIndex: options.loopIndex,
|
|
@@ -343,7 +343,7 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
343
343
|
result: "invalid",
|
|
344
344
|
summary,
|
|
345
345
|
}), {
|
|
346
|
-
targetName:
|
|
346
|
+
targetName: compiledName,
|
|
347
347
|
workflowId: options.workflowId,
|
|
348
348
|
maxLoops: options.maxLoops,
|
|
349
349
|
maxAttempts: options.maxAttempts,
|
|
@@ -357,8 +357,8 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
357
357
|
loopRootPath: shell.loopRootPath,
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
writeWorkflowImprovementRunLedger(options.
|
|
361
|
-
targetName:
|
|
360
|
+
writeWorkflowImprovementRunLedger(options.compiledPath, options.runId, buildWorkflowImprovementLoopRecord({
|
|
361
|
+
targetName: compiledName,
|
|
362
362
|
workflowId: options.workflowId,
|
|
363
363
|
runId: options.runId,
|
|
364
364
|
loopIndex: options.loopIndex,
|
|
@@ -375,13 +375,13 @@ export async function runWorkflowImprovementLoop(options) {
|
|
|
375
375
|
result: "updated",
|
|
376
376
|
summary: "Workflow variation updated and validated.",
|
|
377
377
|
}), {
|
|
378
|
-
targetName:
|
|
378
|
+
targetName: compiledName,
|
|
379
379
|
workflowId: options.workflowId,
|
|
380
380
|
maxLoops: options.maxLoops,
|
|
381
381
|
maxAttempts: options.maxAttempts,
|
|
382
382
|
});
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
updateCompiledWorkflowOrigin({
|
|
384
|
+
compiledPath: options.compiledPath,
|
|
385
385
|
selectedWorkflowId: options.workflowId,
|
|
386
386
|
localDraft: true,
|
|
387
387
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { WorkflowImprovementContext } from "./schema.js";
|
|
2
2
|
export interface WorkflowImprovementReviewSourcePaths {
|
|
3
|
-
|
|
3
|
+
compiledRuntime: string | null;
|
|
4
4
|
testComparisons: string | null;
|
|
5
5
|
executionShells: string | null;
|
|
6
6
|
targetTestRuns: string | null;
|
|
7
7
|
targetTestSandboxes: string | null;
|
|
8
8
|
}
|
|
9
|
-
export declare function resolveWorkflowImprovementReviewSourcePaths(
|
|
10
|
-
export declare function resolveWorkflowImprovementReviewPaths(
|
|
9
|
+
export declare function resolveWorkflowImprovementReviewSourcePaths(compiledPath: string): WorkflowImprovementReviewSourcePaths;
|
|
10
|
+
export declare function resolveWorkflowImprovementReviewPaths(compiledPath: string): WorkflowImprovementContext["review_paths"];
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
export function resolveWorkflowImprovementReviewSourcePaths(
|
|
4
|
-
const
|
|
5
|
-
const testComparisons =
|
|
6
|
-
const executionShells = stageExecutionShellsRoot(
|
|
7
|
-
const targetTestRuns =
|
|
8
|
-
const targetTestSandboxes =
|
|
2
|
+
import { testRootForCompiled, targetTestRunsRootForCompiled, targetTestSandboxesRootForCompiled, stageExecutionShellsRoot, compiledRuntimeRoot, } from "./compiled-paths.js";
|
|
3
|
+
export function resolveWorkflowImprovementReviewSourcePaths(compiledPath) {
|
|
4
|
+
const compiledRuntime = compiledRuntimeRoot(compiledPath);
|
|
5
|
+
const testComparisons = testRootForCompiled(compiledPath);
|
|
6
|
+
const executionShells = stageExecutionShellsRoot(compiledPath);
|
|
7
|
+
const targetTestRuns = targetTestRunsRootForCompiled(compiledPath);
|
|
8
|
+
const targetTestSandboxes = targetTestSandboxesRootForCompiled(compiledPath);
|
|
9
9
|
return {
|
|
10
|
-
|
|
10
|
+
compiledRuntime: existsSync(compiledRuntime) ? compiledRuntime : null,
|
|
11
11
|
testComparisons: existsSync(testComparisons) ? testComparisons : null,
|
|
12
12
|
executionShells: existsSync(executionShells) ? executionShells : null,
|
|
13
13
|
targetTestRuns: existsSync(targetTestRuns) ? targetTestRuns : null,
|
|
14
14
|
targetTestSandboxes: existsSync(targetTestSandboxes) ? targetTestSandboxes : null,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export function resolveWorkflowImprovementReviewPaths(
|
|
18
|
-
const sources = resolveWorkflowImprovementReviewSourcePaths(
|
|
17
|
+
export function resolveWorkflowImprovementReviewPaths(compiledPath) {
|
|
18
|
+
const sources = resolveWorkflowImprovementReviewSourcePaths(compiledPath);
|
|
19
19
|
return {
|
|
20
20
|
workflow_root: "workflow",
|
|
21
|
-
|
|
21
|
+
compiled_runtime: sources.compiledRuntime ? "artifacts/compiled-runtime" : null,
|
|
22
22
|
test_comparisons: sources.testComparisons ? "artifacts/test-comparisons" : null,
|
|
23
23
|
execution_shells: sources.executionShells ? "artifacts/execution-shells" : null,
|
|
24
24
|
test_runs: sources.targetTestRuns ? "artifacts/test-runs" : null,
|
|
@@ -9,7 +9,7 @@ interface WorkflowStageShape<TContractType extends RuntimeContractType> {
|
|
|
9
9
|
}
|
|
10
10
|
interface ExecuteValidatedStageOptions<TContractType extends RuntimeContractType> {
|
|
11
11
|
executor: WorkflowExecutor;
|
|
12
|
-
|
|
12
|
+
compiledPath: string;
|
|
13
13
|
executionPath?: string;
|
|
14
14
|
targetName: string;
|
|
15
15
|
workflow: string;
|
|
@@ -17,9 +17,9 @@ export async function executeValidatedStage(options) {
|
|
|
17
17
|
: undefined;
|
|
18
18
|
const code = await runExecutorStage({
|
|
19
19
|
executor: options.executor,
|
|
20
|
-
|
|
20
|
+
compiledPath: options.compiledPath,
|
|
21
21
|
executionPath: options.executionPath,
|
|
22
|
-
|
|
22
|
+
compiledName: options.targetName,
|
|
23
23
|
workflow: options.workflow,
|
|
24
24
|
workflowSourcePath: options.workflowSourcePath,
|
|
25
25
|
stage: options.stageDefinition.id,
|
|
@@ -42,9 +42,9 @@ export async function executeValidatedSummarizeStage(options) {
|
|
|
42
42
|
: undefined;
|
|
43
43
|
const code = await runExecutorSummarizeStage({
|
|
44
44
|
executor: options.executor,
|
|
45
|
-
|
|
45
|
+
compiledPath: options.compiledPath,
|
|
46
46
|
executionPath: options.executionPath,
|
|
47
|
-
|
|
47
|
+
compiledName: options.targetName,
|
|
48
48
|
workflow: options.workflow,
|
|
49
49
|
workflowSourcePath: options.workflowSourcePath,
|
|
50
50
|
stage: options.stageDefinition.id,
|
|
@@ -64,7 +64,7 @@ function finalizeValidatedStage(options, code) {
|
|
|
64
64
|
options.syncWrites?.();
|
|
65
65
|
options.reconcile?.();
|
|
66
66
|
options.refreshArtifacts?.();
|
|
67
|
-
return validateStageOutcome(options.
|
|
67
|
+
return validateStageOutcome(options.compiledPath, options.validate());
|
|
68
68
|
};
|
|
69
69
|
if (code !== 0) {
|
|
70
70
|
let completionSatisfied = false;
|
|
@@ -79,7 +79,7 @@ function finalizeValidatedStage(options, code) {
|
|
|
79
79
|
if (completionSatisfied) {
|
|
80
80
|
const validation = refreshAndValidate();
|
|
81
81
|
if (validation.ok) {
|
|
82
|
-
markRuntimeRunSucceededAfterValidation(options.
|
|
82
|
+
markRuntimeRunSucceededAfterValidation(options.compiledPath, validation.summary);
|
|
83
83
|
return {
|
|
84
84
|
ok: true,
|
|
85
85
|
code: 0,
|
|
@@ -87,7 +87,7 @@ function finalizeValidatedStage(options, code) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
reportValidationFailure(options.reporter, validation.summary);
|
|
90
|
-
markRuntimeRunFailedAfterValidation(options.
|
|
90
|
+
markRuntimeRunFailedAfterValidation(options.compiledPath, validation.summary);
|
|
91
91
|
return {
|
|
92
92
|
ok: false,
|
|
93
93
|
code,
|
|
@@ -99,7 +99,7 @@ function finalizeValidatedStage(options, code) {
|
|
|
99
99
|
const validation = refreshAndValidate();
|
|
100
100
|
if (!validation.ok) {
|
|
101
101
|
reportValidationFailure(options.reporter, validation.summary);
|
|
102
|
-
markRuntimeRunFailedAfterValidation(options.
|
|
102
|
+
markRuntimeRunFailedAfterValidation(options.compiledPath, validation.summary);
|
|
103
103
|
}
|
|
104
104
|
return {
|
|
105
105
|
ok: validation.ok,
|
package/dist/lib/workflows.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type InterfConfig } from "./interf.js";
|
|
2
2
|
export type { WorkflowReporter, WorkflowStageResult, LocalSkillContractExtension } from "./workflow-helpers.js";
|
|
3
|
-
export { workflowQueryDirectory, workflowImproveDirectory, workflowCompileStageDirectory, emptyLocalSkillContractExtension, buildLocalSkillContractExtension, buildLocalSkillContractExtensionRelativeTo, mergeLocalSkillContractExtensions, buildStageInstructions, reportLine, reportBlankLine, reportValidationFailure,
|
|
4
|
-
export type
|
|
3
|
+
export { workflowQueryDirectory, workflowImproveDirectory, workflowCompileStageDirectory, emptyLocalSkillContractExtension, buildLocalSkillContractExtension, buildLocalSkillContractExtensionRelativeTo, mergeLocalSkillContractExtensions, buildStageInstructions, reportLine, reportBlankLine, reportValidationFailure, resolveStageAcceptance, validateStageOutcome, } from "./workflow-helpers.js";
|
|
4
|
+
export type CompiledCheck = "compiled" | "stage";
|
|
5
5
|
export interface DetectedInterfTarget {
|
|
6
6
|
path: string;
|
|
7
|
-
kind: "
|
|
8
|
-
engineType: "
|
|
7
|
+
kind: "compiled";
|
|
8
|
+
engineType: "compiled";
|
|
9
9
|
config: InterfConfig;
|
|
10
10
|
}
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
11
|
+
export declare function detectCompiled(cwd: string): DetectedInterfTarget | null;
|
|
12
|
+
export declare function createCompiled(name: string, sourcePath: string, workflowId?: string, about?: string, datasetPath?: string): string;
|
|
13
|
+
export declare function verifyCompiledCheck(check: CompiledCheck, compiledPath: string): import("./validate-compiled.js").CompiledWorkflowValidation;
|
|
14
|
+
export { runCompiledSummarize, runCompiledCompile, compileCompiled, resolveCompiledContext, compiledExecutionStages, } from "./compiled-compile.js";
|
|
15
|
+
export type { CompiledSummarizeResult, CompiledCompileResult, CompiledStageExecutionDefinition, StageShellRetentionMode, } from "./compiled-compile.js";
|
package/dist/lib/workflows.js
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCompiled as createCompiledScaffold, } from "./interf.js";
|
|
2
2
|
import { detectInterf } from "./interf.js";
|
|
3
|
-
import {
|
|
4
|
-
export { workflowQueryDirectory, workflowImproveDirectory, workflowCompileStageDirectory, emptyLocalSkillContractExtension, buildLocalSkillContractExtension, buildLocalSkillContractExtensionRelativeTo, mergeLocalSkillContractExtensions, buildStageInstructions, reportLine, reportBlankLine, reportValidationFailure,
|
|
5
|
-
export function
|
|
3
|
+
import { validateCompiledCompile, } from "./validate.js";
|
|
4
|
+
export { workflowQueryDirectory, workflowImproveDirectory, workflowCompileStageDirectory, emptyLocalSkillContractExtension, buildLocalSkillContractExtension, buildLocalSkillContractExtensionRelativeTo, mergeLocalSkillContractExtensions, buildStageInstructions, reportLine, reportBlankLine, reportValidationFailure, resolveStageAcceptance, validateStageOutcome, } from "./workflow-helpers.js";
|
|
5
|
+
export function detectCompiled(cwd) {
|
|
6
6
|
const detected = detectInterf(cwd);
|
|
7
7
|
if (!detected)
|
|
8
8
|
return null;
|
|
9
9
|
return {
|
|
10
10
|
path: detected.path,
|
|
11
|
-
kind: "
|
|
12
|
-
engineType: "
|
|
11
|
+
kind: "compiled",
|
|
12
|
+
engineType: "compiled",
|
|
13
13
|
config: detected.config,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
17
|
-
return
|
|
16
|
+
export function createCompiled(name, sourcePath, workflowId = "interf", about, datasetPath = sourcePath) {
|
|
17
|
+
return createCompiledScaffold(name, sourcePath, workflowId, about, datasetPath);
|
|
18
18
|
}
|
|
19
|
-
export function
|
|
19
|
+
export function verifyCompiledCheck(check, compiledPath) {
|
|
20
20
|
switch (check) {
|
|
21
|
-
case "
|
|
22
|
-
return
|
|
23
|
-
case "
|
|
24
|
-
return
|
|
25
|
-
case "compile":
|
|
26
|
-
return validateWorkspaceCompile(workspacePath);
|
|
21
|
+
case "compiled":
|
|
22
|
+
return validateCompiledCompile(compiledPath);
|
|
23
|
+
case "stage":
|
|
24
|
+
return validateCompiledCompile(compiledPath);
|
|
27
25
|
default: {
|
|
28
26
|
const exhaustiveCheck = check;
|
|
29
|
-
throw new Error(`Unknown
|
|
27
|
+
throw new Error(`Unknown compiled check: ${exhaustiveCheck}`);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
|
-
export {
|
|
31
|
+
export { runCompiledSummarize, runCompiledCompile, compileCompiled, resolveCompiledContext, compiledExecutionStages, } from "./compiled-compile.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interf/compiler",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Interf Compiler is a local runtime for data-processing workflows that turn datasets into compiled
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Interf Compiler is a local runtime for data-processing workflows that turn datasets into compiled datasets for local agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"interf": "dist/bin.js"
|
|
@@ -27,22 +27,23 @@
|
|
|
27
27
|
"test:e2e:claude": "npm run test:acceptance-live -- --agent claude-code",
|
|
28
28
|
"test:e2e:codex": "npm run test:acceptance-live -- --agent codex",
|
|
29
29
|
"test:e2e:quick": "npm run test:e2e:quick:matrix",
|
|
30
|
-
"test:e2e:quick:
|
|
31
|
-
"test:e2e:quick:
|
|
30
|
+
"test:e2e:quick:agent": "node scripts/run-quick-e2e.mjs",
|
|
31
|
+
"test:e2e:quick:claude": "npm run test:e2e:quick:agent -- --agent claude-code",
|
|
32
|
+
"test:e2e:quick:codex": "npm run test:e2e:quick:agent -- --agent codex",
|
|
32
33
|
"test:e2e:quick:matrix": "npm run test:e2e:quick:claude && npm run test:e2e:quick:codex",
|
|
33
34
|
"test:internal:cbre:fast": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-sanity.json",
|
|
34
|
-
"test:internal:cbre:fast:keep": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-sanity.json --keep-
|
|
35
|
+
"test:internal:cbre:fast:keep": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-sanity.json --keep-project-clones",
|
|
35
36
|
"test:internal:cbre:max": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-tier1-max.json",
|
|
36
|
-
"test:internal:cbre:max:keep": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-tier1-max.json --keep-
|
|
37
|
+
"test:internal:cbre:max:keep": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-tier1-max.json --keep-project-clones",
|
|
37
38
|
"test:full": "npm test && npm run test:e2e:quick:matrix",
|
|
38
39
|
"test:release:matrix": "npm run test:internal:cbre:max",
|
|
39
|
-
"test:release": "npm test && npm run test:e2e:claude && npm run test:e2e:codex
|
|
40
|
+
"test:release": "npm test && npm run test:e2e:claude && npm run test:e2e:codex",
|
|
40
41
|
"test:acceptance-live": "npm run build && node scripts/acceptance-live.mjs",
|
|
41
42
|
"test:acceptance-cache:refresh": "npm run test:acceptance-cache:refresh:claude",
|
|
42
43
|
"test:acceptance-cache:refresh:claude": "npm run build && node scripts/acceptance-live.mjs --agent claude-code --output-root .interf-test-cache/claude-code",
|
|
43
44
|
"test:acceptance-cache:refresh:codex": "npm run build && node scripts/acceptance-live.mjs --agent codex --output-root .interf-test-cache/codex",
|
|
44
|
-
"test:acceptance-quick:create-
|
|
45
|
-
"test:acceptance-quick:query
|
|
45
|
+
"test:acceptance-quick:create-compiled": "npm run build && node scripts/acceptance-targeted.mjs create-compiled",
|
|
46
|
+
"test:acceptance-quick:compiled-query": "npm run build && node scripts/acceptance-targeted.mjs compiled-query",
|
|
46
47
|
"test:acceptance-quick:self-improving": "npm run build && node scripts/acceptance-targeted.mjs self-improving-compile",
|
|
47
48
|
"prepublishOnly": "node scripts/prepublish-gate.mjs"
|
|
48
49
|
},
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { SourceWorkspaceConfig } from "../lib/schema.js";
|
|
2
|
-
import { type StageShellRetentionMode } from "../lib/workflows.js";
|
|
3
|
-
import type { WorkflowExecutor } from "../lib/executors.js";
|
|
4
|
-
import type { WorkspaceCompileResult } from "../lib/workflows.js";
|
|
5
|
-
export interface SavedWorkspaceEntry {
|
|
6
|
-
config: SourceWorkspaceConfig;
|
|
7
|
-
path: string | null;
|
|
8
|
-
localDraft: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare function listSavedWorkspaceEntries(sourcePath: string): SavedWorkspaceEntry[];
|
|
11
|
-
export declare function findBuiltWorkspacePath(sourcePath: string, workspaceName: string): string | null;
|
|
12
|
-
export declare function findSavedWorkspaceConfig(sourcePath: string, workspaceName: string): SourceWorkspaceConfig | null;
|
|
13
|
-
export declare function chooseWorkspaceConfigToBuild(options: {
|
|
14
|
-
sourcePath: string;
|
|
15
|
-
selectMessage: string;
|
|
16
|
-
}): Promise<SourceWorkspaceConfig | null | undefined>;
|
|
17
|
-
export declare function createWorkspaceFromConfig(sourcePath: string, workspaceConfig: SourceWorkspaceConfig): string;
|
|
18
|
-
export declare function ensureWorkspaceFromConfig(sourcePath: string, workspaceConfig: SourceWorkspaceConfig): string;
|
|
19
|
-
export declare function compileWorkspaceWithReporter(executor: WorkflowExecutor, workspacePath: string, options?: {
|
|
20
|
-
heading?: string;
|
|
21
|
-
successMessage?: string;
|
|
22
|
-
preserveStageShells?: StageShellRetentionMode;
|
|
23
|
-
}): Promise<WorkspaceCompileResult>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import * as p from "@clack/prompts";
|
|
3
|
-
import { listWorkspacesForSourceFolder } from "../lib/interf.js";
|
|
4
|
-
import { addWorkspace } from "../lib/registry.js";
|
|
5
|
-
import { listSourceWorkspaceConfigs, loadWorkspaceControlConfig, loadSourceFolderConfig, sourceWorkspaceConfigFromInterfConfig, syncWorkspaceInterfConfigFromSourceWorkspaceConfig, } from "../lib/source-config.js";
|
|
6
|
-
import { compileWorkspace, createWorkspace, } from "../lib/workflows.js";
|
|
7
|
-
import { formatWorkflowExecutionProfile } from "../lib/execution-profile.js";
|
|
8
|
-
function formatSavedWorkspaceHint(entry) {
|
|
9
|
-
const config = entry.config;
|
|
10
|
-
const checkCount = config.checks.length;
|
|
11
|
-
const workflowHint = `workflow ${config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`;
|
|
12
|
-
if (config.about)
|
|
13
|
-
return `${config.about} · ${workflowHint}`;
|
|
14
|
-
if (checkCount === 0)
|
|
15
|
-
return "No saved truth checks yet";
|
|
16
|
-
return `${checkCount} saved truth check${checkCount === 1 ? "" : "s"} · ${workflowHint}`;
|
|
17
|
-
}
|
|
18
|
-
export function listSavedWorkspaceEntries(sourcePath) {
|
|
19
|
-
const entries = new Map();
|
|
20
|
-
for (const builtWorkspace of listWorkspacesForSourceFolder(sourcePath)) {
|
|
21
|
-
const workspaceConfig = loadWorkspaceControlConfig(builtWorkspace.path)
|
|
22
|
-
?? sourceWorkspaceConfigFromInterfConfig(builtWorkspace.config);
|
|
23
|
-
entries.set(builtWorkspace.config.name, {
|
|
24
|
-
config: workspaceConfig,
|
|
25
|
-
path: builtWorkspace.path,
|
|
26
|
-
localDraft: builtWorkspace.config.workflow_origin?.local_draft === true,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
for (const config of listSourceWorkspaceConfigs(loadSourceFolderConfig(sourcePath))) {
|
|
30
|
-
if (entries.has(config.name))
|
|
31
|
-
continue;
|
|
32
|
-
entries.set(config.name, {
|
|
33
|
-
config,
|
|
34
|
-
path: null,
|
|
35
|
-
localDraft: false,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return Array.from(entries.values()).sort((left, right) => left.config.name.localeCompare(right.config.name));
|
|
39
|
-
}
|
|
40
|
-
export function findBuiltWorkspacePath(sourcePath, workspaceName) {
|
|
41
|
-
return listSavedWorkspaceEntries(sourcePath).find((entry) => entry.config.name === workspaceName)?.path ?? null;
|
|
42
|
-
}
|
|
43
|
-
export function findSavedWorkspaceConfig(sourcePath, workspaceName) {
|
|
44
|
-
return listSavedWorkspaceEntries(sourcePath).find((entry) => entry.config.name === workspaceName)?.config ?? null;
|
|
45
|
-
}
|
|
46
|
-
export async function chooseWorkspaceConfigToBuild(options) {
|
|
47
|
-
const savedEntries = listSavedWorkspaceEntries(options.sourcePath);
|
|
48
|
-
if (savedEntries.length === 0) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
if (savedEntries.length === 1) {
|
|
52
|
-
return savedEntries[0]?.config ?? null;
|
|
53
|
-
}
|
|
54
|
-
const selected = await p.select({
|
|
55
|
-
message: options.selectMessage,
|
|
56
|
-
options: savedEntries.map((entry) => ({
|
|
57
|
-
value: entry.config.name,
|
|
58
|
-
label: entry.config.name,
|
|
59
|
-
hint: [
|
|
60
|
-
formatSavedWorkspaceHint(entry),
|
|
61
|
-
entry.path ? "built" : "not built yet",
|
|
62
|
-
].join(" · "),
|
|
63
|
-
})),
|
|
64
|
-
});
|
|
65
|
-
if (p.isCancel(selected))
|
|
66
|
-
return undefined;
|
|
67
|
-
return savedEntries.find((entry) => entry.config.name === selected)?.config ?? null;
|
|
68
|
-
}
|
|
69
|
-
export function createWorkspaceFromConfig(sourcePath, workspaceConfig) {
|
|
70
|
-
const workflowId = workspaceConfig.workflow ?? "interf";
|
|
71
|
-
const workspacePath = createWorkspace(workspaceConfig.name, sourcePath, workflowId, workspaceConfig.about);
|
|
72
|
-
syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath, workspaceConfig);
|
|
73
|
-
addWorkspace(workspaceConfig.name, workspacePath, workflowId);
|
|
74
|
-
return workspacePath;
|
|
75
|
-
}
|
|
76
|
-
export function ensureWorkspaceFromConfig(sourcePath, workspaceConfig) {
|
|
77
|
-
const existingPath = findBuiltWorkspacePath(sourcePath, workspaceConfig.name);
|
|
78
|
-
if (existingPath) {
|
|
79
|
-
syncWorkspaceInterfConfigFromSourceWorkspaceConfig(existingPath, workspaceConfig);
|
|
80
|
-
addWorkspace(workspaceConfig.name, existingPath, workspaceConfig.workflow ?? "interf");
|
|
81
|
-
return existingPath;
|
|
82
|
-
}
|
|
83
|
-
return createWorkspaceFromConfig(sourcePath, workspaceConfig);
|
|
84
|
-
}
|
|
85
|
-
export async function compileWorkspaceWithReporter(executor, workspacePath, options = {}) {
|
|
86
|
-
console.log();
|
|
87
|
-
console.log(chalk.bold(` ${options.heading ?? "Building compiled workspace..."}`));
|
|
88
|
-
const profileLabel = formatWorkflowExecutionProfile(executor.executionProfile);
|
|
89
|
-
if (profileLabel) {
|
|
90
|
-
console.log(chalk.dim(` Execution profile: ${profileLabel}`));
|
|
91
|
-
}
|
|
92
|
-
console.log();
|
|
93
|
-
const reporter = {
|
|
94
|
-
line: (message) => console.log(chalk.dim(` ${message}`)),
|
|
95
|
-
blankLine: () => console.log(),
|
|
96
|
-
};
|
|
97
|
-
const result = await compileWorkspace({
|
|
98
|
-
executor,
|
|
99
|
-
workspacePath,
|
|
100
|
-
reporter,
|
|
101
|
-
preserveStageShells: options.preserveStageShells,
|
|
102
|
-
});
|
|
103
|
-
if (!result.ok) {
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
console.log();
|
|
107
|
-
console.log(chalk.green(` ✓ ${options.successMessage ?? "Compiled workspace ready."}`));
|
|
108
|
-
return result;
|
|
109
|
-
}
|