1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
//! CLI subcommand definitions (clap `Subcommand` derive).
//!
//! All top-level `Commands` variants and their nested action enums live here.
//! `main.rs` imports these for dispatch.
use clap::Subcommand;
use clap_complete::Shell;
use std::path::PathBuf;
use crate::cli_types::{IndexTypeArg, MetricArg, StorageModeArg};
use crate::graph;
#[derive(Subcommand)]
pub enum Commands {
/// Start interactive REPL
Repl {
/// Path to database directory
#[arg(default_value = "./data")]
path: PathBuf,
},
/// Execute a single query
Query {
/// Path to database directory
path: PathBuf,
/// `VelesQL` query to execute
query: String,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
/// Show database info
Info {
/// Path to database directory
path: PathBuf,
},
/// List all collections in the database
List {
/// Path to database directory
path: PathBuf,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
/// Show detailed information about a collection
Show {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Show sample records
#[arg(short, long, default_value = "0")]
samples: usize,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
/// Export a collection to JSON file
Export {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Output file path
#[arg(short, long)]
output: Option<PathBuf>,
/// Include vectors in export
#[arg(long, default_value = "true")]
include_vectors: bool,
},
/// Import vectors from CSV or JSONL file
Import {
/// Path to data file (CSV or JSONL)
file: PathBuf,
/// Path to database directory
#[arg(short, long, default_value = "./data")]
database: PathBuf,
/// Collection name
#[arg(short, long)]
collection: String,
/// Vector dimension (auto-detected if not specified)
#[arg(long)]
dimension: Option<usize>,
/// Distance metric
#[arg(long, value_enum, default_value = "cosine")]
metric: MetricArg,
/// Storage mode (full, sq8, binary)
#[arg(long, value_enum, default_value = "full")]
storage_mode: StorageModeArg,
/// ID column name (for CSV)
#[arg(long, default_value = "id")]
id_column: String,
/// Vector column name (for CSV)
#[arg(long, default_value = "vector")]
vector_column: String,
/// Batch size for insertion
#[arg(long, default_value = "1000")]
batch_size: usize,
/// Show progress bar
#[arg(long, default_value = "true")]
progress: bool,
},
/// License management commands
License {
#[command(subcommand)]
action: LicenseAction,
},
/// Create a metadata-only collection (no vectors)
CreateMetadataCollection {
/// Path to database directory
path: PathBuf,
/// Collection name
name: String,
},
/// Get a point by ID
Get {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Point ID to retrieve
id: u64,
/// Output format (table, json)
#[arg(short, long, default_value = "json")]
format: String,
},
/// Perform multi-query search with fusion
MultiSearch {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Query vectors as JSON array of arrays (e.g., '[[1.0, 0.0], [0.0, 1.0]]')
vectors: String,
/// Number of results to return
#[arg(short = 'k', long, default_value = "10")]
top_k: usize,
/// Fusion strategy (average, maximum, rrf, weighted)
#[arg(short, long, default_value = "rrf")]
strategy: String,
/// RRF k parameter (only for rrf strategy)
#[arg(long, default_value = "60")]
rrf_k: u32,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
/// Graph operations (EPIC-016 US-050)
Graph {
#[command(subcommand)]
action: graph::GraphAction,
},
/// Generate shell completions (EPIC-014 US-007)
Completions {
/// Shell type (bash, zsh, fish, powershell, elvish)
#[arg(value_enum)]
shell: Shell,
},
/// SIMD performance diagnostics and benchmarking
Simd {
#[command(subcommand)]
action: SimdAction,
},
/// Create a vector collection with dimension, metric, and storage options
CreateVectorCollection {
/// Path to database directory
path: PathBuf,
/// Collection name
name: String,
/// Vector dimension
#[arg(short, long)]
dimension: usize,
/// Distance metric (cosine, euclidean, dot, hamming, jaccard)
#[arg(short, long, value_enum, default_value = "cosine")]
metric: MetricArg,
/// Storage mode (full, sq8, binary, pq, rabitq)
#[arg(short, long, value_enum, default_value = "full")]
storage: StorageModeArg,
},
/// Create a graph collection
CreateGraphCollection {
/// Path to database directory
path: PathBuf,
/// Collection name
name: String,
/// Create with schemaless mode (any node/edge types accepted)
#[arg(long, default_value = "true")]
schemaless: bool,
},
/// Delete a collection (vector, graph, or metadata)
DeleteCollection {
/// Path to database directory
path: PathBuf,
/// Collection name
name: String,
/// Skip interactive confirmation
#[arg(long)]
force: bool,
},
/// Show the query execution plan (EXPLAIN) for a VelesQL query
Explain {
/// Path to database directory
path: PathBuf,
/// VelesQL query to explain
query: String,
/// Output format (tree, json)
#[arg(short, long, default_value = "tree")]
format: String,
},
/// Analyze a collection and display statistics
Analyze {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
/// Delete points from a vector collection by ID
DeletePoints {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Point IDs to delete
#[arg(required = true)]
ids: Vec<u64>,
},
/// Upsert a single point into a vector collection
Upsert {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Point ID
#[arg(long)]
id: u64,
/// Vector as JSON array (e.g., '[0.1, 0.2, 0.3]')
#[arg(long)]
vector: Option<String>,
/// Payload as JSON object (e.g., '{"title": "Hello"}')
#[arg(long)]
payload: Option<String>,
},
/// Index management (create, drop, list)
Index {
#[command(subcommand)]
action: IndexAction,
},
}
#[derive(Subcommand)]
pub enum SimdAction {
/// Show current SIMD dispatch configuration
Info,
/// Force re-benchmark of all SIMD backends
Benchmark,
}
#[derive(Subcommand)]
pub enum IndexAction {
/// Create an index on a collection field
Create {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Field name to index
field: String,
/// Index type (secondary, property, range)
#[arg(long, value_enum, default_value = "secondary")]
index_type: IndexTypeArg,
/// Label (required for property and range index types)
#[arg(long)]
label: Option<String>,
},
/// Drop an index from a collection
Drop {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Label of the index to drop
label: String,
/// Property of the index to drop
property: String,
},
/// List all indexes on a collection
List {
/// Path to database directory
path: PathBuf,
/// Collection name
collection: String,
/// Output format (table, json)
#[arg(short, long, default_value = "table")]
format: String,
},
}
#[derive(Subcommand)]
pub enum LicenseAction {
/// Show current license status
Show,
/// Activate a license key
Activate {
/// License key from email (format: base64_payload.base64_signature)
key: String,
},
/// Verify a license key without activating it
Verify {
/// License key to verify
key: String,
/// Public key for verification (base64 encoded)
#[arg(short, long)]
public_key: String,
},
}