@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
package/dist/lib/agent-shells.js
CHANGED
|
@@ -2,8 +2,8 @@ import { cpSync, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, re
|
|
|
2
2
|
import { basename, dirname, join, relative } from "node:path";
|
|
3
3
|
import { CHART_APPROXIMATION_NOTES } from "./chart-guidance.js";
|
|
4
4
|
import { WORKFLOW_PACKAGE_DIR } from "./interf-detect.js";
|
|
5
|
-
import {
|
|
6
|
-
import { stageExecutionShellsRoot, workflowImprovementLoopRoot,
|
|
5
|
+
import { ensureCompiledZoneTargets, readCompiledSchemaFile, compiledZoneAbsolutePath, } from "./compiled-schema.js";
|
|
6
|
+
import { stageExecutionShellsRoot, workflowImprovementLoopRoot, workflowPackagePathForCompiled, compiledInterfConfigPath, compiledRuntimeRoot, } from "./compiled-paths.js";
|
|
7
7
|
import { resolveWorkflowImprovementReviewSourcePaths } from "./workflow-review-paths.js";
|
|
8
8
|
const LOCAL_SKILL_ROOTS = [
|
|
9
9
|
".claude/skills",
|
|
@@ -19,16 +19,25 @@ function writeNativeAgentSurface(rootPath, agentsContent, skillName, skillConten
|
|
|
19
19
|
changed = writeNativeSkillCopies(rootPath, skillName, skillContent) || changed;
|
|
20
20
|
return changed;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return join(
|
|
22
|
+
function compiledQuerySkillSourcePath(compiledPath) {
|
|
23
|
+
return join(workflowPackagePathForCompiled(compiledPath), "use", "query", "SKILL.md");
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
function compiledZoneSummaryLines(compiledPath) {
|
|
26
|
+
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
27
|
+
if (!schema)
|
|
28
|
+
return ["- No compiled schema is available yet."];
|
|
29
|
+
return schema.zones
|
|
30
|
+
.filter((zone) => zone.id !== "raw" && zone.kind !== "runtime")
|
|
31
|
+
.map((zone) => `- \`${zone.id}\` -> \`${zone.path}\` (${zone.kind})`);
|
|
32
|
+
}
|
|
33
|
+
export function renderCompiledAgents(compiledPath, name, workflowId, about, options = {}) {
|
|
26
34
|
const workflowOriginSelected = options.workflowOriginSelected ?? workflowId;
|
|
27
35
|
const workflowLocalDraft = options.workflowLocalDraft === true;
|
|
36
|
+
const zoneLines = compiledZoneSummaryLines(compiledPath);
|
|
28
37
|
return [
|
|
29
38
|
`# ${name}`,
|
|
30
39
|
"",
|
|
31
|
-
"This is a compiled
|
|
40
|
+
"This is a compiled dataset built by Interf Compiler.",
|
|
32
41
|
"It is a file-based layer on top of the raw files, built for agents to navigate, retrieve evidence, and answer more accurately.",
|
|
33
42
|
"",
|
|
34
43
|
...(about
|
|
@@ -37,51 +46,48 @@ export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
|
|
|
37
46
|
"",
|
|
38
47
|
]
|
|
39
48
|
: []),
|
|
40
|
-
"## How to use this
|
|
49
|
+
"## How to use this compiled dataset",
|
|
41
50
|
"",
|
|
42
|
-
"1. Use the local native `interf-query` skill that Interf Compiler generated for this
|
|
43
|
-
"2.
|
|
51
|
+
"1. Use the local native `interf-query` skill that Interf Compiler generated for this compiled dataset.",
|
|
52
|
+
"2. Let the workflow docs and compiled output zones guide retrieval instead of assuming a fixed note layout.",
|
|
44
53
|
"3. Use `raw/` when you need direct quotes, exact chart values, table lookups, or verification.",
|
|
45
54
|
"",
|
|
46
|
-
"## How this
|
|
55
|
+
"## How this compiled dataset works",
|
|
47
56
|
"",
|
|
48
|
-
"- `.interf/interf.json` points to the
|
|
57
|
+
"- `.interf/interf.json` points to the local `raw/` snapshot via `source.path` and back to the dataset control plane via `source.control_path`.",
|
|
49
58
|
`- Workflow seed: \`${workflowOriginSelected}\`.`,
|
|
50
59
|
...(workflowLocalDraft
|
|
51
|
-
? ["- This
|
|
60
|
+
? ["- This compiled dataset now carries a local workflow draft improved from that seed. Recompiling this compiled dataset reuses the local `.interf/workflow/` package."]
|
|
52
61
|
: []),
|
|
53
62
|
`- Active local workflow id: \`${workflowId}\`.`,
|
|
54
|
-
"- `.interf/workflow/` is the local editable method package for this
|
|
55
|
-
"- `.interf/workflow/
|
|
63
|
+
"- `.interf/workflow/` is the local editable method package for this compiled dataset.",
|
|
64
|
+
"- `.interf/workflow/compiled.schema.json` is the deterministic output shape for this compiled dataset.",
|
|
56
65
|
"- `.interf/workflow/improve/` is the editable source for workflow-improvement loops.",
|
|
57
66
|
"- `.interf/workflow/use/query/` is the editable source for the generated native query shell.",
|
|
58
67
|
"- `.interf/workflow/compile/stages/` defines stage-specific docs that Interf Compiler projects into native execution shells for automated runs.",
|
|
59
68
|
"- Native local query skills are generated under local agent skill directories such as `.claude/skills/` and `.codex/skills/`.",
|
|
60
|
-
"- `raw/` contains the
|
|
61
|
-
"-
|
|
62
|
-
|
|
63
|
-
"- `home.md` is the starting note.",
|
|
69
|
+
"- `raw/` contains the local raw snapshot used for evidence and verification.",
|
|
70
|
+
"- Compiled output zones are declared in `.interf/workflow/compiled.schema.json`.",
|
|
71
|
+
...zoneLines,
|
|
64
72
|
"- `.interf/runtime/` holds CLI-owned runtime artifacts.",
|
|
65
|
-
"- `.interf/tests/` holds saved raw-vs-compiled test comparisons for this
|
|
73
|
+
"- `.interf/tests/` holds saved raw-vs-compiled test comparisons for this compiled dataset.",
|
|
66
74
|
"- `.interf/tests/targets/` holds detailed raw and compiled target runs plus preserved test sandboxes.",
|
|
67
75
|
"",
|
|
68
76
|
"## Manual query rules",
|
|
69
77
|
"",
|
|
70
|
-
"- Prefer
|
|
78
|
+
"- Prefer the workflow-declared compiled outputs before `raw/`.",
|
|
71
79
|
"- Use the generated native `interf-query` skill for manual querying. The editable source lives at `.interf/workflow/use/query/SKILL.md`.",
|
|
72
80
|
"- Treat `.interf/` as method/runtime metadata, not answer evidence, unless explicitly asked to inspect workflow or test history.",
|
|
73
81
|
"- Use `raw/` for quotes, verification, ambiguity, or evidence the compiled layer does not expose well.",
|
|
74
|
-
"- If the compiled layer already contains a bounded chart-derived read for the exact metric and year the user asked about, answer from that compiled read first.",
|
|
75
82
|
"- If exact chart, table, or image-derived evidence matters, inspect the raw source and say whether the answer was text-derived, table-derived, or chart-derived.",
|
|
76
83
|
"",
|
|
77
84
|
"## Commands",
|
|
78
85
|
"",
|
|
79
86
|
"```",
|
|
80
|
-
"interf compile build this compiled
|
|
81
|
-
"interf test run saved truth checks against this
|
|
82
|
-
"interf verify
|
|
83
|
-
"interf verify
|
|
84
|
-
"interf verify compile verify compile outputs",
|
|
87
|
+
"interf compile build this compiled dataset",
|
|
88
|
+
"interf test run saved truth checks against this compiled dataset",
|
|
89
|
+
"interf verify stage <id> verify one workflow stage",
|
|
90
|
+
"interf verify compiled verify the full workflow output",
|
|
85
91
|
"interf status show deterministic health",
|
|
86
92
|
"```",
|
|
87
93
|
"",
|
|
@@ -93,7 +99,7 @@ export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
|
|
|
93
99
|
"",
|
|
94
100
|
].join("\n");
|
|
95
101
|
}
|
|
96
|
-
export function
|
|
102
|
+
export function renderCompiledQuerySkill() {
|
|
97
103
|
const chartNotes = CHART_APPROXIMATION_NOTES.map((note) => `- ${note.toLowerCase()}`);
|
|
98
104
|
return [
|
|
99
105
|
"# Manual Query Loop",
|
|
@@ -101,24 +107,19 @@ export function renderWorkspaceQuerySkill() {
|
|
|
101
107
|
"This file is the editable authoring source for the generated native local `interf-query` skill.",
|
|
102
108
|
"",
|
|
103
109
|
"Default loop:",
|
|
104
|
-
"1. Read `
|
|
105
|
-
"2.
|
|
106
|
-
"3. Use `
|
|
107
|
-
"4. Use `raw/` for direct quotes, verification, exact table lookups, and cases where the compiled layer is missing or ambiguous.",
|
|
110
|
+
"1. Read `workflow/README.md` and this file first.",
|
|
111
|
+
"2. Use the compiled output zones declared in `workflow/compiled.schema.json` before falling back to `raw/`.",
|
|
112
|
+
"3. Use `raw/` for direct quotes, verification, exact table lookups, and cases where the compiled layer is missing or ambiguous.",
|
|
108
113
|
"",
|
|
109
114
|
"Answering rule:",
|
|
110
115
|
"- do not modify files under `raw/`",
|
|
116
|
+
"- treat the workflow package as the method layer and the compiled zones as the working retrieval surface",
|
|
111
117
|
"- when a number is chart-derived, say that explicitly",
|
|
112
|
-
"-
|
|
113
|
-
"- use `raw/` to confirm source page, metric family, or provenance, not to replace a good compiled bounded read with a second incompatible range",
|
|
114
|
-
"- when the compiled layer preserves a bounded chart-derived range, keep that bounded range in the answer instead of collapsing it to a midpoint or pseudo-exact single value",
|
|
115
|
-
"- when reading charts, verify you are on the correct metric family and year before answering",
|
|
116
|
-
"- keep historical annual charts separate from current-quarter snapshots, sector splits, or nearby lookalike panels",
|
|
118
|
+
"- use `raw/` to confirm source page, metric family, or provenance when the compiled layer is missing or ambiguous",
|
|
117
119
|
...chartNotes,
|
|
118
|
-
"- if multiple compiled notes mention the same chart read, keep the answer consistent with the most focused workspace note instead of synthesizing a new midpoint or shifted band",
|
|
119
120
|
"- when the compiled layer is insufficient, verify in `raw/` and then answer",
|
|
120
121
|
"",
|
|
121
|
-
"You can edit this file to bias manual question-answering behavior for this
|
|
122
|
+
"You can edit this file to bias manual question-answering behavior for this compiled dataset.",
|
|
122
123
|
"",
|
|
123
124
|
].join("\n");
|
|
124
125
|
}
|
|
@@ -128,7 +129,7 @@ function renderRawTestAgents() {
|
|
|
128
129
|
"# Raw Test Shell",
|
|
129
130
|
"",
|
|
130
131
|
"This is an isolated raw-files test shell generated by Interf Compiler.",
|
|
131
|
-
"There is no compiled
|
|
132
|
+
"There is no compiled dataset in this shell.",
|
|
132
133
|
"",
|
|
133
134
|
"## How to use this shell",
|
|
134
135
|
"",
|
|
@@ -139,7 +140,7 @@ function renderRawTestAgents() {
|
|
|
139
140
|
"## Rules",
|
|
140
141
|
"",
|
|
141
142
|
"- Answer only from the files under `raw/`.",
|
|
142
|
-
"- There is no compiled
|
|
143
|
+
"- There is no compiled dataset here, so do not assume any compiled output zones exist.",
|
|
143
144
|
"- Do not treat hidden runtime files or test artifacts as evidence.",
|
|
144
145
|
...chartNotes,
|
|
145
146
|
"- Write the requested answer and trace files, then stop.",
|
|
@@ -164,14 +165,14 @@ function renderRawTestQuerySkill() {
|
|
|
164
165
|
"1. Read `raw/` directly.",
|
|
165
166
|
"2. Verify exact claims against the raw files before answering strongly.",
|
|
166
167
|
...chartNotes,
|
|
167
|
-
"8. Do not rely on compiled
|
|
168
|
+
"8. Do not rely on compiled dataset artifacts because they do not exist in this shell.",
|
|
168
169
|
"",
|
|
169
170
|
].join("\n");
|
|
170
171
|
}
|
|
171
|
-
function
|
|
172
|
-
const filePath =
|
|
172
|
+
function readCompiledQuerySkillSource(compiledPath) {
|
|
173
|
+
const filePath = compiledQuerySkillSourcePath(compiledPath);
|
|
173
174
|
if (!existsSync(filePath)) {
|
|
174
|
-
throw new Error(`Missing
|
|
175
|
+
throw new Error(`Missing compiled query skill source at ${filePath}. Interf compile runs the local workflow package directly, so reseed or repair this compiled dataset instead of auto-healing query docs.`);
|
|
175
176
|
}
|
|
176
177
|
return readFileSync(filePath, "utf8").trim();
|
|
177
178
|
}
|
|
@@ -224,11 +225,11 @@ function linkRelativePath(targetPath, linkPathname) {
|
|
|
224
225
|
mkdirSync(dirname(linkPathname), { recursive: true });
|
|
225
226
|
symlinkSync(relative(dirname(linkPathname), targetPath), linkPathname);
|
|
226
227
|
}
|
|
227
|
-
function
|
|
228
|
-
const workflowRoot =
|
|
229
|
-
const schema =
|
|
228
|
+
function loadCompiledSchema(compiledPath) {
|
|
229
|
+
const workflowRoot = workflowPackagePathForCompiled(compiledPath);
|
|
230
|
+
const schema = readCompiledSchemaFile(workflowRoot);
|
|
230
231
|
if (!schema) {
|
|
231
|
-
throw new Error(`Missing workflow
|
|
232
|
+
throw new Error(`Missing workflow compiled schema at ${join(workflowRoot, "compiled.schema.json")}`);
|
|
232
233
|
}
|
|
233
234
|
return schema;
|
|
234
235
|
}
|
|
@@ -238,29 +239,78 @@ function zoneMap(schema) {
|
|
|
238
239
|
function zoneOrThrow(zones, zoneId) {
|
|
239
240
|
const zone = zones.get(zoneId);
|
|
240
241
|
if (!zone) {
|
|
241
|
-
throw new Error(`Missing
|
|
242
|
+
throw new Error(`Missing compiled schema zone "${zoneId}" for stage shell projection.`);
|
|
242
243
|
}
|
|
243
244
|
return zone;
|
|
244
245
|
}
|
|
245
|
-
function
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
function normalizeArtifactRelativePath(path) {
|
|
247
|
+
return path
|
|
248
|
+
.replaceAll("\\", "/")
|
|
249
|
+
.replace(/^\.?\//, "")
|
|
250
|
+
.replace(/\/+$/g, "");
|
|
251
|
+
}
|
|
252
|
+
function relativePathEqualsOrWithin(basePath, candidatePath) {
|
|
253
|
+
const base = normalizeArtifactRelativePath(basePath);
|
|
254
|
+
const candidate = normalizeArtifactRelativePath(candidatePath);
|
|
255
|
+
if (base.length === 0 || candidate.length === 0)
|
|
256
|
+
return false;
|
|
257
|
+
return candidate === base || candidate.startsWith(`${base}/`);
|
|
258
|
+
}
|
|
259
|
+
function stageWriteZoneSet(schema, stage) {
|
|
260
|
+
return new Set(stage.writes.filter((zoneId) => schema.zones.some((zone) => zone.id === zoneId)));
|
|
261
|
+
}
|
|
262
|
+
function stageMaterializedZoneSet(schema, stage, writeArtifacts = []) {
|
|
263
|
+
const materialized = stageWriteZoneSet(schema, stage);
|
|
264
|
+
for (const zone of schema.zones) {
|
|
265
|
+
if (zone.kind === "runtime" && stage.reads.includes(zone.id)) {
|
|
266
|
+
materialized.add(zone.id);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const artifactPath of writeArtifacts) {
|
|
270
|
+
const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
|
|
271
|
+
if (normalizedArtifactPath.length === 0)
|
|
272
|
+
continue;
|
|
273
|
+
const owner = schema.zones.find((zone) => relativePathEqualsOrWithin(zone.path, normalizedArtifactPath));
|
|
274
|
+
if (owner) {
|
|
275
|
+
materialized.add(owner.id);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return materialized;
|
|
279
|
+
}
|
|
280
|
+
function ensureShellLocalProjection(sourcePath, targetPath, zone) {
|
|
281
|
+
if (existsSync(sourcePath)) {
|
|
282
|
+
copyResolvedTree({
|
|
283
|
+
sourcePath,
|
|
284
|
+
targetPath,
|
|
285
|
+
shellType: "stage-execution",
|
|
286
|
+
});
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (zone.kind === "file") {
|
|
290
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
mkdirSync(targetPath, { recursive: true });
|
|
294
|
+
}
|
|
295
|
+
function ensureCompiledExecutionSurface(compiledPath) {
|
|
296
|
+
mkdirSync(compiledRuntimeRoot(compiledPath), { recursive: true });
|
|
297
|
+
mkdirSync(workflowPackagePathForCompiled(compiledPath), { recursive: true });
|
|
298
|
+
const schema = loadCompiledSchema(compiledPath);
|
|
299
|
+
ensureCompiledZoneTargets(compiledPath, schema);
|
|
250
300
|
return schema;
|
|
251
301
|
}
|
|
252
|
-
function readStageMethodDoc(
|
|
253
|
-
const path = join(
|
|
302
|
+
function readStageMethodDoc(compiledPath, stage) {
|
|
303
|
+
const path = join(workflowPackagePathForCompiled(compiledPath), "compile", "stages", stage.skillDir, "SKILL.md");
|
|
254
304
|
if (!existsSync(path))
|
|
255
305
|
return null;
|
|
256
306
|
return readFileSync(path, "utf8").trim();
|
|
257
307
|
}
|
|
258
|
-
function stageWorkflowDocsPath(
|
|
259
|
-
return join(
|
|
308
|
+
function stageWorkflowDocsPath(compiledPath, stage) {
|
|
309
|
+
return join(workflowPackagePathForCompiled(compiledPath), "compile", "stages", stage.skillDir);
|
|
260
310
|
}
|
|
261
|
-
function renderStageExecutionAgents(
|
|
311
|
+
function renderStageExecutionAgents(compiledName, workflowId, stage) {
|
|
262
312
|
return [
|
|
263
|
-
`# ${
|
|
313
|
+
`# ${compiledName} — ${stage.label} Execution Shell`,
|
|
264
314
|
"",
|
|
265
315
|
"This is an ephemeral stage-execution shell generated by Interf Compiler.",
|
|
266
316
|
"It is for automated pipeline execution only, not for manual querying.",
|
|
@@ -277,16 +327,16 @@ function renderStageExecutionAgents(workspaceName, workflowId, stage) {
|
|
|
277
327
|
"- `inputs/<zone-id>/` = read mounts for the current stage.",
|
|
278
328
|
"- `outputs/<zone-id>/` = write mounts for the current stage.",
|
|
279
329
|
"- For file zones, `runtime/paths.json` points to the exact file path inside those mount roots.",
|
|
280
|
-
"- declared
|
|
330
|
+
"- declared compiled zone paths are also projected at the shell root so workflow-relative contract paths stay valid.",
|
|
281
331
|
"- `runtime/` = stage contract and machine-readable path map for this shell.",
|
|
282
|
-
"- `workflow/` = workflow metadata,
|
|
332
|
+
"- `workflow/` = workflow metadata, compiled schema, and docs for the current stage only.",
|
|
283
333
|
"",
|
|
284
334
|
"## Boundaries",
|
|
285
335
|
"",
|
|
286
336
|
`- Workflow: \`${workflowId}\`.`,
|
|
287
337
|
`- Contract type: \`${stage.contractType}\`.`,
|
|
288
|
-
"- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the compiled
|
|
289
|
-
"- The compiled
|
|
338
|
+
"- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the compiled-dataset query shell.",
|
|
339
|
+
"- The compiled dataset root itself is not linked into this shell.",
|
|
290
340
|
"- Do not switch into query mode or act like a user-facing assistant.",
|
|
291
341
|
"- Do not modify files under `inputs/` unless the same zone is also mounted under `outputs/`.",
|
|
292
342
|
"",
|
|
@@ -339,62 +389,68 @@ function renderStageExecutionSkill(stage, stageMethodDoc) {
|
|
|
339
389
|
: []),
|
|
340
390
|
].join("\n");
|
|
341
391
|
}
|
|
342
|
-
function
|
|
392
|
+
function renderCompiledQueryNativeSkill(querySkillContent) {
|
|
343
393
|
return [
|
|
344
394
|
"---",
|
|
345
395
|
"name: interf-query",
|
|
346
396
|
"description: >",
|
|
347
|
-
" Native local query skill for this compiled
|
|
348
|
-
" Compiler. Use it for manual questions against the compiled
|
|
397
|
+
" Native local query skill for this compiled dataset built by Interf",
|
|
398
|
+
" Compiler. Use it for manual questions against the compiled dataset and",
|
|
349
399
|
" its raw fallback.",
|
|
350
400
|
"---",
|
|
351
401
|
"",
|
|
352
402
|
"# Interf Compiler Query",
|
|
353
403
|
"",
|
|
354
|
-
"This is the native local query skill for a compiled
|
|
355
|
-
"Use it when reading this
|
|
404
|
+
"This is the native local query skill for a compiled dataset built by Interf Compiler.",
|
|
405
|
+
"Use it when reading this compiled dataset manually.",
|
|
356
406
|
"Editable source: `.interf/workflow/use/query/SKILL.md`.",
|
|
357
407
|
"",
|
|
358
408
|
querySkillContent.trim(),
|
|
359
409
|
"",
|
|
360
410
|
].join("\n");
|
|
361
411
|
}
|
|
362
|
-
function projectWorkflowMetadata(
|
|
412
|
+
function projectWorkflowMetadata(compiledPath, shellRoot, stage) {
|
|
363
413
|
const shellWorkflowRoot = stageShellWorkflowRoot(shellRoot);
|
|
364
414
|
mkdirSync(join(shellWorkflowRoot, "compile", "stages"), { recursive: true });
|
|
365
|
-
const
|
|
366
|
-
const workflowJsonPath = join(
|
|
415
|
+
const compiledWorkflowRoot = workflowPackagePathForCompiled(compiledPath);
|
|
416
|
+
const workflowJsonPath = join(compiledWorkflowRoot, "workflow.json");
|
|
367
417
|
if (existsSync(workflowJsonPath)) {
|
|
368
418
|
linkPath(workflowJsonPath, join(shellWorkflowRoot, "workflow.json"));
|
|
369
419
|
}
|
|
370
|
-
const
|
|
371
|
-
if (existsSync(
|
|
372
|
-
linkPath(
|
|
420
|
+
const compiledSchemaPath = join(compiledWorkflowRoot, "compiled.schema.json");
|
|
421
|
+
if (existsSync(compiledSchemaPath)) {
|
|
422
|
+
linkPath(compiledSchemaPath, join(shellWorkflowRoot, "compiled.schema.json"));
|
|
373
423
|
}
|
|
374
|
-
const readmePath = join(
|
|
424
|
+
const readmePath = join(compiledWorkflowRoot, "README.md");
|
|
375
425
|
if (existsSync(readmePath)) {
|
|
376
426
|
linkPath(readmePath, join(shellWorkflowRoot, "README.md"));
|
|
377
427
|
}
|
|
378
|
-
const stageDocsPath = stageWorkflowDocsPath(
|
|
428
|
+
const stageDocsPath = stageWorkflowDocsPath(compiledPath, stage);
|
|
379
429
|
if (existsSync(stageDocsPath)) {
|
|
380
430
|
linkPath(stageDocsPath, join(shellWorkflowRoot, "compile", "stages", stage.skillDir));
|
|
381
431
|
}
|
|
382
432
|
}
|
|
383
|
-
function
|
|
433
|
+
function projectCompiledSchemaZones(compiledPath, shellRoot, schema, zoneIds, materializedZoneIds) {
|
|
384
434
|
const allowedZoneIds = zoneIds ? new Set(zoneIds) : null;
|
|
385
435
|
for (const zone of schema.zones) {
|
|
386
436
|
if (allowedZoneIds && !allowedZoneIds.has(zone.id))
|
|
387
437
|
continue;
|
|
388
|
-
|
|
438
|
+
const sourcePath = compiledZoneAbsolutePath(compiledPath, zone);
|
|
439
|
+
const targetPath = join(shellRoot, zone.path);
|
|
440
|
+
if (materializedZoneIds?.has(zone.id)) {
|
|
441
|
+
ensureShellLocalProjection(sourcePath, targetPath, zone);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
linkPath(sourcePath, targetPath);
|
|
389
445
|
}
|
|
390
446
|
}
|
|
391
|
-
function buildStageZoneMounts(
|
|
447
|
+
function buildStageZoneMounts(compiledPath, shellRoot, stage, schema) {
|
|
392
448
|
const zones = zoneMap(schema);
|
|
393
449
|
const mountFor = (zoneId) => {
|
|
394
450
|
const zone = zoneOrThrow(zones, zoneId);
|
|
395
451
|
return {
|
|
396
452
|
zone_id: zone.id,
|
|
397
|
-
|
|
453
|
+
compiled_path: zone.path,
|
|
398
454
|
shell_root_path: zone.path,
|
|
399
455
|
input_mount_path: stage.reads.includes(zoneId)
|
|
400
456
|
? describeShellZoneAliasMountPath(zone, "inputs")
|
|
@@ -409,16 +465,16 @@ function buildStageZoneMounts(workspacePath, shellRoot, stage, schema) {
|
|
|
409
465
|
writes: stage.writes.map(mountFor),
|
|
410
466
|
};
|
|
411
467
|
}
|
|
412
|
-
function projectStageZoneMountAliases(
|
|
468
|
+
function projectStageZoneMountAliases(shellRoot, stage, schema) {
|
|
413
469
|
const zones = zoneMap(schema);
|
|
414
470
|
for (const zoneId of new Set([...stage.reads, ...stage.writes])) {
|
|
415
471
|
const zone = zoneOrThrow(zones, zoneId);
|
|
416
|
-
const targetPath =
|
|
472
|
+
const targetPath = join(shellRoot, zone.path);
|
|
417
473
|
if (stage.reads.includes(zoneId)) {
|
|
418
|
-
|
|
474
|
+
linkRelativePath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "inputs"));
|
|
419
475
|
}
|
|
420
476
|
if (stage.writes.includes(zoneId)) {
|
|
421
|
-
|
|
477
|
+
linkRelativePath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "outputs"));
|
|
422
478
|
}
|
|
423
479
|
}
|
|
424
480
|
}
|
|
@@ -433,29 +489,61 @@ function writeExecutionShellPathsFile(shellRoot, workflowId, stage, mounts) {
|
|
|
433
489
|
};
|
|
434
490
|
writeFileSync(shellRuntimePath(shellRoot, "paths.json"), `${JSON.stringify(paths, null, 2)}\n`);
|
|
435
491
|
}
|
|
436
|
-
export function syncStageExecutionShellWrites(
|
|
437
|
-
const schema =
|
|
492
|
+
export function syncStageExecutionShellWrites(compiledPath, shellRoot, stage, writeArtifacts = []) {
|
|
493
|
+
const schema = ensureCompiledExecutionSurface(compiledPath);
|
|
438
494
|
const zones = zoneMap(schema);
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
495
|
+
const stageWriteZones = Array.from(stageWriteZoneSet(schema, stage))
|
|
496
|
+
.map((zoneId) => zoneOrThrow(zones, zoneId));
|
|
497
|
+
for (const zone of stageWriteZones) {
|
|
498
|
+
const canonicalShellZonePath = join(shellRoot, zone.path);
|
|
499
|
+
const outputAliasPath = shellZoneAliasMountPath(shellRoot, zone, "outputs");
|
|
500
|
+
const shellZonePath = zone.kind === "file" &&
|
|
501
|
+
existsSync(outputAliasPath) &&
|
|
502
|
+
!lstatSync(outputAliasPath).isSymbolicLink()
|
|
503
|
+
? outputAliasPath
|
|
504
|
+
: canonicalShellZonePath;
|
|
442
505
|
if (!existsSync(shellZonePath))
|
|
443
506
|
continue;
|
|
444
507
|
const shellZoneStat = lstatSync(shellZonePath);
|
|
445
508
|
if (shellZoneStat.isSymbolicLink())
|
|
446
509
|
continue;
|
|
447
|
-
const
|
|
510
|
+
const compiledZonePath = compiledZoneAbsolutePath(compiledPath, zone);
|
|
448
511
|
if (shellZoneStat.isDirectory()) {
|
|
449
|
-
rmSync(
|
|
450
|
-
mkdirSync(dirname(
|
|
451
|
-
cpSync(shellZonePath,
|
|
512
|
+
rmSync(compiledZonePath, { recursive: true, force: true });
|
|
513
|
+
mkdirSync(dirname(compiledZonePath), { recursive: true });
|
|
514
|
+
cpSync(shellZonePath, compiledZonePath, {
|
|
515
|
+
recursive: true,
|
|
516
|
+
force: true,
|
|
517
|
+
});
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
mkdirSync(dirname(compiledZonePath), { recursive: true });
|
|
521
|
+
copyFileSync(shellZonePath, compiledZonePath);
|
|
522
|
+
}
|
|
523
|
+
for (const artifactPath of writeArtifacts) {
|
|
524
|
+
const normalizedArtifactPath = normalizeArtifactRelativePath(artifactPath);
|
|
525
|
+
if (normalizedArtifactPath.length === 0 ||
|
|
526
|
+
stageWriteZones.some((zone) => relativePathEqualsOrWithin(zone.path, normalizedArtifactPath))) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const shellArtifactPath = join(shellRoot, normalizedArtifactPath);
|
|
530
|
+
if (!existsSync(shellArtifactPath))
|
|
531
|
+
continue;
|
|
532
|
+
const compiledArtifactPath = join(compiledPath, normalizedArtifactPath);
|
|
533
|
+
const shellArtifactStat = lstatSync(shellArtifactPath);
|
|
534
|
+
if (shellArtifactStat.isSymbolicLink())
|
|
535
|
+
continue;
|
|
536
|
+
if (shellArtifactStat.isDirectory()) {
|
|
537
|
+
rmSync(compiledArtifactPath, { recursive: true, force: true });
|
|
538
|
+
mkdirSync(dirname(compiledArtifactPath), { recursive: true });
|
|
539
|
+
cpSync(shellArtifactPath, compiledArtifactPath, {
|
|
452
540
|
recursive: true,
|
|
453
541
|
force: true,
|
|
454
542
|
});
|
|
455
543
|
continue;
|
|
456
544
|
}
|
|
457
|
-
mkdirSync(dirname(
|
|
458
|
-
copyFileSync(
|
|
545
|
+
mkdirSync(dirname(compiledArtifactPath), { recursive: true });
|
|
546
|
+
copyFileSync(shellArtifactPath, compiledArtifactPath);
|
|
459
547
|
}
|
|
460
548
|
}
|
|
461
549
|
function preservedShellManifestPath(rootPath) {
|
|
@@ -563,12 +651,12 @@ export function renderClaudeBootstrap(content) {
|
|
|
563
651
|
"",
|
|
564
652
|
].join("\n");
|
|
565
653
|
}
|
|
566
|
-
function improvementWorkflowDocsPath(
|
|
567
|
-
return join(
|
|
654
|
+
function improvementWorkflowDocsPath(compiledPath) {
|
|
655
|
+
return join(workflowPackagePathForCompiled(compiledPath), "improve");
|
|
568
656
|
}
|
|
569
|
-
function renderWorkflowImprovementAgents(
|
|
657
|
+
function renderWorkflowImprovementAgents(compiledName, workflowId, loopIndex) {
|
|
570
658
|
return [
|
|
571
|
-
`# ${
|
|
659
|
+
`# ${compiledName} — Workflow Improvement Shell`,
|
|
572
660
|
"",
|
|
573
661
|
"This is an automated workflow-improvement shell generated by Interf Compiler.",
|
|
574
662
|
"It exists to review failed compile/test runs and edit the workflow package for the next variation.",
|
|
@@ -576,7 +664,7 @@ function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
|
|
|
576
664
|
"## Start Here",
|
|
577
665
|
"",
|
|
578
666
|
"1. Read `runtime/loop-context.json` now.",
|
|
579
|
-
"2. Read `workflow/README.md`, `workflow/workflow.json`, and `workflow/
|
|
667
|
+
"2. Read `workflow/README.md`, `workflow/workflow.json`, and `workflow/compiled.schema.json` now.",
|
|
580
668
|
"3. Read `workflow/improve/SKILL.md` now.",
|
|
581
669
|
"4. Use the local native `interf-workflow-improver` skill now.",
|
|
582
670
|
"",
|
|
@@ -585,20 +673,20 @@ function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
|
|
|
585
673
|
`- Workflow: \`${workflowId}\`.`,
|
|
586
674
|
`- Improvement loop: ${loopIndex}.`,
|
|
587
675
|
"- Edit only files under `workflow/`.",
|
|
588
|
-
"- Do not edit truth checks, test specs, raw dataset files, or generated
|
|
589
|
-
"- Review compiled outputs under `artifacts/
|
|
590
|
-
"- Keep the workflow valid for the current compiler API and
|
|
676
|
+
"- Do not edit truth checks, test specs, raw dataset files, or generated compiled outputs.",
|
|
677
|
+
"- Review compiled outputs under `artifacts/compiled-view/` and test/runtime evidence under `artifacts/`.",
|
|
678
|
+
"- Keep the workflow valid for the current compiler API and compiled schema.",
|
|
591
679
|
"",
|
|
592
680
|
"## Goal",
|
|
593
681
|
"",
|
|
594
682
|
"- create a better workflow variation for this dataset",
|
|
595
|
-
"- preserve deterministic
|
|
683
|
+
"- preserve deterministic compiled structure",
|
|
596
684
|
"- stop after the workflow edits are complete",
|
|
597
685
|
"",
|
|
598
686
|
].join("\n");
|
|
599
687
|
}
|
|
600
|
-
function readWorkflowImprovementDoc(
|
|
601
|
-
const path = join(improvementWorkflowDocsPath(
|
|
688
|
+
function readWorkflowImprovementDoc(compiledPath) {
|
|
689
|
+
const path = join(improvementWorkflowDocsPath(compiledPath), "SKILL.md");
|
|
602
690
|
if (!existsSync(path))
|
|
603
691
|
return null;
|
|
604
692
|
return readFileSync(path, "utf8").trim();
|
|
@@ -616,7 +704,7 @@ function renderWorkflowImprovementSkill(workflowId, loopIndex, improvementDoc) {
|
|
|
616
704
|
"",
|
|
617
705
|
"This local native skill exists for automated workflow-improvement loops.",
|
|
618
706
|
"Read `runtime/loop-context.json` first.",
|
|
619
|
-
"Then review the linked workflow package, `artifacts/
|
|
707
|
+
"Then review the linked workflow package, `artifacts/compiled-view/`, preserved stage shells, runtime logs, and saved test outputs before editing `workflow/`.",
|
|
620
708
|
"",
|
|
621
709
|
"## Current Loop",
|
|
622
710
|
"",
|
|
@@ -634,18 +722,18 @@ function renderWorkflowImprovementSkill(workflowId, loopIndex, improvementDoc) {
|
|
|
634
722
|
: []),
|
|
635
723
|
].join("\n");
|
|
636
724
|
}
|
|
637
|
-
function
|
|
638
|
-
const
|
|
639
|
-
mkdirSync(
|
|
725
|
+
function projectCompiledReviewArtifactsSnapshot(compiledPath, shellRoot, schema) {
|
|
726
|
+
const compiledViewRoot = join(shellRoot, "artifacts", "compiled-view");
|
|
727
|
+
mkdirSync(compiledViewRoot, { recursive: true });
|
|
640
728
|
for (const zone of schema.zones) {
|
|
641
729
|
if (zone.kind === "runtime" || zone.path === "raw")
|
|
642
730
|
continue;
|
|
643
|
-
const sourcePath =
|
|
731
|
+
const sourcePath = compiledZoneAbsolutePath(compiledPath, zone);
|
|
644
732
|
if (!existsSync(sourcePath))
|
|
645
733
|
continue;
|
|
646
734
|
copyResolvedTree({
|
|
647
735
|
sourcePath,
|
|
648
|
-
targetPath: join(
|
|
736
|
+
targetPath: join(compiledViewRoot, zone.path),
|
|
649
737
|
shellType: "workflow-improvement",
|
|
650
738
|
});
|
|
651
739
|
}
|
|
@@ -664,10 +752,10 @@ function copyIfExists(sourcePath, targetPath, shellType) {
|
|
|
664
752
|
shellType,
|
|
665
753
|
});
|
|
666
754
|
}
|
|
667
|
-
function
|
|
668
|
-
const runtimeTarget = join(shellRoot, "artifacts", "
|
|
755
|
+
function projectCompiledRuntimeArtifacts(compiledPath, shellRoot) {
|
|
756
|
+
const runtimeTarget = join(shellRoot, "artifacts", "compiled-runtime");
|
|
669
757
|
mkdirSync(runtimeTarget, { recursive: true });
|
|
670
|
-
const runtimeRoot =
|
|
758
|
+
const runtimeRoot = compiledRuntimeRoot(compiledPath);
|
|
671
759
|
const artifactNames = [
|
|
672
760
|
"run.json",
|
|
673
761
|
"run-history.jsonl",
|
|
@@ -681,33 +769,34 @@ function projectWorkspaceRuntimeArtifacts(workspacePath, shellRoot) {
|
|
|
681
769
|
copyIfExists(join(runtimeRoot, artifactName), join(runtimeTarget, artifactName), "workflow-improvement");
|
|
682
770
|
}
|
|
683
771
|
}
|
|
684
|
-
export function pruneStageExecutionShells(
|
|
685
|
-
rmSync(stageExecutionShellsRoot(
|
|
772
|
+
export function pruneStageExecutionShells(compiledPath) {
|
|
773
|
+
rmSync(stageExecutionShellsRoot(compiledPath), { recursive: true, force: true });
|
|
686
774
|
}
|
|
687
|
-
export function
|
|
688
|
-
const agentsContent =
|
|
689
|
-
const querySkillContent =
|
|
690
|
-
return writeNativeAgentSurface(
|
|
775
|
+
export function projectCompiledQueryShell(compiledPath, compiledName, workflowId, about, options) {
|
|
776
|
+
const agentsContent = renderCompiledAgents(compiledPath, compiledName, workflowId, about, options);
|
|
777
|
+
const querySkillContent = readCompiledQuerySkillSource(compiledPath);
|
|
778
|
+
return writeNativeAgentSurface(compiledPath, agentsContent, "interf-query", renderCompiledQueryNativeSkill(querySkillContent));
|
|
691
779
|
}
|
|
692
780
|
export function projectRawTestQueryShell(rootPath) {
|
|
693
781
|
return writeNativeAgentSurface(rootPath, renderRawTestAgents(), "interf-query", renderRawTestQuerySkill());
|
|
694
782
|
}
|
|
695
|
-
export function createStageExecutionShell(
|
|
696
|
-
const schema =
|
|
697
|
-
const
|
|
783
|
+
export function createStageExecutionShell(compiledPath, compiledName, workflowId, stage, writeArtifacts = []) {
|
|
784
|
+
const schema = ensureCompiledExecutionSurface(compiledPath);
|
|
785
|
+
const materializedZones = stageMaterializedZoneSet(schema, stage, writeArtifacts);
|
|
786
|
+
const shellsRoot = stageExecutionShellsRoot(compiledPath);
|
|
698
787
|
const shellRoot = join(shellsRoot, `${stage.id}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`);
|
|
699
788
|
mkdirSync(shellRoot, { recursive: true });
|
|
700
789
|
mkdirSync(join(shellRoot, "runtime"), { recursive: true });
|
|
701
790
|
mkdirSync(join(shellRoot, "inputs"), { recursive: true });
|
|
702
791
|
mkdirSync(join(shellRoot, "outputs"), { recursive: true });
|
|
703
|
-
linkPath(
|
|
704
|
-
linkPath(join(
|
|
705
|
-
|
|
706
|
-
projectWorkflowMetadata(
|
|
707
|
-
projectStageZoneMountAliases(
|
|
708
|
-
writeExecutionShellPathsFile(shellRoot, workflowId, stage, buildStageZoneMounts(
|
|
709
|
-
const agentsContent = renderStageExecutionAgents(
|
|
710
|
-
writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(
|
|
792
|
+
linkPath(compiledInterfConfigPath(compiledPath), join(shellRoot, "interf.json"));
|
|
793
|
+
linkPath(join(compiledRuntimeRoot(compiledPath), "stage-contract.json"), shellRuntimePath(shellRoot, "stage-contract.json"));
|
|
794
|
+
projectCompiledSchemaZones(compiledPath, shellRoot, schema, new Set([...stage.reads, ...stage.writes]), materializedZones);
|
|
795
|
+
projectWorkflowMetadata(compiledPath, shellRoot, stage);
|
|
796
|
+
projectStageZoneMountAliases(shellRoot, stage, schema);
|
|
797
|
+
writeExecutionShellPathsFile(shellRoot, workflowId, stage, buildStageZoneMounts(compiledPath, shellRoot, stage, schema));
|
|
798
|
+
const agentsContent = renderStageExecutionAgents(compiledName, workflowId, stage);
|
|
799
|
+
writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(compiledPath, stage)));
|
|
711
800
|
return {
|
|
712
801
|
rootPath: shellRoot,
|
|
713
802
|
};
|
|
@@ -716,19 +805,19 @@ export function freezeStageExecutionShell(rootPath) {
|
|
|
716
805
|
return freezePreservedShell(rootPath, "stage-execution");
|
|
717
806
|
}
|
|
718
807
|
export function createWorkflowImprovementShell(options) {
|
|
719
|
-
const schema =
|
|
720
|
-
const loopRootPath = workflowImprovementLoopRoot(options.
|
|
808
|
+
const schema = ensureCompiledExecutionSurface(options.compiledPath);
|
|
809
|
+
const loopRootPath = workflowImprovementLoopRoot(options.compiledPath, options.runId, options.loopIndex);
|
|
721
810
|
const shellRoot = join(loopRootPath, "shell");
|
|
722
811
|
mkdirSync(shellRoot, { recursive: true });
|
|
723
812
|
mkdirSync(join(shellRoot, "runtime"), { recursive: true });
|
|
724
813
|
mkdirSync(join(shellRoot, "artifacts"), { recursive: true });
|
|
725
814
|
mkdirSync(join(loopRootPath, "logs"), { recursive: true });
|
|
726
815
|
writeFileSync(join(shellRoot, "runtime", "loop-context.json"), `${JSON.stringify(options.context, null, 2)}\n`);
|
|
727
|
-
|
|
728
|
-
linkPath(
|
|
729
|
-
copyIfExists(
|
|
730
|
-
|
|
731
|
-
const reviewSources = resolveWorkflowImprovementReviewSourcePaths(options.
|
|
816
|
+
projectCompiledReviewArtifactsSnapshot(options.compiledPath, shellRoot, schema);
|
|
817
|
+
linkPath(workflowPackagePathForCompiled(options.compiledPath), join(shellRoot, "workflow"));
|
|
818
|
+
copyIfExists(compiledInterfConfigPath(options.compiledPath), join(shellRoot, "interf.json"), "workflow-improvement");
|
|
819
|
+
projectCompiledRuntimeArtifacts(options.compiledPath, shellRoot);
|
|
820
|
+
const reviewSources = resolveWorkflowImprovementReviewSourcePaths(options.compiledPath);
|
|
732
821
|
if (reviewSources.executionShells) {
|
|
733
822
|
copyIfExists(reviewSources.executionShells, join(shellRoot, "artifacts", "execution-shells"), "workflow-improvement");
|
|
734
823
|
}
|
|
@@ -741,8 +830,8 @@ export function createWorkflowImprovementShell(options) {
|
|
|
741
830
|
if (reviewSources.targetTestSandboxes) {
|
|
742
831
|
copyIfExists(reviewSources.targetTestSandboxes, join(shellRoot, "artifacts", "test-sandboxes"), "workflow-improvement");
|
|
743
832
|
}
|
|
744
|
-
const agentsContent = renderWorkflowImprovementAgents(options.
|
|
745
|
-
writeNativeAgentSurface(shellRoot, agentsContent, "interf-workflow-improver", renderWorkflowImprovementSkill(options.workflowId, options.loopIndex, readWorkflowImprovementDoc(options.
|
|
833
|
+
const agentsContent = renderWorkflowImprovementAgents(options.compiledName, options.workflowId, options.loopIndex);
|
|
834
|
+
writeNativeAgentSurface(shellRoot, agentsContent, "interf-workflow-improver", renderWorkflowImprovementSkill(options.workflowId, options.loopIndex, readWorkflowImprovementDoc(options.compiledPath)));
|
|
746
835
|
return {
|
|
747
836
|
rootPath: shellRoot,
|
|
748
837
|
loopRootPath,
|