@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.22

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 (124) hide show
  1. package/dist/antiGeneBenchmark.js +2 -0
  2. package/dist/antiGeneRollout.js +9 -3
  3. package/dist/assetHealth.d.ts +6 -0
  4. package/dist/assetHealth.js +107 -0
  5. package/dist/assetRepair.d.ts +24 -0
  6. package/dist/assetRepair.js +172 -0
  7. package/dist/assetSidecarRecovery.d.ts +14 -0
  8. package/dist/assetSidecarRecovery.js +171 -0
  9. package/dist/assetTrust.d.ts +24 -0
  10. package/dist/assetTrust.js +231 -0
  11. package/dist/atp.d.ts +10 -5
  12. package/dist/atp.js +119 -26
  13. package/dist/atpAutoBuyer.d.ts +120 -0
  14. package/dist/atpAutoBuyer.js +814 -0
  15. package/dist/atpAutoDeliver.js +2 -2
  16. package/dist/autoDistillAntiGene.js +7 -5
  17. package/dist/autoDistillLlm.d.ts +26 -0
  18. package/dist/autoDistillLlm.js +119 -22
  19. package/dist/autoDistillTranscript.js +3 -2
  20. package/dist/autoexec.d.ts +111 -24
  21. package/dist/autoexec.js +887 -120
  22. package/dist/autoexecConfig.d.ts +10 -0
  23. package/dist/autoexecConfig.js +69 -0
  24. package/dist/cli.js +13 -0
  25. package/dist/cliContracts.d.ts +33 -2
  26. package/dist/cliContracts.js +818 -78
  27. package/dist/commandCatalog.d.ts +72 -0
  28. package/dist/commandCatalog.js +120 -0
  29. package/dist/commands.d.ts +1 -0
  30. package/dist/commands.js +1 -0
  31. package/dist/curriculumCapabilityGaps.d.ts +6 -0
  32. package/dist/curriculumCapabilityGaps.js +24 -0
  33. package/dist/cycleConsumer.d.ts +17 -2
  34. package/dist/cycleConsumer.js +374 -50
  35. package/dist/dashboard.d.ts +13 -1
  36. package/dist/dashboard.js +235 -18
  37. package/dist/dispatch.d.ts +9 -2
  38. package/dist/dispatch.js +29 -6
  39. package/dist/distillAdmission.d.ts +13 -0
  40. package/dist/distillAdmission.js +35 -0
  41. package/dist/distillObserver.js +27 -12
  42. package/dist/distillPrimitives.d.ts +11 -8
  43. package/dist/distillPrimitives.js +116 -22
  44. package/dist/doctor.d.ts +13 -0
  45. package/dist/doctor.js +177 -10
  46. package/dist/identityHome.d.ts +9 -0
  47. package/dist/identityHome.js +47 -0
  48. package/dist/index.d.ts +73 -40
  49. package/dist/index.js +745 -207
  50. package/dist/issueReport.d.ts +7 -0
  51. package/dist/issueReport.js +291 -0
  52. package/dist/learningTrace.d.ts +15 -0
  53. package/dist/learningTrace.js +73 -0
  54. package/dist/lifecycle.d.ts +199 -2
  55. package/dist/lifecycle.js +4999 -152
  56. package/dist/lifecycleBootstrapTransaction.d.ts +235 -0
  57. package/dist/lifecycleBootstrapTransaction.js +2182 -0
  58. package/dist/localMemoryGraph.d.ts +184 -0
  59. package/dist/localMemoryGraph.js +2689 -0
  60. package/dist/login.d.ts +1 -1
  61. package/dist/login.js +3 -3
  62. package/dist/materialPackage.js +3 -6
  63. package/dist/materialSnapshot.d.ts +35 -1
  64. package/dist/materialSnapshot.js +265 -18
  65. package/dist/memoryGraphOps.d.ts +8 -0
  66. package/dist/memoryGraphOps.js +140 -0
  67. package/dist/migrate/assetFormatMap.d.ts +61 -0
  68. package/dist/migrate/assetFormatMap.js +53 -0
  69. package/dist/migrate/envTranslate.d.ts +26 -0
  70. package/dist/migrate/envTranslate.js +147 -0
  71. package/dist/migrate/fieldMap.d.ts +7 -5
  72. package/dist/migrate/fieldMap.js +20 -14
  73. package/dist/migrate/oauthImport.d.ts +66 -0
  74. package/dist/migrate/oauthImport.js +667 -0
  75. package/dist/migrate/v1Import.d.ts +98 -1
  76. package/dist/migrate/v1Import.js +1532 -71
  77. package/dist/modelCompatibility.d.ts +10 -0
  78. package/dist/modelCompatibility.js +296 -0
  79. package/dist/promptRecallHook.d.ts +24 -0
  80. package/dist/promptRecallHook.js +425 -0
  81. package/dist/recallVerifyReport.d.ts +37 -0
  82. package/dist/recallVerifyReport.js +244 -0
  83. package/dist/recipe.d.ts +14 -2
  84. package/dist/recipe.js +543 -65
  85. package/dist/repairedAssetStore.d.ts +2 -0
  86. package/dist/repairedAssetStore.js +12 -0
  87. package/dist/requiredSandboxValidation.d.ts +5 -0
  88. package/dist/requiredSandboxValidation.js +4 -0
  89. package/dist/reuse.d.ts +18 -4
  90. package/dist/reuse.js +375 -107
  91. package/dist/reviewFilter.d.ts +3 -1
  92. package/dist/reviewFilter.js +3 -1
  93. package/dist/runtimeCapabilities.d.ts +18 -0
  94. package/dist/runtimeCapabilities.js +81 -0
  95. package/dist/runtimeSessionSource.d.ts +8 -2
  96. package/dist/runtimeSessionSource.js +63 -11
  97. package/dist/selectionPolicyConfig.d.ts +8 -0
  98. package/dist/selectionPolicyConfig.js +18 -0
  99. package/dist/semanticIdfConfig.d.ts +2 -0
  100. package/dist/semanticIdfConfig.js +4 -0
  101. package/dist/sessionIngest.d.ts +43 -0
  102. package/dist/sessionIngest.js +180 -0
  103. package/dist/setupHooks.d.ts +5 -0
  104. package/dist/setupHooks.js +330 -14
  105. package/dist/skill2gep.d.ts +13 -9
  106. package/dist/skill2gep.js +99 -36
  107. package/dist/skillDistill.d.ts +8 -4
  108. package/dist/skillDistill.js +39 -9
  109. package/dist/solo/mode.js +1 -0
  110. package/dist/sync.d.ts +13 -1
  111. package/dist/sync.js +1947 -265
  112. package/dist/thesis.d.ts +1 -1
  113. package/dist/thesis.js +20 -3
  114. package/dist/trajectoryExport.js +21 -3
  115. package/dist/v1Compat.d.ts +1 -0
  116. package/dist/v1Compat.js +9 -0
  117. package/dist/valueDigest.js +8 -1
  118. package/dist/windowsLegacyTaskCleanup.d.ts +228 -0
  119. package/dist/windowsLegacyTaskCleanup.js +1475 -0
  120. package/dist/workflow.d.ts +39 -0
  121. package/dist/workflow.js +386 -0
  122. package/dist/workflowRuntime.d.ts +66 -0
  123. package/dist/workflowRuntime.js +638 -0
  124. package/package.json +14 -7
@@ -4,16 +4,24 @@
4
4
  // (the real device-wide scope); `--scope=project` (default) writes the project's own .mcp.json. Deny-nothing:
5
5
  // it only writes the runtime's own config, is idempotent, refuses symlinked adapter paths, and `--uninstall`
6
6
  // cleanly removes only evolver's entries.
7
- import { planInjection, installInjection, uninstallInjection, runtimeSupport, renderManualWiring, renderServiceGuidance, SETUP_RUNTIMES, SERVICE_TARGETS } from '@evomap/evolver-mcp';
7
+ import { planInjection, installInjection, uninstallInjection, runtimeSupport, renderManualWiring, renderServiceGuidance, SETUP_RUNTIMES, SERVICE_TARGETS, kiroConfigRoot, resolveOpenCodeConfig, McpConfigConflictError, McpConfigOwnershipError, McpConfigVerificationError, McpServerValidationError } from '@evomap/evolver-mcp';
8
8
  import { assetstore, events } from '@evomap/evolver-core';
9
- import { readFileSync } from 'node:fs';
9
+ import { accessSync, constants, existsSync, readFileSync, statSync } from 'node:fs';
10
10
  import { createRequire } from 'node:module';
11
+ import { homedir } from 'node:os';
12
+ import { delimiter, dirname, isAbsolute, join, relative, sep } from 'node:path';
11
13
  import { fileURLToPath } from 'node:url';
12
14
  import { currentTopCursorGenes } from './cursorRewrite.js';
13
15
  import { resolveProxyBinPath, resolveStableNodePath } from './lifecycle.js';
14
16
  import { reviewLedgerForStore } from './reviewFilter.js';
15
17
  import { maybeEmitNonGitWorkspaceNotice } from './nonGitWorkspaceNotice.js';
16
18
  const requireFromHere = createRequire(import.meta.url);
19
+ function configuredHomeDir() {
20
+ const configured = process.platform === 'win32'
21
+ ? process.env['USERPROFILE']
22
+ : process.env['HOME'];
23
+ return configured && configured.trim() ? configured : homedir();
24
+ }
17
25
  function parseFlags(argv) {
18
26
  const out = {};
19
27
  for (let i = 0; i < argv.length; i++) {
@@ -34,7 +42,133 @@ function parseFlags(argv) {
34
42
  }
35
43
  return out;
36
44
  }
37
- const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--root=<dir>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--uninstall] [--force] [--json] [--hook-command="evolver inject session-start"] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n`;
45
+ const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--root=<dir>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--verify] [--uninstall] [--dry-run] [--force] [--json] [--hook-command="evolver inject session-start"] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n --verify is read-only for opencode and kiro\n`;
46
+ export function commandNamesForPath(command, platform, pathExt) {
47
+ if (platform !== 'win32' || /\.[^\\/]+$/.test(command))
48
+ return [command];
49
+ const extensions = (pathExt?.trim() || '.COM;.EXE;.BAT;.CMD')
50
+ .split(';')
51
+ .map((extension) => extension.trim())
52
+ .filter((extension) => /^\.?[A-Za-z\d]+$/.test(extension))
53
+ .map((extension) => extension.startsWith('.') ? extension : `.${extension}`);
54
+ return [command, ...extensions.map((extension) => `${command}${extension}`)];
55
+ }
56
+ function commandOnPath(command) {
57
+ const names = commandNamesForPath(command, process.platform, process.env['PATHEXT']);
58
+ for (const directory of (process.env['PATH'] ?? '').split(delimiter).filter(Boolean)) {
59
+ for (const name of names) {
60
+ try {
61
+ const candidate = join(directory, name);
62
+ if (!statSync(candidate).isFile())
63
+ continue;
64
+ accessSync(candidate, constants.X_OK);
65
+ return true;
66
+ }
67
+ catch {
68
+ // Continue searching PATH.
69
+ }
70
+ }
71
+ }
72
+ return false;
73
+ }
74
+ function defaultRuntimeAvailable(runtime, configRoot, scope) {
75
+ if (runtime === 'opencode') {
76
+ const resolution = resolveOpenCodeConfig({
77
+ configRoot,
78
+ scope,
79
+ homeDir: configuredHomeDir(),
80
+ xdgConfigHome: process.env['XDG_CONFIG_HOME'],
81
+ opencodeConfig: process.env['OPENCODE_CONFIG'],
82
+ opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
83
+ });
84
+ return commandOnPath('opencode') || (resolution.evidencePaths ?? [resolution.configPath]).some(existsSync);
85
+ }
86
+ const pathOptions = {
87
+ configRoot,
88
+ homeDir: configuredHomeDir(),
89
+ kiroHome: process.env['KIRO_HOME'],
90
+ };
91
+ const evidenceRoots = scope === 'project'
92
+ ? [
93
+ kiroConfigRoot({ ...pathOptions, scope: 'project' }),
94
+ kiroConfigRoot({ ...pathOptions, scope: 'user' }),
95
+ ]
96
+ : [kiroConfigRoot({ ...pathOptions, scope: 'user' })];
97
+ return commandOnPath('kiro') || commandOnPath('kiro-cli') || evidenceRoots.some(existsSync);
98
+ }
99
+ function displaySetupPath(path, configRoot, scope) {
100
+ if (scope === 'user') {
101
+ const home = configuredHomeDir();
102
+ const homePath = safeRelativePath(home, path);
103
+ if (homePath === '')
104
+ return '~';
105
+ if (homePath !== undefined)
106
+ return `~/${homePath.replaceAll('\\', '/')}`;
107
+ }
108
+ const projectPath = safeProjectRelativePath(configRoot, path);
109
+ if (projectPath === '')
110
+ return '.';
111
+ return projectPath !== undefined ? projectPath.replaceAll('\\', '/') : '<config-path>';
112
+ }
113
+ function safeRelativePath(root, path) {
114
+ const candidate = relative(root, path);
115
+ if (isAbsolute(candidate) || candidate === '..' || candidate.startsWith(`..${sep}`))
116
+ return undefined;
117
+ return candidate;
118
+ }
119
+ function safeProjectRelativePath(root, path) {
120
+ const descendant = safeRelativePath(root, path);
121
+ if (descendant !== undefined)
122
+ return descendant;
123
+ return safeRelativePath(dirname(path), root) === undefined ? undefined : relative(root, path);
124
+ }
125
+ function displayResultPaths(paths, configRoot, scope) {
126
+ return paths?.map((path) => displaySetupPath(path, configRoot, scope));
127
+ }
128
+ export function safeSetupOperationError(error) {
129
+ if (error instanceof McpConfigConflictError)
130
+ return error.message;
131
+ if (error instanceof McpConfigOwnershipError)
132
+ return error.message;
133
+ if (error instanceof McpConfigVerificationError) {
134
+ return error.restored
135
+ ? '[setup-hooks] runtime configuration verification failed; the previous configuration was restored.'
136
+ : '[setup-hooks] runtime configuration verification failed; rollback could not be confirmed. Inspect the runtime config before retrying.';
137
+ }
138
+ if (error instanceof McpServerValidationError)
139
+ return error.message;
140
+ const name = error instanceof Error ? error.name : '';
141
+ switch (name) {
142
+ case 'McpConfigConflictError': return '[setup-hooks] existing Evolver configuration conflicts; use --force to replace only the Evolver entry.';
143
+ case 'McpConfigOwnershipError': return '[setup-hooks] Evolver ownership metadata is ambiguous or no longer matches the runtime configuration; inspect it before retrying.';
144
+ case 'McpConfigShapeError': return '[setup-hooks] runtime configuration has an invalid JSON shape.';
145
+ case 'McpConfigVerificationError': return error.restored === true
146
+ ? '[setup-hooks] runtime configuration verification failed; the previous configuration was restored.'
147
+ : '[setup-hooks] runtime configuration verification failed; rollback could not be confirmed. Inspect the runtime config before retrying.';
148
+ case 'McpConfigChangedError': return '[setup-hooks] runtime configuration changed during the operation; retry after the runtime finishes writing it.';
149
+ case 'EmptySharedConfigError': return '[setup-hooks] runtime configuration is empty; repair or remove it before retrying.';
150
+ case 'UnparseableConfigError': return '[setup-hooks] runtime configuration is not valid JSON; repair it before retrying.';
151
+ case 'SymlinkRefusedError': return '[setup-hooks] refused an unsafe symbolic-link configuration path.';
152
+ default: return '[setup-hooks] runtime configuration operation failed.';
153
+ }
154
+ }
155
+ export function safeSetupResultError(error) {
156
+ if (typeof error !== 'string')
157
+ return safeSetupOperationError(error);
158
+ const reason = error.replace(/\s+/g, ' ').trim();
159
+ const passive = reason.match(/^passive runtime ([a-z0-9][a-z0-9-]{0,63}): no tool injection$/);
160
+ const unimplementedInstall = reason.match(/^installer not yet implemented for ([a-z0-9][a-z0-9-]{0,63}) \(supported: [a-z0-9, -]+\)$/);
161
+ const unimplementedUninstall = reason.match(/^uninstall not implemented for ([a-z0-9][a-z0-9-]{0,63})$/);
162
+ const runtime = passive?.[1] ?? unimplementedInstall?.[1] ?? unimplementedUninstall?.[1];
163
+ if (!runtime || !SETUP_RUNTIMES.includes(runtime)) {
164
+ return safeSetupOperationError(error);
165
+ }
166
+ if (passive)
167
+ return `[setup-hooks] passive runtime ${runtime}: no tool injection`;
168
+ if (unimplementedInstall)
169
+ return `[setup-hooks] installer not yet implemented for ${runtime}`;
170
+ return `[setup-hooks] uninstall not implemented for ${runtime}`;
171
+ }
38
172
  const PROFILE_DESCRIPTOR_FLAG = 'profile-descriptor';
39
173
  const SECRET_ASSIGNMENT_RE = /\b(?:A2A_NODE_SECRET|EVOMAP_ENTERPRISE_TOKEN|EVOMAP_PRIVATE_HUB_TOKEN|EVOMAP_NODE_SECRET|EVOLVER_IPC_TOKEN|EVOLVER_LLM_TOKEN|PHUB_ENTERPRISE_TOKEN|PRIVATE_HUB_ENTERPRISE_TOKEN)\b\s*[:=]\s*["']?[^"'\s<]+/;
40
174
  const INLINE_BEARER_RE = /\bBearer\s+(?!<|\$|%|REDACTED\b|TOKEN\b|token\b|env:)[A-Za-z0-9._~+/=-]{12,}/i;
@@ -274,7 +408,27 @@ function appendAdapterNotes(text, hints) {
274
408
  ? `${text}\n\nAdapter notes:\n${hints.map((hint) => ` - ${hint}`).join('\n')}`
275
409
  : text;
276
410
  }
411
+ const SETUP_VALUE_FLAGS = new Set([
412
+ 'runtime', 'platform', 'scope', 'root', 'env-file', 'profile-descriptor', 'service',
413
+ 'hook-command', 'server-command', 'server-args', 'service-command', 'service-args',
414
+ ]);
415
+ function setupHelpRequested(argv) {
416
+ if (argv.includes('--help'))
417
+ return true;
418
+ return argv.some((arg, index) => {
419
+ if (arg !== '-h')
420
+ return false;
421
+ const previous = argv[index - 1];
422
+ if (!previous?.startsWith('--') || previous.includes('='))
423
+ return true;
424
+ return !SETUP_VALUE_FLAGS.has(previous.slice(2));
425
+ });
426
+ }
277
427
  export async function runSetupHooks(argv, store, review, deps = {}) {
428
+ if (setupHelpRequested(argv)) {
429
+ process.stdout.write(USAGE);
430
+ return 0;
431
+ }
278
432
  const f = parseFlags(argv);
279
433
  const runtimeRaw = typeof f['runtime'] === 'string'
280
434
  ? f['runtime']
@@ -306,19 +460,131 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
306
460
  const configRoot = typeof f['root'] === 'string' ? f['root'] : process.cwd();
307
461
  // claude-code: user scope targets ~/.claude.json regardless of --root; project scope uses configRoot.
308
462
  const scope = scopeResult.scope;
463
+ // V1 exposed setup-hooks --verify as a read-only operation. Silently ignoring it is unsafe: the command then
464
+ // falls through to installInjection and can rewrite runtime configuration while the operator asked only to
465
+ // inspect it. V2's JSON MCP installers already have a transaction-free dry-run preflight, so use that as the
466
+ // verifier for OpenCode and Kiro. Legacy installers do not have a proven read-only preflight and must refuse.
467
+ if (f['verify'] !== undefined) {
468
+ const verificationArgsValid = f['verify'] === true
469
+ && f['uninstall'] === undefined
470
+ && f['dry-run'] === undefined
471
+ && f['force'] === undefined;
472
+ if (!verificationArgsValid) {
473
+ const error = '--verify is read-only and cannot take a value or be combined with --uninstall, --dry-run, or --force';
474
+ if (json)
475
+ emit({ runtime, action: 'verify', ok: false, verified: false, files: [], error });
476
+ else
477
+ process.stderr.write(`${error}\n${USAGE}`);
478
+ return 2;
479
+ }
480
+ if (runtime !== 'opencode' && runtime !== 'kiro') {
481
+ const error = `--verify is not available for ${runtime}; no config was written`;
482
+ if (json)
483
+ emit({ runtime, action: 'verify', ok: false, verified: false, files: [], error });
484
+ else
485
+ process.stderr.write(`${error}\n`);
486
+ return 2;
487
+ }
488
+ const verifyDescriptor = profileDescriptorFromFlag(f);
489
+ if (!verifyDescriptor.ok) {
490
+ if (json)
491
+ emit({ runtime, action: 'verify', ok: false, verified: false, files: [], error: verifyDescriptor.error });
492
+ else
493
+ process.stderr.write(`${verifyDescriptor.error}\n`);
494
+ return 1;
495
+ }
496
+ let verification;
497
+ try {
498
+ const server = buildServer(f, verifyDescriptor.descriptor);
499
+ verification = installInjection(planInjection(runtime, server), {
500
+ configRoot,
501
+ server,
502
+ scope,
503
+ dryRun: true,
504
+ homeDir: configuredHomeDir(),
505
+ kiroHome: process.env['KIRO_HOME'],
506
+ xdgConfigHome: process.env['XDG_CONFIG_HOME'],
507
+ opencodeConfig: process.env['OPENCODE_CONFIG'],
508
+ opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
509
+ });
510
+ }
511
+ catch (error) {
512
+ const message = safeSetupOperationError(error);
513
+ if (json)
514
+ emit({ runtime, action: 'verify', ok: false, verified: false, files: [], error: message });
515
+ else
516
+ process.stderr.write(`${message}\n`);
517
+ return 1;
518
+ }
519
+ if (!verification.ok) {
520
+ const message = safeSetupResultError(verification.error);
521
+ if (json)
522
+ emit({ runtime, action: 'verify', ok: false, verified: false, files: [], error: message });
523
+ else
524
+ process.stderr.write(`${message}\n`);
525
+ return 1;
526
+ }
527
+ const files = displayResultPaths(verification.files, configRoot, scope) ?? [];
528
+ const verified = verification.alreadyInstalled === true && verification.verified === true;
529
+ if (json)
530
+ emit({ runtime, action: 'verify', ok: verified, verified, files });
531
+ else
532
+ process.stdout.write(verified
533
+ ? `verified evolver setup for ${runtime}: ${files.join(', ')}\n`
534
+ : `evolver setup for ${runtime} is missing or does not match the requested configuration\n`);
535
+ return verified ? 0 : 1;
536
+ }
537
+ if (f['dry-run'] === true && runtime !== 'opencode' && runtime !== 'kiro') {
538
+ const error = `--dry-run is currently supported for opencode and kiro setup only; no config was written.`;
539
+ if (json)
540
+ emit({ runtime, outcome: 'error', files: [], error });
541
+ else
542
+ process.stderr.write(`${error}\n`);
543
+ return 1;
544
+ }
309
545
  if (support.outcome === 'installed' && f['uninstall']) {
310
- const r = uninstallInjection(runtime, { configRoot, scope });
546
+ let r;
547
+ try {
548
+ r = uninstallInjection(runtime, {
549
+ configRoot,
550
+ scope,
551
+ homeDir: configuredHomeDir(),
552
+ kiroHome: process.env['KIRO_HOME'],
553
+ xdgConfigHome: process.env['XDG_CONFIG_HOME'],
554
+ opencodeConfig: process.env['OPENCODE_CONFIG'],
555
+ opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
556
+ dryRun: f['dry-run'] === true,
557
+ });
558
+ }
559
+ catch (error) {
560
+ const message = safeSetupOperationError(error);
561
+ if (json)
562
+ emit({ runtime, action: 'uninstall', files: [], error: message });
563
+ else
564
+ process.stderr.write(`${message}\n`);
565
+ return 1;
566
+ }
567
+ const files = displayResultPaths(r.files, configRoot, scope) ?? [];
568
+ const backups = displayResultPaths(r.backups, configRoot, scope);
311
569
  if (!r.ok) {
570
+ const message = safeSetupResultError(r.error);
312
571
  if (json)
313
- emit({ runtime, action: 'uninstall', files: [], error: r.error ?? 'uninstall failed' });
572
+ emit({ runtime, action: 'uninstall', files: [], error: message });
314
573
  else
315
- process.stderr.write(`${r.error ?? 'uninstall failed'}\n`);
574
+ process.stderr.write(`${message}\n`);
316
575
  return 1;
317
576
  }
577
+ if (r.dryRun) {
578
+ if (json)
579
+ emit({ runtime, action: 'uninstall', files, backups, dryRun: true });
580
+ else
581
+ process.stdout.write(files.length ? `dry-run: would remove evolver from: ${files.join(', ')}\n` : 'dry-run: nothing to remove\n');
582
+ return 0;
583
+ }
318
584
  if (json)
319
- emit({ runtime, action: 'uninstall', files: r.files });
585
+ emit({ runtime, action: 'uninstall', files, backups });
320
586
  else
321
- process.stdout.write(r.files.length ? `removed evolver from: ${r.files.join(', ')}\n` : 'nothing to remove\n');
587
+ process.stdout.write(files.length ? `removed evolver from: ${files.join(', ')}\n` : 'nothing to remove\n');
322
588
  return 0;
323
589
  }
324
590
  const profileDescriptor = profileDescriptorFromFlag(f);
@@ -360,6 +626,28 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
360
626
  return 0;
361
627
  }
362
628
  const server = buildServer(f, descriptor);
629
+ if ((runtime === 'opencode' || runtime === 'kiro') && f['dry-run'] !== true) {
630
+ let runtimeDetected;
631
+ try {
632
+ runtimeDetected = (deps.runtimeAvailable ?? defaultRuntimeAvailable)(runtime, configRoot, scope);
633
+ }
634
+ catch (error) {
635
+ const message = safeSetupOperationError(error);
636
+ if (json)
637
+ emit({ runtime, outcome: 'error', files: [], error: message });
638
+ else
639
+ process.stderr.write(`${message}\n`);
640
+ return 1;
641
+ }
642
+ if (!runtimeDetected) {
643
+ const error = `${runtime} runtime was not detected; install or launch ${runtime === 'opencode' ? 'OpenCode' : 'Kiro'} first, then rerun. No config was written.`;
644
+ if (json)
645
+ emit({ runtime, outcome: 'error', files: [], error });
646
+ else
647
+ process.stderr.write(`${error}\n`);
648
+ return 1;
649
+ }
650
+ }
363
651
  if (runtime === 'cursor')
364
652
  (deps.emitNonGitWorkspaceNotice ?? maybeEmitNonGitWorkspaceNotice)({ cwd: configRoot });
365
653
  // cursor seeds .cursor/rules/evolver.mdc with the CURRENT top REVIEW-APPROVED genes so the file is useful
@@ -376,6 +664,12 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
376
664
  ...(typeof f['hook-command'] === 'string' ? { hookCommand: f['hook-command'] } : {}),
377
665
  ...(cursorGenes ? { genes: cursorGenes } : {}),
378
666
  force: f['force'] === true,
667
+ dryRun: f['dry-run'] === true,
668
+ homeDir: configuredHomeDir(),
669
+ kiroHome: process.env['KIRO_HOME'],
670
+ xdgConfigHome: process.env['XDG_CONFIG_HOME'],
671
+ opencodeConfig: process.env['OPENCODE_CONFIG'],
672
+ opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
379
673
  });
380
674
  }
381
675
  catch (e) {
@@ -383,7 +677,7 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
383
677
  // `unsupported` runtime. Reporting `unsupported` here would tell a bootstrapper the runtime isn't supported and
384
678
  // make it stop trying, when the real cause is operational. `error` is a CLI result status (the attempt failed),
385
679
  // distinct from the support-matrix `unsupported` (an unrecognized runtime id) (Bugbot #264).
386
- const msg = e instanceof Error ? e.message : String(e);
680
+ const msg = safeSetupOperationError(e);
387
681
  if (json)
388
682
  emit({ runtime, outcome: 'error', files: [], error: msg });
389
683
  else
@@ -392,22 +686,44 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
392
686
  }
393
687
  if (!r.ok) {
394
688
  // Same reasoning for an ok:false install result: a failed install of a supported runtime is `error`, not `unsupported`.
689
+ const message = safeSetupResultError(r.error);
395
690
  if (json)
396
- emit({ runtime, outcome: 'error', files: [], error: r.error ?? 'install failed' });
691
+ emit({ runtime, outcome: 'error', files: [], error: message });
397
692
  else
398
- process.stderr.write(`${r.error ?? 'install failed'}\n`);
693
+ process.stderr.write(`${message}\n`);
399
694
  return 1;
400
695
  }
696
+ const files = displayResultPaths(r.files, configRoot, scope) ?? [];
697
+ const backups = displayResultPaths(r.backups, configRoot, scope);
698
+ if (r.dryRun) {
699
+ if (json) {
700
+ emit({
701
+ runtime,
702
+ outcome: 'installed',
703
+ files,
704
+ backups,
705
+ dryRun: true,
706
+ ...(r.alreadyInstalled ? { alreadyInstalled: true } : {}),
707
+ });
708
+ }
709
+ else if (r.alreadyInstalled) {
710
+ process.stdout.write('dry-run: evolver already installed (no changes)\n');
711
+ }
712
+ else {
713
+ process.stdout.write(`dry-run: would install evolver (${r.mode}) → ${files.join(', ')}\n`);
714
+ }
715
+ return 0;
716
+ }
401
717
  if (r.alreadyInstalled) {
402
718
  if (json)
403
- emit({ runtime, outcome: 'installed', files: r.files, alreadyInstalled: true });
719
+ emit({ runtime, outcome: 'installed', files, alreadyInstalled: true });
404
720
  else
405
721
  process.stdout.write('evolver already installed (use --force to reinstall)\n');
406
722
  return 0;
407
723
  }
408
724
  if (json)
409
- emit({ runtime, outcome: 'installed', files: r.files, mode: r.mode });
725
+ emit({ runtime, outcome: 'installed', files, backups, mode: r.mode, verified: r.verified });
410
726
  else
411
- process.stdout.write(`installed evolver (${r.mode}) → ${r.files.join(', ')}\n`);
727
+ process.stdout.write(`installed evolver (${r.mode}) → ${files.join(', ')}\n`);
412
728
  return 0;
413
729
  }
@@ -1,4 +1,6 @@
1
- import { type algo, type wire } from '@evomap/evolver-core';
1
+ import { type algo, type wire, verify } from '@evomap/evolver-core';
2
+ declare const isValidationCommandAllowed: typeof verify.isValidationCommandAllowed;
3
+ export { isValidationCommandAllowed };
2
4
  type GenerationSource = wire.GenerationSource;
3
5
  /** Max strategy steps kept from a skill (v1 parity: MAX_STRATEGY_STEPS). */
4
6
  export declare const MAX_STRATEGY_STEPS = 28;
@@ -14,16 +16,16 @@ export interface ParsedSkill {
14
16
  validation: string[];
15
17
  preconditions: string[];
16
18
  }
19
+ export interface ParseSkillMdOptions {
20
+ /** Preserve validation commands from every matching section for fail-closed callers. */
21
+ completeValidationPlan?: boolean;
22
+ }
17
23
  /**
18
24
  * Parse a SKILL.md into a structured intermediate — faithful port of v1 `parseSkillMd`. Pure. Section keywords are
19
25
  * matched against lower-cased headings and include CJK synonyms (skills authored in Chinese), though the signal
20
26
  * tokenizer keeps ASCII `[a-z0-9_]` only, so a CJK skill's signals come from its (English) frontmatter description.
21
27
  */
22
- export declare function parseSkillMd(skillMd: string): ParsedSkill;
23
- /** Whether a validation command is safe to run as a Gene.validation entry (faithful port of v1
24
- * policyCheck.isValidationCommandAllowed): a `node …` command with no command substitution, no shell
25
- * metacharacters (outside quoted strings), and no node eval flags (-e/--eval/--print/-p). */
26
- export declare function isValidationCommandAllowed(cmd: string): boolean;
28
+ export declare function parseSkillMd(skillMd: string, opts?: ParseSkillMdOptions): ParsedSkill;
27
29
  /** Infer a gene category from signals + description (v1 inferCategory): priority repair > innovate > optimize,
28
30
  * substring match (catches inflections + underscore signal tokens like `log_error`). */
29
31
  export declare function inferCategory(signals: readonly string[], description: string): string;
@@ -32,6 +34,7 @@ export interface SynthesizeOptions {
32
34
  skillName?: string;
33
35
  maxFiles?: number;
34
36
  }
37
+ export type SkillEvidenceMode = 'workflow_execution' | 'validation_only';
35
38
  export interface SynthesizeResult {
36
39
  gene: algo.GeneCandidate | null;
37
40
  errors: string[];
@@ -103,7 +106,7 @@ export interface SkillExecution {
103
106
  * hallucinating a successful run to pad the registry. Non-success executions are honest, so not checked. Returns
104
107
  * the rejection reason, or null when clean.
105
108
  */
106
- export declare function detectForgery(execution: SkillExecution): string | null;
109
+ export declare function detectForgery(execution: SkillExecution, evidenceMode?: SkillEvidenceMode): string | null;
107
110
  /** A synthesized Capsule (faithful to v1's shape; schema-conform / persistence is B3's concern). */
108
111
  export interface SkillCapsule {
109
112
  type: 'Capsule';
@@ -149,6 +152,7 @@ export type AssembleResult = {
149
152
  */
150
153
  export declare function assembleCapsule(gene: algo.GeneCandidate, execution: SkillExecution, opts?: {
151
154
  scenario?: string;
155
+ evidenceMode?: SkillEvidenceMode;
152
156
  }): AssembleResult;
153
157
  export interface ReverseDistillResult {
154
158
  gene: algo.GeneCandidate | null;
@@ -169,5 +173,5 @@ export interface ReverseDistillResult {
169
173
  */
170
174
  export declare function reverseDistill(parsed: ParsedSkill, execution?: SkillExecution, opts?: SynthesizeOptions & {
171
175
  scenario?: string;
172
- }): ReverseDistillResult;
173
- export {};
176
+ evidenceMode?: SkillEvidenceMode;
177
+ }): ReverseDistillResult;