@interf/compiler 0.5.1 → 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 -187
- 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 +6 -13
- 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.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 +213 -39
- package/dist/lib/agents.d.ts +1 -1
- package/dist/lib/agents.js +1 -1
- package/dist/lib/builtin-compiled-workflow.d.ts +6 -97
- package/dist/lib/builtin-compiled-workflow.js +66 -125
- package/dist/lib/compiled-compile.d.ts +0 -4
- package/dist/lib/compiled-compile.js +9 -28
- package/dist/lib/compiled-paths.d.ts +1 -0
- package/dist/lib/compiled-paths.js +3 -0
- package/dist/lib/compiled-reset.d.ts +1 -0
- package/dist/lib/compiled-reset.js +42 -14
- package/dist/lib/compiled-schema.d.ts +9 -5
- package/dist/lib/compiled-schema.js +45 -14
- 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-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/local-workflows.d.ts +4 -3
- package/dist/lib/local-workflows.js +126 -103
- 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 +3 -1
- package/dist/lib/runtime-reconcile.js +88 -51
- package/dist/lib/runtime-runs.js +27 -15
- package/dist/lib/runtime.d.ts +1 -1
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/schema.d.ts +71 -14
- package/dist/lib/schema.js +15 -12
- package/dist/lib/state-view.js +6 -6
- 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/validate-compiled.js +9 -6
- package/dist/lib/validate.d.ts +3 -1
- package/dist/lib/validate.js +4 -11
- package/dist/lib/workflow-authoring.d.ts +26 -0
- package/dist/lib/workflow-authoring.js +119 -0
- package/dist/lib/workflow-definitions.d.ts +11 -1
- package/dist/lib/workflow-definitions.js +12 -15
- 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-stage-policy.d.ts +5 -0
- package/dist/lib/workflow-stage-policy.js +31 -0
- package/package.json +4 -5
- 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 -120
|
@@ -1,23 +1,9 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { PACKAGE_ROOT } from "./config.js";
|
|
4
|
+
import { readJsonFileWithSchema } from "./parse.js";
|
|
5
|
+
import { WorkflowCompiledSchemaSchema } from "./schema.js";
|
|
1
6
|
import { COMPILED_ZONE_KINDS } from "./workflow-primitives.js";
|
|
2
|
-
export const COMPILED_CONTRACT_TYPES = [
|
|
3
|
-
"compiled-file-evidence",
|
|
4
|
-
"compiled-knowledge-structure",
|
|
5
|
-
"compiled-query-shape",
|
|
6
|
-
];
|
|
7
|
-
export const COMPILED_CONTRACT_FAMILY_METADATA = {
|
|
8
|
-
"compiled-file-evidence": {
|
|
9
|
-
order: 0,
|
|
10
|
-
bundledSkill: "compile/stages/summarize",
|
|
11
|
-
},
|
|
12
|
-
"compiled-knowledge-structure": {
|
|
13
|
-
order: 1,
|
|
14
|
-
bundledSkill: "compile/stages/structure",
|
|
15
|
-
},
|
|
16
|
-
"compiled-query-shape": {
|
|
17
|
-
order: 2,
|
|
18
|
-
bundledSkill: "compile/stages/shape",
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
7
|
export const BUILTIN_COMPILED_STAGE_IDS = {
|
|
22
8
|
SUMMARIZE: "summarize",
|
|
23
9
|
STRUCTURE: "structure",
|
|
@@ -32,115 +18,70 @@ export const BUILTIN_COMPILED_ZONE_IDS = {
|
|
|
32
18
|
HOME: "home",
|
|
33
19
|
RUNTIME: "runtime",
|
|
34
20
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
reads: [
|
|
94
|
-
BUILTIN_COMPILED_ZONE_IDS.RAW,
|
|
95
|
-
BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
|
|
96
|
-
],
|
|
97
|
-
writes: [
|
|
98
|
-
BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: BUILTIN_COMPILED_STAGE_IDS.STRUCTURE,
|
|
103
|
-
label: "Structure",
|
|
104
|
-
description: "Build the cross-file knowledge structure from the summaries.",
|
|
105
|
-
contractType: "compiled-knowledge-structure",
|
|
106
|
-
skillDir: "structure",
|
|
107
|
-
reads: [
|
|
108
|
-
BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
|
|
109
|
-
BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
|
|
110
|
-
],
|
|
111
|
-
writes: [
|
|
112
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES,
|
|
113
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS,
|
|
114
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: BUILTIN_COMPILED_STAGE_IDS.SHAPE,
|
|
119
|
-
label: "Shape",
|
|
120
|
-
description: "Shape the final compiled around the saved focus and truth checks.",
|
|
121
|
-
contractType: "compiled-query-shape",
|
|
122
|
-
skillDir: "shape",
|
|
123
|
-
reads: [
|
|
124
|
-
BUILTIN_COMPILED_ZONE_IDS.RAW,
|
|
125
|
-
BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
|
|
126
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES,
|
|
127
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS,
|
|
128
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
|
|
129
|
-
BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
|
|
130
|
-
],
|
|
131
|
-
writes: [
|
|
132
|
-
BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
|
|
133
|
-
BUILTIN_COMPILED_ZONE_IDS.HOME,
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
];
|
|
21
|
+
const BUILTIN_ZONE_ID_SET = new Set(Object.values(BUILTIN_COMPILED_ZONE_IDS));
|
|
22
|
+
const BUILTIN_STAGE_ID_SET = new Set(Object.values(BUILTIN_COMPILED_STAGE_IDS));
|
|
23
|
+
const BuiltinWorkflowStageSchema = z.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
contract_type: z.string(),
|
|
26
|
+
reads: z.array(z.string()).min(1),
|
|
27
|
+
writes: z.array(z.string()).min(1),
|
|
28
|
+
});
|
|
29
|
+
const BuiltinWorkflowPackageSchema = z.object({
|
|
30
|
+
stages: z.array(BuiltinWorkflowStageSchema).min(1),
|
|
31
|
+
});
|
|
32
|
+
let builtinCompiledContractCache = null;
|
|
33
|
+
function builtinWorkflowRootPath() {
|
|
34
|
+
return join(PACKAGE_ROOT, "builtin-workflows", "interf");
|
|
35
|
+
}
|
|
36
|
+
function builtinWorkflowPath(relativePath) {
|
|
37
|
+
return join(builtinWorkflowRootPath(), relativePath);
|
|
38
|
+
}
|
|
39
|
+
function assertBuiltinZoneId(value) {
|
|
40
|
+
if (!BUILTIN_ZONE_ID_SET.has(value)) {
|
|
41
|
+
throw new Error(`Built-in Interf workflow schema declares unsupported zone id "${value}".`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
function assertBuiltinStageId(value) {
|
|
46
|
+
if (!BUILTIN_STAGE_ID_SET.has(value)) {
|
|
47
|
+
throw new Error(`Built-in Interf workflow package declares unsupported stage id "${value}".`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
function loadBuiltinCompiledContract() {
|
|
52
|
+
if (builtinCompiledContractCache)
|
|
53
|
+
return builtinCompiledContractCache;
|
|
54
|
+
const schema = readJsonFileWithSchema(builtinWorkflowPath("workflow.schema.json"), "built-in Interf workflow schema", WorkflowCompiledSchemaSchema);
|
|
55
|
+
if (!schema) {
|
|
56
|
+
throw new Error(`Missing or invalid built-in workflow schema at ${builtinWorkflowPath("workflow.schema.json")}.`);
|
|
57
|
+
}
|
|
58
|
+
const workflow = readJsonFileWithSchema(builtinWorkflowPath("workflow.json"), "built-in Interf workflow package", BuiltinWorkflowPackageSchema);
|
|
59
|
+
if (!workflow) {
|
|
60
|
+
throw new Error(`Missing or invalid built-in workflow package at ${builtinWorkflowPath("workflow.json")}.`);
|
|
61
|
+
}
|
|
62
|
+
const zones = schema.zones.map((zone) => ({
|
|
63
|
+
id: assertBuiltinZoneId(zone.id),
|
|
64
|
+
role: zone.role,
|
|
65
|
+
path: zone.path,
|
|
66
|
+
kind: zone.kind,
|
|
67
|
+
required: zone.required,
|
|
68
|
+
description: zone.description,
|
|
69
|
+
}));
|
|
70
|
+
const stages = workflow.stages.map((stage) => ({
|
|
71
|
+
id: assertBuiltinStageId(stage.id),
|
|
72
|
+
contract_type: stage.contract_type,
|
|
73
|
+
reads: stage.reads.map(assertBuiltinZoneId),
|
|
74
|
+
writes: stage.writes.map(assertBuiltinZoneId),
|
|
75
|
+
}));
|
|
76
|
+
builtinCompiledContractCache = { zones, stages };
|
|
77
|
+
return builtinCompiledContractCache;
|
|
78
|
+
}
|
|
137
79
|
export function listBuiltinCompiledZoneSpecs() {
|
|
138
|
-
return
|
|
80
|
+
return loadBuiltinCompiledContract().zones.map((zone) => ({ ...zone }));
|
|
139
81
|
}
|
|
140
82
|
export function listBuiltinCompiledFallbackStages() {
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
contract_type: stage.contractType,
|
|
83
|
+
return loadBuiltinCompiledContract().stages.map((stage) => ({
|
|
84
|
+
...stage,
|
|
144
85
|
reads: [...stage.reads],
|
|
145
86
|
writes: [...stage.writes],
|
|
146
87
|
}));
|
|
@@ -15,10 +15,6 @@ export interface CompiledCompileResult {
|
|
|
15
15
|
ok: boolean;
|
|
16
16
|
stageResults: Record<string, WorkflowStageResult>;
|
|
17
17
|
failedStage: string | null;
|
|
18
|
-
summarize: CompiledSummarizeResult | null;
|
|
19
|
-
structure: WorkflowStageResult | null;
|
|
20
|
-
shape: WorkflowStageResult | null;
|
|
21
|
-
compile: WorkflowStageResult | null;
|
|
22
18
|
}
|
|
23
19
|
export type StageShellRetentionMode = "on-failure" | "always";
|
|
24
20
|
export declare function resolveCompiledContext(compiledPath: string): {
|
|
@@ -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,
|
|
@@ -26,6 +26,7 @@ export declare function workflowImprovementLoopRoot(compiledPath: string, runId:
|
|
|
26
26
|
export declare function targetTestRunsRootForCompiled(compiledPath: string): string;
|
|
27
27
|
export declare function targetTestSandboxesRootForCompiled(compiledPath: string): string;
|
|
28
28
|
export declare function compiledRuntimeLogsRoot(compiledPath: string): string;
|
|
29
|
+
export declare function compiledRuntimeArchivedStageContractPath(compiledPath: string, runId: string): string;
|
|
29
30
|
export declare function compiledQueryAcceptanceRoot(compiledPath: string): string;
|
|
30
31
|
export declare function compiledRuntimeStatePath(compiledPath: string): string;
|
|
31
32
|
export declare function compiledRuntimeHealthPath(compiledPath: string): string;
|
|
@@ -55,6 +55,9 @@ export function targetTestSandboxesRootForCompiled(compiledPath) {
|
|
|
55
55
|
export function compiledRuntimeLogsRoot(compiledPath) {
|
|
56
56
|
return join(compiledRuntimeRoot(compiledPath), "logs");
|
|
57
57
|
}
|
|
58
|
+
export function compiledRuntimeArchivedStageContractPath(compiledPath, runId) {
|
|
59
|
+
return join(compiledRuntimeLogsRoot(compiledPath), `${runId}.stage-contract.json`);
|
|
60
|
+
}
|
|
58
61
|
export function compiledQueryAcceptanceRoot(compiledPath) {
|
|
59
62
|
return join(compiledRuntimeRoot(compiledPath), "query-acceptance");
|
|
60
63
|
}
|
|
@@ -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));
|
|
@@ -5,9 +5,11 @@ export interface WorkflowSchemaStageLike {
|
|
|
5
5
|
writes: readonly string[];
|
|
6
6
|
}
|
|
7
7
|
export { BUILTIN_COMPILED_ZONE_IDS } from "./builtin-compiled-workflow.js";
|
|
8
|
-
export declare const
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
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 {
|
|
3
|
+
import { warnInterf } from "./logger.js";
|
|
4
|
+
import { readJsonFileUnchecked } from "./parse.js";
|
|
4
5
|
import { BUILTIN_COMPILED_ZONE_IDS, listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "./builtin-compiled-workflow.js";
|
|
5
6
|
import { WorkflowCompiledSchemaSchema, } from "./schema.js";
|
|
6
7
|
export { BUILTIN_COMPILED_ZONE_IDS } from "./builtin-compiled-workflow.js";
|
|
7
|
-
export const
|
|
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,
|
|
@@ -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;
|