@interf/compiler 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +71 -69
  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 +278 -58
  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/compiled-compile.d.ts +52 -0
  44. package/dist/lib/compiled-compile.js +274 -0
  45. package/dist/lib/compiled-home.d.ts +5 -0
  46. package/dist/lib/compiled-home.js +32 -0
  47. package/dist/lib/compiled-layout.d.ts +2 -0
  48. package/dist/lib/compiled-layout.js +60 -0
  49. package/dist/lib/compiled-paths.d.ts +41 -0
  50. package/dist/lib/compiled-paths.js +111 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
  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 +10 -10
  64. package/dist/lib/interf-detect.js +78 -56
  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 +13 -0
  76. package/dist/lib/project-paths.js +29 -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 +9 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +92 -171
  87. package/dist/lib/runtime-runs.js +30 -39
  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 +163 -140
  92. package/dist/lib/schema.js +163 -124
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +154 -116
  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 +108 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +77 -50
  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 +18 -16
  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 +16 -10
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +38 -31
  115. package/dist/lib/test-targets.d.ts +2 -2
  116. package/dist/lib/test-targets.js +11 -11
  117. package/dist/lib/test-types.d.ts +1 -1
  118. package/dist/lib/test.d.ts +1 -1
  119. package/dist/lib/test.js +1 -1
  120. package/dist/lib/util.d.ts +2 -0
  121. package/dist/lib/util.js +14 -1
  122. package/dist/lib/validate-compiled.d.ts +27 -0
  123. package/dist/lib/validate-compiled.js +236 -0
  124. package/dist/lib/validate-helpers.d.ts +0 -8
  125. package/dist/lib/validate-helpers.js +0 -30
  126. package/dist/lib/validate.d.ts +4 -4
  127. package/dist/lib/validate.js +49 -15
  128. package/dist/lib/workflow-abi.d.ts +37 -46
  129. package/dist/lib/workflow-abi.js +51 -76
  130. package/dist/lib/workflow-definitions.d.ts +11 -11
  131. package/dist/lib/workflow-definitions.js +36 -53
  132. package/dist/lib/workflow-helpers.d.ts +2 -3
  133. package/dist/lib/workflow-helpers.js +9 -13
  134. package/dist/lib/workflow-improvement.d.ts +3 -3
  135. package/dist/lib/workflow-improvement.js +48 -48
  136. package/dist/lib/workflow-review-paths.d.ts +3 -3
  137. package/dist/lib/workflow-review-paths.js +11 -11
  138. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  139. package/dist/lib/workflow-stage-runner.js +8 -8
  140. package/dist/lib/workflows.d.ts +9 -9
  141. package/dist/lib/workflows.js +15 -17
  142. package/package.json +10 -9
  143. package/dist/commands/workspace-flow.d.ts +0 -23
  144. package/dist/commands/workspace-flow.js +0 -109
  145. package/dist/lib/registry.d.ts +0 -16
  146. package/dist/lib/registry.js +0 -65
  147. package/dist/lib/validate-workspace.d.ts +0 -121
  148. package/dist/lib/validate-workspace.js +0 -407
  149. package/dist/lib/workspace-compile.d.ts +0 -54
  150. package/dist/lib/workspace-compile.js +0 -476
  151. package/dist/lib/workspace-home.d.ts +0 -5
  152. package/dist/lib/workspace-home.js +0 -32
  153. package/dist/lib/workspace-layout.d.ts +0 -2
  154. package/dist/lib/workspace-layout.js +0 -60
  155. package/dist/lib/workspace-paths.d.ts +0 -41
  156. package/dist/lib/workspace-paths.js +0 -107
  157. package/dist/lib/workspace-reset.d.ts +0 -1
  158. package/dist/lib/workspace-reset.js +0 -43
  159. package/dist/lib/workspace-schema.d.ts +0 -17
  160. 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,86 @@ 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,
86
+ datasets: datasets.map((dataset) => ({
87
+ name: dataset.name,
88
+ ...(dataset.path && dataset.path !== "." ? { path: dataset.path } : {}),
89
+ ...(dataset.about ? { about: dataset.about } : {}),
90
+ ...(dataset.workflow && dataset.workflow !== "interf" ? { workflow: dataset.workflow } : {}),
91
+ ...(typeof dataset.max_attempts === "number" ? { max_attempts: dataset.max_attempts } : {}),
92
+ ...(typeof dataset.max_loops === "number" ? { max_loops: dataset.max_loops } : {}),
93
+ checks: dataset.checks,
79
94
  })),
80
95
  };
81
96
  }
82
97
  return {};
83
98
  }
84
99
  export function saveSourceFolderConfig(sourcePath, config) {
85
- writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceFolderConfig(config), null, 2) + "\n");
100
+ writeFileSync(sourceConfigPath(sourcePath), JSON.stringify(toWritableSourceProjectConfig(config), null, 2) + "\n");
86
101
  }
87
- export function appendSourceWorkspaceChecks(sourcePath, workspaceName, checks) {
102
+ export function appendSourceDatasetChecks(sourcePath, datasetName, checks) {
88
103
  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 ?? [];
104
+ const currentDataset = findSourceDatasetConfig(existing, datasetName);
105
+ const otherDatasets = listSourceDatasetConfigs(existing).filter((dataset) => dataset.name !== datasetName);
106
+ const currentChecks = currentDataset?.checks ?? [];
92
107
  saveSourceFolderConfig(sourcePath, {
93
- workspaces: [
108
+ datasets: [
94
109
  {
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 }
110
+ name: datasetName,
111
+ path: currentDataset?.path ?? ".",
112
+ ...(currentDataset?.about ? { about: currentDataset.about } : {}),
113
+ ...(currentDataset?.workflow ? { workflow: currentDataset.workflow } : {}),
114
+ ...(typeof currentDataset?.max_attempts === "number"
115
+ ? { max_attempts: currentDataset.max_attempts }
100
116
  : {}),
101
- ...(typeof currentWorkspace?.max_loops === "number"
102
- ? { max_loops: currentWorkspace.max_loops }
117
+ ...(typeof currentDataset?.max_loops === "number"
118
+ ? { max_loops: currentDataset.max_loops }
103
119
  : {}),
104
120
  checks: [...currentChecks, ...checks],
105
121
  },
106
- ...otherWorkspaces,
122
+ ...otherDatasets,
107
123
  ],
108
124
  });
109
125
  }
110
- export function upsertSourceWorkspaceConfig(sourcePath, workspaceConfig, options = {}) {
126
+ export function upsertSourceDatasetConfig(sourcePath, datasetConfig, options = {}) {
111
127
  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));
128
+ const datasets = listSourceDatasetConfigs(existing);
129
+ const candidateNames = Array.from(new Set([datasetConfig.name, options.matchName].filter((value) => Boolean(value))));
130
+ const existingIndex = datasets.findIndex((entry) => candidateNames.includes(entry.name));
115
131
  if (existingIndex >= 0) {
116
- workspaces[existingIndex] = workspaceConfig;
132
+ datasets[existingIndex] = datasetConfig;
117
133
  }
118
134
  else {
119
- workspaces.push(workspaceConfig);
135
+ datasets.push(datasetConfig);
120
136
  }
121
137
  saveSourceFolderConfig(sourcePath, {
122
- workspaces,
138
+ datasets,
123
139
  });
124
140
  }
125
- export function workspaceMaxAttempts(maxAttempts) {
141
+ export function compiledMaxAttempts(maxAttempts) {
126
142
  if (maxAttempts == null)
127
143
  return undefined;
128
- return resolveWorkspaceCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
144
+ return resolveDatasetCompileMaxAttempts({ max_attempts: maxAttempts }, null) ?? 1;
129
145
  }
130
- export function workspaceMaxLoops(maxLoops) {
146
+ export function compiledMaxLoops(maxLoops) {
131
147
  if (maxLoops == null)
132
148
  return undefined;
133
- return resolveWorkspaceCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
149
+ return resolveDatasetCompileMaxLoops({ max_loops: maxLoops }, null) ?? 1;
134
150
  }
135
- export function sourceWorkspaceConfigFromInterfConfig(config) {
151
+ export function sourceDatasetConfigFromInterfConfig(config, datasetPath = ".") {
136
152
  return {
137
153
  name: config.name,
154
+ path: datasetPath,
138
155
  ...(config.about ? { about: config.about } : {}),
139
156
  ...(config.workflow ? { workflow: config.workflow } : {}),
140
157
  ...(typeof config.max_attempts === "number"
@@ -146,18 +163,27 @@ export function sourceWorkspaceConfigFromInterfConfig(config) {
146
163
  checks: config.checks ?? [],
147
164
  };
148
165
  }
149
- export function loadWorkspaceControlConfig(workspacePath) {
150
- const config = readInterfConfig(workspacePath);
151
- return config ? sourceWorkspaceConfigFromInterfConfig(config) : null;
166
+ export function loadCompiledDatasetConfig(compiledPath) {
167
+ const config = readInterfConfig(compiledPath);
168
+ if (!config)
169
+ return null;
170
+ const projectPath = resolveSourceControlPathForCompiled(compiledPath);
171
+ const datasetPath = typeof config.source?.dataset_path === "string" && config.source.dataset_path.length > 0
172
+ ? relative(projectPath, assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Compiled dataset source path")).split(sep).join("/") || "."
173
+ : ".";
174
+ return sourceDatasetConfigFromInterfConfig(config, datasetPath);
152
175
  }
153
- export function saveWorkspaceInterfConfig(workspacePath, config) {
154
- mkdirSync(workspaceInterfRoot(workspacePath), { recursive: true });
155
- writeFileSync(workspaceInterfConfigPath(workspacePath), JSON.stringify(config, null, 2) + "\n");
176
+ export function saveCompiledInterfConfig(compiledPath, config) {
177
+ mkdirSync(compiledInterfRoot(compiledPath), { recursive: true });
178
+ writeFileSync(compiledInterfConfigPath(compiledPath), JSON.stringify(config, null, 2) + "\n");
156
179
  return config;
157
180
  }
158
- export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath, workspaceConfig) {
159
- const current = readInterfConfig(workspacePath);
160
- const workflowId = workspaceConfig.workflow ?? current?.workflow ?? "interf";
181
+ export function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig) {
182
+ const current = readInterfConfig(compiledPath);
183
+ const projectPath = resolveSourceControlPathForCompiled(compiledPath);
184
+ const datasetAbsolutePath = resolve(projectPath, datasetConfig.path ?? ".");
185
+ const datasetRelativePath = relative(compiledPath, datasetAbsolutePath).split(sep).join("/") || ".";
186
+ const workflowId = datasetConfig.workflow ?? current?.workflow ?? "interf";
161
187
  const workflowChanged = current?.workflow !== undefined && current.workflow !== workflowId;
162
188
  const workflowOrigin = workflowChanged || !current?.workflow_origin
163
189
  ? {
@@ -169,88 +195,100 @@ export function syncWorkspaceInterfConfigFromSourceWorkspaceConfig(workspacePath
169
195
  const nextConfig = {
170
196
  ...passthrough,
171
197
  ...(!current ? {
172
- type: "workspace",
198
+ type: "compiled",
173
199
  source: {
174
200
  path: "./raw",
175
201
  },
176
202
  } : {}),
177
- type: "workspace",
178
- name: workspaceConfig.name,
179
- ...(workspaceConfig.about ? { about: workspaceConfig.about } : {}),
203
+ type: "compiled",
204
+ name: datasetConfig.name,
205
+ ...(datasetConfig.about ? { about: datasetConfig.about } : {}),
180
206
  workflow: workflowId,
181
- ...(typeof workspaceConfig.max_attempts === "number"
182
- ? { max_attempts: workspaceConfig.max_attempts }
207
+ ...(typeof datasetConfig.max_attempts === "number"
208
+ ? { max_attempts: datasetConfig.max_attempts }
183
209
  : {}),
184
- ...(typeof workspaceConfig.max_loops === "number"
185
- ? { max_loops: workspaceConfig.max_loops }
210
+ ...(typeof datasetConfig.max_loops === "number"
211
+ ? { max_loops: datasetConfig.max_loops }
186
212
  : {}),
187
- checks: workspaceConfig.checks,
213
+ checks: datasetConfig.checks,
188
214
  workflow_origin: workflowOrigin,
189
215
  source: {
190
216
  path: current?.source?.path ?? "./raw",
191
- ...(current?.source?.control_path
192
- ? { control_path: current.source.control_path }
193
- : { control_path: defaultControlPathForWorkspace(workspacePath) }),
217
+ control_path: defaultControlPathForCompiled(compiledPath),
218
+ dataset_path: datasetRelativePath,
194
219
  },
195
220
  };
196
- const saved = saveWorkspaceInterfConfig(workspacePath, nextConfig);
221
+ const saved = saveCompiledInterfConfig(compiledPath, nextConfig);
197
222
  if (workflowChanged) {
198
- const sourcePath = resolveSourceControlPath(workspacePath);
199
- const selectedWorkflow = getWorkspaceWorkflow(workflowId, { sourcePath });
200
- seedWorkspaceWorkflowPackage({
201
- workspacePath,
223
+ const sourcePath = projectPath;
224
+ const selectedWorkflow = getCompiledWorkflow(workflowId, { sourcePath });
225
+ seedCompiledWorkflowPackage({
226
+ compiledPath,
202
227
  sourcePath,
203
228
  workflowId: selectedWorkflow.id,
204
229
  });
205
230
  }
206
- refreshWorkspaceBootstrapGuidance(workspacePath);
231
+ refreshCompiledBootstrapGuidance(compiledPath);
207
232
  return saved;
208
233
  }
234
+ function buildLoadedTestSpec(options) {
235
+ if (options.checks.length === 0)
236
+ return null;
237
+ const testId = options.id ?? slugify(options.name);
238
+ return {
239
+ id: options.targetType === "raw" ? `${testId}-raw` : testId,
240
+ filePath: options.filePath,
241
+ type: options.targetType,
242
+ name: options.name,
243
+ description: options.about ?? options.fallbackDescription,
244
+ cases: normalizeTruthChecks(options.checks),
245
+ };
246
+ }
209
247
  export function buildTestSpecFromSourceFolderConfig(options) {
210
- const { sourcePath, targetName, targetType = "workspace" } = options;
248
+ const { sourcePath, targetName, targetType = "compiled" } = options;
211
249
  const config = loadSourceFolderConfig(sourcePath);
212
250
  if (!config)
213
251
  return null;
214
- const workspaces = listSourceWorkspaceConfigs(config);
215
- if (workspaces.length === 0)
252
+ const datasets = listSourceDatasetConfigs(config);
253
+ if (datasets.length === 0)
216
254
  return null;
217
255
  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)
256
+ ? datasets.find((entry) => entry.name === targetName)
257
+ : datasets.length === 1
258
+ ? datasets[0]
259
+ : getDefaultSourceDatasetConfig(config);
260
+ if (!match)
224
261
  return null;
225
262
  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,
263
+ return buildLoadedTestSpec({
264
+ id: match.id,
233
265
  name: match.name,
234
- description: match.about ?? `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
235
- cases: normalizeTruthChecks(workspaceChecks),
236
- };
266
+ about: match.about,
267
+ checks: match.checks,
268
+ targetType,
269
+ filePath: targetType === "raw"
270
+ ? `${configPath}#datasets/${match.name}:file-as-is`
271
+ : `${configPath}#datasets/${match.name}:compiled`,
272
+ fallbackDescription: `Derived from dataset truth checks in ${SOURCE_FOLDER_CONFIG_FILE}`,
273
+ });
237
274
  }
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)
275
+ export function buildTestSpecFromCompiledDatasetConfig(options) {
276
+ const { compiledPath, targetType = "compiled" } = options;
277
+ const config = readInterfConfig(compiledPath);
278
+ const configPath = compiledInterfConfigPath(compiledPath);
279
+ if (!config)
243
280
  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,
281
+ return buildLoadedTestSpec({
252
282
  name: config.name,
253
- description: config.about ?? "Derived from workspace truth checks.",
254
- cases: normalizeTruthChecks(workspaceChecks),
255
- };
283
+ about: config.about,
284
+ checks: config.checks ?? [],
285
+ targetType,
286
+ filePath: targetType === "raw"
287
+ ? `${configPath}#checks:file-as-is`
288
+ : `${configPath}#checks:compiled`,
289
+ fallbackDescription: "Derived from compiled-dataset truth checks.",
290
+ });
291
+ }
292
+ export function resolveSourceDatasetPath(projectPath, datasetConfig) {
293
+ return assertPathWithinRoot(projectPath, resolve(projectPath, datasetConfig.path ?? "."), "Dataset path");
256
294
  }
@@ -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;