@interf/compiler 0.9.3 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +2 -1
  3. package/agent-skills/interf-actions/SKILL.md +17 -11
  4. package/agent-skills/interf-actions/references/cli.md +8 -22
  5. package/dist/cli/commands/action-input-cli.d.ts +25 -0
  6. package/dist/cli/commands/action-input-cli.js +73 -0
  7. package/dist/cli/commands/compile.d.ts +3 -8
  8. package/dist/cli/commands/compile.js +13 -41
  9. package/dist/cli/commands/create-method-wizard.d.ts +0 -12
  10. package/dist/cli/commands/create-method-wizard.js +95 -126
  11. package/dist/cli/commands/create.d.ts +0 -2
  12. package/dist/cli/commands/create.js +16 -22
  13. package/dist/cli/commands/doctor.js +1 -1
  14. package/dist/cli/commands/executor-flow.js +1 -1
  15. package/dist/cli/commands/init.d.ts +16 -1
  16. package/dist/cli/commands/init.js +40 -53
  17. package/dist/cli/commands/list.js +1 -1
  18. package/dist/cli/commands/preparation-action.d.ts +8 -0
  19. package/dist/cli/commands/preparation-action.js +29 -0
  20. package/dist/cli/commands/preparation-picker.d.ts +5 -0
  21. package/dist/cli/commands/preparation-picker.js +36 -0
  22. package/dist/cli/commands/preparation-selection.js +2 -2
  23. package/dist/cli/commands/reset.js +15 -4
  24. package/dist/cli/commands/service-action-flow.d.ts +9 -0
  25. package/dist/cli/commands/service-action-flow.js +19 -0
  26. package/dist/cli/commands/source-config-wizard.d.ts +0 -1
  27. package/dist/cli/commands/source-config-wizard.js +43 -53
  28. package/dist/cli/commands/status.js +7 -123
  29. package/dist/cli/commands/test.d.ts +1 -2
  30. package/dist/cli/commands/test.js +40 -203
  31. package/dist/cli/commands/web.js +8 -262
  32. package/dist/compiler-ui/404.html +1 -1
  33. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  34. package/dist/compiler-ui/__next._full.txt +3 -3
  35. package/dist/compiler-ui/__next._head.txt +1 -1
  36. package/dist/compiler-ui/__next._index.txt +2 -2
  37. package/dist/compiler-ui/__next._tree.txt +2 -2
  38. package/dist/compiler-ui/_next/static/chunks/177mvn4rse235.js +89 -0
  39. package/dist/compiler-ui/_next/static/chunks/18a8f2jkv3z.c.css +3 -0
  40. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  41. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  42. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  43. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  44. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  45. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  46. package/dist/compiler-ui/_not-found.html +1 -1
  47. package/dist/compiler-ui/_not-found.txt +2 -2
  48. package/dist/compiler-ui/index.html +1 -1
  49. package/dist/compiler-ui/index.txt +3 -3
  50. package/dist/index.d.ts +0 -23
  51. package/dist/index.js +0 -16
  52. package/dist/packages/agents/lib/shells.js +2 -2
  53. package/dist/packages/compiler/lib/schema.d.ts +1 -1
  54. package/dist/packages/compiler/lib/schema.js +1 -1
  55. package/dist/packages/contracts/lib/schema.d.ts +0 -1
  56. package/dist/packages/contracts/lib/schema.js +0 -1
  57. package/dist/packages/execution/lib/schema.d.ts +0 -7
  58. package/dist/packages/execution/lib/schema.js +0 -1
  59. package/dist/packages/local-service/action-definitions.d.ts +246 -0
  60. package/dist/packages/local-service/action-definitions.js +1148 -0
  61. package/dist/packages/local-service/action-planner.d.ts +9 -0
  62. package/dist/packages/local-service/action-planner.js +134 -0
  63. package/dist/packages/local-service/action-values.d.ts +1 -22
  64. package/dist/packages/local-service/action-values.js +1 -30
  65. package/dist/packages/local-service/client.d.ts +48 -17
  66. package/dist/packages/local-service/client.js +95 -52
  67. package/dist/packages/local-service/index.d.ts +8 -5
  68. package/dist/packages/local-service/index.js +5 -3
  69. package/dist/packages/local-service/lib/schema.d.ts +302 -292
  70. package/dist/packages/local-service/lib/schema.js +115 -39
  71. package/dist/packages/local-service/native-run-handlers.d.ts +23 -0
  72. package/dist/{cli/commands/compile-controller.js → packages/local-service/native-run-handlers.js} +203 -19
  73. package/dist/{cli/commands/check-draft.d.ts → packages/local-service/readiness-check-draft.d.ts} +2 -2
  74. package/dist/packages/local-service/routes.d.ts +6 -1
  75. package/dist/packages/local-service/routes.js +7 -2
  76. package/dist/packages/local-service/run-observability.js +15 -17
  77. package/dist/packages/local-service/runtime.d.ts +10 -7
  78. package/dist/packages/local-service/runtime.js +430 -286
  79. package/dist/packages/local-service/server.js +94 -44
  80. package/dist/packages/method-package/method-review-paths.d.ts +1 -1
  81. package/dist/packages/method-package/method-review-paths.js +5 -5
  82. package/dist/packages/project-model/index.d.ts +1 -0
  83. package/dist/packages/project-model/index.js +1 -0
  84. package/dist/packages/project-model/preparation-entries.d.ts +11 -0
  85. package/dist/packages/project-model/preparation-entries.js +49 -0
  86. package/dist/packages/project-model/source-config.d.ts +1 -0
  87. package/dist/packages/project-model/source-config.js +12 -1
  88. package/dist/packages/testing/lib/schema.d.ts +2 -3
  89. package/dist/packages/testing/lib/schema.js +2 -3
  90. package/dist/packages/testing/readiness-check-run.d.ts +3 -3
  91. package/dist/packages/testing/readiness-check-run.js +12 -17
  92. package/package.json +5 -24
  93. package/dist/cli/commands/compile-controller.d.ts +0 -17
  94. package/dist/cli/commands/compiled-flow.d.ts +0 -25
  95. package/dist/cli/commands/compiled-flow.js +0 -112
  96. package/dist/cli/commands/test-flow.d.ts +0 -58
  97. package/dist/cli/commands/test-flow.js +0 -231
  98. package/dist/compiler-ui/_next/static/chunks/0c9mu7yldxyyg.css +0 -3
  99. package/dist/compiler-ui/_next/static/chunks/15mks7ry_cupt.js +0 -118
  100. /package/dist/compiler-ui/_next/static/{pIZnDsV3Je6hdC3cOsGdK → 84FaeF3EzBF9kKTMjSEVN}/_buildManifest.js +0 -0
  101. /package/dist/compiler-ui/_next/static/{pIZnDsV3Je6hdC3cOsGdK → 84FaeF3EzBF9kKTMjSEVN}/_clientMiddlewareManifest.js +0 -0
  102. /package/dist/compiler-ui/_next/static/{pIZnDsV3Je6hdC3cOsGdK → 84FaeF3EzBF9kKTMjSEVN}/_ssgManifest.js +0 -0
  103. /package/dist/{cli/commands/check-draft.js → packages/local-service/readiness-check-draft.js} +0 -0
@@ -22,7 +22,13 @@ export const LocalServiceHealthSchema = z.object({
22
22
  started_at: z.string().min(1).optional(),
23
23
  package_version: z.string().min(1).optional(),
24
24
  }).strict();
25
- export const LocalServiceInstancePointerSchema = z.object({
25
+ export const LocalServiceErrorSchema = z.object({
26
+ error: z.object({
27
+ message: z.string().min(1),
28
+ code: z.string().min(1).optional(),
29
+ }).strict(),
30
+ }).strict();
31
+ export const LocalServicePointerSchema = z.object({
26
32
  service_url: z.string().min(1),
27
33
  host: LocalServiceHostSchema,
28
34
  port: LocalServicePortSchema,
@@ -66,6 +72,7 @@ export const MethodResourceSchema = z.object({
66
72
  source_kind: z.enum(["builtin", "local"]).default("local"),
67
73
  built_in: z.boolean().default(false),
68
74
  active_for_preparations: z.array(PreparationNameSchema).default([]),
75
+ output_paths: z.array(z.string().min(1)).default([]),
69
76
  stages: z.array(z.object({
70
77
  id: z.string().min(1),
71
78
  label: z.string().min(1),
@@ -99,12 +106,9 @@ export const CompileRunResourceSchema = z.object({
99
106
  run: CompileRunSchema,
100
107
  }).strict();
101
108
  export const LocalJobTypeSchema = z.enum([
102
- "preparation-setup",
103
109
  "readiness-check-draft",
104
110
  "method-authoring",
105
111
  "method-improvement",
106
- "compile",
107
- "test",
108
112
  ]);
109
113
  export const LocalJobStatusSchema = z.enum([
110
114
  "queued",
@@ -116,7 +120,7 @@ export const LocalJobStatusSchema = z.enum([
116
120
  export const LocalRunHandlerResultSchema = z.object({
117
121
  ok: z.boolean(),
118
122
  error: z.string().min(1).optional(),
119
- comparison: ReadinessCheckRunSchema.nullable().optional(),
123
+ readiness_run: ReadinessCheckRunSchema.nullable().optional(),
120
124
  }).strict();
121
125
  export const LocalJobAgentSchema = z.object({
122
126
  name: z.string().min(1),
@@ -173,6 +177,81 @@ export const LocalJobRunCreateRequestSchema = z.object({
173
177
  }).strict();
174
178
  export const PreparationSetupCreateRequestSchema = z.object({
175
179
  preparation: SourcePreparationConfigSchema,
180
+ prepare_after_setup: z.boolean().default(false),
181
+ setup_mode: z.enum(["create", "select-method"]).default("create"),
182
+ }).strict();
183
+ export const PreparationSetupResultSchema = z.object({
184
+ kind: z.literal("interf-preparation-setup-result"),
185
+ version: z.literal(1),
186
+ operation: z.enum(["create", "select-method"]),
187
+ preparation: PreparationNameSchema,
188
+ method: MethodIdSchema,
189
+ source_folder_path: z.string().min(1),
190
+ config_path: z.string().min(1),
191
+ portable_context_path: z.string().min(1),
192
+ changed: z.boolean(),
193
+ message: z.string().min(1),
194
+ submitted_run_id: z.string().min(1).nullable().optional(),
195
+ submitted_run_type: z.literal("compile-run").nullable().optional(),
196
+ }).strict();
197
+ export const MethodChangeCreateRequestSchema = z.discriminatedUnion("operation", [
198
+ z.object({
199
+ action_type: z.literal("method-change").optional(),
200
+ operation: z.literal("duplicate"),
201
+ method: MethodIdSchema,
202
+ new_method_id: MethodIdSchema,
203
+ label: z.string().min(1).optional(),
204
+ hint: z.string().min(1).optional(),
205
+ }).strict(),
206
+ z.object({
207
+ action_type: z.literal("method-change").optional(),
208
+ operation: z.literal("remove"),
209
+ method: MethodIdSchema,
210
+ confirmation: MethodIdSchema,
211
+ }).strict(),
212
+ ]);
213
+ export const MethodChangeResultSchema = z.object({
214
+ kind: z.literal("interf-method-change-result"),
215
+ version: z.literal(1),
216
+ operation: z.enum(["duplicate", "remove"]),
217
+ method: MethodIdSchema,
218
+ new_method_id: MethodIdSchema.nullable().optional(),
219
+ updated_preparations: z.array(PreparationNameSchema).default([]),
220
+ method_path: z.string().min(1),
221
+ changed: z.boolean(),
222
+ message: z.string().min(1),
223
+ }).strict();
224
+ export const PreparationChangeCreateRequestSchema = z.discriminatedUnion("operation", [
225
+ z.object({
226
+ action_type: z.literal("preparation-change").optional(),
227
+ operation: z.literal("remove"),
228
+ preparation: PreparationNameSchema,
229
+ confirmation: PreparationNameSchema,
230
+ }).strict(),
231
+ ]);
232
+ export const PreparationChangeResultSchema = z.object({
233
+ kind: z.literal("interf-preparation-change-result"),
234
+ version: z.literal(1),
235
+ operation: z.literal("remove"),
236
+ preparation: PreparationNameSchema,
237
+ config_path: z.string().min(1),
238
+ portable_context_path: z.string().min(1),
239
+ portable_context_retained: z.boolean(),
240
+ changed: z.boolean(),
241
+ message: z.string().min(1),
242
+ }).strict();
243
+ export const ResetRequestSchema = z.object({
244
+ preparation: PreparationNameSchema,
245
+ scope: z.enum(["compile", "all"]),
246
+ }).strict();
247
+ export const ResetResultSchema = z.object({
248
+ kind: z.literal("interf-reset-result"),
249
+ version: z.literal(1),
250
+ preparation: PreparationNameSchema,
251
+ scope: z.enum(["compile", "all"]),
252
+ portable_context_path: z.string().min(1),
253
+ changed: z.boolean(),
254
+ message: z.string().min(1),
176
255
  }).strict();
177
256
  export const ReadinessCheckDraftCreateRequestSchema = z.object({
178
257
  preparation: PreparationNameSchema,
@@ -250,40 +329,12 @@ export const TestRunResourceSchema = z.object({
250
329
  portable_context_path: z.string().min(1).nullable(),
251
330
  started_at: z.string().nullable().optional(),
252
331
  finished_at: z.string().nullable().optional(),
253
- comparison: ReadinessCheckRunSchema.nullable(),
332
+ readiness_run: ReadinessCheckRunSchema.nullable(),
254
333
  readiness: ReadinessStateSchema.nullable().optional(),
255
334
  events: z.array(InterfRunEventSchema).default([]),
256
335
  error: z.string().min(1).nullable().optional(),
257
336
  }).strict();
258
337
  export const RunObservabilityResourceSchema = RunObservabilitySchema;
259
- export const RunCreateRequestSchema = z.discriminatedUnion("run_type", [
260
- z.object({
261
- run_type: z.literal("compile"),
262
- preparation: PreparationNameSchema,
263
- method: MethodIdSchema.optional(),
264
- max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
265
- max_loops: SourceCompiledMaxLoopsSchema.optional(),
266
- preserve_stage_shells: z.enum(["on-failure", "always"]).optional(),
267
- }).strict(),
268
- z.object({
269
- run_type: z.literal("prepare"),
270
- preparation: PreparationNameSchema,
271
- method: MethodIdSchema.optional(),
272
- max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
273
- max_loops: SourceCompiledMaxLoopsSchema.optional(),
274
- preserve_stage_shells: z.enum(["on-failure", "always"]).optional(),
275
- }).strict(),
276
- z.object({
277
- run_type: z.literal("test"),
278
- preparation: PreparationNameSchema,
279
- mode: TestRunModeSchema.default("both"),
280
- }).strict(),
281
- z.object({
282
- run_type: z.literal("check"),
283
- preparation: PreparationNameSchema,
284
- mode: TestRunModeSchema.default("both"),
285
- }).strict(),
286
- ]);
287
338
  export const LocalExecutorStatusSchema = z.object({
288
339
  kind: z.literal("interf-local-executor-status"),
289
340
  version: z.literal(1),
@@ -297,10 +348,20 @@ export const LocalExecutorSelectRequestSchema = z.object({
297
348
  agent: z.string().min(1),
298
349
  }).strict();
299
350
  export const ActionProposalTypeSchema = z.enum([
351
+ "clarification",
352
+ "readiness-check-draft",
353
+ "method-authoring",
354
+ "method-improvement",
355
+ "compile",
356
+ "test",
357
+ ]);
358
+ export const ActionProposalPlanActionTypeSchema = z.enum([
300
359
  "clarification",
301
360
  "preparation-setup",
361
+ "preparation-change",
302
362
  "readiness-check-draft",
303
363
  "method-authoring",
364
+ "method-change",
304
365
  "method-improvement",
305
366
  "compile",
306
367
  "test",
@@ -313,13 +374,22 @@ export const ActionProposalStatusSchema = z.enum([
313
374
  "submitted",
314
375
  "failed",
315
376
  ]);
377
+ export const ActionClientOriginSchema = z.enum([
378
+ "ui-chat",
379
+ "cli",
380
+ "agent-cli",
381
+ "mcp",
382
+ "service",
383
+ "unknown",
384
+ ]);
316
385
  export const ActionProposalCreateRequestSchema = z.object({
317
386
  message: z.string().min(1),
318
387
  preparation: PreparationNameSchema.optional(),
388
+ client_origin: ActionClientOriginSchema.default("unknown"),
319
389
  values: JsonObjectSchema.optional(),
320
390
  }).strict();
321
391
  export const ActionProposalPlanSchema = z.object({
322
- action_type: ActionProposalTypeSchema,
392
+ action_type: ActionProposalPlanActionTypeSchema,
323
393
  preparation: PreparationNameSchema.optional(),
324
394
  method: MethodIdSchema.optional(),
325
395
  values: JsonObjectSchema.optional(),
@@ -349,6 +419,7 @@ const ActionProposalResourceBaseSchema = z.object({
349
419
  message: z.string().min(1),
350
420
  preparation: PreparationNameSchema.nullable().optional(),
351
421
  method: MethodIdSchema.nullable().optional(),
422
+ client_origin: ActionClientOriginSchema.default("unknown"),
352
423
  created_at: z.string().min(1),
353
424
  updated_at: z.string().min(1),
354
425
  proposed_by_executor: LocalJobAgentSchema.nullable().optional(),
@@ -366,10 +437,6 @@ export const ActionProposalResourceSchema = z.discriminatedUnion("action_type",
366
437
  action_type: z.literal("compile"),
367
438
  request: CompileRunCreateRequestSchema,
368
439
  }).strict(),
369
- ActionProposalResourceBaseSchema.extend({
370
- action_type: z.literal("preparation-setup"),
371
- request: PreparationSetupCreateRequestSchema,
372
- }).strict(),
373
440
  ActionProposalResourceBaseSchema.extend({
374
441
  action_type: z.literal("test"),
375
442
  request: TestRunCreateRequestSchema,
@@ -424,6 +491,15 @@ export const LocalServiceDiscoverySchema = z.object({
424
491
  source_files: z.string().min(1),
425
492
  workspace_files: z.string().min(1),
426
493
  action_proposals: z.string().min(1),
494
+ preparation_setups: z.string().min(1),
495
+ preparation_changes: z.string().min(1),
496
+ method_changes: z.string().min(1),
497
+ readiness_check_drafts: z.string().min(1),
498
+ method_authoring_runs: z.string().min(1),
499
+ method_improvement_runs: z.string().min(1),
500
+ compile_runs: z.string().min(1),
501
+ test_runs: z.string().min(1),
502
+ reset: z.string().min(1),
427
503
  executor: z.string().min(1),
428
504
  }).strict(),
429
505
  }).strict();
@@ -0,0 +1,23 @@
1
+ import type { MethodExecutionProfile, MethodExecutor } from "../agents/lib/executors.js";
2
+ import type { SourcePreparationConfig } from "../project-model/lib/schema.js";
3
+ import type { StageShellRetentionMode } from "../compiler/method-runs.js";
4
+ import type { RunEventSink } from "../execution/events.js";
5
+ import type { LocalServiceRunHandlers } from "./runtime.js";
6
+ export interface NativeLocalServiceRunHandlerOptions {
7
+ executor?: MethodExecutor;
8
+ testExecutor?: MethodExecutor;
9
+ }
10
+ export declare function runConfiguredCompiledCompile(options: {
11
+ executor: MethodExecutor;
12
+ testExecutor?: MethodExecutor | null;
13
+ compiledPath: string;
14
+ sourcePath: string;
15
+ compiledConfig: SourcePreparationConfig | null;
16
+ executionProfile?: MethodExecutionProfile;
17
+ maxAttemptsOverride: number | null;
18
+ maxLoopsOverride: number | null;
19
+ preserveStageShells?: StageShellRetentionMode;
20
+ runId?: string;
21
+ events?: RunEventSink;
22
+ }): Promise<boolean>;
23
+ export declare function createNativeLocalServiceRunHandlers(options?: NativeLocalServiceRunHandlerOptions): Pick<LocalServiceRunHandlers, "planActionProposal" | "createCompileRun" | "createTestRun" | "createReadinessCheckDraft" | "createMethodAuthoringRun">;
@@ -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,6 +32,55 @@ 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 ?? [])
@@ -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 === "raw" || request.mode === "both") && !result.rawOutcome;
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
+ sourcePath: 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
+ }
@@ -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,6 +1,6 @@
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"];
3
+ export declare const LOCAL_SERVICE_POINTER_PATH: readonly ["interf", ".service", "local-service.json"];
4
4
  export declare const LOCAL_SERVICE_ROUTES: {
5
5
  readonly root: "/";
6
6
  readonly api: "/v1";
@@ -9,10 +9,15 @@ export declare const LOCAL_SERVICE_ROUTES: {
9
9
  readonly workspaceFiles: "/v1/workspace-files";
10
10
  readonly sourceFiles: "/v1/source-files";
11
11
  readonly methods: "/v1/methods";
12
+ readonly preparationSetups: "/v1/preparation-setups";
13
+ readonly preparationChanges: "/v1/preparation-changes";
14
+ readonly methodChanges: "/v1/method-changes";
12
15
  readonly jobs: "/v1/jobs";
13
16
  readonly readinessCheckDrafts: "/v1/readiness-check-drafts";
14
17
  readonly methodAuthoringRuns: "/v1/method-authoring-runs";
18
+ readonly methodImprovementRuns: "/v1/method-improvement-runs";
15
19
  readonly runs: "/v1/runs";
20
+ readonly reset: "/v1/reset";
16
21
  readonly executor: "/v1/executor";
17
22
  readonly actionProposals: "/v1/action-proposals";
18
23
  readonly compileRuns: "/v1/compile-runs";
@@ -1,9 +1,9 @@
1
1
  export const LOCAL_SERVICE_DEFAULT_HOST = "127.0.0.1";
2
2
  export const LOCAL_SERVICE_DEFAULT_PORT = 4873;
3
- export const LOCAL_SERVICE_INSTANCE_POINTER_PATH = [
3
+ export const LOCAL_SERVICE_POINTER_PATH = [
4
4
  "interf",
5
5
  ".service",
6
- "local-instance.json",
6
+ "local-service.json",
7
7
  ];
8
8
  export const LOCAL_SERVICE_ROUTES = {
9
9
  root: "/",
@@ -13,10 +13,15 @@ export const LOCAL_SERVICE_ROUTES = {
13
13
  workspaceFiles: "/v1/workspace-files",
14
14
  sourceFiles: "/v1/source-files",
15
15
  methods: "/v1/methods",
16
+ preparationSetups: "/v1/preparation-setups",
17
+ preparationChanges: "/v1/preparation-changes",
18
+ methodChanges: "/v1/method-changes",
16
19
  jobs: "/v1/jobs",
17
20
  readinessCheckDrafts: "/v1/readiness-check-drafts",
18
21
  methodAuthoringRuns: "/v1/method-authoring-runs",
22
+ methodImprovementRuns: "/v1/method-improvement-runs",
19
23
  runs: "/v1/runs",
24
+ reset: "/v1/reset",
20
25
  executor: "/v1/executor",
21
26
  actionProposals: "/v1/action-proposals",
22
27
  compileRuns: "/v1/compile-runs",