rvlite 0.2.1 → 0.2.2
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/README.md +62 -0
- package/dist/cli-rvf.d.ts +57 -0
- package/dist/cli-rvf.d.ts.map +1 -0
- package/dist/cli-rvf.js +271 -0
- package/dist/cli-rvf.js.map +1 -0
- package/dist/index.d.ts +351 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2123 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2086 -0
- package/dist/wasm/package.json +2 -3
- package/dist/wasm/rvlite.d.ts +5 -5
- package/dist/wasm/rvlite.js +17 -16
- package/dist/wasm/rvlite_bg.wasm +0 -0
- package/dist/wasm/rvlite_bg.wasm.d.ts +5 -5
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -197,6 +197,68 @@ const similar = await memory.query("What was the weather question?", queryEmbedd
|
|
|
197
197
|
const related = await memory.findRelated("conv-1", 2);
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
+
## RVF Storage Backend
|
|
201
|
+
|
|
202
|
+
RvLite can use [RVF (RuVector Format)](https://github.com/ruvnet/ruvector/tree/main/crates/rvf) as a persistent storage backend. When the optional `@ruvector/rvf-wasm` package is installed, rvlite gains file-backed persistence using the `.rvf` cognitive container format.
|
|
203
|
+
|
|
204
|
+
### Install
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm install rvlite @ruvector/rvf-wasm
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Usage
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { createRvLite } from 'rvlite';
|
|
214
|
+
|
|
215
|
+
// rvlite auto-detects @ruvector/rvf-wasm when installed
|
|
216
|
+
const db = await createRvLite({ dimensions: 384 });
|
|
217
|
+
|
|
218
|
+
// All operations persist to RVF format
|
|
219
|
+
await db.insert([0.1, 0.2, ...], { text: "Hello world" });
|
|
220
|
+
const results = await db.search([0.1, 0.2, ...], 5);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Platform Support
|
|
224
|
+
|
|
225
|
+
The RVF backend works everywhere rvlite runs:
|
|
226
|
+
|
|
227
|
+
| Platform | RVF Backend | Notes |
|
|
228
|
+
|----------|-------------|-------|
|
|
229
|
+
| Node.js (Linux, macOS, Windows) | Native or WASM | Auto-detected |
|
|
230
|
+
| Browser (Chrome, Firefox, Safari) | WASM | IndexedDB + RVF |
|
|
231
|
+
| Deno | WASM | Via `npm:` specifier |
|
|
232
|
+
| Cloudflare Workers / Edge | WASM | Stateless queries |
|
|
233
|
+
|
|
234
|
+
### Rust Feature Flag
|
|
235
|
+
|
|
236
|
+
If building from source, enable the `rvf-backend` feature in `crates/rvlite`:
|
|
237
|
+
|
|
238
|
+
```toml
|
|
239
|
+
[dependencies]
|
|
240
|
+
rvlite = { version = "0.1", features = ["rvf-backend"] }
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
This enables epoch-based reconciliation between RVF and metadata stores:
|
|
244
|
+
- Monotonic epoch counter shared between RVF and metadata
|
|
245
|
+
- On startup, compares epochs and rebuilds the lagging side
|
|
246
|
+
- RVF file is source of truth; metadata (IndexedDB) is rebuildable cache
|
|
247
|
+
|
|
248
|
+
### Download Example .rvf Files
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Download pre-built examples to test with
|
|
252
|
+
curl -LO https://raw.githubusercontent.com/ruvnet/ruvector/main/examples/rvf/output/basic_store.rvf
|
|
253
|
+
curl -LO https://raw.githubusercontent.com/ruvnet/ruvector/main/examples/rvf/output/semantic_search.rvf
|
|
254
|
+
curl -LO https://raw.githubusercontent.com/ruvnet/ruvector/main/examples/rvf/output/agent_memory.rvf
|
|
255
|
+
|
|
256
|
+
# 45 examples available at:
|
|
257
|
+
# https://github.com/ruvnet/ruvector/tree/main/examples/rvf/output
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
200
262
|
## Integration with claude-flow
|
|
201
263
|
|
|
202
264
|
RvLite can enhance claude-flow's memory system with semantic search:
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cli-rvf.ts - RVF migration and rebuild CLI commands
|
|
3
|
+
*
|
|
4
|
+
* Two commands:
|
|
5
|
+
* rvf-migrate — Convert existing rvlite data to RVF format
|
|
6
|
+
* rvf-rebuild — Reconstruct metadata from an RVF file
|
|
7
|
+
*
|
|
8
|
+
* Usage (via the rvlite CLI binary or directly):
|
|
9
|
+
* rvlite rvf-migrate --source .rvlite/db.json --dest data.rvf [--dry-run] [--verify]
|
|
10
|
+
* rvlite rvf-rebuild --source data.rvf [--dest .rvlite/db.json]
|
|
11
|
+
*/
|
|
12
|
+
/** Summary report returned by migrate / rebuild. */
|
|
13
|
+
export interface MigrateReport {
|
|
14
|
+
vectorsMigrated: number;
|
|
15
|
+
triplesMigrated: number;
|
|
16
|
+
graphNodesMigrated: number;
|
|
17
|
+
graphEdgesMigrated: number;
|
|
18
|
+
skipped: boolean;
|
|
19
|
+
dryRun: boolean;
|
|
20
|
+
verifyPassed?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface RebuildReport {
|
|
23
|
+
vectorsRecovered: number;
|
|
24
|
+
triplesRecovered: number;
|
|
25
|
+
graphNodesRecovered: number;
|
|
26
|
+
graphEdgesRecovered: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert an existing rvlite JSON database into an RVF file.
|
|
30
|
+
*
|
|
31
|
+
* @param sourcePath - Path to the rvlite JSON database (e.g., .rvlite/db.json).
|
|
32
|
+
* @param destPath - Destination path for the RVF file.
|
|
33
|
+
* @param options - Migration options.
|
|
34
|
+
* @returns A report summarising the migration.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rvfMigrate(sourcePath: string, destPath: string, options?: {
|
|
37
|
+
dryRun?: boolean;
|
|
38
|
+
verify?: boolean;
|
|
39
|
+
}): Promise<MigrateReport>;
|
|
40
|
+
/**
|
|
41
|
+
* Reconstruct metadata from an RVF file.
|
|
42
|
+
*
|
|
43
|
+
* Reads the RVF envelope, extracts vectors, and rebuilds
|
|
44
|
+
* SQL / Cypher / SPARQL metadata from vector metadata fields.
|
|
45
|
+
*
|
|
46
|
+
* @param sourcePath - Path to the RVF file.
|
|
47
|
+
* @param destPath - Optional destination for the rebuilt JSON state.
|
|
48
|
+
* @returns A report summarising the recovered data.
|
|
49
|
+
*/
|
|
50
|
+
export declare function rvfRebuild(sourcePath: string, destPath?: string): Promise<RebuildReport>;
|
|
51
|
+
/**
|
|
52
|
+
* Register rvf-migrate and rvf-rebuild commands on a Commander program
|
|
53
|
+
* instance. This allows the main rvlite CLI to integrate these commands
|
|
54
|
+
* without duplicating code.
|
|
55
|
+
*/
|
|
56
|
+
export declare function registerRvfCommands(program: any): void;
|
|
57
|
+
//# sourceMappingURL=cli-rvf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-rvf.d.ts","sourceRoot":"","sources":["../src/cli-rvf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiCH,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAcD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,OAAO,CAAC,aAAa,CAAC,CAgGxB;AAID;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAyFxB;AAID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAiEtD"}
|
package/dist/cli-rvf.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cli-rvf.ts - RVF migration and rebuild CLI commands
|
|
3
|
+
*
|
|
4
|
+
* Two commands:
|
|
5
|
+
* rvf-migrate — Convert existing rvlite data to RVF format
|
|
6
|
+
* rvf-rebuild — Reconstruct metadata from an RVF file
|
|
7
|
+
*
|
|
8
|
+
* Usage (via the rvlite CLI binary or directly):
|
|
9
|
+
* rvlite rvf-migrate --source .rvlite/db.json --dest data.rvf [--dry-run] [--verify]
|
|
10
|
+
* rvlite rvf-rebuild --source data.rvf [--dest .rvlite/db.json]
|
|
11
|
+
*/
|
|
12
|
+
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
13
|
+
function vectorsClose(a, b, tolerance) {
|
|
14
|
+
if (a.length !== b.length)
|
|
15
|
+
return false;
|
|
16
|
+
for (let i = 0; i < a.length; i++) {
|
|
17
|
+
if (Math.abs(a[i] - b[i]) > tolerance)
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
// ── Migrate ──────────────────────────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* Convert an existing rvlite JSON database into an RVF file.
|
|
25
|
+
*
|
|
26
|
+
* @param sourcePath - Path to the rvlite JSON database (e.g., .rvlite/db.json).
|
|
27
|
+
* @param destPath - Destination path for the RVF file.
|
|
28
|
+
* @param options - Migration options.
|
|
29
|
+
* @returns A report summarising the migration.
|
|
30
|
+
*/
|
|
31
|
+
export async function rvfMigrate(sourcePath, destPath, options = {}) {
|
|
32
|
+
const fs = await import('fs');
|
|
33
|
+
if (!fs.existsSync(sourcePath)) {
|
|
34
|
+
throw new Error(`Source file not found: ${sourcePath}`);
|
|
35
|
+
}
|
|
36
|
+
const raw = fs.readFileSync(sourcePath, 'utf-8');
|
|
37
|
+
const state = JSON.parse(raw);
|
|
38
|
+
// Idempotency: if dest already exists and is a valid RVF file whose
|
|
39
|
+
// payload matches the source, treat as a no-op.
|
|
40
|
+
if (fs.existsSync(destPath)) {
|
|
41
|
+
try {
|
|
42
|
+
const existing = JSON.parse(fs.readFileSync(destPath, 'utf-8'));
|
|
43
|
+
if (existing.magic === 'RVF1') {
|
|
44
|
+
const existingVecCount = Object.keys(existing.payload?.vectors ?? {}).length;
|
|
45
|
+
const sourceVecCount = Object.keys(state.vectors ?? {}).length;
|
|
46
|
+
if (existingVecCount === sourceVecCount) {
|
|
47
|
+
return {
|
|
48
|
+
vectorsMigrated: 0,
|
|
49
|
+
triplesMigrated: 0,
|
|
50
|
+
graphNodesMigrated: 0,
|
|
51
|
+
graphEdgesMigrated: 0,
|
|
52
|
+
skipped: true,
|
|
53
|
+
dryRun: options.dryRun ?? false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// File exists but is not valid RVF — proceed with migration.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const vectorCount = Object.keys(state.vectors ?? {}).length;
|
|
63
|
+
const tripleCount = (state.triples ?? []).length;
|
|
64
|
+
const nodeCount = Object.keys(state.graph?.nodes ?? {}).length;
|
|
65
|
+
const edgeCount = Object.keys(state.graph?.edges ?? {}).length;
|
|
66
|
+
if (options.dryRun) {
|
|
67
|
+
return {
|
|
68
|
+
vectorsMigrated: vectorCount,
|
|
69
|
+
triplesMigrated: tripleCount,
|
|
70
|
+
graphNodesMigrated: nodeCount,
|
|
71
|
+
graphEdgesMigrated: edgeCount,
|
|
72
|
+
skipped: false,
|
|
73
|
+
dryRun: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Build the RVF envelope.
|
|
77
|
+
const envelope = {
|
|
78
|
+
rvf_version: 1,
|
|
79
|
+
magic: 'RVF1',
|
|
80
|
+
created_at: new Date().toISOString(),
|
|
81
|
+
dimensions: state.config?.dimensions ?? 384,
|
|
82
|
+
distance_metric: state.config?.metric ?? 'cosine',
|
|
83
|
+
payload: state,
|
|
84
|
+
};
|
|
85
|
+
const path = await import('path');
|
|
86
|
+
const dir = path.dirname(destPath);
|
|
87
|
+
if (dir && !fs.existsSync(dir)) {
|
|
88
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
89
|
+
}
|
|
90
|
+
fs.writeFileSync(destPath, JSON.stringify(envelope, null, 2), 'utf-8');
|
|
91
|
+
// Optionally verify round-trip fidelity.
|
|
92
|
+
let verifyPassed;
|
|
93
|
+
if (options.verify) {
|
|
94
|
+
const reRead = JSON.parse(fs.readFileSync(destPath, 'utf-8'));
|
|
95
|
+
verifyPassed = true;
|
|
96
|
+
for (const [id, entry] of Object.entries(state.vectors ?? {})) {
|
|
97
|
+
const rvfEntry = reRead.payload.vectors?.[id];
|
|
98
|
+
if (!rvfEntry) {
|
|
99
|
+
verifyPassed = false;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (!vectorsClose(entry.vector, rvfEntry.vector, 1e-6)) {
|
|
103
|
+
verifyPassed = false;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
vectorsMigrated: vectorCount,
|
|
110
|
+
triplesMigrated: tripleCount,
|
|
111
|
+
graphNodesMigrated: nodeCount,
|
|
112
|
+
graphEdgesMigrated: edgeCount,
|
|
113
|
+
skipped: false,
|
|
114
|
+
dryRun: false,
|
|
115
|
+
verifyPassed,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ── Rebuild ──────────────────────────────────────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Reconstruct metadata from an RVF file.
|
|
121
|
+
*
|
|
122
|
+
* Reads the RVF envelope, extracts vectors, and rebuilds
|
|
123
|
+
* SQL / Cypher / SPARQL metadata from vector metadata fields.
|
|
124
|
+
*
|
|
125
|
+
* @param sourcePath - Path to the RVF file.
|
|
126
|
+
* @param destPath - Optional destination for the rebuilt JSON state.
|
|
127
|
+
* @returns A report summarising the recovered data.
|
|
128
|
+
*/
|
|
129
|
+
export async function rvfRebuild(sourcePath, destPath) {
|
|
130
|
+
const fs = await import('fs');
|
|
131
|
+
if (!fs.existsSync(sourcePath)) {
|
|
132
|
+
throw new Error(`RVF file not found: ${sourcePath}`);
|
|
133
|
+
}
|
|
134
|
+
const raw = fs.readFileSync(sourcePath, 'utf-8');
|
|
135
|
+
const envelope = JSON.parse(raw);
|
|
136
|
+
if (envelope.magic !== 'RVF1') {
|
|
137
|
+
throw new Error(`Invalid RVF file: expected magic "RVF1", got "${envelope.magic}"`);
|
|
138
|
+
}
|
|
139
|
+
const state = envelope.payload;
|
|
140
|
+
// Rebuild graph nodes from vectors that have graph-like metadata.
|
|
141
|
+
const recoveredNodes = {};
|
|
142
|
+
const recoveredEdges = {};
|
|
143
|
+
const recoveredTriples = [];
|
|
144
|
+
for (const [id, entry] of Object.entries(state.vectors ?? {})) {
|
|
145
|
+
const meta = entry.metadata;
|
|
146
|
+
if (!meta)
|
|
147
|
+
continue;
|
|
148
|
+
// Recover graph nodes: metadata with a `_label` field.
|
|
149
|
+
if (typeof meta._label === 'string') {
|
|
150
|
+
recoveredNodes[id] = { label: meta._label, properties: meta };
|
|
151
|
+
}
|
|
152
|
+
// Recover graph edges: metadata with `_from` and `_to`.
|
|
153
|
+
if (typeof meta._from === 'string' && typeof meta._to === 'string') {
|
|
154
|
+
recoveredEdges[id] = {
|
|
155
|
+
from: meta._from,
|
|
156
|
+
to: meta._to,
|
|
157
|
+
type: meta._type ?? 'RELATED',
|
|
158
|
+
properties: meta,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Recover triples: metadata with `_subject`, `_predicate`, `_object`.
|
|
162
|
+
if (typeof meta._subject === 'string' &&
|
|
163
|
+
typeof meta._predicate === 'string' &&
|
|
164
|
+
typeof meta._object === 'string') {
|
|
165
|
+
recoveredTriples.push({
|
|
166
|
+
subject: meta._subject,
|
|
167
|
+
predicate: meta._predicate,
|
|
168
|
+
object: meta._object,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Merge recovered data with any existing data in the envelope.
|
|
173
|
+
const existingTriples = state.triples ?? [];
|
|
174
|
+
const allTriples = [...existingTriples, ...recoveredTriples];
|
|
175
|
+
const existingNodes = state.graph?.nodes ?? {};
|
|
176
|
+
const existingEdges = state.graph?.edges ?? {};
|
|
177
|
+
const allNodes = { ...existingNodes, ...recoveredNodes };
|
|
178
|
+
const allEdges = { ...existingEdges, ...recoveredEdges };
|
|
179
|
+
const rebuiltState = {
|
|
180
|
+
vectors: state.vectors ?? {},
|
|
181
|
+
graph: { nodes: allNodes, edges: allEdges },
|
|
182
|
+
triples: allTriples,
|
|
183
|
+
nextId: state.nextId ?? Object.keys(state.vectors ?? {}).length + 1,
|
|
184
|
+
config: {
|
|
185
|
+
dimensions: envelope.dimensions,
|
|
186
|
+
metric: envelope.distance_metric,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
if (destPath) {
|
|
190
|
+
const path = await import('path');
|
|
191
|
+
const dir = path.dirname(destPath);
|
|
192
|
+
if (dir && !fs.existsSync(dir)) {
|
|
193
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
194
|
+
}
|
|
195
|
+
fs.writeFileSync(destPath, JSON.stringify(rebuiltState, null, 2), 'utf-8');
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
vectorsRecovered: Object.keys(state.vectors ?? {}).length,
|
|
199
|
+
triplesRecovered: allTriples.length,
|
|
200
|
+
graphNodesRecovered: Object.keys(allNodes).length,
|
|
201
|
+
graphEdgesRecovered: Object.keys(allEdges).length,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// ── CLI Entry Point ──────────────────────────────────────────────────────
|
|
205
|
+
/**
|
|
206
|
+
* Register rvf-migrate and rvf-rebuild commands on a Commander program
|
|
207
|
+
* instance. This allows the main rvlite CLI to integrate these commands
|
|
208
|
+
* without duplicating code.
|
|
209
|
+
*/
|
|
210
|
+
export function registerRvfCommands(program) {
|
|
211
|
+
program
|
|
212
|
+
.command('rvf-migrate')
|
|
213
|
+
.description('Convert existing rvlite data to RVF format')
|
|
214
|
+
.requiredOption('-s, --source <path>', 'Path to source rvlite JSON database')
|
|
215
|
+
.requiredOption('-d, --dest <path>', 'Destination RVF file path')
|
|
216
|
+
.option('--dry-run', 'Report what would be migrated without writing', false)
|
|
217
|
+
.option('--verify', 'Verify vectors match within 1e-6 tolerance after migration', false)
|
|
218
|
+
.action(async (options) => {
|
|
219
|
+
try {
|
|
220
|
+
const report = await rvfMigrate(options.source, options.dest, {
|
|
221
|
+
dryRun: options.dryRun,
|
|
222
|
+
verify: options.verify,
|
|
223
|
+
});
|
|
224
|
+
if (report.skipped) {
|
|
225
|
+
console.log('Migration skipped: destination already contains matching RVF data (idempotent).');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (report.dryRun) {
|
|
229
|
+
console.log('Dry run — no files written.');
|
|
230
|
+
}
|
|
231
|
+
console.log(`Vectors migrated: ${report.vectorsMigrated}`);
|
|
232
|
+
console.log(`Triples migrated: ${report.triplesMigrated}`);
|
|
233
|
+
console.log(`Graph nodes migrated: ${report.graphNodesMigrated}`);
|
|
234
|
+
console.log(`Graph edges migrated: ${report.graphEdgesMigrated}`);
|
|
235
|
+
if (report.verifyPassed !== undefined) {
|
|
236
|
+
console.log(`Verification: ${report.verifyPassed ? 'PASSED' : 'FAILED'}`);
|
|
237
|
+
if (!report.verifyPassed) {
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
244
|
+
console.error(`Error: ${msg}`);
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
program
|
|
249
|
+
.command('rvf-rebuild')
|
|
250
|
+
.description('Reconstruct metadata from RVF file')
|
|
251
|
+
.requiredOption('-s, --source <path>', 'Path to source RVF file')
|
|
252
|
+
.option('-d, --dest <path>', 'Destination JSON file for rebuilt state')
|
|
253
|
+
.action(async (options) => {
|
|
254
|
+
try {
|
|
255
|
+
const report = await rvfRebuild(options.source, options.dest);
|
|
256
|
+
console.log(`Vectors recovered: ${report.vectorsRecovered}`);
|
|
257
|
+
console.log(`Triples recovered: ${report.triplesRecovered}`);
|
|
258
|
+
console.log(`Graph nodes recovered: ${report.graphNodesRecovered}`);
|
|
259
|
+
console.log(`Graph edges recovered: ${report.graphEdgesRecovered}`);
|
|
260
|
+
if (options.dest) {
|
|
261
|
+
console.log(`Rebuilt state written to: ${options.dest}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
266
|
+
console.error(`Error: ${msg}`);
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=cli-rvf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-rvf.js","sourceRoot":"","sources":["../src/cli-rvf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmDH,4EAA4E;AAE5E,SAAS,YAAY,CAAC,CAAW,EAAE,CAAW,EAAE,SAAiB;IAC/D,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,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