velesdb-cli 1.4.4

Interactive CLI and REPL for VelesDB with VelesQL support
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
// CLI - pedantic/nursery lints relaxed
#![allow(clippy::pedantic)]
#![allow(clippy::nursery)]
#![allow(clippy::doc_markdown)]
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
//! `VelesDB` CLI - Interactive REPL for `VelesQL` queries
//!
//! Usage:
//!   `velesdb repl ./my_database`
//!   `velesdb query ./my_database "SELECT * FROM docs LIMIT 10"`
//!   `velesdb import ./data.jsonl --collection docs`

mod graph;
mod import;
mod license;
mod repl;
mod repl_output;
mod session;

use clap::{CommandFactory, Parser, Subcommand, ValueEnum};
use clap_complete::{generate, Shell};
use std::io;
use std::path::PathBuf;
use velesdb_core::{DistanceMetric, StorageMode};

#[derive(Parser)]
#[command(name = "velesdb")]
#[command(
    author,
    version,
    about = "VelesDB CLI - High-performance vector database"
)]
#[command(propagate_version = true)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

/// CLI metric option
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
enum MetricArg {
    #[default]
    Cosine,
    Euclidean,
    Dot,
    Hamming,
    Jaccard,
}

impl From<MetricArg> for DistanceMetric {
    fn from(m: MetricArg) -> Self {
        match m {
            MetricArg::Cosine => DistanceMetric::Cosine,
            MetricArg::Euclidean => DistanceMetric::Euclidean,
            MetricArg::Dot => DistanceMetric::DotProduct,
            MetricArg::Hamming => DistanceMetric::Hamming,
            MetricArg::Jaccard => DistanceMetric::Jaccard,
        }
    }
}

/// CLI storage mode option
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
enum StorageModeArg {
    #[default]
    Full,
    Sq8,
    Binary,
}

impl From<StorageModeArg> for StorageMode {
    fn from(m: StorageModeArg) -> Self {
        match m {
            StorageModeArg::Full => StorageMode::Full,
            StorageModeArg::Sq8 => StorageMode::SQ8,
            StorageModeArg::Binary => StorageMode::Binary,
        }
    }
}

#[derive(Subcommand)]
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,
    },
}

#[derive(Subcommand)]
enum SimdAction {
    /// Show current SIMD dispatch configuration
    Info,

    /// Force re-benchmark of all SIMD backends
    Benchmark,
}

#[derive(Subcommand)]
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,
    },
}

#[allow(clippy::too_many_lines, clippy::cognitive_complexity)] // Reason: CLI entry point with command dispatch
fn main() -> anyhow::Result<()> {
    let cli = Cli::parse();

    match cli.command {
        Commands::Repl { path } => {
            repl::run(path)?;
        }
        Commands::Query {
            path,
            query,
            format,
        } => {
            let db = velesdb_core::Database::open(&path)?;
            let result = repl::execute_query(&db, &query)?;
            repl::print_result(&result, &format);
        }
        Commands::Info { path } => {
            let db = velesdb_core::Database::open(&path)?;
            println!("VelesDB Database: {}", path.display());
            println!("Collections:");
            for name in db.list_collections() {
                if let Some(col) = db.get_collection(&name) {
                    let config = col.config();
                    println!(
                        "  - {} ({} dims, {:?}, {} points)",
                        config.name, config.dimension, config.metric, config.point_count
                    );
                }
            }
        }
        Commands::List { path, format } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&path)?;
            let collections = db.list_collections();

            if format == "json" {
                let data: Vec<_> = collections
                    .iter()
                    .filter_map(|name| db.get_collection(name))
                    .map(|col| {
                        let cfg = col.config();
                        serde_json::json!({
                            "name": cfg.name,
                            "dimension": cfg.dimension,
                            "metric": format!("{:?}", cfg.metric),
                            "point_count": cfg.point_count,
                            "storage_mode": format!("{:?}", cfg.storage_mode)
                        })
                    })
                    .collect();
                println!("{}", serde_json::to_string_pretty(&data)?);
            } else {
                println!("\n{}", "Collections".bold().underline());
                if collections.is_empty() {
                    println!("  No collections found.\n");
                } else {
                    for name in &collections {
                        if let Some(col) = db.get_collection(name) {
                            let cfg = col.config();
                            println!(
                                "  {} {} ({} dims, {:?}, {} points)",
                                "".cyan(),
                                cfg.name.green(),
                                cfg.dimension,
                                cfg.metric,
                                cfg.point_count
                            );
                        }
                    }
                    println!("\n  Total: {} collection(s)\n", collections.len());
                }
            }
        }
        Commands::Show {
            path,
            collection,
            samples,
            format,
        } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&path)?;
            let col = db
                .get_collection(&collection)
                .ok_or_else(|| anyhow::anyhow!("Collection '{}' not found", collection))?;

            let cfg = col.config();

            if format == "json" {
                let data = serde_json::json!({
                    "name": cfg.name,
                    "dimension": cfg.dimension,
                    "metric": format!("{:?}", cfg.metric),
                    "point_count": cfg.point_count,
                    "storage_mode": format!("{:?}", cfg.storage_mode),
                    "estimated_memory_mb": (cfg.point_count * cfg.dimension * 4) as f64 / 1_000_000.0
                });
                println!("{}", serde_json::to_string_pretty(&data)?);
            } else {
                println!("\n{}", "Collection Details".bold().underline());
                println!("  {} {}", "Name:".cyan(), cfg.name.green());
                println!("  {} {}", "Dimension:".cyan(), cfg.dimension);
                println!("  {} {:?}", "Metric:".cyan(), cfg.metric);
                println!("  {} {}", "Point Count:".cyan(), cfg.point_count);
                println!("  {} {:?}", "Storage Mode:".cyan(), cfg.storage_mode);

                let estimated_mb = (cfg.point_count * cfg.dimension * 4) as f64 / 1_000_000.0;
                println!("  {} {:.2} MB", "Est. Memory:".cyan(), estimated_mb);

                if samples > 0 {
                    println!("\n{}", "Sample Records".bold().underline());
                    let ids: Vec<u64> = (1..=(samples as u64 * 2)).collect();
                    let points = col.get(&ids);

                    for point in points.into_iter().flatten().take(samples) {
                        println!("  ID: {}", point.id.to_string().green());
                        if let Some(payload) = &point.payload {
                            println!("    Payload: {}", payload);
                        }
                    }
                }
                println!();
            }
        }
        Commands::Export {
            path,
            collection,
            output,
            include_vectors,
        } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&path)?;
            let col = db
                .get_collection(&collection)
                .ok_or_else(|| anyhow::anyhow!("Collection '{}' not found", collection))?;

            let cfg = col.config();
            let output_path =
                output.unwrap_or_else(|| PathBuf::from(format!("{}.json", collection)));

            println!(
                "Exporting {} records from {}...",
                cfg.point_count,
                collection.green()
            );

            let mut records = Vec::new();
            let batch_size = 1000;

            for batch_start in (0..cfg.point_count).step_by(batch_size) {
                let ids: Vec<u64> =
                    ((batch_start as u64 + 1)..=((batch_start + batch_size) as u64)).collect();
                let points = col.get(&ids);

                for point in points.into_iter().flatten() {
                    let mut record = serde_json::Map::new();
                    record.insert("id".to_string(), serde_json::json!(point.id));
                    if include_vectors {
                        record.insert("vector".to_string(), serde_json::json!(point.vector));
                    }
                    if let Some(payload) = &point.payload {
                        record.insert("payload".to_string(), payload.clone());
                    }
                    records.push(serde_json::Value::Object(record));
                }
            }

            std::fs::write(&output_path, serde_json::to_string_pretty(&records)?)?;
            println!(
                "{} Exported {} records to {}",
                "".green(),
                records.len(),
                output_path.display().to_string().green()
            );
        }
        Commands::Import {
            file,
            database,
            collection,
            dimension,
            metric,
            storage_mode,
            id_column,
            vector_column,
            batch_size,
            progress,
        } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&database)?;
            let config = import::ImportConfig {
                collection,
                dimension,
                metric: metric.into(),
                storage_mode: storage_mode.into(),
                batch_size,
                id_column,
                vector_column,
                show_progress: progress,
            };

            let ext = file.extension().and_then(|e| e.to_str()).unwrap_or("");

            let stats = match ext.to_lowercase().as_str() {
                "jsonl" | "ndjson" => import::import_jsonl(&db, &file, &config)?,
                "csv" => import::import_csv(&db, &file, &config)?,
                _ => {
                    anyhow::bail!("Unsupported file format: {}. Use .csv or .jsonl", ext);
                }
            };

            println!("\n{}", "Import Summary".green().bold());
            println!("  Total records:    {}", stats.total);
            println!("  Imported:         {}", stats.imported.to_string().green());
            if stats.errors > 0 {
                println!("  Errors:           {}", stats.errors.to_string().red());
            }
            println!("  Duration:         {} ms", stats.duration_ms);
            println!(
                "  Throughput:       {:.0} records/sec",
                stats.records_per_sec()
            );
        }
        Commands::License { action } => {
            use colored::Colorize;

            match action {
                LicenseAction::Show => {
                    if let Ok(key) = license::load_license_key() {
                        // Try to get public key from environment
                        let public_key = std::env::var("VELESDB_LICENSE_PUBLIC_KEY")
                            .unwrap_or_else(|_| {
                                println!("{}", "⚠️  Warning: VELESDB_LICENSE_PUBLIC_KEY not set in environment".yellow());
                                println!("   Set it with: export VELESDB_LICENSE_PUBLIC_KEY=<base64_key>");
                                println!("   Using embedded development key for validation...\n");
                                // Development fallback key (same as velesdb-premium)
                                "MCowBQYDK2VwAyEADevelopmentKeyReplaceMeInProd==".to_string()
                            });

                        match license::validate_license(&key, &public_key) {
                            Ok(info) => {
                                license::display_license_info(&info);
                            }
                            Err(e) => {
                                println!("{} {}", "❌ License validation failed:".red().bold(), e);
                                std::process::exit(1);
                            }
                        }
                    } else {
                        println!("{}", "❌ No license found".red().bold());
                        println!("\n{}", "To activate a license:".cyan());
                        println!("  velesdb license activate <license_key>");
                        println!("\n{}", "License keys are stored in:".cyan());
                        if let Ok(path) = license::get_license_config_path() {
                            println!("  {}", path.display());
                        }
                        std::process::exit(1);
                    }
                }
                LicenseAction::Activate { key } => {
                    // Try to get public key from environment
                    let public_key =
                        std::env::var("VELESDB_LICENSE_PUBLIC_KEY").unwrap_or_else(|_| {
                            println!(
                                "{}",
                                "⚠️  Warning: VELESDB_LICENSE_PUBLIC_KEY not set in environment"
                                    .yellow()
                            );
                            println!(
                                "   Set it with: export VELESDB_LICENSE_PUBLIC_KEY=<base64_key>"
                            );
                            println!("   Using embedded development key for validation...\n");
                            "MCowBQYDK2VwAyEADevelopmentKeyReplaceMeInProd==".to_string()
                        });

                    // Validate the license first
                    match license::validate_license(&key, &public_key) {
                        Ok(info) => {
                            // Save the license
                            license::save_license_key(&key)?;

                            println!("{}", "✅ License activated successfully!".green().bold());
                            println!();
                            license::display_license_info(&info);

                            if let Ok(path) = license::get_license_config_path() {
                                println!("{}", "License saved to:".cyan());
                                println!("  {}", path.display());
                            }
                        }
                        Err(e) => {
                            println!("{} {}", "❌ License activation failed:".red().bold(), e);
                            println!("\n{}", "Please check:".yellow());
                            println!("  • License key format is correct (base64_payload.base64_signature)");
                            println!("  • License has not expired");
                            println!(
                                "  • Public key is correctly set in VELESDB_LICENSE_PUBLIC_KEY"
                            );
                            std::process::exit(1);
                        }
                    }
                }
                LicenseAction::Verify { key, public_key } => {
                    match license::validate_license(&key, &public_key) {
                        Ok(info) => {
                            println!("{}", "✅ License is VALID".green().bold());
                            println!();
                            license::display_license_info(&info);
                        }
                        Err(e) => {
                            println!("{} {}", "❌ License verification failed:".red().bold(), e);
                            println!("\n{}", "Possible reasons:".yellow());
                            println!("  • Invalid signature (license may have been tampered with)");
                            println!("  • Wrong public key");
                            println!("  • License has expired");
                            println!("  • Malformed license format");
                            std::process::exit(1);
                        }
                    }
                }
            }
        }
        Commands::MultiSearch {
            path,
            collection,
            vectors,
            top_k,
            strategy,
            rrf_k,
            format,
        } => {
            use colored::Colorize;
            use velesdb_core::FusionStrategy;

            let db = velesdb_core::Database::open(&path)?;
            let col = db
                .get_collection(&collection)
                .ok_or_else(|| anyhow::anyhow!("Collection '{}' not found", collection))?;

            // Parse vectors from JSON
            let parsed_vectors: Vec<Vec<f32>> = serde_json::from_str(&vectors)
                .map_err(|e| anyhow::anyhow!("Invalid vectors JSON: {}", e))?;

            if parsed_vectors.is_empty() {
                anyhow::bail!("At least one query vector is required");
            }

            // Parse fusion strategy
            let fusion_strategy = match strategy.to_lowercase().as_str() {
                "average" | "avg" => FusionStrategy::Average,
                "maximum" | "max" => FusionStrategy::Maximum,
                "rrf" => FusionStrategy::RRF { k: rrf_k },
                "weighted" => FusionStrategy::Weighted {
                    avg_weight: 0.5,
                    max_weight: 0.3,
                    hit_weight: 0.2,
                },
                _ => anyhow::bail!(
                    "Invalid strategy '{}'. Valid: average, maximum, rrf, weighted",
                    strategy
                ),
            };

            // Convert to slices
            let query_refs: Vec<&[f32]> = parsed_vectors.iter().map(Vec::as_slice).collect();

            // Execute multi-query search
            let results = col
                .multi_query_search(&query_refs, top_k, fusion_strategy, None)
                .map_err(|e| anyhow::anyhow!("Search failed: {}", e))?;

            if format == "json" {
                let output: Vec<_> = results
                    .iter()
                    .map(|r| {
                        serde_json::json!({
                            "id": r.point.id,
                            "score": r.score,
                            "payload": r.point.payload
                        })
                    })
                    .collect();
                println!("{}", serde_json::to_string_pretty(&output)?);
            } else {
                println!(
                    "\n{} (strategy: {}, {} vectors)",
                    "Multi-Query Search Results".bold().underline(),
                    strategy.green(),
                    parsed_vectors.len()
                );
                if results.is_empty() {
                    println!("  No results found.\n");
                } else {
                    for (i, r) in results.iter().enumerate() {
                        println!(
                            "  {}. ID: {} (score: {:.4})",
                            i + 1,
                            r.point.id.to_string().green(),
                            r.score
                        );
                        if let Some(payload) = &r.point.payload {
                            println!("     Payload: {}", payload);
                        }
                    }
                    println!("\n  Total: {} result(s)\n", results.len());
                }
            }
        }
        Commands::CreateMetadataCollection { path, name } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&path)?;
            db.create_collection_typed(&name, &velesdb_core::CollectionType::MetadataOnly)?;

            println!(
                "{} Collection '{}' created (metadata-only)",
                "".green(),
                name.cyan()
            );
        }
        Commands::Get {
            path,
            collection,
            id,
            format,
        } => {
            use colored::Colorize;

            let db = velesdb_core::Database::open(&path)?;
            let col = db
                .get_collection(&collection)
                .ok_or_else(|| anyhow::anyhow!("Collection '{}' not found", collection))?;

            let points = col.get(&[id]);

            if format == "json" {
                if let Some(point) = points.into_iter().flatten().next() {
                    let output = serde_json::json!({
                        "id": point.id,
                        "vector": point.vector,
                        "payload": point.payload
                    });
                    println!("{}", serde_json::to_string_pretty(&output)?);
                } else {
                    println!("null");
                }
            } else if let Some(point) = points.into_iter().flatten().next() {
                println!("\n{}", "Point Found".bold().underline());
                println!("  ID: {}", point.id.to_string().green());
                println!("  Vector: [{} dimensions]", point.vector.len());
                if let Some(payload) = &point.payload {
                    println!("  Payload: {}", payload);
                }
            } else {
                println!("{} Point with ID {} not found", "".red(), id);
            }
        }
        Commands::Graph { action } => {
            graph::handle(action);
        }
        Commands::Completions { shell } => {
            let mut cmd = Cli::command();
            generate(shell, &mut cmd, "velesdb", &mut io::stdout());
        }
        Commands::Simd { action } => {
            use colored::Colorize;

            match action {
                SimdAction::Info => {
                    println!("\n{}", "SIMD Native Configuration".bold().underline());
                    println!("  Using simd_native with tiered dispatch:");
                    println!("  - AVX-512: 4/2/1 accumulators based on vector size");
                    println!("  - AVX2: 4-acc (>1024D), 2-acc (64-1023D), 1-acc (<64D)");
                    println!("  - ARM NEON: 128-bit SIMD");
                    println!("  - Scalar: fallback for small vectors");
                    println!("\n{}", "Available Functions:".cyan());
                    println!("  - dot_product_native()");
                    println!("  - cosine_similarity_native()");
                    println!("  - euclidean_native()");
                    println!("  - hamming_distance_native()");
                    println!("  - jaccard_similarity_native()");
                    println!("  - batch_dot_product_native() (with prefetching)");
                    println!();
                }
                SimdAction::Benchmark => {
                    println!("{}", "SIMD micro-benchmarks removed.".yellow());
                    println!("Use 'cargo bench --bench simd_benchmark' for detailed benchmarks.");
                    println!();
                }
            }
        }
    }

    Ok(())
}