@evomap/evolver-cli 2.0.23 → 2.0.24
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/autoDistillAntiGene.js +7 -5
- package/dist/autoDistillLlm.js +10 -12
- package/dist/autoexec.js +39 -7
- package/dist/cliContracts.d.ts +2 -0
- package/dist/cliContracts.js +39 -21
- package/dist/cycleConsumer.js +3 -3
- package/dist/distillObserver.js +6 -4
- package/dist/doctor.d.ts +11 -0
- package/dist/doctor.js +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +98 -31
- package/dist/lifecycle.d.ts +23 -0
- package/dist/lifecycle.js +86 -5
- package/dist/recipe.js +49 -16
- package/dist/requiredSandboxValidation.d.ts +2 -1
- package/dist/requiredSandboxValidation.js +36 -2
- package/dist/reviewFilter.d.ts +3 -1
- package/dist/reviewFilter.js +3 -1
- package/dist/setupHooks.js +12 -6
- package/dist/skill2gep.js +72 -8
- package/dist/valueDigest.js +8 -1
- package/dist/windowsLegacyTaskCleanup.d.ts +228 -0
- package/dist/windowsLegacyTaskCleanup.js +1475 -0
- package/dist/workflowRuntime.js +2 -2
- package/package.json +7 -7
package/dist/lifecycle.js
CHANGED
|
@@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
8
8
|
import { bootstrap as coreBootstrap, util as coreUtil } from '@evomap/evolver-core';
|
|
9
9
|
import { expandHomePath, loadEnvFile, loadEnvFileFromEnv, parseEnvFile } from '@evomap/evolver-mcp';
|
|
10
10
|
import { acquireBootstrapOwnerLock, acquireBootstrapReadinessLock, adoptLegacyBootstrapMarker, applyBootstrapCanonicalQuarantine, assertTrustedArtifactParent, assertActiveBootstrapRegistrationIntentToken, assertPlannedArtifactsAbsent, assertBootstrapTransactionClaimsAbsent, bootstrapArtifactClaimPath, bootstrapArtifactContentIdentityForFile, bootstrapArtifactIdentityForBytes, bootstrapJournalPath, bootstrapJournalFromMarker, bootstrapJournalManagerArtifactPath, bootstrapMarkerPath, bootstrapReadinessPath, captureBootstrapArtifactIdentities, createLegacyBootstrapRemovalJournal, createBootstrapJournal, ensureBootstrapManualTransition, finalizeBootstrapCanonicalQuarantine, planBootstrapCanonicalQuarantine, readBootstrapJournal, readBootstrapArtifactFile, readLegacyBootstrapMarker, readBootstrapManualTransition, readBootstrapMarker, readBootstrapReadiness, recordPublishedBootstrapArtifact, removeBootstrapJournal, removeBootstrapManualTransition, removeBootstrapReadiness, removeDurableFile, removeOwnedBootstrapArtifacts, restoreBootstrapCanonicalQuarantine, updateBootstrapJournal, writeBootstrapJournal, writeDurableBytesExclusive, writeDurableJsonExclusive, writeDurableTextExclusive, LEGACY_BOOTSTRAP_REMOVAL_OPERATION, } from './lifecycleBootstrapTransaction.js';
|
|
11
|
+
import { cleanupLegacyWindowsDaemonTasks, legacyTaskProbeSkipped, restoreLegacyTaskPreimage, sweepLegacyWindowsDaemonTasksAfterBootstrap, LEGACY_TASK_SKIP_ENV, } from './windowsLegacyTaskCleanup.js';
|
|
11
12
|
const requireFromHere = createRequire(import.meta.url);
|
|
12
13
|
const DEFAULT_DAEMON_NAME = 'evolver-proxy';
|
|
13
14
|
const DEFAULT_LABEL = 'com.evomap.evolver-proxy';
|
|
@@ -35,7 +36,7 @@ const PS_PATH = selectExistingPosixCommand([
|
|
|
35
36
|
const LAUNCHCTL_PATH = '/bin/launchctl';
|
|
36
37
|
const UNIX_RECOVERY_CONTROLLER_FILENAME = 'evolver-recovery-controller';
|
|
37
38
|
const HOST_WINDOWS_SYSTEM_ROOT = process.env['SystemRoot']?.trim() || 'C:\\Windows';
|
|
38
|
-
const LIFECYCLE_USAGE = 'Usage: evolver lifecycle <start|stop|restart|status|check|watch|install-service --target=launchd|systemd|windows [--with-autoexec] [--autoexec-home=<path>]|remove-service --target=launchd|systemd|windows [--dry-run] [--env-file=<path>]|bootstrap [--target=launchd|systemd|windows] [--dry-run]|remove-autoexec-service --target=launchd|systemd|windows [--dry-run]
|
|
39
|
+
const LIFECYCLE_USAGE = 'Usage: evolver lifecycle <start|stop|restart|status|check|watch|install-service --target=launchd|systemd|windows [--with-autoexec] [--autoexec-home=<path>]|remove-service --target=launchd|systemd|windows [--dry-run] [--env-file=<path>]|bootstrap [--target=launchd|systemd|windows] [--dry-run]|remove-autoexec-service --target=launchd|systemd|windows [--dry-run]|cleanup-legacy-tasks [--dry-run]|restore-legacy-task-preimage --preimage=<path>>\n';
|
|
39
40
|
export function selectExistingPosixCommand(candidates, exists = existsSync) {
|
|
40
41
|
if (candidates.length === 0 || candidates.some((candidate) => !posix.isAbsolute(candidate))) {
|
|
41
42
|
throw new Error('trusted command candidates must be non-empty absolute POSIX paths');
|
|
@@ -336,9 +337,41 @@ async function runLifecycleCommandInner(argv, deps) {
|
|
|
336
337
|
: loadEnvFileFromEnv(env);
|
|
337
338
|
if (envFileResult.error)
|
|
338
339
|
throw new Error('failed to load lifecycle environment file');
|
|
340
|
+
// Like install-service: recompute AFTER the env-file load so a state-dir pointer in
|
|
341
|
+
// the env file is honored by the piggyback legacy sweep below (the `paths` captured
|
|
342
|
+
// before the load would put owner lock/preimage/cooldown state in the wrong dir).
|
|
343
|
+
const removeStateDir = lifecyclePaths(env).stateDir;
|
|
339
344
|
const result = await removeBootstrapService(removeFlags.target, removeFlags.dryRun, env, deps.bootstrap ?? {}, deps.argv1 ?? process.argv[1], deps.loadUnixRecoveryController, removeFlags.envFile ? { 'env-file': removeFlags.envFile } : {});
|
|
340
|
-
|
|
341
|
-
|
|
345
|
+
const payload = { ...result };
|
|
346
|
+
let exitCode = 0;
|
|
347
|
+
if (removeFlags.target === 'windows') {
|
|
348
|
+
// #956 uninstall path: after the owned v2 manager removal, sweep legacy v1 residue.
|
|
349
|
+
// The sweep keeps its own fail-closed semantics and is reported in the payload.
|
|
350
|
+
// This composite command must also return non-zero when the sweep cannot prove a
|
|
351
|
+
// conclusive result, so payload-aware and exit-code-aware automation see the same truth.
|
|
352
|
+
// Unlike that explicit command, this piggyback sweep honors the opt-out so suites
|
|
353
|
+
// and opted-out hosts never touch the real Task Scheduler.
|
|
354
|
+
if (legacyTaskProbeSkipped(env)) {
|
|
355
|
+
payload.legacyTaskCleanup = {
|
|
356
|
+
status: 'skipped',
|
|
357
|
+
detail: `${LEGACY_TASK_SKIP_ENV} is set; run evolver lifecycle cleanup-legacy-tasks explicitly`,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
const sweep = (deps.cleanupLegacyTasks ?? cleanupLegacyWindowsDaemonTasks)({
|
|
362
|
+
env,
|
|
363
|
+
stateDir: removeStateDir,
|
|
364
|
+
dryRun: removeFlags.dryRun,
|
|
365
|
+
});
|
|
366
|
+
payload.legacyTaskCleanup = sweep;
|
|
367
|
+
if (sweep.status === 'failed' || sweep.status === 'inconclusive') {
|
|
368
|
+
exitCode = 1;
|
|
369
|
+
stderr(`legacy v1 scheduled-task cleanup ${sweep.status}${sweep.detail ? `: ${sweep.detail}` : ''}; run evolver lifecycle cleanup-legacy-tasks\n`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
stdout(`${JSON.stringify(payload, null, 2)}\n`);
|
|
374
|
+
return exitCode;
|
|
342
375
|
}
|
|
343
376
|
case 'remove-autoexec-service': {
|
|
344
377
|
if (flags['dry-run'] !== undefined && flags['dry-run'] !== true) {
|
|
@@ -349,6 +382,42 @@ async function runLifecycleCommandInner(argv, deps) {
|
|
|
349
382
|
stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
350
383
|
return 0;
|
|
351
384
|
}
|
|
385
|
+
case 'cleanup-legacy-tasks': {
|
|
386
|
+
if (flags['dry-run'] !== undefined && flags['dry-run'] !== true) {
|
|
387
|
+
throw new Error('--dry-run is a boolean flag and does not accept a value');
|
|
388
|
+
}
|
|
389
|
+
const cleanupEnvFileResult = loadEnvFileFromEnv(env);
|
|
390
|
+
if (cleanupEnvFileResult.error)
|
|
391
|
+
throw new Error('failed to load lifecycle environment file');
|
|
392
|
+
// Read AFTER the env-file load so a pointer in the env file is honored
|
|
393
|
+
// (mirrors the session-start sweep in index.ts).
|
|
394
|
+
const result = (deps.cleanupLegacyTasks ?? cleanupLegacyWindowsDaemonTasks)({
|
|
395
|
+
env,
|
|
396
|
+
stateDir: lifecyclePaths(env).stateDir,
|
|
397
|
+
dryRun: flags['dry-run'] === true,
|
|
398
|
+
});
|
|
399
|
+
stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
400
|
+
// An inconclusive or failed run must surface a non-zero exit: automation that reads
|
|
401
|
+
// the status field and automation that reads the exit code get the same truth.
|
|
402
|
+
return result.status === 'inconclusive' || result.status === 'failed' ? 1 : 0;
|
|
403
|
+
}
|
|
404
|
+
case 'restore-legacy-task-preimage': {
|
|
405
|
+
const preimage = typeof flags['preimage'] === 'string' ? flags['preimage'] : undefined;
|
|
406
|
+
if (!preimage) {
|
|
407
|
+
throw new Error('restore-legacy-task-preimage requires --preimage=<path>');
|
|
408
|
+
}
|
|
409
|
+
const restoreEnvFileResult = loadEnvFileFromEnv(env);
|
|
410
|
+
if (restoreEnvFileResult.error)
|
|
411
|
+
throw new Error('failed to load lifecycle environment file');
|
|
412
|
+
// Read AFTER the env-file load so a pointer in the env file is honored
|
|
413
|
+
// (mirrors the session-start sweep in index.ts).
|
|
414
|
+
const result = (deps.restoreLegacyTaskPreimage ?? restoreLegacyTaskPreimage)(preimage, {
|
|
415
|
+
env,
|
|
416
|
+
stateDir: lifecyclePaths(env).stateDir,
|
|
417
|
+
});
|
|
418
|
+
stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
419
|
+
return result.status === 'restored' ? 0 : 1;
|
|
420
|
+
}
|
|
352
421
|
default:
|
|
353
422
|
stderr(LIFECYCLE_USAGE);
|
|
354
423
|
return action === undefined ? 0 : 1;
|
|
@@ -812,7 +881,7 @@ function trustedWindowsSystemExecutable(name) {
|
|
|
812
881
|
}
|
|
813
882
|
return win32.join(HOST_WINDOWS_SYSTEM_ROOT, 'System32', name);
|
|
814
883
|
}
|
|
815
|
-
function trustedWindowsPowerShell() {
|
|
884
|
+
export function trustedWindowsPowerShell() {
|
|
816
885
|
return trustedWindowsSystemExecutable('WindowsPowerShell\\v1.0\\powershell.exe');
|
|
817
886
|
}
|
|
818
887
|
function renderWindowsProxyLauncherBytes(defaults) {
|
|
@@ -2563,7 +2632,7 @@ async function bootstrapService(flags, env, argv1, deps, loadUnixRecoveryControl
|
|
|
2563
2632
|
assertForwardMutationBudget(deadlineMs, now());
|
|
2564
2633
|
return result;
|
|
2565
2634
|
};
|
|
2566
|
-
const actions = activateBootstrapTarget(target, files, forwardRun, uid, deadlineMs, now);
|
|
2635
|
+
const actions = [...activateBootstrapTarget(target, files, forwardRun, uid, deadlineMs, now)];
|
|
2567
2636
|
const managerPid = await waitForBootstrapManagerBinding(journal, forwardRun, uid, deadlineMs, now, deps.healthTimeoutMs ?? BOOTSTRAP_HEALTH_TIMEOUT_MS, assertOwner);
|
|
2568
2637
|
assertOwner();
|
|
2569
2638
|
const healthyReadiness = await requireBootstrapProxyHealth(lifecyclePaths(env), env, journal, managerPid, deps, forwardRun, uid, deadlineMs, now, assertOwner);
|
|
@@ -2627,6 +2696,18 @@ async function bootstrapService(flags, env, argv1, deps, loadUnixRecoveryControl
|
|
|
2627
2696
|
catch {
|
|
2628
2697
|
// The durable versioned marker is the commit point. Recovery recognizes its transaction id.
|
|
2629
2698
|
}
|
|
2699
|
+
if (target === 'windows') {
|
|
2700
|
+
// Post-activation sweep (#956): remove legacy V1 scheduled-task residue under the
|
|
2701
|
+
// already-held owner lock. Best-effort for the bootstrap (the committed marker is
|
|
2702
|
+
// the commit point and a sweep error can never roll it back), but an inconclusive
|
|
2703
|
+
// or failed sweep is reported in `actions` instead of being hidden.
|
|
2704
|
+
actions.push(...sweepLegacyWindowsDaemonTasksAfterBootstrap({
|
|
2705
|
+
env,
|
|
2706
|
+
stateDir,
|
|
2707
|
+
assertOwner,
|
|
2708
|
+
...(deps.legacyTaskCleanupRun ? { run: deps.legacyTaskCleanupRun } : {}),
|
|
2709
|
+
}));
|
|
2710
|
+
}
|
|
2630
2711
|
return {
|
|
2631
2712
|
status: 'bootstrapped',
|
|
2632
2713
|
transactionId: marker.transactionId,
|
package/dist/recipe.js
CHANGED
|
@@ -16,10 +16,24 @@ const MAX_RECIPE_INPUT_BYTES = 1024 * 1024;
|
|
|
16
16
|
const MAX_ID_LENGTH = 200;
|
|
17
17
|
const SENSITIVE_ERROR_KEYS = new Set(['authorization', 'node_secret', 'nodesecret', 'token', 'access_token', 'refresh_token', 'secret']);
|
|
18
18
|
const STALE_NODE_SECRET_ERRORS = new Set(['node_secret_invalid', 'node_secret_not_set']);
|
|
19
|
+
const RECIPE_SEARCH_VALUE_OPTIONS = new Set(['--q', '--query', '--limit']);
|
|
20
|
+
const RECIPE_REUSE_COMMAND = 'evolver recipe reuse --id <recipe_id>';
|
|
19
21
|
function recipeIdempotencyKey(operation, value) {
|
|
20
22
|
const digest = createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
21
23
|
return `evolver-recipe-${operation}-${digest}`;
|
|
22
24
|
}
|
|
25
|
+
function terminalSafeText(value) {
|
|
26
|
+
return String(value ?? '').replace(/\p{Cc}/gu, '');
|
|
27
|
+
}
|
|
28
|
+
function terminalSafeJson(value, space) {
|
|
29
|
+
const json = JSON.stringify(value === undefined ? {} : value, null, space);
|
|
30
|
+
return json.replace(/\p{Cc}/gu, (char) => {
|
|
31
|
+
const codePoint = char.codePointAt(0);
|
|
32
|
+
if (codePoint === undefined || codePoint < 0x7f)
|
|
33
|
+
return char;
|
|
34
|
+
return `\\u${codePoint.toString(16).padStart(4, '0')}`;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
23
37
|
const recipeIdentityBootstraps = new WeakMap();
|
|
24
38
|
export async function runRecipeCommand(argv, deps = {}) {
|
|
25
39
|
const parsed = parseRecipeArgs(argv);
|
|
@@ -77,15 +91,16 @@ async function runRecipeBuildDryRun(opts, store, io) {
|
|
|
77
91
|
}
|
|
78
92
|
function runRecipeSearchDryRun(opts, io) {
|
|
79
93
|
const action = opts.q ? 'search_recipe' : 'list_recipe';
|
|
80
|
-
|
|
94
|
+
const displayQuery = terminalSafeText(opts.q);
|
|
95
|
+
io.log(`[recipe search] dry-run: would ${opts.q ? `search recipes q=${JSON.stringify(displayQuery)}` : 'list published recipes'}.`);
|
|
81
96
|
if (opts.jsonOut) {
|
|
82
|
-
io.log(
|
|
97
|
+
io.log(terminalSafeJson({
|
|
83
98
|
dry_run: true,
|
|
84
99
|
would: action,
|
|
85
100
|
...(opts.q ? { q: opts.q } : {}),
|
|
86
101
|
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
87
102
|
recipes: [],
|
|
88
|
-
},
|
|
103
|
+
}, 2));
|
|
89
104
|
}
|
|
90
105
|
return 0;
|
|
91
106
|
}
|
|
@@ -102,9 +117,9 @@ async function runRecipeSearch(opts, hub, io) {
|
|
|
102
117
|
const receipt = opts.q
|
|
103
118
|
? await callRecipeWithAuthRetry(hub, 'recipe search', () => recipes.search(request), io)
|
|
104
119
|
: await callRecipeWithAuthRetry(hub, 'recipe search', () => recipes.list(request), io);
|
|
105
|
-
io.log(`[recipe search] ${receipt.recipes.length} recipe(s)
|
|
120
|
+
io.log(`[recipe search] ${receipt.recipes.length} recipe(s). Express with: ${RECIPE_REUSE_COMMAND}`);
|
|
106
121
|
if (opts.jsonOut) {
|
|
107
|
-
io.log(
|
|
122
|
+
io.log(terminalSafeJson(receipt.raw ?? receipt, 2));
|
|
108
123
|
return 0;
|
|
109
124
|
}
|
|
110
125
|
for (const recipe of receipt.recipes) {
|
|
@@ -114,20 +129,23 @@ async function runRecipeSearch(opts, hub, io) {
|
|
|
114
129
|
: typeof row['recipeId'] === 'string' ? row['recipeId']
|
|
115
130
|
: undefined;
|
|
116
131
|
const title = typeof row['title'] === 'string' ? row['title'] : undefined;
|
|
117
|
-
|
|
132
|
+
const displayId = id ? terminalSafeText(id) : undefined;
|
|
133
|
+
const displayTitle = title ? terminalSafeText(title) : undefined;
|
|
134
|
+
io.log(displayId && displayTitle ? ` ${displayId} ${displayTitle}` : displayId ? ` ${displayId}` : ` ${terminalSafeJson(recipe)}`);
|
|
118
135
|
}
|
|
119
136
|
return 0;
|
|
120
137
|
}
|
|
121
138
|
function runRecipeReuseDryRun(opts, io) {
|
|
122
|
-
|
|
123
|
-
io.log(`[recipe reuse] dry-run: would
|
|
139
|
+
const displayRecipeId = terminalSafeText(opts.recipeId);
|
|
140
|
+
io.log(`[recipe reuse] dry-run: would fetch recipe ${displayRecipeId}.`);
|
|
141
|
+
io.log(`[recipe reuse] dry-run: would express recipe ${displayRecipeId}.`);
|
|
124
142
|
if (opts.jsonOut) {
|
|
125
|
-
io.log(
|
|
143
|
+
io.log(terminalSafeJson({
|
|
126
144
|
dry_run: true,
|
|
127
145
|
would: 'express_recipe',
|
|
128
146
|
recipe_id: opts.recipeId,
|
|
129
147
|
input_payload: opts.inputPayload,
|
|
130
|
-
},
|
|
148
|
+
}, 2));
|
|
131
149
|
}
|
|
132
150
|
return 0;
|
|
133
151
|
}
|
|
@@ -435,9 +453,9 @@ async function runRecipeFromSkills(opts, hub, deps, io, dryRun) {
|
|
|
435
453
|
async function runRecipeReuse(opts, hub, io) {
|
|
436
454
|
await callRecipeWithAuthRetry(hub, 'recipe reuse', () => hub.recipes.get(opts.recipeId), io);
|
|
437
455
|
const receipt = await callRecipeWithAuthRetry(hub, 'recipe reuse', () => hub.recipes.express(opts.recipeId, { inputPayload: opts.inputPayload }), io);
|
|
438
|
-
io.log(`[recipe reuse] Expressed recipe ${opts.recipeId}.`);
|
|
456
|
+
io.log(`[recipe reuse] Expressed recipe ${terminalSafeText(opts.recipeId)}.`);
|
|
439
457
|
if (opts.jsonOut)
|
|
440
|
-
io.log(
|
|
458
|
+
io.log(terminalSafeJson(receipt.raw, 2));
|
|
441
459
|
return 0;
|
|
442
460
|
}
|
|
443
461
|
async function recipeStepsFromLocalAssets(assetIds, store) {
|
|
@@ -495,8 +513,8 @@ async function verifyRecipeFromSkillsSteps(steps, runValidation) {
|
|
|
495
513
|
};
|
|
496
514
|
}
|
|
497
515
|
if (validation.skipped.length > 0) {
|
|
498
|
-
const skipped = validation.skipped.map((item) => item.script).join(', ');
|
|
499
|
-
return { ok: false, error: `recipe from-skills step ${i + 1} validation incomplete:
|
|
516
|
+
const skipped = validation.skipped.map((item) => `${item.script} (${item.reason})`).join(', ');
|
|
517
|
+
return { ok: false, error: `recipe from-skills step ${i + 1} validation incomplete: skipped or rejected ${skipped}` };
|
|
500
518
|
}
|
|
501
519
|
if (!validation.passed) {
|
|
502
520
|
return { ok: false, error: `recipe from-skills step ${i + 1} validation failed` };
|
|
@@ -932,7 +950,7 @@ function parseFromSkillsArgs(args) {
|
|
|
932
950
|
};
|
|
933
951
|
}
|
|
934
952
|
function parseSearchArgs(args) {
|
|
935
|
-
const q = flagValue(args, '--q') ?? flagValue(args, '--query') ??
|
|
953
|
+
const q = flagValue(args, '--q') ?? flagValue(args, '--query') ?? firstSearchPositional(args) ?? undefined;
|
|
936
954
|
const limitRaw = flagValue(args, '--limit');
|
|
937
955
|
const limit = limitRaw === null ? undefined : Number(limitRaw);
|
|
938
956
|
if (limit !== undefined && (!Number.isSafeInteger(limit) || limit <= 0)) {
|
|
@@ -980,6 +998,21 @@ function flagValue(args, flag) {
|
|
|
980
998
|
function firstPositional(args) {
|
|
981
999
|
return args.find((a) => typeof a === 'string' && !a.startsWith('--')) ?? null;
|
|
982
1000
|
}
|
|
1001
|
+
function firstSearchPositional(args) {
|
|
1002
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
1003
|
+
const token = args[i];
|
|
1004
|
+
if (token === undefined)
|
|
1005
|
+
continue;
|
|
1006
|
+
if (!token.startsWith('--'))
|
|
1007
|
+
return token;
|
|
1008
|
+
if (!token.includes('=') && RECIPE_SEARCH_VALUE_OPTIONS.has(token)) {
|
|
1009
|
+
const next = args[i + 1];
|
|
1010
|
+
if (next !== undefined && !next.startsWith('--'))
|
|
1011
|
+
i += 1;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
983
1016
|
function parseJsonObject(raw) {
|
|
984
1017
|
try {
|
|
985
1018
|
const parsed = JSON.parse(raw);
|
|
@@ -1346,6 +1379,6 @@ function recipeUsage() {
|
|
|
1346
1379
|
' Distills ordered SKILL.md steps with execution evidence, then creates a recipe.',
|
|
1347
1380
|
' evolver recipe reuse --id <recipe_id> [--input <json-object>] [--json]',
|
|
1348
1381
|
' evolver recipe search [--q <text>] [--limit <n>] [--json]',
|
|
1349
|
-
|
|
1382
|
+
` Default agent lookup. Express a hit with \`${RECIPE_REUSE_COMMAND}\`. Gene/Capsule search is fallback.`,
|
|
1350
1383
|
].join('\n');
|
|
1351
1384
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { verify } from '@evomap/evolver-core';
|
|
2
2
|
export type SandboxedValidationRunner = typeof verify.runSandboxedValidation;
|
|
3
3
|
type SandboxedValidationOptions = NonNullable<Parameters<SandboxedValidationRunner>[2]>;
|
|
4
|
-
|
|
4
|
+
type SandboxedValidationReceipt = Awaited<ReturnType<SandboxedValidationRunner>>;
|
|
5
|
+
export declare function runRequiredSandboxedValidation(commands: readonly string[], cwd: string, options?: SandboxedValidationOptions, runner?: SandboxedValidationRunner): Promise<SandboxedValidationReceipt>;
|
|
5
6
|
export {};
|
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
import { verify } from '@evomap/evolver-core';
|
|
2
|
-
export function runRequiredSandboxedValidation(commands, cwd, options = {}, runner = verify.runSandboxedValidation) {
|
|
3
|
-
|
|
2
|
+
export async function runRequiredSandboxedValidation(commands, cwd, options = {}, runner = verify.runSandboxedValidation) {
|
|
3
|
+
const sanitizedPlan = commands.map((command) => verify.sanitizeExecutionCommand(command));
|
|
4
|
+
if (sanitizedPlan.some((command) => command.changed || command.blocked)) {
|
|
5
|
+
return {
|
|
6
|
+
passed: false,
|
|
7
|
+
score: 0.2,
|
|
8
|
+
results: sanitizedPlan.map((command) => ({
|
|
9
|
+
label: command.value.split(/\s+/)[0] || '<redacted>',
|
|
10
|
+
cmd: command.value,
|
|
11
|
+
allowed: false,
|
|
12
|
+
exitCode: null,
|
|
13
|
+
stdoutSummary: command.changed || command.blocked
|
|
14
|
+
? 'execution_credential_blocked'
|
|
15
|
+
: 'validation_plan_blocked',
|
|
16
|
+
passed: false,
|
|
17
|
+
})),
|
|
18
|
+
skipped: [],
|
|
19
|
+
isolated: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const safeCommands = sanitizedPlan.map((command) => command.value);
|
|
23
|
+
const result = await runner(safeCommands, cwd, { ...options, requireIsolation: true });
|
|
24
|
+
const sanitized = verify.sanitizeExecutionPayload(result);
|
|
25
|
+
if (!sanitized.blocked)
|
|
26
|
+
return sanitized.value;
|
|
27
|
+
return {
|
|
28
|
+
...sanitized.value,
|
|
29
|
+
passed: false,
|
|
30
|
+
score: 0.2,
|
|
31
|
+
results: sanitized.value.results.map((entry) => ({
|
|
32
|
+
...entry,
|
|
33
|
+
allowed: false,
|
|
34
|
+
passed: false,
|
|
35
|
+
stdoutSummary: entry.stdoutSummary || 'execution_credential_blocked',
|
|
36
|
+
})),
|
|
37
|
+
};
|
|
4
38
|
}
|
package/dist/reviewFilter.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { assetstore } from '@evomap/evolver-core';
|
|
2
2
|
export declare const reviewLedgerForStore: typeof assetstore.reviewLedgerForStore;
|
|
3
3
|
export declare const provenanceStoreForStore: typeof assetstore.provenanceStoreForStore;
|
|
4
|
-
export declare const listApprovedGenes: typeof assetstore.listApprovedGenes;
|
|
4
|
+
export declare const listApprovedGenes: typeof assetstore.listApprovedGenes;
|
|
5
|
+
export declare const pendingReviewRecords: typeof assetstore.pendingReviewRecords;
|
|
6
|
+
export declare const pendingGeneReviewRecords: typeof assetstore.pendingGeneReviewRecords;
|
package/dist/reviewFilter.js
CHANGED
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
import { assetstore } from '@evomap/evolver-core';
|
|
4
4
|
export const reviewLedgerForStore = assetstore.reviewLedgerForStore;
|
|
5
5
|
export const provenanceStoreForStore = assetstore.provenanceStoreForStore;
|
|
6
|
-
export const listApprovedGenes = assetstore.listApprovedGenes;
|
|
6
|
+
export const listApprovedGenes = assetstore.listApprovedGenes;
|
|
7
|
+
export const pendingReviewRecords = assetstore.pendingReviewRecords;
|
|
8
|
+
export const pendingGeneReviewRecords = assetstore.pendingGeneReviewRecords;
|
package/dist/setupHooks.js
CHANGED
|
@@ -16,6 +16,12 @@ import { resolveProxyBinPath, resolveStableNodePath } from './lifecycle.js';
|
|
|
16
16
|
import { reviewLedgerForStore } from './reviewFilter.js';
|
|
17
17
|
import { maybeEmitNonGitWorkspaceNotice } from './nonGitWorkspaceNotice.js';
|
|
18
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
|
+
}
|
|
19
25
|
function parseFlags(argv) {
|
|
20
26
|
const out = {};
|
|
21
27
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -70,7 +76,7 @@ function defaultRuntimeAvailable(runtime, configRoot, scope) {
|
|
|
70
76
|
const resolution = resolveOpenCodeConfig({
|
|
71
77
|
configRoot,
|
|
72
78
|
scope,
|
|
73
|
-
homeDir:
|
|
79
|
+
homeDir: configuredHomeDir(),
|
|
74
80
|
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
75
81
|
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
76
82
|
opencodeConfigDir: process.env['OPENCODE_CONFIG_DIR'],
|
|
@@ -79,7 +85,7 @@ function defaultRuntimeAvailable(runtime, configRoot, scope) {
|
|
|
79
85
|
}
|
|
80
86
|
const pathOptions = {
|
|
81
87
|
configRoot,
|
|
82
|
-
homeDir:
|
|
88
|
+
homeDir: configuredHomeDir(),
|
|
83
89
|
kiroHome: process.env['KIRO_HOME'],
|
|
84
90
|
};
|
|
85
91
|
const evidenceRoots = scope === 'project'
|
|
@@ -92,7 +98,7 @@ function defaultRuntimeAvailable(runtime, configRoot, scope) {
|
|
|
92
98
|
}
|
|
93
99
|
function displaySetupPath(path, configRoot, scope) {
|
|
94
100
|
if (scope === 'user') {
|
|
95
|
-
const home =
|
|
101
|
+
const home = configuredHomeDir();
|
|
96
102
|
const homePath = safeRelativePath(home, path);
|
|
97
103
|
if (homePath === '')
|
|
98
104
|
return '~';
|
|
@@ -495,7 +501,7 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
|
|
|
495
501
|
server,
|
|
496
502
|
scope,
|
|
497
503
|
dryRun: true,
|
|
498
|
-
homeDir:
|
|
504
|
+
homeDir: configuredHomeDir(),
|
|
499
505
|
kiroHome: process.env['KIRO_HOME'],
|
|
500
506
|
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
501
507
|
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
@@ -542,7 +548,7 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
|
|
|
542
548
|
r = uninstallInjection(runtime, {
|
|
543
549
|
configRoot,
|
|
544
550
|
scope,
|
|
545
|
-
homeDir:
|
|
551
|
+
homeDir: configuredHomeDir(),
|
|
546
552
|
kiroHome: process.env['KIRO_HOME'],
|
|
547
553
|
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
548
554
|
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
|
@@ -659,7 +665,7 @@ export async function runSetupHooks(argv, store, review, deps = {}) {
|
|
|
659
665
|
...(cursorGenes ? { genes: cursorGenes } : {}),
|
|
660
666
|
force: f['force'] === true,
|
|
661
667
|
dryRun: f['dry-run'] === true,
|
|
662
|
-
homeDir:
|
|
668
|
+
homeDir: configuredHomeDir(),
|
|
663
669
|
kiroHome: process.env['KIRO_HOME'],
|
|
664
670
|
xdgConfigHome: process.env['XDG_CONFIG_HOME'],
|
|
665
671
|
opencodeConfig: process.env['OPENCODE_CONFIG'],
|
package/dist/skill2gep.js
CHANGED
|
@@ -14,6 +14,19 @@ export const MAX_STRATEGY_STEPS = 28;
|
|
|
14
14
|
const SKILL2GEP_ID_PREFIX = 'gene_s2g_';
|
|
15
15
|
/** Default max-files constraint for a distilled gene (v1 skillDistiller.DISTILLED_MAX_FILES). */
|
|
16
16
|
const SKILL_MAX_FILES = 12;
|
|
17
|
+
const WORKFLOW_SECTION_KEYWORDS = [
|
|
18
|
+
'workflow', 'strategy', 'steps', 'procedure', 'quick start', 'how to',
|
|
19
|
+
'human gate', 'output contract', 'release', 'rollback', 'promotion',
|
|
20
|
+
'process each', 'request process', 'request path',
|
|
21
|
+
'工作流', '流程', '步骤', '核心方法', '方法', '快速规则', '规则',
|
|
22
|
+
'输出门', '输出门槛', '人工确认', '人工门', '回滚', '发布', '晋级',
|
|
23
|
+
];
|
|
24
|
+
// 安全与请求章节属于策略,而不是可选说明;丢失它们会让蒸馏后的 Skill 缺少审批和信任边界契约。
|
|
25
|
+
const GOVERNANCE_SECTION_KEYWORDS = [
|
|
26
|
+
'security', 'safety', 'credential', 'approval', 'adversarial',
|
|
27
|
+
'trust boundary', 'content isolation', 'untrusted content',
|
|
28
|
+
'protect x data', 'protect data', 'data protection', 'privacy', 'legal basis', 'consent',
|
|
29
|
+
];
|
|
17
30
|
function sectionHeadingMatches(heading, keyword) {
|
|
18
31
|
if (/^[a-z0-9 ]+$/i.test(keyword)) {
|
|
19
32
|
const forms = keyword === 'verify'
|
|
@@ -105,6 +118,49 @@ export function parseSkillMd(skillMd, opts = {}) {
|
|
|
105
118
|
}
|
|
106
119
|
return steps;
|
|
107
120
|
};
|
|
121
|
+
/** 将只有 prose 的安全章节中的声明式防护规则保留为有界策略语句。 */
|
|
122
|
+
const extractGovernanceStatements = (blocks) => {
|
|
123
|
+
const statements = [];
|
|
124
|
+
for (const block of blocks) {
|
|
125
|
+
let fenceMarker;
|
|
126
|
+
for (const rawLine of String(block || '').split(/\n/)) {
|
|
127
|
+
const line = rawLine.trim();
|
|
128
|
+
if (fenceMarker !== undefined) {
|
|
129
|
+
const closingFence = line.match(/^(`+|~+)$/);
|
|
130
|
+
if (closingFence !== null
|
|
131
|
+
&& closingFence[1][0] === fenceMarker.char
|
|
132
|
+
&& closingFence[1].length >= fenceMarker.length) {
|
|
133
|
+
fenceMarker = undefined;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const openingFence = line.match(/^(`{3,}|~{3,})(?:.*)?$/);
|
|
138
|
+
if (openingFence !== null) {
|
|
139
|
+
fenceMarker = { char: openingFence[1][0], length: openingFence[1].length };
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (!line || /^<\/?[A-Z0-9_-]+(?:>|\s)/.test(line))
|
|
143
|
+
continue;
|
|
144
|
+
const listItem = line.match(/^(?:\d+\.|[-*])\s+(.+?)\s*$/);
|
|
145
|
+
const statement = (listItem ? listItem[1] : line).replace(/^>\s?/, '').trim();
|
|
146
|
+
if (statement.length >= 5 && statement.length <= 300 && !statements.includes(statement)) {
|
|
147
|
+
statements.push(statement);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return statements;
|
|
152
|
+
};
|
|
153
|
+
const matchingGovernanceBlocks = sectionOccurrences
|
|
154
|
+
.filter(({ key }) => GOVERNANCE_SECTION_KEYWORDS.some((kw) => sectionHeadingMatches(key, kw)))
|
|
155
|
+
.map(({ lines: occurrenceLines }) => occurrenceLines.join('\n').trim());
|
|
156
|
+
const selectStrategySteps = (workflowSteps, governanceSteps) => {
|
|
157
|
+
const workflow = [...new Set(workflowSteps)];
|
|
158
|
+
const governance = [...new Set(governanceSteps)];
|
|
159
|
+
if (workflow.length + governance.length <= MAX_STRATEGY_STEPS)
|
|
160
|
+
return [...workflow, ...governance];
|
|
161
|
+
return [...governance.slice(0, MAX_STRATEGY_STEPS), ...workflow]
|
|
162
|
+
.slice(0, MAX_STRATEGY_STEPS);
|
|
163
|
+
};
|
|
108
164
|
// --- signals: frontmatter.description + the trigger/when section, tokenized to [a-z0-9_] (3..40, has-letter) ---
|
|
109
165
|
const signals = [];
|
|
110
166
|
const signalSource = (frontmatter['description'] || '') + '\n' + pickSection([
|
|
@@ -117,12 +173,7 @@ export function parseSkillMd(skillMd, opts = {}) {
|
|
|
117
173
|
signals.push(s);
|
|
118
174
|
});
|
|
119
175
|
// --- strategy: workflow + governance-tail sections; avoid: anti-pattern sections ---
|
|
120
|
-
const strategy = extractSteps(pickSectionsAll(
|
|
121
|
-
'workflow', 'strategy', 'steps', 'procedure', 'quick start', 'how to',
|
|
122
|
-
'human gate', 'output contract', 'release', 'rollback', 'promotion',
|
|
123
|
-
'工作流', '流程', '步骤', '核心方法', '方法', '快速规则', '规则',
|
|
124
|
-
'输出门', '输出门槛', '人工确认', '人工门', '回滚', '发布', '晋级',
|
|
125
|
-
]));
|
|
176
|
+
const strategy = selectStrategySteps(extractSteps(pickSectionsAll(WORKFLOW_SECTION_KEYWORDS)), extractGovernanceStatements(matchingGovernanceBlocks));
|
|
126
177
|
const avoid = extractSteps(pickSectionsAll([
|
|
127
178
|
'avoid', 'pitfall', 'anti-pattern', 'common mistake', 'do not', 'forbidden', "don't",
|
|
128
179
|
'不要做', '不要', '常见错误', '避免', '陷阱', '禁止',
|
|
@@ -300,7 +351,17 @@ export function synthesizeGene(parsed, execution = {}, opts = {}) {
|
|
|
300
351
|
strategy.push('Run the Skill validation commands and abort if any fails.');
|
|
301
352
|
}
|
|
302
353
|
const rawValidations = Array.isArray(parsed.validation) ? parsed.validation : [];
|
|
303
|
-
const
|
|
354
|
+
const normalizedValidations = rawValidations.map((v) => String(v || '').trim()).filter(Boolean);
|
|
355
|
+
const sanitizedValidations = normalizedValidations.map((command) => verify.sanitizeExecutionCommand(command));
|
|
356
|
+
if (sanitizedValidations.some((command) => command.changed || command.blocked)) {
|
|
357
|
+
return {
|
|
358
|
+
gene: null,
|
|
359
|
+
errors: ['execution_validation_unsafe: validation commands must not contain credential-bearing arguments'],
|
|
360
|
+
generation_meta: { source, quality_score: computeQualityScore(source, parsed, execution) },
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
const allowedValidations = sanitizedValidations.map((command) => command.value)
|
|
364
|
+
.filter((command) => isValidationCommandAllowed(command));
|
|
304
365
|
if (opts.strict && allowedValidations.length === 0) {
|
|
305
366
|
return {
|
|
306
367
|
gene: null,
|
|
@@ -432,7 +493,10 @@ export function assembleCapsule(gene, execution, opts = {}) {
|
|
|
432
493
|
})),
|
|
433
494
|
schema_version: '1.6.0',
|
|
434
495
|
};
|
|
435
|
-
|
|
496
|
+
const sanitized = verify.sanitizeExecutionPayload(capsule);
|
|
497
|
+
if (sanitized.blocked)
|
|
498
|
+
return { ok: false, reason: 'execution_trace_unsafe' };
|
|
499
|
+
return { ok: true, capsule: sanitized.value };
|
|
436
500
|
}
|
|
437
501
|
/**
|
|
438
502
|
* Reverse-distill a parsed SKILL.md + its execution into GEP assets — the PURE core of v1 runOnSkillInvocation
|
package/dist/valueDigest.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// tick the cadence check — this is the bus's first live built-in observer.
|
|
10
10
|
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import { dirname, join } from 'node:path';
|
|
12
|
-
import { events, observers, ops } from '@evomap/evolver-core';
|
|
12
|
+
import { assetstore, events, observers, ops } from '@evomap/evolver-core';
|
|
13
13
|
import { loadPriceTable } from '@evomap/evolver-adapter-public';
|
|
14
14
|
/** Markdown file sink: appends each weekly digest to <home>/evolution/value-digest.md (inspectable history). */
|
|
15
15
|
export function fileDigestSink(path) {
|
|
@@ -87,6 +87,13 @@ export function resolveValueDigestObserver(env = process.env, opts = {}) {
|
|
|
87
87
|
events: events.readEvents(eventsPath),
|
|
88
88
|
prices,
|
|
89
89
|
}, window),
|
|
90
|
+
digestExtras: async () => {
|
|
91
|
+
const store = new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
92
|
+
const review = assetstore.reviewLedgerForStore(store);
|
|
93
|
+
return {
|
|
94
|
+
pendingReviewCount: (await assetstore.pendingGeneReviewRecords(store, review)).length,
|
|
95
|
+
};
|
|
96
|
+
},
|
|
90
97
|
sink: multiSink(sinks),
|
|
91
98
|
state: new FileDigestState(join(home, 'evolution', 'value-digest-state.json')),
|
|
92
99
|
});
|