@interf/compiler 0.4.1 → 0.5.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 (162) hide show
  1. package/README.md +70 -66
  2. package/builtin-workflows/interf/README.md +6 -6
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
  6. package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
  7. package/builtin-workflows/interf/improve/SKILL.md +3 -3
  8. package/builtin-workflows/interf/use/query/SKILL.md +2 -2
  9. package/builtin-workflows/interf/workflow.json +42 -31
  10. package/dist/commands/check-draft.d.ts +19 -0
  11. package/dist/commands/check-draft.js +110 -0
  12. package/dist/commands/compile-controller.d.ts +4 -4
  13. package/dist/commands/compile-controller.js +117 -81
  14. package/dist/commands/compile.d.ts +5 -5
  15. package/dist/commands/compile.js +61 -62
  16. package/dist/commands/compiled-flow.d.ts +23 -0
  17. package/dist/commands/compiled-flow.js +112 -0
  18. package/dist/commands/create-workflow-wizard.d.ts +3 -3
  19. package/dist/commands/create-workflow-wizard.js +11 -11
  20. package/dist/commands/create.d.ts +2 -2
  21. package/dist/commands/create.js +50 -57
  22. package/dist/commands/default.js +2 -2
  23. package/dist/commands/executor-flow.d.ts +20 -1
  24. package/dist/commands/executor-flow.js +67 -7
  25. package/dist/commands/init.js +242 -289
  26. package/dist/commands/list.js +14 -10
  27. package/dist/commands/reset.js +6 -6
  28. package/dist/commands/source-config-wizard.d.ts +12 -8
  29. package/dist/commands/source-config-wizard.js +356 -119
  30. package/dist/commands/status.js +49 -26
  31. package/dist/commands/test-flow.d.ts +23 -10
  32. package/dist/commands/test-flow.js +274 -65
  33. package/dist/commands/test.d.ts +7 -1
  34. package/dist/commands/test.js +264 -65
  35. package/dist/commands/verify.js +23 -14
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +4 -4
  38. package/dist/lib/agent-args.js +2 -1
  39. package/dist/lib/agent-constants.js +1 -1
  40. package/dist/lib/agent-render.js +4 -4
  41. package/dist/lib/agent-shells.d.ts +8 -8
  42. package/dist/lib/agent-shells.js +231 -142
  43. package/dist/lib/{workflow-abi.d.ts → builtin-compiled-workflow.d.ts} +37 -46
  44. package/dist/lib/builtin-compiled-workflow.js +153 -0
  45. package/dist/lib/compiled-compile.d.ts +52 -0
  46. package/dist/lib/compiled-compile.js +274 -0
  47. package/dist/lib/compiled-home.d.ts +5 -0
  48. package/dist/lib/compiled-home.js +32 -0
  49. package/dist/lib/compiled-paths.d.ts +39 -0
  50. package/dist/lib/compiled-paths.js +103 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +9 -8
  52. package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
  53. package/dist/lib/compiled-reset.d.ts +1 -0
  54. package/dist/lib/compiled-reset.js +44 -0
  55. package/dist/lib/compiled-schema.d.ts +27 -0
  56. package/dist/lib/compiled-schema.js +110 -0
  57. package/dist/lib/config.d.ts +0 -1
  58. package/dist/lib/config.js +0 -1
  59. package/dist/lib/discovery.d.ts +1 -1
  60. package/dist/lib/discovery.js +3 -3
  61. package/dist/lib/interf-bootstrap.d.ts +1 -1
  62. package/dist/lib/interf-bootstrap.js +4 -4
  63. package/dist/lib/interf-detect.d.ts +9 -10
  64. package/dist/lib/interf-detect.js +70 -59
  65. package/dist/lib/interf-scaffold.d.ts +2 -2
  66. package/dist/lib/interf-scaffold.js +90 -57
  67. package/dist/lib/interf-workflow-package.d.ts +3 -3
  68. package/dist/lib/interf-workflow-package.js +30 -30
  69. package/dist/lib/interf.d.ts +5 -5
  70. package/dist/lib/interf.js +4 -4
  71. package/dist/lib/local-workflows.d.ts +4 -4
  72. package/dist/lib/local-workflows.js +35 -70
  73. package/dist/lib/obsidian.d.ts +1 -1
  74. package/dist/lib/parse.js +92 -1
  75. package/dist/lib/project-paths.d.ts +11 -0
  76. package/dist/lib/project-paths.js +32 -0
  77. package/dist/lib/runtime-acceptance.d.ts +7 -1
  78. package/dist/lib/runtime-acceptance.js +194 -59
  79. package/dist/lib/runtime-contracts.d.ts +2 -4
  80. package/dist/lib/runtime-contracts.js +17 -161
  81. package/dist/lib/runtime-inventory.d.ts +7 -0
  82. package/dist/lib/runtime-inventory.js +29 -0
  83. package/dist/lib/runtime-paths.js +5 -5
  84. package/dist/lib/runtime-prompt.js +7 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +94 -184
  87. package/dist/lib/runtime-runs.js +25 -119
  88. package/dist/lib/runtime-types.d.ts +10 -19
  89. package/dist/lib/runtime.d.ts +2 -2
  90. package/dist/lib/runtime.js +1 -1
  91. package/dist/lib/schema.d.ts +169 -153
  92. package/dist/lib/schema.js +116 -164
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +159 -122
  95. package/dist/lib/state-artifacts.d.ts +5 -5
  96. package/dist/lib/state-artifacts.js +8 -8
  97. package/dist/lib/state-health.d.ts +4 -4
  98. package/dist/lib/state-health.js +110 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +21 -102
  101. package/dist/lib/state-paths.js +5 -5
  102. package/dist/lib/state-view.d.ts +4 -4
  103. package/dist/lib/state-view.js +52 -55
  104. package/dist/lib/state.d.ts +5 -5
  105. package/dist/lib/state.js +4 -4
  106. package/dist/lib/summarize-plan.d.ts +3 -2
  107. package/dist/lib/summarize-plan.js +19 -21
  108. package/dist/lib/test-execution.js +9 -9
  109. package/dist/lib/test-matrices.d.ts +3 -3
  110. package/dist/lib/test-matrices.js +6 -6
  111. package/dist/lib/test-paths.d.ts +4 -4
  112. package/dist/lib/test-paths.js +26 -11
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +32 -38
  115. package/dist/lib/test-specs.js +1 -1
  116. package/dist/lib/test-targets.d.ts +2 -2
  117. package/dist/lib/test-targets.js +11 -11
  118. package/dist/lib/test-types.d.ts +1 -1
  119. package/dist/lib/test.d.ts +1 -1
  120. package/dist/lib/test.js +1 -1
  121. package/dist/lib/util.d.ts +2 -0
  122. package/dist/lib/util.js +14 -1
  123. package/dist/lib/validate-compiled.d.ts +27 -0
  124. package/dist/lib/validate-compiled.js +238 -0
  125. package/dist/lib/validate-helpers.d.ts +0 -8
  126. package/dist/lib/validate-helpers.js +0 -30
  127. package/dist/lib/validate.d.ts +6 -4
  128. package/dist/lib/validate.js +76 -27
  129. package/dist/lib/workflow-definitions.d.ts +12 -11
  130. package/dist/lib/workflow-definitions.js +45 -55
  131. package/dist/lib/workflow-helpers.d.ts +2 -3
  132. package/dist/lib/workflow-helpers.js +9 -13
  133. package/dist/lib/workflow-improvement.d.ts +3 -3
  134. package/dist/lib/workflow-improvement.js +48 -48
  135. package/dist/lib/workflow-primitives.d.ts +2 -0
  136. package/dist/lib/workflow-primitives.js +5 -0
  137. package/dist/lib/workflow-review-paths.d.ts +3 -3
  138. package/dist/lib/workflow-review-paths.js +11 -11
  139. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  140. package/dist/lib/workflow-stage-runner.js +8 -8
  141. package/dist/lib/workflows.d.ts +9 -9
  142. package/dist/lib/workflows.js +15 -17
  143. package/package.json +13 -12
  144. package/dist/commands/workspace-flow.d.ts +0 -23
  145. package/dist/commands/workspace-flow.js +0 -109
  146. package/dist/lib/registry.d.ts +0 -16
  147. package/dist/lib/registry.js +0 -65
  148. package/dist/lib/validate-workspace.d.ts +0 -121
  149. package/dist/lib/validate-workspace.js +0 -407
  150. package/dist/lib/workflow-abi.js +0 -181
  151. package/dist/lib/workspace-compile.d.ts +0 -54
  152. package/dist/lib/workspace-compile.js +0 -476
  153. package/dist/lib/workspace-home.d.ts +0 -5
  154. package/dist/lib/workspace-home.js +0 -32
  155. package/dist/lib/workspace-layout.d.ts +0 -2
  156. package/dist/lib/workspace-layout.js +0 -60
  157. package/dist/lib/workspace-paths.d.ts +0 -41
  158. package/dist/lib/workspace-paths.js +0 -107
  159. package/dist/lib/workspace-reset.d.ts +0 -1
  160. package/dist/lib/workspace-reset.js +0 -43
  161. package/dist/lib/workspace-schema.d.ts +0 -17
  162. package/dist/lib/workspace-schema.js +0 -74
@@ -1,13 +1,15 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { readInterfConfig, refreshWorkspaceBootstrapGuidance, resolveSourceControlPath, } from "./interf.js";
4
- import { seedWorkspaceWorkflowPackage } from "./interf-workflow-package.js";
3
+ import { join, relative, resolve, sep } from "node:path";
4
+ import { readInterfConfig, refreshCompiledBootstrapGuidance, } from "./interf.js";
5
+ import { seedCompiledWorkflowPackage } from "./interf-workflow-package.js";
5
6
  import { readJsonFileWithSchema } from "./parse.js";
6
- import { getWorkspaceWorkflow } from "./workflow-definitions.js";
7
+ import { getCompiledWorkflow } from "./workflow-definitions.js";
7
8
  import { SourceFolderConfigSchema, } from "./schema.js";
8
9
  import { slugify } from "./util.js";
9
- import { defaultControlPathForWorkspace, workspaceInterfConfigPath, workspaceInterfRoot, } from "./workspace-paths.js";
10
- export const SOURCE_FOLDER_CONFIG_FILE = "interf.config.json";
10
+ import { assertPathWithinRoot } from "./util.js";
11
+ import { defaultControlPathForCompiled, resolveSourceControlPathForCompiled, compiledInterfConfigPath, compiledInterfRoot, } from "./compiled-paths.js";
12
+ export const SOURCE_FOLDER_CONFIG_FILE = "interf.json";
11
13
  function sourceConfigPath(sourcePath) {
12
14
  return join(sourcePath, SOURCE_FOLDER_CONFIG_FILE);
13
15
  }
@@ -31,17 +33,29 @@ function normalizeTruthChecks(cases) {
31
33
  };
32
34
  });
33
35
  }
36
+ export function fingerprintTruthChecks(checks) {
37
+ const normalized = checks.map((check) => ({
38
+ question: check.question.trim(),
39
+ ...(check.answer ? { answer: check.answer.trim() } : {}),
40
+ ...(check.strictness ? { strictness: check.strictness.trim() } : {}),
41
+ ...(check.expect ? { expect: check.expect } : {}),
42
+ }));
43
+ return createHash("sha256")
44
+ .update(JSON.stringify(normalized))
45
+ .digest("hex")
46
+ .slice(0, 16);
47
+ }
34
48
  export function loadSourceFolderConfig(sourcePath) {
35
49
  const filePath = sourceConfigPath(sourcePath);
36
50
  if (!existsSync(filePath))
37
51
  return null;
38
- return readJsonFileWithSchema(filePath, "source-folder config", SourceFolderConfigSchema);
52
+ return readJsonFileWithSchema(filePath, "Interf project config", SourceFolderConfigSchema);
39
53
  }
40
- export function listSourceWorkspaceConfigs(config) {
41
- return config?.workspaces ?? [];
54
+ export function listSourceDatasetConfigs(config) {
55
+ return config?.datasets ?? [];
42
56
  }
43
- export function resolveWorkspaceCompileMaxAttempts(workspaceConfig, override = null) {
44
- const configured = override ?? workspaceConfig.max_attempts ?? null;
57
+ export function resolveDatasetCompileMaxAttempts(datasetConfig, override = null) {
58
+ const configured = override ?? datasetConfig.max_attempts ?? null;
45
59
  if (configured == null)
46
60
  return null;
47
61
  const normalized = Math.trunc(configured);
@@ -49,8 +63,8 @@ export function resolveWorkspaceCompileMaxAttempts(workspaceConfig, override = n
49
63
  return 1;
50
64
  return Math.min(5, normalized);
51
65
  }
52
- export function resolveWorkspaceCompileMaxLoops(workspaceConfig, override = null) {
53
- const configured = override ?? workspaceConfig.max_loops ?? null;
66
+ export function resolveDatasetCompileMaxLoops(datasetConfig, override = null) {
67
+ const configured = override ?? datasetConfig.max_loops ?? null;
54
68
  if (configured == null)
55
69
  return null;
56
70
  const normalized = Math.trunc(configured);
@@ -58,83 +72,85 @@ export function resolveWorkspaceCompileMaxLoops(workspaceConfig, override = null
58
72
  return 1;
59
73
  return Math.min(3, normalized);
60
74
  }
61
- export function getDefaultSourceWorkspaceConfig(config) {
62
- const workspaces = listSourceWorkspaceConfigs(config);
63
- return workspaces[0] ?? null;
75
+ export function getDefaultSourceDatasetConfig(config) {
76
+ const datasets = listSourceDatasetConfigs(config);
77
+ return datasets[0] ?? null;
64
78
  }
65
- export function findSourceWorkspaceConfig(config, workspaceName) {
66
- return listSourceWorkspaceConfigs(config).find((workspace) => workspace.name === workspaceName) ?? null;
79
+ export function findSourceDatasetConfig(config, datasetName) {
80
+ return listSourceDatasetConfigs(config).find((dataset) => dataset.name === datasetName) ?? null;
67
81
  }
68
- function toWritableSourceFolderConfig(config) {
69
- const workspaces = config?.workspaces ?? [];
70
- if (workspaces.length > 0) {
82
+ function toWritableSourceProjectConfig(config) {
83
+ const datasets = config?.datasets ?? [];
84
+ if (datasets.length > 0) {
71
85
  return {
72
- workspaces: workspaces.map((workspace) => ({
73
- name: workspace.name,
74
- ...(workspace.about ? { about: workspace.about } : {}),
75
- ...(workspace.workflow && workspace.workflow !== "interf" ? { workflow: workspace.workflow } : {}),
76
- ...(typeof workspace.max_attempts === "number" ? { max_attempts: workspace.max_attempts } : {}),
77
- ...(typeof workspace.max_loops === "number" ? { max_loops: workspace.max_loops } : {}),
78
- checks: workspace.checks,
79
- })),
86
+ datasets: datasets.map((dataset) => toWritableSourceDatasetConfig(dataset)),
80
87
  };
81
88
  }
82
89
  return {};
83
90
  }
91
+ function toWritableSourceDatasetConfig(dataset) {
92
+ return {
93
+ name: dataset.name,
94
+ ...(dataset.path && dataset.path !== "." ? { path: dataset.path } : {}),
95
+ ...(dataset.about ? { about: dataset.about } : {}),
96
+ ...(dataset.workflow && dataset.workflow !== "interf" ? { workflow: dataset.workflow } : {}),
97
+ ...(typeof dataset.max_attempts === "number" ? { max_attempts: dataset.max_attempts } : {}),
98
+ ...(typeof dataset.max_loops === "number" ? { max_loops: dataset.max_loops } : {}),
99
+ checks: dataset.checks,
100
+ };
101
+ }
84
102
  export function saveSourceFolderConfig(sourcePath, config) {
85
- writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceFolderConfig(config), null, 2) + "\n");
103
+ writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceProjectConfig(config), null, 2) + "\n");
86
104
  }
87
- export function appendSourceWorkspaceChecks(sourcePath, workspaceName, checks) {
105
+ export function appendSourceDatasetChecks(sourcePath, datasetName, checks) {
88
106
  const existing = loadSourceFolderConfig(sourcePath);
89
- const currentWorkspace = findSourceWorkspaceConfig(existing, workspaceName);
90
- const otherWorkspaces = listSourceWorkspaceConfigs(existing).filter((workspace) => workspace.name !== workspaceName);
91
- const currentChecks = currentWorkspace?.checks ?? [];
107
+ const currentDataset = findSourceDatasetConfig(existing, datasetName);
108
+ const otherDatasets = listSourceDatasetConfigs(existing).filter((dataset) => dataset.name !== datasetName);
109
+ const currentChecks = currentDataset?.checks ?? [];
110
+ const nextDataset = {
111
+ ...toWritableSourceDatasetConfig(currentDataset ?? {
112
+ name: datasetName,
113
+ path: ".",
114
+ checks: [],
115
+ }),
116
+ checks: [...currentChecks, ...checks],
117
+ };
92
118
  saveSourceFolderConfig(sourcePath, {
93
- workspaces: [
94
- {
95
- name: workspaceName,
96
- ...(currentWorkspace?.about ? { about: currentWorkspace.about } : {}),
97
- ...(currentWorkspace?.workflow ? { workflow: currentWorkspace.workflow } : {}),
98
- ...(typeof currentWorkspace?.max_attempts === "number"
99
- ? { max_attempts: currentWorkspace.max_attempts }
100
- : {}),
101
- ...(typeof currentWorkspace?.max_loops === "number"
102
- ? { max_loops: currentWorkspace.max_loops }
103
- : {}),
104
- checks: [...currentChecks, ...checks],
105
- },
106
- ...otherWorkspaces,
119
+ datasets: [
120
+ nextDataset,
121
+ ...otherDatasets,
107
122
  ],
108
123
  });
109
124
  }
110
- export function upsertSourceWorkspaceConfig(sourcePath, workspaceConfig, options = {}) {
125
+ export function upsertSourceDatasetConfig(sourcePath, datasetConfig, options = {}) {
111
126
  const existing = loadSourceFolderConfig(sourcePath);
112
- const workspaces = listSourceWorkspaceConfigs(existing);
113
- const candidateNames = Array.from(new Set([workspaceConfig.name, options.matchName].filter((value) => Boolean(value))));
114
- const existingIndex = workspaces.findIndex((entry) => candidateNames.includes(entry.name));
127
+ const datasets = listSourceDatasetConfigs(existing);
128
+ const candidateNames = Array.from(new Set([datasetConfig.name, options.matchName].filter((value) => Boolean(value))));
129
+ const existingIndex = datasets.findIndex((entry) => candidateNames.includes(entry.name));
115
130
  if (existingIndex >= 0) {
116
- workspaces[existingIndex] = workspaceConfig;
131
+ datasets[existingIndex] = datasetConfig;
117
132
  }
118
133
  else {
119
- workspaces.push(workspaceConfig);
134
+ datasets.push(datasetConfig);
120
135
  }
121
136
  saveSourceFolderConfig(sourcePath, {
122
- workspaces,
137
+ datasets,
123
138
  });
124
139
  }
125
- export function workspaceMaxAttempts(maxAttempts) {
140
+ export function compiledMaxAttempts(maxAttempts) {
126
141
  if (maxAttempts == null)
127
142
  return undefined;
128
- return resolveWorkspaceCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
143
+ return resolveDatasetCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
129
144
  }
130
- export function workspaceMaxLoops(maxLoops) {
145
+ export function compiledMaxLoops(maxLoops) {
131
146
  if (maxLoops == null)
132
147
  return undefined;
133
- return resolveWorkspaceCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
148
+ return resolveDatasetCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
134
149
  }
135
- export function sourceWorkspaceConfigFromInterfConfig(config) {
150
+ export function sourceDatasetConfigFromInterfConfig(config, datasetPath = ".") {
136
151
  return {
137
152
  name: config.name,
153
+ path: datasetPath,
138
154
  ...(config.about ? { about: config.about } : {}),
139
155
  ...(config.workflow ? { workflow: config.workflow } : {}),
140
156
  ...(typeof config.max_attempts === "number"
@@ -146,18 +162,27 @@ export function sourceWorkspaceConfigFromInterfConfig(config) {
146
162
  checks: config.checks ?? [],
147
163
  };
148
164
  }
149
- export function loadWorkspaceControlConfig(workspacePath) {
150
- const config = readInterfConfig(workspacePath);
151
- return config ? sourceWorkspaceConfigFromInterfConfig(config) : null;
165
+ export function loadCompiledDatasetConfig(compiledPath) {
166
+ const config = readInterfConfig(compiledPath);
167
+ if (!config)
168
+ return null;
169
+ const projectPath = resolveSourceControlPathForCompiled(compiledPath);
170
+ const datasetPath = typeof config.source?.dataset_path === "string" && config.source.dataset_path.length > 0
171
+ ? relative(projectPath, assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Compiled dataset source path")).split(sep).join("/") || "."
172
+ : ".";
173
+ return sourceDatasetConfigFromInterfConfig(config, datasetPath);
152
174
  }
153
- export function saveWorkspaceInterfConfig(workspacePath, config) {
154
- mkdirSync(workspaceInterfRoot(workspacePath), { recursive: true });
155
- writeFileSync(workspaceInterfConfigPath(workspacePath), JSON.stringify(config, null, 2) + "\n");
175
+ export function saveCompiledInterfConfig(compiledPath, config) {
176
+ mkdirSync(compiledInterfRoot(compiledPath), { recursive: true });
177
+ writeFileSync(compiledInterfConfigPath(compiledPath), JSON.stringify(config, null, 2) + "\n");
156
178
  return config;
157
179
  }
158
- export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath, workspaceConfig) {
159
- const current = readInterfConfig(workspacePath);
160
- const workflowId = workspaceConfig.workflow ?? current?.workflow ?? "interf";
180
+ export function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig) {
181
+ const current = readInterfConfig(compiledPath);
182
+ const projectPath = resolveSourceControlPathForCompiled(compiledPath);
183
+ const datasetAbsolutePath = resolve(projectPath, datasetConfig.path ?? ".");
184
+ const datasetRelativePath = relative(compiledPath, datasetAbsolutePath).split(sep).join("/") || ".";
185
+ const workflowId = datasetConfig.workflow ?? current?.workflow ?? "interf";
161
186
  const workflowChanged = current?.workflow !== undefined && current.workflow !== workflowId;
162
187
  const workflowOrigin = workflowChanged || !current?.workflow_origin
163
188
  ? {
@@ -169,88 +194,100 @@ export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath
169
194
  const nextConfig = {
170
195
  ...passthrough,
171
196
  ...(!current ? {
172
- type: "workspace",
197
+ type: "compiled",
173
198
  source: {
174
199
  path: "./raw",
175
200
  },
176
201
  } : {}),
177
- type: "workspace",
178
- name: workspaceConfig.name,
179
- ...(workspaceConfig.about ? { about: workspaceConfig.about } : {}),
202
+ type: "compiled",
203
+ name: datasetConfig.name,
204
+ ...(datasetConfig.about ? { about: datasetConfig.about } : {}),
180
205
  workflow: workflowId,
181
- ...(typeof workspaceConfig.max_attempts === "number"
182
- ? { max_attempts: workspaceConfig.max_attempts }
206
+ ...(typeof datasetConfig.max_attempts === "number"
207
+ ? { max_attempts: datasetConfig.max_attempts }
183
208
  : {}),
184
- ...(typeof workspaceConfig.max_loops === "number"
185
- ? { max_loops: workspaceConfig.max_loops }
209
+ ...(typeof datasetConfig.max_loops === "number"
210
+ ? { max_loops: datasetConfig.max_loops }
186
211
  : {}),
187
- checks: workspaceConfig.checks,
212
+ checks: datasetConfig.checks,
188
213
  workflow_origin: workflowOrigin,
189
214
  source: {
190
215
  path: current?.source?.path ?? "./raw",
191
- ...(current?.source?.control_path
192
- ? { control_path: current.source.control_path }
193
- : { control_path: defaultControlPathForWorkspace(workspacePath) }),
216
+ control_path: defaultControlPathForCompiled(compiledPath),
217
+ dataset_path: datasetRelativePath,
194
218
  },
195
219
  };
196
- const saved = saveWorkspaceInterfConfig(workspacePath, nextConfig);
220
+ const saved = saveCompiledInterfConfig(compiledPath, nextConfig);
197
221
  if (workflowChanged) {
198
- const sourcePath = resolveSourceControlPath(workspacePath);
199
- const selectedWorkflow = getWorkspaceWorkflow(workflowId, { sourcePath });
200
- seedWorkspaceWorkflowPackage({
201
- workspacePath,
222
+ const sourcePath = projectPath;
223
+ const selectedWorkflow = getCompiledWorkflow(workflowId, { sourcePath });
224
+ seedCompiledWorkflowPackage({
225
+ compiledPath,
202
226
  sourcePath,
203
227
  workflowId: selectedWorkflow.id,
204
228
  });
205
229
  }
206
- refreshWorkspaceBootstrapGuidance(workspacePath);
230
+ refreshCompiledBootstrapGuidance(compiledPath);
207
231
  return saved;
208
232
  }
233
+ function buildLoadedTestSpec(options) {
234
+ if (options.checks.length === 0)
235
+ return null;
236
+ const testId = options.id ?? slugify(options.name);
237
+ return {
238
+ id: options.targetType === "raw" ? `${testId}-raw` : testId,
239
+ filePath: options.filePath,
240
+ type: options.targetType,
241
+ name: options.name,
242
+ description: options.about ?? options.fallbackDescription,
243
+ cases: normalizeTruthChecks(options.checks),
244
+ };
245
+ }
209
246
  export function buildTestSpecFromSourceFolderConfig(options) {
210
- const { sourcePath, targetName, targetType = "workspace" } = options;
247
+ const { sourcePath, targetName, targetType = "compiled" } = options;
211
248
  const config = loadSourceFolderConfig(sourcePath);
212
249
  if (!config)
213
250
  return null;
214
- const workspaces = listSourceWorkspaceConfigs(config);
215
- if (workspaces.length === 0)
251
+ const datasets = listSourceDatasetConfigs(config);
252
+ if (datasets.length === 0)
216
253
  return null;
217
254
  const match = targetName
218
- ? workspaces.find((entry) => entry.name === targetName)
219
- : workspaces.length === 1
220
- ? workspaces[0]
221
- : getDefaultSourceWorkspaceConfig(config);
222
- const workspaceChecks = match?.checks ?? [];
223
- if (!match || workspaceChecks.length === 0)
255
+ ? datasets.find((entry) => entry.name === targetName)
256
+ : datasets.length === 1
257
+ ? datasets[0]
258
+ : getDefaultSourceDatasetConfig(config);
259
+ if (!match)
224
260
  return null;
225
261
  const configPath = sourceConfigPath(sourcePath);
226
- const testId = match.id ?? slugify(match.name);
227
- return {
228
- id: targetType === "raw" ? `${testId}-raw` : testId,
229
- filePath: targetType === "raw"
230
- ? `${configPath}#workspaces/${match.name}:raw`
231
- : `${configPath}#workspaces/${match.name}`,
232
- type: targetType,
262
+ return buildLoadedTestSpec({
263
+ id: match.id,
233
264
  name: match.name,
234
- description: match.about ?? `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
235
- cases: normalizeTruthChecks(workspaceChecks),
236
- };
265
+ about: match.about,
266
+ checks: match.checks,
267
+ targetType,
268
+ filePath: targetType === "raw"
269
+ ? `${configPath}#datasets/${match.name}:file-as-is`
270
+ : `${configPath}#datasets/${match.name}:compiled`,
271
+ fallbackDescription: `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
272
+ });
237
273
  }
238
- export function buildTestSpecFromWorkspaceConfig(options) {
239
- const { workspacePath, targetType = "workspace" } = options;
240
- const config = readInterfConfig(workspacePath);
241
- const workspaceChecks = config?.checks ?? [];
242
- if (!config || workspaceChecks.length === 0)
274
+ export function buildTestSpecFromCompiledDatasetConfig(options) {
275
+ const { compiledPath, targetType = "compiled" } = options;
276
+ const config = readInterfConfig(compiledPath);
277
+ const configPath = compiledInterfConfigPath(compiledPath);
278
+ if (!config)
243
279
  return null;
244
- const testId = slugify(config.name);
245
- const configPath = workspaceInterfConfigPath(workspacePath);
246
- return {
247
- id: targetType === "raw" ? `${testId}-raw` : testId,
248
- filePath: targetType === "raw"
249
- ? `${configPath}#checks:raw`
250
- : `${configPath}#checks:workspace`,
251
- type: targetType,
280
+ return buildLoadedTestSpec({
252
281
  name: config.name,
253
- description: config.about ?? "Derived from workspace truth checks.",
254
- cases: normalizeTruthChecks(workspaceChecks),
255
- };
282
+ about: config.about,
283
+ checks: config.checks ?? [],
284
+ targetType,
285
+ filePath: targetType === "raw"
286
+ ? `${configPath}#checks:file-as-is`
287
+ : `${configPath}#checks:compiled`,
288
+ fallbackDescription: "Derived from compiled-dataset truth checks.",
289
+ });
290
+ }
291
+ export function resolveSourceDatasetPath(projectPath, datasetConfig) {
292
+ return assertPathWithinRoot(projectPath, resolve(projectPath, datasetConfig.path ?? "."), "Dataset path");
256
293
  }
@@ -1,8 +1,8 @@
1
- import { type WorkspaceHealth, type WorkspaceRawSnapshot, type WorkspaceViewSpec } from "./schema.js";
2
- export declare function refreshWorkspaceArtifacts(dirPath: string, options?: {
1
+ import { type CompiledHealth, type CompiledRawSnapshot, type CompiledViewSpec } from "./schema.js";
2
+ export declare function refreshCompiledArtifacts(dirPath: string, options?: {
3
3
  ensureViewSpec?: boolean;
4
4
  }): {
5
- health: WorkspaceHealth;
6
- viewSpec?: WorkspaceViewSpec;
7
- rawSnapshot: WorkspaceRawSnapshot;
5
+ health: CompiledHealth;
6
+ viewSpec?: CompiledViewSpec;
7
+ rawSnapshot: CompiledRawSnapshot;
8
8
  };
@@ -1,13 +1,13 @@
1
- import { saveWorkspaceHealth, } from "./state-io.js";
2
- import { computeWorkspaceHealth, } from "./state-health.js";
3
- import { ensureWorkspaceRawSnapshot, ensureWorkspaceViewSpec, } from "./state-view.js";
4
- export function refreshWorkspaceArtifacts(dirPath, options) {
5
- const health = computeWorkspaceHealth(dirPath);
6
- saveWorkspaceHealth(dirPath, health);
7
- const rawSnapshot = ensureWorkspaceRawSnapshot(dirPath);
1
+ import { saveCompiledHealth, } from "./state-io.js";
2
+ import { computeCompiledHealth, } from "./state-health.js";
3
+ import { ensureCompiledRawSnapshot, ensureCompiledViewSpec, } from "./state-view.js";
4
+ export function refreshCompiledArtifacts(dirPath, options) {
5
+ const health = computeCompiledHealth(dirPath);
6
+ saveCompiledHealth(dirPath, health);
7
+ const rawSnapshot = ensureCompiledRawSnapshot(dirPath);
8
8
  let viewSpec;
9
9
  if (options?.ensureViewSpec) {
10
- viewSpec = ensureWorkspaceViewSpec(dirPath);
10
+ viewSpec = ensureCompiledViewSpec(dirPath);
11
11
  }
12
12
  return { health, viewSpec, rawSnapshot };
13
13
  }
@@ -1,4 +1,4 @@
1
- import { type WorkspaceHealth, type WorkspaceState, type WorkspaceStage, type RuntimeStatus } from "./schema.js";
2
- export declare function computeWorkspaceHealth(dirPath: string): WorkspaceHealth;
3
- export declare function resolveWorkspaceStatus(sourceTotal: number, summarized: number, toSummarize: number, toStructure: number, toShape: number, errors: number, state: WorkspaceState): RuntimeStatus;
4
- export declare function resolveWorkspaceStage(state: WorkspaceState, sourceTotal: number, summarized: number, toSummarize: number, toStructure: number, toShape: number, errors: number): WorkspaceStage;
1
+ import { type CompiledHealth, type CompiledStage, type RuntimeStatus } from "./schema.js";
2
+ export declare function computeCompiledHealth(dirPath: string): CompiledHealth;
3
+ export declare function resolveCompiledStatus(..._args: unknown[]): RuntimeStatus;
4
+ export declare function resolveCompiledStage(...args: unknown[]): CompiledStage;