@evomap/evolver-cli 2.0.19 → 2.0.23

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.
@@ -17,6 +17,7 @@ export interface PublishParseResult {
17
17
  autoPair?: boolean;
18
18
  dryRun?: boolean;
19
19
  repair?: boolean;
20
+ noRecipe?: boolean;
20
21
  jsonOut?: boolean;
21
22
  reason?: ContractReason;
22
23
  message?: string;
@@ -57,6 +58,7 @@ interface ContractHubTransport {
57
58
  fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
58
59
  validate(bundle: readonly assetstore.AssetRecord[]): Promise<HubCallResult>;
59
60
  publish(bundle: readonly assetstore.AssetRecord[]): Promise<HubCallResult>;
61
+ composeRecipe?(payload: hub.RecipeComposeInput): Promise<hub.RecipeComposeResult>;
60
62
  }
61
63
  interface PrivateContractProxy {
62
64
  status(): Promise<unknown>;
@@ -71,6 +73,7 @@ interface PrivateContractProxy {
71
73
  submitAssetBundle(bundle: {
72
74
  assets: unknown[];
73
75
  expected_hub_mode?: 'private';
76
+ compose_recipe?: boolean;
74
77
  }): Promise<unknown>;
75
78
  }
76
79
  export interface CliContractDeps {
@@ -16,9 +16,9 @@ const PRIVATE_AUTH_REQUIRED_MESSAGE = 'Private Hub authentication failed; verify
16
16
  const BUNDLE_REQUIRED_MESSAGE = 'publish requires Gene + Capsule bundle; pass --gene <id|path> --capsule <id|path>';
17
17
  const MAX_ASSETS = 50;
18
18
  const PUBLISH_USAGE = [
19
- 'usage: evolver publish --asset <gene_id_or_path> --asset <capsule_id_or_path> --json [--dry-run] [--repair]',
20
- ' evolver publish --gene <id_or_path> --capsule <id_or_path> --json [--dry-run]',
21
- ' evolver publish --gene <id_or_path> --auto-pair --json [--dry-run]',
19
+ 'usage: evolver publish --asset <gene_id_or_path> --asset <capsule_id_or_path> --json [--dry-run] [--repair] [--no-recipe]',
20
+ ' evolver publish --gene <id_or_path> --capsule <id_or_path> --json [--dry-run] [--no-recipe]',
21
+ ' evolver publish --gene <id_or_path> --auto-pair --json [--dry-run] [--no-recipe]',
22
22
  ].join('\n');
23
23
  const ASSET_FLAGS = new Set(['--asset', '--gene', '--capsule', '--event']);
24
24
  const STABLE_CONTRACT_REASONS = new Set([
@@ -174,7 +174,9 @@ export async function runPublishCommand(args, deps = {}) {
174
174
  assets: bundle.assets,
175
175
  }), 1);
176
176
  }
177
- const transport = deps.transport ?? createDefaultTransport(runtimeDeps);
177
+ const transport = deps.transport ?? createDefaultTransport(runtimeDeps, {
178
+ composeRecipe: parsed.noRecipe !== true,
179
+ });
178
180
  const validate = deps.validate ?? transport.validate;
179
181
  // A field-level refusal is a defect in the RECORD, not a verdict on the work in it. Read the Hub's own
180
182
  // `details[]`, mend what is mechanically derivable, and (only when asked) try once more — otherwise the
@@ -268,6 +270,9 @@ export async function runPublishCommand(args, deps = {}) {
268
270
  const bundleId = stringField(payload, 'bundle_id');
269
271
  const publishedBundle = { ...bundle, sanitized: [...effectiveAssets] };
270
272
  appendPublishedCapsuleCall(publishedBundle, deps, { status, receiptId, bundleId });
273
+ const recipeId = parsed.noRecipe || deps.publish
274
+ ? undefined
275
+ : await composePublishedRecipe(transport, effectiveAssets);
271
276
  return write({
272
277
  ok: true,
273
278
  contract: PUBLISH_CONTRACT,
@@ -276,6 +281,7 @@ export async function runPublishCommand(args, deps = {}) {
276
281
  reversibility: REVERSIBILITY,
277
282
  ...(receiptId ? { receipt_id: receiptId } : {}),
278
283
  ...(bundleId ? { bundle_id: bundleId } : {}),
284
+ ...(recipeId ? { recipe_id: recipeId } : {}),
279
285
  ...(safetyCandidate ? { hub_reason: hubReason } : {}),
280
286
  // What the Hub actually holds — after a repair that is the mended record, not the one first submitted.
281
287
  assets: repairApplied?.applied === true ? summarizePublishAssets(effectiveAssets) : bundle.assets,
@@ -435,6 +441,7 @@ export function parsePublishArgs(args) {
435
441
  let autoPair = false;
436
442
  let dryRun = false;
437
443
  let repair = false;
444
+ let noRecipe = false;
438
445
  let jsonOut = false;
439
446
  for (let i = 0; i < args.length; i++) {
440
447
  const token = args[i];
@@ -456,6 +463,10 @@ export function parsePublishArgs(args) {
456
463
  repair = true;
457
464
  continue;
458
465
  }
466
+ if (token === '--no-recipe') {
467
+ noRecipe = true;
468
+ continue;
469
+ }
459
470
  const equalFlag = [...ASSET_FLAGS].find((flag) => token.startsWith(`${flag}=`));
460
471
  if (equalFlag) {
461
472
  const value = token.slice(equalFlag.length + 1).trim();
@@ -508,7 +519,16 @@ export function parsePublishArgs(args) {
508
519
  return { ok: false, reason: 'bundle_required', message: 'publish requires --asset <id|path>' };
509
520
  if (refs.length > MAX_ASSETS)
510
521
  return { ok: false, reason: 'bundle_required', message: `publish supports at most ${MAX_ASSETS} assets` };
511
- return { ok: true, assetRefs: refs, ...(geneRef ? { geneRef } : {}), ...(autoPair ? { autoPair: true } : {}), dryRun, repair, jsonOut };
522
+ return {
523
+ ok: true,
524
+ assetRefs: refs,
525
+ ...(geneRef ? { geneRef } : {}),
526
+ ...(autoPair ? { autoPair: true } : {}),
527
+ dryRun,
528
+ repair,
529
+ ...(noRecipe ? { noRecipe: true } : {}),
530
+ jsonOut,
531
+ };
512
532
  }
513
533
  export async function buildPublishBundle(refs, deps = {}) {
514
534
  let original;
@@ -1064,11 +1084,25 @@ async function withMachineJsonConsole(enabled, deps, fn) {
1064
1084
  machineJsonStdoutBypass = previousBypass;
1065
1085
  }
1066
1086
  }
1067
- function createDefaultTransport(deps) {
1087
+ async function composePublishedRecipe(transport, assets) {
1088
+ if (!transport.composeRecipe)
1089
+ return undefined;
1090
+ try {
1091
+ const composed = await transport.composeRecipe({
1092
+ compose_recipe: true,
1093
+ assets: [...assets],
1094
+ });
1095
+ return composed.ok && composed.recipeId ? composed.recipeId : undefined;
1096
+ }
1097
+ catch {
1098
+ return undefined;
1099
+ }
1100
+ }
1101
+ function createDefaultTransport(deps, opts = {}) {
1068
1102
  const env = loadContractEnv(deps);
1069
1103
  const hubMode = configuredHubMode(env);
1070
1104
  if (hubMode === 'private') {
1071
- return createPrivateTransport(env, deps.resolveProxyClient ?? resolveDefaultPrivateProxy);
1105
+ return createPrivateTransport(env, deps.resolveProxyClient ?? resolveDefaultPrivateProxy, opts.composeRecipe !== false);
1072
1106
  }
1073
1107
  const hubUrl = resolveHubUrl(env);
1074
1108
  const evomapDir = resolveIdentityHome(env);
@@ -1105,6 +1139,9 @@ function createDefaultTransport(deps) {
1105
1139
  fetchAssetById: (assetId) => connected.hub.fetchAssetById(assetId),
1106
1140
  validate: (bundle) => call('/a2a/validate', 'validate', bundle),
1107
1141
  publish: (bundle) => call('/a2a/publish', 'publish', bundle),
1142
+ ...(opts.composeRecipe === false ? {} : {
1143
+ composeRecipe: (payload) => hub.composeRecipeAfterAssetPublish(connected.hub, payload),
1144
+ }),
1108
1145
  };
1109
1146
  }
1110
1147
  function loadContractEnv(deps) {
@@ -1133,7 +1170,7 @@ function configuredHubMode(env) {
1133
1170
  function resolveDefaultPrivateProxy(env) {
1134
1171
  return proxyClientFromEnv(env);
1135
1172
  }
1136
- function createPrivateTransport(env, resolveProxy) {
1173
+ function createPrivateTransport(env, resolveProxy, composeRecipe = true) {
1137
1174
  const proxy = resolveProxy(env);
1138
1175
  if (!proxy)
1139
1176
  throw new Error('private Hub proxy credentials are not configured');
@@ -1174,6 +1211,7 @@ function createPrivateTransport(env, resolveProxy) {
1174
1211
  const body = normalizePrivatePublishBody(await proxy.submitAssetBundle({
1175
1212
  assets: [...bundle],
1176
1213
  expected_hub_mode: 'private',
1214
+ ...(composeRecipe ? {} : { compose_recipe: false }),
1177
1215
  }));
1178
1216
  return { ok: !privatePublishExplicitFailure(body) && normalizePublishStatus(body) !== undefined, status: 200, body };
1179
1217
  }
@@ -59,6 +59,7 @@ export declare const COMMAND_GROUPS: {
59
59
  readonly exec: "Tools";
60
60
  readonly 'anti-gene-benchmark': "Advanced";
61
61
  readonly 'anti-gene-rollout': "Advanced";
62
+ readonly 'model-compatibility-replay': "Advanced";
62
63
  readonly 'reset-local-secret': "Advanced";
63
64
  readonly 'skill-distill': "Advanced";
64
65
  readonly 'skill-md-update': "Advanced";
@@ -72,6 +72,7 @@ export const COMMAND_GROUPS = {
72
72
  exec: 'Tools',
73
73
  'anti-gene-benchmark': 'Advanced',
74
74
  'anti-gene-rollout': 'Advanced',
75
+ 'model-compatibility-replay': 'Advanced',
75
76
  'reset-local-secret': 'Advanced',
76
77
  'skill-distill': 'Advanced',
77
78
  'skill-md-update': 'Advanced',
package/dist/dispatch.js CHANGED
@@ -36,6 +36,7 @@ import { runAssetRepairCommand } from './assetRepair.js';
36
36
  import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat, runV1ExecCompat } from './v1Compat.js';
37
37
  import { runWorkflowCommand } from './workflow.js';
38
38
  import { runMemoryGraphCommand } from './memoryGraphOps.js';
39
+ import { runModelCompatibilityReplay } from './modelCompatibility.js';
39
40
  import { SYNC_COMMAND_NAMES } from './commandCatalog.js';
40
41
  export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
41
42
  const { runProxyCli } = await importer();
@@ -91,6 +92,7 @@ const ASYNC_COMMAND_TABLE = {
91
92
  webui: runV1WebuiCompat,
92
93
  exec: runV1ExecCompat,
93
94
  workflow: runWorkflowCommand,
95
+ 'model-compatibility-replay': runModelCompatibilityReplay,
94
96
  };
95
97
  export const ASYNC_COMMANDS = ASYNC_COMMAND_TABLE;
96
98
  /** Verbs handled by the synchronous runCli core (read-only views + local ops). Kept in sync with runCli's switch
package/dist/lifecycle.js CHANGED
@@ -2495,6 +2495,12 @@ async function bootstrapService(flags, env, argv1, deps, loadUnixRecoveryControl
2495
2495
  if (!plannedArtifactIdentities)
2496
2496
  throw new Error('bootstrap install plan did not declare expected artifact identities');
2497
2497
  requireBootstrapManagerState(probeBootstrapManagerState(target, ownerRun, uid, commandTimeout(deadlineMs, now, BOOTSTRAP_ROLLBACK_RESERVE_MS)), ['absent'], 'preflight existing service check');
2498
+ // Trust the artifact-parent chain with the HOST platform, never the injected target platform.
2499
+ // The deeper owner-lock guard (assertTrustedArtifactParent at .bootstrap-owner) already uses
2500
+ // process.platform; matching it here keeps preflight consistent. Routing this preflight through an
2501
+ // injected POSIX platform on a Windows host would run the POSIX mode-bit chain against a real NTFS
2502
+ // directory, where Node simulates group/world-writable bits and the guard false-positives (#972: the
2503
+ // native-CI bootstrap suite runs with platform:'linux'/'darwin' fixtures on a Windows runner).
2498
2504
  assertPlannedArtifactsAbsent(plannedArtifacts, process.platform, uid);
2499
2505
  assertForwardMutationBudget(deadlineMs, now());
2500
2506
  let journal = createBootstrapJournal({
@@ -5263,11 +5269,26 @@ function normalizeFsIdentity(value) {
5263
5269
  function isPidRunning(pid) {
5264
5270
  try {
5265
5271
  process.kill(pid, 0);
5266
- return true;
5267
5272
  }
5268
5273
  catch (err) {
5269
5274
  return err.code === 'EPERM';
5270
5275
  }
5276
+ // Detached Unix children that have already exited can remain zombies while kill(0)
5277
+ // still succeeds. Treat zombie / defunct state as not running so stop waits complete.
5278
+ if (process.platform === 'win32')
5279
+ return true;
5280
+ try {
5281
+ const state = execFileSync(PS_PATH, ['-p', String(pid), '-o', 'state='], {
5282
+ encoding: 'utf8',
5283
+ stdio: ['ignore', 'pipe', 'ignore'],
5284
+ }).trim();
5285
+ if (state.startsWith('Z'))
5286
+ return false;
5287
+ }
5288
+ catch {
5289
+ // Keep the kill(0) success if process-state inspection is unavailable.
5290
+ }
5291
+ return true;
5271
5292
  }
5272
5293
  function waitForExit(pid, timeoutMs) {
5273
5294
  const start = Date.now();
@@ -0,0 +1,10 @@
1
+ import { compatibility, exec, verify } from '@evomap/evolver-core';
2
+ export interface ModelCompatibilityReplayDeps {
3
+ spawn?: typeof exec.spawnCapture;
4
+ validation?: typeof verify.runSandboxedValidation;
5
+ isolationAvailable?: () => boolean;
6
+ }
7
+ declare function claudeArgs(test: compatibility.ReplayCase): string[];
8
+ export declare function runModelCompatibilityReplay(argv: string[], deps?: ModelCompatibilityReplayDeps): Promise<number>;
9
+ export declare const modelCompatibilityClaudeArgs: typeof claudeArgs;
10
+ export {};
@@ -0,0 +1,296 @@
1
+ import { compatibility, exec, verify } from '@evomap/evolver-core';
2
+ import { cpSync, existsSync, lstatSync, mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
5
+ const MAX_INPUT = 2 * 1024 * 1024;
6
+ const MAX_CASES = 256;
7
+ const EXIT_USAGE = 2;
8
+ const EXIT_RUNTIME = 3;
9
+ const EXIT_QUARANTINE = 4;
10
+ const RESULT_SCHEMA = {
11
+ type: 'object',
12
+ additionalProperties: false,
13
+ properties: {
14
+ status: { type: 'string', enum: ['completed'] },
15
+ task_family: { type: 'string' },
16
+ input_digest: { type: 'string' },
17
+ mode: { type: 'string', enum: ['baseline', 'asset-enabled'] },
18
+ },
19
+ required: ['status', 'task_family', 'input_digest', 'mode'],
20
+ };
21
+ function flag(argv, name) {
22
+ const index = argv.indexOf(name);
23
+ return index >= 0 ? argv[index + 1] : undefined;
24
+ }
25
+ function output(value) { process.stdout.write(`${JSON.stringify(value)}\n`); }
26
+ function fail(message, code) { process.stderr.write(`[model-compatibility-replay] ${message}\n`); return code; }
27
+ function object(value, label) {
28
+ if (!value || typeof value !== 'object' || Array.isArray(value))
29
+ throw new Error(`${label} must be an object`);
30
+ return value;
31
+ }
32
+ function boundedJson(path) {
33
+ const raw = readFileSync(path, 'utf8');
34
+ if (Buffer.byteLength(raw) > MAX_INPUT)
35
+ throw new Error('input exceeds 2 MiB');
36
+ return JSON.parse(raw);
37
+ }
38
+ function positiveNumber(value, label) {
39
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)
40
+ throw new Error(`${label} must be positive`);
41
+ return value;
42
+ }
43
+ function runnerDefinition(value) {
44
+ if (value === undefined)
45
+ return { kind: 'claude-cli' };
46
+ const input = object(value, 'runner');
47
+ const kind = input.kind === 'fixture' ? 'fixture' : input.kind === 'claude-cli' ? 'claude-cli' : undefined;
48
+ if (!kind)
49
+ throw new Error('runner.kind must be claude-cli or fixture');
50
+ return {
51
+ kind,
52
+ ...(typeof input.executable === 'string' ? { executable: input.executable.slice(0, 512) } : {}),
53
+ ...(Array.isArray(input.argv) ? { argv: input.argv.filter((item) => typeof item === 'string').slice(0, 64) } : {}),
54
+ ...(Array.isArray(input.setupFiles) ? { setupFiles: input.setupFiles.filter((item) => typeof item === 'string').slice(0, 64) } : {}),
55
+ };
56
+ }
57
+ function assertWithinRoot(root, value, label) {
58
+ if (isAbsolute(value))
59
+ throw new Error(`${label} must be relative to --cwd`);
60
+ const target = resolve(root, value);
61
+ const rel = relative(root, target);
62
+ if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel))
63
+ throw new Error(`${label} escapes --cwd`);
64
+ return target;
65
+ }
66
+ function replayCase(value, root) {
67
+ const input = object(value, 'case');
68
+ const asset = object(input.asset, 'asset');
69
+ for (const key of ['type', 'id', 'revision'])
70
+ if (typeof asset[key] !== 'string' || !asset[key])
71
+ throw new Error(`asset.${key} is required`);
72
+ if (typeof input.requestedModelId !== 'string' || !input.requestedModelId)
73
+ throw new Error('requestedModelId is required');
74
+ if (typeof input.taskFamily !== 'string' || !input.taskFamily)
75
+ throw new Error('taskFamily is required');
76
+ const budgetInput = object(input.budget, 'budget');
77
+ const timeoutMs = positiveNumber(budgetInput.timeoutMs, 'budget.timeoutMs');
78
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs > 120_000)
79
+ throw new Error('budget.timeoutMs must be an integer up to 120000');
80
+ const validation = Array.isArray(input.validation)
81
+ ? input.validation.filter((item) => typeof item === 'string').slice(0, 64)
82
+ : [];
83
+ if (validation.length === 0)
84
+ throw new Error('validation must contain at least one command');
85
+ for (const command of validation) {
86
+ if (!verify.isValidationCommandAllowed(command))
87
+ throw new Error('validation commands must be safe node scripts');
88
+ const script = verify.validationScriptPath(command);
89
+ if (script)
90
+ assertWithinRoot(root, script, 'validation script');
91
+ }
92
+ return {
93
+ asset: { type: asset.type, id: asset.id, revision: asset.revision },
94
+ requestedModelId: input.requestedModelId,
95
+ taskFamily: input.taskFamily,
96
+ input: input.input,
97
+ environment: input.environment ?? {},
98
+ budget: { maxUsd: positiveNumber(budgetInput.maxUsd, 'budget.maxUsd'), timeoutMs },
99
+ validation,
100
+ };
101
+ }
102
+ function copySandbox(root, files) {
103
+ const sandbox = mkdtempSync(join(tmpdir(), 'evolver-model-compatibility-'));
104
+ try {
105
+ for (const file of files) {
106
+ const source = assertWithinRoot(root, file, 'setup file');
107
+ if (!existsSync(source) || lstatSync(source).isSymbolicLink())
108
+ throw new Error(`setup file is missing or symlinked: ${file}`);
109
+ const target = join(sandbox, file);
110
+ const parent = dirname(target);
111
+ const parentRel = relative(sandbox, parent);
112
+ if (parentRel === '..' || parentRel.startsWith(`..${sep}`))
113
+ throw new Error('setup target escapes sandbox');
114
+ cpSync(source, target, { recursive: statSync(source).isDirectory(), dereference: false, force: true });
115
+ }
116
+ return sandbox;
117
+ }
118
+ catch (error) {
119
+ rmSync(sandbox, { recursive: true, force: true });
120
+ throw error;
121
+ }
122
+ }
123
+ function claudeArgs(test) {
124
+ return [
125
+ '--print', '--safe-mode', '--no-session-persistence', '--tools', '', '--permission-mode', 'dontAsk',
126
+ '--model', test.requestedModelId, '--effort', 'low', '--output-format', 'json',
127
+ '--json-schema', JSON.stringify(RESULT_SCHEMA), '--max-budget-usd', String(test.budget.maxUsd),
128
+ ];
129
+ }
130
+ function fixtureArgs(definition, test, mode) {
131
+ const argv = [...(definition.argv ?? [])];
132
+ if (argv.some((item) => /[;&|`$<>\n\r]/.test(item)))
133
+ throw new Error('unsafe fixture argv');
134
+ return [...argv, '--model', test.requestedModelId, '--mode', mode];
135
+ }
136
+ function prompt(test, mode) {
137
+ return JSON.stringify({
138
+ instruction: 'Execute the fixed compatibility replay task. Do not use fallback models. Return only the schema result.',
139
+ task_family: test.taskFamily,
140
+ input_digest: compatibility.canonicalDigest(test.input),
141
+ mode,
142
+ asset: mode === 'asset-enabled' ? test.asset : null,
143
+ input: test.input,
144
+ });
145
+ }
146
+ function finiteInteger(value) {
147
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
148
+ }
149
+ function finiteNumber(value) {
150
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
151
+ }
152
+ function parseStructuredResult(value, test, mode) {
153
+ let result = value;
154
+ if (typeof result === 'string') {
155
+ try {
156
+ result = JSON.parse(result);
157
+ }
158
+ catch {
159
+ return null;
160
+ }
161
+ }
162
+ if (!result || typeof result !== 'object' || Array.isArray(result))
163
+ return null;
164
+ const row = result;
165
+ if (Object.keys(row).some((key) => !['status', 'task_family', 'input_digest', 'mode'].includes(key)))
166
+ return null;
167
+ return row.status === 'completed'
168
+ && row.task_family === test.taskFamily
169
+ && row.input_digest === compatibility.canonicalDigest(test.input)
170
+ && row.mode === mode ? row : null;
171
+ }
172
+ function parseClaudeEnvelope(raw, test, mode, processResult) {
173
+ let envelope;
174
+ try {
175
+ envelope = object(JSON.parse(raw), 'Claude CLI envelope');
176
+ }
177
+ catch {
178
+ envelope = undefined;
179
+ }
180
+ const usage = envelope?.usage && typeof envelope.usage === 'object' ? envelope.usage : undefined;
181
+ const modelUsage = envelope?.modelUsage && typeof envelope.modelUsage === 'object' && !Array.isArray(envelope.modelUsage)
182
+ ? envelope.modelUsage : undefined;
183
+ const servedIds = modelUsage ? Object.keys(modelUsage) : [];
184
+ const servedModel = servedIds.length === 1 && servedIds[0] === test.requestedModelId
185
+ ? { id: servedIds[0], source: 'claude-cli-envelope' }
186
+ : null;
187
+ const inputTokens = finiteInteger(usage?.input_tokens);
188
+ const outputTokens = finiteInteger(usage?.output_tokens);
189
+ const cacheCreation = finiteInteger(usage?.cache_creation_input_tokens);
190
+ const cacheRead = finiteInteger(usage?.cache_read_input_tokens);
191
+ const cost = finiteNumber(envelope?.total_cost_usd);
192
+ const parsedUsage = inputTokens !== undefined && outputTokens !== undefined && cacheCreation !== undefined && cacheRead !== undefined && cost !== undefined
193
+ ? { inputTokens, outputTokens, cacheCreationInputTokens: cacheCreation, cacheReadInputTokens: cacheRead, costUsd: cost }
194
+ : null;
195
+ const structuredResult = parseStructuredResult(envelope?.structured_output ?? envelope?.result, test, mode);
196
+ const sessionId = typeof envelope?.session_id === 'string' && envelope.session_id.length > 0 ? envelope.session_id : null;
197
+ const envelopeSuccess = envelope?.type === 'result' && envelope.subtype === 'success' && envelope.is_error === false;
198
+ return {
199
+ trust: 'claude-cli', mode,
200
+ ok: processResult.code === 0 && processResult.termination === 'exit' && envelopeSuccess,
201
+ exitCode: processResult.code,
202
+ termination: processResult.termination,
203
+ requestedModel: { id: test.requestedModelId }, servedModel, sessionId, usage: parsedUsage, structuredResult,
204
+ stdoutTruncated: processResult.stdoutTruncated === true,
205
+ stderrTruncated: processResult.stderrTruncated === true,
206
+ };
207
+ }
208
+ function fixtureObservation(test, mode, result) {
209
+ return {
210
+ trust: 'fixture', mode, ok: result.code === 0 && result.termination === 'exit', exitCode: result.code,
211
+ termination: result.termination, requestedModel: { id: test.requestedModelId }, servedModel: null,
212
+ sessionId: null, usage: null, structuredResult: null,
213
+ stdoutTruncated: result.stdoutTruncated === true, stderrTruncated: result.stderrTruncated === true,
214
+ };
215
+ }
216
+ async function execute(definition, test, mode, cwd, deps) {
217
+ const spawn = deps.spawn ?? exec.spawnCapture;
218
+ const executable = definition.kind === 'claude-cli' ? definition.executable ?? 'claude' : definition.executable ?? process.execPath;
219
+ if (definition.kind === 'claude-cli' && executable !== 'claude')
220
+ throw new Error('claude-cli runner executable must be claude');
221
+ if (definition.kind === 'fixture' && ![process.execPath, 'node', 'nodejs'].includes(executable))
222
+ throw new Error('fixture executable is not allowlisted');
223
+ const result = await spawn(executable, definition.kind === 'claude-cli' ? claudeArgs(test) : fixtureArgs(definition, test, mode), {
224
+ cwd, timeoutMs: test.budget.timeoutMs, input: prompt(test, mode), maxOutputBytes: 256 * 1024,
225
+ env: { PATH: process.env.PATH ?? '/usr/bin:/bin', HOME: cwd, NODE_ENV: 'production' },
226
+ });
227
+ const processEvidence = definition.kind === 'claude-cli'
228
+ ? parseClaudeEnvelope(result.stdout, test, mode, result)
229
+ : fixtureObservation(test, mode, result);
230
+ const validate = deps.validation ?? verify.runSandboxedValidation;
231
+ const validation = await validate(test.validation, cwd, {
232
+ timeoutMs: Math.min(test.budget.timeoutMs, 30_000), requireIsolation: true, readOnlyRoot: cwd,
233
+ ...(deps.isolationAvailable ? { unshareCheck: deps.isolationAvailable } : {}),
234
+ });
235
+ const steps = validation.results.map((item) => ({
236
+ command: item.cmd, exitCode: item.exitCode, passed: item.passed, executed: true, termination: 'exit',
237
+ }));
238
+ for (const skipped of validation.skipped)
239
+ steps.push({
240
+ command: skipped.cmd, exitCode: null, passed: false, executed: false, termination: 'not-started',
241
+ });
242
+ return { ...processEvidence, validation: compatibility.validationTrace(validation.isolated, steps) };
243
+ }
244
+ export async function runModelCompatibilityReplay(argv, deps = {}) {
245
+ if (argv.includes('--help')) {
246
+ output({ usage: 'evolver model-compatibility-replay --input <json> [--ledger <json>] [--cwd <dir>] [--retries <n>] [--transition quarantine|revalidate|release --request-id <id> --reason <text>]' });
247
+ return 0;
248
+ }
249
+ const inputPath = flag(argv, '--input');
250
+ if (!inputPath)
251
+ return fail('Usage: evolver model-compatibility-replay --input <json>', EXIT_USAGE);
252
+ try {
253
+ const root = resolve(flag(argv, '--cwd') ?? process.cwd());
254
+ const source = boundedJson(resolve(inputPath));
255
+ const body = Array.isArray(source) ? { cases: source } : object(source, 'input');
256
+ const cases = Array.isArray(body.cases) ? body.cases : null;
257
+ if (!cases || cases.length === 0 || cases.length > MAX_CASES)
258
+ throw new Error('input must contain 1 to 256 cases');
259
+ const corpus = cases.map((item) => replayCase(item, root));
260
+ const ledgerPath = flag(argv, '--ledger');
261
+ const transition = flag(argv, '--transition');
262
+ if (transition) {
263
+ if (!ledgerPath || corpus.length !== 1 || !['quarantine', 'revalidate', 'release'].includes(transition))
264
+ throw new Error('transition requires --ledger, one case, and a valid transition');
265
+ const requestId = flag(argv, '--request-id');
266
+ const reason = flag(argv, '--reason');
267
+ if (!requestId || !reason)
268
+ throw new Error('transition requires --request-id and --reason');
269
+ const ledger = new compatibility.CompatibilityLedger(resolve(ledgerPath));
270
+ const changed = ledger.transition(compatibility.compatibilityKey(corpus[0]), transition, requestId, reason);
271
+ output({ changed, resolved: ledger.resolve(compatibility.compatibilityKey(corpus[0])) });
272
+ return 0;
273
+ }
274
+ const definition = runnerDefinition(body.runner);
275
+ const retries = Math.max(0, Math.min(Number(flag(argv, '--retries') ?? '1') || 0, 5));
276
+ const setupFiles = definition.setupFiles ?? [];
277
+ const run = await compatibility.replayCorpus(corpus, async ({ mode, test }) => {
278
+ const sandbox = copySandbox(root, setupFiles);
279
+ try {
280
+ return await execute(definition, test, mode, sandbox, deps);
281
+ }
282
+ finally {
283
+ rmSync(sandbox, { recursive: true, force: true });
284
+ }
285
+ }, { requestId: flag(argv, '--request-id'), retries });
286
+ if (ledgerPath)
287
+ new compatibility.CompatibilityLedger(resolve(ledgerPath)).appendRun(run);
288
+ const decisions = run.evidence.map((item) => compatibility.evaluateEvidence(item));
289
+ output({ ...run, decisions });
290
+ return decisions.includes('quarantine') ? EXIT_QUARANTINE : 0;
291
+ }
292
+ catch (error) {
293
+ return fail(error instanceof Error ? error.message : String(error), EXIT_RUNTIME);
294
+ }
295
+ }
296
+ export const modelCompatibilityClaudeArgs = claudeArgs;
package/dist/recipe.d.ts CHANGED
@@ -54,7 +54,13 @@ export interface RecipeFromSkillsOptions {
54
54
  publish: boolean;
55
55
  jsonOut: boolean;
56
56
  }
57
- export type RecipeOptions = RecipeBuildOptions | RecipeReuseOptions | RecipeFromSkillsOptions;
57
+ export interface RecipeSearchOptions {
58
+ sub: 'search';
59
+ q?: string;
60
+ limit?: number;
61
+ jsonOut: boolean;
62
+ }
63
+ export type RecipeOptions = RecipeBuildOptions | RecipeReuseOptions | RecipeFromSkillsOptions | RecipeSearchOptions;
58
64
  export declare function runRecipeCommand(argv: readonly string[], deps?: RecipeCliDeps): Promise<number>;
59
65
  export declare function createRecipeHubFromEnv(env?: NodeJS.ProcessEnv, connectHub?: (opts: ConnectPublicOptions) => {
60
66
  hub: PublicHubCapability;
package/dist/recipe.js CHANGED
@@ -37,6 +37,8 @@ export async function runRecipeCommand(argv, deps = {}) {
37
37
  return await runRecipeBuildDryRun(parsed.value, deps.store, { log, err });
38
38
  if (parsed.value.sub === 'from-skills')
39
39
  return await runRecipeFromSkills(parsed.value, undefined, deps, { log, err }, true);
40
+ if (parsed.value.sub === 'search')
41
+ return runRecipeSearchDryRun(parsed.value, { log });
40
42
  return runRecipeReuseDryRun(parsed.value, { log });
41
43
  }
42
44
  const hub = deps.hub ?? createRecipeHubFromEnv(env, deps.connectHub ?? connectPublicHub);
@@ -49,6 +51,8 @@ export async function runRecipeCommand(argv, deps = {}) {
49
51
  return await runRecipeBuild(parsed.value, hub, deps.store, { log, err });
50
52
  if (parsed.value.sub === 'from-skills')
51
53
  return await runRecipeFromSkills(parsed.value, hub, deps, { log, err }, false);
54
+ if (parsed.value.sub === 'search')
55
+ return await runRecipeSearch(parsed.value, hub, { log, err });
52
56
  return await runRecipeReuse(parsed.value, hub, { log, err });
53
57
  }
54
58
  catch (e) {
@@ -71,6 +75,49 @@ async function runRecipeBuildDryRun(opts, store, io) {
71
75
  }
72
76
  return 0;
73
77
  }
78
+ function runRecipeSearchDryRun(opts, io) {
79
+ const action = opts.q ? 'search_recipe' : 'list_recipe';
80
+ io.log(`[recipe search] dry-run: would ${opts.q ? `search recipes q=${JSON.stringify(opts.q)}` : 'list published recipes'}.`);
81
+ if (opts.jsonOut) {
82
+ io.log(JSON.stringify({
83
+ dry_run: true,
84
+ would: action,
85
+ ...(opts.q ? { q: opts.q } : {}),
86
+ ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
87
+ recipes: [],
88
+ }, null, 2));
89
+ }
90
+ return 0;
91
+ }
92
+ async function runRecipeSearch(opts, hub, io) {
93
+ const recipes = hub.recipes;
94
+ if (!recipes) {
95
+ io.err('recipe capability is not available for the configured Hub adapter');
96
+ return 1;
97
+ }
98
+ const request = {
99
+ ...(opts.q ? { q: opts.q } : {}),
100
+ ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
101
+ };
102
+ const receipt = opts.q
103
+ ? await callRecipeWithAuthRetry(hub, 'recipe search', () => recipes.search(request), io)
104
+ : await callRecipeWithAuthRetry(hub, 'recipe search', () => recipes.list(request), io);
105
+ io.log(`[recipe search] ${receipt.recipes.length} recipe(s).`);
106
+ if (opts.jsonOut) {
107
+ io.log(JSON.stringify(receipt.raw ?? receipt, null, 2));
108
+ return 0;
109
+ }
110
+ for (const recipe of receipt.recipes) {
111
+ const row = recipe && typeof recipe === 'object' && !Array.isArray(recipe) ? recipe : {};
112
+ const id = typeof row['id'] === 'string' ? row['id']
113
+ : typeof row['recipe_id'] === 'string' ? row['recipe_id']
114
+ : typeof row['recipeId'] === 'string' ? row['recipeId']
115
+ : undefined;
116
+ const title = typeof row['title'] === 'string' ? row['title'] : undefined;
117
+ io.log(id && title ? ` ${id} ${title}` : id ? ` ${id}` : ` ${JSON.stringify(recipe)}`);
118
+ }
119
+ return 0;
120
+ }
74
121
  function runRecipeReuseDryRun(opts, io) {
75
122
  io.log(`[recipe reuse] dry-run: would fetch recipe ${opts.recipeId}.`);
76
123
  io.log(`[recipe reuse] dry-run: would express recipe ${opts.recipeId}.`);
@@ -153,13 +200,16 @@ function resolveRecipeHubUrl(env) {
153
200
  }
154
201
  export function parseRecipeArgs(argv) {
155
202
  const sub = argv[0];
156
- if (sub !== 'build' && sub !== 'reuse' && sub !== 'from-skills')
157
- return { ok: false, error: 'recipe subcommand must be build|reuse|from-skills' };
203
+ if (sub !== 'build' && sub !== 'reuse' && sub !== 'from-skills' && sub !== 'search') {
204
+ return { ok: false, error: 'recipe subcommand must be build|reuse|from-skills|search' };
205
+ }
158
206
  const args = argv.slice(1);
159
207
  if (sub === 'build')
160
208
  return parseBuildArgs(args);
161
209
  if (sub === 'from-skills')
162
210
  return parseFromSkillsArgs(args);
211
+ if (sub === 'search')
212
+ return parseSearchArgs(args);
163
213
  return parseReuseArgs(args);
164
214
  }
165
215
  async function runRecipeBuild(opts, hub, store, io) {
@@ -881,6 +931,23 @@ function parseFromSkillsArgs(args) {
881
931
  },
882
932
  };
883
933
  }
934
+ function parseSearchArgs(args) {
935
+ const q = flagValue(args, '--q') ?? flagValue(args, '--query') ?? firstPositional(args) ?? undefined;
936
+ const limitRaw = flagValue(args, '--limit');
937
+ const limit = limitRaw === null ? undefined : Number(limitRaw);
938
+ if (limit !== undefined && (!Number.isSafeInteger(limit) || limit <= 0)) {
939
+ return { ok: false, error: '--limit must be a positive integer' };
940
+ }
941
+ return {
942
+ ok: true,
943
+ value: {
944
+ sub: 'search',
945
+ ...(q ? { q } : {}),
946
+ ...(limit !== undefined ? { limit } : {}),
947
+ jsonOut: args.includes('--json'),
948
+ },
949
+ };
950
+ }
884
951
  function parseReuseArgs(args) {
885
952
  const recipeId = flagValue(args, '--id') ?? firstPositional(args);
886
953
  if (!recipeId)
@@ -1278,5 +1345,7 @@ function recipeUsage() {
1278
1345
  ' evolver recipe from-skills --manifest <file> [--publish] [--json]',
1279
1346
  ' Distills ordered SKILL.md steps with execution evidence, then creates a recipe.',
1280
1347
  ' evolver recipe reuse --id <recipe_id> [--input <json-object>] [--json]',
1348
+ ' evolver recipe search [--q <text>] [--limit <n>] [--json]',
1349
+ ' Default agent lookup. Express a hit with `evolver recipe reuse`. Gene/Capsule search is fallback.',
1281
1350
  ].join('\n');
1282
1351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.19",
3
+ "version": "2.0.23",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -23,12 +23,12 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@evomap/evolver-core": "2.0.19",
27
- "@evomap/evolver-adapter-public": "2.0.19",
28
- "@evomap/evolver-mcp": "2.0.19",
29
- "@evomap/evolver-proxy": "2.0.19",
30
- "@evomap/evolver-runtime-adapters": "2.0.19",
31
- "@evomap/evolver-webui": "2.0.19"
26
+ "@evomap/evolver-core": "2.0.23",
27
+ "@evomap/evolver-adapter-public": "2.0.23",
28
+ "@evomap/evolver-mcp": "2.0.23",
29
+ "@evomap/evolver-proxy": "2.0.23",
30
+ "@evomap/evolver-runtime-adapters": "2.0.23",
31
+ "@evomap/evolver-webui": "2.0.23"
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",