/// engram-migrate — import a Neuron SQLite database into an Engram sled store. /// /// Usage: /// engram-migrate --sqlite ~/.neuron/neuron.db --output ~/.engram/neuron /// /// The tool reads memory_nodes, knowledge_entries, and graph_edges from the /// Neuron SQLite database and writes them to a new Engram sled store. /// /// Embeddings are placeholder random unit vectors (dimension 384 by default). /// Re-run with a real embedding model once the ONNX engine is available. use engram_core::migration::{migrate_from_neuron, MigrationConfig}; use std::path::PathBuf; use std::process; fn main() { let args: Vec = std::env::args().collect(); if args.len() < 5 { eprintln!("Usage: engram-migrate --sqlite --output "); eprintln!(" --sqlite Path to the Neuron SQLite database (e.g. ~/.neuron/neuron.db)"); eprintln!(" --output Path for the new Engram sled store (e.g. ~/.engram/neuron)"); process::exit(1); } let mut sqlite_path: Option = None; let mut output_path: Option = None; let mut embedding_dim: usize = 384; let mut i = 1; while i < args.len() { match args[i].as_str() { "--sqlite" => { i += 1; sqlite_path = Some(PathBuf::from(&args[i])); } "--output" => { i += 1; output_path = Some(PathBuf::from(&args[i])); } "--embedding-dim" => { i += 1; embedding_dim = args[i].parse().unwrap_or(384); } _ => { eprintln!("Unknown argument: {}", args[i]); process::exit(1); } } i += 1; } let sqlite_path = match sqlite_path { Some(p) => p, None => { eprintln!("Missing --sqlite argument"); process::exit(1); } }; let output_path = match output_path { Some(p) => p, None => { eprintln!("Missing --output argument"); process::exit(1); } }; if !sqlite_path.exists() { eprintln!("SQLite file not found: {}", sqlite_path.display()); process::exit(1); } println!("Migrating Neuron database..."); println!(" Source: {}", sqlite_path.display()); println!(" Output: {}", output_path.display()); println!(" Embedding dim: {}", embedding_dim); println!(); let config = MigrationConfig { sqlite_path, engram_path: output_path, embedding_dim, }; match migrate_from_neuron(&config) { Ok(report) => { println!("Migration complete."); println!(" Memories migrated: {}", report.memories_migrated); println!(" Knowledge migrated: {}", report.knowledge_migrated); println!(" Edges created: {}", report.edges_created); if !report.errors.is_empty() { println!(); println!("Non-fatal errors ({}):", report.errors.len()); for e in &report.errors { println!(" - {}", e); } } } Err(e) => { eprintln!("Migration failed: {}", e); process::exit(1); } } }