@evomap/evolver-cli 2.0.0-beta.1 → 2.0.0-beta.4

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 (73) hide show
  1. package/dist/antiGeneBenchmark.js +12 -0
  2. package/dist/antiGeneEvidence.d.ts +15 -0
  3. package/dist/antiGeneEvidence.js +49 -0
  4. package/dist/antiGeneRollout.d.ts +3 -1
  5. package/dist/antiGeneRollout.js +16 -2
  6. package/dist/assetHealth.d.ts +6 -0
  7. package/dist/assetHealth.js +105 -0
  8. package/dist/assetSidecarRecovery.d.ts +14 -0
  9. package/dist/assetSidecarRecovery.js +171 -0
  10. package/dist/assetTrust.d.ts +24 -0
  11. package/dist/assetTrust.js +218 -0
  12. package/dist/atp.js +4 -2
  13. package/dist/autoDistillLlm.js +4 -1
  14. package/dist/autoexec.d.ts +13 -3
  15. package/dist/autoexec.js +71 -13
  16. package/dist/cli.js +12 -5
  17. package/dist/cliContracts.js +8 -2
  18. package/dist/cliLifecycle.d.ts +7 -0
  19. package/dist/cliLifecycle.js +9 -0
  20. package/dist/cycleConsumer.d.ts +61 -1
  21. package/dist/cycleConsumer.js +551 -16
  22. package/dist/dashboard.d.ts +23 -0
  23. package/dist/dashboard.js +191 -0
  24. package/dist/dispatch.d.ts +10 -1
  25. package/dist/dispatch.js +36 -2
  26. package/dist/distillObserver.js +2 -2
  27. package/dist/distillPrimitives.d.ts +1 -1
  28. package/dist/distillPrimitives.js +29 -2
  29. package/dist/doctor.d.ts +2 -0
  30. package/dist/doctor.js +33 -3
  31. package/dist/index.d.ts +7 -2
  32. package/dist/index.js +292 -36
  33. package/dist/lifecycle.d.ts +19 -1
  34. package/dist/lifecycle.js +226 -29
  35. package/dist/localMemoryGraph.d.ts +97 -0
  36. package/dist/localMemoryGraph.js +889 -0
  37. package/dist/login.d.ts +20 -4
  38. package/dist/login.js +58 -8
  39. package/dist/materialPackage.d.ts +52 -0
  40. package/dist/materialPackage.js +404 -0
  41. package/dist/materialSnapshot.d.ts +30 -0
  42. package/dist/materialSnapshot.js +148 -0
  43. package/dist/memoryEventMirror.d.ts +23 -0
  44. package/dist/memoryEventMirror.js +140 -0
  45. package/dist/migrate/fieldMap.js +25 -0
  46. package/dist/migrate/v1Import.d.ts +7 -1
  47. package/dist/migrate/v1Import.js +132 -11
  48. package/dist/nonGitWorkspaceNotice.d.ts +24 -0
  49. package/dist/nonGitWorkspaceNotice.js +122 -0
  50. package/dist/proxyToken.d.ts +10 -0
  51. package/dist/proxyToken.js +80 -0
  52. package/dist/recipe.d.ts +10 -2
  53. package/dist/recipe.js +349 -7
  54. package/dist/reuseReport.js +16 -16
  55. package/dist/runtimeCapabilities.d.ts +18 -0
  56. package/dist/runtimeCapabilities.js +81 -0
  57. package/dist/runtimeSessionSource.d.ts +10 -0
  58. package/dist/runtimeSessionSource.js +32 -5
  59. package/dist/setupHooks.d.ts +6 -1
  60. package/dist/setupHooks.js +5 -2
  61. package/dist/skill2gep.d.ts +38 -9
  62. package/dist/skill2gep.js +147 -14
  63. package/dist/skillDistill.d.ts +1 -0
  64. package/dist/skillDistill.js +4 -4
  65. package/dist/skillFetch.d.ts +18 -0
  66. package/dist/skillFetch.js +391 -0
  67. package/dist/solo/mode.js +5 -0
  68. package/dist/sync.d.ts +26 -0
  69. package/dist/sync.js +988 -0
  70. package/dist/trajectoryExport.js +23 -12
  71. package/dist/v1Compat.d.ts +24 -0
  72. package/dist/v1Compat.js +249 -0
  73. package/package.json +12 -6
@@ -0,0 +1,218 @@
1
+ import { assetstore, events, hub } from '@evomap/evolver-core';
2
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
3
+ const GROUP = 'asset-trust';
4
+ const DEFAULT_LIMIT = 50;
5
+ const MAX_LIMIT = 200;
6
+ const MAX_REASON_INPUT = 1_000;
7
+ const MAX_REASON = 240;
8
+ const ASSET_ID_RE = /^sha256:[a-f0-9]{64}$/;
9
+ const ACTOR_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_.@:-]{0,79}$/;
10
+ const USAGE = [
11
+ 'Usage:',
12
+ ' evolver asset-trust list [--limit N] [--json]',
13
+ ' evolver asset-trust show <asset_id> [--json]',
14
+ ' evolver asset-trust promote <asset_id> --reason <text> [--json]',
15
+ ' evolver asset-trust revoke <asset_id> --reason <text> [--json]',
16
+ '',
17
+ ].join('\n');
18
+ function parseArgs(argv) {
19
+ const action = argv[0];
20
+ if (action !== 'list' && action !== 'show' && action !== 'promote' && action !== 'revoke')
21
+ return 'invalid_action';
22
+ let assetId;
23
+ let reason;
24
+ let limit = DEFAULT_LIMIT;
25
+ let json = false;
26
+ let index = 1;
27
+ if (action !== 'list') {
28
+ assetId = argv[index];
29
+ index += 1;
30
+ if (!assetId || !ASSET_ID_RE.test(assetId))
31
+ return 'invalid_asset_id';
32
+ }
33
+ while (index < argv.length) {
34
+ const arg = argv[index];
35
+ if (arg === '--json') {
36
+ json = true;
37
+ index += 1;
38
+ continue;
39
+ }
40
+ if (arg === '--reason' && (action === 'promote' || action === 'revoke')) {
41
+ const value = argv[index + 1];
42
+ if (!value || value.startsWith('--'))
43
+ return 'reason_required';
44
+ reason = value;
45
+ index += 2;
46
+ continue;
47
+ }
48
+ if (arg === '--limit' && action === 'list') {
49
+ const value = argv[index + 1];
50
+ if (!value || !/^\d+$/.test(value))
51
+ return 'invalid_limit';
52
+ limit = Math.min(MAX_LIMIT, Math.max(1, Number(value)));
53
+ index += 2;
54
+ continue;
55
+ }
56
+ return 'unknown_argument';
57
+ }
58
+ if ((action === 'promote' || action === 'revoke') && !reason)
59
+ return 'reason_required';
60
+ return { action, ...(assetId ? { assetId } : {}), ...(reason ? { reason } : {}), limit, json };
61
+ }
62
+ function safeActorId(env) {
63
+ const raw = env['EVOLVER_ACTOR_ID'] ?? env['USER'] ?? env['LOGNAME'] ?? env['USERNAME'] ?? 'cli';
64
+ const trimmed = raw.trim();
65
+ return ACTOR_ID_RE.test(trimmed) && hub.redactString(trimmed) === trimmed ? trimmed : 'cli';
66
+ }
67
+ function safeReason(raw, env) {
68
+ if (raw.length > MAX_REASON_INPUT)
69
+ return null;
70
+ const redacted = hub.redactString(raw).replace(/\s+/g, ' ').trim().slice(0, MAX_REASON);
71
+ if (!redacted || hub.fullLeakCheck(redacted, env).found)
72
+ return null;
73
+ return redacted;
74
+ }
75
+ function safeOutputText(value, env, max = MAX_REASON) {
76
+ if (!value)
77
+ return undefined;
78
+ const redacted = hub.redactString(value).replace(/\s+/g, ' ').trim().slice(0, max);
79
+ return redacted && !hub.fullLeakCheck(redacted, env).found ? redacted : '[redacted]';
80
+ }
81
+ function safeActorOutput(value) {
82
+ if (!value)
83
+ return undefined;
84
+ const trimmed = value.trim();
85
+ return ACTOR_ID_RE.test(trimmed) && hub.redactString(trimmed) === trimmed ? trimmed : '[redacted]';
86
+ }
87
+ function viewFor(asset, record, env) {
88
+ const logicalId = typeof asset['id'] === 'string' && asset['id'].trim() ? asset['id'].trim() : undefined;
89
+ const decidedBy = safeActorOutput(record?.decidedBy ?? record?.promotedBy);
90
+ const reason = safeOutputText(record?.reason, env);
91
+ return {
92
+ assetId: asset.asset_id,
93
+ type: asset.type,
94
+ ...(logicalId ? { logicalId: safeOutputText(logicalId, env, 120) } : {}),
95
+ source: record?.source ?? 'local_default',
96
+ trusted: record?.trusted ?? true,
97
+ ...(record?.at ? { at: record.at } : {}),
98
+ ...(record?.decision ? { decision: record.decision } : {}),
99
+ ...(decidedBy ? { decidedBy } : {}),
100
+ ...(reason ? { reason } : {}),
101
+ };
102
+ }
103
+ function storeBaseDir(store, deps) {
104
+ if (deps.assetsDir)
105
+ return deps.assetsDir;
106
+ return store instanceof assetstore.LocalJsonlProvider ? store.baseDir : events.assetsDir();
107
+ }
108
+ function writeJson(write, value) {
109
+ write(`${JSON.stringify(value)}\n`);
110
+ }
111
+ function parseFailure(reason, json, stdout, stderr) {
112
+ if (json)
113
+ writeJson(stdout, { ok: false, group: GROUP, reason });
114
+ else
115
+ stderr(`[asset-trust] ${reason}\n${USAGE}`);
116
+ return 2;
117
+ }
118
+ function renderView(view) {
119
+ return `${view.type} ${view.assetId} source=${view.source} trusted=${view.trusted}${view.logicalId ? ` id=${view.logicalId}` : ''}`;
120
+ }
121
+ async function recordTrustEvent(ingestor, action, view, reason, actorId) {
122
+ try {
123
+ await ingestor.ingest({
124
+ type: action === 'promote' ? 'actor.human.trust.promote' : 'actor.human.trust.revoke',
125
+ payload: { assetId: view.assetId, assetType: view.type, source: view.source, reason },
126
+ human: { title: `${action} ${view.type} ${view.assetId.slice(0, 19)}`, severity: 'notice' },
127
+ actor: { kind: 'human', id: actorId },
128
+ });
129
+ return true;
130
+ }
131
+ catch {
132
+ return false;
133
+ }
134
+ }
135
+ export async function runAssetTrustCommand(argv, deps = {}) {
136
+ const stdout = deps.stdout ?? ((text) => { process.stdout.write(text); });
137
+ const stderr = deps.stderr ?? ((text) => { process.stderr.write(text); });
138
+ if (argv.includes('--help') || argv.includes('-h')) {
139
+ stdout(USAGE);
140
+ return 0;
141
+ }
142
+ const json = argv.includes('--json');
143
+ const parsed = parseArgs(argv);
144
+ if (typeof parsed === 'string')
145
+ return parseFailure(parsed, json, stdout, stderr);
146
+ const env = deps.env ?? process.env;
147
+ const envFile = loadEnvFileFromEnv(env);
148
+ if (envFile.error)
149
+ return parseFailure('env_file_unavailable', parsed.json, stdout, stderr);
150
+ const store = deps.store ?? new assetstore.LocalJsonlProvider(deps.assetsDir ?? events.assetsDir());
151
+ const provenance = deps.provenance ?? new assetstore.ProvenanceStore(storeBaseDir(store, deps));
152
+ if (parsed.action === 'list') {
153
+ const snapshot = provenance.snapshot();
154
+ const allAssets = (await store.list(undefined, Number.MAX_SAFE_INTEGER))
155
+ .map((asset) => viewFor(asset, snapshot.get(asset.asset_id) ?? null, env))
156
+ .sort((left, right) => Number(left.trusted) - Number(right.trusted)
157
+ || left.assetId.localeCompare(right.assetId));
158
+ const assets = allAssets.slice(0, parsed.limit);
159
+ const counts = {
160
+ total: allAssets.length,
161
+ trusted: allAssets.filter((asset) => asset.trusted).length,
162
+ untrusted: allAssets.filter((asset) => !asset.trusted).length,
163
+ returned: assets.length,
164
+ };
165
+ const truncated = assets.length < allAssets.length;
166
+ const result = { ok: true, group: GROUP, mode: 'list', counts, truncated, assets };
167
+ if (parsed.json)
168
+ writeJson(stdout, result);
169
+ else {
170
+ stdout(`asset trust: total=${counts.total} trusted=${counts.trusted} untrusted=${counts.untrusted} returned=${counts.returned} truncated=${truncated}\n`);
171
+ for (const asset of assets)
172
+ stdout(`${renderView(asset)}\n`);
173
+ }
174
+ return 0;
175
+ }
176
+ const asset = await store.get(parsed.assetId);
177
+ if (!asset) {
178
+ if (parsed.json)
179
+ writeJson(stdout, { ok: false, group: GROUP, reason: 'asset_not_found' });
180
+ else
181
+ stderr('[asset-trust] asset_not_found\n');
182
+ return 1;
183
+ }
184
+ if (parsed.action === 'show') {
185
+ const result = { ok: true, group: GROUP, mode: 'show', asset: viewFor(asset, provenance.get(asset.asset_id), env) };
186
+ if (parsed.json)
187
+ writeJson(stdout, result);
188
+ else
189
+ stdout(`${renderView(result.asset)}\n`);
190
+ return 0;
191
+ }
192
+ const reason = safeReason(parsed.reason, env);
193
+ if (!reason)
194
+ return parseFailure('unsafe_reason', parsed.json, stdout, stderr);
195
+ const actorId = safeActorId(env);
196
+ const desiredTrust = parsed.action === 'promote';
197
+ const change = provenance.changeTrust(asset.asset_id, desiredTrust, actorId, reason);
198
+ const view = viewFor(asset, change.record, env);
199
+ const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
200
+ const auditEventRecorded = change.changed
201
+ ? await recordTrustEvent(ingestor, parsed.action, view, reason, actorId)
202
+ : false;
203
+ if (change.changed && !auditEventRecorded)
204
+ stderr('[asset-trust] trust decision saved; root event unavailable\n');
205
+ const result = {
206
+ ok: true,
207
+ group: GROUP,
208
+ mode: parsed.action,
209
+ changed: change.changed,
210
+ auditEventRecorded,
211
+ asset: view,
212
+ };
213
+ if (parsed.json)
214
+ writeJson(stdout, result);
215
+ else
216
+ stdout(`${change.changed ? 'updated' : 'unchanged'} ${renderView(view)}\n`);
217
+ return 0;
218
+ }
package/dist/atp.js CHANGED
@@ -2,7 +2,8 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from '
2
2
  import { homedir } from 'node:os';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { events, mailbox } from '@evomap/evolver-core';
5
- import { AtpHubClient, ATP_PROOF_STATUSES, ATP_ROLES, ATP_ROUTING_MODES, ATP_VERIFY_ACTIONS, ATP_VERIFY_MODES, connectPublicHub, globalFetchLike, } from '@evomap/evolver-adapter-public';
5
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
6
+ import { AtpHubClient, ATP_PROOF_STATUSES, ATP_ROLES, ATP_ROUTING_MODES, ATP_VERIFY_ACTIONS, ATP_VERIFY_MODES, connectPublicHub, globalFetchLike, resolveHubUrl, } from '@evomap/evolver-adapter-public';
6
7
  export function parseBuyArgs(args) {
7
8
  if (args.length === 0)
8
9
  return { ok: false, error: 'buy requires <capabilities>: comma-separated list (e.g. code_review,bug_fix)' };
@@ -226,7 +227,8 @@ export async function runAtpCommand(argv) {
226
227
  return (await runAtp(parsed.opts)).exitCode;
227
228
  }
228
229
  export function createAtpClientFromEnv(env = process.env) {
229
- const hubUrl = env['EVOMAP_HUB_URL'] ?? 'https://evomap.ai';
230
+ loadEnvFileFromEnv(env);
231
+ const hubUrl = resolveHubUrl(env);
230
232
  const evomapDir = resolveAtpHome(env);
231
233
  const resolvedSenderId = resolveAtpSenderId(env);
232
234
  const senderId = () => resolvedSenderId;
@@ -259,7 +259,7 @@ export function asGeneCandidate(value) {
259
259
  ...(isRecord(value['constraints']) ? {
260
260
  constraints: {
261
261
  ...(typeof value['constraints']['max_files'] === 'number' ? { max_files: value['constraints']['max_files'] } : {}),
262
- // Only carry a NON-EMPTY forbidden_paths through. intakeGene defaults the field with `?? DEFAULT`,
262
+ // Only carry a NON-EMPTY forbiddenPaths through. intakeGene defaults the field with `?? DEFAULT`,
263
263
  // and nullish-coalescing does NOT replace an empty array — so an LLM-supplied `[]` would drop the
264
264
  // default `.git`/`node_modules` guard on an autonomously-stored gene. Omit it so the default kicks in. (V1 parity.)
265
265
  ...(Array.isArray(value['constraints']['forbidden_paths']) && value['constraints']['forbidden_paths'].length > 0
@@ -267,6 +267,9 @@ export function asGeneCandidate(value) {
267
267
  },
268
268
  } : {}),
269
269
  ...(Array.isArray(value['validation']) ? { validation: value['validation'].map(String) } : {}),
270
+ // An LLM-distilled gene is distilled from prior capsule/session evidence (not a verified fail→pass trajectory,
271
+ // not a human-taught gene) → `distilled` per V1 #302 classifyProvenance. intakeGene normalizes + validates it.
272
+ generation_meta: { source: 'distilled' },
270
273
  };
271
274
  }
272
275
  export function jaccardDuplicate(candidate, existing, threshold = DEFAULT_DUP_JACCARD) {
@@ -1,8 +1,9 @@
1
- import { events, assetstore, algo, exec, hooks, material as materialNs, verify, hub as hubNs } from '@evomap/evolver-core';
1
+ import { events, assetstore, algo, exec, hooks, material as materialNs, util, verify, hub as hubNs } from '@evomap/evolver-core';
2
2
  import { type Beat } from './daemonLoop.js';
3
3
  import { connectPublicHub, ReuseCache } from '@evomap/evolver-adapter-public';
4
- import type { FetchLike, OfflinePermitStore, OutcomeReport, OutcomeReceipt } from '@evomap/evolver-adapter-public';
4
+ import type { FetchLike, MemoryGraphEventReceipt, MemoryGraphEventReport, OfflinePermitStore, OutcomeReport, OutcomeReceipt } from '@evomap/evolver-adapter-public';
5
5
  import { type EvolverProxyClient } from '@evomap/evolver-mcp';
6
+ import { type MemoryEventMirrorWiring } from './memoryEventMirror.js';
6
7
  import { resolveDistillObserver } from './distillObserver.js';
7
8
  import { type AutoDistillLlmResult, type LlmDistillRunner } from './autoDistillLlm.js';
8
9
  import { type AutoDistillAntiGeneMode, type AutoDistillAntiGeneResult } from './autoDistillAntiGene.js';
@@ -18,7 +19,7 @@ export interface AutoExecConfig {
18
19
  allowedRoots: string[];
19
20
  pollMs: number;
20
21
  timeoutMs: number;
21
- runner: 'claude' | 'codex' | 'cursor';
22
+ runner: 'claude' | 'codex' | 'cursor' | 'gemini';
22
23
  }
23
24
  /** Create the queue layout under <home>/autoexec/{tasks,done,refused}. */
24
25
  export declare function ensureAutoExecDirs(base: string): AutoExecDirs;
@@ -62,6 +63,7 @@ export declare function makeInjectEmitter(ingestor?: events.Ingestor): {
62
63
  /** A hub the link can report outcomes to. Structural (not the concrete class) so tests can fake it. */
63
64
  export type OutcomeReportingHub = hubNs.HubCapability & {
64
65
  recordOutcome(report: OutcomeReport): Promise<OutcomeReceipt>;
66
+ recordMemoryEvent?(report: MemoryGraphEventReport): Promise<MemoryGraphEventReceipt>;
65
67
  recordReuseResult?(report: hubNs.ReuseResultReport): Promise<hubNs.ReuseResultReceipt>;
66
68
  };
67
69
  /** The composed hub wiring: the reuse seam plus the matching outcome reporter that closes the loop. */
@@ -111,6 +113,13 @@ export declare function verdictToOutcomeStatus(status: exec.AutoExecVerdict['sta
111
113
  export declare function questionGeneratorStatePath(home?: string): string;
112
114
  export declare function makeHubQuestionLink(cap: hubNs.HubCapability, options?: HubQuestionLinkOptions): HubQuestionLink;
113
115
  export declare function shouldSubmitProactiveQuestionsForTask(task: exec.AutoExecTask): boolean;
116
+ export declare function autoexecLockFailureMessage(error: unknown): string;
117
+ export declare function autoexecLockReleaseFailureMessage(error: unknown): string;
118
+ export interface AutoexecLockReleaseDeps {
119
+ releaseLock?: (path: string) => util.ReleaseLockResult | void;
120
+ stderr?: (text: string) => void;
121
+ }
122
+ export declare function releaseAutoexecLock(lockPath: string, deps?: AutoexecLockReleaseDeps): boolean;
114
123
  export declare function urgentQuestionRuntimeWiringStatus(): typeof hubNs.URGENT_QUESTION_RUNTIME_WIRING_STATUS;
115
124
  export declare function submitDistillTickExplorationQuestion(questions: HubQuestionLink | undefined, source: DistillTickQuestionSource | undefined): Promise<HubQuestionSubmitResult>;
116
125
  export declare function scheduleAutoExecHubSideEffects(task: exec.AutoExecTask, verdict: exec.AutoExecVerdict, links: {
@@ -133,6 +142,7 @@ export declare function makeHubLink(cap: OutcomeReportingHub, ingestor?: events.
133
142
  */
134
143
  export declare function resolveHubLink(env?: NodeJS.ProcessEnv, ingestor?: events.Ingestor, connectHub?: PublicHubConnector): HubLink | undefined;
135
144
  export declare function resolveHubQuestionLink(env?: NodeJS.ProcessEnv, connectHub?: PublicHubConnector): HubQuestionLink | undefined;
145
+ export declare function resolveMemoryEventMirror(env?: NodeJS.ProcessEnv, connectHub?: PublicHubConnector): MemoryEventMirrorWiring;
136
146
  export declare function offlinePermitDir(env?: NodeJS.ProcessEnv): string;
137
147
  export declare function makeOfflineSolidifyPermitGate(permits: Pick<OfflinePermitStore, 'consumeOfflinePermit'>): algo.SolidifyPermitGate;
138
148
  export declare function resolveSolidifyPermitGate(env?: NodeJS.ProcessEnv, connectHub?: PublicHubPermitConnector, opts?: SolidifyPermitResolverOptions): algo.SolidifyPermitGate | undefined;
package/dist/autoexec.js CHANGED
@@ -7,16 +7,18 @@ import { readdirSync, readFileSync, writeFileSync, renameSync, mkdirSync, exists
7
7
  import { join, dirname } from 'node:path';
8
8
  import { events, assetstore, algo, exec, ops, observers, hooks, material as materialNs, util, verify, hub as hubNs, daemon as daemonNs, personality } from '@evomap/evolver-core';
9
9
  import { startResidentLoop } from './daemonLoop.js';
10
- import { connectPublicHub, createSolidifyPermitCheck, ReuseCache, reuseBeforeSolve } from '@evomap/evolver-adapter-public';
10
+ import { connectPublicHub, createSolidifyPermitCheck, ReuseCache, reuseBeforeSolve, resolveConfiguredHubUrl, resolveHubUrl } from '@evomap/evolver-adapter-public';
11
11
  import { loadEnvFileFromEnv, proxyClientFromEnv } from '@evomap/evolver-mcp';
12
12
  import { resolveValueDigestObserver } from './valueDigest.js';
13
13
  import { resolveReflectionObserver } from './reflectionObserver.js';
14
14
  import { resolveCursorRewriteObserver } from './cursorRewrite.js';
15
+ import { resolveMemoryEventMirrorObserver } from './memoryEventMirror.js';
15
16
  import { resolveDistillObserver } from './distillObserver.js';
16
17
  import { resolveAutoDistillLlm } from './autoDistillLlm.js';
17
18
  import { resolveAutoDistillAntiGene as resolveAntiGeneDistill } from './autoDistillAntiGene.js';
18
19
  import { runTranscriptDistillTick, transcriptDistillMode } from './autoDistillTranscript.js';
19
20
  import { runSessionIngestTick, scanSessionDirs } from './index.js';
21
+ import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
20
22
  import { resolveAtpAutoDeliver } from './atpAutoDeliver.js';
21
23
  import { resolveAtpHome, resolveAtpSenderId } from './atp.js';
22
24
  import { runAutobuyPrompt } from './atpAutobuyPrompt.js';
@@ -39,8 +41,10 @@ export function readAutoExecConfig(base) {
39
41
  try {
40
42
  const c = JSON.parse(readFileSync(p, 'utf8'));
41
43
  // Coerce runner to the known set — an unknown value falls back to claude rather than reaching the registry.
42
- // cursor is a scaffold runner (#66, unverified flags); selectable here but its safe default keeps skip OFF.
43
- const runner = c.runner === 'codex' ? 'codex' : c.runner === 'cursor' ? 'cursor' : 'claude';
44
+ // Cursor and Gemini remain experimental; both are selectable only through their bounded registry defaults.
45
+ const runner = c.runner === 'codex' || c.runner === 'cursor' || c.runner === 'gemini'
46
+ ? c.runner
47
+ : 'claude';
44
48
  return { ...def, ...c, allowedRoots: Array.isArray(c.allowedRoots) ? c.allowedRoots : [], runner };
45
49
  }
46
50
  catch {
@@ -325,6 +329,40 @@ export function makeHubQuestionLink(cap, options = {}) {
325
329
  export function shouldSubmitProactiveQuestionsForTask(task) {
326
330
  return typeof task.publicQuestionContext === 'string' && task.publicQuestionContext.trim().length > 0;
327
331
  }
332
+ export function autoexecLockFailureMessage(error) {
333
+ if (error instanceof util.UnsafeLockPathError) {
334
+ return `evolver autoexec: unsafe single-instance lock (${error.reason}) - inspect the Evolver state directory before retrying\n`;
335
+ }
336
+ if (error instanceof util.LockTimeoutError) {
337
+ return 'evolver autoexec: another daemon holds the single-instance lock - refusing to start a second instance\n';
338
+ }
339
+ return 'evolver autoexec: failed to acquire the single-instance lock - refusing to start\n';
340
+ }
341
+ export function autoexecLockReleaseFailureMessage(error) {
342
+ const reason = error instanceof util.UnsafeLockPathError
343
+ ? error.reason
344
+ : typeof error === 'object' && error !== null && typeof error.reason === 'string'
345
+ ? error.reason
346
+ : null;
347
+ if (reason) {
348
+ return `evolver autoexec: could not safely release the single-instance lock (${reason}); inspect the Evolver state directory if the next start is blocked\n`;
349
+ }
350
+ return 'evolver autoexec: could not release the single-instance lock; inspect the Evolver state directory if the next start is blocked\n';
351
+ }
352
+ export function releaseAutoexecLock(lockPath, deps = {}) {
353
+ try {
354
+ const result = (deps.releaseLock ?? util.releaseLock)(lockPath);
355
+ if (result && !result.released) {
356
+ (deps.stderr ?? ((text) => { process.stderr.write(text); }))(autoexecLockReleaseFailureMessage(result));
357
+ return false;
358
+ }
359
+ return true;
360
+ }
361
+ catch (error) {
362
+ (deps.stderr ?? ((text) => { process.stderr.write(text); }))(autoexecLockReleaseFailureMessage(error));
363
+ return false;
364
+ }
365
+ }
328
366
  export function urgentQuestionRuntimeWiringStatus() {
329
367
  return hubNs.URGENT_QUESTION_RUNTIME_WIRING_STATUS;
330
368
  }
@@ -433,7 +471,7 @@ function resolvePublicHub(env = process.env, connectHub = connectPublicHub) {
433
471
  if (!existsSync(join(dir, 'token.json')))
434
472
  return undefined;
435
473
  try {
436
- const hubUrl = env['EVOMAP_HUB_URL'] ?? 'https://evomap.ai';
474
+ const hubUrl = resolveHubUrl(env);
437
475
  const resolvedSenderId = resolveAtpSenderId(env);
438
476
  if (!resolvedSenderId)
439
477
  return undefined;
@@ -444,6 +482,9 @@ function resolvePublicHub(env = process.env, connectHub = connectPublicHub) {
444
482
  return undefined;
445
483
  }
446
484
  }
485
+ function hubMode(env) {
486
+ return String(env['EVOMAP_HUB_MODE'] ?? 'public').trim().toLowerCase();
487
+ }
447
488
  /**
448
489
  * Resolve the hub link (reuse seam + outcome reporter) from the environment, or undefined when reuse is
449
490
  * not enabled/credentialed. Default OFF: requires EVOLVER_REUSE_BEFORE_SOLVE === '1' and an OAuth token at
@@ -457,7 +498,7 @@ export function resolveHubLink(env = process.env, ingestor, connectHub = connect
457
498
  process.stderr.write(`[evolver-autoexec] failed to load EVOLVER_ENV_FILE: ${envFile.error}\n`);
458
499
  if (env['EVOLVER_REUSE_BEFORE_SOLVE'] !== '1')
459
500
  return undefined;
460
- if (String(env['EVOMAP_HUB_MODE'] ?? 'public').toLowerCase() === 'private') {
501
+ if (hubMode(env) === 'private') {
461
502
  const proxy = proxyClientFromEnv(env);
462
503
  return proxy ? makeHubLink(makeProxyHubCapability(proxy), ingestor, env['EVOLVER_OUTCOME_REPORT'] !== '0') : undefined;
463
504
  }
@@ -478,6 +519,15 @@ export function resolveHubQuestionLink(env = process.env, connectHub = connectPu
478
519
  return undefined;
479
520
  return makeHubQuestionLink(hub, { env });
480
521
  }
522
+ export function resolveMemoryEventMirror(env = process.env, connectHub = connectPublicHub) {
523
+ if (hubMode(env) === 'private') {
524
+ return { enabled: false, reason: 'no_hub', observer: null };
525
+ }
526
+ const disabled = resolveMemoryEventMirrorObserver(env, null);
527
+ if (disabled.reason === 'disabled')
528
+ return disabled;
529
+ return resolveMemoryEventMirrorObserver(env, resolvePublicHub(env, connectHub));
530
+ }
481
531
  function solidifyVerifyFlag(env) {
482
532
  const raw = env[SOLIDIFY_VERIFY_ENV]?.trim().toLowerCase();
483
533
  if (raw === '0' || raw === 'false' || raw === 'off')
@@ -505,7 +555,7 @@ export function resolveSolidifyPermitGate(env = process.env, connectHub = connec
505
555
  const flag = solidifyVerifyFlag(env);
506
556
  if (flag === 'off')
507
557
  return undefined;
508
- const hubUrl = (env['EVOMAP_HUB_URL'] ?? env['A2A_HUB_URL'] ?? '').replace(/\/+$/, '');
558
+ const hubUrl = resolveConfiguredHubUrl(env) ?? (flag === 'on' ? resolveHubUrl(env) : undefined);
509
559
  if (!hubUrl) {
510
560
  if (flag === 'on')
511
561
  return () => ({ ok: false, reason: 'hub_solidify_verify_unavailable:no_hub_url' });
@@ -640,6 +690,8 @@ export function defaultSessionDirs(env = process.env) {
640
690
  join(h, '.cursor'),
641
691
  join(h, '.codex'),
642
692
  join(h, '.gemini', 'tmp'),
693
+ join(h, '.gemini', 'antigravity'),
694
+ join(h, '.gemini', 'antigravity-ide'),
643
695
  join(h, '.kimi'),
644
696
  join(h, 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage'),
645
697
  join(h, 'AppData', 'Roaming', 'Cursor', 'User', 'globalStorage'),
@@ -786,6 +838,9 @@ export async function runAutoExec(argv) {
786
838
  process.stdout.write(line + '\n');
787
839
  }
788
840
  const store = new assetstore.LocalJsonlProvider(events.assetsDir());
841
+ const memoryGraphDir = join(events.evomapHome(), 'evolution');
842
+ const memoryUser = resolveLocalMemoryUserIdentity(memoryGraphDir);
843
+ const memoryGraph = new LocalMemoryGraph({ dir: memoryGraphDir, ...memoryUser });
789
844
  // Observer bus (#113): the event total-bus, finally given its FIRST built-in observer. The value-digest
790
845
  // observer is hung off the bus and the bus is wired as the Ingestor's sink, so every emitted event fans out to
791
846
  // it; its weekly cadence + measured-value gate keep it quiet. Off via EVOLVER_VALUE_DIGEST=0. Fault-isolated:
@@ -813,6 +868,9 @@ export async function runAutoExec(argv) {
813
868
  const reflection = resolveReflectionObserver(process.env, { ingestor });
814
869
  if (reflection.observer)
815
870
  bus.register(reflection.observer);
871
+ const memoryEventMirror = resolveMemoryEventMirror(process.env);
872
+ if (memoryEventMirror.observer)
873
+ bus.register(memoryEventMirror.observer);
816
874
  const personalityStore = createAutoExecPersonalityStore();
817
875
  const engine = new algo.CycleEngine({ ingestor, selection: algo.makeGeneSelectionPoint(), store, now: () => Date.now(), personality: personalityStore });
818
876
  // Reuse-before-solve (#110) + outcome report-back: wire the adapter's reuseBeforeSolve as the hub-reuse
@@ -829,7 +887,7 @@ export async function runAutoExec(argv) {
829
887
  let warnedNoIsolation = false;
830
888
  const probationOn = geneProbationEnabled();
831
889
  const deps = {
832
- engine, store, provenance, review, personality: personalityStore,
890
+ engine, store, provenance, review, personality: personalityStore, memoryGraph,
833
891
  // Probation (#306, gated, default OFF via EVOLVER_GENE_PROBATION): try unproven auto-distilled genes (with their
834
892
  // strategy embedded) so the cross-AI loop self-closes — contained by the proven exec gates + worktree isolation.
835
893
  ...(probationOn ? { includeProbation: true } : {}),
@@ -884,7 +942,7 @@ export async function runAutoExec(argv) {
884
942
  const antiGeneDistill = resolveAutoDistillAntiGene(process.env, { store, review, ingestor });
885
943
  const transcriptDistill = resolveAutoDistillTranscript(process.env, { store, review, ingestor });
886
944
  const atpAutoDeliver = resolveAtpAutoDeliver(process.env);
887
- process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${hubLink ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`}\n`);
945
+ process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${hubLink ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} memory-event-mirror=${memoryEventMirror.enabled ? 'on' : `off(${memoryEventMirror.reason ?? 'no_hub'})`} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`}\n`);
888
946
  if (cfg.allowedRoots.length === 0)
889
947
  process.stdout.write(' (allowlist empty → deny-by-default: nothing runs until you add a repo to config.json)\n');
890
948
  // Single-instance lock (#106): a second daemon on the same home would double-process the queue. That is harmless
@@ -898,8 +956,8 @@ export async function runAutoExec(argv) {
898
956
  try {
899
957
  util.acquireLock(lockPath, { maxTries: 5 });
900
958
  }
901
- catch {
902
- process.stderr.write(`evolver autoexec: another daemon holds ${lockPath} — refusing to start a second instance\n`);
959
+ catch (error) {
960
+ process.stderr.write(autoexecLockFailureMessage(error));
903
961
  return 1;
904
962
  }
905
963
  // First-run auto-buyer opt-in (PORT v1 #10): introduce the autonomous spend path to interactive operators once,
@@ -914,7 +972,7 @@ export async function runAutoExec(argv) {
914
972
  process.stderr.write(`[ATP-AutoBuyer] first-run prompt failed: ${e instanceof Error ? e.message : String(e)}\n`);
915
973
  }
916
974
  const uninstallUnhandledRejectionGuard = daemonNs.installUnhandledRejectionWindow({
917
- beforeExit: () => { util.releaseLock(lockPath); },
975
+ beforeExit: () => { releaseAutoexecLock(lockPath); },
918
976
  });
919
977
  // SINGLE-FLIGHT the producer tick (same as autoExecPass): a session scan that outlasts pollMs must not let two
920
978
  // ticks interleave in recordSessionMaterial (which would re-emit material.batch_ready before watermarks settle).
@@ -998,7 +1056,7 @@ export async function runAutoExec(argv) {
998
1056
  process.stderr.write(`[Solo] 连续失败 ${soloState.consecutiveFailures} 次达阈值,熔断停机(非盲重生)。\n`);
999
1057
  // Stop scheduling, release the lock, and exit non-zero. Detached so we
1000
1058
  // don't await our own loop.stop() from inside a tick.
1001
- void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); util.releaseLock(lockPath); process.exit(1); });
1059
+ void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); releaseAutoexecLock(lockPath); process.exit(1); });
1002
1060
  }
1003
1061
  };
1004
1062
  // Heartbeat (#106): record liveness + pacing on the AE spine for the WebUI console, THROTTLED so a fast poll does
@@ -1033,7 +1091,7 @@ export async function runAutoExec(argv) {
1033
1091
  return;
1034
1092
  stopping = true;
1035
1093
  process.stdout.write(`\nevolver autoexec: ${sig} → graceful stop (finishing in-flight, releasing lock)\n`);
1036
- void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); util.releaseLock(lockPath); resolve(0); });
1094
+ void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); releaseAutoexecLock(lockPath); resolve(0); });
1037
1095
  };
1038
1096
  process.once('SIGINT', () => shutdown('SIGINT'));
1039
1097
  process.once('SIGTERM', () => shutdown('SIGTERM'));
package/dist/cli.js CHANGED
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { dispatch } from './dispatch.js';
2
+ import { settleCliProcess } from './cliLifecycle.js';
3
3
  const argv = process.argv.slice(2);
4
- const fail = (e) => { process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`); process.exit(1); };
5
- // Single dispatch path (registry in dispatch.ts): async handler if the verb is registered, else the runCli core.
6
- // Promise.resolve normalizes the sync (runCli → number) and async (handler → Promise<number>) branches to one exit.
7
- Promise.resolve(dispatch(argv)).then((code) => process.exit(code)).catch(fail);
4
+ async function main() {
5
+ if (argv[0] === 'proxy-token') {
6
+ const { runProxyToken } = await import('./proxyToken.js');
7
+ return runProxyToken(argv.slice(1));
8
+ }
9
+ const { dispatch } = await import('./dispatch.js');
10
+ // Single dispatch path (registry in dispatch.ts): async handler if the verb is registered, else the runCli core.
11
+ // Promise.resolve normalizes the sync (runCli → number) and async (handler → Promise<number>) branches to one exit.
12
+ return await Promise.resolve(dispatch(argv));
13
+ }
14
+ void settleCliProcess(main);
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, statSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { inspect, format } from 'node:util';
4
4
  import { assetstore, events, hub, wire } from '@evomap/evolver-core';
5
- import { AuthError, HubClientError, HubFetch, HubUnreachableError, connectPublicHub, gepEnvelope, globalFetchLike, } from '@evomap/evolver-adapter-public';
5
+ import { AuthError, HubClientError, HubFetch, HubUnreachableError, connectPublicHub, gepEnvelope, globalFetchLike, resolveHubUrl, } from '@evomap/evolver-adapter-public';
6
6
  import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
7
7
  import { resolveAtpHome, resolveAtpSenderId } from './atp.js';
8
8
  const REUSE_CONTRACT = 'reuse.v1';
@@ -570,7 +570,7 @@ async function withMachineJsonConsole(enabled, deps, fn) {
570
570
  function createDefaultTransport(deps) {
571
571
  const env = deps.env ?? process.env;
572
572
  loadEnvFileFromEnv(env);
573
- const hubUrl = env['EVOMAP_HUB_URL'] ?? 'https://evomap.ai';
573
+ const hubUrl = resolveHubUrl(env);
574
574
  const evomapDir = resolveAtpHome(env);
575
575
  const sender = resolveAtpSenderId(env);
576
576
  const senderId = () => sender ?? env['A2A_NODE_ID']?.trim();
@@ -591,6 +591,8 @@ function createDefaultTransport(deps) {
591
591
  catch (err) {
592
592
  if (err instanceof AuthError)
593
593
  return { ok: false, status: err.status };
594
+ if (isAuthLikeError(err))
595
+ return { ok: false, status: 401 };
594
596
  if (err instanceof HubClientError)
595
597
  return { ok: false, status: err.status, body: err.body };
596
598
  return { ok: false, status: 0 };
@@ -602,6 +604,10 @@ function createDefaultTransport(deps) {
602
604
  publish: (bundle) => call('/a2a/publish', 'publish', bundle),
603
605
  };
604
606
  }
607
+ function isAuthLikeError(err) {
608
+ const message = err instanceof Error ? err.message : String(err);
609
+ return /oauth|login|credential|auth|401|403|node_secret/i.test(message);
610
+ }
605
611
  function classifyError(err, command) {
606
612
  if (err instanceof ContractError)
607
613
  return { reason: err.reason, message: err.safeMessage, retryable: err.reason === 'network_error' };
@@ -0,0 +1,7 @@
1
+ export interface CliProcessLike {
2
+ exitCode?: string | number | null;
3
+ stderr: {
4
+ write(chunk: string): unknown;
5
+ };
6
+ }
7
+ export declare function settleCliProcess(run: () => Promise<number>, proc?: CliProcessLike): Promise<void>;
@@ -0,0 +1,9 @@
1
+ export async function settleCliProcess(run, proc = process) {
2
+ try {
3
+ proc.exitCode = await run();
4
+ }
5
+ catch (error) {
6
+ proc.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
7
+ proc.exitCode = 1;
8
+ }
9
+ }