@interf/compiler 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +126 -188
  2. package/builtin-workflows/interf/README.md +22 -10
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +6 -3
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +3 -0
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -2
  6. package/builtin-workflows/interf/improve/SKILL.md +2 -2
  7. package/builtin-workflows/interf/workflow.json +18 -4
  8. package/builtin-workflows/interf/{compiled.schema.json → workflow.schema.json} +9 -2
  9. package/dist/commands/check-draft.js +3 -3
  10. package/dist/commands/compile-controller.js +9 -16
  11. package/dist/commands/compile.d.ts +19 -1
  12. package/dist/commands/compile.js +98 -28
  13. package/dist/commands/create-workflow-wizard.d.ts +20 -2
  14. package/dist/commands/create-workflow-wizard.js +163 -27
  15. package/dist/commands/create.d.ts +1 -1
  16. package/dist/commands/create.js +67 -60
  17. package/dist/commands/dataset-selection.d.ts +6 -0
  18. package/dist/commands/dataset-selection.js +11 -0
  19. package/dist/commands/default.js +3 -3
  20. package/dist/commands/doctor.js +8 -8
  21. package/dist/commands/executor-flow.d.ts +1 -1
  22. package/dist/commands/executor-flow.js +5 -2
  23. package/dist/commands/init.d.ts +5 -0
  24. package/dist/commands/init.js +56 -48
  25. package/dist/commands/list.js +6 -3
  26. package/dist/commands/reset.js +1 -1
  27. package/dist/commands/source-config-wizard.d.ts +2 -2
  28. package/dist/commands/source-config-wizard.js +50 -17
  29. package/dist/commands/test-flow.js +5 -16
  30. package/dist/commands/test.d.ts +0 -6
  31. package/dist/commands/test.js +9 -17
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/lib/agent-args.d.ts +1 -0
  35. package/dist/lib/agent-args.js +10 -0
  36. package/dist/lib/agent-execution.js +2 -1
  37. package/dist/lib/agent-preflight.js +2 -1
  38. package/dist/lib/agent-shells.d.ts +26 -1
  39. package/dist/lib/agent-shells.js +214 -40
  40. package/dist/lib/agents.d.ts +1 -1
  41. package/dist/lib/agents.js +1 -1
  42. package/dist/lib/builtin-compiled-workflow.d.ts +38 -0
  43. package/dist/lib/builtin-compiled-workflow.js +94 -0
  44. package/dist/lib/compiled-compile.d.ts +0 -4
  45. package/dist/lib/compiled-compile.js +11 -30
  46. package/dist/lib/compiled-paths.d.ts +1 -2
  47. package/dist/lib/compiled-paths.js +8 -13
  48. package/dist/lib/compiled-raw.d.ts +2 -2
  49. package/dist/lib/compiled-reset.d.ts +1 -0
  50. package/dist/lib/compiled-reset.js +42 -14
  51. package/dist/lib/compiled-schema.d.ts +11 -7
  52. package/dist/lib/compiled-schema.js +47 -16
  53. package/dist/lib/discovery.d.ts +1 -1
  54. package/dist/lib/discovery.js +2 -2
  55. package/dist/lib/executors.d.ts +1 -1
  56. package/dist/lib/executors.js +2 -2
  57. package/dist/lib/interf-detect.d.ts +0 -1
  58. package/dist/lib/interf-detect.js +7 -18
  59. package/dist/lib/interf-scaffold.js +4 -11
  60. package/dist/lib/interf-workflow-package.d.ts +8 -3
  61. package/dist/lib/interf-workflow-package.js +128 -62
  62. package/dist/lib/interf.d.ts +1 -1
  63. package/dist/lib/interf.js +1 -1
  64. package/dist/lib/local-workflows.d.ts +4 -3
  65. package/dist/lib/local-workflows.js +127 -104
  66. package/dist/lib/project-paths.d.ts +2 -4
  67. package/dist/lib/project-paths.js +13 -10
  68. package/dist/lib/runtime-acceptance.js +15 -3
  69. package/dist/lib/runtime-contracts.js +3 -2
  70. package/dist/lib/runtime-paths.d.ts +1 -0
  71. package/dist/lib/runtime-paths.js +4 -1
  72. package/dist/lib/runtime-prompt.js +4 -4
  73. package/dist/lib/runtime-reconcile.js +90 -64
  74. package/dist/lib/runtime-runs.js +29 -102
  75. package/dist/lib/runtime.d.ts +1 -1
  76. package/dist/lib/runtime.js +1 -1
  77. package/dist/lib/schema.d.ts +104 -54
  78. package/dist/lib/schema.js +32 -116
  79. package/dist/lib/source-config.js +21 -22
  80. package/dist/lib/state-health.js +4 -2
  81. package/dist/lib/state-io.js +2 -110
  82. package/dist/lib/state-view.js +8 -8
  83. package/dist/lib/state.d.ts +1 -0
  84. package/dist/lib/state.js +7 -0
  85. package/dist/lib/test-execution.js +2 -2
  86. package/dist/lib/test-paths.js +12 -3
  87. package/dist/lib/test-sandbox.js +4 -17
  88. package/dist/lib/test-specs.js +1 -1
  89. package/dist/lib/validate-compiled.js +13 -8
  90. package/dist/lib/validate.d.ts +5 -1
  91. package/dist/lib/validate.js +30 -22
  92. package/dist/lib/workflow-authoring.d.ts +26 -0
  93. package/dist/lib/workflow-authoring.js +119 -0
  94. package/dist/lib/workflow-definitions.d.ts +14 -3
  95. package/dist/lib/workflow-definitions.js +21 -17
  96. package/dist/lib/workflow-edit-session.d.ts +16 -0
  97. package/dist/lib/workflow-edit-session.js +57 -0
  98. package/dist/lib/workflow-edit-utils.d.ts +10 -0
  99. package/dist/lib/workflow-edit-utils.js +39 -0
  100. package/dist/lib/workflow-improvement.js +30 -217
  101. package/dist/lib/workflow-primitives.d.ts +2 -0
  102. package/dist/lib/workflow-primitives.js +5 -0
  103. package/dist/lib/workflow-stage-policy.d.ts +5 -0
  104. package/dist/lib/workflow-stage-policy.js +31 -0
  105. package/package.json +7 -8
  106. package/dist/lib/compiled-layout.d.ts +0 -2
  107. package/dist/lib/compiled-layout.js +0 -60
  108. package/dist/lib/obsidian.d.ts +0 -1
  109. package/dist/lib/obsidian.js +0 -15
  110. package/dist/lib/summarize-plan.d.ts +0 -17
  111. package/dist/lib/summarize-plan.js +0 -124
  112. package/dist/lib/workflow-abi.d.ts +0 -129
  113. package/dist/lib/workflow-abi.js +0 -156
@@ -0,0 +1,5 @@
1
+ export const COMPILED_ZONE_KINDS = [
2
+ "directory",
3
+ "file",
4
+ "runtime",
5
+ ];
@@ -0,0 +1,5 @@
1
+ export interface StagePolicyStageLike {
2
+ id: string;
3
+ }
4
+ export declare function normalizeStagePolicyNotes(value: unknown): Record<string, string[]> | undefined;
5
+ export declare function mergeStagePolicyNotesForStages(stages: readonly StagePolicyStageLike[], baseNotes: unknown, overrideNotes: Record<string, string[]> | undefined): Record<string, string[]> | undefined;
@@ -0,0 +1,31 @@
1
+ export function normalizeStagePolicyNotes(value) {
2
+ if (!value || typeof value !== "object" || Array.isArray(value))
3
+ return undefined;
4
+ const normalized = {};
5
+ for (const [stageId, notes] of Object.entries(value)) {
6
+ if (!Array.isArray(notes))
7
+ continue;
8
+ const cleaned = Array.from(new Set(notes
9
+ .filter((note) => typeof note === "string")
10
+ .map((note) => note.trim())
11
+ .filter((note) => note.length > 0)));
12
+ if (cleaned.length > 0) {
13
+ normalized[stageId] = cleaned;
14
+ }
15
+ }
16
+ return Object.keys(normalized).length > 0 ? normalized : undefined;
17
+ }
18
+ export function mergeStagePolicyNotesForStages(stages, baseNotes, overrideNotes) {
19
+ const normalizedBase = normalizeStagePolicyNotes(baseNotes);
20
+ const merged = {};
21
+ for (const stage of stages) {
22
+ const combined = Array.from(new Set([
23
+ ...(normalizedBase?.[stage.id] ?? []),
24
+ ...((overrideNotes?.[stage.id] ?? []).map((note) => note.trim()).filter((note) => note.length > 0)),
25
+ ]));
26
+ if (combined.length > 0) {
27
+ merged[stage.id] = combined;
28
+ }
29
+ }
30
+ return Object.keys(merged).length > 0 ? merged : undefined;
31
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@interf/compiler",
3
- "version": "0.5.0",
4
- "description": "Interf Compiler is a local runtime for data-processing workflows that turn datasets into compiled datasets for local agents.",
3
+ "version": "0.6.1",
4
+ "description": "Interf helps make data ready for agent work. Measure raw files first, then prepare a compiled dataset when you need it.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "interf": "dist/bin.js"
@@ -37,13 +37,14 @@
37
37
  "test:internal:cbre:max:keep": "npm run test:matrix -- --matrix internal/test-matrices/cbre-chart-tier1-max.json --keep-project-clones",
38
38
  "test:full": "npm test && npm run test:e2e:quick:matrix",
39
39
  "test:release:matrix": "npm run test:internal:cbre:max",
40
- "test:release": "npm test && npm run test:e2e:claude && npm run test:e2e:codex",
40
+ "test:release": "npm test && npm run test:acceptance-quick:workflow-authoring -- --agent claude-code && npm run test:acceptance-live -- --agent claude-code --with-test && npm run test:acceptance-quick:workflow-authoring -- --agent codex && npm run test:acceptance-live -- --agent codex --with-test",
41
41
  "test:acceptance-live": "npm run build && node scripts/acceptance-live.mjs",
42
- "test:acceptance-cache:refresh": "npm run test:acceptance-cache:refresh:claude",
43
- "test:acceptance-cache:refresh:claude": "npm run build && node scripts/acceptance-live.mjs --agent claude-code --output-root .interf-test-cache/claude-code",
44
- "test:acceptance-cache:refresh:codex": "npm run build && node scripts/acceptance-live.mjs --agent codex --output-root .interf-test-cache/codex",
42
+ "test:acceptance-cache:refresh": "npm run test:acceptance-cache:refresh:claude && npm run test:acceptance-cache:refresh:codex",
43
+ "test:acceptance-cache:refresh:claude": "node scripts/acceptance-cache-refresh.mjs --agent claude-code",
44
+ "test:acceptance-cache:refresh:codex": "node scripts/acceptance-cache-refresh.mjs --agent codex",
45
45
  "test:acceptance-quick:create-compiled": "npm run build && node scripts/acceptance-targeted.mjs create-compiled",
46
46
  "test:acceptance-quick:compiled-query": "npm run build && node scripts/acceptance-targeted.mjs compiled-query",
47
+ "test:acceptance-quick:workflow-authoring": "npm run build && node scripts/acceptance-targeted.mjs workflow-authoring",
47
48
  "test:acceptance-quick:self-improving": "npm run build && node scripts/acceptance-targeted.mjs self-improving-compile",
48
49
  "prepublishOnly": "node scripts/prepublish-gate.mjs"
49
50
  },
@@ -59,8 +60,6 @@
59
60
  "interf",
60
61
  "ai",
61
62
  "agent",
62
- "knowledge",
63
- "obsidian",
64
63
  "coding-agent",
65
64
  "claude",
66
65
  "codex"
@@ -1,2 +0,0 @@
1
- export declare function normalizeLegacyCompiledLayout(compiledPath: string): boolean;
2
- export declare function compiledNeedsLegacyLayoutNormalization(compiledPath: string): boolean;
@@ -1,60 +0,0 @@
1
- import { existsSync, mkdirSync, readdirSync, renameSync, } from "node:fs";
2
- import { dirname, join } from "node:path";
3
- import { COMPILED_CONFIG_FILE, COMPILED_INTERF_DIR, COMPILED_RUNTIME_DIR, COMPILED_TEST_DIR, COMPILED_WORKFLOW_DIR, workflowPackagePathForCompiled, compiledInterfConfigPath, compiledInterfRoot, compiledRuntimeRoot, } from "./compiled-paths.js";
4
- const LEGACY_COMPILED_CONFIG_FILE = "interf.json";
5
- const LEGACY_WORKFLOW_DIR = "workflow";
6
- function movePathIfMissing(sourcePath, targetPath) {
7
- if (!existsSync(sourcePath)) {
8
- return false;
9
- }
10
- if (existsSync(targetPath)) {
11
- return false;
12
- }
13
- mkdirSync(dirname(targetPath), { recursive: true });
14
- renameSync(sourcePath, targetPath);
15
- return true;
16
- }
17
- export function normalizeLegacyCompiledLayout(compiledPath) {
18
- const interfRoot = compiledInterfRoot(compiledPath);
19
- const runtimeRoot = compiledRuntimeRoot(compiledPath);
20
- let changed = false;
21
- changed = movePathIfMissing(join(compiledPath, LEGACY_COMPILED_CONFIG_FILE), compiledInterfConfigPath(compiledPath)) || changed;
22
- changed = movePathIfMissing(join(compiledPath, LEGACY_WORKFLOW_DIR), workflowPackagePathForCompiled(compiledPath)) || changed;
23
- if (!existsSync(interfRoot)) {
24
- return changed;
25
- }
26
- for (const entry of readdirSync(interfRoot)) {
27
- if (entry === COMPILED_RUNTIME_DIR ||
28
- entry === COMPILED_TEST_DIR ||
29
- entry === COMPILED_WORKFLOW_DIR ||
30
- entry === COMPILED_CONFIG_FILE) {
31
- continue;
32
- }
33
- changed = movePathIfMissing(join(interfRoot, entry), join(runtimeRoot, entry)) || changed;
34
- }
35
- return changed;
36
- }
37
- export function compiledNeedsLegacyLayoutNormalization(compiledPath) {
38
- if (existsSync(join(compiledPath, LEGACY_COMPILED_CONFIG_FILE)) &&
39
- !existsSync(compiledInterfConfigPath(compiledPath))) {
40
- return true;
41
- }
42
- if (!existsSync(join(compiledPath, COMPILED_INTERF_DIR)))
43
- return false;
44
- if (existsSync(join(compiledPath, LEGACY_WORKFLOW_DIR)) &&
45
- !existsSync(workflowPackagePathForCompiled(compiledPath))) {
46
- return true;
47
- }
48
- for (const entry of readdirSync(join(compiledPath, COMPILED_INTERF_DIR))) {
49
- if (entry === COMPILED_RUNTIME_DIR ||
50
- entry === COMPILED_TEST_DIR ||
51
- entry === COMPILED_WORKFLOW_DIR ||
52
- entry === COMPILED_CONFIG_FILE) {
53
- continue;
54
- }
55
- if (!existsSync(join(compiledRuntimeRoot(compiledPath), entry))) {
56
- return true;
57
- }
58
- }
59
- return false;
60
- }
@@ -1 +0,0 @@
1
- export declare function writeObsidianDefaults(dirPath: string, type: "compiled"): void;
@@ -1,15 +0,0 @@
1
- import { mkdirSync, writeFileSync, } from "node:fs";
2
- import { join } from "node:path";
3
- export function writeObsidianDefaults(dirPath, type) {
4
- const obsidianDir = join(dirPath, ".obsidian");
5
- mkdirSync(obsidianDir, { recursive: true });
6
- const graphSettings = {
7
- "collapse-filter": true,
8
- search: 'path:"summaries" OR path:"knowledge" OR path:"home"',
9
- showTags: false,
10
- showAttachments: false,
11
- hideUnresolved: true,
12
- showOrphans: false,
13
- };
14
- writeFileSync(join(obsidianDir, "graph.json"), JSON.stringify(graphSettings, null, 2) + "\n");
15
- }
@@ -1,17 +0,0 @@
1
- export interface SummarizeTarget {
2
- source: string;
3
- summary: string | null;
4
- output: string;
5
- reason: "pending" | "missing_synth" | "changed" | "full_pass";
6
- }
7
- export interface SummarizePlan {
8
- generatedAt: string;
9
- sourceCount: number;
10
- summaryCount: number;
11
- pendingCount: number;
12
- targetCount: number;
13
- targets: SummarizeTarget[];
14
- }
15
- export declare const SUMMARIZE_PLAN_RELATIVE_PATH: string;
16
- export declare function buildSummarizePlan(sourcePath: string, compiledPath: string, mode?: "pending" | "all"): SummarizePlan;
17
- export declare function writeSummarizePlan(compiledPath: string, plan: SummarizePlan): string;
@@ -1,124 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2
- import { join, relative } from "node:path";
3
- import { listFilesRecursive } from "./filesystem.js";
4
- import { builtinCompiledZoneRelativePath, compiledSummariesPath, BUILTIN_COMPILED_ZONE_IDS, } from "./compiled-schema.js";
5
- import { discoverSourceFiles } from "./discovery.js";
6
- import { loadState } from "./state.js";
7
- import { parseJsonFrontmatter } from "./parse.js";
8
- import { compiledRuntimeRoot } from "./compiled-paths.js";
9
- export const SUMMARIZE_PLAN_RELATIVE_PATH = join(".interf", "runtime", "summarize-targets.json");
10
- export function buildSummarizePlan(sourcePath, compiledPath, mode = "pending") {
11
- const discovery = discoverSourceFiles(sourcePath, compiledPath);
12
- const sourceFiles = discovery.sourceFiles;
13
- const summariesDir = compiledSummariesPath(compiledPath);
14
- const summaryFiles = listSummaryFiles(summariesDir, compiledPath);
15
- const state = loadState(compiledPath);
16
- const pending = new Set((state?.pending ?? []).filter((value) => typeof value === "string" && sourceFiles.includes(value)));
17
- const summaryIndex = new Map();
18
- for (const summary of summaryFiles) {
19
- const source = readSourceReference(join(compiledPath, summary));
20
- if (source)
21
- summaryIndex.set(source, summary);
22
- }
23
- const targets = new Map();
24
- if (mode === "all") {
25
- for (const src of sourceFiles) {
26
- targets.set(src, {
27
- source: src,
28
- summary: summaryIndex.get(src) ?? null,
29
- output: defaultSummaryPath(src),
30
- reason: "full_pass",
31
- });
32
- }
33
- return {
34
- generatedAt: new Date().toISOString(),
35
- sourceCount: sourceFiles.length,
36
- summaryCount: summaryFiles.length,
37
- pendingCount: pending.size,
38
- targetCount: targets.size,
39
- targets: Array.from(targets.values()).sort((a, b) => a.source.localeCompare(b.source)),
40
- };
41
- }
42
- for (const src of pending) {
43
- targets.set(src, {
44
- source: src,
45
- summary: summaryIndex.get(src) ?? null,
46
- output: defaultSummaryPath(src),
47
- reason: "pending",
48
- });
49
- }
50
- for (const src of sourceFiles) {
51
- if (summaryIndex.has(src))
52
- continue;
53
- if (targets.has(src))
54
- continue;
55
- targets.set(src, {
56
- source: src,
57
- summary: null,
58
- output: defaultSummaryPath(src),
59
- reason: "missing_synth",
60
- });
61
- }
62
- // Detect changed source files (source newer than its summary)
63
- for (const [src, summary] of summaryIndex) {
64
- if (targets.has(src))
65
- continue;
66
- const sourceFile = join(sourcePath, src);
67
- const synthFile = join(compiledPath, summary);
68
- if (!existsSync(sourceFile) || !existsSync(synthFile))
69
- continue;
70
- try {
71
- const sourceMtime = statSync(sourceFile).mtimeMs;
72
- const synthMtime = statSync(synthFile).mtimeMs;
73
- if (sourceMtime > synthMtime) {
74
- targets.set(src, {
75
- source: src,
76
- summary,
77
- output: defaultSummaryPath(src),
78
- reason: "changed",
79
- });
80
- }
81
- }
82
- catch {
83
- continue;
84
- }
85
- }
86
- return {
87
- generatedAt: new Date().toISOString(),
88
- sourceCount: sourceFiles.length,
89
- summaryCount: summaryFiles.length,
90
- pendingCount: pending.size,
91
- targetCount: targets.size,
92
- targets: Array.from(targets.values()).sort((a, b) => a.source.localeCompare(b.source)),
93
- };
94
- }
95
- export function writeSummarizePlan(compiledPath, plan) {
96
- const planPath = join(compiledPath, SUMMARIZE_PLAN_RELATIVE_PATH);
97
- mkdirSync(compiledRuntimeRoot(compiledPath), { recursive: true });
98
- writeFileSync(planPath, JSON.stringify(plan, null, 2) + "\n");
99
- return planPath;
100
- }
101
- function listSummaryFiles(summariesDir, compiledPath) {
102
- return listFilesRecursive(summariesDir, (filePath) => filePath.endsWith(".md")).map((filePath) => relative(compiledPath, filePath));
103
- }
104
- function readSourceReference(synthPath) {
105
- if (!existsSync(synthPath))
106
- return null;
107
- const content = readFileSync(synthPath, "utf-8");
108
- const parsed = parseJsonFrontmatter(content);
109
- const source = typeof parsed?.frontmatter.source === "string"
110
- ? parsed.frontmatter.source
111
- : typeof parsed?.frontmatter.source_file === "string"
112
- ? parsed.frontmatter.source_file
113
- : typeof parsed?.frontmatter.raw === "string"
114
- ? parsed.frontmatter.raw
115
- : null;
116
- return source?.trim() ?? null;
117
- }
118
- function defaultSummaryPath(sourcePath) {
119
- const summariesRoot = builtinCompiledZoneRelativePath(BUILTIN_COMPILED_ZONE_IDS.SUMMARIES);
120
- if (sourcePath.endsWith(".md"))
121
- return `${summariesRoot}/${sourcePath}`;
122
- const replaced = sourcePath.replace(/\.[^.]+$/, ".md");
123
- return `${summariesRoot}/${replaced === sourcePath ? `${sourcePath}.md` : replaced}`;
124
- }
@@ -1,129 +0,0 @@
1
- export declare const COMPILED_CONTRACT_TYPES: readonly ["compiled-file-evidence", "compiled-knowledge-structure", "compiled-query-shape"];
2
- export type CompiledContractType = typeof COMPILED_CONTRACT_TYPES[number];
3
- export declare const COMPILED_ZONE_KINDS: readonly ["directory", "file", "runtime"];
4
- export type CompiledZoneKind = typeof COMPILED_ZONE_KINDS[number];
5
- export declare const COMPILED_CONTRACT_FAMILY_METADATA: {
6
- readonly "compiled-file-evidence": {
7
- readonly order: 0;
8
- readonly bundledSkill: "compile/stages/summarize";
9
- };
10
- readonly "compiled-knowledge-structure": {
11
- readonly order: 1;
12
- readonly bundledSkill: "compile/stages/structure";
13
- };
14
- readonly "compiled-query-shape": {
15
- readonly order: 2;
16
- readonly bundledSkill: "compile/stages/shape";
17
- };
18
- };
19
- export declare const BUILTIN_COMPILED_STAGE_IDS: {
20
- readonly SUMMARIZE: "summarize";
21
- readonly STRUCTURE: "structure";
22
- readonly SHAPE: "shape";
23
- };
24
- export type BuiltinCompiledStageId = typeof BUILTIN_COMPILED_STAGE_IDS[keyof typeof BUILTIN_COMPILED_STAGE_IDS];
25
- export declare const BUILTIN_COMPILED_ZONE_IDS: {
26
- readonly RAW: "raw";
27
- readonly SUMMARIES: "summaries";
28
- readonly KNOWLEDGE_ENTITIES: "knowledge-entities";
29
- readonly KNOWLEDGE_CLAIMS: "knowledge-claims";
30
- readonly KNOWLEDGE_INDEXES: "knowledge-indexes";
31
- readonly HOME: "home";
32
- readonly RUNTIME: "runtime";
33
- };
34
- export type BuiltinCompiledZoneId = typeof BUILTIN_COMPILED_ZONE_IDS[keyof typeof BUILTIN_COMPILED_ZONE_IDS];
35
- export interface BuiltinCompiledZoneSpec {
36
- id: BuiltinCompiledZoneId;
37
- path: string;
38
- kind: CompiledZoneKind;
39
- required: true;
40
- description: string;
41
- }
42
- export declare const BUILTIN_COMPILED_ZONE_SPECS: readonly [{
43
- readonly id: "raw";
44
- readonly path: "raw";
45
- readonly kind: "directory";
46
- readonly required: true;
47
- readonly description: "Compiled-local raw snapshot copied from the dataset for direct evidence and verification.";
48
- }, {
49
- readonly id: "summaries";
50
- readonly path: "summaries";
51
- readonly kind: "directory";
52
- readonly required: true;
53
- readonly description: "Per-file evidence notes produced by file-evidence stages.";
54
- }, {
55
- readonly id: "knowledge-entities";
56
- readonly path: "knowledge/entities";
57
- readonly kind: "directory";
58
- readonly required: true;
59
- readonly description: "Canonical entity notes produced by knowledge-structure stages.";
60
- }, {
61
- readonly id: "knowledge-claims";
62
- readonly path: "knowledge/claims";
63
- readonly kind: "directory";
64
- readonly required: true;
65
- readonly description: "Claim notes produced by knowledge-structure stages.";
66
- }, {
67
- readonly id: "knowledge-indexes";
68
- readonly path: "knowledge/indexes";
69
- readonly kind: "directory";
70
- readonly required: true;
71
- readonly description: "Retrieval indexes and navigation notes produced by structure and shape stages.";
72
- }, {
73
- readonly id: "home";
74
- readonly path: "home.md";
75
- readonly kind: "file";
76
- readonly required: true;
77
- readonly description: "Primary entrypoint note for agents using the compiled dataset.";
78
- }, {
79
- readonly id: "runtime";
80
- readonly path: ".interf/runtime";
81
- readonly kind: "runtime";
82
- readonly required: true;
83
- readonly description: "CLI-owned runtime state, health, stage contracts, and proof artifacts.";
84
- }];
85
- export interface BuiltinCompiledStageAccessPattern {
86
- id: BuiltinCompiledStageId;
87
- label: string;
88
- description: string;
89
- contractType: CompiledContractType;
90
- skillDir: string;
91
- reads: readonly BuiltinCompiledZoneId[];
92
- writes: readonly BuiltinCompiledZoneId[];
93
- }
94
- export declare const BUILTIN_COMPILED_STAGE_ACCESS_PATTERNS: readonly [{
95
- readonly id: "summarize";
96
- readonly label: "Summarize";
97
- readonly description: "Turn source files into per-file summaries.";
98
- readonly contractType: "compiled-file-evidence";
99
- readonly skillDir: "summarize";
100
- readonly reads: readonly ["raw", "runtime"];
101
- readonly writes: readonly ["summaries"];
102
- }, {
103
- readonly id: "structure";
104
- readonly label: "Structure";
105
- readonly description: "Build the cross-file knowledge structure from the summaries.";
106
- readonly contractType: "compiled-knowledge-structure";
107
- readonly skillDir: "structure";
108
- readonly reads: readonly ["summaries", "runtime"];
109
- readonly writes: readonly ["knowledge-entities", "knowledge-claims", "knowledge-indexes"];
110
- }, {
111
- readonly id: "shape";
112
- readonly label: "Shape";
113
- readonly description: "Shape the final compiled around the saved focus and truth checks.";
114
- readonly contractType: "compiled-query-shape";
115
- readonly skillDir: "shape";
116
- readonly reads: readonly ["raw", "summaries", "knowledge-entities", "knowledge-claims", "knowledge-indexes", "runtime"];
117
- readonly writes: readonly ["knowledge-indexes", "home"];
118
- }];
119
- export declare function listBuiltinCompiledZoneSpecs(): BuiltinCompiledZoneSpec[];
120
- export declare function listBuiltinCompiledFallbackStages(): Array<{
121
- id: BuiltinCompiledStageId;
122
- contract_type: CompiledContractType;
123
- reads: BuiltinCompiledZoneId[];
124
- writes: BuiltinCompiledZoneId[];
125
- }>;
126
- export declare function requiredCompiledZoneOwners<TStage extends {
127
- id: string;
128
- writes: readonly string[];
129
- }>(stages: readonly TStage[], zoneId: BuiltinCompiledZoneId): string[];
@@ -1,156 +0,0 @@
1
- export const COMPILED_CONTRACT_TYPES = [
2
- "compiled-file-evidence",
3
- "compiled-knowledge-structure",
4
- "compiled-query-shape",
5
- ];
6
- export const COMPILED_ZONE_KINDS = [
7
- "directory",
8
- "file",
9
- "runtime",
10
- ];
11
- export const COMPILED_CONTRACT_FAMILY_METADATA = {
12
- "compiled-file-evidence": {
13
- order: 0,
14
- bundledSkill: "compile/stages/summarize",
15
- },
16
- "compiled-knowledge-structure": {
17
- order: 1,
18
- bundledSkill: "compile/stages/structure",
19
- },
20
- "compiled-query-shape": {
21
- order: 2,
22
- bundledSkill: "compile/stages/shape",
23
- },
24
- };
25
- export const BUILTIN_COMPILED_STAGE_IDS = {
26
- SUMMARIZE: "summarize",
27
- STRUCTURE: "structure",
28
- SHAPE: "shape",
29
- };
30
- export const BUILTIN_COMPILED_ZONE_IDS = {
31
- RAW: "raw",
32
- SUMMARIES: "summaries",
33
- KNOWLEDGE_ENTITIES: "knowledge-entities",
34
- KNOWLEDGE_CLAIMS: "knowledge-claims",
35
- KNOWLEDGE_INDEXES: "knowledge-indexes",
36
- HOME: "home",
37
- RUNTIME: "runtime",
38
- };
39
- export const BUILTIN_COMPILED_ZONE_SPECS = [
40
- {
41
- id: BUILTIN_COMPILED_ZONE_IDS.RAW,
42
- path: "raw",
43
- kind: "directory",
44
- required: true,
45
- description: "Compiled-local raw snapshot copied from the dataset for direct evidence and verification.",
46
- },
47
- {
48
- id: BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
49
- path: "summaries",
50
- kind: "directory",
51
- required: true,
52
- description: "Per-file evidence notes produced by file-evidence stages.",
53
- },
54
- {
55
- id: BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES,
56
- path: "knowledge/entities",
57
- kind: "directory",
58
- required: true,
59
- description: "Canonical entity notes produced by knowledge-structure stages.",
60
- },
61
- {
62
- id: BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS,
63
- path: "knowledge/claims",
64
- kind: "directory",
65
- required: true,
66
- description: "Claim notes produced by knowledge-structure stages.",
67
- },
68
- {
69
- id: BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
70
- path: "knowledge/indexes",
71
- kind: "directory",
72
- required: true,
73
- description: "Retrieval indexes and navigation notes produced by structure and shape stages.",
74
- },
75
- {
76
- id: BUILTIN_COMPILED_ZONE_IDS.HOME,
77
- path: "home.md",
78
- kind: "file",
79
- required: true,
80
- description: "Primary entrypoint note for agents using the compiled dataset.",
81
- },
82
- {
83
- id: BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
84
- path: ".interf/runtime",
85
- kind: "runtime",
86
- required: true,
87
- description: "CLI-owned runtime state, health, stage contracts, and proof artifacts.",
88
- },
89
- ];
90
- export const BUILTIN_COMPILED_STAGE_ACCESS_PATTERNS = [
91
- {
92
- id: BUILTIN_COMPILED_STAGE_IDS.SUMMARIZE,
93
- label: "Summarize",
94
- description: "Turn source files into per-file summaries.",
95
- contractType: "compiled-file-evidence",
96
- skillDir: "summarize",
97
- reads: [
98
- BUILTIN_COMPILED_ZONE_IDS.RAW,
99
- BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
100
- ],
101
- writes: [
102
- BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
103
- ],
104
- },
105
- {
106
- id: BUILTIN_COMPILED_STAGE_IDS.STRUCTURE,
107
- label: "Structure",
108
- description: "Build the cross-file knowledge structure from the summaries.",
109
- contractType: "compiled-knowledge-structure",
110
- skillDir: "structure",
111
- reads: [
112
- BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
113
- BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
114
- ],
115
- writes: [
116
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES,
117
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS,
118
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
119
- ],
120
- },
121
- {
122
- id: BUILTIN_COMPILED_STAGE_IDS.SHAPE,
123
- label: "Shape",
124
- description: "Shape the final compiled around the saved focus and truth checks.",
125
- contractType: "compiled-query-shape",
126
- skillDir: "shape",
127
- reads: [
128
- BUILTIN_COMPILED_ZONE_IDS.RAW,
129
- BUILTIN_COMPILED_ZONE_IDS.SUMMARIES,
130
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES,
131
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS,
132
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
133
- BUILTIN_COMPILED_ZONE_IDS.RUNTIME,
134
- ],
135
- writes: [
136
- BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES,
137
- BUILTIN_COMPILED_ZONE_IDS.HOME,
138
- ],
139
- },
140
- ];
141
- export function listBuiltinCompiledZoneSpecs() {
142
- return BUILTIN_COMPILED_ZONE_SPECS.map((zone) => ({ ...zone }));
143
- }
144
- export function listBuiltinCompiledFallbackStages() {
145
- return BUILTIN_COMPILED_STAGE_ACCESS_PATTERNS.map((stage) => ({
146
- id: stage.id,
147
- contract_type: stage.contractType,
148
- reads: [...stage.reads],
149
- writes: [...stage.writes],
150
- }));
151
- }
152
- export function requiredCompiledZoneOwners(stages, zoneId) {
153
- return Array.from(new Set(stages
154
- .filter((stage) => stage.writes.includes(zoneId))
155
- .map((stage) => stage.id)));
156
- }