@interf/compiler 0.9.4 → 0.13.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 (222) hide show
  1. package/README.md +96 -91
  2. package/TRADEMARKS.md +2 -13
  3. package/agent-skills/interf-actions/SKILL.md +97 -32
  4. package/agent-skills/interf-actions/references/cli.md +124 -71
  5. package/builtin-methods/interf-default/README.md +3 -4
  6. package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
  7. package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
  8. package/builtin-methods/interf-default/improve/SKILL.md +1 -1
  9. package/builtin-methods/interf-default/method.json +10 -4
  10. package/builtin-methods/interf-default/method.schema.json +0 -9
  11. package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
  12. package/dist/cli/commands/compile.d.ts +9 -31
  13. package/dist/cli/commands/compile.js +75 -388
  14. package/dist/cli/commands/doctor.js +1 -1
  15. package/dist/cli/commands/login.d.ts +7 -0
  16. package/dist/cli/commands/login.js +39 -0
  17. package/dist/cli/commands/logout.d.ts +2 -0
  18. package/dist/cli/commands/logout.js +16 -0
  19. package/dist/cli/commands/method.d.ts +2 -0
  20. package/dist/cli/commands/method.js +113 -0
  21. package/dist/cli/commands/prep.d.ts +2 -0
  22. package/dist/cli/commands/prep.js +134 -0
  23. package/dist/cli/commands/reset.d.ts +8 -1
  24. package/dist/cli/commands/reset.js +47 -15
  25. package/dist/cli/commands/runs.d.ts +2 -0
  26. package/dist/cli/commands/runs.js +120 -0
  27. package/dist/cli/commands/status.d.ts +6 -1
  28. package/dist/cli/commands/status.js +61 -220
  29. package/dist/cli/commands/test.d.ts +6 -15
  30. package/dist/cli/commands/test.js +63 -342
  31. package/dist/cli/commands/web.d.ts +0 -9
  32. package/dist/cli/commands/web.js +140 -367
  33. package/dist/cli/commands/wizard.d.ts +9 -0
  34. package/dist/cli/commands/wizard.js +442 -0
  35. package/dist/cli/index.d.ts +7 -6
  36. package/dist/cli/index.js +13 -10
  37. package/dist/compiler-ui/404.html +1 -1
  38. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  39. package/dist/compiler-ui/__next._full.txt +3 -3
  40. package/dist/compiler-ui/__next._head.txt +1 -1
  41. package/dist/compiler-ui/__next._index.txt +2 -2
  42. package/dist/compiler-ui/__next._tree.txt +2 -2
  43. package/dist/compiler-ui/_next/static/chunks/045gole2ojo3g.css +3 -0
  44. package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +89 -0
  45. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  46. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  47. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  48. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  49. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  50. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  51. package/dist/compiler-ui/_not-found.html +1 -1
  52. package/dist/compiler-ui/_not-found.txt +2 -2
  53. package/dist/compiler-ui/index.html +1 -1
  54. package/dist/compiler-ui/index.txt +3 -3
  55. package/dist/index.d.ts +0 -23
  56. package/dist/index.js +0 -16
  57. package/dist/packages/agents/lib/shells.d.ts +1 -1
  58. package/dist/packages/agents/lib/shells.js +113 -54
  59. package/dist/packages/agents/lib/user-config.d.ts +4 -2
  60. package/dist/packages/agents/lib/user-config.js +15 -7
  61. package/dist/packages/compiler/compiled-paths.d.ts +9 -2
  62. package/dist/packages/compiler/compiled-paths.js +30 -15
  63. package/dist/packages/compiler/compiled-pipeline.js +23 -3
  64. package/dist/packages/compiler/compiled-stage-plan.js +4 -0
  65. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  66. package/dist/packages/compiler/compiled-target.js +1 -1
  67. package/dist/packages/compiler/index.d.ts +1 -0
  68. package/dist/packages/compiler/index.js +1 -0
  69. package/dist/packages/compiler/lib/schema.d.ts +27 -32
  70. package/dist/packages/compiler/lib/schema.js +2 -13
  71. package/dist/packages/compiler/method-runs.d.ts +2 -3
  72. package/dist/packages/compiler/method-runs.js +2 -3
  73. package/dist/packages/compiler/reset.js +3 -1
  74. package/dist/packages/compiler/runtime-contracts.js +0 -3
  75. package/dist/packages/compiler/runtime-prompt.js +1 -1
  76. package/dist/packages/compiler/source-files.d.ts +46 -0
  77. package/dist/packages/compiler/source-files.js +149 -0
  78. package/dist/packages/compiler/state-artifacts.d.ts +3 -2
  79. package/dist/packages/compiler/state-artifacts.js +4 -3
  80. package/dist/packages/compiler/state-io.d.ts +3 -2
  81. package/dist/packages/compiler/state-io.js +11 -5
  82. package/dist/packages/compiler/state-paths.d.ts +2 -1
  83. package/dist/packages/compiler/state-paths.js +6 -3
  84. package/dist/packages/compiler/state-view.d.ts +3 -2
  85. package/dist/packages/compiler/state-view.js +18 -28
  86. package/dist/packages/compiler/state.d.ts +4 -4
  87. package/dist/packages/compiler/state.js +3 -3
  88. package/dist/packages/contracts/index.d.ts +1 -1
  89. package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
  90. package/dist/packages/contracts/lib/preparation-paths.js +177 -0
  91. package/dist/packages/contracts/lib/schema.d.ts +85 -6
  92. package/dist/packages/contracts/lib/schema.js +46 -2
  93. package/dist/packages/execution/lib/schema.d.ts +50 -57
  94. package/dist/packages/execution/lib/schema.js +1 -2
  95. package/dist/packages/local-service/action-definitions.d.ts +246 -0
  96. package/dist/packages/local-service/action-definitions.js +1147 -0
  97. package/dist/packages/local-service/action-planner.d.ts +9 -0
  98. package/dist/packages/local-service/action-planner.js +135 -0
  99. package/dist/packages/local-service/action-values.d.ts +1 -23
  100. package/dist/packages/local-service/action-values.js +1 -31
  101. package/dist/packages/local-service/client.d.ts +76 -46
  102. package/dist/packages/local-service/client.js +184 -149
  103. package/dist/packages/local-service/connection-config.d.ts +38 -0
  104. package/dist/packages/local-service/connection-config.js +75 -0
  105. package/dist/packages/local-service/index.d.ts +14 -7
  106. package/dist/packages/local-service/index.js +8 -4
  107. package/dist/packages/local-service/instance-paths.d.ts +100 -0
  108. package/dist/packages/local-service/instance-paths.js +165 -0
  109. package/dist/packages/local-service/lib/schema.d.ts +689 -2575
  110. package/dist/packages/local-service/lib/schema.js +260 -101
  111. package/dist/packages/local-service/native-run-handlers.d.ts +23 -0
  112. package/dist/{cli/commands/compile-controller.js → packages/local-service/native-run-handlers.js} +204 -20
  113. package/dist/packages/local-service/preparation-store.d.ts +92 -0
  114. package/dist/packages/local-service/preparation-store.js +171 -0
  115. package/dist/{cli/commands/check-draft.d.ts → packages/local-service/readiness-check-draft.d.ts} +2 -2
  116. package/dist/packages/local-service/routes.d.ts +33 -11
  117. package/dist/packages/local-service/routes.js +44 -15
  118. package/dist/packages/local-service/run-observability.js +25 -27
  119. package/dist/packages/local-service/runtime-caches.d.ts +76 -0
  120. package/dist/packages/local-service/runtime-caches.js +191 -0
  121. package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
  122. package/dist/packages/local-service/runtime-event-applier.js +177 -0
  123. package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
  124. package/dist/packages/local-service/runtime-persistence.js +137 -0
  125. package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
  126. package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
  127. package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
  128. package/dist/packages/local-service/runtime-resource-builders.js +149 -0
  129. package/dist/packages/local-service/runtime.d.ts +201 -44
  130. package/dist/packages/local-service/runtime.js +1062 -1106
  131. package/dist/packages/local-service/server.d.ts +15 -0
  132. package/dist/packages/local-service/server.js +651 -233
  133. package/dist/packages/local-service/service-registry.d.ts +47 -0
  134. package/dist/packages/local-service/service-registry.js +137 -0
  135. package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
  136. package/dist/packages/method-authoring/method-authoring.js +2 -2
  137. package/dist/packages/method-authoring/method-improvement.js +1 -1
  138. package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
  139. package/dist/packages/method-package/builtin-compiled-method.js +8 -14
  140. package/dist/packages/method-package/context-interface.d.ts +4 -40
  141. package/dist/packages/method-package/context-interface.js +1 -23
  142. package/dist/packages/method-package/interf-method-package.d.ts +4 -4
  143. package/dist/packages/method-package/interf-method-package.js +21 -33
  144. package/dist/packages/method-package/local-methods.d.ts +10 -6
  145. package/dist/packages/method-package/local-methods.js +57 -39
  146. package/dist/packages/method-package/method-definitions.d.ts +8 -34
  147. package/dist/packages/method-package/method-definitions.js +49 -37
  148. package/dist/packages/method-package/method-helpers.d.ts +1 -13
  149. package/dist/packages/method-package/method-helpers.js +8 -42
  150. package/dist/packages/method-package/method-review-paths.d.ts +1 -1
  151. package/dist/packages/method-package/method-review-paths.js +5 -5
  152. package/dist/packages/method-package/method-stage-runner.js +2 -2
  153. package/dist/packages/method-package/user-methods.d.ts +17 -0
  154. package/dist/packages/method-package/user-methods.js +77 -0
  155. package/dist/packages/project-model/index.d.ts +1 -1
  156. package/dist/packages/project-model/index.js +1 -1
  157. package/dist/packages/project-model/interf-detect.d.ts +8 -3
  158. package/dist/packages/project-model/interf-detect.js +34 -34
  159. package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
  160. package/dist/packages/project-model/interf-scaffold.js +23 -32
  161. package/dist/packages/project-model/lib/schema.js +38 -1
  162. package/dist/packages/project-model/preparation-entries.d.ts +11 -0
  163. package/dist/packages/project-model/preparation-entries.js +49 -0
  164. package/dist/packages/project-model/source-config.d.ts +11 -10
  165. package/dist/packages/project-model/source-config.js +83 -44
  166. package/dist/packages/project-model/source-folders.d.ts +5 -5
  167. package/dist/packages/project-model/source-folders.js +14 -14
  168. package/dist/packages/shared/filesystem.d.ts +7 -0
  169. package/dist/packages/shared/filesystem.js +97 -10
  170. package/dist/packages/testing/lib/schema.d.ts +12 -13
  171. package/dist/packages/testing/lib/schema.js +4 -5
  172. package/dist/packages/testing/readiness-check-run.d.ts +7 -7
  173. package/dist/packages/testing/readiness-check-run.js +46 -51
  174. package/dist/packages/testing/test-execution.js +6 -6
  175. package/dist/packages/testing/test-paths.js +4 -3
  176. package/dist/packages/testing/test-sandbox.d.ts +0 -1
  177. package/dist/packages/testing/test-sandbox.js +14 -30
  178. package/dist/packages/testing/test-targets.d.ts +1 -1
  179. package/dist/packages/testing/test-targets.js +6 -6
  180. package/dist/packages/testing/test.d.ts +1 -1
  181. package/dist/packages/testing/test.js +1 -1
  182. package/package.json +6 -26
  183. package/LICENSE +0 -183
  184. package/dist/cli/commands/compile-controller.d.ts +0 -17
  185. package/dist/cli/commands/compiled-flow.d.ts +0 -25
  186. package/dist/cli/commands/compiled-flow.js +0 -112
  187. package/dist/cli/commands/control-path.d.ts +0 -11
  188. package/dist/cli/commands/control-path.js +0 -72
  189. package/dist/cli/commands/create-method-wizard.d.ts +0 -76
  190. package/dist/cli/commands/create-method-wizard.js +0 -465
  191. package/dist/cli/commands/create.d.ts +0 -8
  192. package/dist/cli/commands/create.js +0 -189
  193. package/dist/cli/commands/default.d.ts +0 -2
  194. package/dist/cli/commands/default.js +0 -39
  195. package/dist/cli/commands/executor-flow.d.ts +0 -29
  196. package/dist/cli/commands/executor-flow.js +0 -163
  197. package/dist/cli/commands/init.d.ts +0 -11
  198. package/dist/cli/commands/init.js +0 -784
  199. package/dist/cli/commands/list.d.ts +0 -2
  200. package/dist/cli/commands/list.js +0 -30
  201. package/dist/cli/commands/preparation-selection.d.ts +0 -6
  202. package/dist/cli/commands/preparation-selection.js +0 -11
  203. package/dist/cli/commands/source-config-wizard.d.ts +0 -52
  204. package/dist/cli/commands/source-config-wizard.js +0 -680
  205. package/dist/cli/commands/test-flow.d.ts +0 -58
  206. package/dist/cli/commands/test-flow.js +0 -231
  207. package/dist/cli/commands/verify.d.ts +0 -2
  208. package/dist/cli/commands/verify.js +0 -94
  209. package/dist/compiler-ui/_next/static/chunks/0d~8t0zm6545p.js +0 -118
  210. package/dist/compiler-ui/_next/static/chunks/0xnel.ax9a.2c.css +0 -3
  211. package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
  212. package/dist/packages/compiler/raw-snapshot.js +0 -101
  213. package/dist/packages/method-package/index.d.ts +0 -11
  214. package/dist/packages/method-package/index.js +0 -11
  215. package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
  216. package/dist/packages/method-package/method-stage-policy.js +0 -31
  217. package/dist/packages/project-model/project-paths.d.ts +0 -12
  218. package/dist/packages/project-model/project-paths.js +0 -33
  219. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
  220. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
  221. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
  222. /package/dist/{cli/commands/check-draft.js → packages/local-service/readiness-check-draft.js} +0 -0
@@ -2,16 +2,22 @@ import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { dirname, join } from "node:path";
4
4
  import chalk from "chalk";
5
- import { readInterfConfig } from "../../packages/project-model/interf.js";
6
- import { clearCompiledRuntimeDerivedArtifacts, } from "../../packages/compiler/reset.js";
7
- import { formatActiveCompiledMethodStageStep, resolveRequiredCompiledMethodFromConfig, } from "../../packages/method-package/method-definitions.js";
8
- import { loadCompiledPreparationConfig, resolvePreparationCompileMaxAttempts, resolvePreparationCompileMaxLoops, } from "../../packages/project-model/source-config.js";
9
- import { runMethodImprovementLoop } from "../../packages/method-authoring/method-improvement.js";
10
- import { stageExecutionShellsRoot, methodPackagePathForCompiled, } from "../../packages/compiler/compiled-paths.js";
11
- import { readCompiledSchemaFile } from "../../packages/compiler/compiled-schema.js";
12
- import { initializeCompiledRuntimeState } from "../../packages/compiler/state.js";
13
- import { compileCompiledWithReporter } from "./compiled-flow.js";
14
- import { printSavedTestOutcome, readinessPassRate, runSavedCompiledTest, } from "./test-flow.js";
5
+ import { compileCompiled, } from "../compiler/method-runs.js";
6
+ import { readInterfConfig } from "../project-model/interf.js";
7
+ import { resolveLocalExecutor, } from "../agents/lib/executors.js";
8
+ import { formatMethodExecutionProfile } from "../agents/lib/execution-profile.js";
9
+ import { clearCompiledRuntimeDerivedArtifacts, } from "../compiler/reset.js";
10
+ import { formatActiveCompiledMethodStageStep, resolveRequiredCompiledMethodFromConfig, } from "../method-package/method-definitions.js";
11
+ import { loadCompiledPreparationConfig, resolvePreparationCompileMaxAttempts, resolvePreparationCompileMaxLoops, } from "../project-model/source-config.js";
12
+ import { runMethodImprovementLoop } from "../method-authoring/method-improvement.js";
13
+ import { stageExecutionShellsRoot, methodPackagePathForCompiled, } from "../compiler/compiled-paths.js";
14
+ import { readCompiledSchemaFile } from "../compiler/compiled-schema.js";
15
+ import { initializeCompiledRuntimeState } from "../compiler/state.js";
16
+ import { readinessPassRate, runReadinessChecksForExecutor, runSavedPortableContextCheck, } from "../testing/readiness-check-run.js";
17
+ import { runMethodAuthoringDraft, } from "../method-authoring/method-authoring.js";
18
+ import { draftReadinessChecks, } from "./readiness-check-draft.js";
19
+ import { planActionProposalWithExecutor, } from "./action-planner.js";
20
+ import { ActionProposalPlanSchema, } from "./lib/schema.js";
15
21
  function printCompileFailure(compiledPath, failedStage) {
16
22
  resolveRequiredCompiledMethodFromConfig(readInterfConfig(compiledPath), `.interf/interf.json for ${compiledPath}`);
17
23
  let failedStageLabel = failedStage ? `Stage "${failedStage}"` : "Compile";
@@ -26,10 +32,59 @@ function printCompileFailure(compiledPath, failedStage) {
26
32
  function testScore(outcome) {
27
33
  return (outcome.result.passedCases * 1000) + outcome.result.passedChecks;
28
34
  }
35
+ async function compileCompiledWithReporter(executor, compiledPath, options = {}) {
36
+ console.log();
37
+ console.log(chalk.bold(` ${options.heading ?? "Building Portable Context..."}`));
38
+ const profileLabel = formatMethodExecutionProfile(executor.executionProfile);
39
+ if (profileLabel) {
40
+ console.log(chalk.dim(` Execution profile: ${profileLabel}`));
41
+ }
42
+ console.log();
43
+ const reporter = {
44
+ line: (message) => console.log(chalk.dim(` ${message}`)),
45
+ blankLine: () => console.log(),
46
+ };
47
+ const result = await compileCompiled({
48
+ executor,
49
+ compiledPath,
50
+ reporter,
51
+ preserveStageShells: options.preserveStageShells,
52
+ runId: options.runId,
53
+ events: options.events,
54
+ });
55
+ if (!result.ok)
56
+ return result;
57
+ console.log();
58
+ console.log(chalk.green(` ${options.successMessage ?? "Portable Context ready."}`));
59
+ return result;
60
+ }
61
+ function printSavedReadinessOutcome(prefix, outcome) {
62
+ const color = outcome.result.ok ? chalk.green : chalk.red;
63
+ const status = outcome.result.ok ? chalk.green("PASS") : chalk.red("FAIL");
64
+ console.log(chalk.bold(` ${prefix}`));
65
+ console.log();
66
+ console.log(color(` ${status} ${outcome.result.passedCases}/${outcome.result.totalCases} readiness checks`));
67
+ console.log();
68
+ for (const [index, caseResult] of outcome.result.caseResults.entries()) {
69
+ const caseStatus = caseResult.ok ? chalk.green("PASS") : chalk.red("FAIL");
70
+ console.log(` ${caseStatus} Check ${index + 1}`);
71
+ console.log(chalk.dim(` ${caseResult.question}`));
72
+ const failedChecks = caseResult.checks.filter((entry) => !entry.ok).slice(0, 3);
73
+ for (const failedCheck of failedChecks) {
74
+ console.log(chalk.dim(` Failed criterion: ${failedCheck.label}: ${failedCheck.detail}`));
75
+ }
76
+ }
77
+ console.log();
78
+ if (outcome.result.sandbox_path) {
79
+ console.log(chalk.dim(` Preserved sandbox: ${outcome.result.sandbox_path}`));
80
+ console.log();
81
+ }
82
+ console.log(chalk.dim(` Saved run: ${outcome.displayRunPath ?? outcome.runPath}`));
83
+ }
29
84
  function bestVariationRestorePaths(compiledPath) {
30
85
  const schema = readCompiledSchemaFile(methodPackagePathForCompiled(compiledPath));
31
86
  const zonePaths = (schema?.zones ?? [])
32
- .filter((zone) => zone.id !== "raw" && zone.kind !== "runtime")
87
+ .filter((zone) => zone.kind !== "runtime")
33
88
  .map((zone) => zone.path);
34
89
  return [
35
90
  "AGENTS.md",
@@ -107,12 +162,11 @@ async function runMethodVariation(options) {
107
162
  fatalError: null,
108
163
  };
109
164
  }
110
- const outcome = await runSavedCompiledTest({
165
+ const outcome = await runSavedPortableContextCheck({
111
166
  sourcePath: options.sourcePath,
112
167
  preparationConfig: options.compiledConfig,
113
168
  executor: options.testExecutor,
114
- executionProfile: options.executionProfile,
115
- compiledPath: options.compiledPath,
169
+ portableContextPath: options.compiledPath,
116
170
  preserveSandboxes: options.preserveStageShells === "always" ? "always" : "on-failure",
117
171
  });
118
172
  if (!outcome) {
@@ -123,11 +177,11 @@ async function runMethodVariation(options) {
123
177
  bestOutcome,
124
178
  bestSnapshotPath,
125
179
  bestAttempt,
126
- fatalError: "Could not run the saved Portable Context comparison after compile.",
180
+ fatalError: "Could not run saved readiness checks against the Portable Context after prepare.",
127
181
  };
128
182
  }
129
183
  console.log();
130
- printSavedTestOutcome(`${options.variationLabel} · attempt ${attempt}/${options.maxAttempts}`, outcome);
184
+ printSavedReadinessOutcome(`${options.variationLabel} · attempt ${attempt}/${options.maxAttempts}`, outcome);
131
185
  if (!bestOutcome || testScore(outcome) > testScore(bestOutcome)) {
132
186
  if (bestSnapshotPath) {
133
187
  rmSync(bestSnapshotPath, { recursive: true, force: true });
@@ -185,7 +239,7 @@ function summarizeMethodVariation(options) {
185
239
  : options.result.bestOutcome
186
240
  ? `Best result: ${passedChecks}/${totalChecks} readiness checks passed.`
187
241
  : options.result.failedStage
188
- ? `Compile failed at stage ${options.result.failedStage} before any saved comparison result.`
242
+ ? `Prepare failed at stage ${options.result.failedStage} before any saved readiness result.`
189
243
  : "Method variation did not produce a passing result.";
190
244
  return {
191
245
  variation: options.variation,
@@ -219,10 +273,10 @@ function printPostCompileNextStep(options) {
219
273
  return;
220
274
  }
221
275
  if (options.testedDuringCompile) {
222
- console.log(chalk.dim(" Next: inspect the Portable Context agents will use, or run `interf test` if you also want a source files versus Portable Context comparison."));
276
+ console.log(chalk.dim(" Next: inspect the Portable Context agents will use, or run `interf test` if you also want readiness evidence for source files and Portable Context."));
223
277
  return;
224
278
  }
225
- console.log(chalk.dim(" Next: run `interf test` to compare source files and Portable Context."));
279
+ console.log(chalk.dim(" Next: run `interf test` to collect readiness evidence for source files and Portable Context."));
226
280
  }
227
281
  function formatVariationReadinessSummary(summary) {
228
282
  return `${summary.passed_questions}/${summary.total_questions}`;
@@ -300,7 +354,7 @@ export async function runConfiguredCompiledCompile(options) {
300
354
  const compiledConfig = options.compiledConfig
301
355
  ?? loadCompiledPreparationConfig(options.compiledPath)
302
356
  ?? {
303
- name: readInterfConfig(options.compiledPath)?.name ?? "compiled",
357
+ name: readInterfConfig(options.compiledPath)?.name ?? "preparation",
304
358
  path: "./source-folder",
305
359
  checks: [],
306
360
  };
@@ -443,3 +497,133 @@ export async function runConfiguredCompiledCompile(options) {
443
497
  }
444
498
  }
445
499
  }
500
+ function resolveHandlerExecutor(configured) {
501
+ if (configured)
502
+ return configured;
503
+ const resolved = resolveLocalExecutor({ preflight: true });
504
+ if (!resolved.executor) {
505
+ throw new Error(resolved.error ?? "No local agent detected.");
506
+ }
507
+ return resolved.executor;
508
+ }
509
+ export function createNativeLocalServiceRunHandlers(options = {}) {
510
+ return {
511
+ async planActionProposal(request, context) {
512
+ const resolved = options.executor
513
+ ? { executor: options.executor, error: null }
514
+ : resolveLocalExecutor({ preflight: true });
515
+ if (!resolved.executor) {
516
+ return ActionProposalPlanSchema.parse({
517
+ action_type: "clarification",
518
+ preparation: request.preparation,
519
+ assistant_message: resolved.error ?? "No local agent detected for action planning.",
520
+ });
521
+ }
522
+ return planActionProposalWithExecutor({
523
+ request,
524
+ context,
525
+ executor: resolved.executor,
526
+ });
527
+ },
528
+ async createCompileRun(request, context) {
529
+ const executor = resolveHandlerExecutor(options.executor);
530
+ const testExecutor = resolveHandlerExecutor(options.testExecutor ?? options.executor);
531
+ const ok = await runConfiguredCompiledCompile({
532
+ executor,
533
+ testExecutor,
534
+ compiledPath: context.compiledPath,
535
+ sourcePath: context.sourcePath,
536
+ compiledConfig: context.preparationConfig,
537
+ maxAttemptsOverride: request.max_attempts ?? null,
538
+ maxLoopsOverride: request.max_loops ?? null,
539
+ preserveStageShells: request.preserve_stage_shells,
540
+ runId: context.runId,
541
+ events: context.events,
542
+ });
543
+ return { ok };
544
+ },
545
+ async createTestRun(request, context) {
546
+ const executor = resolveHandlerExecutor(options.testExecutor ?? options.executor);
547
+ const result = await runReadinessChecksForExecutor({
548
+ sourcePath: context.sourcePath,
549
+ preparationConfig: context.preparationConfig,
550
+ portableContextPath: context.compiledPath,
551
+ mode: request.mode,
552
+ executor,
553
+ });
554
+ const missingSourceFiles = (request.mode === "source-files" || request.mode === "both") && !result.sourceFilesOutcome;
555
+ const missingPortableContext = (request.mode === "compiled" || request.mode === "both") && !result.compiledOutcome;
556
+ if (missingSourceFiles || missingPortableContext) {
557
+ return {
558
+ ok: false,
559
+ readiness_run: result.readinessRun,
560
+ error: missingPortableContext
561
+ ? "Portable Context is not ready for readiness checks."
562
+ : "Source files are not ready for readiness checks.",
563
+ };
564
+ }
565
+ return {
566
+ ok: true,
567
+ readiness_run: result.readinessRun,
568
+ };
569
+ },
570
+ async createReadinessCheckDraft(request, context) {
571
+ const executor = resolveHandlerExecutor(options.executor);
572
+ context.emit({
573
+ type: "log.appended",
574
+ step_id: "agent-draft",
575
+ message: `Using ${executor.displayName} to draft readiness checks.`,
576
+ });
577
+ const drafted = await draftReadinessChecks({
578
+ preparationName: request.preparation,
579
+ sourceFolderPath: request.source_folder_path,
580
+ about: request.about,
581
+ executor,
582
+ targetCount: request.target_count,
583
+ onStatus: (line) => context.emit({
584
+ type: "log.appended",
585
+ step_id: "agent-draft",
586
+ message: line,
587
+ }),
588
+ });
589
+ if (!drafted.checks) {
590
+ throw new Error(drafted.error ?? "Could not draft readiness checks from this Source Folder.");
591
+ }
592
+ return {
593
+ checks: drafted.checks,
594
+ };
595
+ },
596
+ async createMethodAuthoringRun(request, context) {
597
+ const executor = resolveHandlerExecutor(options.executor);
598
+ context.emit({
599
+ type: "log.appended",
600
+ step_id: "draft-package",
601
+ message: `Using ${executor.displayName} for Method authoring.`,
602
+ });
603
+ const result = await runMethodAuthoringDraft({
604
+ prepDataDir: context.sourcePath,
605
+ sourceFolderPath: request.source_folder_path,
606
+ baseMethodId: request.reference_method_id ?? request.base_method_id,
607
+ methodId: request.method_id,
608
+ label: request.label,
609
+ hint: request.hint,
610
+ taskPrompt: request.task_prompt,
611
+ checks: request.checks,
612
+ executor,
613
+ onStatus: (line) => context.emit({
614
+ type: "log.appended",
615
+ step_id: "draft-package",
616
+ message: line,
617
+ }),
618
+ });
619
+ return {
620
+ status: result.status,
621
+ changed: result.changed,
622
+ summary: result.summary,
623
+ validation: result.validation,
624
+ method_path: result.methodPath,
625
+ shell_path: result.shellPath,
626
+ };
627
+ },
628
+ };
629
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * 0.13 preparation store.
3
+ *
4
+ * Each preparation lives at `~/.interf/preparations/<id>/` and is also
5
+ * registered with the runtime as a synthetic workspace so the existing
6
+ * compile / test / readiness machinery (preparation-keyed under the hood)
7
+ * keeps working without a parallel implementation.
8
+ *
9
+ * ~/.interf/preparations/<id>/
10
+ * interf.json ← preparation config, single preparation entry name=<id>
11
+ * <id>/ ← portable context (matches preparation name)
12
+ *
13
+ * NOTE: We keep the synthetic `interf.json` shape (with a `preparations[]`
14
+ * array of length 1, name=id, path=id) so the existing compile/test
15
+ * machinery stays functional. The doc-shape `config.json` /
16
+ * `portable-context/` from `instance-paths.ts` is aspirational; transitioning
17
+ * the entire compile pipeline to read those names is out of scope for the
18
+ * 0.13 cutover.
19
+ *
20
+ * Public callers reach this through the preparation-keyed HTTP routes.
21
+ */
22
+ import type { SourcePreparationConfig } from "../project-model/lib/schema.js";
23
+ import type { LocalServiceRuntime } from "./runtime.js";
24
+ export interface PreparationCreateInput {
25
+ id: string;
26
+ source: {
27
+ kind: "local-folder";
28
+ locator: string;
29
+ };
30
+ method_id: string;
31
+ about?: string;
32
+ checks?: Array<{
33
+ question: string;
34
+ answer?: string;
35
+ strictness?: string;
36
+ expect?: string;
37
+ }>;
38
+ max_attempts?: number;
39
+ max_loops?: number;
40
+ }
41
+ export interface StoredPreparation {
42
+ id: string;
43
+ prepDataDir: string;
44
+ source: {
45
+ kind: "local-folder";
46
+ locator: string;
47
+ };
48
+ methodId: string;
49
+ about: string | null;
50
+ config: SourcePreparationConfig;
51
+ portableContextPath: string;
52
+ configPath: string;
53
+ }
54
+ /** List every preparation registered under `~/.interf/preparations/`. */
55
+ export declare function listStoredPreparations(): StoredPreparation[];
56
+ /** Read one preparation by id. Returns null when missing. */
57
+ export declare function getStoredPreparation(prepId: string): StoredPreparation | null;
58
+ /**
59
+ * Create a preparation: scaffold its data dir, write the synthetic
60
+ * workspace config, and register it with the runtime so subsequent
61
+ * compile / test / readiness calls find it.
62
+ *
63
+ * Throws on validation errors (bad id, bad method id, source missing).
64
+ */
65
+ export declare function createStoredPreparation(runtime: LocalServiceRuntime, input: PreparationCreateInput): StoredPreparation;
66
+ /**
67
+ * Delete a preparation: deregister its synthetic workspace and remove
68
+ * `~/.interf/preparations/<id>/` from disk. Returns true when something
69
+ * was actually removed.
70
+ */
71
+ export declare function deleteStoredPreparation(runtime: LocalServiceRuntime, prepId: string): boolean;
72
+ /**
73
+ * Re-register every preparation directory with the runtime on startup so
74
+ * synthetic workspaces survive a `interf web` restart.
75
+ */
76
+ export declare function rehydratePreparations(runtime: LocalServiceRuntime): void;
77
+ /** Build the wire shape for `GET /v1/preparations/<id>` given a stored preparation. */
78
+ export declare function preparationWireShape(stored: StoredPreparation): {
79
+ id: string;
80
+ source: {
81
+ kind: string;
82
+ locator: string;
83
+ };
84
+ method_id: string;
85
+ about: string | null;
86
+ config_path: string;
87
+ portable_context: {
88
+ kind: "local-path";
89
+ value: string;
90
+ };
91
+ checks: SourcePreparationConfig["checks"];
92
+ };
@@ -0,0 +1,171 @@
1
+ /**
2
+ * 0.13 preparation store.
3
+ *
4
+ * Each preparation lives at `~/.interf/preparations/<id>/` and is also
5
+ * registered with the runtime as a synthetic workspace so the existing
6
+ * compile / test / readiness machinery (preparation-keyed under the hood)
7
+ * keeps working without a parallel implementation.
8
+ *
9
+ * ~/.interf/preparations/<id>/
10
+ * interf.json ← preparation config, single preparation entry name=<id>
11
+ * <id>/ ← portable context (matches preparation name)
12
+ *
13
+ * NOTE: We keep the synthetic `interf.json` shape (with a `preparations[]`
14
+ * array of length 1, name=id, path=id) so the existing compile/test
15
+ * machinery stays functional. The doc-shape `config.json` /
16
+ * `portable-context/` from `instance-paths.ts` is aspirational; transitioning
17
+ * the entire compile pipeline to read those names is out of scope for the
18
+ * 0.13 cutover.
19
+ *
20
+ * Public callers reach this through the preparation-keyed HTTP routes.
21
+ */
22
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, } from "node:fs";
23
+ import { join, resolve } from "node:path";
24
+ import { PreparationNameSchema, MethodIdSchema, } from "../contracts/lib/schema.js";
25
+ import { preparationDataDir, preparationsRoot, } from "./instance-paths.js";
26
+ import { saveSourceFolderConfig, loadSourceFolderConfig, } from "../project-model/source-config.js";
27
+ function ensurePreparationsRoot() {
28
+ mkdirSync(preparationsRoot(), { recursive: true });
29
+ }
30
+ function readSourceFolderBindingFromInterfJson(prepDataDir) {
31
+ const filePath = join(prepDataDir, "interf.json");
32
+ if (!existsSync(filePath))
33
+ return null;
34
+ try {
35
+ const raw = JSON.parse(readFileSync(filePath, "utf8"));
36
+ const sourceFolder = raw.source_folder;
37
+ if (!sourceFolder?.path)
38
+ return null;
39
+ return { path: sourceFolder.path, about: sourceFolder.about ?? null };
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ function loadStoredPreparation(prepId) {
46
+ const prepDataDir = preparationDataDir(prepId);
47
+ if (!existsSync(prepDataDir) || !statSync(prepDataDir).isDirectory())
48
+ return null;
49
+ const config = loadSourceFolderConfig(prepDataDir);
50
+ if (!config)
51
+ return null;
52
+ const preparation = config.preparations?.find((p) => p.name === prepId);
53
+ if (!preparation)
54
+ return null;
55
+ const binding = readSourceFolderBindingFromInterfJson(prepDataDir);
56
+ if (!binding?.path)
57
+ return null;
58
+ return {
59
+ id: prepId,
60
+ prepDataDir,
61
+ source: { kind: "local-folder", locator: binding.path },
62
+ methodId: preparation.method ?? "interf-default",
63
+ about: binding.about ?? null,
64
+ config: preparation,
65
+ portableContextPath: join(prepDataDir, prepId),
66
+ configPath: join(prepDataDir, "interf.json"),
67
+ };
68
+ }
69
+ /** List every preparation registered under `~/.interf/preparations/`. */
70
+ export function listStoredPreparations() {
71
+ const root = preparationsRoot();
72
+ if (!existsSync(root))
73
+ return [];
74
+ const entries = readdirSync(root, { withFileTypes: true });
75
+ const out = [];
76
+ for (const entry of entries) {
77
+ if (!entry.isDirectory())
78
+ continue;
79
+ const stored = loadStoredPreparation(entry.name);
80
+ if (stored)
81
+ out.push(stored);
82
+ }
83
+ return out.sort((a, b) => a.id.localeCompare(b.id));
84
+ }
85
+ /** Read one preparation by id. Returns null when missing. */
86
+ export function getStoredPreparation(prepId) {
87
+ return loadStoredPreparation(prepId);
88
+ }
89
+ /**
90
+ * Create a preparation: scaffold its data dir, write the synthetic
91
+ * workspace config, and register it with the runtime so subsequent
92
+ * compile / test / readiness calls find it.
93
+ *
94
+ * Throws on validation errors (bad id, bad method id, source missing).
95
+ */
96
+ export function createStoredPreparation(runtime, input) {
97
+ PreparationNameSchema.parse(input.id);
98
+ MethodIdSchema.parse(input.method_id);
99
+ const sourceLocator = resolve(input.source.locator);
100
+ if (!existsSync(sourceLocator)) {
101
+ throw new Error(`Source folder does not exist: ${sourceLocator}`);
102
+ }
103
+ if (!statSync(sourceLocator).isDirectory()) {
104
+ throw new Error(`Source folder is not a directory: ${sourceLocator}`);
105
+ }
106
+ ensurePreparationsRoot();
107
+ const prepDataDir = preparationDataDir(input.id);
108
+ if (existsSync(prepDataDir) && loadStoredPreparation(input.id)) {
109
+ throw new Error(`Preparation already exists: ${input.id}`);
110
+ }
111
+ mkdirSync(prepDataDir, { recursive: true });
112
+ const preparation = {
113
+ name: input.id,
114
+ path: input.id,
115
+ method: input.method_id,
116
+ checks: (input.checks ?? []).map((check) => ({
117
+ question: check.question,
118
+ ...(check.answer ? { answer: check.answer } : {}),
119
+ ...(check.strictness ? { strictness: check.strictness } : {}),
120
+ ...(check.expect ? { expect: check.expect } : {}),
121
+ })),
122
+ ...(input.about ? { about: input.about } : {}),
123
+ ...(input.max_attempts ? { max_attempts: input.max_attempts } : {}),
124
+ ...(input.max_loops ? { max_loops: input.max_loops } : {}),
125
+ };
126
+ saveSourceFolderConfig(prepDataDir, {
127
+ source_folder: { path: sourceLocator, ...(input.about ? { about: input.about } : {}) },
128
+ preparations: [preparation],
129
+ });
130
+ // Hand the synthetic workspace to the runtime so the existing
131
+ // compile/test/readiness paths see it.
132
+ runtime.registerPreparation(prepDataDir);
133
+ const stored = loadStoredPreparation(input.id);
134
+ if (!stored)
135
+ throw new Error(`Failed to load freshly-created preparation ${input.id}`);
136
+ return stored;
137
+ }
138
+ /**
139
+ * Delete a preparation: deregister its synthetic workspace and remove
140
+ * `~/.interf/preparations/<id>/` from disk. Returns true when something
141
+ * was actually removed.
142
+ */
143
+ export function deleteStoredPreparation(runtime, prepId) {
144
+ const prepDataDir = preparationDataDir(prepId);
145
+ if (!existsSync(prepDataDir))
146
+ return false;
147
+ runtime.deregisterPreparation(prepDataDir);
148
+ rmSync(prepDataDir, { recursive: true, force: true });
149
+ return true;
150
+ }
151
+ /**
152
+ * Re-register every preparation directory with the runtime on startup so
153
+ * synthetic workspaces survive a `interf web` restart.
154
+ */
155
+ export function rehydratePreparations(runtime) {
156
+ for (const stored of listStoredPreparations()) {
157
+ runtime.registerPreparation(stored.prepDataDir);
158
+ }
159
+ }
160
+ /** Build the wire shape for `GET /v1/preparations/<id>` given a stored preparation. */
161
+ export function preparationWireShape(stored) {
162
+ return {
163
+ id: stored.id,
164
+ source: stored.source,
165
+ method_id: stored.methodId,
166
+ about: stored.about,
167
+ config_path: stored.configPath,
168
+ portable_context: { kind: "local-path", value: stored.portableContextPath },
169
+ checks: stored.config.checks ?? [],
170
+ };
171
+ }
@@ -1,5 +1,5 @@
1
- import type { MethodExecutor } from "../../packages/agents/lib/executors.js";
2
- import type { SourceReadinessCheck } from "../../packages/project-model/lib/schema.js";
1
+ import type { MethodExecutor } from "../agents/lib/executors.js";
2
+ import type { SourceReadinessCheck } from "../project-model/lib/schema.js";
3
3
  export declare function buildReadinessCheckDraftPrompt(options: {
4
4
  preparationName: string;
5
5
  sourceFolderPath: string;
@@ -1,27 +1,49 @@
1
1
  export declare const LOCAL_SERVICE_DEFAULT_HOST = "127.0.0.1";
2
2
  export declare const LOCAL_SERVICE_DEFAULT_PORT = 4873;
3
- export declare const LOCAL_SERVICE_INSTANCE_POINTER_PATH: readonly ["interf", ".service", "local-instance.json"];
4
3
  export declare const LOCAL_SERVICE_ROUTES: {
5
4
  readonly root: "/";
6
5
  readonly api: "/v1";
7
6
  readonly health: "/health";
7
+ readonly instance: "/v1/instance";
8
8
  readonly preparations: "/v1/preparations";
9
- readonly workspaceFiles: "/v1/workspace-files";
10
- readonly sourceFiles: "/v1/source-files";
11
9
  readonly methods: "/v1/methods";
12
- readonly jobs: "/v1/jobs";
13
- readonly readinessCheckDrafts: "/v1/readiness-check-drafts";
14
- readonly methodAuthoringRuns: "/v1/method-authoring-runs";
15
10
  readonly runs: "/v1/runs";
16
- readonly executor: "/v1/executor";
17
11
  readonly actionProposals: "/v1/action-proposals";
18
- readonly compileRuns: "/v1/compile-runs";
19
- readonly testRuns: "/v1/test-runs";
20
- readonly portableContexts: "/v1/portable-contexts";
21
- readonly readiness: "/v1/readiness";
12
+ readonly executor: "/v1/executor";
22
13
  readonly openPath: "/v1/open-path";
23
14
  };
15
+ /** Preparation-scoped sub-resources (relative to /v1/preparations/<id>/). */
16
+ export declare const PREPARATION_SUBRESOURCES: {
17
+ readonly compileRuns: "compile-runs";
18
+ readonly testRuns: "test-runs";
19
+ readonly methodAuthoringRuns: "method-authoring-runs";
20
+ readonly methodImprovementRuns: "method-improvement-runs";
21
+ readonly readinessCheckDrafts: "readiness-check-drafts";
22
+ readonly changes: "changes";
23
+ readonly reset: "reset";
24
+ readonly runs: "runs";
25
+ readonly readiness: "readiness";
26
+ readonly sourceFiles: "source-files";
27
+ readonly portableContext: "portable-context";
28
+ };
29
+ /** Run-scoped sub-resources (relative to /v1/runs/<run-id>/). */
30
+ export declare const RUN_SUBRESOURCES: {
31
+ readonly events: "events";
32
+ readonly cancel: "cancel";
33
+ readonly proof: "proof";
34
+ readonly artifacts: "artifacts";
35
+ };
24
36
  export declare function buildLocalServiceUrl(options?: {
25
37
  host?: string;
26
38
  port?: number;
27
39
  }): string;
40
+ /** Path builder: /v1/preparations/<id>. */
41
+ export declare function preparationResourcePath(prepId: string): string;
42
+ /** Path builder: /v1/preparations/<id>/<subresource>. */
43
+ export declare function preparationSubresourcePath(prepId: string, sub: keyof typeof PREPARATION_SUBRESOURCES): string;
44
+ /** Path builder: /v1/runs/<run-id>. */
45
+ export declare function runResourcePath(runId: string): string;
46
+ /** Path builder: /v1/runs/<run-id>/<subresource>. */
47
+ export declare function runSubresourcePath(runId: string, sub: keyof typeof RUN_SUBRESOURCES): string;
48
+ /** Path builder: /v1/methods/<id>. */
49
+ export declare function methodResourcePath(methodId: string): string;