@evomap/evolver-cli 2.0.47 → 2.0.49
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/autoDistillTranscript.d.ts +1 -1
- package/dist/autoDistillTranscript.js +9 -2
- package/dist/autoexec.js +4 -0
- package/dist/cliContracts.js +5 -28
- package/dist/cycleConsumer.js +3 -0
- package/dist/distillAdmission.d.ts +8 -1
- package/dist/distillAdmission.js +30 -0
- package/dist/distillObserver.d.ts +0 -6
- package/dist/distillObserver.js +17 -5
- package/dist/distillPrimitives.d.ts +4 -3
- package/dist/distillPrimitives.js +27 -18
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.js +17 -0
- package/dist/feedbackOutbox.js +11 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/lifecycle.d.ts +9 -0
- package/dist/lifecycle.js +158 -98
- package/dist/lifecycleAutoexecCompanion.d.ts +40 -0
- package/dist/lifecycleAutoexecCompanion.js +102 -0
- package/dist/llmCycle.js +15 -5
- package/dist/localMemoryGraph.js +23 -19
- package/dist/localPublishBinding.js +5 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +15 -7
- package/dist/pluginBundle.d.ts +1 -0
- package/dist/pluginBundle.js +3 -4
- package/dist/pluginDshStore.d.ts +7 -0
- package/dist/pluginDshStore.js +84 -0
- package/dist/pluginHosts.d.ts +16 -0
- package/dist/pluginHosts.js +34 -8
- package/dist/pluginInspection.d.ts +2 -0
- package/dist/pluginInspection.js +20 -9
- package/dist/pluginInstall.d.ts +1 -0
- package/dist/pluginInstall.js +29 -10
- package/dist/pluginRuntime.d.ts +3 -2
- package/dist/pluginRuntime.js +3 -1
- package/dist/promptRecallRuntime.d.ts +3 -0
- package/dist/promptRecallRuntime.js +6 -0
- package/dist/promptRecallShared.d.ts +2 -0
- package/dist/promptRecallShared.js +13 -3
- package/dist/protectedAuditStatus.d.ts +22 -0
- package/dist/protectedAuditStatus.js +234 -0
- package/dist/recall.js +2 -3
- package/dist/runtimeCapabilities.d.ts +1 -1
- package/dist/runtimeCapabilities.js +24 -0
- package/dist/runtimeSessionSource.js +4 -4
- package/dist/sessionIngest.js +3 -0
- package/dist/setupHooks.d.ts +3 -0
- package/dist/setupHooks.js +29 -5
- package/dist/trajectoryExport.js +2 -2
- package/package.json +7 -7
package/dist/pluginInspection.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolveOpenCodeConfig } from '@evomap/evolver-mcp';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { AGENT_PLUGIN_GIT_URL, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY } from './pluginHosts.js';
|
|
5
|
+
import { AGENT_PLUGIN_GIT_URL, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, standalonePluginRemoval } from './pluginHosts.js';
|
|
6
6
|
import { checkedPluginCommand, objectOf, pluginHome, pluginJson, pluginVersionAtLeast, PluginInstallError, readPluginJson, readPluginText } from './pluginRuntime.js';
|
|
7
7
|
function listRecords(value, key, label) {
|
|
8
8
|
const list = Array.isArray(value) ? value : objectOf(value)?.[key];
|
|
@@ -91,11 +91,14 @@ async function inspectMarketplacePlugin(runtime, options) {
|
|
|
91
91
|
const markets = listRecords(pluginJson(marketResult.stdout, `${host.label} marketplace list`), 'marketplaces', `${host.label} marketplace list`);
|
|
92
92
|
const market = markets.find(record => record['name'] === host.marketplace);
|
|
93
93
|
const conflicts = oldHookConflicts(runtime, options);
|
|
94
|
+
const migrations = [];
|
|
94
95
|
if (market && !await marketplaceMatches(runtime, market))
|
|
95
96
|
conflicts.push(`Marketplace ${host.marketplace} belongs to another source. Review its plugins before replacing it with ${AGENT_PLUGIN_REPOSITORY}.`);
|
|
96
97
|
for (const plugin of plugins) {
|
|
97
|
-
if (host.legacyNames.includes(plugin.name) && plugin.enabled)
|
|
98
|
+
if (host.legacyNames.includes(plugin.name) && plugin.enabled) {
|
|
98
99
|
conflicts.push(`The standalone ${plugin.name} plugin is enabled. Disable/remove it using ${host.label}, keeping its data, before installing ${AGENT_PLUGIN_NAME}.`);
|
|
100
|
+
migrations.push(standalonePluginRemoval(options, plugin));
|
|
101
|
+
}
|
|
99
102
|
if (plugin.name === AGENT_PLUGIN_NAME && plugin.id !== `${AGENT_PLUGIN_NAME}@${host.marketplace}` && !(host.id === 'grok' && plugin.id === AGENT_PLUGIN_NAME))
|
|
100
103
|
conflicts.push('An Evolver plugin from another marketplace is registered; review that installation before continuing.');
|
|
101
104
|
}
|
|
@@ -106,14 +109,15 @@ async function inspectMarketplacePlugin(runtime, options) {
|
|
|
106
109
|
conflicts.push('The plugin is installed but disabled. Enable it explicitly in the host rather than installing another copy.');
|
|
107
110
|
if (installed && host.id === 'codex' && !agentPluginRepositoryMatches(repositoryOf(installed.raw)))
|
|
108
111
|
conflicts.push('The installed plugin source does not match the unified Evolver plugin repository.');
|
|
109
|
-
return { installed, marketplacePresent: Boolean(market), conflicts };
|
|
112
|
+
return { installed, marketplacePresent: Boolean(market), conflicts, migrations };
|
|
110
113
|
}
|
|
111
114
|
export function verifyPluginManifest(runtime, options, plugin, installAnswer) {
|
|
112
115
|
const { host } = options;
|
|
113
116
|
if (!pluginVersionAtLeast(plugin.version, plugin.version))
|
|
114
117
|
throw new PluginInstallError('failed', 'The installed plugin has no verifiable version.');
|
|
115
118
|
const answer = objectOf(installAnswer);
|
|
116
|
-
const
|
|
119
|
+
const listedPath = plugin.path && host.packedSubdir ? join(plugin.path, host.packedSubdir) : plugin.path;
|
|
120
|
+
const path = listedPath ?? stringOf(answer?.['installedPath']) ?? stringOf(answer?.['installPath'])
|
|
117
121
|
?? (host.id === 'codex' ? join(runtime.env['CODEX_HOME'] ?? join(pluginHome(runtime), '.codex'), 'plugins', 'cache', host.marketplace, AGENT_PLUGIN_NAME, plugin.version) : undefined);
|
|
118
122
|
if (!path || !host.manifest)
|
|
119
123
|
throw new PluginInstallError('failed', 'The host did not identify a verifiable installed plugin directory.');
|
|
@@ -161,10 +165,13 @@ export function inspectOpenCodePlugin(runtime, options) {
|
|
|
161
165
|
const tuiFile = existsSync(join(root, 'tui.jsonc')) ? join(root, 'tui.jsonc') : join(root, 'tui.json');
|
|
162
166
|
const tuiEntries = pluginEntries(readPluginJson(tuiFile));
|
|
163
167
|
const conflicts = [];
|
|
168
|
+
const migrations = [];
|
|
164
169
|
const pairs = [];
|
|
165
170
|
for (const entry of [...serverEntries, ...tuiEntries]) {
|
|
166
|
-
if (options.host.legacyNames.some(name => entry.includes(name)))
|
|
171
|
+
if (options.host.legacyNames.some(name => entry.includes(name))) {
|
|
167
172
|
conflicts.push('The standalone OpenCode Evolver package is registered; remove only its entries, keeping its data.');
|
|
173
|
+
migrations.push(standalonePluginRemoval(options, { id: entry, name: entry }));
|
|
174
|
+
}
|
|
168
175
|
}
|
|
169
176
|
if (existsSync(join(options.root, '.opencode', 'plugins', 'evolver.js')))
|
|
170
177
|
conflicts.push('A legacy .opencode/plugins/evolver.js is present; inspect/disable it before continuing.');
|
|
@@ -199,7 +206,7 @@ export function inspectOpenCodePlugin(runtime, options) {
|
|
|
199
206
|
const path = pair && dirname(pair.server);
|
|
200
207
|
const manifest = path && readPluginJson(join(path, 'package.json'));
|
|
201
208
|
const installed = manifest && typeof manifest['version'] === 'string' ? { id: AGENT_PLUGIN_NAME, name: AGENT_PLUGIN_NAME, version: manifest['version'], enabled: true, path, raw: manifest } : undefined;
|
|
202
|
-
return { installed, marketplacePresent: false, conflicts };
|
|
209
|
+
return { installed, marketplacePresent: false, conflicts, migrations: [...new Set(migrations)] };
|
|
203
210
|
}
|
|
204
211
|
function inspectDshPlugin(runtime, options) {
|
|
205
212
|
const profileDir = join(pluginHome(runtime), '.dsh', 'profiles', options.profile);
|
|
@@ -208,15 +215,17 @@ function inspectDshPlugin(runtime, options) {
|
|
|
208
215
|
const path = join(profileDir, 'node_modules', '@evomap', 'dsh-evolver');
|
|
209
216
|
const manifest = readPluginJson(join(path, 'package.json'));
|
|
210
217
|
const conflicts = [];
|
|
218
|
+
const migrations = [];
|
|
211
219
|
if (dependency !== undefined && (typeof dependency !== 'string' || !dependency.includes(`github:${AGENT_PLUGIN_REPOSITORY}#release&path:dist/dsh`))) {
|
|
212
220
|
conflicts.push(`Profile ${options.profile} contains the standalone or differently sourced @evomap/dsh-evolver. Remove that package in this profile first; keep its state.`);
|
|
221
|
+
migrations.push(standalonePluginRemoval(options, { id: '@evomap/dsh-evolver', name: '@evomap/dsh-evolver' }));
|
|
213
222
|
}
|
|
214
223
|
const repository = packageRepositoryOf(manifest?.['repository']);
|
|
215
224
|
if (manifest && !agentPluginRepositoryMatches(repository))
|
|
216
225
|
conflicts.push('The installed dsh package does not belong to the unified plugin repository.');
|
|
217
226
|
const installed = manifest && dependency !== undefined && typeof manifest['version'] === 'string'
|
|
218
227
|
? { id: AGENT_PLUGIN_NAME, name: AGENT_PLUGIN_NAME, version: manifest['version'], enabled: true, path, raw: manifest } : undefined;
|
|
219
|
-
return { installed, marketplacePresent: false, conflicts };
|
|
228
|
+
return { installed, marketplacePresent: false, conflicts, migrations };
|
|
220
229
|
}
|
|
221
230
|
export async function inspectAgentPlugin(runtime, options) {
|
|
222
231
|
if (options.host.kind === 'marketplace')
|
|
@@ -228,10 +237,12 @@ export async function inspectAgentPlugin(runtime, options) {
|
|
|
228
237
|
const result = await checkedPluginCommand(runtime, options.host.command, ['plugin', 'list', '--json'], options.root);
|
|
229
238
|
const plugins = installedPluginsFromJson(pluginJson(result.stdout, 'Antigravity plugin list'), options.host);
|
|
230
239
|
const installed = plugins.find(plugin => plugin.name === AGENT_PLUGIN_NAME);
|
|
231
|
-
const
|
|
240
|
+
const standalone = plugins.filter(plugin => options.host.legacyNames.includes(plugin.name) && plugin.enabled);
|
|
241
|
+
const conflicts = standalone.map(plugin => `Standalone ${plugin.name} is enabled; disable/remove it and keep its data before continuing.`);
|
|
242
|
+
const migrations = standalone.map(plugin => standalonePluginRemoval(options, plugin));
|
|
232
243
|
if (installed && hasForeignInstalledScope(installed, options.scope))
|
|
233
244
|
conflicts.push('The host registered this plugin in another scope; it cannot confirm the requested installation scope.');
|
|
234
245
|
if (installed && !installed.enabled)
|
|
235
246
|
conflicts.push('The plugin is installed but disabled. Enable it explicitly in the host rather than installing another copy.');
|
|
236
|
-
return { marketplacePresent: false, installed, conflicts };
|
|
247
|
+
return { marketplacePresent: false, installed, conflicts, migrations };
|
|
237
248
|
}
|
package/dist/pluginInstall.d.ts
CHANGED
package/dist/pluginInstall.js
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { ensureAgentPluginBundle } from './pluginBundle.js';
|
|
2
|
+
import { assertDshProfileStoreMatches } from './pluginDshStore.js';
|
|
2
3
|
import { AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, pluginInstallSteps, pluginRollbackInstructions } from './pluginHosts.js';
|
|
3
4
|
import { inspectAgentPlugin, verifyPluginManifest } from './pluginInspection.js';
|
|
4
5
|
import { withPluginInstallLock } from './pluginLock.js';
|
|
5
6
|
import { checkedPluginCommand, checkPluginHostVersion, PluginInstallError } from './pluginRuntime.js';
|
|
7
|
+
function trustInstruction(host) {
|
|
8
|
+
return `${host.label} asks you to trust a plugin before it installs. Review ${AGENT_PLUGIN_REPOSITORY}, then rerun with --trust: evolver plugin install --host ${host.id} --trust`;
|
|
9
|
+
}
|
|
10
|
+
function assertNoConflicts(inspection) {
|
|
11
|
+
if (inspection.conflicts.length > 0)
|
|
12
|
+
throw new PluginInstallError('conflict', inspection.conflicts.join('\n'), inspection.migrations);
|
|
13
|
+
}
|
|
14
|
+
function migrationInstructions(error) {
|
|
15
|
+
if (!(error instanceof PluginInstallError) || error.instructions.length === 0)
|
|
16
|
+
return [];
|
|
17
|
+
if (error.status !== 'conflict')
|
|
18
|
+
return [...error.instructions];
|
|
19
|
+
return ['To migrate, run this yourself after checking the old plugin and its data (Evolver never runs it):', ...error.instructions];
|
|
20
|
+
}
|
|
6
21
|
export async function installAgentPlugin(runtime, options) {
|
|
7
22
|
const { host } = options;
|
|
8
23
|
const result = {
|
|
9
|
-
ok: false, status: 'failed', host: host.id, scope: options.scope, verified: false, repository: AGENT_PLUGIN_REPOSITORY,
|
|
24
|
+
ok: false, status: 'failed', host: host.id, scope: options.scope, verified: false, requiresTrust: Boolean(host.requiresTrust), repository: AGENT_PLUGIN_REPOSITORY,
|
|
10
25
|
commands: pluginInstallSteps(options), completed: [], instructions: [...host.instructions], rollback: pluginRollbackInstructions(options),
|
|
11
26
|
...(host.id === 'dsh' && { profile: options.profile }),
|
|
12
27
|
};
|
|
@@ -16,25 +31,30 @@ export async function installAgentPlugin(runtime, options) {
|
|
|
16
31
|
: result.instructions;
|
|
17
32
|
return { ...result, status: 'manual_required', instructions: [...instructions, `Requested scope: ${options.scope}. No client configuration was changed.`] };
|
|
18
33
|
}
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
const trustMissing = host.requiresTrust && !options.trust;
|
|
35
|
+
if (options.dryRun) {
|
|
36
|
+
return { ...result, ok: true, status: 'dry_run', instructions: [...result.instructions, ...(trustMissing ? [trustInstruction(host)] : []), 'Preview only: host version, registration, download and installation have not been executed.'] };
|
|
37
|
+
}
|
|
38
|
+
if (trustMissing) {
|
|
39
|
+
return { ...result, status: 'trust_required', error: `${host.label} installs plugin hooks, MCP servers and skills only after you trust the plugin. No host command was run.`, instructions: [trustInstruction(host)] };
|
|
40
|
+
}
|
|
21
41
|
try {
|
|
22
42
|
await checkPluginHostVersion(runtime, host);
|
|
23
43
|
let inspection = await inspectAgentPlugin(runtime, options);
|
|
24
|
-
|
|
25
|
-
throw new PluginInstallError('conflict', inspection.conflicts.join('\n'));
|
|
44
|
+
assertNoConflicts(inspection);
|
|
26
45
|
if (inspection.installed) {
|
|
27
46
|
const installedPath = verifyPluginManifest(runtime, options, inspection.installed);
|
|
28
47
|
return { ...result, ok: true, status: 'already_installed', verified: true, version: inspection.installed.version, installedPath, commands: [] };
|
|
29
48
|
}
|
|
30
49
|
return await withPluginInstallLock(runtime, options, async () => {
|
|
31
50
|
inspection = await inspectAgentPlugin(runtime, options);
|
|
32
|
-
|
|
33
|
-
throw new PluginInstallError('conflict', inspection.conflicts.join('\n'));
|
|
51
|
+
assertNoConflicts(inspection);
|
|
34
52
|
if (inspection.installed) {
|
|
35
53
|
const installedPath = verifyPluginManifest(runtime, options, inspection.installed);
|
|
36
54
|
return { ...result, ok: true, status: 'already_installed', verified: true, version: inspection.installed.version, installedPath, commands: [] };
|
|
37
55
|
}
|
|
56
|
+
if (host.id === 'dsh')
|
|
57
|
+
await assertDshProfileStoreMatches(runtime, options);
|
|
38
58
|
let bundle;
|
|
39
59
|
if (host.kind === 'bundle') {
|
|
40
60
|
bundle = await ensureAgentPluginBundle(runtime, host);
|
|
@@ -62,8 +82,7 @@ export async function installAgentPlugin(runtime, options) {
|
|
|
62
82
|
}
|
|
63
83
|
}
|
|
64
84
|
inspection = await inspectAgentPlugin(runtime, options);
|
|
65
|
-
|
|
66
|
-
throw new PluginInstallError('conflict', inspection.conflicts.join('\n'));
|
|
85
|
+
assertNoConflicts(inspection);
|
|
67
86
|
if (!inspection.installed)
|
|
68
87
|
throw new PluginInstallError('failed', `The ${AGENT_PLUGIN_NAME} command completed, but the selected host/scope did not register it. Installation was not confirmed.`);
|
|
69
88
|
const installedPath = verifyPluginManifest(runtime, options, inspection.installed, installAnswer);
|
|
@@ -75,7 +94,7 @@ export async function installAgentPlugin(runtime, options) {
|
|
|
75
94
|
...result,
|
|
76
95
|
status: error instanceof PluginInstallError ? error.status : 'failed',
|
|
77
96
|
error: error instanceof PluginInstallError ? error.message : 'The plugin operation failed; no verified installation was reported.',
|
|
78
|
-
instructions: [...result.instructions, ...(result.completed.length > 0 ? [
|
|
97
|
+
instructions: [...result.instructions, ...migrationInstructions(error), ...(result.completed.length > 0 ? [
|
|
79
98
|
`Commands already completed: ${result.completed.join(', ')}. Inspect the selected host before retrying.`,
|
|
80
99
|
'No existing plugin, user data or marketplace was automatically removed. Use the rollback instructions only after checking the current host registration.',
|
|
81
100
|
] : [])],
|
package/dist/pluginRuntime.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { exec } from '@evomap/evolver-core';
|
|
2
2
|
import type { PluginHost } from './pluginHosts.js';
|
|
3
3
|
export type PluginProcessResult = Awaited<ReturnType<typeof exec.spawnCapture>>;
|
|
4
|
-
export type PluginInstallStatus = 'installed' | 'already_installed' | 'dry_run' | 'manual_required' | 'host_missing' | 'unsupported_version' | 'unsupported_capability' | 'conflict' | 'failed' | 'invalid_arguments' | 'selection_required';
|
|
4
|
+
export type PluginInstallStatus = 'installed' | 'already_installed' | 'dry_run' | 'manual_required' | 'host_missing' | 'unsupported_version' | 'unsupported_capability' | 'conflict' | 'failed' | 'invalid_arguments' | 'selection_required' | 'trust_required' | 'profile_store_mismatch';
|
|
5
5
|
export declare class PluginInstallError extends Error {
|
|
6
6
|
readonly status: PluginInstallStatus;
|
|
7
|
-
|
|
7
|
+
readonly instructions: readonly string[];
|
|
8
|
+
constructor(status: PluginInstallStatus, message: string, instructions?: readonly string[]);
|
|
8
9
|
}
|
|
9
10
|
export interface PluginRuntime {
|
|
10
11
|
env: NodeJS.ProcessEnv;
|
package/dist/pluginRuntime.js
CHANGED
|
@@ -4,9 +4,11 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
5
5
|
export class PluginInstallError extends Error {
|
|
6
6
|
status;
|
|
7
|
-
|
|
7
|
+
instructions;
|
|
8
|
+
constructor(status, message, instructions = []) {
|
|
8
9
|
super(message);
|
|
9
10
|
this.status = status;
|
|
11
|
+
this.instructions = instructions;
|
|
10
12
|
this.name = 'PluginInstallError';
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as recall from '@evomap/evolver-core/prompt-recall';
|
|
2
|
+
import { type ProtectedAuditSessionNoticeOptions } from './protectedAuditStatus.js';
|
|
2
3
|
type HookInputReader = (signal?: AbortSignal) => string | undefined | Promise<string | undefined>;
|
|
3
4
|
export interface PromptRecallHookDeps {
|
|
4
5
|
store?: recall.AssetStoreProvider;
|
|
@@ -15,6 +16,8 @@ export interface PromptRecallHookDeps {
|
|
|
15
16
|
/** External delivery writers must own preparation, projection and terminal release. */
|
|
16
17
|
ingestor?: Pick<recall.Ingestor, 'prepareContextDelivery'> & Partial<Pick<recall.Ingestor, 'prepareContextDeliveryAsync' | 'recoverContextDeliveries'>>;
|
|
17
18
|
selectionTimeoutMs?: number;
|
|
19
|
+
/** Test seam for the protected audit probe and its per-session notice state. */
|
|
20
|
+
protectedAuditNotice?: ProtectedAuditSessionNoticeOptions;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Shared Claude Code/Codex UserPromptSubmit entrypoint. It is intentionally local-only and fail-open: no Hub
|
|
@@ -2,6 +2,7 @@ import * as recall from '@evomap/evolver-core/prompt-recall';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { deliverContextOutput, waitContextDelivery } from './contextDelivery.js';
|
|
5
|
+
import { writeProtectedAuditSessionNotice, protectedAuditNoticeStatePath } from './protectedAuditStatus.js';
|
|
5
6
|
import { MAX_PROMPT_RECALL_STDIN_BYTES, MAX_PROMPT_RECALL_LOCAL_FILE_BYTES, MAX_PROMPT_RECALL_LOCAL_TOTAL_BYTES, promptRecallMode, wrapGeneContext, writeHookStdout, writeContextReadDiagnostic } from './promptRecallShared.js';
|
|
6
7
|
const PROMPT_RECALL_STDIN_TIMEOUT_MS = 250;
|
|
7
8
|
const PROMPT_RECALL_SELECTION_TIMEOUT_MS = 750;
|
|
@@ -543,6 +544,11 @@ async function runPromptRecallHookOwned(argv, deps) {
|
|
|
543
544
|
if (typeof input.hook_event_name === 'string' && input.hook_event_name !== 'UserPromptSubmit') {
|
|
544
545
|
throw new Error('unexpected hook event');
|
|
545
546
|
}
|
|
547
|
+
const auditReadiness = (deps.protectedAuditNotice?.readiness ?? recall.protectedAuditReadiness)();
|
|
548
|
+
if (auditReadiness.state === 'unavailable') {
|
|
549
|
+
await writeProtectedAuditSessionNotice(typeof input.session_id === 'string' ? input.session_id : undefined, auditReadiness, deps.protectedAuditNotice?.statePath ?? protectedAuditNoticeStatePath(recall.evomapHome(env)), deps, '{}\n');
|
|
550
|
+
return 0;
|
|
551
|
+
}
|
|
546
552
|
const prompt = input.prompt;
|
|
547
553
|
if (typeof prompt !== 'string')
|
|
548
554
|
throw new Error('prompt is not recallable');
|
|
@@ -11,6 +11,8 @@ export declare function waitContextDelivery<T>(promise: Promise<T>, timeoutMs?:
|
|
|
11
11
|
export declare function promptRecallMode(env?: NodeJS.ProcessEnv): PromptRecallMode;
|
|
12
12
|
/** Rebind section offsets/digest to the actual prompt, including wrappers; never slice an assembled body. */
|
|
13
13
|
export declare function wrapGeneContext(context: assetstore.AssembledGeneContext, prefix: string, suffix: string): assetstore.AssembledGeneContext;
|
|
14
|
+
/** Only the transport's own pre-dispatch refusal proves no bytes were submitted. */
|
|
15
|
+
export declare function hookStdoutNotSubmitted(error: unknown): boolean;
|
|
14
16
|
/** A successful callback means stdout_written, not host_received. One attempt only, even on EPIPE. */
|
|
15
17
|
export declare function writeHookStdout(text: string, options?: {
|
|
16
18
|
destroyOnTimeout?: boolean;
|
|
@@ -47,13 +47,23 @@ export function wrapGeneContext(context, prefix, suffix) {
|
|
|
47
47
|
// One submitted write owns the stream until callback/close, including after
|
|
48
48
|
// caller timeout. Refuse retries instead of accumulating listeners and queued bytes.
|
|
49
49
|
const pendingStdoutWrites = new WeakMap();
|
|
50
|
+
class HookStdoutNotSubmittedError extends Error {
|
|
51
|
+
constructor() { super('hook_stdout_unconfirmed'); }
|
|
52
|
+
}
|
|
53
|
+
/** Only the transport's own pre-dispatch refusal proves no bytes were submitted. */
|
|
54
|
+
export function hookStdoutNotSubmitted(error) {
|
|
55
|
+
return error instanceof HookStdoutNotSubmittedError;
|
|
56
|
+
}
|
|
50
57
|
/** A successful callback means stdout_written, not host_received. One attempt only, even on EPIPE. */
|
|
51
58
|
export function writeHookStdout(text, options = {}) {
|
|
52
59
|
return new Promise((resolve, reject) => {
|
|
53
60
|
const stdout = process.stdout;
|
|
54
|
-
if (pendingStdoutWrites.has(stdout)) {
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
if (pendingStdoutWrites.has(stdout) || stdout.destroyed || stdout.writableEnded) {
|
|
62
|
+
try {
|
|
63
|
+
options.onSettled?.(false);
|
|
64
|
+
}
|
|
65
|
+
catch { /* The observer does not own the stream. */ }
|
|
66
|
+
reject(new HookStdoutNotSubmittedError());
|
|
57
67
|
return;
|
|
58
68
|
}
|
|
59
69
|
const owner = {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ProtectedAuditReadiness } from '@evomap/evolver-core/prompt-recall';
|
|
2
|
+
export type { ProtectedAuditReadiness };
|
|
3
|
+
export type ProtectedAuditInstallState = 'ready' | 'not_required' | 'not_provisioned' | 'unavailable';
|
|
4
|
+
export declare const PROTECTED_AUDIT_INSTALL_GUIDE: string;
|
|
5
|
+
export interface ProtectedAuditInstallReport {
|
|
6
|
+
protected_audit: ProtectedAuditInstallState;
|
|
7
|
+
protected_audit_next_step?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function protectedAuditInstallReport(readiness: ProtectedAuditReadiness): ProtectedAuditInstallReport;
|
|
10
|
+
export interface ProtectedAuditSessionNoticeOptions {
|
|
11
|
+
readiness?: () => ProtectedAuditReadiness;
|
|
12
|
+
statePath?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function protectedAuditNoticeStatePath(evomapHome: string): string;
|
|
15
|
+
interface NoticeWriter {
|
|
16
|
+
/** A trusted writer resolves only after its output is complete. */
|
|
17
|
+
stdout?: (text: string) => void | Promise<void>;
|
|
18
|
+
stdoutWithSettlement?: (text: string, onSettled: (written: boolean) => void) => Promise<void>;
|
|
19
|
+
onOutputWritten?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/** Reserve before attempting one write; only the actual transport acknowledgement confirms it. */
|
|
22
|
+
export declare function writeProtectedAuditSessionNotice(sessionId: string | undefined, readiness: ProtectedAuditReadiness, path: string, writer: NoticeWriter, emptyOutput?: string): Promise<void>;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { closeSync, constants, fstatSync, mkdirSync, openSync, readFileSync, readSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { acquireLock, releaseLock } from '@evomap/evolver-core/prompt-recall';
|
|
5
|
+
import { hookStdoutNotSubmitted, writeHookStdout } from './promptRecallShared.js';
|
|
6
|
+
export const PROTECTED_AUDIT_INSTALL_GUIDE = 'an administrator must install the protected audit service with install-protected-audit-service.sh '
|
|
7
|
+
+ 'from the same sealed release as this evolver binary (docs/release-smoke.md, section "POSIX 用户实际安装边界")';
|
|
8
|
+
const NOT_PROVISIONED_REASONS = new Set(['service_not_provisioned', 'client_config_missing']);
|
|
9
|
+
const MAX_NOTIFIED_SESSIONS = 256;
|
|
10
|
+
const NOTICE_OWNER = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
11
|
+
function protectedAuditInstallState(readiness) {
|
|
12
|
+
if (readiness.state !== 'unavailable')
|
|
13
|
+
return readiness.state;
|
|
14
|
+
return NOT_PROVISIONED_REASONS.has(readiness.reason) ? 'not_provisioned' : 'unavailable';
|
|
15
|
+
}
|
|
16
|
+
export function protectedAuditInstallReport(readiness) {
|
|
17
|
+
const state = protectedAuditInstallState(readiness);
|
|
18
|
+
if (state === 'ready' || state === 'not_required')
|
|
19
|
+
return { protected_audit: state };
|
|
20
|
+
const reason = readiness.state === 'unavailable' ? readiness.reason : state;
|
|
21
|
+
return {
|
|
22
|
+
protected_audit: state,
|
|
23
|
+
protected_audit_next_step: `Evolver cannot record audit events until the protected audit service is available (${reason}); ${PROTECTED_AUDIT_INSTALL_GUIDE}.`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function protectedAuditNoticeStatePath(evomapHome) {
|
|
27
|
+
return join(evomapHome, 'evolution', 'protected-audit-session-notice.json');
|
|
28
|
+
}
|
|
29
|
+
function decodeNoticeState(text) {
|
|
30
|
+
const data = JSON.parse(text);
|
|
31
|
+
const sessions = data.sessions;
|
|
32
|
+
if (!Array.isArray(sessions) || sessions.length > MAX_NOTIFIED_SESSIONS
|
|
33
|
+
|| sessions.some((key) => typeof key !== 'string' || !/^[a-f0-9]{64}$/.test(key)))
|
|
34
|
+
throw new Error('invalid_audit_notice_state');
|
|
35
|
+
if (data.version === 1)
|
|
36
|
+
return { sessions, pending: {} };
|
|
37
|
+
const pending = data.pending;
|
|
38
|
+
if (data.version !== 2 || !pending || typeof pending !== 'object' || Array.isArray(pending)
|
|
39
|
+
|| Object.entries(pending).some(([key, owner]) => !sessions.includes(key) || typeof owner !== 'string' || !NOTICE_OWNER.test(owner))) {
|
|
40
|
+
throw new Error('invalid_audit_notice_state');
|
|
41
|
+
}
|
|
42
|
+
return { sessions, pending };
|
|
43
|
+
}
|
|
44
|
+
function readNoticeState(path) {
|
|
45
|
+
try {
|
|
46
|
+
return decodeNoticeState(readFileSync(path, 'utf8'));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code === 'ENOENT')
|
|
50
|
+
return { sessions: [], pending: {} };
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function writeOwnedNoticeFile(path, text) {
|
|
55
|
+
const fd = openSync(path, 'wx', 0o600);
|
|
56
|
+
try {
|
|
57
|
+
try {
|
|
58
|
+
writeFileSync(fd, text, 'utf8');
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
closeSync(fd);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
removeNoticeFile(path);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function removeNoticeFile(path) {
|
|
70
|
+
try {
|
|
71
|
+
unlinkSync(path);
|
|
72
|
+
}
|
|
73
|
+
catch { /* The state file remains authoritative. */ }
|
|
74
|
+
}
|
|
75
|
+
function writeNoticeState(path, state) {
|
|
76
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
77
|
+
writeOwnedNoticeFile(temporary, `${JSON.stringify({ version: 2, ...state })}\n`);
|
|
78
|
+
try {
|
|
79
|
+
renameSync(temporary, path);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
removeNoticeFile(temporary);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function applyNoticeSettlement(state, key, owner, outcome) {
|
|
87
|
+
if (state.pending[key] !== owner)
|
|
88
|
+
return false;
|
|
89
|
+
delete state.pending[key];
|
|
90
|
+
if (outcome === 'not_submitted')
|
|
91
|
+
state.sessions.splice(state.sessions.indexOf(key), 1);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function noticeSettlementPath(path, owner) {
|
|
95
|
+
return `${path}.${owner}.settled`;
|
|
96
|
+
}
|
|
97
|
+
function readNoticeSettlement(path, key) {
|
|
98
|
+
try {
|
|
99
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
100
|
+
try {
|
|
101
|
+
const info = fstatSync(fd);
|
|
102
|
+
if (!info.isFile() || info.size > 80)
|
|
103
|
+
return undefined;
|
|
104
|
+
const bytes = Buffer.alloc(80);
|
|
105
|
+
const length = readSync(fd, bytes, 0, bytes.length, 0);
|
|
106
|
+
if (length !== info.size)
|
|
107
|
+
return undefined;
|
|
108
|
+
const receipt = bytes.toString('utf8', 0, length);
|
|
109
|
+
if (receipt === `${key}:written\n`)
|
|
110
|
+
return 'written';
|
|
111
|
+
if (receipt === `${key}:not_submitted\n`)
|
|
112
|
+
return 'not_submitted';
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
closeSync(fd);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch { /* An unavailable receipt cannot authorize replay. */ }
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
function recoverNoticeSettlements(path, state, key) {
|
|
122
|
+
const candidates = state.sessions.length === MAX_NOTIFIED_SESSIONS ? Object.keys(state.pending) : [key];
|
|
123
|
+
const consumed = [];
|
|
124
|
+
for (const session of candidates) {
|
|
125
|
+
const owner = state.pending[session];
|
|
126
|
+
if (!owner)
|
|
127
|
+
continue;
|
|
128
|
+
const receipt = noticeSettlementPath(path, owner);
|
|
129
|
+
const outcome = readNoticeSettlement(receipt, session);
|
|
130
|
+
if (outcome && applyNoticeSettlement(state, session, owner, outcome))
|
|
131
|
+
consumed.push(receipt);
|
|
132
|
+
}
|
|
133
|
+
return consumed;
|
|
134
|
+
}
|
|
135
|
+
function updateNoticeState(path, update, recoveryKey) {
|
|
136
|
+
try {
|
|
137
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
138
|
+
const lockPath = `${path}.lock`;
|
|
139
|
+
const owner = acquireLock(lockPath, { maxTries: 1, waitMs: 0 });
|
|
140
|
+
let changed = false, released = false;
|
|
141
|
+
try {
|
|
142
|
+
const state = readNoticeState(path);
|
|
143
|
+
const consumed = recoveryKey ? recoverNoticeSettlements(path, state, recoveryKey) : [];
|
|
144
|
+
changed = update(state);
|
|
145
|
+
if (changed || consumed.length > 0)
|
|
146
|
+
writeNoticeState(path, state);
|
|
147
|
+
for (const receipt of consumed)
|
|
148
|
+
removeNoticeFile(receipt);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
released = releaseLock(lockPath, owner).released;
|
|
152
|
+
}
|
|
153
|
+
return changed && released;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function settleNotice(path, key, owner, outcome) {
|
|
160
|
+
// The callback can outlive the caller or lose the state lock to another hook.
|
|
161
|
+
// An exclusive receipt preserves the exact outcome without waiting on that lock.
|
|
162
|
+
try {
|
|
163
|
+
writeOwnedNoticeFile(noticeSettlementPath(path, owner), `${key}:${outcome}\n`);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (error.code !== 'EEXIST') {
|
|
167
|
+
updateNoticeState(path, (state) => applyNoticeSettlement(state, key, owner, outcome));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
updateNoticeState(path, () => false, key);
|
|
172
|
+
}
|
|
173
|
+
function claimProtectedAuditSessionNotice(sessionId, readiness, path) {
|
|
174
|
+
if (readiness.state !== 'unavailable' || !sessionId)
|
|
175
|
+
return undefined;
|
|
176
|
+
const key = createHash('sha256').update(sessionId).digest('hex');
|
|
177
|
+
const owner = randomUUID();
|
|
178
|
+
const claimed = updateNoticeState(path, (state) => {
|
|
179
|
+
if (state.sessions.includes(key))
|
|
180
|
+
return false;
|
|
181
|
+
if (state.sessions.length === MAX_NOTIFIED_SESSIONS) {
|
|
182
|
+
// An interrupted write may have delivered bytes. Never evict an unconfirmed reservation.
|
|
183
|
+
const oldestConfirmed = state.sessions.findIndex((session) => !Object.hasOwn(state.pending, session));
|
|
184
|
+
if (oldestConfirmed < 0)
|
|
185
|
+
return false;
|
|
186
|
+
state.sessions.splice(oldestConfirmed, 1);
|
|
187
|
+
}
|
|
188
|
+
state.sessions.push(key);
|
|
189
|
+
state.pending[key] = owner;
|
|
190
|
+
return true;
|
|
191
|
+
}, key);
|
|
192
|
+
if (!claimed)
|
|
193
|
+
return undefined;
|
|
194
|
+
return {
|
|
195
|
+
message: `[evolver] Memory recall and recording are paused: the protected audit service is unavailable (${readiness.reason}); ${PROTECTED_AUDIT_INSTALL_GUIDE}.`,
|
|
196
|
+
settle: (outcome) => settleNotice(path, key, owner, outcome),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** Reserve before attempting one write; only the actual transport acknowledgement confirms it. */
|
|
200
|
+
export async function writeProtectedAuditSessionNotice(sessionId, readiness, path, writer, emptyOutput = '') {
|
|
201
|
+
const notice = claimProtectedAuditSessionNotice(sessionId, readiness, path);
|
|
202
|
+
const text = notice ? `${JSON.stringify({ systemMessage: notice.message })}\n` : emptyOutput;
|
|
203
|
+
if (!text)
|
|
204
|
+
return;
|
|
205
|
+
let settled = false, outputWritten = false;
|
|
206
|
+
const actual = (written) => {
|
|
207
|
+
if (settled)
|
|
208
|
+
return;
|
|
209
|
+
settled = true;
|
|
210
|
+
if (!written)
|
|
211
|
+
return;
|
|
212
|
+
outputWritten = true;
|
|
213
|
+
notice?.settle('written');
|
|
214
|
+
try {
|
|
215
|
+
writer.onOutputWritten?.();
|
|
216
|
+
}
|
|
217
|
+
catch { /* An observer cannot invalidate confirmed stdout. */ }
|
|
218
|
+
};
|
|
219
|
+
try {
|
|
220
|
+
if (writer.stdoutWithSettlement)
|
|
221
|
+
await writer.stdoutWithSettlement(text, actual);
|
|
222
|
+
else if (writer.stdout) {
|
|
223
|
+
await writer.stdout(text);
|
|
224
|
+
actual(true);
|
|
225
|
+
}
|
|
226
|
+
else
|
|
227
|
+
await writeHookStdout(text, { onSettled: actual });
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
// EPIPE, timeout and other post-dispatch errors can follow a partial delivery.
|
|
231
|
+
if (!outputWritten && hookStdoutNotSubmitted(error))
|
|
232
|
+
notice?.settle('not_submitted');
|
|
233
|
+
}
|
|
234
|
+
}
|
package/dist/recall.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
// `<session_id>.jsonl`, so recall matches them by session id (falling back to the most-recent inject for un-stamped
|
|
6
6
|
// events / runtimes with no id). Pure logic lives in evolver-core/ops/recall; this module is the IO glue (read
|
|
7
7
|
// transcript -> turns, resolve genes from the store, pull geneIds off the matching inject event).
|
|
8
|
-
import { readFileSync } from 'node:fs';
|
|
9
8
|
import { basename } from 'node:path';
|
|
10
9
|
import { assetstore, events, ops } from '@evomap/evolver-core';
|
|
11
|
-
import { adapterForPath } from '@evomap/evolver-runtime-adapters';
|
|
10
|
+
import { adapterForPath, readSessionLog } from '@evomap/evolver-runtime-adapters';
|
|
12
11
|
/** Claude Code names a transcript `<session_id>.jsonl`, so the basename (minus extension) is the session id used to
|
|
13
12
|
* match the inject event that produced THIS session (#205). Other runtimes' names simply won't match any stamped
|
|
14
13
|
* sessionId, and the caller falls back to the most-recent inject — safe, never wrong, just less precise. */
|
|
@@ -146,7 +145,7 @@ export async function runRecall(argv, deps = {}) {
|
|
|
146
145
|
}
|
|
147
146
|
let content;
|
|
148
147
|
try {
|
|
149
|
-
content = (deps.readFile ??
|
|
148
|
+
content = (deps.readFile ?? readSessionLog)(transcript);
|
|
150
149
|
}
|
|
151
150
|
catch (e) {
|
|
152
151
|
err(`recall: cannot read ${transcript}: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type RuntimeCapabilityStatus = 'supported' | 'experimental' | 'unsupported';
|
|
2
|
-
type RuntimeCapabilityId = 'claude-code' | 'codex' | 'cursor' | 'gemini' | 'antigravity' | 'kimi' | 'kiro' | 'opencode' | 'generic-chat' | 'llm';
|
|
2
|
+
type RuntimeCapabilityId = 'claude-code' | 'codex' | 'cursor' | 'gemini' | 'antigravity' | 'kimi' | 'workbuddy' | 'dsh' | 'grok' | 'kiro' | 'opencode' | 'generic-chat' | 'llm';
|
|
3
3
|
interface RuntimeCapability {
|
|
4
4
|
status: RuntimeCapabilityStatus;
|
|
5
5
|
evidence: string;
|
|
@@ -59,6 +59,30 @@ export const RUNTIME_CAPABILITY_MATRIX = {
|
|
|
59
59
|
verify: unsupported('no Kimi execution runner exists'),
|
|
60
60
|
resume: unsupported('no verified Kimi resume contract'),
|
|
61
61
|
},
|
|
62
|
+
workbuddy: {
|
|
63
|
+
runtime: 'workbuddy',
|
|
64
|
+
ingest: supported('WorkBuddy ~/.workbuddy/projects JSONL adapter verified against a sanitized real-log golden'),
|
|
65
|
+
inject: unsupported('no Evolver CLI injection installer; live hooks come from evolver-agent-plugin'),
|
|
66
|
+
execute: unsupported('no verified WorkBuddy runner contract'),
|
|
67
|
+
verify: unsupported('no WorkBuddy execution runner exists'),
|
|
68
|
+
resume: unsupported('no verified WorkBuddy resume contract'),
|
|
69
|
+
},
|
|
70
|
+
dsh: {
|
|
71
|
+
runtime: 'dsh',
|
|
72
|
+
ingest: supported('DeepSeek Harness session.v4.jsonl.zstd adapter verified against a sanitized real-log golden; needs Node zstd support'),
|
|
73
|
+
inject: unsupported('no Evolver CLI injection installer; live hooks come from evolver-agent-plugin'),
|
|
74
|
+
execute: unsupported('no verified DeepSeek Harness runner contract'),
|
|
75
|
+
verify: unsupported('no DeepSeek Harness execution runner exists'),
|
|
76
|
+
resume: unsupported('no verified DeepSeek Harness resume contract'),
|
|
77
|
+
},
|
|
78
|
+
grok: {
|
|
79
|
+
runtime: 'grok',
|
|
80
|
+
ingest: supported('Grok CLI chat_history.jsonl adapter verified against a sanitized real-log golden'),
|
|
81
|
+
inject: unsupported('no Evolver CLI injection installer; live hooks come from evolver-agent-plugin'),
|
|
82
|
+
execute: unsupported('no verified Grok runner contract'),
|
|
83
|
+
verify: unsupported('no Grok execution runner exists'),
|
|
84
|
+
resume: unsupported('no verified Grok resume contract'),
|
|
85
|
+
},
|
|
62
86
|
kiro: {
|
|
63
87
|
runtime: 'kiro',
|
|
64
88
|
ingest: unsupported('transcript adapter is not registered; no real-log golden fixture'),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
|
-
import { adapterForPath, isCursorStateVscdbPath, parseJsonlLinesWithStats, parseCursorStateVscdb, stripUtf8Bom, } from '@evomap/evolver-runtime-adapters';
|
|
4
|
+
import { adapterForPath, isCursorStateVscdbPath, parseJsonlLinesWithStats, parseCursorStateVscdb, readSessionLog, stripUtf8Bom, } from '@evomap/evolver-runtime-adapters';
|
|
5
5
|
const EMPTY_DIAGNOSTICS = { rowsScanned: 0, rowsRead: 0, invalidJson: 0 };
|
|
6
6
|
function canonicalNativeSessionSource(path, agent, nativeSessionHome) {
|
|
7
7
|
const runtimeRoot = agent === 'claude-code'
|
|
@@ -46,7 +46,7 @@ function diagnosticsForRuntimeSource(raw) {
|
|
|
46
46
|
return parseJsonlLinesWithStats(raw).stats;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource =
|
|
49
|
+
export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = readSessionLog, nativeSessionHome = homedir()) {
|
|
50
50
|
const absPath = resolve(path);
|
|
51
51
|
if (isCursorStateVscdbPath(absPath)) {
|
|
52
52
|
const sources = parseCursorStateVscdb(absPath)
|
|
@@ -103,6 +103,6 @@ export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = (p)
|
|
|
103
103
|
diagnostics: diagnosticsForRuntimeSource(raw),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
export function parseRuntimeSessionSources(path, readSource =
|
|
106
|
+
export function parseRuntimeSessionSources(path, readSource = readSessionLog, nativeSessionHome = homedir()) {
|
|
107
107
|
return parseRuntimeSessionSourcesWithDiagnostics(path, readSource, nativeSessionHome).sources;
|
|
108
108
|
}
|