@evomap/evolver-cli 2.0.32 → 2.0.34
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.
- package/dist/atp.js +6 -1
- package/dist/autoexec.d.ts +2 -6
- package/dist/autoexec.js +18 -17
- package/dist/distillObserver.js +21 -7
- package/dist/distillPrimitives.d.ts +39 -6
- package/dist/distillPrimitives.js +293 -75
- package/dist/index.js +153 -21
- package/dist/lifecycleBootstrapTransaction.js +123 -8
- package/dist/materialPackage.d.ts +4 -0
- package/dist/materialPackage.js +30 -9
- package/dist/materialSnapshot.d.ts +3 -0
- package/dist/materialSnapshot.js +49 -3
- package/dist/migrate/oauthImport.js +4 -1
- package/dist/setupHooks.js +121 -2
- package/dist/setupHooksLifecycle.d.ts +73 -0
- package/dist/setupHooksLifecycle.js +448 -0
- package/package.json +7 -7
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { DEFAULT_HOOK_COMMAND, DEFAULT_PROMPT_RECALL_HOOK_COMMAND, installInjection, uninstallInjection, } from '@evomap/evolver-mcp';
|
|
6
|
+
export const SETUP_LIFECYCLE_SCHEMA = 'evolver.setup_hooks.lifecycle.v1';
|
|
7
|
+
export const SETUP_LIFECYCLE_PLAN_TTL_MS = 120_000;
|
|
8
|
+
export class SetupLifecycleError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
constructor(code, message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.name = 'SetupLifecycleError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function setupLifecycleCapabilities(runtime, scope) {
|
|
17
|
+
const supported = runtime === 'claude-code' || runtime === 'codex';
|
|
18
|
+
return {
|
|
19
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
20
|
+
runtime,
|
|
21
|
+
scope,
|
|
22
|
+
supported,
|
|
23
|
+
operations: {
|
|
24
|
+
plan: supported,
|
|
25
|
+
verify: supported,
|
|
26
|
+
install: supported,
|
|
27
|
+
uninstall: supported,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function digest(value) {
|
|
32
|
+
return createHash('sha256').update(value).digest('hex');
|
|
33
|
+
}
|
|
34
|
+
function canonicalJson(value) {
|
|
35
|
+
if (Array.isArray(value))
|
|
36
|
+
return value.map(canonicalJson);
|
|
37
|
+
if (value !== null && typeof value === 'object') {
|
|
38
|
+
const entries = Object.entries(value)
|
|
39
|
+
.filter(([, entry]) => entry !== undefined)
|
|
40
|
+
.sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)
|
|
41
|
+
.map(([key, entry]) => [key, canonicalJson(entry)]);
|
|
42
|
+
return Object.fromEntries(entries);
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
function lifecycleIntentDigest(context, action) {
|
|
47
|
+
const options = context.installOptions;
|
|
48
|
+
const targetResolution = {
|
|
49
|
+
configRoot: context.configRoot,
|
|
50
|
+
scope: context.scope,
|
|
51
|
+
homeDir: options.homeDir,
|
|
52
|
+
codexHome: options.codexHome,
|
|
53
|
+
kiroHome: options.kiroHome,
|
|
54
|
+
xdgConfigHome: options.xdgConfigHome,
|
|
55
|
+
opencodeConfig: options.opencodeConfig,
|
|
56
|
+
opencodeConfigDir: options.opencodeConfigDir,
|
|
57
|
+
};
|
|
58
|
+
const intent = action === 'install'
|
|
59
|
+
? {
|
|
60
|
+
action,
|
|
61
|
+
runtime: context.runtime,
|
|
62
|
+
scope: context.scope,
|
|
63
|
+
targetResolution,
|
|
64
|
+
injectionPlan: {
|
|
65
|
+
runtime: context.injectionPlan.runtime,
|
|
66
|
+
mode: context.injectionPlan.mode,
|
|
67
|
+
config: context.injectionPlan.config,
|
|
68
|
+
},
|
|
69
|
+
install: {
|
|
70
|
+
server: options.server,
|
|
71
|
+
productBridgeNodePath: options.productBridgeNodePath ?? process.execPath,
|
|
72
|
+
hookCommand: options.hookCommand ?? DEFAULT_HOOK_COMMAND,
|
|
73
|
+
promptRecallHookCommand: options.promptRecallHookCommand ?? DEFAULT_PROMPT_RECALL_HOOK_COMMAND,
|
|
74
|
+
force: options.force === true,
|
|
75
|
+
genes: options.genes,
|
|
76
|
+
maxGenes: options.maxGenes,
|
|
77
|
+
opencodeConfigContent: options.opencodeConfigContent,
|
|
78
|
+
opencodeDisableProjectConfig: options.opencodeDisableProjectConfig,
|
|
79
|
+
opencodeManagedConfigDir: options.opencodeManagedConfigDir,
|
|
80
|
+
opencodeManagedPreferencePaths: options.opencodeManagedPreferencePaths,
|
|
81
|
+
opencodePlatform: options.opencodePlatform,
|
|
82
|
+
opencodeProgramData: options.opencodeProgramData,
|
|
83
|
+
opencodeUsername: options.opencodeUsername,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
: { action, runtime: context.runtime, scope: context.scope, targetResolution };
|
|
87
|
+
return digest(JSON.stringify(canonicalJson(intent)));
|
|
88
|
+
}
|
|
89
|
+
function fileIdentity(path) {
|
|
90
|
+
try {
|
|
91
|
+
const stat = lstatSync(path);
|
|
92
|
+
if (stat.isSymbolicLink())
|
|
93
|
+
return digest(`symlink:${path}`);
|
|
94
|
+
if (!stat.isFile())
|
|
95
|
+
return digest(`non-file:${path}:${stat.mode}`);
|
|
96
|
+
return digest(Buffer.concat([
|
|
97
|
+
Buffer.from(`file:${path}:${stat.mode}:`),
|
|
98
|
+
readFileSync(path),
|
|
99
|
+
]));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error.code === 'ENOENT')
|
|
103
|
+
return digest(`absent:${path}`);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function displayTarget(path, context) {
|
|
108
|
+
const base = context.scope === 'user' ? context.installOptions.homeDir ?? homedir() : context.configRoot;
|
|
109
|
+
const candidate = relative(base, path);
|
|
110
|
+
if (!isAbsolute(candidate) && candidate !== '..' && !candidate.startsWith(`..${sep}`)) {
|
|
111
|
+
return context.scope === 'user' ? `~/${candidate.replaceAll('\\', '/')}` : candidate.replaceAll('\\', '/');
|
|
112
|
+
}
|
|
113
|
+
return `<managed:${context.runtime}:${context.scope}>`;
|
|
114
|
+
}
|
|
115
|
+
function planResult(context, action) {
|
|
116
|
+
if (action === 'install') {
|
|
117
|
+
return installInjection(context.injectionPlan, { ...context.installOptions, dryRun: true });
|
|
118
|
+
}
|
|
119
|
+
return uninstallInjection(context.runtime, {
|
|
120
|
+
configRoot: context.configRoot,
|
|
121
|
+
scope: context.scope,
|
|
122
|
+
homeDir: context.installOptions.homeDir,
|
|
123
|
+
codexHome: context.installOptions.codexHome,
|
|
124
|
+
kiroHome: context.installOptions.kiroHome,
|
|
125
|
+
xdgConfigHome: context.installOptions.xdgConfigHome,
|
|
126
|
+
opencodeConfig: context.installOptions.opencodeConfig,
|
|
127
|
+
opencodeConfigDir: context.installOptions.opencodeConfigDir,
|
|
128
|
+
dryRun: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function planForTimes(context, action, createdAt, expiresAt) {
|
|
132
|
+
const capabilities = setupLifecycleCapabilities(context.runtime, context.scope);
|
|
133
|
+
if (!capabilities.supported || !capabilities.operations[action]) {
|
|
134
|
+
throw new SetupLifecycleError('CAPABILITY_UNAVAILABLE', `lifecycle ${action} is unavailable for ${context.runtime}/${context.scope}`);
|
|
135
|
+
}
|
|
136
|
+
const dryRun = planResult(context, action);
|
|
137
|
+
if (!dryRun.ok)
|
|
138
|
+
throw new SetupLifecycleError('PLAN_INVALID', dryRun.error ?? 'lifecycle plan failed');
|
|
139
|
+
const files = [...new Set(dryRun.files.map((path) => resolve(path)))].sort();
|
|
140
|
+
const targets = files.map((path) => {
|
|
141
|
+
const expectedIdentity = fileIdentity(path);
|
|
142
|
+
return {
|
|
143
|
+
target_id: digest(`${context.runtime}\0${context.scope}\0${path}`).slice(0, 32),
|
|
144
|
+
target_ref: displayTarget(path, context),
|
|
145
|
+
expected_identity: expectedIdentity,
|
|
146
|
+
disposition: action === 'install' ? 'installable' : 'removable',
|
|
147
|
+
impact_hints: action === 'uninstall' ? ['new_sessions_required'] : [],
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
if (targets.length === 0) {
|
|
151
|
+
targets.push({
|
|
152
|
+
target_id: digest(`${context.runtime}\0${context.scope}\0already-satisfied`).slice(0, 32),
|
|
153
|
+
target_ref: `${context.runtime}:${context.scope}`,
|
|
154
|
+
expected_identity: digest('already-satisfied'),
|
|
155
|
+
disposition: 'already_satisfied',
|
|
156
|
+
impact_hints: [],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const intentDigest = lifecycleIntentDigest(context, action);
|
|
160
|
+
const generation = digest(JSON.stringify([intentDigest, targets.map(({ target_id, expected_identity }) => [target_id, expected_identity])]));
|
|
161
|
+
const targetSetDigest = digest(JSON.stringify(targets.map(({ target_id }) => target_id)));
|
|
162
|
+
const base = {
|
|
163
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
164
|
+
generation,
|
|
165
|
+
target_set_digest: targetSetDigest,
|
|
166
|
+
intent_digest: intentDigest,
|
|
167
|
+
created_at: createdAt.toISOString(),
|
|
168
|
+
expires_at: expiresAt.toISOString(),
|
|
169
|
+
action,
|
|
170
|
+
runtime: context.runtime,
|
|
171
|
+
scope: context.scope,
|
|
172
|
+
targets,
|
|
173
|
+
};
|
|
174
|
+
return { ...base, plan_id: digest(JSON.stringify(base)) };
|
|
175
|
+
}
|
|
176
|
+
export function createSetupLifecyclePlan(context, action) {
|
|
177
|
+
const createdAt = (context.now ?? (() => new Date()))();
|
|
178
|
+
return planForTimes(context, action, createdAt, new Date(createdAt.getTime() + SETUP_LIFECYCLE_PLAN_TTL_MS));
|
|
179
|
+
}
|
|
180
|
+
export function encodeSetupLifecyclePlan(plan) {
|
|
181
|
+
return Buffer.from(JSON.stringify(plan), 'utf8').toString('base64url');
|
|
182
|
+
}
|
|
183
|
+
export function decodeSetupLifecyclePlan(raw) {
|
|
184
|
+
let value;
|
|
185
|
+
try {
|
|
186
|
+
value = JSON.parse(Buffer.from(raw, 'base64url').toString('utf8'));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan is not valid base64url JSON');
|
|
190
|
+
}
|
|
191
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
192
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan must be an object');
|
|
193
|
+
}
|
|
194
|
+
const plan = value;
|
|
195
|
+
const targetsValid = Array.isArray(plan.targets) && plan.targets.every((target) => target !== null
|
|
196
|
+
&& typeof target === 'object'
|
|
197
|
+
&& typeof target.target_id === 'string'
|
|
198
|
+
&& typeof target.target_ref === 'string'
|
|
199
|
+
&& typeof target.expected_identity === 'string'
|
|
200
|
+
&& ['installable', 'removable', 'already_satisfied'].includes(target.disposition)
|
|
201
|
+
&& Array.isArray(target.impact_hints)
|
|
202
|
+
&& target.impact_hints.every((hint) => typeof hint === 'string'));
|
|
203
|
+
if (plan.schema !== SETUP_LIFECYCLE_SCHEMA
|
|
204
|
+
|| typeof plan.plan_id !== 'string'
|
|
205
|
+
|| typeof plan.generation !== 'string'
|
|
206
|
+
|| typeof plan.target_set_digest !== 'string'
|
|
207
|
+
|| typeof plan.intent_digest !== 'string'
|
|
208
|
+
|| typeof plan.created_at !== 'string'
|
|
209
|
+
|| typeof plan.expires_at !== 'string'
|
|
210
|
+
|| (plan.action !== 'install' && plan.action !== 'uninstall')
|
|
211
|
+
|| typeof plan.runtime !== 'string'
|
|
212
|
+
|| (plan.scope !== 'project' && plan.scope !== 'user')
|
|
213
|
+
|| !targetsValid) {
|
|
214
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan has an invalid schema');
|
|
215
|
+
}
|
|
216
|
+
return plan;
|
|
217
|
+
}
|
|
218
|
+
export function verifySetupLifecycle(context) {
|
|
219
|
+
const result = installInjection(context.injectionPlan, { ...context.installOptions, dryRun: true });
|
|
220
|
+
return result.ok && result.alreadyInstalled === true && result.verified === true && result.files.length === 0;
|
|
221
|
+
}
|
|
222
|
+
export function executeSetupLifecyclePlan(context, confirmed, options = {}) {
|
|
223
|
+
if (confirmed.runtime !== context.runtime || confirmed.scope !== context.scope) {
|
|
224
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan does not match runtime scope');
|
|
225
|
+
}
|
|
226
|
+
const { plan_id: confirmedPlanID, ...confirmedBase } = confirmed;
|
|
227
|
+
if (digest(JSON.stringify(confirmedBase)) !== confirmedPlanID) {
|
|
228
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan identity is invalid');
|
|
229
|
+
}
|
|
230
|
+
if (lifecycleIntentDigest(context, confirmed.action) !== confirmed.intent_digest) {
|
|
231
|
+
throw new SetupLifecycleError('PLAN_STALE', 'lifecycle write intent changed; create a fresh plan');
|
|
232
|
+
}
|
|
233
|
+
const now = (context.now ?? (() => new Date()))();
|
|
234
|
+
const createdAt = new Date(confirmed.created_at);
|
|
235
|
+
const expiresAt = new Date(confirmed.expires_at);
|
|
236
|
+
if (!Number.isFinite(createdAt.getTime()) || !Number.isFinite(expiresAt.getTime())) {
|
|
237
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'confirmed lifecycle plan has invalid timestamps');
|
|
238
|
+
}
|
|
239
|
+
const continuingTargetExecution = options.targetId !== undefined && (options.completedTargetIds?.length ?? 0) > 0;
|
|
240
|
+
if (now.getTime() > expiresAt.getTime() && !continuingTargetExecution) {
|
|
241
|
+
throw new SetupLifecycleError('PLAN_EXPIRED', 'confirmed lifecycle plan expired; create a fresh plan');
|
|
242
|
+
}
|
|
243
|
+
if (options.targetId !== undefined) {
|
|
244
|
+
return executeSetupLifecycleTarget(context, confirmed, options.targetId, options.completedTargetIds ?? [], createdAt, expiresAt);
|
|
245
|
+
}
|
|
246
|
+
const current = planForTimes(context, confirmed.action, createdAt, expiresAt);
|
|
247
|
+
const sameTargets = JSON.stringify(current.targets.map((target) => target.target_id))
|
|
248
|
+
=== JSON.stringify(confirmed.targets.map((target) => target.target_id));
|
|
249
|
+
if (current.plan_id !== confirmed.plan_id
|
|
250
|
+
|| current.generation !== confirmed.generation
|
|
251
|
+
|| current.target_set_digest !== confirmed.target_set_digest
|
|
252
|
+
|| !sameTargets) {
|
|
253
|
+
throw new SetupLifecycleError('PLAN_STALE', 'lifecycle target identity changed; create a fresh plan');
|
|
254
|
+
}
|
|
255
|
+
let result;
|
|
256
|
+
let executionFailed = false;
|
|
257
|
+
try {
|
|
258
|
+
result = confirmed.action === 'install'
|
|
259
|
+
? installInjection(context.injectionPlan, context.installOptions)
|
|
260
|
+
: uninstallInjection(context.runtime, {
|
|
261
|
+
configRoot: context.configRoot,
|
|
262
|
+
scope: context.scope,
|
|
263
|
+
homeDir: context.installOptions.homeDir,
|
|
264
|
+
codexHome: context.installOptions.codexHome,
|
|
265
|
+
kiroHome: context.installOptions.kiroHome,
|
|
266
|
+
xdgConfigHome: context.installOptions.xdgConfigHome,
|
|
267
|
+
opencodeConfig: context.installOptions.opencodeConfig,
|
|
268
|
+
opencodeConfigDir: context.installOptions.opencodeConfigDir,
|
|
269
|
+
});
|
|
270
|
+
executionFailed = !result.ok;
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
executionFailed = true;
|
|
274
|
+
}
|
|
275
|
+
let verified = false;
|
|
276
|
+
if (!executionFailed) {
|
|
277
|
+
try {
|
|
278
|
+
verified = confirmed.action === 'install'
|
|
279
|
+
? verifySetupLifecycle(context)
|
|
280
|
+
: planResult(context, 'uninstall').files.length === 0;
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
executionFailed = true;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const targets = confirmed.targets.map((target) => {
|
|
287
|
+
const path = resolveTargetRef(target, context);
|
|
288
|
+
const committed = path !== '' && fileIdentity(path) !== target.expected_identity;
|
|
289
|
+
const targetVerified = !executionFailed && verified;
|
|
290
|
+
return {
|
|
291
|
+
target_id: target.target_id,
|
|
292
|
+
outcome: target.disposition === 'already_satisfied' || !committed && targetVerified
|
|
293
|
+
? confirmed.action === 'uninstall' ? 'already_absent' : 'already_satisfied'
|
|
294
|
+
: committed
|
|
295
|
+
? confirmed.action === 'install' ? 'installed' : 'removed'
|
|
296
|
+
: 'failed',
|
|
297
|
+
committed,
|
|
298
|
+
verified: targetVerified,
|
|
299
|
+
...(!targetVerified ? { recovery: committed ? 'RETRY_VERIFICATION' : 'OPEN_CONFIG' } : {}),
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
return {
|
|
303
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
304
|
+
action: confirmed.action,
|
|
305
|
+
runtime: context.runtime,
|
|
306
|
+
scope: context.scope,
|
|
307
|
+
plan_id: confirmed.plan_id,
|
|
308
|
+
generation: confirmed.generation,
|
|
309
|
+
target_set_digest: confirmed.target_set_digest,
|
|
310
|
+
complete: verified,
|
|
311
|
+
verified,
|
|
312
|
+
targets,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function executeSetupLifecycleTarget(context, confirmed, targetId, completedTargetIds, createdAt, expiresAt) {
|
|
316
|
+
const selected = confirmed.targets.find((target) => target.target_id === targetId);
|
|
317
|
+
if (!selected)
|
|
318
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'selected lifecycle target is not in the confirmed plan');
|
|
319
|
+
const confirmedIds = new Set(confirmed.targets.map((target) => target.target_id));
|
|
320
|
+
const completed = new Set(completedTargetIds);
|
|
321
|
+
if (completed.size !== completedTargetIds.length || completed.has(targetId) || [...completed].some((id) => !confirmedIds.has(id))) {
|
|
322
|
+
throw new SetupLifecycleError('PLAN_INVALID', 'completed lifecycle target set is invalid');
|
|
323
|
+
}
|
|
324
|
+
const current = planForTimes(context, confirmed.action, createdAt, expiresAt);
|
|
325
|
+
const currentTargets = current.targets.filter((target) => target.disposition !== 'already_satisfied');
|
|
326
|
+
const currentByID = new Map(currentTargets.map((target) => [target.target_id, target]));
|
|
327
|
+
if (currentTargets.some((target) => !confirmedIds.has(target.target_id))) {
|
|
328
|
+
throw new SetupLifecycleError('PLAN_STALE', 'lifecycle target set changed; create a fresh plan');
|
|
329
|
+
}
|
|
330
|
+
if (selected.disposition === 'already_satisfied') {
|
|
331
|
+
return {
|
|
332
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
333
|
+
action: confirmed.action,
|
|
334
|
+
runtime: context.runtime,
|
|
335
|
+
scope: context.scope,
|
|
336
|
+
plan_id: confirmed.plan_id,
|
|
337
|
+
generation: confirmed.generation,
|
|
338
|
+
target_set_digest: confirmed.target_set_digest,
|
|
339
|
+
complete: true,
|
|
340
|
+
verified: true,
|
|
341
|
+
targets: [{
|
|
342
|
+
target_id: targetId,
|
|
343
|
+
outcome: confirmed.action === 'uninstall' ? 'already_absent' : 'already_satisfied',
|
|
344
|
+
committed: false,
|
|
345
|
+
verified: true,
|
|
346
|
+
}],
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
for (const target of confirmed.targets) {
|
|
350
|
+
if (target.disposition === 'already_satisfied')
|
|
351
|
+
continue;
|
|
352
|
+
const currentTarget = currentByID.get(target.target_id);
|
|
353
|
+
if (completed.has(target.target_id)) {
|
|
354
|
+
if (currentTarget)
|
|
355
|
+
throw new SetupLifecycleError('PLAN_STALE', 'a completed lifecycle target is no longer verified');
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (target.target_id === targetId) {
|
|
359
|
+
if (currentTarget && currentTarget.expected_identity !== target.expected_identity) {
|
|
360
|
+
throw new SetupLifecycleError('PLAN_STALE', 'selected lifecycle target identity changed');
|
|
361
|
+
}
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (!currentTarget || currentTarget.expected_identity !== target.expected_identity) {
|
|
365
|
+
throw new SetupLifecycleError('PLAN_STALE', 'a pending lifecycle target identity changed');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const targetPath = resolveTargetRef(selected, context);
|
|
369
|
+
const alreadyApplied = !currentByID.has(targetId);
|
|
370
|
+
if (alreadyApplied) {
|
|
371
|
+
return {
|
|
372
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
373
|
+
action: confirmed.action,
|
|
374
|
+
runtime: context.runtime,
|
|
375
|
+
scope: context.scope,
|
|
376
|
+
plan_id: confirmed.plan_id,
|
|
377
|
+
generation: confirmed.generation,
|
|
378
|
+
target_set_digest: confirmed.target_set_digest,
|
|
379
|
+
complete: true,
|
|
380
|
+
verified: true,
|
|
381
|
+
targets: [{
|
|
382
|
+
target_id: targetId,
|
|
383
|
+
outcome: confirmed.action === 'uninstall' ? 'already_absent' : 'already_satisfied',
|
|
384
|
+
committed: false,
|
|
385
|
+
verified: true,
|
|
386
|
+
}],
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
let executionFailed = false;
|
|
390
|
+
try {
|
|
391
|
+
const result = confirmed.action === 'install'
|
|
392
|
+
? installInjection(context.injectionPlan, { ...context.installOptions, targetPath })
|
|
393
|
+
: uninstallInjection(context.runtime, {
|
|
394
|
+
configRoot: context.configRoot,
|
|
395
|
+
scope: context.scope,
|
|
396
|
+
homeDir: context.installOptions.homeDir,
|
|
397
|
+
codexHome: context.installOptions.codexHome,
|
|
398
|
+
kiroHome: context.installOptions.kiroHome,
|
|
399
|
+
xdgConfigHome: context.installOptions.xdgConfigHome,
|
|
400
|
+
opencodeConfig: context.installOptions.opencodeConfig,
|
|
401
|
+
opencodeConfigDir: context.installOptions.opencodeConfigDir,
|
|
402
|
+
targetPath,
|
|
403
|
+
});
|
|
404
|
+
executionFailed = !result.ok;
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
executionFailed = true;
|
|
408
|
+
}
|
|
409
|
+
let verified = false;
|
|
410
|
+
try {
|
|
411
|
+
const after = planForTimes(context, confirmed.action, createdAt, expiresAt);
|
|
412
|
+
verified = !after.targets.some((target) => target.target_id === targetId);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
executionFailed = true;
|
|
416
|
+
}
|
|
417
|
+
const committed = targetPath !== '' && fileIdentity(targetPath) !== selected.expected_identity;
|
|
418
|
+
const targetVerified = !executionFailed && verified;
|
|
419
|
+
const outcome = targetVerified
|
|
420
|
+
? confirmed.action === 'install' ? 'installed' : 'removed'
|
|
421
|
+
: 'failed';
|
|
422
|
+
return {
|
|
423
|
+
schema: SETUP_LIFECYCLE_SCHEMA,
|
|
424
|
+
action: confirmed.action,
|
|
425
|
+
runtime: context.runtime,
|
|
426
|
+
scope: context.scope,
|
|
427
|
+
plan_id: confirmed.plan_id,
|
|
428
|
+
generation: confirmed.generation,
|
|
429
|
+
target_set_digest: confirmed.target_set_digest,
|
|
430
|
+
complete: targetVerified,
|
|
431
|
+
verified: targetVerified,
|
|
432
|
+
targets: [{
|
|
433
|
+
target_id: targetId,
|
|
434
|
+
outcome,
|
|
435
|
+
committed,
|
|
436
|
+
verified: targetVerified,
|
|
437
|
+
...(!targetVerified ? { recovery: committed ? 'RETRY_VERIFICATION' : 'OPEN_CONFIG' } : {}),
|
|
438
|
+
}],
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function resolveTargetRef(target, context) {
|
|
442
|
+
if (target.disposition === 'already_satisfied' || target.target_ref.startsWith('<managed:'))
|
|
443
|
+
return '';
|
|
444
|
+
if (target.target_ref.startsWith('~/')) {
|
|
445
|
+
return resolve(context.installOptions.homeDir ?? homedir(), target.target_ref.slice(2));
|
|
446
|
+
}
|
|
447
|
+
return resolve(context.configRoot, target.target_ref);
|
|
448
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evomap/evolver-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.34",
|
|
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.
|
|
27
|
-
"@evomap/evolver-adapter-public": "2.0.
|
|
28
|
-
"@evomap/evolver-mcp": "2.0.
|
|
29
|
-
"@evomap/evolver-proxy": "2.0.
|
|
30
|
-
"@evomap/evolver-runtime-adapters": "2.0.
|
|
31
|
-
"@evomap/evolver-webui": "2.0.
|
|
26
|
+
"@evomap/evolver-core": "2.0.34",
|
|
27
|
+
"@evomap/evolver-adapter-public": "2.0.34",
|
|
28
|
+
"@evomap/evolver-mcp": "2.0.34",
|
|
29
|
+
"@evomap/evolver-proxy": "2.0.34",
|
|
30
|
+
"@evomap/evolver-runtime-adapters": "2.0.34",
|
|
31
|
+
"@evomap/evolver-webui": "2.0.34"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|