@evomap/evolver-cli 2.0.46 → 2.0.47

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 (53) hide show
  1. package/dist/autoexec.d.ts +1 -2
  2. package/dist/autoexec.js +2 -7
  3. package/dist/cliEntry.js +8 -0
  4. package/dist/commandCatalog.d.ts +4 -0
  5. package/dist/commandCatalog.js +4 -0
  6. package/dist/dispatch.js +8 -0
  7. package/dist/experience.d.ts +2 -0
  8. package/dist/experience.js +229 -0
  9. package/dist/feedbackDestinationIdentity.d.ts +1 -0
  10. package/dist/feedbackDestinationIdentity.js +8 -0
  11. package/dist/kernelTriggerFeedback.d.ts +13 -0
  12. package/dist/kernelTriggerFeedback.js +65 -0
  13. package/dist/lifecycle.js +4 -1
  14. package/dist/lifecycleBootstrapTransaction.js +13 -7
  15. package/dist/localMemoryGraph.d.ts +38 -0
  16. package/dist/localMemoryGraph.js +192 -7
  17. package/dist/localTriggerFeedback.d.ts +30 -0
  18. package/dist/localTriggerFeedback.js +126 -0
  19. package/dist/mcpStdio.d.ts +1 -0
  20. package/dist/mcpStdio.js +9 -0
  21. package/dist/plugin.d.ts +8 -0
  22. package/dist/plugin.js +132 -0
  23. package/dist/pluginBundle.d.ts +3 -0
  24. package/dist/pluginBundle.js +94 -0
  25. package/dist/pluginHosts.d.ts +36 -0
  26. package/dist/pluginHosts.js +120 -0
  27. package/dist/pluginInspection.d.ts +22 -0
  28. package/dist/pluginInspection.js +237 -0
  29. package/dist/pluginInstall.d.ts +19 -0
  30. package/dist/pluginInstall.js +84 -0
  31. package/dist/pluginLock.d.ts +4 -0
  32. package/dist/pluginLock.js +52 -0
  33. package/dist/pluginRuntime.d.ts +31 -0
  34. package/dist/pluginRuntime.js +191 -0
  35. package/dist/recipe.d.ts +1 -1
  36. package/dist/recipe.js +14 -5
  37. package/dist/setupHooks.js +5 -3
  38. package/dist/setupHooksLifecycle.d.ts +2 -0
  39. package/dist/setupHooksLifecycle.js +52 -52
  40. package/dist/sourceQualification.js +6 -2
  41. package/dist/triggerFeedbackCli.d.ts +15 -0
  42. package/dist/triggerFeedbackCli.js +146 -0
  43. package/dist/triggerFeedbackDelivery.d.ts +9 -0
  44. package/dist/triggerFeedbackDelivery.js +29 -0
  45. package/dist/triggerFeedbackHub.d.ts +7 -0
  46. package/dist/triggerFeedbackHub.js +62 -0
  47. package/dist/triggerFeedbackRecovery.d.ts +15 -0
  48. package/dist/triggerFeedbackRecovery.js +124 -0
  49. package/dist/triggerFeedbackSync.d.ts +23 -0
  50. package/dist/triggerFeedbackSync.js +98 -0
  51. package/dist/triggerFeedbackSyncState.d.ts +42 -0
  52. package/dist/triggerFeedbackSyncState.js +112 -0
  53. package/package.json +7 -7
@@ -0,0 +1,191 @@
1
+ import { exec } from '@evomap/evolver-core';
2
+ import { accessSync, constants, lstatSync, readFileSync, statSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
5
+ export class PluginInstallError extends Error {
6
+ status;
7
+ constructor(status, message) {
8
+ super(message);
9
+ this.status = status;
10
+ this.name = 'PluginInstallError';
11
+ }
12
+ }
13
+ export function pluginHome(runtime) {
14
+ return runtime.env[runtime.platform === 'win32' ? 'USERPROFILE' : 'HOME']?.trim() || homedir();
15
+ }
16
+ export function pluginExecutableAvailable(command, env, platform) {
17
+ if (platform === 'win32') {
18
+ const resolved = exec.resolveSpawnCommand(command, [], env, platform);
19
+ return resolved.cmd !== command && executableFile(resolved.cmd, platform);
20
+ }
21
+ const paths = isAbsolute(command) ? [command] : (env['PATH'] ?? '').split(delimiter).filter(Boolean).map(dir => join(dir, command));
22
+ return paths.some(path => executableFile(path, platform));
23
+ }
24
+ function executableFile(path, platform) {
25
+ try {
26
+ if (!statSync(path).isFile())
27
+ return false;
28
+ accessSync(path, platform === 'win32' ? constants.F_OK : constants.X_OK);
29
+ return true;
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
35
+ export function resolvePluginSpawn(command, args, env, platform, standalone = Boolean(process.versions.bun)) {
36
+ const resolved = exec.resolveSpawnCommand(command, args, env, platform);
37
+ if (standalone && platform === 'win32' && resolved.cmd === process.execPath && resolved.args.length > args.length) {
38
+ const node = exec.resolveSpawnCommand('node', [], env, platform);
39
+ if (node.cmd === 'node' || !executableFile(node.cmd, platform))
40
+ throw new PluginInstallError('host_missing', 'The selected host uses an npm launcher. Standalone Evolver requires a real Node.js executable on PATH to run it; it cannot run that script as the Evolver binary.');
41
+ return { cmd: node.cmd, args: resolved.args };
42
+ }
43
+ return resolved;
44
+ }
45
+ export function createPluginRuntime(overrides = {}) {
46
+ const env = overrides.env ?? process.env;
47
+ const platform = overrides.platform ?? process.platform;
48
+ const cwd = overrides.cwd ?? process.cwd();
49
+ return {
50
+ env, platform, cwd,
51
+ available: command => pluginExecutableAvailable(command, env, platform),
52
+ run: (command, args, workdir = cwd, timeoutMs = 120_000) => {
53
+ const spawn = resolvePluginSpawn(command, args, env, platform);
54
+ return exec.spawnCapture(spawn.cmd, spawn.args, {
55
+ cwd: workdir, env, timeoutMs, input: '', maxOutputBytes: 1_048_576, resolvePlatform: platform,
56
+ });
57
+ },
58
+ ...overrides,
59
+ };
60
+ }
61
+ export async function checkedPluginCommand(runtime, command, args, cwd = runtime.cwd, timeoutMs) {
62
+ let result;
63
+ try {
64
+ result = await runtime.run(command, args, cwd, timeoutMs);
65
+ }
66
+ catch (error) {
67
+ if (error instanceof PluginInstallError)
68
+ throw error;
69
+ const missing = error?.code === 'ENOENT';
70
+ throw new PluginInstallError(missing ? 'host_missing' : 'failed', `${command}: ${missing ? 'executable not found' : 'could not start the command'}.`);
71
+ }
72
+ if (result.termination !== 'exit')
73
+ throw new PluginInstallError('failed', `${command}: command ${result.termination}; installation was not confirmed.`);
74
+ if (result.code !== 0)
75
+ throw new PluginInstallError('failed', `${command}: ${args[0] ?? 'command'} exited ${result.code ?? 'without an exit code'}; inspect the host's installation output before retrying.`);
76
+ if (result.stdoutTruncated)
77
+ throw new PluginInstallError('failed', `${command}: output exceeded the verification limit; installation was not confirmed.`);
78
+ return result;
79
+ }
80
+ export function pluginJson(text, label) {
81
+ try {
82
+ return JSON.parse(text);
83
+ }
84
+ catch {
85
+ throw new PluginInstallError('unsupported_capability', `${label} did not return valid JSON; no installed state can be inferred.`);
86
+ }
87
+ }
88
+ export function objectOf(value) {
89
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
90
+ }
91
+ export function readPluginText(path, maxBytes = 1_048_576) {
92
+ try {
93
+ const stat = statSync(path);
94
+ if (!stat.isFile() || stat.size > maxBytes)
95
+ throw new PluginInstallError('failed', 'An installation/configuration file is not a bounded regular file.');
96
+ return readFileSync(path, 'utf8');
97
+ }
98
+ catch (error) {
99
+ if (error?.code === 'ENOENT')
100
+ return undefined;
101
+ if (error instanceof PluginInstallError)
102
+ throw error;
103
+ throw new PluginInstallError('failed', 'An installation/configuration file could not be read.');
104
+ }
105
+ }
106
+ export function readPluginJson(path) {
107
+ const text = readPluginText(path);
108
+ if (text === undefined)
109
+ return undefined;
110
+ const parsed = objectOf(pluginJson(text, 'Installation/configuration file'));
111
+ if (!parsed)
112
+ throw new PluginInstallError('failed', 'An installation/configuration file is not a JSON object.');
113
+ return parsed;
114
+ }
115
+ function parsedPluginVersion(value) {
116
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$/.exec(value);
117
+ if (!match)
118
+ return undefined;
119
+ const prerelease = match[4]?.split('.') ?? [];
120
+ const build = match[5]?.split('.') ?? [];
121
+ if (prerelease.some(part => !part || (/^\d+$/.test(part) && /^0\d/.test(part))) || build.some(part => !part))
122
+ return undefined;
123
+ return { core: [match[1], match[2], match[3]], prerelease };
124
+ }
125
+ function compareVersionNumber(left, right) {
126
+ return left.length !== right.length ? left.length - right.length : left === right ? 0 : left > right ? 1 : -1;
127
+ }
128
+ export function pluginVersionAtLeast(current, minimum) {
129
+ const a = parsedPluginVersion(current), b = parsedPluginVersion(minimum);
130
+ if (!a || !b)
131
+ return false;
132
+ for (let index = 0; index < 3; index++) {
133
+ const difference = compareVersionNumber(a.core[index], b.core[index]);
134
+ if (difference !== 0)
135
+ return difference > 0;
136
+ }
137
+ if (a.prerelease.length === 0)
138
+ return true;
139
+ if (b.prerelease.length === 0)
140
+ return false;
141
+ for (let index = 0; index < Math.max(a.prerelease.length, b.prerelease.length); index++) {
142
+ const left = a.prerelease[index], right = b.prerelease[index];
143
+ if (left === undefined)
144
+ return false;
145
+ if (right === undefined)
146
+ return true;
147
+ if (left === right)
148
+ continue;
149
+ const leftNumeric = /^\d+$/.test(left), rightNumeric = /^\d+$/.test(right);
150
+ if (leftNumeric && rightNumeric)
151
+ return compareVersionNumber(left, right) > 0;
152
+ if (leftNumeric !== rightNumeric)
153
+ return !leftNumeric;
154
+ return left > right;
155
+ }
156
+ return true;
157
+ }
158
+ export async function checkPluginHostVersion(runtime, host) {
159
+ if (!host.command || !runtime.available(host.command))
160
+ throw new PluginInstallError('host_missing', `${host.label} CLI (${host.command ?? 'none'}) was not found on PATH.`);
161
+ if (!host.minimumVersion)
162
+ return;
163
+ const { stdout } = await checkedPluginCommand(runtime, host.command, ['--version']);
164
+ const version = /(?:^|\s)v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)(?:\s|$)/.exec(stdout.trim())?.[1];
165
+ if (!version || !pluginVersionAtLeast(version, host.minimumVersion)) {
166
+ throw new PluginInstallError('unsupported_version', `${host.label} requires ${host.minimumVersion}+; ${version ?? 'an unknown version'} was observed. Upgrade the host CLI before installing.`);
167
+ }
168
+ }
169
+ /** Only installer-owned descendants are written; a symlink may not redirect the cache or lock. */
170
+ export function assertPluginManagedPath(path) {
171
+ let current = resolve(path);
172
+ for (;;) {
173
+ try {
174
+ const stat = lstatSync(current);
175
+ if (stat.isSymbolicLink())
176
+ throw new PluginInstallError('conflict', 'The plugin cache/lock path contains a symbolic link; no installation files were written.');
177
+ if (!stat.isDirectory())
178
+ throw new PluginInstallError('conflict', 'The plugin cache parent is not a directory.');
179
+ }
180
+ catch (error) {
181
+ if (error instanceof PluginInstallError)
182
+ throw error;
183
+ if (error?.code !== 'ENOENT')
184
+ throw new PluginInstallError('failed', 'The plugin cache parent could not be inspected safely.');
185
+ }
186
+ const parent = dirname(current);
187
+ if (parent === current)
188
+ return;
189
+ current = parent;
190
+ }
191
+ }
package/dist/recipe.d.ts CHANGED
@@ -75,7 +75,7 @@ export declare function createRecipeHubFromEnv(env?: NodeJS.ProcessEnv, connectH
75
75
  auth: hubNs.AuthProvider;
76
76
  }): PublicHubCapability;
77
77
  /** Opaque identity for resume isolation; raw credentials, account ids, and local paths never leave this helper. */
78
- export declare function resolveRecipeHubResumeIdentityFingerprint(env: NodeJS.ProcessEnv): string;
78
+ export declare function resolveRecipeHubResumeIdentityFingerprint(env: NodeJS.ProcessEnv, includeCredentialGeneration?: boolean): string;
79
79
  export declare function parseRecipeArgs(argv: readonly string[]): ParseResult<RecipeOptions>;
80
80
  /**
81
81
  * The EXPLICIT home overrides (EVOMAP_DIR / EVOLVER_HOME / EVOMAP_HOME) the recipe credential layer honors,
package/dist/recipe.js CHANGED
@@ -4,7 +4,7 @@ import { homedir } from 'node:os';
4
4
  import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
5
5
  import { assetstore, events, mailbox, verify, hub as recipeExecution, hub as hubNs } from '@evomap/evolver-core';
6
6
  import { runRecipeConsentCommand } from './recipeConsent.js';
7
- import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled, isNodeSecret, parseNodeSecretVersion, resolveHubUrl } from '@evomap/evolver-adapter-public';
7
+ import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled, isNodeSecret, parseNodeSecretVersion, readPublicOAuthCredentialBinding, resolveHubUrl } from '@evomap/evolver-adapter-public';
8
8
  import { loadEnvFileFromEnv, loadEnvFileFromEnvOrThrow, safeReverificationRecovery } from '@evomap/evolver-mcp';
9
9
  import { resolveExplicitNodeCredentials } from './identityHome.js';
10
10
  import { getCliVersion } from './version.js';
@@ -210,7 +210,7 @@ export function createRecipeHubFromEnv(env = process.env, connectHub = connectPu
210
210
  return connected.hub;
211
211
  }
212
212
  /** Opaque identity for resume isolation; raw credentials, account ids, and local paths never leave this helper. */
213
- export function resolveRecipeHubResumeIdentityFingerprint(env) {
213
+ export function resolveRecipeHubResumeIdentityFingerprint(env, includeCredentialGeneration = false) {
214
214
  loadEnvFileFromEnv(env);
215
215
  const credentials = resolveRecipeHubCredentials(env);
216
216
  let credential;
@@ -219,9 +219,17 @@ export function resolveRecipeHubResumeIdentityFingerprint(env) {
219
219
  }
220
220
  else {
221
221
  try {
222
- credential = createHash('sha256')
223
- .update(readFileSync(join(credentials.evomapDir, 'token.json'), 'utf8'))
224
- .digest('hex');
222
+ if (includeCredentialGeneration) {
223
+ const binding = readPublicOAuthCredentialBinding(join(credentials.evomapDir, 'token.json'));
224
+ if (!binding)
225
+ throw new Error('Hub resume identity credentials are unavailable');
226
+ credential = binding;
227
+ }
228
+ else {
229
+ credential = createHash('sha256')
230
+ .update(readFileSync(join(credentials.evomapDir, 'token.json'), 'utf8'))
231
+ .digest('hex');
232
+ }
225
233
  }
226
234
  catch {
227
235
  throw new Error('Hub resume identity credentials are unavailable');
@@ -231,6 +239,7 @@ export function resolveRecipeHubResumeIdentityFingerprint(env) {
231
239
  authMode: credentials.nodeSecret ? 'legacy' : 'oauth',
232
240
  senderId: credentials.senderId ?? '',
233
241
  credential,
242
+ ...(includeCredentialGeneration ? { nodeSecretVersion: credentials.nodeSecretVersion ?? null } : {}),
234
243
  })).digest('hex');
235
244
  }
236
245
  function resolveRecipeHubUrl(env) {
@@ -44,7 +44,7 @@ function parseFlags(argv) {
44
44
  }
45
45
  return out;
46
46
  }
47
- const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--components=product-only|evolution-only|both] [--root=<dir>] [--lifecycle=capabilities|plan|verify|execute] [--action=install|uninstall] [--confirmed-plan=<base64url>] [--target-id=<id>] [--completed-targets=<id,id>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--verify] [--uninstall] [--dry-run] [--force] [--json] [--hook-command="evolver inject session-start"] [--server-node=<absolute-node>] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n --verify is read-only for claude-code, codex, opencode and kiro\n lifecycle operations are versioned JSON and require --json\n`;
47
+ const USAGE = `usage: evolver setup-hooks [--runtime=${SETUP_RUNTIMES.join('|')}] [--scope=user|project|global] [--components=product-only|evolution-only|both] [--root=<dir>] [--lifecycle=capabilities|plan|verify|execute] [--action=install|uninstall] [--confirmed-plan=<base64url>] [--target-id=<id>] [--completed-targets=<id,id>] [--env-file=<path>] [--profile-descriptor=<json>] [--service=${SERVICE_TARGETS.join('|')}] [--verify] [--uninstall] [--dry-run] [--force] [--json] [--hook-command="evolver inject session-start"] [--prompt-recall-hook-command="evolver inject prompt-recall"] [--server-node=<absolute-node>] [--server-command=<cmd>] [--server-args=a,b] [--service-command=<cmd>] [--service-args=a,b]\n --verify is read-only for claude-code, codex, opencode and kiro\n lifecycle operations are versioned JSON and require --json\n`;
48
48
  export function commandNamesForPath(command, platform, pathExt) {
49
49
  if (platform !== 'win32' || /\.[^\\/]+$/.test(command))
50
50
  return [command];
@@ -602,7 +602,7 @@ function runSetupLifecycle(f, runtime, scope, configRoot, emit, deps) {
602
602
  try {
603
603
  const built = buildServer(f, descriptor.descriptor, deps.resolveMcpNodePath);
604
604
  server = built.server;
605
- if (f['components'] !== 'evolution-only') {
605
+ if ((runtime === 'claude-code' || runtime === 'codex') && f['components'] !== 'evolution-only') {
606
606
  productBridgeNodePath = built.nodePath ?? (deps.resolveMcpNodePath ?? resolveStableMcpNodePath)();
607
607
  }
608
608
  }
@@ -617,12 +617,13 @@ function runSetupLifecycle(f, runtime, scope, configRoot, emit, deps) {
617
617
  configRoot,
618
618
  injectionPlan,
619
619
  installOptions: {
620
- components: resolveInstallComponents(f['components']),
620
+ ...((runtime === 'claude-code' || runtime === 'codex') ? { components: resolveInstallComponents(f['components']) } : {}),
621
621
  configRoot,
622
622
  server,
623
623
  scope,
624
624
  ...(productBridgeNodePath !== undefined ? { productBridgeNodePath } : {}),
625
625
  ...(typeof f['hook-command'] === 'string' ? { hookCommand: f['hook-command'] } : {}),
626
+ ...(typeof f['prompt-recall-hook-command'] === 'string' ? { promptRecallHookCommand: f['prompt-recall-hook-command'] } : {}),
626
627
  homeDir: configuredHomeDir(),
627
628
  codexHome: process.env['CODEX_HOME'],
628
629
  kiroHome: process.env['KIRO_HOME'],
@@ -986,6 +987,7 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
986
987
  configRoot, server, scope,
987
988
  ...(productBridgeNodePath !== undefined ? { productBridgeNodePath } : {}),
988
989
  ...(typeof f['hook-command'] === 'string' ? { hookCommand: f['hook-command'] } : {}),
990
+ ...(typeof f['prompt-recall-hook-command'] === 'string' ? { promptRecallHookCommand: f['prompt-recall-hook-command'] } : {}),
989
991
  ...(cursorGenes ? { genes: cursorGenes } : {}),
990
992
  force: f['force'] === true,
991
993
  dryRun: f['dry-run'] === true,
@@ -8,6 +8,8 @@ export interface SetupLifecycleCapabilities {
8
8
  runtime: RuntimeId;
9
9
  scope: InstallScope;
10
10
  supported: boolean;
11
+ hookCommandsBound: boolean;
12
+ standaloneMcp: boolean;
11
13
  operations: Record<SetupLifecycleOperation, boolean>;
12
14
  }
13
15
  export interface SetupLifecycleTarget {
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { lstatSync, readFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { isAbsolute, relative, resolve, sep } from 'node:path';
5
- import { DEFAULT_HOOK_COMMAND, DEFAULT_PROMPT_RECALL_HOOK_COMMAND, claudeCodeTargets, codexConfigTarget, installInjection, uninstallInjection, resolveInstallComponents, } from '@evomap/evolver-mcp';
5
+ import { DEFAULT_HOOK_COMMAND, DEFAULT_PROMPT_RECALL_HOOK_COMMAND, claudeCodeTargets, codexConfigTarget, installInjection, uninstallInjection, resolveInstallComponents, cursorRulesPath, resolveAntigravityConfigTargets, resolveOpenCodeConfig, resolveKiroConfig, } from '@evomap/evolver-mcp';
6
6
  export const SETUP_LIFECYCLE_SCHEMA = 'evolver.setup_hooks.lifecycle.v1';
7
7
  export const SETUP_LIFECYCLE_PLAN_TTL_MS = 120_000;
8
8
  export class SetupLifecycleError extends Error {
@@ -14,12 +14,16 @@ export class SetupLifecycleError extends Error {
14
14
  }
15
15
  }
16
16
  export function setupLifecycleCapabilities(runtime, scope) {
17
- const supported = runtime === 'claude-code' || runtime === 'codex';
17
+ const supported = ['claude-code', 'codex', 'cursor', 'antigravity', 'opencode', 'kiro'].includes(runtime)
18
+ && (runtime !== 'cursor' || scope === 'project')
19
+ && (runtime !== 'antigravity' || scope === 'user');
18
20
  return {
19
21
  schema: SETUP_LIFECYCLE_SCHEMA,
20
22
  runtime,
21
23
  scope,
22
24
  supported,
25
+ hookCommandsBound: runtime === 'claude-code' || runtime === 'codex',
26
+ standaloneMcp: true,
23
27
  operations: {
24
28
  plan: supported,
25
29
  verify: supported,
@@ -44,7 +48,7 @@ function canonicalJson(value) {
44
48
  return value;
45
49
  }
46
50
  function lifecycleIntentDigest(context, action) {
47
- const options = context.installOptions;
51
+ const options = lifecycleInstallOptions(context);
48
52
  const targetResolution = {
49
53
  components: resolveInstallComponents(options.components),
50
54
  configRoot: context.configRoot,
@@ -113,22 +117,47 @@ function displayTarget(path, context) {
113
117
  }
114
118
  return `<managed:${context.runtime}:${context.scope}>`;
115
119
  }
120
+ function lifecycleInstallOptions(context) {
121
+ return { ...context.installOptions, configRoot: context.configRoot, scope: context.scope };
122
+ }
116
123
  function planResult(context, action) {
117
- if (action === 'install') {
118
- return installInjection(context.injectionPlan, { ...context.installOptions, dryRun: true });
124
+ const options = { ...lifecycleInstallOptions(context), dryRun: true };
125
+ return action === 'install' ? installInjection(context.injectionPlan, options) : uninstallInjection(context.runtime, options);
126
+ }
127
+ function applyLifecycleMutation(context, action, targetPath) {
128
+ const options = { ...lifecycleInstallOptions(context), ...(targetPath === undefined ? {} : { targetPath }) };
129
+ return action === 'install'
130
+ ? installInjection(context.injectionPlan, options)
131
+ : uninstallInjection(context.runtime, options);
132
+ }
133
+ function applyConfirmedTargets(context, plan, paths) {
134
+ const files = [];
135
+ for (const target of plan.targets) {
136
+ if (target.disposition === 'already_satisfied')
137
+ continue;
138
+ const path = paths.get(target.target_id);
139
+ if (!path)
140
+ throw new SetupLifecycleError('PLAN_STALE', 'confirmed target is no longer resolved');
141
+ const result = applyLifecycleMutation(context, plan.action, path);
142
+ files.push(...result.files);
143
+ if (!result.ok)
144
+ return { ...result, files };
145
+ }
146
+ return { ok: true, runtime: context.runtime, mode: context.injectionPlan.mode, files };
147
+ }
148
+ function lifecycleConfigPaths(context) {
149
+ const options = lifecycleInstallOptions(context);
150
+ switch (context.runtime) {
151
+ case 'claude-code': {
152
+ const targets = claudeCodeTargets(context.scope, context.configRoot, options.homeDir);
153
+ return [targets.mcpConfigPath, ...(resolveInstallComponents(options.components) === 'product-only' ? [] : [targets.settingsPath])];
154
+ }
155
+ case 'codex': return [codexConfigTarget(options).configPath];
156
+ case 'cursor': return [cursorRulesPath(context.configRoot)];
157
+ case 'antigravity': return resolveAntigravityConfigTargets(options.homeDir).map((target) => target.configPath);
158
+ case 'opencode': return [resolveOpenCodeConfig(options).configPath];
159
+ case 'kiro': return [resolveKiroConfig(options).configPath];
119
160
  }
120
- return uninstallInjection(context.runtime, {
121
- components: context.installOptions.components,
122
- configRoot: context.configRoot,
123
- scope: context.scope,
124
- homeDir: context.installOptions.homeDir,
125
- codexHome: context.installOptions.codexHome,
126
- kiroHome: context.installOptions.kiroHome,
127
- xdgConfigHome: context.installOptions.xdgConfigHome,
128
- opencodeConfig: context.installOptions.opencodeConfig,
129
- opencodeConfigDir: context.installOptions.opencodeConfigDir,
130
- dryRun: true,
131
- });
132
161
  }
133
162
  function planForTimes(context, action, createdAt, expiresAt, resolvedPaths) {
134
163
  const capabilities = setupLifecycleCapabilities(context.runtime, context.scope);
@@ -139,13 +168,7 @@ function planForTimes(context, action, createdAt, expiresAt, resolvedPaths) {
139
168
  if (!dryRun.ok)
140
169
  throw new SetupLifecycleError('PLAN_INVALID', dryRun.error ?? 'lifecycle plan failed');
141
170
  if (resolvedPaths) {
142
- const options = context.installOptions;
143
- const claude = context.runtime === 'claude-code'
144
- ? claudeCodeTargets(options.scope ?? 'project', options.configRoot, options.homeDir)
145
- : undefined;
146
- const paths = claude
147
- ? [claude.mcpConfigPath, ...(resolveInstallComponents(options.components) === 'product-only' ? [] : [claude.settingsPath])]
148
- : [codexConfigTarget(options).configPath];
171
+ const paths = [...lifecycleConfigPaths(context), ...dryRun.files];
149
172
  for (const path of paths.map((path) => resolve(path))) {
150
173
  resolvedPaths.set(digest(`${context.runtime}\0${context.scope}\0${path}`).slice(0, 32), path);
151
174
  }
@@ -231,7 +254,7 @@ export function decodeSetupLifecyclePlan(raw) {
231
254
  return plan;
232
255
  }
233
256
  export function verifySetupLifecycle(context) {
234
- const result = installInjection(context.injectionPlan, { ...context.installOptions, dryRun: true });
257
+ const result = installInjection(context.injectionPlan, { ...lifecycleInstallOptions(context), dryRun: true });
235
258
  return result.ok && result.alreadyInstalled === true && result.verified === true && result.files.length === 0;
236
259
  }
237
260
  export function executeSetupLifecyclePlan(context, confirmed, options = {}) {
@@ -271,19 +294,9 @@ export function executeSetupLifecyclePlan(context, confirmed, options = {}) {
271
294
  let result;
272
295
  let executionFailed = false;
273
296
  try {
274
- result = confirmed.action === 'install'
275
- ? installInjection(context.injectionPlan, context.installOptions)
276
- : uninstallInjection(context.runtime, {
277
- components: context.installOptions.components,
278
- configRoot: context.configRoot,
279
- scope: context.scope,
280
- homeDir: context.installOptions.homeDir,
281
- codexHome: context.installOptions.codexHome,
282
- kiroHome: context.installOptions.kiroHome,
283
- xdgConfigHome: context.installOptions.xdgConfigHome,
284
- opencodeConfig: context.installOptions.opencodeConfig,
285
- opencodeConfigDir: context.installOptions.opencodeConfigDir,
286
- });
297
+ result = context.runtime === 'claude-code' || context.runtime === 'codex'
298
+ ? applyLifecycleMutation(context, confirmed.action)
299
+ : applyConfirmedTargets(context, confirmed, resolvedPaths);
287
300
  executionFailed = !result.ok;
288
301
  }
289
302
  catch {
@@ -417,20 +430,7 @@ function executeSetupLifecycleTarget(context, confirmed, targetId, completedTarg
417
430
  }
418
431
  let executionFailed = false;
419
432
  try {
420
- const result = confirmed.action === 'install'
421
- ? installInjection(context.injectionPlan, { ...context.installOptions, targetPath })
422
- : uninstallInjection(context.runtime, {
423
- components: context.installOptions.components,
424
- configRoot: context.configRoot,
425
- scope: context.scope,
426
- homeDir: context.installOptions.homeDir,
427
- codexHome: context.installOptions.codexHome,
428
- kiroHome: context.installOptions.kiroHome,
429
- xdgConfigHome: context.installOptions.xdgConfigHome,
430
- opencodeConfig: context.installOptions.opencodeConfig,
431
- opencodeConfigDir: context.installOptions.opencodeConfigDir,
432
- targetPath,
433
- });
433
+ const result = applyLifecycleMutation(context, confirmed.action, targetPath);
434
434
  executionFailed = !result.ok;
435
435
  }
436
436
  catch {
@@ -5,13 +5,16 @@ const USAGE = 'evolver asset-trust qualify <asset_id> --evidence <file> --reason
5
5
  + 'evolver asset-trust qualification <asset_id> --benchmark <id> [--evidence-digest <sha256>] [--json]\n';
6
6
  /** 有界、单descriptor读取;不执行证据中的命令,不跟随symlink或读取增长中的文件。 */
7
7
  function readEvidence(path) {
8
+ const identity = assetstore.captureRegularAssetFileIdentity(path);
8
9
  const before = lstatSync(path);
9
10
  if (!before.isFile() || before.isSymbolicLink() || before.size > 128 * 1024)
10
11
  throw new Error('invalid_evidence_file');
11
12
  const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
12
13
  try {
13
14
  const opened = fstatSync(fd);
14
- if (!opened.isFile() || before.dev !== opened.dev || before.ino !== opened.ino || before.size !== opened.size)
15
+ assetstore.assertOpenedRegularAssetFile(fd, path, identity);
16
+ if (!opened.isFile() || (process.platform !== 'win32' && before.dev !== opened.dev) || before.ino !== opened.ino || before.size !== opened.size
17
+ || before.mtimeMs !== opened.mtimeMs || before.ctimeMs !== opened.ctimeMs)
15
18
  throw new Error('evidence_changed');
16
19
  const bytes = Buffer.alloc(opened.size);
17
20
  let offset = 0;
@@ -23,8 +26,9 @@ function readEvidence(path) {
23
26
  }
24
27
  const after = fstatSync(fd);
25
28
  const named = lstatSync(path);
29
+ assetstore.assertOpenedRegularAssetFile(fd, path, identity);
26
30
  if (opened.size !== after.size || opened.mtimeMs !== after.mtimeMs || opened.ctimeMs !== after.ctimeMs
27
- || named.isSymbolicLink() || named.dev !== opened.dev || named.ino !== opened.ino)
31
+ || named.isSymbolicLink() || named.ino !== opened.ino)
28
32
  throw new Error('evidence_changed');
29
33
  return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
30
34
  }
@@ -0,0 +1,15 @@
1
+ import { algo } from '@evomap/evolver-core';
2
+ import { LocalMemoryGraph } from './localMemoryGraph.js';
3
+ import { type KernelTriggerFeedbackBinding, type KernelTriggerFeedbackPage } from './kernelTriggerFeedback.js';
4
+ import { type BoundTriggerFeedbackCapability } from './triggerFeedbackHub.js';
5
+ export interface TriggerFeedbackCommandDeps {
6
+ env?: Record<string, string | undefined>;
7
+ stdout?: (text: string) => void;
8
+ stderr?: (text: string) => void;
9
+ now?: () => number;
10
+ readKernel?: (binding: KernelTriggerFeedbackBinding, runId: string, signal?: AbortSignal) => Promise<algo.TriggerFeedbackSnapshot>;
11
+ listKernel?: (binding: KernelTriggerFeedbackBinding, after: string | null, signal?: AbortSignal) => Promise<KernelTriggerFeedbackPage>;
12
+ createGraph?: (dir: string) => LocalMemoryGraph;
13
+ createRemote?: (binding: KernelTriggerFeedbackBinding, env: Readonly<Record<string, string | undefined>>, signal?: AbortSignal) => BoundTriggerFeedbackCapability;
14
+ }
15
+ export declare function runTriggerFeedbackCommand(argv: readonly string[], deps?: TriggerFeedbackCommandDeps): Promise<number>;