@interf/compiler 0.6.3 → 0.6.5

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.
Files changed (115) hide show
  1. package/README.md +92 -94
  2. package/dist/cli/commands/check-draft.js +4 -4
  3. package/dist/cli/commands/compile-controller.js +23 -23
  4. package/dist/cli/commands/compile.js +2 -2
  5. package/dist/cli/commands/compiled-flow.js +4 -4
  6. package/dist/cli/commands/create-workflow-wizard.js +8 -8
  7. package/dist/cli/commands/create.js +5 -5
  8. package/dist/cli/commands/default.js +1 -1
  9. package/dist/cli/commands/init.js +44 -44
  10. package/dist/cli/commands/list.js +2 -2
  11. package/dist/cli/commands/reset.js +1 -1
  12. package/dist/cli/commands/source-config-wizard.d.ts +1 -1
  13. package/dist/cli/commands/source-config-wizard.js +40 -40
  14. package/dist/cli/commands/status.js +5 -5
  15. package/dist/cli/commands/test-flow.js +26 -26
  16. package/dist/cli/commands/test.js +12 -12
  17. package/dist/lib/chart-guidance.d.ts +1 -1
  18. package/dist/lib/chart-guidance.js +1 -8
  19. package/dist/lib/discovery.d.ts +1 -7
  20. package/dist/lib/discovery.js +1 -84
  21. package/dist/lib/filesystem.d.ts +1 -2
  22. package/dist/lib/filesystem.js +1 -55
  23. package/dist/lib/logger.d.ts +1 -3
  24. package/dist/lib/logger.js +1 -10
  25. package/dist/lib/parse.d.ts +1 -8
  26. package/dist/lib/parse.js +1 -145
  27. package/dist/lib/util.d.ts +1 -4
  28. package/dist/lib/util.js +1 -25
  29. package/dist/packages/agents/index.d.ts +1 -0
  30. package/dist/packages/agents/index.js +1 -0
  31. package/dist/packages/agents/lib/chart-guidance.d.ts +1 -0
  32. package/dist/packages/agents/lib/chart-guidance.js +8 -0
  33. package/dist/packages/agents/lib/compiled-bootstrap.d.ts +3 -0
  34. package/dist/packages/agents/lib/compiled-bootstrap.js +18 -0
  35. package/dist/packages/agents/lib/executors.d.ts +2 -2
  36. package/dist/packages/agents/lib/shells.d.ts +3 -1
  37. package/dist/packages/agents/lib/shells.js +22 -20
  38. package/dist/packages/agents/lib/user-config.js +1 -1
  39. package/dist/packages/compiler/compiled-compile.d.ts +4 -48
  40. package/dist/packages/compiler/compiled-compile.js +4 -256
  41. package/dist/packages/compiler/compiled-paths.d.ts +40 -0
  42. package/dist/packages/compiler/compiled-paths.js +106 -0
  43. package/dist/packages/compiler/compiled-pipeline.d.ts +39 -0
  44. package/dist/packages/compiler/compiled-pipeline.js +134 -0
  45. package/dist/packages/compiler/compiled-schema.js +2 -2
  46. package/dist/packages/compiler/compiled-stage-plan.d.ts +15 -0
  47. package/dist/packages/compiler/compiled-stage-plan.js +79 -0
  48. package/dist/packages/compiler/compiled-stage-runner.d.ts +10 -0
  49. package/dist/packages/compiler/compiled-stage-runner.js +46 -0
  50. package/dist/packages/compiler/compiled-target.d.ts +11 -0
  51. package/dist/packages/compiler/compiled-target.js +16 -0
  52. package/dist/packages/compiler/discovery.d.ts +7 -0
  53. package/dist/packages/compiler/discovery.js +80 -0
  54. package/dist/packages/compiler/lib/schema.js +2 -0
  55. package/dist/packages/compiler/raw-snapshot.d.ts +49 -0
  56. package/dist/packages/compiler/raw-snapshot.js +102 -0
  57. package/dist/packages/compiler/reset.d.ts +2 -0
  58. package/dist/packages/compiler/reset.js +72 -0
  59. package/dist/packages/compiler/runtime-acceptance.js +3 -3
  60. package/dist/packages/compiler/runtime-contracts.js +1 -1
  61. package/dist/packages/compiler/runtime-paths.js +1 -1
  62. package/dist/packages/compiler/runtime-reconcile.js +3 -3
  63. package/dist/packages/compiler/runtime-runs.js +2 -2
  64. package/dist/packages/compiler/state-health.js +3 -3
  65. package/dist/packages/compiler/state-io.js +3 -3
  66. package/dist/packages/compiler/state-paths.js +1 -1
  67. package/dist/packages/compiler/state-view.js +2 -2
  68. package/dist/packages/compiler/validate-compiled.js +3 -3
  69. package/dist/packages/compiler/validate.js +4 -4
  70. package/dist/packages/project-model/compiled-paths.d.ts +1 -40
  71. package/dist/packages/project-model/compiled-paths.js +1 -106
  72. package/dist/packages/project-model/compiled-raw.d.ts +1 -49
  73. package/dist/packages/project-model/compiled-raw.js +1 -102
  74. package/dist/packages/project-model/compiled-reset.d.ts +1 -2
  75. package/dist/packages/project-model/compiled-reset.js +1 -72
  76. package/dist/packages/project-model/interf-bootstrap.d.ts +1 -3
  77. package/dist/packages/project-model/interf-bootstrap.js +1 -18
  78. package/dist/packages/project-model/interf-detect.js +4 -4
  79. package/dist/packages/project-model/interf-scaffold.js +7 -7
  80. package/dist/packages/project-model/source-config.js +6 -5
  81. package/dist/packages/shared/file-types.d.ts +1 -0
  82. package/dist/packages/shared/file-types.js +4 -0
  83. package/dist/packages/shared/filesystem.d.ts +2 -0
  84. package/dist/packages/shared/filesystem.js +55 -0
  85. package/dist/packages/shared/index.d.ts +7 -0
  86. package/dist/packages/shared/index.js +7 -0
  87. package/dist/packages/shared/logger.d.ts +3 -0
  88. package/dist/packages/shared/logger.js +10 -0
  89. package/dist/packages/shared/naming.d.ts +1 -0
  90. package/dist/packages/shared/naming.js +8 -0
  91. package/dist/packages/shared/parse.d.ts +8 -0
  92. package/dist/packages/shared/parse.js +145 -0
  93. package/dist/packages/shared/path-guards.d.ts +2 -0
  94. package/dist/packages/shared/path-guards.js +14 -0
  95. package/dist/packages/shared/util.d.ts +3 -0
  96. package/dist/packages/shared/util.js +3 -0
  97. package/dist/packages/testing/test-execution.js +3 -3
  98. package/dist/packages/testing/test-paths.js +1 -1
  99. package/dist/packages/testing/test-sandbox.js +3 -3
  100. package/dist/packages/testing/test-specs.js +1 -1
  101. package/dist/packages/workflow-authoring/workflow-authoring.js +5 -4
  102. package/dist/packages/workflow-authoring/workflow-improvement.js +6 -5
  103. package/dist/packages/workflow-package/builtin-compiled-workflow.js +1 -1
  104. package/dist/packages/workflow-package/context-interface.d.ts +96 -0
  105. package/dist/packages/workflow-package/context-interface.js +146 -0
  106. package/dist/packages/workflow-package/index.d.ts +2 -0
  107. package/dist/packages/workflow-package/index.js +2 -0
  108. package/dist/packages/workflow-package/interf-workflow-package.js +75 -28
  109. package/dist/packages/workflow-package/local-workflows.d.ts +5 -2
  110. package/dist/packages/workflow-package/local-workflows.js +15 -13
  111. package/dist/packages/workflow-package/workflow-definitions.d.ts +11 -7
  112. package/dist/packages/workflow-package/workflow-definitions.js +10 -3
  113. package/dist/packages/workflow-package/workflow-helpers.js +4 -4
  114. package/dist/packages/workflow-package/workflow-review-paths.js +1 -1
  115. package/package.json +3 -2
@@ -0,0 +1,72 @@
1
+ import { existsSync, readdirSync, rmSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { readCompiledSchemaFile } from "./compiled-schema.js";
4
+ import { initializeCompiledRuntimeState } from "./state.js";
5
+ import { stageExecutionShellsRoot, testRootForCompiled, testTargetsRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeRoot, compiledRuntimeLogsRoot, workflowPackagePathForCompiled, } from "./compiled-paths.js";
6
+ function removeIfExists(path) {
7
+ if (existsSync(path)) {
8
+ rmSync(path, { recursive: true, force: true });
9
+ }
10
+ }
11
+ const COMPILE_RUNTIME_RESET_ENTRIES = [
12
+ "state.json",
13
+ "health.json",
14
+ "view-spec.json",
15
+ "inventory.json",
16
+ "run.json",
17
+ "raw-snapshot.json",
18
+ "stage-contract.json",
19
+ ];
20
+ const PRESERVED_COMPILED_ROOTS = new Set([
21
+ ".agents",
22
+ ".claude",
23
+ ".codex",
24
+ ".cursor",
25
+ ".gitignore",
26
+ ".interf",
27
+ ".interfignore",
28
+ "AGENTS.md",
29
+ "CLAUDE.md",
30
+ ]);
31
+ export function clearCompiledRuntimeDerivedArtifacts(compiledPath) {
32
+ const runtimeRoot = compiledRuntimeRoot(compiledPath);
33
+ for (const entry of COMPILE_RUNTIME_RESET_ENTRIES) {
34
+ removeIfExists(join(runtimeRoot, entry));
35
+ }
36
+ removeIfExists(compiledQueryAcceptanceRoot(compiledPath));
37
+ }
38
+ function activeCompiledInputRoots(compiledPath) {
39
+ const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
40
+ const roots = new Set();
41
+ for (const zone of schema?.zones ?? []) {
42
+ if (zone.role !== "input")
43
+ continue;
44
+ const root = zone.path.split("/")[0]?.trim();
45
+ if (root)
46
+ roots.add(root);
47
+ }
48
+ return roots;
49
+ }
50
+ function resetCompiledGeneratedOutputs(compiledPath) {
51
+ const preservedInputRoots = activeCompiledInputRoots(compiledPath);
52
+ for (const entry of readdirSync(compiledPath)) {
53
+ if (PRESERVED_COMPILED_ROOTS.has(entry))
54
+ continue;
55
+ if (preservedInputRoots.has(entry))
56
+ continue;
57
+ removeIfExists(join(compiledPath, entry));
58
+ }
59
+ }
60
+ export function resetCompiledGeneratedState(compiledPath, scope = "compile") {
61
+ resetCompiledGeneratedOutputs(compiledPath);
62
+ clearCompiledRuntimeDerivedArtifacts(compiledPath);
63
+ initializeCompiledRuntimeState(compiledPath);
64
+ if (scope === "all") {
65
+ removeIfExists(stageExecutionShellsRoot(compiledPath));
66
+ removeIfExists(workflowImprovementLoopsRoot(compiledPath));
67
+ removeIfExists(compiledRuntimeLogsRoot(compiledPath));
68
+ removeIfExists(join(compiledRuntimeRoot(compiledPath), "run-history.jsonl"));
69
+ removeIfExists(testRootForCompiled(compiledPath));
70
+ removeIfExists(testTargetsRootForCompiled(compiledPath));
71
+ }
72
+ }
@@ -1,11 +1,11 @@
1
1
  import { existsSync, } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { listFilesRecursive } from "../../lib/filesystem.js";
4
- import { readJsonFileWithSchema } from "../../lib/parse.js";
3
+ import { listFilesRecursive } from "../shared/filesystem.js";
4
+ import { readJsonFileWithSchema } from "../shared/parse.js";
5
5
  import { WORKFLOW_SCHEMA_FILE, compiledZoneAbsolutePath, findCompiledSchemaZone, readCompiledSchemaFile, } from "./compiled-schema.js";
6
6
  import { RuntimeStageContractSchema, } from "./lib/schema.js";
7
7
  import { stageContractPath } from "./runtime-paths.js";
8
- import { workflowPackagePathForCompiled } from "../project-model/compiled-paths.js";
8
+ import { workflowPackagePathForCompiled } from "./compiled-paths.js";
9
9
  import { loadState } from "./state-io.js";
10
10
  import { countBrokenWikilinks, isOutputMarkdownFile, safeReadText, validateSynthFiles } from "./validate.js";
11
11
  function toFiniteNumber(value) {
@@ -28,7 +28,7 @@ export function buildRuntimeStageContract(options) {
28
28
  notes: [
29
29
  `This is the "${options.stageLabel}" stage for the compiled context "${options.compiledName}".`,
30
30
  "The workflow package is the authoritative method layer for this run.",
31
- `Use \`workflow/${WORKFLOW_SCHEMA_FILE}\` as the deterministic zone-contract reference for this compiled context.`,
31
+ `Use \`workflow/${WORKFLOW_SCHEMA_FILE}\` as the deterministic context-interface reference for this compiled context.`,
32
32
  "Honor the declared read and write artifacts instead of inventing a parallel workflow.",
33
33
  "Only create or update files that fall under the declared write targets for this stage.",
34
34
  "Interf writes `.interf/runtime/` ledgers such as run, state, health, and view-spec files. Read them if needed, but do not create, edit, or replace them in this stage unless the contract explicitly marks a runtime artifact as stage-owned.",
@@ -1,5 +1,5 @@
1
1
  import { join } from "node:path";
2
- import { compiledRuntimeArchivedStageContractPath, compiledRuntimeLogsRoot, compiledRuntimeRunHistoryPath, compiledRuntimeRunPath, compiledRuntimeStageContractPath, } from "../project-model/compiled-paths.js";
2
+ import { compiledRuntimeArchivedStageContractPath, compiledRuntimeLogsRoot, compiledRuntimeRunHistoryPath, compiledRuntimeRunPath, compiledRuntimeStageContractPath, } from "./compiled-paths.js";
3
3
  export function runPath(dirPath) {
4
4
  return compiledRuntimeRunPath(dirPath);
5
5
  }
@@ -1,12 +1,12 @@
1
1
  import { existsSync, readFileSync, statSync, writeFileSync, } from "node:fs";
2
2
  import { extname, join, relative } from "node:path";
3
- import { listFilesRecursive } from "../../lib/filesystem.js";
3
+ import { listFilesRecursive } from "../shared/filesystem.js";
4
4
  import { compiledZoneAbsolutePath, findCompiledSchemaZone, readCompiledSchemaFile, } from "./compiled-schema.js";
5
- import { parseJsonFrontmatter } from "../../lib/parse.js";
5
+ import { parseJsonFrontmatter } from "../shared/parse.js";
6
6
  import { loadRuntimeRun } from "./runtime.js";
7
7
  import { initCompiledState, loadState, refreshCompiledArtifacts, saveState, } from "./state.js";
8
8
  import { compiledInventoryFromEntries } from "./runtime-inventory.js";
9
- import { compiledRuntimeRoot } from "../project-model/compiled-paths.js";
9
+ import { compiledRuntimeRoot } from "./compiled-paths.js";
10
10
  import { extractSynthAbstract, isOutputMarkdownFile } from "./validate.js";
11
11
  function readActiveRunStartedAtMs(dirPath) {
12
12
  const run = loadRuntimeRun(dirPath);
@@ -1,12 +1,12 @@
1
1
  import { appendFileSync, mkdirSync, existsSync, readFileSync, writeFileSync, } from "node:fs";
2
2
  import { dirname, join, relative } from "node:path";
3
3
  import chalk from "chalk";
4
- import { countFilesRecursive } from "../../lib/filesystem.js";
4
+ import { countFilesRecursive } from "../shared/filesystem.js";
5
5
  import { buildRuntimeExecutorInfo } from "../agents/lib/executors.js";
6
6
  import { RuntimeRunSchema, } from "./lib/schema.js";
7
7
  import { getWorkflowStageDefinition, getWorkflowStagePosition, getWorkflowStages, } from "../workflow-package/workflow-definitions.js";
8
8
  import { archivedStageContractPath, eventLogPath, logsDirPath, promptLogPath, runHistoryPath, runPath, stageContractPath, statusLogPath, } from "./runtime-paths.js";
9
- import { warnInterf } from "../../lib/logger.js";
9
+ import { warnInterf } from "../shared/logger.js";
10
10
  export function loadRuntimeRun(dirPath) {
11
11
  const path = runPath(dirPath);
12
12
  if (!existsSync(path))
@@ -1,14 +1,14 @@
1
1
  import { basename, join } from "node:path";
2
2
  import { existsSync } from "node:fs";
3
3
  import { readInterfConfig, resolveSourceFolderPath, } from "../project-model/interf-detect.js";
4
- import { discoverSourceFiles } from "../../lib/discovery.js";
4
+ import { discoverSourceFiles } from "./discovery.js";
5
5
  import { loadRuntimeRun } from "./runtime.js";
6
6
  import { loadState } from "./state-io.js";
7
7
  import { validateCompiled, validateCompiledStage, validateCompiledWorkflow, } from "./validate.js";
8
8
  import { readCompiledSchemaFile } from "./compiled-schema.js";
9
- import { workflowPackagePathForCompiled } from "../project-model/compiled-paths.js";
9
+ import { workflowPackagePathForCompiled } from "./compiled-paths.js";
10
10
  import { getActiveCompiledWorkflow, resolveRequiredCompiledWorkflowFromConfig } from "../workflow-package/workflow-definitions.js";
11
- import { listFilesRecursive } from "../../lib/filesystem.js";
11
+ import { listFilesRecursive } from "../shared/filesystem.js";
12
12
  function countZoneArtifacts(compiledPath, zonePath, kind) {
13
13
  const absolutePath = join(compiledPath, zonePath);
14
14
  if (!existsSync(absolutePath))
@@ -1,10 +1,10 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
2
- import { warnInterf } from "../../lib/logger.js";
3
- import { readJsonFileUnchecked, readJsonFileWithSchema } from "../../lib/parse.js";
2
+ import { warnInterf } from "../shared/logger.js";
3
+ import { readJsonFileUnchecked, readJsonFileWithSchema } from "../shared/parse.js";
4
4
  import { CompiledHealthSchema, CompiledRawSnapshotSchema, CompiledStateSchema, CompiledViewSpecSchema, } from "./lib/schema.js";
5
5
  import { emptyCompiledInventory, } from "./runtime-inventory.js";
6
6
  import { healthPath, rawSnapshotPath, statePath, viewSpecPath } from "./state-paths.js";
7
- import { compiledRuntimeInventoryPath, compiledRuntimeRoot, } from "../project-model/compiled-paths.js";
7
+ import { compiledRuntimeInventoryPath, compiledRuntimeRoot, } from "./compiled-paths.js";
8
8
  export function loadState(dirPath) {
9
9
  const path = statePath(dirPath);
10
10
  if (!existsSync(path))
@@ -1,4 +1,4 @@
1
- import { compiledRawSnapshotMetadataPath, compiledRuntimeHealthPath, compiledRuntimeStatePath, compiledRuntimeViewSpecPath, } from "../project-model/compiled-paths.js";
1
+ import { compiledRawSnapshotMetadataPath, compiledRuntimeHealthPath, compiledRuntimeStatePath, compiledRuntimeViewSpecPath, } from "./compiled-paths.js";
2
2
  export function statePath(dirPath) {
3
3
  return compiledRuntimeStatePath(dirPath);
4
4
  }
@@ -1,10 +1,10 @@
1
1
  import { basename, relative } from "node:path";
2
2
  import { mkdirSync, writeFileSync } from "node:fs";
3
- import { discoverSourceFiles } from "../../lib/discovery.js";
3
+ import { discoverSourceFiles } from "./discovery.js";
4
4
  import { readInterfConfig, resolveSourceFolderPath } from "../project-model/interf-detect.js";
5
5
  import { loadCompiledViewSpec, saveCompiledViewSpec, } from "./state-io.js";
6
6
  import { rawSnapshotPath } from "./state-paths.js";
7
- import { compiledRuntimeRoot, workflowPackagePathForCompiled } from "../project-model/compiled-paths.js";
7
+ import { compiledRuntimeRoot, workflowPackagePathForCompiled } from "./compiled-paths.js";
8
8
  import { readCompiledSchemaFile } from "./compiled-schema.js";
9
9
  import { getActiveCompiledWorkflow, resolveRequiredCompiledWorkflowFromConfig } from "../workflow-package/workflow-definitions.js";
10
10
  export function ensureCompiledViewSpec(dirPath) {
@@ -1,14 +1,14 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { discoverSourceFiles } from "../../lib/discovery.js";
3
+ import { discoverSourceFiles } from "./discovery.js";
4
4
  import { WORKFLOW_SCHEMA_FILE, compiledZoneAbsolutePath, findCompiledSchemaZone, readCompiledSchemaFile, workflowSchemaExists, } from "./compiled-schema.js";
5
5
  import { resolveSourceFolderPath } from "../project-model/interf-detect.js";
6
- import { compiledInterfConfigPath, workflowPackagePathForCompiled } from "../project-model/compiled-paths.js";
6
+ import { compiledInterfConfigPath, workflowPackagePathForCompiled } from "./compiled-paths.js";
7
7
  import { readCompiledConfig } from "./validate.js";
8
8
  import { loadState } from "./state.js";
9
9
  import { validateResolvedStageAcceptance, stageRecordFromState } from "./runtime-acceptance.js";
10
10
  import { getActiveCompiledWorkflow, resolveRequiredCompiledWorkflowFromConfig, } from "../workflow-package/workflow-definitions.js";
11
- import { listFilesRecursive } from "../../lib/filesystem.js";
11
+ import { listFilesRecursive } from "../shared/filesystem.js";
12
12
  function workflowSchemaPresent(dirPath) {
13
13
  return workflowSchemaExists(join(dirPath, ".interf", "workflow"));
14
14
  }
@@ -2,11 +2,11 @@ import { existsSync, readFileSync, statSync, } from "node:fs";
2
2
  import { basename, extname, join } from "node:path";
3
3
  import { readCompiledSchemaFile } from "./compiled-schema.js";
4
4
  import { compiledKnowledgeRootPath } from "./compiled-schema.js";
5
- import { workflowPackagePathForCompiled } from "../project-model/compiled-paths.js";
6
- import { listFilesRecursive } from "../../lib/filesystem.js";
5
+ import { workflowPackagePathForCompiled } from "./compiled-paths.js";
6
+ import { listFilesRecursive } from "../shared/filesystem.js";
7
7
  import { readInterfConfig } from "../project-model/interf-detect.js";
8
- import { parseJsonFrontmatter } from "../../lib/parse.js";
9
- import { compiledInterfConfigPath } from "../project-model/compiled-paths.js";
8
+ import { parseJsonFrontmatter } from "../shared/parse.js";
9
+ import { compiledInterfConfigPath } from "./compiled-paths.js";
10
10
  const MIN_ABSTRACT_WORDS = 5;
11
11
  const WIKILINK_PATTERN = /!?\[\[([^[\]]+)\]\]/g;
12
12
  export function readCompiledConfig(dirPath) {
@@ -1,40 +1 @@
1
- export declare const COMPILED_INTERF_DIR = ".interf";
2
- export declare const COMPILED_CONFIG_FILE = "interf.json";
3
- export declare const COMPILED_WORKFLOW_DIR = "workflow";
4
- export declare const COMPILED_TEST_DIR = "tests";
5
- export declare const COMPILED_TEST_TARGETS_DIR = "targets";
6
- export declare const COMPILED_RUNTIME_DIR = "runtime";
7
- export declare const COMPILED_RUNTIME_STATE_FILE = "state.json";
8
- export declare const COMPILED_RUNTIME_HEALTH_FILE = "health.json";
9
- export declare const COMPILED_RUNTIME_VIEW_SPEC_FILE = "view-spec.json";
10
- export declare const COMPILED_RUNTIME_RAW_SNAPSHOT_FILE = "raw-snapshot.json";
11
- export declare const COMPILED_RUNTIME_INVENTORY_FILE = "inventory.json";
12
- export declare const COMPILED_RUNTIME_RUN_FILE = "run.json";
13
- export declare const COMPILED_RUNTIME_RUN_HISTORY_FILE = "run-history.jsonl";
14
- export declare const COMPILED_RUNTIME_STAGE_CONTRACT_FILE = "stage-contract.json";
15
- export declare function compiledRuntimeRoot(compiledPath: string): string;
16
- export declare function compiledRuntimeFilePath(compiledPath: string, fileName: string): string;
17
- export declare function compiledInterfRoot(compiledPath: string): string;
18
- export declare function compiledInterfConfigPath(compiledPath: string): string;
19
- export declare function workflowPackagePathForCompiled(compiledPath: string): string;
20
- export declare function testRootForCompiled(compiledPath: string): string;
21
- export declare function testTargetsRootForCompiled(compiledPath: string): string;
22
- export declare function stageExecutionShellsRoot(compiledPath: string): string;
23
- export declare function workflowImprovementLoopsRoot(compiledPath: string): string;
24
- export declare function workflowImprovementRunRoot(compiledPath: string, runId: string): string;
25
- export declare function workflowImprovementLoopRoot(compiledPath: string, runId: string, loopIndex: number): string;
26
- export declare function targetTestRunsRootForCompiled(compiledPath: string): string;
27
- export declare function targetTestSandboxesRootForCompiled(compiledPath: string): string;
28
- export declare function compiledRuntimeLogsRoot(compiledPath: string): string;
29
- export declare function compiledRuntimeArchivedStageContractPath(compiledPath: string, runId: string): string;
30
- export declare function compiledQueryAcceptanceRoot(compiledPath: string): string;
31
- export declare function compiledRuntimeStatePath(compiledPath: string): string;
32
- export declare function compiledRuntimeHealthPath(compiledPath: string): string;
33
- export declare function compiledRuntimeViewSpecPath(compiledPath: string): string;
34
- export declare function compiledRawSnapshotMetadataPath(compiledPath: string): string;
35
- export declare function compiledRuntimeInventoryPath(compiledPath: string): string;
36
- export declare function compiledRuntimeRunPath(compiledPath: string): string;
37
- export declare function compiledRuntimeRunHistoryPath(compiledPath: string): string;
38
- export declare function compiledRuntimeStageContractPath(compiledPath: string): string;
39
- export declare function resolveSourceControlPathForCompiled(compiledPath: string): string;
40
- export declare function defaultControlPathForCompiled(compiledPath: string): string;
1
+ export * from "../compiler/compiled-paths.js";
@@ -1,106 +1 @@
1
- import { basename, dirname, join, relative, resolve, sep } from "node:path";
2
- export const COMPILED_INTERF_DIR = ".interf";
3
- export const COMPILED_CONFIG_FILE = "interf.json";
4
- export const COMPILED_WORKFLOW_DIR = "workflow";
5
- export const COMPILED_TEST_DIR = "tests";
6
- export const COMPILED_TEST_TARGETS_DIR = "targets";
7
- export const COMPILED_RUNTIME_DIR = "runtime";
8
- export const COMPILED_RUNTIME_STATE_FILE = "state.json";
9
- export const COMPILED_RUNTIME_HEALTH_FILE = "health.json";
10
- export const COMPILED_RUNTIME_VIEW_SPEC_FILE = "view-spec.json";
11
- export const COMPILED_RUNTIME_RAW_SNAPSHOT_FILE = "raw-snapshot.json";
12
- export const COMPILED_RUNTIME_INVENTORY_FILE = "inventory.json";
13
- export const COMPILED_RUNTIME_RUN_FILE = "run.json";
14
- export const COMPILED_RUNTIME_RUN_HISTORY_FILE = "run-history.jsonl";
15
- export const COMPILED_RUNTIME_STAGE_CONTRACT_FILE = "stage-contract.json";
16
- export function compiledRuntimeRoot(compiledPath) {
17
- return join(compiledPath, COMPILED_INTERF_DIR, COMPILED_RUNTIME_DIR);
18
- }
19
- export function compiledRuntimeFilePath(compiledPath, fileName) {
20
- return join(compiledRuntimeRoot(compiledPath), fileName);
21
- }
22
- export function compiledInterfRoot(compiledPath) {
23
- return join(compiledPath, COMPILED_INTERF_DIR);
24
- }
25
- export function compiledInterfConfigPath(compiledPath) {
26
- return join(compiledInterfRoot(compiledPath), COMPILED_CONFIG_FILE);
27
- }
28
- export function workflowPackagePathForCompiled(compiledPath) {
29
- return join(compiledInterfRoot(compiledPath), COMPILED_WORKFLOW_DIR);
30
- }
31
- export function testRootForCompiled(compiledPath) {
32
- return join(compiledInterfRoot(compiledPath), COMPILED_TEST_DIR);
33
- }
34
- export function testTargetsRootForCompiled(compiledPath) {
35
- return join(testRootForCompiled(compiledPath), COMPILED_TEST_TARGETS_DIR);
36
- }
37
- export function stageExecutionShellsRoot(compiledPath) {
38
- return join(compiledRuntimeRoot(compiledPath), "execution-shells");
39
- }
40
- export function workflowImprovementLoopsRoot(compiledPath) {
41
- return join(compiledRuntimeRoot(compiledPath), "improvement-loops");
42
- }
43
- export function workflowImprovementRunRoot(compiledPath, runId) {
44
- return join(workflowImprovementLoopsRoot(compiledPath), runId);
45
- }
46
- export function workflowImprovementLoopRoot(compiledPath, runId, loopIndex) {
47
- return join(workflowImprovementRunRoot(compiledPath, runId), `loop-${String(loopIndex).padStart(2, "0")}`);
48
- }
49
- export function targetTestRunsRootForCompiled(compiledPath) {
50
- return join(testTargetsRootForCompiled(compiledPath), "runs");
51
- }
52
- export function targetTestSandboxesRootForCompiled(compiledPath) {
53
- return join(testTargetsRootForCompiled(compiledPath), "sandboxes");
54
- }
55
- export function compiledRuntimeLogsRoot(compiledPath) {
56
- return join(compiledRuntimeRoot(compiledPath), "logs");
57
- }
58
- export function compiledRuntimeArchivedStageContractPath(compiledPath, runId) {
59
- return join(compiledRuntimeLogsRoot(compiledPath), `${runId}.stage-contract.json`);
60
- }
61
- export function compiledQueryAcceptanceRoot(compiledPath) {
62
- return join(compiledRuntimeRoot(compiledPath), "query-acceptance");
63
- }
64
- export function compiledRuntimeStatePath(compiledPath) {
65
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_STATE_FILE);
66
- }
67
- export function compiledRuntimeHealthPath(compiledPath) {
68
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_HEALTH_FILE);
69
- }
70
- export function compiledRuntimeViewSpecPath(compiledPath) {
71
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_VIEW_SPEC_FILE);
72
- }
73
- export function compiledRawSnapshotMetadataPath(compiledPath) {
74
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RAW_SNAPSHOT_FILE);
75
- }
76
- export function compiledRuntimeInventoryPath(compiledPath) {
77
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_INVENTORY_FILE);
78
- }
79
- export function compiledRuntimeRunPath(compiledPath) {
80
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RUN_FILE);
81
- }
82
- export function compiledRuntimeRunHistoryPath(compiledPath) {
83
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RUN_HISTORY_FILE);
84
- }
85
- export function compiledRuntimeStageContractPath(compiledPath) {
86
- return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_STAGE_CONTRACT_FILE);
87
- }
88
- export function resolveSourceControlPathForCompiled(compiledPath) {
89
- let cursor = resolve(compiledPath);
90
- while (true) {
91
- const parent = dirname(cursor);
92
- if (basename(parent) === "interf" &&
93
- basename(cursor) !== "tests" &&
94
- basename(cursor) !== "workflows") {
95
- return dirname(parent);
96
- }
97
- if (parent === cursor)
98
- break;
99
- cursor = parent;
100
- }
101
- throw new Error(`Context folder is not under the canonical project layout: ${compiledPath}`);
102
- }
103
- export function defaultControlPathForCompiled(compiledPath) {
104
- const relativePath = relative(compiledPath, resolveSourceControlPathForCompiled(compiledPath));
105
- return relativePath.length > 0 ? relativePath.split(sep).join("/") : ".";
106
- }
1
+ export * from "../compiler/compiled-paths.js";
@@ -1,49 +1 @@
1
- import type { InterfConfig } from "./lib/schema.js";
2
- export interface CompiledRawSyncResult {
3
- sourceTotal: number;
4
- copied: number;
5
- removed: number;
6
- }
7
- type RawSnapshotMaterializeMode = "copy" | "link-or-copy";
8
- export declare function resolveCompiledRawPath(compiledPath: string, config?: {
9
- [x: string]: unknown;
10
- type: "compiled";
11
- name: string;
12
- workflow: string;
13
- checks: {
14
- question: string;
15
- id?: string | undefined;
16
- answer?: string | undefined;
17
- expect?: {
18
- must_include?: string[] | undefined;
19
- must_include_one_of?: string[][] | undefined;
20
- must_not_include?: string[] | undefined;
21
- min_words?: number | undefined;
22
- max_words?: number | undefined;
23
- } | undefined;
24
- strictness?: string | undefined;
25
- }[];
26
- source: {
27
- path: string;
28
- dataset_path: string;
29
- control_path?: string | undefined;
30
- };
31
- about?: string | undefined;
32
- max_attempts?: number | undefined;
33
- max_loops?: number | undefined;
34
- workflow_origin?: {
35
- selected: string;
36
- local_draft?: boolean | undefined;
37
- } | undefined;
38
- } | null): string;
39
- export declare function syncCompiledRawSnapshot(compiledPath: string, sourcePath?: string): CompiledRawSyncResult;
40
- export declare function ensureCompiledRawBinding(compiledPath: string): InterfConfig | null;
41
- export declare function projectRawSnapshot(options: {
42
- sourcePath: string;
43
- destinationPath: string;
44
- compiledPath: string;
45
- mode?: RawSnapshotMaterializeMode;
46
- prune?: boolean;
47
- preserveTimestamps?: boolean;
48
- }): CompiledRawSyncResult;
49
- export {};
1
+ export * from "../compiler/raw-snapshot.js";
@@ -1,102 +1 @@
1
- import { cpSync, existsSync, linkSync, mkdirSync, rmSync, statSync, } from "node:fs";
2
- import { dirname, join, relative, resolve } from "node:path";
3
- import { listFilesRecursive } from "../../lib/filesystem.js";
4
- import { discoverSourceFiles } from "../../lib/discovery.js";
5
- import { readInterfConfig, resolveSourceInputPath, } from "./interf-detect.js";
6
- import { saveCompiledInterfConfig } from "./source-config.js";
7
- import { defaultControlPathForCompiled, } from "./compiled-paths.js";
8
- import { assertPathWithinRoot } from "../../lib/util.js";
9
- export function resolveCompiledRawPath(compiledPath, config = readInterfConfig(compiledPath)) {
10
- const configuredPath = typeof config?.source?.path === "string" && config.source.path.length > 0
11
- ? config.source.path
12
- : "raw";
13
- return assertPathWithinRoot(compiledPath, resolve(compiledPath, configuredPath), "Compiled raw path");
14
- }
15
- export function syncCompiledRawSnapshot(compiledPath, sourcePath = resolveSourceInputPath(compiledPath)) {
16
- ensureCompiledRawBinding(compiledPath);
17
- const rawPath = resolveCompiledRawPath(compiledPath);
18
- return projectRawSnapshot({
19
- sourcePath,
20
- destinationPath: rawPath,
21
- compiledPath,
22
- mode: "copy",
23
- prune: true,
24
- preserveTimestamps: true,
25
- });
26
- }
27
- export function ensureCompiledRawBinding(compiledPath) {
28
- const config = readInterfConfig(compiledPath);
29
- if (!config)
30
- return null;
31
- if (config.source?.path === "./raw")
32
- return config;
33
- const nextConfig = {
34
- ...config,
35
- source: {
36
- ...(config.source ?? {}),
37
- path: "./raw",
38
- control_path: config.source?.control_path ?? defaultControlPathForCompiled(compiledPath),
39
- ...(config.source?.dataset_path ? { dataset_path: config.source.dataset_path } : {}),
40
- },
41
- };
42
- return saveCompiledInterfConfig(compiledPath, nextConfig);
43
- }
44
- function filesMatch(sourcePath, targetPath) {
45
- if (!existsSync(targetPath))
46
- return false;
47
- try {
48
- const sourceStat = statSync(sourcePath);
49
- const targetStat = statSync(targetPath);
50
- return sourceStat.size === targetStat.size && sourceStat.mtimeMs === targetStat.mtimeMs;
51
- }
52
- catch {
53
- return false;
54
- }
55
- }
56
- function materializeRawSnapshotFile(sourcePath, targetPath, options) {
57
- mkdirSync(dirname(targetPath), { recursive: true });
58
- rmSync(targetPath, { force: true });
59
- if (options.mode === "link-or-copy") {
60
- try {
61
- linkSync(sourcePath, targetPath);
62
- return;
63
- }
64
- catch {
65
- // fall through to copy
66
- }
67
- }
68
- cpSync(sourcePath, targetPath, { preserveTimestamps: options.preserveTimestamps });
69
- }
70
- export function projectRawSnapshot(options) {
71
- const discovery = discoverSourceFiles(options.sourcePath, options.compiledPath);
72
- const expectedFiles = new Set(discovery.sourceFiles);
73
- mkdirSync(options.destinationPath, { recursive: true });
74
- let removed = 0;
75
- if (options.prune !== false) {
76
- for (const existingPath of listFilesRecursive(options.destinationPath)) {
77
- const relativePath = relative(options.destinationPath, existingPath);
78
- if (expectedFiles.has(relativePath))
79
- continue;
80
- rmSync(existingPath, { force: true });
81
- removed += 1;
82
- }
83
- }
84
- let copied = 0;
85
- for (const relativePath of discovery.sourceFiles) {
86
- const sourceFilePath = join(options.sourcePath, relativePath);
87
- const targetFilePath = join(options.destinationPath, relativePath);
88
- if (filesMatch(sourceFilePath, targetFilePath)) {
89
- continue;
90
- }
91
- materializeRawSnapshotFile(sourceFilePath, targetFilePath, {
92
- mode: options.mode ?? "copy",
93
- preserveTimestamps: options.preserveTimestamps ?? true,
94
- });
95
- copied += 1;
96
- }
97
- return {
98
- sourceTotal: discovery.totalCount,
99
- copied,
100
- removed,
101
- };
102
- }
1
+ export * from "../compiler/raw-snapshot.js";
@@ -1,2 +1 @@
1
- export declare function clearCompiledRuntimeDerivedArtifacts(compiledPath: string): void;
2
- export declare function resetCompiledGeneratedState(compiledPath: string, scope?: "compile" | "all"): void;
1
+ export * from "../compiler/reset.js";
@@ -1,72 +1 @@
1
- import { existsSync, readdirSync, rmSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { readCompiledSchemaFile, } from "../compiler/compiled-schema.js";
4
- import { initializeCompiledRuntimeState, } from "../compiler/state.js";
5
- import { stageExecutionShellsRoot, testRootForCompiled, testTargetsRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeRoot, compiledRuntimeLogsRoot, workflowPackagePathForCompiled, } from "./compiled-paths.js";
6
- function removeIfExists(path) {
7
- if (existsSync(path)) {
8
- rmSync(path, { recursive: true, force: true });
9
- }
10
- }
11
- const COMPILE_RUNTIME_RESET_ENTRIES = [
12
- "state.json",
13
- "health.json",
14
- "view-spec.json",
15
- "inventory.json",
16
- "run.json",
17
- "raw-snapshot.json",
18
- "stage-contract.json",
19
- ];
20
- const PRESERVED_COMPILED_ROOTS = new Set([
21
- ".agents",
22
- ".claude",
23
- ".codex",
24
- ".cursor",
25
- ".gitignore",
26
- ".interf",
27
- ".interfignore",
28
- "AGENTS.md",
29
- "CLAUDE.md",
30
- ]);
31
- export function clearCompiledRuntimeDerivedArtifacts(compiledPath) {
32
- const runtimeRoot = compiledRuntimeRoot(compiledPath);
33
- for (const entry of COMPILE_RUNTIME_RESET_ENTRIES) {
34
- removeIfExists(join(runtimeRoot, entry));
35
- }
36
- removeIfExists(compiledQueryAcceptanceRoot(compiledPath));
37
- }
38
- function activeCompiledInputRoots(compiledPath) {
39
- const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
40
- const roots = new Set();
41
- for (const zone of schema?.zones ?? []) {
42
- if (zone.role !== "input")
43
- continue;
44
- const root = zone.path.split("/")[0]?.trim();
45
- if (root)
46
- roots.add(root);
47
- }
48
- return roots;
49
- }
50
- function resetCompiledGeneratedOutputs(compiledPath) {
51
- const preservedInputRoots = activeCompiledInputRoots(compiledPath);
52
- for (const entry of readdirSync(compiledPath)) {
53
- if (PRESERVED_COMPILED_ROOTS.has(entry))
54
- continue;
55
- if (preservedInputRoots.has(entry))
56
- continue;
57
- removeIfExists(join(compiledPath, entry));
58
- }
59
- }
60
- export function resetCompiledGeneratedState(compiledPath, scope = "compile") {
61
- resetCompiledGeneratedOutputs(compiledPath);
62
- clearCompiledRuntimeDerivedArtifacts(compiledPath);
63
- initializeCompiledRuntimeState(compiledPath);
64
- if (scope === "all") {
65
- removeIfExists(stageExecutionShellsRoot(compiledPath));
66
- removeIfExists(workflowImprovementLoopsRoot(compiledPath));
67
- removeIfExists(compiledRuntimeLogsRoot(compiledPath));
68
- removeIfExists(join(compiledRuntimeRoot(compiledPath), "run-history.jsonl"));
69
- removeIfExists(testRootForCompiled(compiledPath));
70
- removeIfExists(testTargetsRootForCompiled(compiledPath));
71
- }
72
- }
1
+ export * from "../compiler/reset.js";
@@ -1,3 +1 @@
1
- import { renderClaudeBootstrap } from "../agents/lib/shells.js";
2
- export { renderClaudeBootstrap };
3
- export declare function refreshCompiledBootstrapGuidance(dirPath: string): boolean;
1
+ export { refreshCompiledBootstrapGuidance, renderClaudeBootstrap, } from "../agents/lib/compiled-bootstrap.js";
@@ -1,18 +1 @@
1
- import { basename } from "node:path";
2
- import { readInterfConfig } from "./interf-detect.js";
3
- import { projectCompiledQueryShell, renderClaudeBootstrap } from "../agents/lib/shells.js";
4
- export { renderClaudeBootstrap };
5
- export function refreshCompiledBootstrapGuidance(dirPath) {
6
- const config = readInterfConfig(dirPath);
7
- if (!config)
8
- return false;
9
- const compiledName = config.name ?? basename(dirPath);
10
- const workflowId = config.workflow ?? "interf";
11
- const workflowOriginSelected = config.workflow_origin?.selected ?? workflowId;
12
- const workflowLocalDraft = config.workflow_origin?.local_draft === true;
13
- const about = typeof config.about === "string" && config.about.length > 0 ? config.about : undefined;
14
- return projectCompiledQueryShell(dirPath, compiledName, workflowId, about, {
15
- workflowOriginSelected,
16
- workflowLocalDraft,
17
- });
18
- }
1
+ export { refreshCompiledBootstrapGuidance, renderClaudeBootstrap, } from "../agents/lib/compiled-bootstrap.js";