@interf/compiler 0.3.3 → 0.4.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 +137 -243
- package/builtin-workflows/interf/README.md +19 -0
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +28 -0
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +18 -0
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -0
- package/builtin-workflows/interf/improve/SKILL.md +18 -0
- package/builtin-workflows/interf/use/query/SKILL.md +28 -0
- package/builtin-workflows/interf/workflow.json +120 -0
- package/builtin-workflows/interf/workspace.schema.json +75 -0
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +0 -1
- package/dist/commands/compile-controller.d.ts +14 -0
- package/dist/commands/compile-controller.js +409 -0
- package/dist/commands/compile.d.ts +8 -9
- package/dist/commands/compile.js +151 -153
- package/dist/commands/create-workflow-wizard.d.ts +4 -2
- package/dist/commands/create-workflow-wizard.js +33 -31
- package/dist/commands/create.d.ts +0 -1
- package/dist/commands/create.js +16 -12
- package/dist/commands/default.d.ts +0 -1
- package/dist/commands/default.js +1 -2
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/doctor.js +7 -22
- package/dist/commands/executor-flow.d.ts +0 -1
- package/dist/commands/executor-flow.js +0 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +72 -15
- package/dist/commands/list.d.ts +0 -1
- package/dist/commands/list.js +0 -1
- package/dist/commands/reset.d.ts +0 -1
- package/dist/commands/reset.js +0 -1
- package/dist/commands/source-config-wizard.d.ts +28 -7
- package/dist/commands/source-config-wizard.js +159 -63
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/status.js +0 -1
- package/dist/commands/test-flow.d.ts +20 -10
- package/dist/commands/test-flow.js +89 -23
- package/dist/commands/test.d.ts +0 -1
- package/dist/commands/test.js +36 -72
- package/dist/commands/verify.d.ts +0 -1
- package/dist/commands/verify.js +0 -1
- package/dist/commands/workspace-flow.d.ts +3 -3
- package/dist/commands/workspace-flow.js +30 -12
- package/dist/index.d.ts +5 -6
- package/dist/index.js +3 -4
- package/dist/lib/agent-args.d.ts +0 -1
- package/dist/lib/agent-args.js +0 -1
- package/dist/lib/agent-constants.d.ts +0 -1
- package/dist/lib/agent-constants.js +0 -1
- package/dist/lib/agent-detection.d.ts +0 -1
- package/dist/lib/agent-detection.js +0 -1
- package/dist/lib/agent-execution.d.ts +0 -1
- package/dist/lib/agent-execution.js +47 -12
- package/dist/lib/agent-logs.d.ts +0 -1
- package/dist/lib/agent-logs.js +0 -1
- package/dist/lib/agent-preflight.d.ts +0 -1
- package/dist/lib/agent-preflight.js +1 -2
- package/dist/lib/agent-render.d.ts +0 -1
- package/dist/lib/agent-render.js +0 -1
- package/dist/lib/agent-shells.d.ts +30 -3
- package/dist/lib/agent-shells.js +527 -63
- package/dist/lib/agent-status.d.ts +0 -1
- package/dist/lib/agent-status.js +0 -1
- package/dist/lib/agent-types.d.ts +0 -1
- package/dist/lib/agent-types.js +0 -1
- package/dist/lib/agents.d.ts +0 -9
- package/dist/lib/agents.js +0 -9
- package/dist/lib/chart-guidance.d.ts +1 -0
- package/dist/lib/chart-guidance.js +8 -0
- package/dist/lib/config.d.ts +0 -3
- package/dist/lib/config.js +0 -5
- package/dist/lib/discovery.d.ts +0 -1
- package/dist/lib/discovery.js +0 -1
- package/dist/lib/execution-profile.d.ts +0 -1
- package/dist/lib/execution-profile.js +0 -1
- package/dist/lib/executors.d.ts +0 -1
- package/dist/lib/executors.js +0 -1
- package/dist/lib/filesystem.d.ts +0 -1
- package/dist/lib/filesystem.js +0 -1
- package/dist/lib/interf-bootstrap.d.ts +0 -1
- package/dist/lib/interf-bootstrap.js +6 -2
- package/dist/lib/interf-detect.d.ts +2 -2
- package/dist/lib/interf-detect.js +25 -8
- package/dist/lib/interf-scaffold.d.ts +0 -1
- package/dist/lib/interf-scaffold.js +54 -21
- package/dist/lib/interf-workflow-package.d.ts +18 -1
- package/dist/lib/interf-workflow-package.js +164 -23
- package/dist/lib/interf.d.ts +1 -2
- package/dist/lib/interf.js +1 -2
- package/dist/lib/local-workflows.d.ts +10 -5
- package/dist/lib/local-workflows.js +208 -97
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +0 -1
- package/dist/lib/obsidian.d.ts +0 -1
- package/dist/lib/obsidian.js +0 -1
- package/dist/lib/parse.d.ts +0 -1
- package/dist/lib/parse.js +0 -1
- package/dist/lib/registry.d.ts +0 -1
- package/dist/lib/registry.js +0 -1
- package/dist/lib/runtime-acceptance.d.ts +0 -1
- package/dist/lib/runtime-acceptance.js +1 -2
- package/dist/lib/runtime-contracts.d.ts +0 -1
- package/dist/lib/runtime-contracts.js +14 -8
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-paths.js +5 -10
- package/dist/lib/runtime-prompt.d.ts +0 -1
- package/dist/lib/runtime-prompt.js +8 -23
- package/dist/lib/runtime-reconcile.d.ts +0 -1
- package/dist/lib/runtime-reconcile.js +7 -3
- package/dist/lib/runtime-runs.d.ts +0 -1
- package/dist/lib/runtime-runs.js +4 -5
- package/dist/lib/runtime-types.d.ts +0 -1
- package/dist/lib/runtime-types.js +0 -1
- package/dist/lib/runtime.d.ts +0 -1
- package/dist/lib/runtime.js +0 -1
- package/dist/lib/schema.d.ts +356 -51
- package/dist/lib/schema.js +189 -54
- package/dist/lib/source-config.d.ts +17 -8
- package/dist/lib/source-config.js +125 -11
- package/dist/lib/state-artifacts.d.ts +0 -1
- package/dist/lib/state-artifacts.js +0 -1
- package/dist/lib/state-health.d.ts +0 -1
- package/dist/lib/state-health.js +2 -3
- package/dist/lib/state-io.d.ts +1 -1
- package/dist/lib/state-io.js +9 -10
- package/dist/lib/state-paths.d.ts +0 -1
- package/dist/lib/state-paths.js +5 -11
- package/dist/lib/state-view.d.ts +0 -1
- package/dist/lib/state-view.js +7 -8
- package/dist/lib/state.d.ts +0 -1
- package/dist/lib/state.js +0 -1
- package/dist/lib/summarize-plan.d.ts +0 -1
- package/dist/lib/summarize-plan.js +3 -3
- package/dist/lib/test-execution.d.ts +14 -0
- package/dist/lib/{benchmark-execution.js → test-execution.js} +122 -120
- package/dist/lib/test-matrices.d.ts +90 -0
- package/dist/lib/test-matrices.js +96 -0
- package/dist/lib/test-paths.d.ts +12 -0
- package/dist/lib/test-paths.js +44 -0
- package/dist/lib/test-profile-presets.d.ts +57 -0
- package/dist/lib/test-profile-presets.js +50 -0
- package/dist/lib/test-sandbox.d.ts +11 -0
- package/dist/lib/{benchmark-sandbox.js → test-sandbox.js} +18 -13
- package/dist/lib/test-specs.d.ts +7 -0
- package/dist/lib/test-specs.js +114 -0
- package/dist/lib/test-targets.d.ts +5 -0
- package/dist/lib/test-targets.js +38 -0
- package/dist/lib/test-types.d.ts +17 -0
- package/dist/lib/test-types.js +1 -0
- package/dist/lib/test.d.ts +4 -0
- package/dist/lib/test.js +3 -0
- package/dist/lib/user-config.d.ts +0 -1
- package/dist/lib/user-config.js +0 -1
- package/dist/lib/util.d.ts +0 -2
- package/dist/lib/util.js +0 -2
- package/dist/lib/validate-helpers.d.ts +0 -1
- package/dist/lib/validate-helpers.js +0 -1
- package/dist/lib/validate-workspace.d.ts +0 -1
- package/dist/lib/validate-workspace.js +34 -25
- package/dist/lib/validate.d.ts +0 -1
- package/dist/lib/validate.js +55 -9
- package/dist/lib/workflow-abi.d.ts +138 -0
- package/dist/lib/workflow-abi.js +181 -0
- package/dist/lib/workflow-definitions.d.ts +26 -5
- package/dist/lib/workflow-definitions.js +105 -168
- package/dist/lib/workflow-helpers.d.ts +1 -2
- package/dist/lib/workflow-helpers.js +32 -21
- package/dist/lib/workflow-improvement.d.ts +22 -0
- package/dist/lib/workflow-improvement.js +396 -0
- package/dist/lib/workflow-review-paths.d.ts +10 -0
- package/dist/lib/workflow-review-paths.js +27 -0
- package/dist/lib/workflow-stage-runner.d.ts +1 -1
- package/dist/lib/workflow-stage-runner.js +4 -1
- package/dist/lib/workflows.d.ts +1 -2
- package/dist/lib/workflows.js +1 -2
- package/dist/lib/workspace-compile.d.ts +0 -1
- package/dist/lib/workspace-compile.js +146 -109
- package/dist/lib/workspace-home.d.ts +5 -0
- package/dist/lib/workspace-home.js +32 -0
- package/dist/lib/workspace-layout.d.ts +2 -0
- package/dist/lib/workspace-layout.js +60 -0
- package/dist/lib/workspace-paths.d.ts +41 -0
- package/dist/lib/workspace-paths.js +107 -0
- package/dist/lib/workspace-raw.d.ts +20 -2
- package/dist/lib/workspace-raw.js +6 -8
- package/dist/lib/workspace-reset.d.ts +0 -1
- package/dist/lib/workspace-reset.js +27 -5
- package/dist/lib/workspace-schema.d.ts +1 -10
- package/dist/lib/workspace-schema.js +16 -74
- package/package.json +17 -16
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/commands/compile.d.ts.map +0 -1
- package/dist/commands/compile.js.map +0 -1
- package/dist/commands/create-workflow-wizard.d.ts.map +0 -1
- package/dist/commands/create-workflow-wizard.js.map +0 -1
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/default.d.ts.map +0 -1
- package/dist/commands/default.js.map +0 -1
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/executor-flow.d.ts.map +0 -1
- package/dist/commands/executor-flow.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list.d.ts.map +0 -1
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/reset.d.ts.map +0 -1
- package/dist/commands/reset.js.map +0 -1
- package/dist/commands/source-config-wizard.d.ts.map +0 -1
- package/dist/commands/source-config-wizard.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/test-flow.d.ts.map +0 -1
- package/dist/commands/test-flow.js.map +0 -1
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/verify.d.ts.map +0 -1
- package/dist/commands/verify.js.map +0 -1
- package/dist/commands/workspace-flow.d.ts.map +0 -1
- package/dist/commands/workspace-flow.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/agent-args.d.ts.map +0 -1
- package/dist/lib/agent-args.js.map +0 -1
- package/dist/lib/agent-constants.d.ts.map +0 -1
- package/dist/lib/agent-constants.js.map +0 -1
- package/dist/lib/agent-detection.d.ts.map +0 -1
- package/dist/lib/agent-detection.js.map +0 -1
- package/dist/lib/agent-execution.d.ts.map +0 -1
- package/dist/lib/agent-execution.js.map +0 -1
- package/dist/lib/agent-logs.d.ts.map +0 -1
- package/dist/lib/agent-logs.js.map +0 -1
- package/dist/lib/agent-preflight.d.ts.map +0 -1
- package/dist/lib/agent-preflight.js.map +0 -1
- package/dist/lib/agent-render.d.ts.map +0 -1
- package/dist/lib/agent-render.js.map +0 -1
- package/dist/lib/agent-shells.d.ts.map +0 -1
- package/dist/lib/agent-shells.js.map +0 -1
- package/dist/lib/agent-skills.d.ts +0 -21
- package/dist/lib/agent-skills.d.ts.map +0 -1
- package/dist/lib/agent-skills.js +0 -215
- package/dist/lib/agent-skills.js.map +0 -1
- package/dist/lib/agent-status.d.ts.map +0 -1
- package/dist/lib/agent-status.js.map +0 -1
- package/dist/lib/agent-types.d.ts.map +0 -1
- package/dist/lib/agent-types.js.map +0 -1
- package/dist/lib/agents.d.ts.map +0 -1
- package/dist/lib/agents.js.map +0 -1
- package/dist/lib/benchmark-execution.d.ts +0 -13
- package/dist/lib/benchmark-execution.d.ts.map +0 -1
- package/dist/lib/benchmark-execution.js.map +0 -1
- package/dist/lib/benchmark-paths.d.ts +0 -13
- package/dist/lib/benchmark-paths.d.ts.map +0 -1
- package/dist/lib/benchmark-paths.js +0 -44
- package/dist/lib/benchmark-paths.js.map +0 -1
- package/dist/lib/benchmark-sandbox.d.ts +0 -12
- package/dist/lib/benchmark-sandbox.d.ts.map +0 -1
- package/dist/lib/benchmark-sandbox.js.map +0 -1
- package/dist/lib/benchmark-specs.d.ts +0 -8
- package/dist/lib/benchmark-specs.d.ts.map +0 -1
- package/dist/lib/benchmark-specs.js +0 -115
- package/dist/lib/benchmark-specs.js.map +0 -1
- package/dist/lib/benchmark-targets.d.ts +0 -5
- package/dist/lib/benchmark-targets.d.ts.map +0 -1
- package/dist/lib/benchmark-targets.js +0 -38
- package/dist/lib/benchmark-targets.js.map +0 -1
- package/dist/lib/benchmark-types.d.ts +0 -18
- package/dist/lib/benchmark-types.d.ts.map +0 -1
- package/dist/lib/benchmark-types.js +0 -2
- package/dist/lib/benchmark-types.js.map +0 -1
- package/dist/lib/benchmark.d.ts +0 -5
- package/dist/lib/benchmark.d.ts.map +0 -1
- package/dist/lib/benchmark.js +0 -4
- package/dist/lib/benchmark.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/discovery.d.ts.map +0 -1
- package/dist/lib/discovery.js.map +0 -1
- package/dist/lib/eval-packs.d.ts +0 -158
- package/dist/lib/eval-packs.d.ts.map +0 -1
- package/dist/lib/eval-packs.js +0 -149
- package/dist/lib/eval-packs.js.map +0 -1
- package/dist/lib/execution-profile.d.ts.map +0 -1
- package/dist/lib/execution-profile.js.map +0 -1
- package/dist/lib/executors.d.ts.map +0 -1
- package/dist/lib/executors.js.map +0 -1
- package/dist/lib/filesystem.d.ts.map +0 -1
- package/dist/lib/filesystem.js.map +0 -1
- package/dist/lib/interf-bootstrap.d.ts.map +0 -1
- package/dist/lib/interf-bootstrap.js.map +0 -1
- package/dist/lib/interf-detect.d.ts.map +0 -1
- package/dist/lib/interf-detect.js.map +0 -1
- package/dist/lib/interf-scaffold.d.ts.map +0 -1
- package/dist/lib/interf-scaffold.js.map +0 -1
- package/dist/lib/interf-workflow-package.d.ts.map +0 -1
- package/dist/lib/interf-workflow-package.js.map +0 -1
- package/dist/lib/interf.d.ts.map +0 -1
- package/dist/lib/interf.js.map +0 -1
- package/dist/lib/local-workflows.d.ts.map +0 -1
- package/dist/lib/local-workflows.js.map +0 -1
- package/dist/lib/logger.d.ts.map +0 -1
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/obsidian.d.ts.map +0 -1
- package/dist/lib/obsidian.js.map +0 -1
- package/dist/lib/parse.d.ts.map +0 -1
- package/dist/lib/parse.js.map +0 -1
- package/dist/lib/registry.d.ts.map +0 -1
- package/dist/lib/registry.js.map +0 -1
- package/dist/lib/runtime-acceptance.d.ts.map +0 -1
- package/dist/lib/runtime-acceptance.js.map +0 -1
- package/dist/lib/runtime-contracts.d.ts.map +0 -1
- package/dist/lib/runtime-contracts.js.map +0 -1
- package/dist/lib/runtime-paths.d.ts.map +0 -1
- package/dist/lib/runtime-paths.js.map +0 -1
- package/dist/lib/runtime-prompt.d.ts.map +0 -1
- package/dist/lib/runtime-prompt.js.map +0 -1
- package/dist/lib/runtime-reconcile.d.ts.map +0 -1
- package/dist/lib/runtime-reconcile.js.map +0 -1
- package/dist/lib/runtime-runs.d.ts.map +0 -1
- package/dist/lib/runtime-runs.js.map +0 -1
- package/dist/lib/runtime-types.d.ts.map +0 -1
- package/dist/lib/runtime-types.js.map +0 -1
- package/dist/lib/runtime.d.ts.map +0 -1
- package/dist/lib/runtime.js.map +0 -1
- package/dist/lib/schema.d.ts.map +0 -1
- package/dist/lib/schema.js.map +0 -1
- package/dist/lib/source-config.d.ts.map +0 -1
- package/dist/lib/source-config.js.map +0 -1
- package/dist/lib/state-artifacts.d.ts.map +0 -1
- package/dist/lib/state-artifacts.js.map +0 -1
- package/dist/lib/state-health.d.ts.map +0 -1
- package/dist/lib/state-health.js.map +0 -1
- package/dist/lib/state-io.d.ts.map +0 -1
- package/dist/lib/state-io.js.map +0 -1
- package/dist/lib/state-paths.d.ts.map +0 -1
- package/dist/lib/state-paths.js.map +0 -1
- package/dist/lib/state-view.d.ts.map +0 -1
- package/dist/lib/state-view.js.map +0 -1
- package/dist/lib/state.d.ts.map +0 -1
- package/dist/lib/state.js.map +0 -1
- package/dist/lib/summarize-plan.d.ts.map +0 -1
- package/dist/lib/summarize-plan.js.map +0 -1
- package/dist/lib/user-config.d.ts.map +0 -1
- package/dist/lib/user-config.js.map +0 -1
- package/dist/lib/util.d.ts.map +0 -1
- package/dist/lib/util.js.map +0 -1
- package/dist/lib/validate-helpers.d.ts.map +0 -1
- package/dist/lib/validate-helpers.js.map +0 -1
- package/dist/lib/validate-workspace.d.ts.map +0 -1
- package/dist/lib/validate-workspace.js.map +0 -1
- package/dist/lib/validate.d.ts.map +0 -1
- package/dist/lib/validate.js.map +0 -1
- package/dist/lib/workflow-definitions.d.ts.map +0 -1
- package/dist/lib/workflow-definitions.js.map +0 -1
- package/dist/lib/workflow-helpers.d.ts.map +0 -1
- package/dist/lib/workflow-helpers.js.map +0 -1
- package/dist/lib/workflow-stage-runner.d.ts.map +0 -1
- package/dist/lib/workflow-stage-runner.js.map +0 -1
- package/dist/lib/workflow-starter-docs.d.ts +0 -7
- package/dist/lib/workflow-starter-docs.d.ts.map +0 -1
- package/dist/lib/workflow-starter-docs.js +0 -3
- package/dist/lib/workflow-starter-docs.js.map +0 -1
- package/dist/lib/workflows.d.ts.map +0 -1
- package/dist/lib/workflows.js.map +0 -1
- package/dist/lib/workspace-compile.d.ts.map +0 -1
- package/dist/lib/workspace-compile.js.map +0 -1
- package/dist/lib/workspace-docs.d.ts +0 -3
- package/dist/lib/workspace-docs.d.ts.map +0 -1
- package/dist/lib/workspace-docs.js +0 -82
- package/dist/lib/workspace-docs.js.map +0 -1
- package/dist/lib/workspace-raw.d.ts.map +0 -1
- package/dist/lib/workspace-raw.js.map +0 -1
- package/dist/lib/workspace-reset.d.ts.map +0 -1
- package/dist/lib/workspace-reset.js.map +0 -1
- package/dist/lib/workspace-schema.d.ts.map +0 -1
- package/dist/lib/workspace-schema.js.map +0 -1
- package/skills/benchmark/SKILL.md +0 -122
- package/skills/workflow/create/SKILL.md +0 -141
- package/skills/workspace/shape/SKILL.md +0 -15
- package/skills/workspace/structure/SKILL.md +0 -15
- package/skills/workspace/summarize/SKILL.md +0 -15
- package/templates/workspace/README.md +0 -24
- package/templates/workspace/interfignore +0 -2
package/dist/lib/agent-shells.js
CHANGED
|
@@ -1,16 +1,179 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, symlinkSync, } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { cpSync, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, symlinkSync, } from "node:fs";
|
|
2
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
3
|
+
import { CHART_APPROXIMATION_NOTES } from "./chart-guidance.js";
|
|
3
4
|
import { WORKFLOW_PACKAGE_DIR } from "./interf-detect.js";
|
|
4
|
-
import { renderWorkspaceAgents, renderWorkspaceQuerySkill, } from "./workspace-docs.js";
|
|
5
5
|
import { ensureWorkspaceZoneTargets, readWorkspaceSchemaFile, workspaceZoneAbsolutePath, } from "./workspace-schema.js";
|
|
6
|
+
import { stageExecutionShellsRoot, workflowImprovementLoopRoot, workflowPackagePathForWorkspace, workspaceInterfConfigPath, workspaceRuntimeRoot, } from "./workspace-paths.js";
|
|
7
|
+
import { resolveWorkflowImprovementReviewSourcePaths } from "./workflow-review-paths.js";
|
|
6
8
|
const LOCAL_SKILL_ROOTS = [
|
|
7
9
|
".claude/skills",
|
|
8
10
|
".codex/skills",
|
|
9
11
|
".agents/skills",
|
|
10
12
|
".cursor/skills",
|
|
11
13
|
];
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
+
function writeNativeAgentSurface(rootPath, agentsContent, skillName, skillContent) {
|
|
15
|
+
let changed = false;
|
|
16
|
+
changed = writeIfChanged(join(rootPath, "AGENTS.md"), `${agentsContent.trimEnd()}\n`) || changed;
|
|
17
|
+
changed =
|
|
18
|
+
writeIfChanged(join(rootPath, "CLAUDE.md"), renderClaudeBootstrap(agentsContent)) || changed;
|
|
19
|
+
changed = writeNativeSkillCopies(rootPath, skillName, skillContent) || changed;
|
|
20
|
+
return changed;
|
|
21
|
+
}
|
|
22
|
+
function workspaceQuerySkillSourcePath(workspacePath) {
|
|
23
|
+
return join(workflowPackagePathForWorkspace(workspacePath), "use", "query", "SKILL.md");
|
|
24
|
+
}
|
|
25
|
+
export function renderWorkspaceAgents(name, workflowId, about, options = {}) {
|
|
26
|
+
const workflowOriginSelected = options.workflowOriginSelected ?? workflowId;
|
|
27
|
+
const workflowLocalDraft = options.workflowLocalDraft === true;
|
|
28
|
+
return [
|
|
29
|
+
`# ${name}`,
|
|
30
|
+
"",
|
|
31
|
+
"This is a compiled workspace built by Interf Compiler.",
|
|
32
|
+
"It is a file-based layer on top of the raw files, built for agents to navigate, retrieve evidence, and answer more accurately.",
|
|
33
|
+
"",
|
|
34
|
+
...(about
|
|
35
|
+
? [
|
|
36
|
+
`About: ${about}`,
|
|
37
|
+
"",
|
|
38
|
+
]
|
|
39
|
+
: []),
|
|
40
|
+
"## How to use this workspace",
|
|
41
|
+
"",
|
|
42
|
+
"1. Use the local native `interf-query` skill that Interf Compiler generated for this workspace.",
|
|
43
|
+
"2. Start from `home.md`, then use `knowledge/` and `summaries/`.",
|
|
44
|
+
"3. Use `raw/` when you need direct quotes, exact chart values, table lookups, or verification.",
|
|
45
|
+
"",
|
|
46
|
+
"## How this workspace works",
|
|
47
|
+
"",
|
|
48
|
+
"- `.interf/interf.json` points to the workspace-local `raw/` snapshot via `source.path` and back to the dataset control plane via `source.control_path`.",
|
|
49
|
+
`- Workflow seed: \`${workflowOriginSelected}\`.`,
|
|
50
|
+
...(workflowLocalDraft
|
|
51
|
+
? ["- This workspace now carries a local workflow draft improved from that seed. Recompiling this workspace reuses the local `.interf/workflow/` package."]
|
|
52
|
+
: []),
|
|
53
|
+
`- Active local workflow id: \`${workflowId}\`.`,
|
|
54
|
+
"- `.interf/workflow/` is the local editable method package for this workspace.",
|
|
55
|
+
"- `.interf/workflow/workspace.schema.json` is the deterministic output shape for this workspace.",
|
|
56
|
+
"- `.interf/workflow/improve/` is the editable source for workflow-improvement loops.",
|
|
57
|
+
"- `.interf/workflow/use/query/` is the editable source for the generated native query shell.",
|
|
58
|
+
"- `.interf/workflow/compile/stages/` defines stage-specific docs that Interf Compiler projects into native execution shells for automated runs.",
|
|
59
|
+
"- Native local query skills are generated under local agent skill directories such as `.claude/skills/` and `.codex/skills/`.",
|
|
60
|
+
"- `raw/` contains the workspace-local raw snapshot used for evidence and verification.",
|
|
61
|
+
"- `summaries/` contains per-file evidence objects.",
|
|
62
|
+
"- `knowledge/` contains the cross-file knowledge layer and navigation structure.",
|
|
63
|
+
"- `home.md` is the starting note.",
|
|
64
|
+
"- `.interf/runtime/` holds CLI-owned runtime artifacts.",
|
|
65
|
+
"- `.interf/tests/` holds saved raw-vs-compiled test comparisons for this workspace.",
|
|
66
|
+
"- `.interf/tests/targets/` holds detailed raw and compiled target runs plus preserved test sandboxes.",
|
|
67
|
+
"",
|
|
68
|
+
"## Manual query rules",
|
|
69
|
+
"",
|
|
70
|
+
"- Prefer `home.md`, `knowledge/`, and `summaries/` before `raw/`.",
|
|
71
|
+
"- Use the generated native `interf-query` skill for manual querying. The editable source lives at `.interf/workflow/use/query/SKILL.md`.",
|
|
72
|
+
"- Treat `.interf/` as method/runtime metadata, not answer evidence, unless explicitly asked to inspect workflow or test history.",
|
|
73
|
+
"- 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
|
+
"- 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
|
+
"",
|
|
77
|
+
"## Commands",
|
|
78
|
+
"",
|
|
79
|
+
"```",
|
|
80
|
+
"interf compile build this compiled workspace",
|
|
81
|
+
"interf test run saved truth checks against this workspace",
|
|
82
|
+
"interf verify summarize verify summary coverage",
|
|
83
|
+
"interf verify structure verify cross-file structure outputs",
|
|
84
|
+
"interf verify compile verify compile outputs",
|
|
85
|
+
"interf status show deterministic health",
|
|
86
|
+
"```",
|
|
87
|
+
"",
|
|
88
|
+
"## Rules",
|
|
89
|
+
"",
|
|
90
|
+
"- Do not modify files under `raw/`.",
|
|
91
|
+
"- Treat compiled notes as working retrieval artifacts, not final truth.",
|
|
92
|
+
"- When confidence is low, verify against `raw/` before answering strongly.",
|
|
93
|
+
"",
|
|
94
|
+
].join("\n");
|
|
95
|
+
}
|
|
96
|
+
export function renderWorkspaceQuerySkill() {
|
|
97
|
+
const chartNotes = CHART_APPROXIMATION_NOTES.map((note) => `- ${note.toLowerCase()}`);
|
|
98
|
+
return [
|
|
99
|
+
"# Manual Query Loop",
|
|
100
|
+
"",
|
|
101
|
+
"This file is the editable authoring source for the generated native local `interf-query` skill.",
|
|
102
|
+
"",
|
|
103
|
+
"Default loop:",
|
|
104
|
+
"1. Read `home.md` first.",
|
|
105
|
+
"2. Browse `knowledge/` before `raw/`.",
|
|
106
|
+
"3. Use `summaries/` for source-grounded evidence.",
|
|
107
|
+
"4. Use `raw/` for direct quotes, verification, exact table lookups, and cases where the compiled layer is missing or ambiguous.",
|
|
108
|
+
"",
|
|
109
|
+
"Answering rule:",
|
|
110
|
+
"- do not modify files under `raw/`",
|
|
111
|
+
"- when a number is chart-derived, say that explicitly",
|
|
112
|
+
"- if the compiled layer already contains a bounded chart-derived read for the exact metric and year, answer from that compiled read first",
|
|
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",
|
|
117
|
+
...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
|
+
"- when the compiled layer is insufficient, verify in `raw/` and then answer",
|
|
120
|
+
"",
|
|
121
|
+
"You can edit this file to bias manual question-answering behavior for this workspace.",
|
|
122
|
+
"",
|
|
123
|
+
].join("\n");
|
|
124
|
+
}
|
|
125
|
+
function renderRawTestAgents() {
|
|
126
|
+
const chartNotes = CHART_APPROXIMATION_NOTES.map((note) => `- ${note}`);
|
|
127
|
+
return [
|
|
128
|
+
"# Raw Test Shell",
|
|
129
|
+
"",
|
|
130
|
+
"This is an isolated raw-files test shell generated by Interf Compiler.",
|
|
131
|
+
"There is no compiled workspace in this shell.",
|
|
132
|
+
"",
|
|
133
|
+
"## How to use this shell",
|
|
134
|
+
"",
|
|
135
|
+
"1. Read this file first.",
|
|
136
|
+
"2. Use the local native `interf-query` skill available in this shell.",
|
|
137
|
+
"3. Read only from `raw/`.",
|
|
138
|
+
"",
|
|
139
|
+
"## Rules",
|
|
140
|
+
"",
|
|
141
|
+
"- Answer only from the files under `raw/`.",
|
|
142
|
+
"- There is no compiled workspace here, so do not assume `home.md`, `knowledge/`, or `summaries/` exist.",
|
|
143
|
+
"- Do not treat hidden runtime files or test artifacts as evidence.",
|
|
144
|
+
...chartNotes,
|
|
145
|
+
"- Write the requested answer and trace files, then stop.",
|
|
146
|
+
"",
|
|
147
|
+
].join("\n");
|
|
148
|
+
}
|
|
149
|
+
function renderRawTestQuerySkill() {
|
|
150
|
+
const chartNotes = CHART_APPROXIMATION_NOTES.map((note, index) => `${index + 3}. ${note}`);
|
|
151
|
+
return [
|
|
152
|
+
"---",
|
|
153
|
+
"name: interf-query",
|
|
154
|
+
"description: >",
|
|
155
|
+
" Native local query skill for an Interf raw test shell. Use it only",
|
|
156
|
+
" to answer baseline questions directly from `raw/`.",
|
|
157
|
+
"---",
|
|
158
|
+
"",
|
|
159
|
+
"# Interf Raw Test Query",
|
|
160
|
+
"",
|
|
161
|
+
"This is the native local query skill for an isolated raw-files test shell.",
|
|
162
|
+
"",
|
|
163
|
+
"Loop:",
|
|
164
|
+
"1. Read `raw/` directly.",
|
|
165
|
+
"2. Verify exact claims against the raw files before answering strongly.",
|
|
166
|
+
...chartNotes,
|
|
167
|
+
"8. Do not rely on compiled workspace artifacts because they do not exist in this shell.",
|
|
168
|
+
"",
|
|
169
|
+
].join("\n");
|
|
170
|
+
}
|
|
171
|
+
function readWorkspaceQuerySkillSource(workspacePath) {
|
|
172
|
+
const filePath = workspaceQuerySkillSourcePath(workspacePath);
|
|
173
|
+
if (!existsSync(filePath)) {
|
|
174
|
+
throw new Error(`Missing workspace query skill source at ${filePath}. Interf compile runs the workspace-local workflow package directly, so reseed or repair this workspace instead of auto-healing query docs.`);
|
|
175
|
+
}
|
|
176
|
+
return readFileSync(filePath, "utf8").trim();
|
|
14
177
|
}
|
|
15
178
|
function stageShellWorkflowRoot(shellRoot) {
|
|
16
179
|
return join(shellRoot, WORKFLOW_PACKAGE_DIR);
|
|
@@ -21,6 +184,19 @@ function shellInputZonePath(shellRoot, zoneId) {
|
|
|
21
184
|
function shellOutputZonePath(shellRoot, zoneId) {
|
|
22
185
|
return join(shellRoot, "outputs", zoneId);
|
|
23
186
|
}
|
|
187
|
+
function shellZoneAliasMountPath(shellRoot, zone, mountKind) {
|
|
188
|
+
const mountRoot = mountKind === "inputs"
|
|
189
|
+
? shellInputZonePath(shellRoot, zone.id)
|
|
190
|
+
: shellOutputZonePath(shellRoot, zone.id);
|
|
191
|
+
return zone.kind === "file"
|
|
192
|
+
? join(mountRoot, basename(zone.path))
|
|
193
|
+
: mountRoot;
|
|
194
|
+
}
|
|
195
|
+
function describeShellZoneAliasMountPath(zone, mountKind) {
|
|
196
|
+
return zone.kind === "file"
|
|
197
|
+
? `${mountKind}/${zone.id}/${basename(zone.path)}`
|
|
198
|
+
: `${mountKind}/${zone.id}`;
|
|
199
|
+
}
|
|
24
200
|
function shellRuntimePath(shellRoot, relativePath) {
|
|
25
201
|
return join(shellRoot, "runtime", relativePath);
|
|
26
202
|
}
|
|
@@ -44,10 +220,15 @@ function linkPath(targetPath, linkPathname) {
|
|
|
44
220
|
mkdirSync(dirname(linkPathname), { recursive: true });
|
|
45
221
|
symlinkSync(targetPath, linkPathname);
|
|
46
222
|
}
|
|
223
|
+
function linkRelativePath(targetPath, linkPathname) {
|
|
224
|
+
mkdirSync(dirname(linkPathname), { recursive: true });
|
|
225
|
+
symlinkSync(relative(dirname(linkPathname), targetPath), linkPathname);
|
|
226
|
+
}
|
|
47
227
|
function loadWorkspaceSchema(workspacePath) {
|
|
48
|
-
const
|
|
228
|
+
const workflowRoot = workflowPackagePathForWorkspace(workspacePath);
|
|
229
|
+
const schema = readWorkspaceSchemaFile(workflowRoot);
|
|
49
230
|
if (!schema) {
|
|
50
|
-
throw new Error(`Missing workflow workspace schema at ${join(
|
|
231
|
+
throw new Error(`Missing workflow workspace schema at ${join(workflowRoot, "workspace.schema.json")}`);
|
|
51
232
|
}
|
|
52
233
|
return schema;
|
|
53
234
|
}
|
|
@@ -62,26 +243,26 @@ function zoneOrThrow(zones, zoneId) {
|
|
|
62
243
|
return zone;
|
|
63
244
|
}
|
|
64
245
|
function ensureWorkspaceExecutionSurface(workspacePath) {
|
|
65
|
-
mkdirSync(
|
|
66
|
-
mkdirSync(
|
|
246
|
+
mkdirSync(workspaceRuntimeRoot(workspacePath), { recursive: true });
|
|
247
|
+
mkdirSync(workflowPackagePathForWorkspace(workspacePath), { recursive: true });
|
|
67
248
|
const schema = loadWorkspaceSchema(workspacePath);
|
|
68
249
|
ensureWorkspaceZoneTargets(workspacePath, schema);
|
|
69
250
|
return schema;
|
|
70
251
|
}
|
|
71
252
|
function readStageMethodDoc(workspacePath, stage) {
|
|
72
|
-
const path = join(workspacePath,
|
|
253
|
+
const path = join(workflowPackagePathForWorkspace(workspacePath), "compile", "stages", stage.skillDir, "SKILL.md");
|
|
73
254
|
if (!existsSync(path))
|
|
74
255
|
return null;
|
|
75
256
|
return readFileSync(path, "utf8").trim();
|
|
76
257
|
}
|
|
77
258
|
function stageWorkflowDocsPath(workspacePath, stage) {
|
|
78
|
-
return join(workspacePath,
|
|
259
|
+
return join(workflowPackagePathForWorkspace(workspacePath), "compile", "stages", stage.skillDir);
|
|
79
260
|
}
|
|
80
261
|
function renderStageExecutionAgents(workspaceName, workflowId, stage) {
|
|
81
262
|
return [
|
|
82
263
|
`# ${workspaceName} — ${stage.label} Execution Shell`,
|
|
83
264
|
"",
|
|
84
|
-
"This is an ephemeral
|
|
265
|
+
"This is an ephemeral stage-execution shell generated by Interf Compiler.",
|
|
85
266
|
"It is for automated pipeline execution only, not for manual querying.",
|
|
86
267
|
"",
|
|
87
268
|
"## Start Here",
|
|
@@ -95,7 +276,8 @@ function renderStageExecutionAgents(workspaceName, workflowId, stage) {
|
|
|
95
276
|
"",
|
|
96
277
|
"- `inputs/<zone-id>/` = read mounts for the current stage.",
|
|
97
278
|
"- `outputs/<zone-id>/` = write mounts for the current stage.",
|
|
98
|
-
"-
|
|
279
|
+
"- For file zones, `runtime/paths.json` points to the exact file path inside those mount roots.",
|
|
280
|
+
"- declared workspace zone paths are also projected at the shell root so workflow-relative contract paths stay valid.",
|
|
99
281
|
"- `runtime/` = stage contract and machine-readable path map for this shell.",
|
|
100
282
|
"- `workflow/` = workflow metadata, workspace schema, and docs for the current stage only.",
|
|
101
283
|
"",
|
|
@@ -127,13 +309,13 @@ function renderStageExecutionSkill(stage, stageMethodDoc) {
|
|
|
127
309
|
"---",
|
|
128
310
|
"name: interf-stage",
|
|
129
311
|
"description: >",
|
|
130
|
-
` Native local execution skill for the ${stage.label} stage in this
|
|
131
|
-
"
|
|
312
|
+
` Native local execution skill for the ${stage.label} stage in this`,
|
|
313
|
+
" Interf Compiler run. Use it only inside an automated stage execution shell.",
|
|
132
314
|
"---",
|
|
133
315
|
"",
|
|
134
|
-
`# Interf Stage Execution — ${stage.label}`,
|
|
316
|
+
`# Interf Compiler Stage Execution — ${stage.label}`,
|
|
135
317
|
"",
|
|
136
|
-
"This local native skill exists for automated Interf stage execution.",
|
|
318
|
+
"This local native skill exists for automated Interf Compiler stage execution.",
|
|
137
319
|
"Read `runtime/stage-contract.json` first.",
|
|
138
320
|
"Then read `runtime/paths.json` and use the mounted `inputs/` and `outputs/` zones for this stage.",
|
|
139
321
|
"Do not switch into manual query mode.",
|
|
@@ -157,50 +339,52 @@ function renderStageExecutionSkill(stage, stageMethodDoc) {
|
|
|
157
339
|
: []),
|
|
158
340
|
].join("\n");
|
|
159
341
|
}
|
|
160
|
-
function renderWorkspaceQueryNativeSkill() {
|
|
342
|
+
function renderWorkspaceQueryNativeSkill(querySkillContent) {
|
|
161
343
|
return [
|
|
162
344
|
"---",
|
|
163
345
|
"name: interf-query",
|
|
164
346
|
"description: >",
|
|
165
|
-
" Native local query skill for this
|
|
166
|
-
" manual questions against the compiled workspace and
|
|
347
|
+
" Native local query skill for this compiled workspace built by Interf",
|
|
348
|
+
" Compiler. Use it for manual questions against the compiled workspace and",
|
|
349
|
+
" its raw fallback.",
|
|
167
350
|
"---",
|
|
168
351
|
"",
|
|
169
|
-
"# Interf Query",
|
|
352
|
+
"# Interf Compiler Query",
|
|
170
353
|
"",
|
|
171
|
-
"This is the native local query skill for
|
|
354
|
+
"This is the native local query skill for a compiled workspace built by Interf Compiler.",
|
|
172
355
|
"Use it when reading this workspace manually.",
|
|
173
|
-
"Editable source:
|
|
356
|
+
"Editable source: `.interf/workflow/use/query/SKILL.md`.",
|
|
174
357
|
"",
|
|
175
|
-
|
|
358
|
+
querySkillContent.trim(),
|
|
176
359
|
"",
|
|
177
360
|
].join("\n");
|
|
178
361
|
}
|
|
179
|
-
function syncWorkspaceNativeQuerySkillCopies(workspacePath) {
|
|
180
|
-
return writeNativeSkillCopies(workspacePath, "interf-query", renderWorkspaceQueryNativeSkill());
|
|
181
|
-
}
|
|
182
362
|
function projectWorkflowMetadata(workspacePath, shellRoot, stage) {
|
|
183
|
-
const
|
|
184
|
-
mkdirSync(join(
|
|
185
|
-
const
|
|
363
|
+
const shellWorkflowRoot = stageShellWorkflowRoot(shellRoot);
|
|
364
|
+
mkdirSync(join(shellWorkflowRoot, "compile", "stages"), { recursive: true });
|
|
365
|
+
const workspaceWorkflowRoot = workflowPackagePathForWorkspace(workspacePath);
|
|
366
|
+
const workflowJsonPath = join(workspaceWorkflowRoot, "workflow.json");
|
|
186
367
|
if (existsSync(workflowJsonPath)) {
|
|
187
|
-
linkPath(workflowJsonPath, join(
|
|
368
|
+
linkPath(workflowJsonPath, join(shellWorkflowRoot, "workflow.json"));
|
|
188
369
|
}
|
|
189
|
-
const workspaceSchemaPath = join(
|
|
370
|
+
const workspaceSchemaPath = join(workspaceWorkflowRoot, "workspace.schema.json");
|
|
190
371
|
if (existsSync(workspaceSchemaPath)) {
|
|
191
|
-
linkPath(workspaceSchemaPath, join(
|
|
372
|
+
linkPath(workspaceSchemaPath, join(shellWorkflowRoot, "workspace.schema.json"));
|
|
192
373
|
}
|
|
193
|
-
const readmePath = join(
|
|
374
|
+
const readmePath = join(workspaceWorkflowRoot, "README.md");
|
|
194
375
|
if (existsSync(readmePath)) {
|
|
195
|
-
linkPath(readmePath, join(
|
|
376
|
+
linkPath(readmePath, join(shellWorkflowRoot, "README.md"));
|
|
196
377
|
}
|
|
197
378
|
const stageDocsPath = stageWorkflowDocsPath(workspacePath, stage);
|
|
198
379
|
if (existsSync(stageDocsPath)) {
|
|
199
|
-
linkPath(stageDocsPath, join(
|
|
380
|
+
linkPath(stageDocsPath, join(shellWorkflowRoot, "compile", "stages", stage.skillDir));
|
|
200
381
|
}
|
|
201
382
|
}
|
|
202
|
-
function projectWorkspaceSchemaZones(workspacePath, shellRoot, schema) {
|
|
383
|
+
function projectWorkspaceSchemaZones(workspacePath, shellRoot, schema, zoneIds) {
|
|
384
|
+
const allowedZoneIds = zoneIds ? new Set(zoneIds) : null;
|
|
203
385
|
for (const zone of schema.zones) {
|
|
386
|
+
if (allowedZoneIds && !allowedZoneIds.has(zone.id))
|
|
387
|
+
continue;
|
|
204
388
|
linkPath(workspaceZoneAbsolutePath(workspacePath, zone), join(shellRoot, zone.path));
|
|
205
389
|
}
|
|
206
390
|
}
|
|
@@ -212,8 +396,12 @@ function buildStageZoneMounts(workspacePath, shellRoot, stage, schema) {
|
|
|
212
396
|
zone_id: zone.id,
|
|
213
397
|
workspace_path: zone.path,
|
|
214
398
|
shell_root_path: zone.path,
|
|
215
|
-
input_mount_path: stage.reads.includes(zoneId)
|
|
216
|
-
|
|
399
|
+
input_mount_path: stage.reads.includes(zoneId)
|
|
400
|
+
? describeShellZoneAliasMountPath(zone, "inputs")
|
|
401
|
+
: null,
|
|
402
|
+
output_mount_path: stage.writes.includes(zoneId)
|
|
403
|
+
? describeShellZoneAliasMountPath(zone, "outputs")
|
|
404
|
+
: null,
|
|
217
405
|
};
|
|
218
406
|
};
|
|
219
407
|
return {
|
|
@@ -227,10 +415,10 @@ function projectStageZoneMountAliases(workspacePath, shellRoot, stage, schema) {
|
|
|
227
415
|
const zone = zoneOrThrow(zones, zoneId);
|
|
228
416
|
const targetPath = workspaceZoneAbsolutePath(workspacePath, zone);
|
|
229
417
|
if (stage.reads.includes(zoneId)) {
|
|
230
|
-
linkPath(targetPath,
|
|
418
|
+
linkPath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "inputs"));
|
|
231
419
|
}
|
|
232
420
|
if (stage.writes.includes(zoneId)) {
|
|
233
|
-
linkPath(targetPath,
|
|
421
|
+
linkPath(targetPath, shellZoneAliasMountPath(shellRoot, zone, "outputs"));
|
|
234
422
|
}
|
|
235
423
|
}
|
|
236
424
|
}
|
|
@@ -245,50 +433,326 @@ function writeExecutionShellPathsFile(shellRoot, workflowId, stage, mounts) {
|
|
|
245
433
|
};
|
|
246
434
|
writeFileSync(shellRuntimePath(shellRoot, "paths.json"), `${JSON.stringify(paths, null, 2)}\n`);
|
|
247
435
|
}
|
|
436
|
+
export function syncStageExecutionShellWrites(workspacePath, shellRoot, stage) {
|
|
437
|
+
const schema = ensureWorkspaceExecutionSurface(workspacePath);
|
|
438
|
+
const zones = zoneMap(schema);
|
|
439
|
+
for (const zoneId of new Set(stage.writes)) {
|
|
440
|
+
const zone = zoneOrThrow(zones, zoneId);
|
|
441
|
+
const shellZonePath = join(shellRoot, zone.path);
|
|
442
|
+
if (!existsSync(shellZonePath))
|
|
443
|
+
continue;
|
|
444
|
+
const shellZoneStat = lstatSync(shellZonePath);
|
|
445
|
+
if (shellZoneStat.isSymbolicLink())
|
|
446
|
+
continue;
|
|
447
|
+
const workspaceZonePath = workspaceZoneAbsolutePath(workspacePath, zone);
|
|
448
|
+
if (shellZoneStat.isDirectory()) {
|
|
449
|
+
rmSync(workspaceZonePath, { recursive: true, force: true });
|
|
450
|
+
mkdirSync(dirname(workspaceZonePath), { recursive: true });
|
|
451
|
+
cpSync(shellZonePath, workspaceZonePath, {
|
|
452
|
+
recursive: true,
|
|
453
|
+
force: true,
|
|
454
|
+
});
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
mkdirSync(dirname(workspaceZonePath), { recursive: true });
|
|
458
|
+
copyFileSync(shellZonePath, workspaceZonePath);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function preservedShellManifestPath(rootPath) {
|
|
462
|
+
return shellRuntimePath(rootPath, "preserved-shell.json");
|
|
463
|
+
}
|
|
464
|
+
function shouldSkipFrozenStageShellRelativePath(relativePath) {
|
|
465
|
+
const normalized = relativePath.replaceAll("\\", "/");
|
|
466
|
+
return normalized === "execution-shells" ||
|
|
467
|
+
normalized.endsWith("/execution-shells") ||
|
|
468
|
+
normalized.includes("/execution-shells/") ||
|
|
469
|
+
normalized === "improvement-loops" ||
|
|
470
|
+
normalized.endsWith("/improvement-loops") ||
|
|
471
|
+
normalized.includes("/improvement-loops/");
|
|
472
|
+
}
|
|
473
|
+
function copyResolvedTree(options) {
|
|
474
|
+
const relativePath = options.relativePath ?? "";
|
|
475
|
+
if (options.shellType === "stage-execution" && shouldSkipFrozenStageShellRelativePath(relativePath)) {
|
|
476
|
+
return { materializedSymlinks: 0 };
|
|
477
|
+
}
|
|
478
|
+
const stat = lstatSync(options.sourcePath);
|
|
479
|
+
if (stat.isSymbolicLink()) {
|
|
480
|
+
const realTarget = realpathSync(options.sourcePath);
|
|
481
|
+
const realStat = statSync(realTarget);
|
|
482
|
+
if (realStat.isDirectory()) {
|
|
483
|
+
const mappedTarget = options.materializedRealPaths?.get(realTarget);
|
|
484
|
+
if (mappedTarget) {
|
|
485
|
+
linkRelativePath(mappedTarget, options.targetPath);
|
|
486
|
+
return { materializedSymlinks: 1 };
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
materializedSymlinks: 1 + copyResolvedTree({
|
|
490
|
+
sourcePath: realTarget,
|
|
491
|
+
targetPath: options.targetPath,
|
|
492
|
+
shellType: options.shellType,
|
|
493
|
+
relativePath,
|
|
494
|
+
activeRealPaths: options.activeRealPaths,
|
|
495
|
+
materializedRealPaths: options.materializedRealPaths,
|
|
496
|
+
}).materializedSymlinks,
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
mkdirSync(dirname(options.targetPath), { recursive: true });
|
|
500
|
+
copyFileSync(realTarget, options.targetPath);
|
|
501
|
+
return { materializedSymlinks: 1 };
|
|
502
|
+
}
|
|
503
|
+
if (stat.isDirectory()) {
|
|
504
|
+
const realSource = realpathSync(options.sourcePath);
|
|
505
|
+
const mappedTarget = options.materializedRealPaths?.get(realSource);
|
|
506
|
+
if (mappedTarget && mappedTarget !== options.targetPath) {
|
|
507
|
+
linkRelativePath(mappedTarget, options.targetPath);
|
|
508
|
+
return { materializedSymlinks: 0 };
|
|
509
|
+
}
|
|
510
|
+
const nextRealPaths = new Set([...(options.activeRealPaths ?? []), realSource]);
|
|
511
|
+
const nextMaterializedRealPaths = new Map(options.materializedRealPaths ?? []);
|
|
512
|
+
nextMaterializedRealPaths.set(realSource, options.targetPath);
|
|
513
|
+
mkdirSync(options.targetPath, { recursive: true });
|
|
514
|
+
let materializedSymlinks = 0;
|
|
515
|
+
for (const entry of readdirSync(options.sourcePath)) {
|
|
516
|
+
const childRelativePath = relativePath.length > 0 ? `${relativePath}/${entry}` : entry;
|
|
517
|
+
const copied = copyResolvedTree({
|
|
518
|
+
sourcePath: join(options.sourcePath, entry),
|
|
519
|
+
targetPath: join(options.targetPath, entry),
|
|
520
|
+
shellType: options.shellType,
|
|
521
|
+
relativePath: childRelativePath,
|
|
522
|
+
activeRealPaths: nextRealPaths,
|
|
523
|
+
materializedRealPaths: nextMaterializedRealPaths,
|
|
524
|
+
});
|
|
525
|
+
materializedSymlinks += copied.materializedSymlinks;
|
|
526
|
+
}
|
|
527
|
+
return { materializedSymlinks };
|
|
528
|
+
}
|
|
529
|
+
mkdirSync(dirname(options.targetPath), { recursive: true });
|
|
530
|
+
copyFileSync(options.sourcePath, options.targetPath);
|
|
531
|
+
return { materializedSymlinks: 0 };
|
|
532
|
+
}
|
|
533
|
+
function freezePreservedShell(rootPath, shellType) {
|
|
534
|
+
if (!existsSync(rootPath))
|
|
535
|
+
return null;
|
|
536
|
+
const manifestPath = preservedShellManifestPath(rootPath);
|
|
537
|
+
if (existsSync(manifestPath))
|
|
538
|
+
return manifestPath;
|
|
539
|
+
const tempRoot = `${rootPath}.frozen-${Date.now().toString(36)}`;
|
|
540
|
+
const copied = copyResolvedTree({
|
|
541
|
+
sourcePath: rootPath,
|
|
542
|
+
targetPath: tempRoot,
|
|
543
|
+
shellType,
|
|
544
|
+
});
|
|
545
|
+
const manifest = {
|
|
546
|
+
kind: "interf-preserved-shell",
|
|
547
|
+
version: 1,
|
|
548
|
+
shell_type: shellType,
|
|
549
|
+
generated_at: new Date().toISOString(),
|
|
550
|
+
root_path: rootPath,
|
|
551
|
+
materialized_symlinks: copied.materializedSymlinks,
|
|
552
|
+
};
|
|
553
|
+
writeFileSync(preservedShellManifestPath(tempRoot), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
554
|
+
rmSync(rootPath, { recursive: true, force: true });
|
|
555
|
+
renameSync(tempRoot, rootPath);
|
|
556
|
+
return manifestPath;
|
|
557
|
+
}
|
|
248
558
|
export function renderClaudeBootstrap(content) {
|
|
249
559
|
return [
|
|
250
|
-
"<!-- Generated
|
|
560
|
+
"<!-- Generated compatibility mirror of AGENTS.md. Interf Compiler may rewrite this file. -->",
|
|
251
561
|
"",
|
|
252
562
|
content.trimEnd(),
|
|
253
563
|
"",
|
|
254
564
|
].join("\n");
|
|
255
565
|
}
|
|
566
|
+
function improvementWorkflowDocsPath(workspacePath) {
|
|
567
|
+
return join(workflowPackagePathForWorkspace(workspacePath), "improve");
|
|
568
|
+
}
|
|
569
|
+
function renderWorkflowImprovementAgents(workspaceName, workflowId, loopIndex) {
|
|
570
|
+
return [
|
|
571
|
+
`# ${workspaceName} — Workflow Improvement Shell`,
|
|
572
|
+
"",
|
|
573
|
+
"This is an automated workflow-improvement shell generated by Interf Compiler.",
|
|
574
|
+
"It exists to review failed compile/test runs and edit the workflow package for the next variation.",
|
|
575
|
+
"",
|
|
576
|
+
"## Start Here",
|
|
577
|
+
"",
|
|
578
|
+
"1. Read `runtime/loop-context.json` now.",
|
|
579
|
+
"2. Read `workflow/README.md`, `workflow/workflow.json`, and `workflow/workspace.schema.json` now.",
|
|
580
|
+
"3. Read `workflow/improve/SKILL.md` now.",
|
|
581
|
+
"4. Use the local native `interf-workflow-improver` skill now.",
|
|
582
|
+
"",
|
|
583
|
+
"## Boundaries",
|
|
584
|
+
"",
|
|
585
|
+
`- Workflow: \`${workflowId}\`.`,
|
|
586
|
+
`- Improvement loop: ${loopIndex}.`,
|
|
587
|
+
"- Edit only files under `workflow/`.",
|
|
588
|
+
"- Do not edit truth checks, test specs, raw dataset files, or generated workspace outputs.",
|
|
589
|
+
"- Review compiled outputs under `artifacts/workspace-view/` and test/runtime evidence under `artifacts/`.",
|
|
590
|
+
"- Keep the workflow valid for the current compiler API and workspace schema.",
|
|
591
|
+
"",
|
|
592
|
+
"## Goal",
|
|
593
|
+
"",
|
|
594
|
+
"- create a better workflow variation for this dataset",
|
|
595
|
+
"- preserve deterministic workspace structure",
|
|
596
|
+
"- stop after the workflow edits are complete",
|
|
597
|
+
"",
|
|
598
|
+
].join("\n");
|
|
599
|
+
}
|
|
600
|
+
function readWorkflowImprovementDoc(workspacePath) {
|
|
601
|
+
const path = join(improvementWorkflowDocsPath(workspacePath), "SKILL.md");
|
|
602
|
+
if (!existsSync(path))
|
|
603
|
+
return null;
|
|
604
|
+
return readFileSync(path, "utf8").trim();
|
|
605
|
+
}
|
|
606
|
+
function renderWorkflowImprovementSkill(workflowId, loopIndex, improvementDoc) {
|
|
607
|
+
return [
|
|
608
|
+
"---",
|
|
609
|
+
"name: interf-workflow-improver",
|
|
610
|
+
"description: >",
|
|
611
|
+
" Native local workflow-improvement skill for this Interf Compiler run.",
|
|
612
|
+
" Use it only inside an automated workflow-improvement shell.",
|
|
613
|
+
"---",
|
|
614
|
+
"",
|
|
615
|
+
`# Interf Compiler Workflow Improvement — ${workflowId}`,
|
|
616
|
+
"",
|
|
617
|
+
"This local native skill exists for automated workflow-improvement loops.",
|
|
618
|
+
"Read `runtime/loop-context.json` first.",
|
|
619
|
+
"Then review the linked workflow package, `artifacts/workspace-view/`, preserved stage shells, runtime logs, and saved test outputs before editing `workflow/`.",
|
|
620
|
+
"",
|
|
621
|
+
"## Current Loop",
|
|
622
|
+
"",
|
|
623
|
+
`- workflow: \`${workflowId}\``,
|
|
624
|
+
`- loop index: ${loopIndex}`,
|
|
625
|
+
"- editable source: `workflow/improve/SKILL.md`",
|
|
626
|
+
"",
|
|
627
|
+
...(improvementDoc
|
|
628
|
+
? [
|
|
629
|
+
"## Improvement Method",
|
|
630
|
+
"",
|
|
631
|
+
improvementDoc,
|
|
632
|
+
"",
|
|
633
|
+
]
|
|
634
|
+
: []),
|
|
635
|
+
].join("\n");
|
|
636
|
+
}
|
|
637
|
+
function projectWorkspaceReviewArtifactsSnapshot(workspacePath, shellRoot, schema) {
|
|
638
|
+
const workspaceViewRoot = join(shellRoot, "artifacts", "workspace-view");
|
|
639
|
+
mkdirSync(workspaceViewRoot, { recursive: true });
|
|
640
|
+
for (const zone of schema.zones) {
|
|
641
|
+
if (zone.kind === "runtime" || zone.path === "raw")
|
|
642
|
+
continue;
|
|
643
|
+
const sourcePath = workspaceZoneAbsolutePath(workspacePath, zone);
|
|
644
|
+
if (!existsSync(sourcePath))
|
|
645
|
+
continue;
|
|
646
|
+
copyResolvedTree({
|
|
647
|
+
sourcePath,
|
|
648
|
+
targetPath: join(workspaceViewRoot, zone.path),
|
|
649
|
+
shellType: "workflow-improvement",
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function linkIfExists(targetPath, linkPathname) {
|
|
654
|
+
if (!existsSync(targetPath))
|
|
655
|
+
return;
|
|
656
|
+
linkPath(targetPath, linkPathname);
|
|
657
|
+
}
|
|
658
|
+
function copyIfExists(sourcePath, targetPath, shellType) {
|
|
659
|
+
if (!existsSync(sourcePath))
|
|
660
|
+
return;
|
|
661
|
+
copyResolvedTree({
|
|
662
|
+
sourcePath,
|
|
663
|
+
targetPath,
|
|
664
|
+
shellType,
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function projectWorkspaceRuntimeArtifacts(workspacePath, shellRoot) {
|
|
668
|
+
const runtimeTarget = join(shellRoot, "artifacts", "workspace-runtime");
|
|
669
|
+
mkdirSync(runtimeTarget, { recursive: true });
|
|
670
|
+
const runtimeRoot = workspaceRuntimeRoot(workspacePath);
|
|
671
|
+
const artifactNames = [
|
|
672
|
+
"run.json",
|
|
673
|
+
"run-history.jsonl",
|
|
674
|
+
"state.json",
|
|
675
|
+
"health.json",
|
|
676
|
+
"view-spec.json",
|
|
677
|
+
"raw-snapshot.json",
|
|
678
|
+
"logs",
|
|
679
|
+
];
|
|
680
|
+
for (const artifactName of artifactNames) {
|
|
681
|
+
copyIfExists(join(runtimeRoot, artifactName), join(runtimeTarget, artifactName), "workflow-improvement");
|
|
682
|
+
}
|
|
683
|
+
}
|
|
256
684
|
export function pruneStageExecutionShells(workspacePath) {
|
|
257
|
-
rmSync(
|
|
685
|
+
rmSync(stageExecutionShellsRoot(workspacePath), { recursive: true, force: true });
|
|
258
686
|
}
|
|
259
|
-
export function projectWorkspaceQueryShell(workspacePath, workspaceName, workflowId, about) {
|
|
260
|
-
const agentsContent = renderWorkspaceAgents(workspaceName, workflowId, about);
|
|
261
|
-
const querySkillContent =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const querySkillPath = join(workspacePath, WORKFLOW_PACKAGE_DIR, "use", "query", "SKILL.md");
|
|
267
|
-
mkdirSync(dirname(querySkillPath), { recursive: true });
|
|
268
|
-
changed = writeIfChanged(querySkillPath, querySkillContent) || changed;
|
|
269
|
-
changed = syncWorkspaceNativeQuerySkillCopies(workspacePath) || changed;
|
|
270
|
-
return changed;
|
|
687
|
+
export function projectWorkspaceQueryShell(workspacePath, workspaceName, workflowId, about, options) {
|
|
688
|
+
const agentsContent = renderWorkspaceAgents(workspaceName, workflowId, about, options);
|
|
689
|
+
const querySkillContent = readWorkspaceQuerySkillSource(workspacePath);
|
|
690
|
+
return writeNativeAgentSurface(workspacePath, agentsContent, "interf-query", renderWorkspaceQueryNativeSkill(querySkillContent));
|
|
691
|
+
}
|
|
692
|
+
export function projectRawTestQueryShell(rootPath) {
|
|
693
|
+
return writeNativeAgentSurface(rootPath, renderRawTestAgents(), "interf-query", renderRawTestQuerySkill());
|
|
271
694
|
}
|
|
272
695
|
export function createStageExecutionShell(workspacePath, workspaceName, workflowId, stage) {
|
|
273
696
|
const schema = ensureWorkspaceExecutionSurface(workspacePath);
|
|
274
|
-
const shellsRoot =
|
|
697
|
+
const shellsRoot = stageExecutionShellsRoot(workspacePath);
|
|
275
698
|
const shellRoot = join(shellsRoot, `${stage.id}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`);
|
|
276
699
|
mkdirSync(shellRoot, { recursive: true });
|
|
277
700
|
mkdirSync(join(shellRoot, "runtime"), { recursive: true });
|
|
278
701
|
mkdirSync(join(shellRoot, "inputs"), { recursive: true });
|
|
279
702
|
mkdirSync(join(shellRoot, "outputs"), { recursive: true });
|
|
280
|
-
linkPath(
|
|
281
|
-
linkPath(join(workspacePath, "
|
|
282
|
-
projectWorkspaceSchemaZones(workspacePath, shellRoot, schema);
|
|
703
|
+
linkPath(workspaceInterfConfigPath(workspacePath), join(shellRoot, "interf.json"));
|
|
704
|
+
linkPath(join(workspaceRuntimeRoot(workspacePath), "stage-contract.json"), shellRuntimePath(shellRoot, "stage-contract.json"));
|
|
705
|
+
projectWorkspaceSchemaZones(workspacePath, shellRoot, schema, new Set([...stage.reads, ...stage.writes]));
|
|
283
706
|
projectWorkflowMetadata(workspacePath, shellRoot, stage);
|
|
284
707
|
projectStageZoneMountAliases(workspacePath, shellRoot, stage, schema);
|
|
285
708
|
writeExecutionShellPathsFile(shellRoot, workflowId, stage, buildStageZoneMounts(workspacePath, shellRoot, stage, schema));
|
|
286
709
|
const agentsContent = renderStageExecutionAgents(workspaceName, workflowId, stage);
|
|
287
|
-
|
|
288
|
-
writeFileSync(join(shellRoot, "CLAUDE.md"), renderClaudeBootstrap(agentsContent));
|
|
289
|
-
writeNativeSkillCopies(shellRoot, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(workspacePath, stage)));
|
|
710
|
+
writeNativeAgentSurface(shellRoot, agentsContent, "interf-stage", renderStageExecutionSkill(stage, readStageMethodDoc(workspacePath, stage)));
|
|
290
711
|
return {
|
|
291
712
|
rootPath: shellRoot,
|
|
292
713
|
};
|
|
293
714
|
}
|
|
294
|
-
|
|
715
|
+
export function freezeStageExecutionShell(rootPath) {
|
|
716
|
+
return freezePreservedShell(rootPath, "stage-execution");
|
|
717
|
+
}
|
|
718
|
+
export function createWorkflowImprovementShell(options) {
|
|
719
|
+
const schema = ensureWorkspaceExecutionSurface(options.workspacePath);
|
|
720
|
+
const loopRootPath = workflowImprovementLoopRoot(options.workspacePath, options.runId, options.loopIndex);
|
|
721
|
+
const shellRoot = join(loopRootPath, "shell");
|
|
722
|
+
mkdirSync(shellRoot, { recursive: true });
|
|
723
|
+
mkdirSync(join(shellRoot, "runtime"), { recursive: true });
|
|
724
|
+
mkdirSync(join(shellRoot, "artifacts"), { recursive: true });
|
|
725
|
+
mkdirSync(join(loopRootPath, "logs"), { recursive: true });
|
|
726
|
+
writeFileSync(join(shellRoot, "runtime", "loop-context.json"), `${JSON.stringify(options.context, null, 2)}\n`);
|
|
727
|
+
projectWorkspaceReviewArtifactsSnapshot(options.workspacePath, shellRoot, schema);
|
|
728
|
+
linkPath(workflowPackagePathForWorkspace(options.workspacePath), join(shellRoot, "workflow"));
|
|
729
|
+
copyIfExists(workspaceInterfConfigPath(options.workspacePath), join(shellRoot, "interf.json"), "workflow-improvement");
|
|
730
|
+
projectWorkspaceRuntimeArtifacts(options.workspacePath, shellRoot);
|
|
731
|
+
const reviewSources = resolveWorkflowImprovementReviewSourcePaths(options.workspacePath);
|
|
732
|
+
if (reviewSources.executionShells) {
|
|
733
|
+
copyIfExists(reviewSources.executionShells, join(shellRoot, "artifacts", "execution-shells"), "workflow-improvement");
|
|
734
|
+
}
|
|
735
|
+
if (reviewSources.testComparisons) {
|
|
736
|
+
copyIfExists(reviewSources.testComparisons, join(shellRoot, "artifacts", "test-comparisons"), "workflow-improvement");
|
|
737
|
+
}
|
|
738
|
+
if (reviewSources.targetTestRuns) {
|
|
739
|
+
copyIfExists(reviewSources.targetTestRuns, join(shellRoot, "artifacts", "test-runs"), "workflow-improvement");
|
|
740
|
+
}
|
|
741
|
+
if (reviewSources.targetTestSandboxes) {
|
|
742
|
+
copyIfExists(reviewSources.targetTestSandboxes, join(shellRoot, "artifacts", "test-sandboxes"), "workflow-improvement");
|
|
743
|
+
}
|
|
744
|
+
const agentsContent = renderWorkflowImprovementAgents(options.workspaceName, options.workflowId, options.loopIndex);
|
|
745
|
+
writeNativeAgentSurface(shellRoot, agentsContent, "interf-workflow-improver", renderWorkflowImprovementSkill(options.workflowId, options.loopIndex, readWorkflowImprovementDoc(options.workspacePath)));
|
|
746
|
+
return {
|
|
747
|
+
rootPath: shellRoot,
|
|
748
|
+
loopRootPath,
|
|
749
|
+
workflowBeforePath: join(loopRootPath, "workflow-before"),
|
|
750
|
+
workflowAfterPath: join(loopRootPath, "workflow-after"),
|
|
751
|
+
promptLogPath: join(loopRootPath, "logs", "workflow-improver.prompt.txt"),
|
|
752
|
+
eventLogPath: join(loopRootPath, "logs", "workflow-improver.events.ndjson"),
|
|
753
|
+
statusLogPath: join(loopRootPath, "logs", "workflow-improver.status.log"),
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
export function freezeWorkflowImprovementShell(rootPath) {
|
|
757
|
+
return freezePreservedShell(rootPath, "workflow-improvement");
|
|
758
|
+
}
|