@interf/compiler 0.5.0 → 0.6.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 +126 -188
- package/builtin-workflows/interf/README.md +22 -10
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +6 -3
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +3 -0
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -2
- package/builtin-workflows/interf/improve/SKILL.md +2 -2
- package/builtin-workflows/interf/workflow.json +18 -4
- package/builtin-workflows/interf/{compiled.schema.json → workflow.schema.json} +9 -2
- package/dist/commands/check-draft.js +3 -3
- package/dist/commands/compile-controller.js +9 -16
- package/dist/commands/compile.d.ts +19 -1
- package/dist/commands/compile.js +98 -28
- package/dist/commands/create-workflow-wizard.d.ts +20 -2
- package/dist/commands/create-workflow-wizard.js +163 -27
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +67 -60
- package/dist/commands/dataset-selection.d.ts +6 -0
- package/dist/commands/dataset-selection.js +11 -0
- package/dist/commands/default.js +3 -3
- package/dist/commands/doctor.js +8 -8
- package/dist/commands/executor-flow.d.ts +1 -1
- package/dist/commands/executor-flow.js +5 -2
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +56 -48
- package/dist/commands/list.js +6 -3
- package/dist/commands/reset.js +1 -1
- package/dist/commands/source-config-wizard.d.ts +2 -2
- package/dist/commands/source-config-wizard.js +50 -17
- package/dist/commands/test-flow.js +5 -16
- package/dist/commands/test.d.ts +0 -6
- package/dist/commands/test.js +9 -17
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/agent-args.d.ts +1 -0
- package/dist/lib/agent-args.js +10 -0
- package/dist/lib/agent-execution.js +2 -1
- package/dist/lib/agent-preflight.js +2 -1
- package/dist/lib/agent-shells.d.ts +26 -1
- package/dist/lib/agent-shells.js +214 -40
- package/dist/lib/agents.d.ts +1 -1
- package/dist/lib/agents.js +1 -1
- package/dist/lib/builtin-compiled-workflow.d.ts +38 -0
- package/dist/lib/builtin-compiled-workflow.js +94 -0
- package/dist/lib/compiled-compile.d.ts +0 -4
- package/dist/lib/compiled-compile.js +11 -30
- package/dist/lib/compiled-paths.d.ts +1 -2
- package/dist/lib/compiled-paths.js +8 -13
- package/dist/lib/compiled-raw.d.ts +2 -2
- package/dist/lib/compiled-reset.d.ts +1 -0
- package/dist/lib/compiled-reset.js +42 -14
- package/dist/lib/compiled-schema.d.ts +11 -7
- package/dist/lib/compiled-schema.js +47 -16
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +2 -2
- package/dist/lib/executors.d.ts +1 -1
- package/dist/lib/executors.js +2 -2
- package/dist/lib/interf-detect.d.ts +0 -1
- package/dist/lib/interf-detect.js +7 -18
- package/dist/lib/interf-scaffold.js +4 -11
- package/dist/lib/interf-workflow-package.d.ts +8 -3
- package/dist/lib/interf-workflow-package.js +128 -62
- package/dist/lib/interf.d.ts +1 -1
- package/dist/lib/interf.js +1 -1
- package/dist/lib/local-workflows.d.ts +4 -3
- package/dist/lib/local-workflows.js +127 -104
- package/dist/lib/project-paths.d.ts +2 -4
- package/dist/lib/project-paths.js +13 -10
- package/dist/lib/runtime-acceptance.js +15 -3
- package/dist/lib/runtime-contracts.js +3 -2
- package/dist/lib/runtime-paths.d.ts +1 -0
- package/dist/lib/runtime-paths.js +4 -1
- package/dist/lib/runtime-prompt.js +4 -4
- package/dist/lib/runtime-reconcile.js +90 -64
- package/dist/lib/runtime-runs.js +29 -102
- package/dist/lib/runtime.d.ts +1 -1
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/schema.d.ts +104 -54
- package/dist/lib/schema.js +32 -116
- package/dist/lib/source-config.js +21 -22
- package/dist/lib/state-health.js +4 -2
- package/dist/lib/state-io.js +2 -110
- package/dist/lib/state-view.js +8 -8
- package/dist/lib/state.d.ts +1 -0
- package/dist/lib/state.js +7 -0
- package/dist/lib/test-execution.js +2 -2
- package/dist/lib/test-paths.js +12 -3
- package/dist/lib/test-sandbox.js +4 -17
- package/dist/lib/test-specs.js +1 -1
- package/dist/lib/validate-compiled.js +13 -8
- package/dist/lib/validate.d.ts +5 -1
- package/dist/lib/validate.js +30 -22
- package/dist/lib/workflow-authoring.d.ts +26 -0
- package/dist/lib/workflow-authoring.js +119 -0
- package/dist/lib/workflow-definitions.d.ts +14 -3
- package/dist/lib/workflow-definitions.js +21 -17
- package/dist/lib/workflow-edit-session.d.ts +16 -0
- package/dist/lib/workflow-edit-session.js +57 -0
- package/dist/lib/workflow-edit-utils.d.ts +10 -0
- package/dist/lib/workflow-edit-utils.js +39 -0
- package/dist/lib/workflow-improvement.js +30 -217
- package/dist/lib/workflow-primitives.d.ts +2 -0
- package/dist/lib/workflow-primitives.js +5 -0
- package/dist/lib/workflow-stage-policy.d.ts +5 -0
- package/dist/lib/workflow-stage-policy.js +31 -0
- package/package.json +7 -8
- package/dist/lib/compiled-layout.d.ts +0 -2
- package/dist/lib/compiled-layout.js +0 -60
- package/dist/lib/obsidian.d.ts +0 -1
- package/dist/lib/obsidian.js +0 -15
- package/dist/lib/summarize-plan.d.ts +0 -17
- package/dist/lib/summarize-plan.js +0 -124
- package/dist/lib/workflow-abi.d.ts +0 -129
- package/dist/lib/workflow-abi.js +0 -156
|
@@ -5,7 +5,7 @@ import { reconcileCompiledStageRun, } from "./runtime-reconcile.js";
|
|
|
5
5
|
import { refreshCompiledArtifacts, } from "./state.js";
|
|
6
6
|
import { buildRuntimeStageContract, } from "./runtime.js";
|
|
7
7
|
import { validateWorkflowPackage } from "./local-workflows.js";
|
|
8
|
-
import { formatActiveCompiledWorkflowStageStep, getActiveCompiledStagePolicyNotes, getActiveCompiledWorkflow,
|
|
8
|
+
import { formatActiveCompiledWorkflowStageStep, getActiveCompiledStagePolicyNotes, getActiveCompiledWorkflow, resolveRequiredCompiledWorkflowFromConfig, resolveActiveCompiledStageAcceptance, } from "./workflow-definitions.js";
|
|
9
9
|
import { validateCompiledStage, validateCompiledWorkflow, } from "./validate.js";
|
|
10
10
|
import { buildLocalSkillContractExtension, buildStageInstructions, reportBlankLine, reportLine, reportValidationFailure, workflowCompileStageDirectory, } from "./workflow-helpers.js";
|
|
11
11
|
import { executeValidatedStage, } from "./workflow-stage-runner.js";
|
|
@@ -16,7 +16,7 @@ import { discoverSourceFiles } from "./discovery.js";
|
|
|
16
16
|
import { listFilesRecursive } from "./filesystem.js";
|
|
17
17
|
export function resolveCompiledContext(compiledPath) {
|
|
18
18
|
const config = readInterfConfig(compiledPath);
|
|
19
|
-
const workflowId =
|
|
19
|
+
const workflowId = resolveRequiredCompiledWorkflowFromConfig(config, `.interf/interf.json for ${compiledPath}`);
|
|
20
20
|
return {
|
|
21
21
|
compiledName: config?.name ?? "compiled",
|
|
22
22
|
sourcePath: resolveSourceFolderPath(compiledPath, config),
|
|
@@ -44,7 +44,7 @@ function zoneArtifactCount(compiledPath, zonePath, kind) {
|
|
|
44
44
|
function resolveStageContractArtifacts(compiledPath, stageDefinition) {
|
|
45
45
|
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
46
46
|
if (!schema) {
|
|
47
|
-
throw new Error(`Missing
|
|
47
|
+
throw new Error(`Missing workflow schema for stage "${stageDefinition.id}" at ${workflowPackagePathForCompiled(compiledPath)}.`);
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
50
|
reads: compiledContractArtifactPathsForZoneIds(schema, stageDefinition.reads),
|
|
@@ -198,10 +198,6 @@ export async function compileCompiled(options) {
|
|
|
198
198
|
ok: true,
|
|
199
199
|
stageResults: {},
|
|
200
200
|
failedStage: null,
|
|
201
|
-
summarize: null,
|
|
202
|
-
structure: null,
|
|
203
|
-
shape: null,
|
|
204
|
-
compile: null,
|
|
205
201
|
};
|
|
206
202
|
try {
|
|
207
203
|
const sourceInputPath = resolveSourceInputPath(options.compiledPath);
|
|
@@ -214,10 +210,13 @@ export async function compileCompiled(options) {
|
|
|
214
210
|
...result,
|
|
215
211
|
ok: false,
|
|
216
212
|
failedStage: "workflow",
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
stageResults: {
|
|
214
|
+
...result.stageResults,
|
|
215
|
+
workflow: {
|
|
216
|
+
ok: false,
|
|
217
|
+
code: 1,
|
|
218
|
+
summary: workflowValidation.summary,
|
|
219
|
+
},
|
|
221
220
|
},
|
|
222
221
|
};
|
|
223
222
|
}
|
|
@@ -232,34 +231,16 @@ export async function compileCompiled(options) {
|
|
|
232
231
|
stageDefinition,
|
|
233
232
|
});
|
|
234
233
|
result.stageResults[stageDefinition.id] = stageResult;
|
|
235
|
-
if (stageDefinition.id === "summarize") {
|
|
236
|
-
result.summarize = {
|
|
237
|
-
...stageResult,
|
|
238
|
-
skipped: false,
|
|
239
|
-
plan: {
|
|
240
|
-
sourceCount: discoverSourceFiles(context.sourcePath, options.compiledPath).totalCount,
|
|
241
|
-
summaryCount: 0,
|
|
242
|
-
targetCount: discoverSourceFiles(context.sourcePath, options.compiledPath).totalCount,
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
else if (stageDefinition.id === "structure") {
|
|
247
|
-
result.structure = stageResult;
|
|
248
|
-
}
|
|
249
|
-
else if (stageDefinition.id === "shape") {
|
|
250
|
-
result.shape = stageResult;
|
|
251
|
-
}
|
|
252
234
|
if (!stageResult.ok) {
|
|
253
235
|
result.ok = false;
|
|
254
236
|
result.failedStage = stageDefinition.id;
|
|
255
|
-
result.compile = stageResult;
|
|
256
237
|
return result;
|
|
257
238
|
}
|
|
258
239
|
}
|
|
259
240
|
const workflowValidationResult = validateCompiledWorkflow(options.compiledPath);
|
|
260
241
|
result.ok = workflowValidationResult.ok;
|
|
261
242
|
result.failedStage = workflowValidationResult.ok ? null : workflowValidationResult.stage;
|
|
262
|
-
result.
|
|
243
|
+
result.stageResults.compiled = {
|
|
263
244
|
ok: workflowValidationResult.ok,
|
|
264
245
|
code: workflowValidationResult.ok ? 0 : 1,
|
|
265
246
|
summary: workflowValidationResult.summary,
|
|
@@ -18,9 +18,7 @@ export declare function compiledInterfRoot(compiledPath: string): string;
|
|
|
18
18
|
export declare function compiledInterfConfigPath(compiledPath: string): string;
|
|
19
19
|
export declare function workflowPackagePathForCompiled(compiledPath: string): string;
|
|
20
20
|
export declare function testRootForCompiled(compiledPath: string): string;
|
|
21
|
-
export declare function testRunsRootForCompiled(compiledPath: string): string;
|
|
22
21
|
export declare function testTargetsRootForCompiled(compiledPath: string): string;
|
|
23
|
-
export declare function latestTestComparisonPathForCompiled(compiledPath: string): string;
|
|
24
22
|
export declare function stageExecutionShellsRoot(compiledPath: string): string;
|
|
25
23
|
export declare function workflowImprovementLoopsRoot(compiledPath: string): string;
|
|
26
24
|
export declare function workflowImprovementRunRoot(compiledPath: string, runId: string): string;
|
|
@@ -28,6 +26,7 @@ export declare function workflowImprovementLoopRoot(compiledPath: string, runId:
|
|
|
28
26
|
export declare function targetTestRunsRootForCompiled(compiledPath: string): string;
|
|
29
27
|
export declare function targetTestSandboxesRootForCompiled(compiledPath: string): string;
|
|
30
28
|
export declare function compiledRuntimeLogsRoot(compiledPath: string): string;
|
|
29
|
+
export declare function compiledRuntimeArchivedStageContractPath(compiledPath: string, runId: string): string;
|
|
31
30
|
export declare function compiledQueryAcceptanceRoot(compiledPath: string): string;
|
|
32
31
|
export declare function compiledRuntimeStatePath(compiledPath: string): string;
|
|
33
32
|
export declare function compiledRuntimeHealthPath(compiledPath: string): string;
|
|
@@ -31,15 +31,9 @@ export function workflowPackagePathForCompiled(compiledPath) {
|
|
|
31
31
|
export function testRootForCompiled(compiledPath) {
|
|
32
32
|
return join(compiledInterfRoot(compiledPath), COMPILED_TEST_DIR);
|
|
33
33
|
}
|
|
34
|
-
export function testRunsRootForCompiled(compiledPath) {
|
|
35
|
-
return join(testRootForCompiled(compiledPath), "runs");
|
|
36
|
-
}
|
|
37
34
|
export function testTargetsRootForCompiled(compiledPath) {
|
|
38
35
|
return join(testRootForCompiled(compiledPath), COMPILED_TEST_TARGETS_DIR);
|
|
39
36
|
}
|
|
40
|
-
export function latestTestComparisonPathForCompiled(compiledPath) {
|
|
41
|
-
return join(testRootForCompiled(compiledPath), "latest.json");
|
|
42
|
-
}
|
|
43
37
|
export function stageExecutionShellsRoot(compiledPath) {
|
|
44
38
|
return join(compiledRuntimeRoot(compiledPath), "execution-shells");
|
|
45
39
|
}
|
|
@@ -61,6 +55,9 @@ export function targetTestSandboxesRootForCompiled(compiledPath) {
|
|
|
61
55
|
export function compiledRuntimeLogsRoot(compiledPath) {
|
|
62
56
|
return join(compiledRuntimeRoot(compiledPath), "logs");
|
|
63
57
|
}
|
|
58
|
+
export function compiledRuntimeArchivedStageContractPath(compiledPath, runId) {
|
|
59
|
+
return join(compiledRuntimeLogsRoot(compiledPath), `${runId}.stage-contract.json`);
|
|
60
|
+
}
|
|
64
61
|
export function compiledQueryAcceptanceRoot(compiledPath) {
|
|
65
62
|
return join(compiledRuntimeRoot(compiledPath), "query-acceptance");
|
|
66
63
|
}
|
|
@@ -91,14 +88,12 @@ export function compiledRuntimeStageContractPath(compiledPath) {
|
|
|
91
88
|
export function resolveSourceControlPathForCompiled(compiledPath) {
|
|
92
89
|
let cursor = resolve(compiledPath);
|
|
93
90
|
while (true) {
|
|
94
|
-
if (basename(cursor) === "compiled") {
|
|
95
|
-
const datasetRoot = dirname(cursor);
|
|
96
|
-
const interfRoot = dirname(datasetRoot);
|
|
97
|
-
if (basename(interfRoot) === "interf") {
|
|
98
|
-
return dirname(interfRoot);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
91
|
const parent = dirname(cursor);
|
|
92
|
+
if (basename(parent) === "interf" &&
|
|
93
|
+
basename(cursor) !== "tests" &&
|
|
94
|
+
basename(cursor) !== "workflows") {
|
|
95
|
+
return dirname(parent);
|
|
96
|
+
}
|
|
102
97
|
if (parent === cursor)
|
|
103
98
|
break;
|
|
104
99
|
cursor = parent;
|
|
@@ -9,6 +9,7 @@ export declare function resolveCompiledRawPath(compiledPath: string, config?: {
|
|
|
9
9
|
[x: string]: unknown;
|
|
10
10
|
type: "compiled";
|
|
11
11
|
name: string;
|
|
12
|
+
workflow: string;
|
|
12
13
|
checks: {
|
|
13
14
|
question: string;
|
|
14
15
|
id?: string | undefined;
|
|
@@ -24,11 +25,10 @@ export declare function resolveCompiledRawPath(compiledPath: string, config?: {
|
|
|
24
25
|
}[];
|
|
25
26
|
source: {
|
|
26
27
|
path: string;
|
|
28
|
+
dataset_path: string;
|
|
27
29
|
control_path?: string | undefined;
|
|
28
|
-
dataset_path?: string | undefined;
|
|
29
30
|
};
|
|
30
31
|
about?: string | undefined;
|
|
31
|
-
workflow?: string | undefined;
|
|
32
32
|
max_attempts?: number | undefined;
|
|
33
33
|
max_loops?: number | undefined;
|
|
34
34
|
workflow_origin?: {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { existsSync, rmSync } from "node:fs";
|
|
1
|
+
import { existsSync, readdirSync, rmSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { stageExecutionShellsRoot, testRootForCompiled, testTargetsRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeRoot, compiledRuntimeLogsRoot, } from "./compiled-paths.js";
|
|
3
|
+
import { readCompiledSchemaFile, } from "./compiled-schema.js";
|
|
4
|
+
import { initializeCompiledRuntimeState, } from "./state.js";
|
|
5
|
+
import { stageExecutionShellsRoot, testRootForCompiled, testTargetsRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeRoot, compiledRuntimeLogsRoot, workflowPackagePathForCompiled, } from "./compiled-paths.js";
|
|
7
6
|
function removeIfExists(path) {
|
|
8
7
|
if (existsSync(path)) {
|
|
9
8
|
rmSync(path, { recursive: true, force: true });
|
|
@@ -15,24 +14,53 @@ const COMPILE_RUNTIME_RESET_ENTRIES = [
|
|
|
15
14
|
"view-spec.json",
|
|
16
15
|
"inventory.json",
|
|
17
16
|
"run.json",
|
|
17
|
+
"raw-snapshot.json",
|
|
18
18
|
"stage-contract.json",
|
|
19
|
-
"summarize-targets.json",
|
|
20
19
|
];
|
|
21
|
-
|
|
20
|
+
const PRESERVED_COMPILED_ROOTS = new Set([
|
|
21
|
+
".agents",
|
|
22
|
+
".claude",
|
|
23
|
+
".codex",
|
|
24
|
+
".cursor",
|
|
25
|
+
".gitignore",
|
|
26
|
+
".interf",
|
|
27
|
+
".interfignore",
|
|
28
|
+
"AGENTS.md",
|
|
29
|
+
"CLAUDE.md",
|
|
30
|
+
]);
|
|
31
|
+
export function clearCompiledRuntimeDerivedArtifacts(compiledPath) {
|
|
22
32
|
const runtimeRoot = compiledRuntimeRoot(compiledPath);
|
|
23
33
|
for (const entry of COMPILE_RUNTIME_RESET_ENTRIES) {
|
|
24
34
|
removeIfExists(join(runtimeRoot, entry));
|
|
25
35
|
}
|
|
26
36
|
removeIfExists(compiledQueryAcceptanceRoot(compiledPath));
|
|
27
37
|
}
|
|
38
|
+
function activeCompiledInputRoots(compiledPath) {
|
|
39
|
+
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
40
|
+
const roots = new Set();
|
|
41
|
+
for (const zone of schema?.zones ?? []) {
|
|
42
|
+
if (zone.role !== "input")
|
|
43
|
+
continue;
|
|
44
|
+
const root = zone.path.split("/")[0]?.trim();
|
|
45
|
+
if (root)
|
|
46
|
+
roots.add(root);
|
|
47
|
+
}
|
|
48
|
+
return roots;
|
|
49
|
+
}
|
|
50
|
+
function resetCompiledGeneratedOutputs(compiledPath) {
|
|
51
|
+
const preservedInputRoots = activeCompiledInputRoots(compiledPath);
|
|
52
|
+
for (const entry of readdirSync(compiledPath)) {
|
|
53
|
+
if (PRESERVED_COMPILED_ROOTS.has(entry))
|
|
54
|
+
continue;
|
|
55
|
+
if (preservedInputRoots.has(entry))
|
|
56
|
+
continue;
|
|
57
|
+
removeIfExists(join(compiledPath, entry));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
28
60
|
export function resetCompiledGeneratedState(compiledPath, scope = "compile") {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
resetCompiledRuntimeFiles(compiledPath);
|
|
33
|
-
saveState(compiledPath, initCompiledState());
|
|
34
|
-
saveEmptyCompiledInventory(compiledPath);
|
|
35
|
-
refreshCompiledArtifacts(compiledPath, { ensureViewSpec: true });
|
|
61
|
+
resetCompiledGeneratedOutputs(compiledPath);
|
|
62
|
+
clearCompiledRuntimeDerivedArtifacts(compiledPath);
|
|
63
|
+
initializeCompiledRuntimeState(compiledPath);
|
|
36
64
|
if (scope === "all") {
|
|
37
65
|
removeIfExists(stageExecutionShellsRoot(compiledPath));
|
|
38
66
|
removeIfExists(workflowImprovementLoopsRoot(compiledPath));
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { type BuiltinCompiledZoneId } from "./workflow
|
|
1
|
+
import { type BuiltinCompiledZoneId } from "./builtin-compiled-workflow.js";
|
|
2
2
|
import { type WorkflowCompiledSchema, type WorkflowCompiledZone, type WorkflowZoneId } from "./schema.js";
|
|
3
3
|
export interface WorkflowSchemaStageLike {
|
|
4
4
|
id: string;
|
|
5
5
|
writes: readonly string[];
|
|
6
6
|
}
|
|
7
|
-
export { BUILTIN_COMPILED_ZONE_IDS } from "./workflow
|
|
8
|
-
export declare const
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
7
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "./builtin-compiled-workflow.js";
|
|
8
|
+
export declare const WORKFLOW_SCHEMA_FILE = "workflow.schema.json";
|
|
9
|
+
export declare function workflowSchemaFilePath(rootPath: string): string;
|
|
10
|
+
export declare function resolveWorkflowSchemaPath(rootPath: string): string | null;
|
|
11
|
+
export declare function workflowSchemaExists(rootPath: string): boolean;
|
|
12
|
+
export declare function workflowSchemaRelativePath(): string;
|
|
11
13
|
export declare function listCompiledSchemaZones(schema: WorkflowCompiledSchema): WorkflowCompiledZone[];
|
|
12
14
|
export declare function findCompiledSchemaZone(schema: WorkflowCompiledSchema, zoneId: WorkflowZoneId): WorkflowCompiledZone | null;
|
|
13
15
|
export declare function compiledZoneAbsolutePath(compiledPath: string, zone: Pick<WorkflowCompiledZone, "path">): string;
|
|
@@ -22,6 +24,8 @@ export declare function compiledKnowledgeIndexesPath(compiledPath: string): stri
|
|
|
22
24
|
export declare function compiledKnowledgeRootPath(compiledPath: string): string;
|
|
23
25
|
export declare function compiledHomePath(compiledPath: string): string;
|
|
24
26
|
export declare function ensureCompiledZoneTargets(compiledPath: string, schema: WorkflowCompiledSchema): void;
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
+
export declare function buildWorkflowSchema(stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
28
|
+
export declare function writeWorkflowSchemaFile(rootPath: string, stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
29
|
+
export declare function writeWorkflowSchemaDocument(rootPath: string, schema: WorkflowCompiledSchema): WorkflowCompiledSchema;
|
|
30
|
+
export declare function readWorkflowSchemaFile(rootPath: string): WorkflowCompiledSchema | null;
|
|
27
31
|
export declare function readCompiledSchemaFile(rootPath: string): WorkflowCompiledSchema | null;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { warnInterf } from "./logger.js";
|
|
4
|
+
import { readJsonFileUnchecked } from "./parse.js";
|
|
5
|
+
import { BUILTIN_COMPILED_ZONE_IDS, listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "./builtin-compiled-workflow.js";
|
|
5
6
|
import { WorkflowCompiledSchemaSchema, } from "./schema.js";
|
|
6
|
-
export { BUILTIN_COMPILED_ZONE_IDS } from "./workflow
|
|
7
|
-
export const
|
|
7
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "./builtin-compiled-workflow.js";
|
|
8
|
+
export const WORKFLOW_SCHEMA_FILE = "workflow.schema.json";
|
|
8
9
|
const BUILTIN_COMPILED_ZONE_SPEC_BY_ID = new Map(listBuiltinCompiledZoneSpecs().map((zone) => [zone.id, zone]));
|
|
9
|
-
export function
|
|
10
|
-
return join(rootPath,
|
|
10
|
+
export function workflowSchemaFilePath(rootPath) {
|
|
11
|
+
return join(rootPath, WORKFLOW_SCHEMA_FILE);
|
|
11
12
|
}
|
|
12
|
-
export function
|
|
13
|
-
|
|
13
|
+
export function resolveWorkflowSchemaPath(rootPath) {
|
|
14
|
+
const path = workflowSchemaFilePath(rootPath);
|
|
15
|
+
return existsSync(path) ? path : null;
|
|
16
|
+
}
|
|
17
|
+
export function workflowSchemaExists(rootPath) {
|
|
18
|
+
return existsSync(workflowSchemaFilePath(rootPath));
|
|
19
|
+
}
|
|
20
|
+
export function workflowSchemaRelativePath() {
|
|
21
|
+
return `workflow/${WORKFLOW_SCHEMA_FILE}`;
|
|
14
22
|
}
|
|
15
23
|
export function listCompiledSchemaZones(schema) {
|
|
16
24
|
return [...schema.zones];
|
|
@@ -77,11 +85,18 @@ function pushZone(zones, zone) {
|
|
|
77
85
|
return;
|
|
78
86
|
zones.push(zone);
|
|
79
87
|
}
|
|
80
|
-
|
|
88
|
+
function normalizeWorkflowSchema(schema) {
|
|
89
|
+
return {
|
|
90
|
+
...schema,
|
|
91
|
+
kind: "workflow-schema",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function buildWorkflowSchema(stages, label = "Workflow schema") {
|
|
81
95
|
const zones = [];
|
|
82
96
|
for (const zone of listBuiltinCompiledZoneSpecs()) {
|
|
83
97
|
pushZone(zones, {
|
|
84
98
|
id: zone.id,
|
|
99
|
+
role: zone.role,
|
|
85
100
|
path: zone.path,
|
|
86
101
|
kind: zone.kind,
|
|
87
102
|
required: zone.required,
|
|
@@ -90,21 +105,37 @@ export function buildCompiledSchema(stages, label = "Compiled dataset schema") {
|
|
|
90
105
|
});
|
|
91
106
|
}
|
|
92
107
|
return {
|
|
93
|
-
kind: "
|
|
108
|
+
kind: "workflow-schema",
|
|
94
109
|
version: 1,
|
|
95
110
|
target_type: "compiled",
|
|
96
111
|
label,
|
|
97
112
|
zones,
|
|
98
113
|
};
|
|
99
114
|
}
|
|
100
|
-
export function
|
|
101
|
-
const schema =
|
|
102
|
-
|
|
115
|
+
export function writeWorkflowSchemaFile(rootPath, stages, label) {
|
|
116
|
+
const schema = buildWorkflowSchema(stages, label);
|
|
117
|
+
writeWorkflowSchemaDocument(rootPath, schema);
|
|
103
118
|
return schema;
|
|
104
119
|
}
|
|
105
|
-
export function
|
|
106
|
-
const
|
|
120
|
+
export function writeWorkflowSchemaDocument(rootPath, schema) {
|
|
121
|
+
const normalized = normalizeWorkflowSchema(schema);
|
|
122
|
+
writeFileSync(workflowSchemaFilePath(rootPath), `${JSON.stringify(normalized, null, 2)}\n`);
|
|
123
|
+
return normalized;
|
|
124
|
+
}
|
|
125
|
+
export function readWorkflowSchemaFile(rootPath) {
|
|
126
|
+
const path = workflowSchemaFilePath(rootPath);
|
|
107
127
|
if (!existsSync(path))
|
|
108
128
|
return null;
|
|
109
|
-
|
|
129
|
+
const raw = readJsonFileUnchecked(path, "workflow schema");
|
|
130
|
+
if (raw === null)
|
|
131
|
+
return null;
|
|
132
|
+
const parsed = WorkflowCompiledSchemaSchema.safeParse(raw);
|
|
133
|
+
if (!parsed.success) {
|
|
134
|
+
warnInterf(`Warning: failed to validate workflow schema at ${path}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return normalizeWorkflowSchema(parsed.data);
|
|
138
|
+
}
|
|
139
|
+
export function readCompiledSchemaFile(rootPath) {
|
|
140
|
+
return readWorkflowSchemaFile(rootPath);
|
|
110
141
|
}
|
package/dist/lib/discovery.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export interface DiscoveryResult {
|
|
|
4
4
|
ignoredCount: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function discoverSourceFiles(sourcePath: string, compiledPath: string): DiscoveryResult;
|
|
7
|
-
export declare function loadIgnorePatterns(
|
|
7
|
+
export declare function loadIgnorePatterns(compiledPath: string): string[];
|
package/dist/lib/discovery.js
CHANGED
|
@@ -36,8 +36,8 @@ export function discoverSourceFiles(sourcePath, compiledPath) {
|
|
|
36
36
|
ignoredCount,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
export function loadIgnorePatterns(
|
|
40
|
-
const ignorePath = join(
|
|
39
|
+
export function loadIgnorePatterns(compiledPath) {
|
|
40
|
+
const ignorePath = join(compiledPath, ".interfignore");
|
|
41
41
|
if (!existsSync(ignorePath))
|
|
42
42
|
return [];
|
|
43
43
|
return readFileSync(ignorePath, "utf-8")
|
package/dist/lib/executors.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface WorkflowExecutor {
|
|
|
18
18
|
displayName: string;
|
|
19
19
|
command?: string | null;
|
|
20
20
|
executionProfile?: WorkflowExecutionProfile;
|
|
21
|
-
execute(
|
|
21
|
+
execute(rootPath: string, prompt: string, options?: WorkflowExecuteOptions): Promise<number>;
|
|
22
22
|
}
|
|
23
23
|
export type { RuntimeExecutorInfo } from "./schema.js";
|
|
24
24
|
export declare function buildRuntimeExecutorInfo(executor: WorkflowExecutor): RuntimeExecutorInfo;
|
package/dist/lib/executors.js
CHANGED
|
@@ -18,8 +18,8 @@ export function createLocalAgentExecutor(agent, executionProfile = {}) {
|
|
|
18
18
|
displayName: agent.displayName,
|
|
19
19
|
command: agent.command,
|
|
20
20
|
executionProfile,
|
|
21
|
-
execute(
|
|
22
|
-
return spawnAgent(agent,
|
|
21
|
+
execute(rootPath, prompt, options) {
|
|
22
|
+
return spawnAgent(agent, rootPath, prompt, {
|
|
23
23
|
eventLogPath: options?.eventLogPath,
|
|
24
24
|
statusLogPath: options?.statusLogPath,
|
|
25
25
|
executionProfile,
|
|
@@ -10,7 +10,6 @@ export declare const WORKFLOW_CONTAINER_NAME = "workflows";
|
|
|
10
10
|
export declare const TEST_CONTAINER_NAME = "tests";
|
|
11
11
|
export declare const INTERF_CONFIG_FILE = "interf.json";
|
|
12
12
|
export declare const WORKFLOW_PACKAGE_DIR = "workflow";
|
|
13
|
-
export declare function prepareCompiledLayout(dirPath: string): boolean;
|
|
14
13
|
export declare function readInterfConfig(dirPath: string): InterfConfig | null;
|
|
15
14
|
export declare function hasSourceFolderInput(config: InterfConfig | null | undefined): config is InterfConfig & {
|
|
16
15
|
source: {
|
|
@@ -4,7 +4,6 @@ import { warnInterf } from "./logger.js";
|
|
|
4
4
|
import { readJsonFileUnchecked } from "./parse.js";
|
|
5
5
|
import { compiledCompiledPathForDataset, projectInterfRoot, } from "./project-paths.js";
|
|
6
6
|
import { resolveSourceControlPathForCompiled, compiledInterfConfigPath, } from "./compiled-paths.js";
|
|
7
|
-
import { normalizeLegacyCompiledLayout, compiledNeedsLegacyLayoutNormalization, } from "./compiled-layout.js";
|
|
8
7
|
import { InterfConfigSchema, } from "./schema.js";
|
|
9
8
|
import { assertPathWithinRoot } from "./util.js";
|
|
10
9
|
export const INTERF_CONTAINER_NAME = "interf";
|
|
@@ -12,12 +11,6 @@ export const WORKFLOW_CONTAINER_NAME = "workflows";
|
|
|
12
11
|
export const TEST_CONTAINER_NAME = "tests";
|
|
13
12
|
export const INTERF_CONFIG_FILE = "interf.json";
|
|
14
13
|
export const WORKFLOW_PACKAGE_DIR = "workflow";
|
|
15
|
-
export function prepareCompiledLayout(dirPath) {
|
|
16
|
-
if (!compiledNeedsLegacyLayoutNormalization(dirPath)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return normalizeLegacyCompiledLayout(dirPath);
|
|
20
|
-
}
|
|
21
14
|
export function readInterfConfig(dirPath) {
|
|
22
15
|
const configPath = compiledInterfConfigPath(dirPath);
|
|
23
16
|
if (!existsSync(configPath))
|
|
@@ -41,7 +34,6 @@ export function hasSourceFolderInput(config) {
|
|
|
41
34
|
return typeof config?.source?.path === "string" && config.source.path.length > 0;
|
|
42
35
|
}
|
|
43
36
|
export function detectInterf(cwd) {
|
|
44
|
-
prepareCompiledLayout(cwd);
|
|
45
37
|
const config = readInterfConfig(cwd);
|
|
46
38
|
if (config)
|
|
47
39
|
return { path: cwd, config };
|
|
@@ -58,7 +50,6 @@ export function resolveCompiled(cwd) {
|
|
|
58
50
|
};
|
|
59
51
|
}
|
|
60
52
|
export function resolveSourceFolderPath(compiledPath, config = null) {
|
|
61
|
-
prepareCompiledLayout(compiledPath);
|
|
62
53
|
const resolvedConfig = config ?? readInterfConfig(compiledPath);
|
|
63
54
|
if (hasSourceFolderInput(resolvedConfig)) {
|
|
64
55
|
return assertPathWithinRoot(compiledPath, resolve(compiledPath, resolvedConfig.source.path), "Compiled raw source path");
|
|
@@ -66,17 +57,15 @@ export function resolveSourceFolderPath(compiledPath, config = null) {
|
|
|
66
57
|
return resolve(compiledPath, "raw");
|
|
67
58
|
}
|
|
68
59
|
export function resolveSourceControlPath(compiledPath) {
|
|
69
|
-
prepareCompiledLayout(compiledPath);
|
|
70
60
|
return resolveSourceControlPathForCompiled(compiledPath);
|
|
71
61
|
}
|
|
72
62
|
export function resolveSourceInputPath(compiledPath) {
|
|
73
|
-
prepareCompiledLayout(compiledPath);
|
|
74
|
-
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
75
63
|
const config = readInterfConfig(compiledPath);
|
|
76
64
|
if (typeof config?.source?.dataset_path === "string" && config.source.dataset_path.length > 0) {
|
|
65
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
77
66
|
return assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Dataset source path");
|
|
78
67
|
}
|
|
79
|
-
|
|
68
|
+
throw new Error(`Compiled dataset is missing source.dataset_path in ${compiledInterfConfigPath(compiledPath)}.`);
|
|
80
69
|
}
|
|
81
70
|
export function listCompiledDatasetsForSourceFolder(sourcePath) {
|
|
82
71
|
const interfRoot = projectInterfRoot(sourcePath);
|
|
@@ -91,11 +80,12 @@ export function listCompiledDatasetsForSourceFolder(sourcePath) {
|
|
|
91
80
|
return [];
|
|
92
81
|
}
|
|
93
82
|
return readdirSync(interfRoot)
|
|
94
|
-
.filter((entry) => !entry.startsWith(".") &&
|
|
83
|
+
.filter((entry) => !entry.startsWith(".") &&
|
|
84
|
+
entry !== WORKFLOW_CONTAINER_NAME &&
|
|
85
|
+
entry !== TEST_CONTAINER_NAME)
|
|
95
86
|
.map((entry) => compiledCompiledPathForDataset(sourcePath, entry))
|
|
96
87
|
.filter((compiledPath) => existsSync(compiledPath))
|
|
97
88
|
.map((compiledPath) => {
|
|
98
|
-
prepareCompiledLayout(compiledPath);
|
|
99
89
|
const config = readInterfConfig(compiledPath);
|
|
100
90
|
return config ? { path: compiledPath, config } : null;
|
|
101
91
|
})
|
|
@@ -112,7 +102,7 @@ export function assertCompiledContainer(sourcePath) {
|
|
|
112
102
|
if (entry.startsWith("."))
|
|
113
103
|
return false;
|
|
114
104
|
const entryPath = join(interfRoot, entry);
|
|
115
|
-
if (entry === WORKFLOW_CONTAINER_NAME) {
|
|
105
|
+
if (entry === WORKFLOW_CONTAINER_NAME || entry === TEST_CONTAINER_NAME) {
|
|
116
106
|
try {
|
|
117
107
|
return !statSync(entryPath).isDirectory();
|
|
118
108
|
}
|
|
@@ -146,7 +136,7 @@ export function assertCompiledContainer(sourcePath) {
|
|
|
146
136
|
const unexpectedEntries = readdirSync(containerPath).filter((entry) => {
|
|
147
137
|
if (entry.startsWith("."))
|
|
148
138
|
return false;
|
|
149
|
-
if (entry === WORKFLOW_CONTAINER_NAME)
|
|
139
|
+
if (entry === WORKFLOW_CONTAINER_NAME || entry === TEST_CONTAINER_NAME)
|
|
150
140
|
return false;
|
|
151
141
|
const entryPath = join(containerPath, entry);
|
|
152
142
|
try {
|
|
@@ -161,7 +151,6 @@ export function assertCompiledContainer(sourcePath) {
|
|
|
161
151
|
if (!existsSync(compiledPath)) {
|
|
162
152
|
return false;
|
|
163
153
|
}
|
|
164
|
-
prepareCompiledLayout(compiledPath);
|
|
165
154
|
return !readInterfConfig(compiledPath);
|
|
166
155
|
});
|
|
167
156
|
if (unexpectedEntries.length > 0) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, existsSync, writeFileSync, } from "node:fs";
|
|
2
2
|
import { basename, join, relative, sep } from "node:path";
|
|
3
3
|
import { getCompiledWorkflow } from "./workflow-definitions.js";
|
|
4
|
-
import {
|
|
5
|
-
import { saveEmptyCompiledInventory } from "./state-io.js";
|
|
6
|
-
import { writeObsidianDefaults } from "./obsidian.js";
|
|
4
|
+
import { initializeCompiledRuntimeState, } from "./state.js";
|
|
7
5
|
import { assertCompiledContainer, assertWritableTargetDir, assertCompiledName, } from "./interf-detect.js";
|
|
8
6
|
import { refreshCompiledBootstrapGuidance } from "./interf-bootstrap.js";
|
|
9
7
|
import { seedCompiledWorkflowPackage } from "./interf-workflow-package.js";
|
|
@@ -20,7 +18,6 @@ const DEFAULT_INTERFIGNORE = [
|
|
|
20
18
|
".interf/tests/",
|
|
21
19
|
".interf/tests/targets/sandboxes/",
|
|
22
20
|
".interf/runtime/",
|
|
23
|
-
".obsidian/",
|
|
24
21
|
"",
|
|
25
22
|
].join("\n");
|
|
26
23
|
const UNCOMPILED_COMPILED_PLACEHOLDER = "Not yet compiled. Run `interf compile` to build the compiled dataset.";
|
|
@@ -47,17 +44,16 @@ function compiledGitignoreEntries(compiledPath) {
|
|
|
47
44
|
".interf/tests/",
|
|
48
45
|
".interf/tests/targets/sandboxes/",
|
|
49
46
|
".interf/runtime/",
|
|
50
|
-
".obsidian/",
|
|
51
47
|
];
|
|
52
48
|
}
|
|
53
49
|
function scaffoldCompiledOutputs(compiledPath, compiledName, about) {
|
|
54
50
|
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
55
51
|
if (!schema) {
|
|
56
|
-
throw new Error(`Missing
|
|
52
|
+
throw new Error(`Missing workflow schema at ${workflowPackagePathForCompiled(compiledPath)}.`);
|
|
57
53
|
}
|
|
58
54
|
ensureCompiledZoneTargets(compiledPath, schema);
|
|
59
55
|
for (const zone of schema.zones) {
|
|
60
|
-
if (!zone.required || zone.kind !== "file" || zone.
|
|
56
|
+
if (!zone.required || zone.kind !== "file" || zone.role !== "output")
|
|
61
57
|
continue;
|
|
62
58
|
const targetPath = join(compiledPath, zone.path);
|
|
63
59
|
if (existsSync(targetPath))
|
|
@@ -110,10 +106,7 @@ export function createCompiled(name, sourcePath, workflowId = "interf", about, d
|
|
|
110
106
|
scaffoldCompiledOutputs(compiledPath, name, about);
|
|
111
107
|
refreshCompiledBootstrapGuidance(compiledPath);
|
|
112
108
|
writeFileSync(join(compiledPath, ".gitignore"), [...compiledGitignoreEntries(compiledPath), ""].join("\n"));
|
|
113
|
-
|
|
114
|
-
saveEmptyCompiledInventory(compiledPath);
|
|
115
|
-
refreshCompiledArtifacts(compiledPath, { ensureViewSpec: true });
|
|
116
|
-
writeObsidianDefaults(compiledPath, "compiled");
|
|
109
|
+
initializeCompiledRuntimeState(compiledPath);
|
|
117
110
|
return compiledPath;
|
|
118
111
|
}
|
|
119
112
|
export function defaultCompiledNameForSource(sourcePath) {
|
|
@@ -14,7 +14,12 @@ export declare function createLocalWorkflowPackageFromTemplate(options: {
|
|
|
14
14
|
workflowId: string;
|
|
15
15
|
label: string;
|
|
16
16
|
hint: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
stagePolicyNotes: Record<string, string[]>;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function seedLocalWorkflowPackageFromBase(options: {
|
|
20
|
+
sourcePath: string;
|
|
21
|
+
baseWorkflowId: string;
|
|
22
|
+
workflowId: string;
|
|
23
|
+
label: string;
|
|
24
|
+
hint: string;
|
|
20
25
|
}): string;
|