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

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 (86) 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 +107 -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.d.ts +6 -0
  14. package/dist/autoDistillLlm.js +44 -7
  15. package/dist/autoexec.d.ts +14 -12
  16. package/dist/autoexec.js +84 -34
  17. package/dist/autoexecConfig.d.ts +10 -0
  18. package/dist/autoexecConfig.js +68 -0
  19. package/dist/cli.js +12 -5
  20. package/dist/cliContracts.js +30 -3
  21. package/dist/cliLifecycle.d.ts +7 -0
  22. package/dist/cliLifecycle.js +9 -0
  23. package/dist/cycleConsumer.d.ts +61 -1
  24. package/dist/cycleConsumer.js +551 -16
  25. package/dist/dashboard.d.ts +33 -0
  26. package/dist/dashboard.js +352 -0
  27. package/dist/dispatch.d.ts +10 -1
  28. package/dist/dispatch.js +40 -2
  29. package/dist/distillAdmission.d.ts +13 -0
  30. package/dist/distillAdmission.js +35 -0
  31. package/dist/distillObserver.js +6 -8
  32. package/dist/distillPrimitives.d.ts +9 -7
  33. package/dist/distillPrimitives.js +65 -12
  34. package/dist/doctor.d.ts +2 -0
  35. package/dist/doctor.js +49 -3
  36. package/dist/index.d.ts +8 -2
  37. package/dist/index.js +350 -42
  38. package/dist/issueReport.d.ts +7 -0
  39. package/dist/issueReport.js +291 -0
  40. package/dist/lifecycle.d.ts +22 -1
  41. package/dist/lifecycle.js +226 -29
  42. package/dist/localMemoryGraph.d.ts +97 -0
  43. package/dist/localMemoryGraph.js +889 -0
  44. package/dist/login.d.ts +20 -4
  45. package/dist/login.js +58 -8
  46. package/dist/materialPackage.d.ts +52 -0
  47. package/dist/materialPackage.js +401 -0
  48. package/dist/materialSnapshot.d.ts +54 -0
  49. package/dist/materialSnapshot.js +370 -0
  50. package/dist/memoryEventMirror.d.ts +23 -0
  51. package/dist/memoryEventMirror.js +140 -0
  52. package/dist/migrate/fieldMap.js +25 -0
  53. package/dist/migrate/v1Import.d.ts +7 -1
  54. package/dist/migrate/v1Import.js +132 -11
  55. package/dist/nonGitWorkspaceNotice.d.ts +24 -0
  56. package/dist/nonGitWorkspaceNotice.js +122 -0
  57. package/dist/proxyToken.d.ts +10 -0
  58. package/dist/proxyToken.js +80 -0
  59. package/dist/recipe.d.ts +12 -2
  60. package/dist/recipe.js +381 -8
  61. package/dist/reuse.d.ts +5 -3
  62. package/dist/reuse.js +126 -15
  63. package/dist/reuseReport.js +16 -16
  64. package/dist/runtimeCapabilities.d.ts +18 -0
  65. package/dist/runtimeCapabilities.js +81 -0
  66. package/dist/runtimeSessionSource.d.ts +10 -0
  67. package/dist/runtimeSessionSource.js +32 -5
  68. package/dist/setupHooks.d.ts +11 -1
  69. package/dist/setupHooks.js +235 -16
  70. package/dist/skill2gep.d.ts +38 -9
  71. package/dist/skill2gep.js +147 -14
  72. package/dist/skillDistill.d.ts +1 -0
  73. package/dist/skillDistill.js +4 -4
  74. package/dist/skillFetch.d.ts +18 -0
  75. package/dist/skillFetch.js +391 -0
  76. package/dist/solo/mode.js +5 -0
  77. package/dist/sync.d.ts +38 -0
  78. package/dist/sync.js +1981 -0
  79. package/dist/trajectoryExport.js +23 -12
  80. package/dist/v1Compat.d.ts +24 -0
  81. package/dist/v1Compat.js +249 -0
  82. package/dist/workflow.d.ts +39 -0
  83. package/dist/workflow.js +386 -0
  84. package/dist/workflowRuntime.d.ts +66 -0
  85. package/dist/workflowRuntime.js +631 -0
  86. package/package.json +12 -6
@@ -0,0 +1,33 @@
1
+ import { type WorkflowProvider } from '@evomap/evolver-webui';
2
+ import { type MemoryGraphOperatorStatus } from './localMemoryGraph.js';
3
+ export interface DashboardServer {
4
+ readonly token: string;
5
+ readonly launchTicket: string;
6
+ listen(port?: number): Promise<number>;
7
+ close(): Promise<void>;
8
+ }
9
+ export type DashboardEnv = Readonly<Record<string, string | undefined>>;
10
+ export interface DashboardDeps {
11
+ createServer?: (memoryGraphStatus: () => MemoryGraphOperatorStatus, env: DashboardEnv) => DashboardServer;
12
+ env?: DashboardEnv;
13
+ openUrl?: (url: string) => Promise<boolean>;
14
+ waitForShutdown?: () => Promise<void>;
15
+ stdout?: (text: string) => void;
16
+ stderr?: (text: string) => void;
17
+ memoryGraphStatus?: () => MemoryGraphOperatorStatus;
18
+ }
19
+ export interface DashboardCommandOptions {
20
+ eaddrinusePortAttempts?: number;
21
+ }
22
+ export interface WorkflowStateReader {
23
+ listRunIds(): string[];
24
+ read(runId: string): unknown;
25
+ }
26
+ export declare function createWorkflowDashboardProvider(store: WorkflowStateReader): WorkflowProvider;
27
+ export declare function createDashboardWorkflowProvider(env?: DashboardEnv, defaultStateDir?: () => string): WorkflowProvider;
28
+ export declare function createDashboardServer(memoryGraphStatus: () => MemoryGraphOperatorStatus, env?: DashboardEnv): DashboardServer;
29
+ export declare function dashboardOpenCommand(url: string, platform?: NodeJS.Platform): {
30
+ command: string;
31
+ args: string[];
32
+ };
33
+ export declare function runDashboardCommand(argv: readonly string[], deps?: DashboardDeps, options?: DashboardCommandOptions): Promise<number>;
@@ -0,0 +1,352 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { assetstore, events, ops, personality, workflow } from '@evomap/evolver-core';
3
+ import { loadPriceTable } from '@evomap/evolver-adapter-public';
4
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
5
+ import { createGithubPrDiagnosticsProvider, readLogDiagnostics, readPersonalityDiagnostics, WebUIServer, } from '@evomap/evolver-webui';
6
+ import { lifecyclePaths } from './lifecycle.js';
7
+ import { formatMemoryGraphOperatorStatus, loadMemoryGraphOperatorStatus } from './localMemoryGraph.js';
8
+ const USAGE = 'usage: evolver dashboard [--port N] [--no-open]\n';
9
+ class DashboardEnvFileUnavailableError extends Error {
10
+ constructor() {
11
+ super('dashboard_env_file_unavailable');
12
+ this.name = 'DashboardEnvFileUnavailableError';
13
+ }
14
+ }
15
+ function resolveDashboardEnv(env) {
16
+ const resolvedEnv = { ...env };
17
+ const envFile = loadEnvFileFromEnv(resolvedEnv);
18
+ if (envFile.error)
19
+ throw new DashboardEnvFileUnavailableError();
20
+ return resolvedEnv;
21
+ }
22
+ function dashboardStartupError(error) {
23
+ return error instanceof DashboardEnvFileUnavailableError
24
+ ? 'dashboard_env_file_unavailable'
25
+ : 'dashboard_start_failed';
26
+ }
27
+ function record(value) {
28
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
29
+ }
30
+ function stringField(value) {
31
+ return typeof value === 'string' ? value : null;
32
+ }
33
+ function runSummary(value) {
34
+ const state = record(value);
35
+ if (!state)
36
+ return null;
37
+ const runId = stringField(state['runId']);
38
+ const workflowId = stringField(state['workflowId']);
39
+ const status = stringField(state['status']);
40
+ const createdAt = stringField(state['createdAt']);
41
+ const updatedAt = stringField(state['updatedAt']);
42
+ if (!runId || !workflowId || !status || !createdAt || !updatedAt)
43
+ return null;
44
+ const currentKey = stringField(state['currentStep']);
45
+ const steps = record(state['steps']);
46
+ const currentState = currentKey && steps ? record(steps[currentKey]) : null;
47
+ const currentStep = currentState && currentState['status'] !== 'succeeded'
48
+ ? stringField(currentState['executionId']) ?? stringField(currentState['stepId']) ?? currentKey
49
+ : currentState ? null : currentKey;
50
+ return {
51
+ runId,
52
+ workflowId,
53
+ status,
54
+ currentStep,
55
+ createdAt,
56
+ updatedAt,
57
+ completedAt: stringField(state['completedAt']),
58
+ };
59
+ }
60
+ function historyRows(value) {
61
+ if (Array.isArray(value))
62
+ return value;
63
+ const envelope = record(value);
64
+ if (!envelope)
65
+ return [];
66
+ if (Array.isArray(envelope['history']))
67
+ return envelope['history'];
68
+ if (Array.isArray(envelope['entries']))
69
+ return envelope['entries'];
70
+ return [];
71
+ }
72
+ function historyEntry(value, index) {
73
+ const entry = record(value);
74
+ if (!entry)
75
+ return null;
76
+ const actor = record(entry['actor']);
77
+ const timestamp = stringField(entry['timestamp'])
78
+ ?? stringField(entry['createdAt'])
79
+ ?? stringField(entry['at'])
80
+ ?? stringField(entry['ts']);
81
+ const type = stringField(entry['type'])
82
+ ?? stringField(entry['event'])
83
+ ?? stringField(entry['operation'])
84
+ ?? stringField(entry['kind']);
85
+ if (!timestamp || !type)
86
+ return null;
87
+ const rawSequence = entry['sequence'] ?? entry['seq'];
88
+ const sequence = typeof rawSequence === 'number' && Number.isSafeInteger(rawSequence) && rawSequence >= 0
89
+ ? rawSequence
90
+ : index;
91
+ const status = stringField(entry['status']);
92
+ const stepId = stringField(entry['stepId']);
93
+ const executionId = stringField(entry['executionId']);
94
+ const gateId = stringField(entry['gateId']);
95
+ const attempt = typeof entry['attempt'] === 'number' && Number.isSafeInteger(entry['attempt']) && entry['attempt'] >= 0
96
+ ? entry['attempt']
97
+ : null;
98
+ const actorId = stringField(entry['actorId']) ?? stringField(entry['actor']) ?? stringField(actor?.['id']);
99
+ const errorClass = stringField(entry['errorClass']);
100
+ return {
101
+ sequence,
102
+ timestamp,
103
+ type,
104
+ ...(status ? { status } : {}),
105
+ ...(stepId ? { stepId } : {}),
106
+ ...(executionId ? { executionId } : {}),
107
+ ...(gateId ? { gateId } : {}),
108
+ ...(attempt !== null ? { attempt } : {}),
109
+ ...(actorId ? { actorId } : {}),
110
+ ...(errorClass ? { errorClass } : {}),
111
+ };
112
+ }
113
+ function readDurableHistory(store, runId, state) {
114
+ const candidate = store;
115
+ const reader = candidate.readHistory ?? candidate.listHistory ?? candidate.history;
116
+ if (reader)
117
+ return historyRows(reader.call(store, runId));
118
+ return historyRows(record(state)?.['history']);
119
+ }
120
+ export function createWorkflowDashboardProvider(store) {
121
+ const read = (runId) => {
122
+ try {
123
+ return store.read(runId);
124
+ }
125
+ catch (error) {
126
+ if (error instanceof workflow.WorkflowStateError && error.code === 'STATE_NOT_FOUND')
127
+ return null;
128
+ throw error;
129
+ }
130
+ };
131
+ return {
132
+ listRuns: () => store.listRunIds()
133
+ .map((runId) => runSummary(read(runId)))
134
+ .filter((run) => run !== null)
135
+ .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.runId.localeCompare(b.runId)),
136
+ getRun: (runId) => runSummary(read(runId)),
137
+ getHistory: (runId) => {
138
+ const state = read(runId);
139
+ if (state === null)
140
+ return null;
141
+ return readDurableHistory(store, runId, state)
142
+ .map(historyEntry)
143
+ .filter((entry) => entry !== null);
144
+ },
145
+ };
146
+ }
147
+ export function createDashboardWorkflowProvider(env = process.env, defaultStateDir = workflow.defaultWorkflowStateDir) {
148
+ const resolvedEnv = resolveDashboardEnv(env);
149
+ const configuredStateDir = resolvedEnv['EVOLVER_WORKFLOW_STATE_DIR']?.trim();
150
+ const stateDir = configuredStateDir || defaultStateDir();
151
+ return createWorkflowDashboardProvider(new workflow.WorkflowStateStore(stateDir));
152
+ }
153
+ function parsePort(raw) {
154
+ if (!/^\d+$/.test(raw))
155
+ return null;
156
+ const port = Number(raw);
157
+ return Number.isSafeInteger(port) && port >= 0 && port <= 65_535 ? port : null;
158
+ }
159
+ function parseDashboardOptions(argv) {
160
+ const options = { help: false, noOpen: false, port: 0 };
161
+ for (let i = 0; i < argv.length; i += 1) {
162
+ const arg = argv[i] ?? '';
163
+ if (arg === '--help' || arg === '-h') {
164
+ options.help = true;
165
+ continue;
166
+ }
167
+ if (arg === '--no-open') {
168
+ options.noOpen = true;
169
+ continue;
170
+ }
171
+ if (arg === '--port') {
172
+ const raw = argv[i + 1];
173
+ if (raw === undefined || raw.startsWith('--'))
174
+ return { ok: false, error: 'missing_port' };
175
+ const port = parsePort(raw);
176
+ if (port === null)
177
+ return { ok: false, error: 'invalid_port' };
178
+ options.port = port;
179
+ i += 1;
180
+ continue;
181
+ }
182
+ if (arg.startsWith('--port=')) {
183
+ const port = parsePort(arg.slice('--port='.length));
184
+ if (port === null)
185
+ return { ok: false, error: 'invalid_port' };
186
+ options.port = port;
187
+ continue;
188
+ }
189
+ return { ok: false, error: 'unknown_argument' };
190
+ }
191
+ return { ok: true, options };
192
+ }
193
+ export function createDashboardServer(memoryGraphStatus, env = process.env) {
194
+ const resolvedEnv = resolveDashboardEnv(env);
195
+ const eventsPath = events.rootEventsPath(resolvedEnv);
196
+ const tracesDir = events.tracesDir(resolvedEnv);
197
+ const store = new assetstore.LocalJsonlProvider(events.assetsDir(resolvedEnv));
198
+ const prices = loadPriceTable();
199
+ const personalityStore = new personality.PersonalityStore({
200
+ path: events.personalityStatePath(resolvedEnv),
201
+ });
202
+ const logFile = lifecyclePaths(resolvedEnv).logFile;
203
+ const githubPrDiagnostics = createGithubPrDiagnosticsProvider({ cwd: process.cwd() });
204
+ return new WebUIServer({
205
+ eventsPath,
206
+ store,
207
+ valueSummary: (window, eventSnapshot) => ops.loadValueSummary({
208
+ traces: ops.readTraceRecords(tracesDir),
209
+ events: eventSnapshot,
210
+ prices,
211
+ }, window),
212
+ retentionReport: () => events.buildRetentionReport({
213
+ rootEventsPath: eventsPath,
214
+ materialStorePath: events.materialStorePath(resolvedEnv),
215
+ materialCursorPath: events.materialWatermarkPath(resolvedEnv),
216
+ }),
217
+ personalityDiagnostics: () => readPersonalityDiagnostics(() => personalityStore.load()),
218
+ logDiagnostics: () => readLogDiagnostics(logFile),
219
+ githubPrDiagnostics: () => githubPrDiagnostics.read(),
220
+ memoryGraphStatus,
221
+ workflow: createDashboardWorkflowProvider(resolvedEnv),
222
+ });
223
+ }
224
+ export function dashboardOpenCommand(url, platform = process.platform) {
225
+ if (platform === 'win32')
226
+ return { command: 'rundll32.exe', args: ['url.dll,FileProtocolHandler', url] };
227
+ if (platform === 'darwin')
228
+ return { command: 'open', args: [url] };
229
+ return { command: 'xdg-open', args: [url] };
230
+ }
231
+ async function openDashboardUrl(url) {
232
+ const command = dashboardOpenCommand(url);
233
+ return new Promise((resolve) => {
234
+ const child = spawn(command.command, command.args, {
235
+ detached: true,
236
+ shell: false,
237
+ stdio: 'ignore',
238
+ windowsHide: true,
239
+ });
240
+ child.once('error', () => resolve(false));
241
+ child.once('spawn', () => {
242
+ child.unref();
243
+ resolve(true);
244
+ });
245
+ });
246
+ }
247
+ function waitForShutdownSignal() {
248
+ return new Promise((resolve) => {
249
+ const finish = () => {
250
+ process.removeListener('SIGINT', finish);
251
+ process.removeListener('SIGTERM', finish);
252
+ resolve();
253
+ };
254
+ process.once('SIGINT', finish);
255
+ process.once('SIGTERM', finish);
256
+ });
257
+ }
258
+ function isAddressInUse(error) {
259
+ return typeof error === 'object'
260
+ && error !== null
261
+ && 'code' in error
262
+ && error.code === 'EADDRINUSE';
263
+ }
264
+ async function listenWithPortFallback(server, requestedPort, maxAttempts) {
265
+ const attempts = requestedPort === 0
266
+ ? 1
267
+ : Math.min(Math.max(1, maxAttempts), 65_536 - requestedPort);
268
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
269
+ try {
270
+ return await server.listen(requestedPort + attempt);
271
+ }
272
+ catch (error) {
273
+ if (!isAddressInUse(error) || attempt === attempts - 1)
274
+ throw error;
275
+ }
276
+ }
277
+ throw new Error('dashboard_start_failed');
278
+ }
279
+ export async function runDashboardCommand(argv, deps = {}, options = {}) {
280
+ const stdout = deps.stdout ?? ((text) => { process.stdout.write(text); });
281
+ const stderr = deps.stderr ?? ((text) => { process.stderr.write(text); });
282
+ const parsed = parseDashboardOptions(argv);
283
+ if (!parsed.ok) {
284
+ stderr(`dashboard: ${parsed.error}\n${USAGE}`);
285
+ return 2;
286
+ }
287
+ if (parsed.options.help) {
288
+ stdout(USAGE);
289
+ return 0;
290
+ }
291
+ const createServer = deps.createServer ?? createDashboardServer;
292
+ let env;
293
+ try {
294
+ env = resolveDashboardEnv(deps.env ?? process.env);
295
+ }
296
+ catch (error) {
297
+ stderr(`dashboard: ${dashboardStartupError(error)}\n`);
298
+ return 1;
299
+ }
300
+ const memoryGraphStatus = deps.memoryGraphStatus ?? (() => loadMemoryGraphOperatorStatus(env));
301
+ const openUrl = deps.openUrl ?? openDashboardUrl;
302
+ const waitForShutdown = deps.waitForShutdown ?? waitForShutdownSignal;
303
+ let server;
304
+ try {
305
+ server = createServer(memoryGraphStatus, env);
306
+ }
307
+ catch (error) {
308
+ stderr(`dashboard: ${dashboardStartupError(error)}\n`);
309
+ return 1;
310
+ }
311
+ let listening = false;
312
+ try {
313
+ const port = await listenWithPortFallback(server, parsed.options.port, options.eaddrinusePortAttempts ?? 1);
314
+ listening = true;
315
+ let graphStatus;
316
+ try {
317
+ graphStatus = memoryGraphStatus();
318
+ }
319
+ catch {
320
+ graphStatus = { recovery: 'degraded', compactedRecords: 0, activeRecords: 0, corruptLines: 1, oversizedLines: 0, oversizedFiles: 0, archives: 0 };
321
+ }
322
+ stdout(`dashboard: memory-graph ${formatMemoryGraphOperatorStatus(graphStatus)}\n`);
323
+ const baseUrl = `http://127.0.0.1:${port}/`;
324
+ const launchUrl = `${baseUrl}launch?ticket=${encodeURIComponent(server.launchTicket)}`;
325
+ if (parsed.options.noOpen) {
326
+ stdout(`dashboard: ${launchUrl}\n`);
327
+ }
328
+ else if (await openUrl(launchUrl)) {
329
+ stdout(`dashboard: ${baseUrl}\n`);
330
+ }
331
+ else {
332
+ stderr('dashboard: browser_open_failed\n');
333
+ stdout(`dashboard: ${launchUrl}\n`);
334
+ }
335
+ await waitForShutdown();
336
+ return 0;
337
+ }
338
+ catch {
339
+ stderr(`dashboard: ${listening ? 'dashboard_runtime_failed' : 'dashboard_start_failed'}\n`);
340
+ return 1;
341
+ }
342
+ finally {
343
+ if (listening) {
344
+ try {
345
+ await server.close();
346
+ }
347
+ catch {
348
+ // The process is already shutting down; avoid replacing the command result with a close race.
349
+ }
350
+ }
351
+ }
352
+ }
@@ -1,3 +1,10 @@
1
+ interface ProxyCliModule {
2
+ runProxyCli(options: {
3
+ argv: readonly string[];
4
+ }): Promise<number>;
5
+ }
6
+ type ProxyCliImporter = () => Promise<ProxyCliModule>;
7
+ export declare function runProxyCommand(argv: string[], importer?: ProxyCliImporter): Promise<number>;
1
8
  export type CommandHandler = (argv: string[]) => Promise<number>;
2
9
  /** Verbs dispatched asynchronously ahead of the synchronous runCli core. cli.ts drives its dispatch from this. */
3
10
  export declare const ASYNC_COMMANDS: Readonly<Record<string, CommandHandler>>;
@@ -6,5 +13,7 @@ export declare const ASYNC_COMMANDS: Readonly<Record<string, CommandHandler>>;
6
13
  export declare const SYNC_COMMANDS: readonly ["status", "cycles", "trigger", "value", "narrative", "retention", "gene-value", "replay", "rebuild-views", "reset-local-secret"];
7
14
  /** Every top-level verb `evolver` resolves to (async-dispatched ∪ runCli core). */
8
15
  export declare const ALL_COMMANDS: ReadonlySet<string>;
16
+ export declare function v1TopLevelRunArgs(argv: readonly string[]): readonly string[] | undefined;
9
17
  /** Run a top-level argv against the registry: async handler if present, else the synchronous runCli core. */
10
- export declare function dispatch(argv: readonly string[]): Promise<number> | number;
18
+ export declare function dispatch(argv: readonly string[]): Promise<number> | number;
19
+ export {};
package/dist/dispatch.js CHANGED
@@ -6,9 +6,10 @@
6
6
  import { runCli, runMigrate, runAssetLog, runDistill, runIngest, runInject, runReview, } from './index.js';
7
7
  import { runAutoExec } from './autoexec.js';
8
8
  import { runAtpCommand, runBuyCommand, runOrdersCommand, runVerifyCommand } from './atp.js';
9
- import { runLogin } from './login.js';
9
+ import { runLogin, runLogout } from './login.js';
10
10
  import { runSetupHooks } from './setupHooks.js';
11
11
  import { runSkillDistill, runSkillMdUpdate } from './skillDistill.js';
12
+ import { runSkillCommand } from './skillFetch.js';
12
13
  import { runThesisCommand } from './thesis.js';
13
14
  import { getCliVersion } from './version.js';
14
15
  import { runRecipeCommand } from './recipe.js';
@@ -19,10 +20,23 @@ import { runReuseReportCommand } from './reuseReport.js';
19
20
  import { runDoctorCommand } from './doctor.js';
20
21
  import { runPhubCommand } from './phub.js';
21
22
  import { runTrajectoryExport } from './trajectoryExport.js';
23
+ import { runSyncCommand } from './sync.js';
22
24
  import { runAntiGeneBenchmarkCommand } from './antiGeneBenchmark.js';
23
25
  import { runAntiGeneRolloutCommand } from './antiGeneRollout.js';
24
26
  import { runLifecycleCommand } from './lifecycle.js';
25
27
  import { runCycleCommand } from './cycleConsumer.js';
28
+ import { runProxyToken } from './proxyToken.js';
29
+ import { runMaterialCommand } from './materialPackage.js';
30
+ import { runDashboardCommand } from './dashboard.js';
31
+ import { runIssueReportCommand } from './issueReport.js';
32
+ import { runAssetTrustCommand } from './assetTrust.js';
33
+ import { runAssetHealthCommand } from './assetHealth.js';
34
+ import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat } from './v1Compat.js';
35
+ import { runWorkflowCommand } from './workflow.js';
36
+ export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
37
+ const { runProxyCli } = await importer();
38
+ return runProxyCli({ argv: ['proxy', ...argv] });
39
+ }
26
40
  /** Verbs dispatched asynchronously ahead of the synchronous runCli core. cli.ts drives its dispatch from this. */
27
41
  export const ASYNC_COMMANDS = {
28
42
  migrate: runMigrate,
@@ -31,11 +45,14 @@ export const ASYNC_COMMANDS = {
31
45
  ingest: runIngest,
32
46
  inject: runInject,
33
47
  review: runReview,
48
+ skill: runSkillCommand,
34
49
  'skill-distill': runSkillDistill,
35
50
  'skill-md-update': runSkillMdUpdate,
36
51
  thesis: runThesisCommand,
37
52
  autoexec: runAutoExec,
38
53
  login: runLogin,
54
+ logout: runLogout,
55
+ 'proxy-token': runProxyToken,
39
56
  'setup-hooks': runSetupHooks,
40
57
  buy: runBuyCommand,
41
58
  orders: runOrdersCommand,
@@ -44,15 +61,27 @@ export const ASYNC_COMMANDS = {
44
61
  recipe: runRecipeCommand,
45
62
  reuse: runReuseCommand,
46
63
  publish: runPublishCommand,
64
+ sync: runSyncCommand,
47
65
  recall: runRecallCommand,
48
66
  'reuse-report': runReuseReportCommand,
49
67
  doctor: runDoctorCommand,
50
68
  phub: runPhubCommand,
51
69
  lifecycle: runLifecycleCommand,
52
70
  cycle: runCycleCommand,
71
+ material: runMaterialCommand,
53
72
  'trajectory-export': runTrajectoryExport,
54
73
  'anti-gene-benchmark': runAntiGeneBenchmarkCommand,
55
74
  'anti-gene-rollout': runAntiGeneRolloutCommand,
75
+ dashboard: runDashboardCommand,
76
+ 'issue-report': runIssueReportCommand,
77
+ 'asset-trust': runAssetTrustCommand,
78
+ 'asset-health': runAssetHealthCommand,
79
+ proxy: runProxyCommand,
80
+ run: runV1RunCompat,
81
+ solidify: runV1SolidifyCompat,
82
+ fetch: runV1FetchCompat,
83
+ webui: runV1WebuiCompat,
84
+ workflow: runWorkflowCommand,
56
85
  };
57
86
  /** Verbs handled by the synchronous runCli core (read-only views + local ops). Kept in sync with runCli's switch
58
87
  * — the source of truth for these stays runCli; this list completes the surface for the registry contract. */
@@ -64,9 +93,18 @@ export const ALL_COMMANDS = new Set([
64
93
  ...Object.keys(ASYNC_COMMANDS),
65
94
  ...SYNC_COMMANDS,
66
95
  ]);
96
+ export function v1TopLevelRunArgs(argv) {
97
+ if (argv.length === 0)
98
+ return [];
99
+ const hasLoopMode = argv.includes('--loop') || argv.includes('--mad-dog');
100
+ return argv[0]?.startsWith('-') && hasLoopMode ? argv : undefined;
101
+ }
67
102
  /** Run a top-level argv against the registry: async handler if present, else the synchronous runCli core. */
68
103
  export function dispatch(argv) {
69
- if (argv[0] === '--version' || argv[0] === '-v') {
104
+ const topLevelRunArgs = v1TopLevelRunArgs(argv);
105
+ if (topLevelRunArgs)
106
+ return runV1RunCompat(topLevelRunArgs);
107
+ if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-v')) {
70
108
  process.stdout.write(`${getCliVersion()}\n`);
71
109
  return 0;
72
110
  }
@@ -0,0 +1,13 @@
1
+ import { type algo, type assetstore } from '@evomap/evolver-core';
2
+ import { type DraftAdmission, type DraftAdmissionOptions, type ExistingGeneSignals } from './distillPrimitives.js';
3
+ export interface StoreDraftAdmission {
4
+ admission: DraftAdmission;
5
+ existing: ExistingGeneSignals[];
6
+ }
7
+ /**
8
+ * Build the complete dedupe context without loading the entire pool. Any subset or positive-Jaccard duplicate must
9
+ * share at least one candidate signal, so a store-side signalsAny query is complete for admission while excluding
10
+ * unrelated Genes. MAX_SAFE_INTEGER deliberately removes the provider's default result window; silently accepting
11
+ * a duplicate after row 1000 is worse than evaluating all signal-related rows in a mature pool.
12
+ */
13
+ export declare function assessDraftAdmissionFromStore(store: Pick<assetstore.AssetStoreProvider, 'search'>, candidate: algo.GeneCandidate, additional?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): Promise<StoreDraftAdmission>;
@@ -0,0 +1,35 @@
1
+ import {} from '@evomap/evolver-core';
2
+ import { assessDraftAdmission, } from './distillPrimitives.js';
3
+ function normalizedCandidateSignals(candidate) {
4
+ return [...new Set((candidate.signals_match ?? [])
5
+ .map((signal) => String(signal).trim().toLowerCase())
6
+ .filter(Boolean))];
7
+ }
8
+ function geneSignalRef(record) {
9
+ if (record.type !== 'Gene')
10
+ return null;
11
+ return {
12
+ id: typeof record['id'] === 'string' ? String(record['id']) : undefined,
13
+ signals_match: Array.isArray(record['signals_match']) ? record['signals_match'] : [],
14
+ };
15
+ }
16
+ /**
17
+ * Build the complete dedupe context without loading the entire pool. Any subset or positive-Jaccard duplicate must
18
+ * share at least one candidate signal, so a store-side signalsAny query is complete for admission while excluding
19
+ * unrelated Genes. MAX_SAFE_INTEGER deliberately removes the provider's default result window; silently accepting
20
+ * a duplicate after row 1000 is worse than evaluating all signal-related rows in a mature pool.
21
+ */
22
+ export async function assessDraftAdmissionFromStore(store, candidate, additional = [], opts = {}) {
23
+ const intrinsic = assessDraftAdmission(candidate, [], opts);
24
+ if (!intrinsic.admit)
25
+ return { admission: intrinsic, existing: [...additional] };
26
+ const signalsAny = normalizedCandidateSignals(candidate);
27
+ const stored = signalsAny.length > 0
28
+ ? await store.search({ kind: 'Gene', signalsAny, limit: Number.MAX_SAFE_INTEGER })
29
+ : [];
30
+ const existing = [
31
+ ...stored.map(geneSignalRef).filter((ref) => ref !== null),
32
+ ...additional,
33
+ ];
34
+ return { admission: assessDraftAdmission(candidate, existing, opts), existing };
35
+ }
@@ -11,9 +11,10 @@
11
11
  // wired into autoexec — a tracked dependency, not dead code. See distillObserver.test.ts.
12
12
  import { assetstore, events, observers, signals, algo } from '@evomap/evolver-core';
13
13
  import { readFileSync } from 'node:fs';
14
- import { draftGeneCandidate, assessDraftAdmission } from './distillPrimitives.js';
14
+ import { draftGeneCandidate } from './distillPrimitives.js';
15
+ import { assessDraftAdmissionFromStore } from './distillAdmission.js';
15
16
  import { reviewLedgerForStore } from './reviewFilter.js';
16
- import { parseRuntimeSessionSources } from './runtimeSessionSource.js';
17
+ import { runtimeSessionSourcesForMaterial } from './materialSnapshot.js';
17
18
  /** Consumer group the distill drain claims under — independent cursor from any other material consumer. */
18
19
  export const DISTILL_CONSUMER_GROUP = 'distill';
19
20
  /** Drafts created per tick — bound the auto-draft rate so an idle daemon does not flood the human review queue. */
@@ -37,7 +38,7 @@ export function makeDistillDrain(c) {
37
38
  return { ack: true, drafted: 0 };
38
39
  let sources;
39
40
  try {
40
- sources = parseRuntimeSessionSources(m.sourcePath, readSource);
41
+ sources = runtimeSessionSourcesForMaterial(m, readSource);
41
42
  }
42
43
  catch {
43
44
  return { ack: true, drafted: 0 }; // bad / missing / unparseable source — nothing to retry
@@ -49,13 +50,10 @@ export function makeDistillDrain(c) {
49
50
  const candidate = draftGeneCandidate(source.turns, signals.extractSignals(source.turns), source.agent);
50
51
  if (!candidate)
51
52
  continue; // too thin to distill
52
- const existing = (await c.store.list('Gene', 1000)).map((g) => ({
53
- id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
54
- signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
55
- }));
56
53
  // Value/novelty gate (#117 improvement 3): drop thin / near-duplicate drafts BEFORE they reach the human
57
54
  // review queue. Ack the material (a deliberate skip, not a failure — nothing to retry).
58
- if (!assessDraftAdmission(candidate, existing).admit)
55
+ const { admission, existing } = await assessDraftAdmissionFromStore(c.store, candidate);
56
+ if (!admission.admit)
59
57
  continue;
60
58
  const r = algo.intakeGene(candidate, existing);
61
59
  if (!r.ok || !r.gene)
@@ -1,4 +1,4 @@
1
- import type { signals, algo } from '@evomap/evolver-core';
1
+ import { algo, type signals } from '@evomap/evolver-core';
2
2
  import type { NormalizedTurn } from '@evomap/evolver-runtime-adapters';
3
3
  /** Short matchable signal tokens from the STRONG signals only (toolName + a known error class). Every strong
4
4
  * signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
@@ -30,7 +30,9 @@ export interface DraftAdmissionOptions {
30
30
  /** Reject a draft with fewer strategy steps than this (default 1, i.e. just non-empty like intakeGene; raise it
31
31
  * for a stricter substance floor). A real fix can be one concrete step, so the default does not over-filter. */
32
32
  minStrategy?: number;
33
- /** Reject a draft whose signal-set Jaccard similarity to ANY existing gene is >= this (default 0.8). */
33
+ /** Reject a draft whose discriminating-signal Jaccard similarity to ANY existing gene is >= this (default 0.6).
34
+ * Generated fallback markers and generic command runners are omitted from this SOFT comparison, while the
35
+ * exact-subset check still uses the complete signal sets. */
34
36
  maxSimilarity?: number;
35
37
  }
36
38
  export interface DraftAdmission {
@@ -39,10 +41,10 @@ export interface DraftAdmission {
39
41
  }
40
42
  /**
41
43
  * Value/novelty gate run BEFORE a draft is quarantined (#117 improvement 3). `intakeGene` already rejects
42
- * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps), but two kinds of noise still
43
- * reach the human review queue: drafts too thin to be worth reviewing (one weak signal, one vague step), and
44
- * near-duplicates that escape the subset check by carrying one extra signal. Unattended auto-distill turns that
45
- * trickle into a flood, and a review gate nobody reads is no gate. This adds a substance floor + a SOFT similarity
46
- * reject. Pure and deterministic; the caller decides what to do with a non-admit (skip, never an error).
44
+ * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps). Admission mirrors that subset
45
+ * check so a duplicate is a per-candidate skip instead of aborting a whole batch, then adds the two missing noise
46
+ * controls: a substance floor and a SOFT near-duplicate comparison. Unattended auto-distill turns that trickle
47
+ * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
48
+ * with a non-admit (skip, never an error).
47
49
  */
48
50
  export declare function assessDraftAdmission(candidate: algo.GeneCandidate, existing?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): DraftAdmission;