@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.5

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.
@@ -7,10 +7,16 @@ export interface ImportReport {
7
7
  deduped: number;
8
8
  sidecarExtensions: number;
9
9
  memoryGraphArchived: boolean;
10
+ memoryGraphImported: number;
11
+ memoryGraphDeferred: boolean;
10
12
  candidatesSkipped: boolean;
11
13
  }
12
14
  /**
13
15
  * v1→v2 只读迁移(M8-2). 只读 v1(无双写); 冻结存量 asset_id; 非 schema 字段(avoid)落 sidecar;
14
16
  * memory_graph 不强转(语义不符)→ 归档只读; candidates 候选池不属 wire 资产 → 跳过.
15
17
  */
16
- export declare function importV1(v1Dir: string, store: assetstore.LocalJsonlProvider, outDir: string): Promise<ImportReport>;
18
+ export interface ImportV1Options {
19
+ workspace?: string;
20
+ userId?: string;
21
+ }
22
+ export declare function importV1(v1Dir: string, store: assetstore.LocalJsonlProvider, outDir: string, options?: ImportV1Options): Promise<ImportReport>;
@@ -1,10 +1,13 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { createReadStream } from 'node:fs';
2
- import { existsSync, mkdirSync, appendFileSync, copyFileSync } from 'node:fs';
3
- import { join, dirname } from 'node:path';
3
+ import { appendFileSync, closeSync, constants, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readSync, realpathSync, unlinkSync, writeFileSync, writeSync, } from 'node:fs';
4
+ import { basename, dirname, join, resolve, sep } from 'node:path';
4
5
  import { assetstore } from '@evomap/evolver-core';
5
6
  import { mapV1Asset } from './fieldMap.js';
7
+ import { LocalMemoryGraph, MemoryGraphBusyError, MemoryGraphImportStateRejectedError, resolveLocalMemoryUserId, } from '../localMemoryGraph.js';
6
8
  const FILES = { Gene: 'genes.jsonl', Capsule: 'capsules.jsonl', EvolutionEvent: 'events.jsonl' };
7
9
  const DEFAULT_IMPORT_JSONL_MAX_LINE_BYTES = 16 * 1024 * 1024;
10
+ let migrationArchiveNonce = 0;
8
11
  function maxJsonlLineBytes() {
9
12
  const raw = Number(process.env['EVOLVER_IMPORT_JSONL_MAX_LINE_BYTES']);
10
13
  return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : DEFAULT_IMPORT_JSONL_MAX_LINE_BYTES;
@@ -71,15 +74,11 @@ async function* readJsonl(path) {
71
74
  for (const record of finish())
72
75
  yield record;
73
76
  }
74
- /**
75
- * v1→v2 只读迁移(M8-2). 只读 v1(无双写); 冻结存量 asset_id; 非 schema 字段(avoid)落 sidecar;
76
- * memory_graph 不强转(语义不符)→ 归档只读; candidates 候选池不属 wire 资产 → 跳过.
77
- */
78
- export async function importV1(v1Dir, store, outDir) {
77
+ export async function importV1(v1Dir, store, outDir, options = {}) {
79
78
  const sidecarPath = join(outDir, 'migration', 'v1_extensions.jsonl');
80
79
  const rep = {
81
80
  imported: { Gene: 0, Capsule: 0, EvolutionEvent: 0 }, frozen: 0, recomputed: 0, deduped: 0,
82
- sidecarExtensions: 0, memoryGraphArchived: false, candidatesSkipped: false,
81
+ sidecarExtensions: 0, memoryGraphArchived: false, memoryGraphImported: 0, memoryGraphDeferred: false, candidatesSkipped: false,
83
82
  };
84
83
  const gepDir = join(v1Dir, 'assets', 'gep');
85
84
  for (const kind of ['Gene', 'Capsule', 'EvolutionEvent']) {
@@ -103,16 +102,138 @@ export async function importV1(v1Dir, store, outDir) {
103
102
  }
104
103
  }
105
104
  }
106
- // memory_graph: 不迁移成 EvolutionEvent(缺 required + 无 intent/genes_used 语义, 强转=污染谱系). 归档只读.
105
+ // memory_graph remains a sidecar: never convert it into EvolutionEvent or mutate Gene/Capsule identity.
107
106
  const mg = join(v1Dir, 'memory', 'evolution', 'memory_graph.jsonl');
108
- if (existsSync(mg)) {
107
+ if (secureRegularFileWithin(v1Dir, mg)) {
109
108
  const dest = join(outDir, 'migration', 'legacy_memory_graph.jsonl');
110
109
  mkdirSync(dirname(dest), { recursive: true });
111
- copyFileSync(mg, dest);
110
+ archiveRegularFile(mg, dest);
112
111
  rep.memoryGraphArchived = true;
112
+ const workspace = options.workspace ? canonicalDirectory(options.workspace) : null;
113
+ if (!workspace) {
114
+ rep.memoryGraphDeferred = true;
115
+ }
116
+ else {
117
+ const source = realpathSync(mg);
118
+ const userId = options.userId ?? resolveLocalMemoryUserId();
119
+ const marker = scopedMemoryGraphMarker(outDir, workspace, userId, source);
120
+ if (!existsSync(marker)) {
121
+ const graph = new LocalMemoryGraph({ dir: join(outDir, 'evolution'), userId });
122
+ try {
123
+ for await (const record of readJsonl(mg)) {
124
+ if (graph.importV1Outcome(workspace, record, source))
125
+ rep.memoryGraphImported += 1;
126
+ }
127
+ }
128
+ catch (error) {
129
+ if (!(error instanceof MemoryGraphImportStateRejectedError) && !(error instanceof MemoryGraphBusyError))
130
+ throw error;
131
+ rep.memoryGraphDeferred = true;
132
+ }
133
+ if (!rep.memoryGraphDeferred)
134
+ writeFileSync(marker, `${rep.memoryGraphImported}\n`, { mode: 0o600 });
135
+ }
136
+ }
113
137
  }
114
138
  // candidates 候选池非 wire 资产 → 不迁移(留作 selection 输入)
115
139
  if (existsSync(join(gepDir, 'candidates.jsonl')))
116
140
  rep.candidatesSkipped = true;
117
141
  return rep;
142
+ }
143
+ function canonicalDirectory(path) {
144
+ try {
145
+ const absolute = resolve(path);
146
+ const stat = lstatSync(absolute);
147
+ return stat.isDirectory() && !stat.isSymbolicLink() ? realpathSync(absolute) : null;
148
+ }
149
+ catch {
150
+ return null;
151
+ }
152
+ }
153
+ function scopedMemoryGraphMarker(outDir, workspace, userId, source) {
154
+ const scope = createHash('sha256').update(JSON.stringify({ workspace, userId, source })).digest('hex');
155
+ return join(outDir, 'migration', `v1_memory_graph_import.${scope}.complete`);
156
+ }
157
+ function secureRegularFileWithin(root, path) {
158
+ try {
159
+ const absoluteRoot = resolve(root);
160
+ const absolutePath = resolve(path);
161
+ const rootStat = lstatSync(absoluteRoot);
162
+ const fileStat = lstatSync(absolutePath);
163
+ if (!rootStat.isDirectory() || rootStat.isSymbolicLink() || !fileStat.isFile() || fileStat.isSymbolicLink())
164
+ return false;
165
+ const canonicalRoot = realpathSync(absoluteRoot);
166
+ const canonicalPath = realpathSync(absolutePath);
167
+ return canonicalPath.startsWith(canonicalRoot.endsWith(sep) ? canonicalRoot : `${canonicalRoot}${sep}`);
168
+ }
169
+ catch {
170
+ return false;
171
+ }
172
+ }
173
+ function archiveRegularFile(source, destination) {
174
+ if (existsSync(destination)) {
175
+ const existing = lstatSync(destination);
176
+ if (!existing.isFile() || existing.isSymbolicLink())
177
+ throw new Error('memory_graph_archive_path_rejected');
178
+ return;
179
+ }
180
+ const sourceFd = openSync(source, constants.O_RDONLY | constants.O_NOFOLLOW);
181
+ const temp = join(dirname(destination), `.${basename(destination)}.${process.pid}.${Date.now()}.${migrationArchiveNonce++}.tmp`);
182
+ let tempFd;
183
+ let copyError;
184
+ try {
185
+ if (!fstatSync(sourceFd).isFile())
186
+ throw new Error('memory_graph_source_path_rejected');
187
+ tempFd = openSync(temp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
188
+ const buffer = Buffer.alloc(64 * 1024);
189
+ for (;;) {
190
+ const bytesRead = readSync(sourceFd, buffer, 0, buffer.length, null);
191
+ if (bytesRead === 0)
192
+ break;
193
+ let offset = 0;
194
+ while (offset < bytesRead)
195
+ offset += writeSync(tempFd, buffer, offset, bytesRead - offset);
196
+ }
197
+ fsyncSync(tempFd);
198
+ }
199
+ catch (error) {
200
+ copyError = error;
201
+ }
202
+ finally {
203
+ closeSync(sourceFd);
204
+ if (tempFd !== undefined)
205
+ closeSync(tempFd);
206
+ }
207
+ if (copyError !== undefined) {
208
+ try {
209
+ if (existsSync(temp))
210
+ unlinkSync(temp);
211
+ }
212
+ catch {
213
+ // Preserve the source/copy failure; cleanup is best-effort.
214
+ }
215
+ throw copyError;
216
+ }
217
+ try {
218
+ if (existsSync(destination)) {
219
+ const existing = lstatSync(destination);
220
+ if (!existing.isFile() || existing.isSymbolicLink())
221
+ throw new Error('memory_graph_archive_path_rejected');
222
+ unlinkSync(temp);
223
+ return;
224
+ }
225
+ // A same-directory hard link publishes without replacing a path created by a concurrent process.
226
+ linkSync(temp, destination);
227
+ unlinkSync(temp);
228
+ }
229
+ catch (error) {
230
+ try {
231
+ if (existsSync(temp))
232
+ unlinkSync(temp);
233
+ }
234
+ catch {
235
+ // Preserve the publication failure; cleanup is best-effort.
236
+ }
237
+ throw error;
238
+ }
118
239
  }
@@ -0,0 +1,18 @@
1
+ type RuntimeCapabilityStatus = 'supported' | 'experimental' | 'unsupported';
2
+ type RuntimeCapabilityId = 'claude-code' | 'codex' | 'cursor' | 'gemini' | 'antigravity' | 'kimi' | 'kiro' | 'opencode' | 'generic-chat';
3
+ interface RuntimeCapability {
4
+ status: RuntimeCapabilityStatus;
5
+ evidence: string;
6
+ }
7
+ interface RuntimeCapabilityEntry {
8
+ runtime: RuntimeCapabilityId;
9
+ ingest: RuntimeCapability;
10
+ inject: RuntimeCapability;
11
+ execute: RuntimeCapability;
12
+ verify: RuntimeCapability;
13
+ resume: RuntimeCapability;
14
+ }
15
+ /** Product-level runtime matrix. A transcript parser never implies execution, verification, or resumability. */
16
+ export declare const RUNTIME_CAPABILITY_MATRIX: Readonly<Record<RuntimeCapabilityId, RuntimeCapabilityEntry>>;
17
+ export declare function runtimeCapabilities(): RuntimeCapabilityEntry[];
18
+ export {};
@@ -0,0 +1,81 @@
1
+ const supported = (evidence) => ({ status: 'supported', evidence });
2
+ const experimental = (evidence) => ({ status: 'experimental', evidence });
3
+ const unsupported = (evidence) => ({ status: 'unsupported', evidence });
4
+ /** Product-level runtime matrix. A transcript parser never implies execution, verification, or resumability. */
5
+ export const RUNTIME_CAPABILITY_MATRIX = {
6
+ 'claude-code': {
7
+ runtime: 'claude-code',
8
+ ingest: supported('normalized Claude Code JSONL adapter'),
9
+ inject: supported('MCP registration plus SessionStart hook'),
10
+ execute: supported('run-verified claude -p runner'),
11
+ verify: supported('git diff proof plus external validation hook'),
12
+ resume: unsupported('cycle runner does not bind ingested session ids to claude resume'),
13
+ },
14
+ codex: {
15
+ runtime: 'codex',
16
+ ingest: supported('normalized Codex rollout adapter'),
17
+ inject: supported('project MCP config plus SessionStart hook'),
18
+ execute: supported('run-verified codex exec runner'),
19
+ verify: supported('git diff proof plus external validation hook'),
20
+ resume: unsupported('cycle runner starts a new codex exec session'),
21
+ },
22
+ cursor: {
23
+ runtime: 'cursor',
24
+ ingest: supported('Cursor transcript and state.vscdb adapters'),
25
+ inject: supported('always-on project rules injection'),
26
+ execute: experimental('CLI flags are contract-tested but the repository still treats the runner as a scaffold'),
27
+ verify: supported('git diff proof plus external validation hook'),
28
+ resume: unsupported('no verified headless session resume mapping'),
29
+ },
30
+ gemini: {
31
+ runtime: 'gemini',
32
+ ingest: supported('normalized Gemini CLI session adapter'),
33
+ inject: unsupported('no Evolver Gemini injection installer'),
34
+ execute: experimental('hermetic Gemini CLI 0.46.0 headless JSON contract exists, but provider-backed live E2E smoke is not complete'),
35
+ verify: experimental('hermetic structured-result and git-diff proof contract exists, but provider-backed live E2E verification is not complete'),
36
+ resume: unsupported('Gemini resume accepts latest/index; ingested UUIDs cannot be mapped reliably'),
37
+ },
38
+ antigravity: {
39
+ runtime: 'antigravity',
40
+ ingest: supported('strict Antigravity transcript adapter'),
41
+ inject: supported('user-level MCP tool discovery only; no SessionStart hook'),
42
+ execute: unsupported('agy is not installed or live-verified in the implementation environment'),
43
+ verify: unsupported('no Antigravity runner result is wired to state proof'),
44
+ resume: unsupported('no verified transcript-id to agy resume contract'),
45
+ },
46
+ kimi: {
47
+ runtime: 'kimi',
48
+ ingest: supported('normalized Kimi session adapter'),
49
+ inject: unsupported('no Evolver Kimi injection installer'),
50
+ execute: unsupported('no verified Kimi runner contract'),
51
+ verify: unsupported('no Kimi execution runner exists'),
52
+ resume: unsupported('no verified Kimi resume contract'),
53
+ },
54
+ kiro: {
55
+ runtime: 'kiro',
56
+ ingest: supported('normalized Kiro session adapter'),
57
+ inject: unsupported('automatic Kiro setup is not available on the current main branch'),
58
+ execute: unsupported('no verified Kiro runner contract'),
59
+ verify: unsupported('no Kiro execution runner exists'),
60
+ resume: unsupported('no verified Kiro resume contract'),
61
+ },
62
+ opencode: {
63
+ runtime: 'opencode',
64
+ ingest: supported('normalized OpenCode session adapter'),
65
+ inject: unsupported('automatic OpenCode setup is not available on the current main branch'),
66
+ execute: unsupported('no verified OpenCode runner contract'),
67
+ verify: unsupported('no OpenCode execution runner exists'),
68
+ resume: unsupported('no verified OpenCode resume contract'),
69
+ },
70
+ 'generic-chat': {
71
+ runtime: 'generic-chat',
72
+ ingest: supported('normalized standard OpenAI and Anthropic message JSON/JSONL adapter'),
73
+ inject: unsupported('generic transcript interchange has no Evolver injection installer'),
74
+ execute: unsupported('generic chat transcripts do not identify a runnable provider or CLI contract'),
75
+ verify: unsupported('no provider-backed execution runner exists for generic chat transcripts'),
76
+ resume: unsupported('no provider or session identity contract exists for generic chat transcripts'),
77
+ },
78
+ };
79
+ export function runtimeCapabilities() {
80
+ return Object.values(RUNTIME_CAPABILITY_MATRIX);
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "evolver CLI (status/watch/cycles/rebuild-views/...)",
@@ -20,12 +20,16 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@evomap/evolver-core": "2.0.0-beta.2",
24
- "@evomap/evolver-adapter-public": "2.0.0-beta.2",
25
- "@evomap/evolver-mcp": "2.0.0-beta.2",
26
- "@evomap/evolver-proxy": "2.0.0-beta.2",
27
- "@evomap/evolver-runtime-adapters": "2.0.0-beta.2",
28
- "@evomap/evolver-webui": "2.0.0-beta.2"
23
+ "@evomap/evolver-core": "2.0.0-beta.5",
24
+ "@evomap/evolver-adapter-public": "2.0.0-beta.5",
25
+ "@evomap/evolver-mcp": "2.0.0-beta.5",
26
+ "@evomap/evolver-proxy": "2.0.0-beta.5",
27
+ "@evomap/evolver-runtime-adapters": "2.0.0-beta.5",
28
+ "@evomap/evolver-webui": "2.0.0-beta.5"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/EvoMap/evolver.git"
29
33
  },
30
34
  "publishConfig": {
31
35
  "access": "public",