ruvector 0.1.23 → 0.1.24

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "startTime": 1764217582157,
3
- "sessionId": "session-1764217582157",
4
- "lastActivity": 1764217582157,
2
+ "startTime": 1764220734177,
3
+ "sessionId": "session-1764220734177",
4
+ "lastActivity": 1764220734177,
5
5
  "sessionDuration": 0,
6
6
  "totalTasks": 1,
7
7
  "successfulTasks": 1,
@@ -1,10 +1,10 @@
1
1
  [
2
2
  {
3
- "id": "cmd-hooks-1764217582465",
3
+ "id": "cmd-hooks-1764220734296",
4
4
  "type": "hooks",
5
5
  "success": true,
6
- "duration": 37.93139400000007,
7
- "timestamp": 1764217582503,
6
+ "duration": 9.616918999999996,
7
+ "timestamp": 1764220734306,
8
8
  "metadata": {}
9
9
  }
10
10
  ]
package/bin/cli.js CHANGED
@@ -855,4 +855,767 @@ gnnCmd
855
855
  console.log(chalk.gray(` binary (freq <= 0.01) - ~32x compression, archive`));
856
856
  });
857
857
 
858
+ // =============================================================================
859
+ // Doctor Command - Check system health and dependencies
860
+ // =============================================================================
861
+
862
+ program
863
+ .command('doctor')
864
+ .description('Check system health and dependencies')
865
+ .option('-v, --verbose', 'Show detailed information')
866
+ .action(async (options) => {
867
+ const { execSync } = require('child_process');
868
+
869
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
870
+ console.log(chalk.cyan(' RuVector Doctor'));
871
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
872
+
873
+ let issues = 0;
874
+ let warnings = 0;
875
+
876
+ // Helper functions
877
+ const check = (name, condition, fix) => {
878
+ if (condition) {
879
+ console.log(chalk.green(` ✓ ${name}`));
880
+ return true;
881
+ } else {
882
+ console.log(chalk.red(` ✗ ${name}`));
883
+ if (fix) console.log(chalk.gray(` Fix: ${fix}`));
884
+ issues++;
885
+ return false;
886
+ }
887
+ };
888
+
889
+ const warn = (name, condition, suggestion) => {
890
+ if (condition) {
891
+ console.log(chalk.green(` ✓ ${name}`));
892
+ return true;
893
+ } else {
894
+ console.log(chalk.yellow(` ! ${name}`));
895
+ if (suggestion) console.log(chalk.gray(` Suggestion: ${suggestion}`));
896
+ warnings++;
897
+ return false;
898
+ }
899
+ };
900
+
901
+ const getVersion = (cmd) => {
902
+ try {
903
+ return execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
904
+ } catch (e) {
905
+ return null;
906
+ }
907
+ };
908
+
909
+ // System Information
910
+ console.log(chalk.cyan('System Information:'));
911
+ console.log(chalk.white(` Platform: ${chalk.yellow(process.platform)}`));
912
+ console.log(chalk.white(` Architecture: ${chalk.yellow(process.arch)}`));
913
+ console.log(chalk.white(` Node.js: ${chalk.yellow(process.version)}`));
914
+ console.log('');
915
+
916
+ // Node.js Checks
917
+ console.log(chalk.cyan('Node.js Environment:'));
918
+ const nodeVersion = parseInt(process.version.slice(1).split('.')[0]);
919
+ check('Node.js >= 14', nodeVersion >= 14, 'Upgrade Node.js: https://nodejs.org');
920
+
921
+ const npmVersion = getVersion('npm --version');
922
+ if (npmVersion) {
923
+ console.log(chalk.green(` ✓ npm ${npmVersion}`));
924
+ } else {
925
+ check('npm installed', false, 'Install npm or reinstall Node.js');
926
+ }
927
+ console.log('');
928
+
929
+ // RuVector Packages
930
+ console.log(chalk.cyan('RuVector Packages:'));
931
+
932
+ // Check @ruvector/core
933
+ let coreAvailable = false;
934
+ try {
935
+ require.resolve('@ruvector/core');
936
+ coreAvailable = true;
937
+ console.log(chalk.green(` ✓ @ruvector/core installed`));
938
+ } catch (e) {
939
+ console.log(chalk.yellow(` ! @ruvector/core not found (using WASM fallback)`));
940
+ warnings++;
941
+ }
942
+
943
+ // Check if native binding works
944
+ if (coreAvailable && loadRuvector()) {
945
+ const info = getVersion();
946
+ console.log(chalk.green(` ✓ Native binding working (${info.implementation})`));
947
+ } else if (coreAvailable) {
948
+ console.log(chalk.yellow(` ! Native binding failed to load`));
949
+ warnings++;
950
+ }
951
+
952
+ // Check @ruvector/gnn
953
+ if (gnnAvailable) {
954
+ console.log(chalk.green(` ✓ @ruvector/gnn installed`));
955
+ } else {
956
+ console.log(chalk.gray(` ○ @ruvector/gnn not installed (optional)`));
957
+ }
958
+
959
+ // Check @ruvector/graph-node
960
+ try {
961
+ require.resolve('@ruvector/graph-node');
962
+ console.log(chalk.green(` ✓ @ruvector/graph-node installed`));
963
+ } catch (e) {
964
+ console.log(chalk.gray(` ○ @ruvector/graph-node not installed (optional)`));
965
+ }
966
+ console.log('');
967
+
968
+ // Rust Toolchain (optional for development)
969
+ console.log(chalk.cyan('Rust Toolchain (optional):'));
970
+
971
+ const rustVersion = getVersion('rustc --version');
972
+ if (rustVersion) {
973
+ console.log(chalk.green(` ✓ ${rustVersion}`));
974
+ } else {
975
+ console.log(chalk.gray(` ○ Rust not installed (only needed for development)`));
976
+ }
977
+
978
+ const cargoVersion = getVersion('cargo --version');
979
+ if (cargoVersion) {
980
+ console.log(chalk.green(` ✓ ${cargoVersion}`));
981
+ } else if (rustVersion) {
982
+ console.log(chalk.yellow(` ! cargo not found`));
983
+ warnings++;
984
+ }
985
+ console.log('');
986
+
987
+ // Build Tools (optional)
988
+ if (options.verbose) {
989
+ console.log(chalk.cyan('Build Tools (for native compilation):'));
990
+
991
+ const hasGcc = getVersion('gcc --version');
992
+ const hasClang = getVersion('clang --version');
993
+ const hasCc = getVersion('cc --version');
994
+
995
+ if (hasGcc || hasClang || hasCc) {
996
+ console.log(chalk.green(` ✓ C compiler available`));
997
+ } else {
998
+ console.log(chalk.gray(` ○ No C compiler found (only needed for building from source)`));
999
+ }
1000
+
1001
+ const hasMake = getVersion('make --version');
1002
+ if (hasMake) {
1003
+ console.log(chalk.green(` ✓ make available`));
1004
+ } else {
1005
+ console.log(chalk.gray(` ○ make not found`));
1006
+ }
1007
+
1008
+ const hasCmake = getVersion('cmake --version');
1009
+ if (hasCmake) {
1010
+ console.log(chalk.green(` ✓ cmake available`));
1011
+ } else {
1012
+ console.log(chalk.gray(` ○ cmake not found`));
1013
+ }
1014
+ console.log('');
1015
+ }
1016
+
1017
+ // Summary
1018
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════'));
1019
+ if (issues === 0 && warnings === 0) {
1020
+ console.log(chalk.green('\n ✓ All checks passed! RuVector is ready to use.\n'));
1021
+ } else if (issues === 0) {
1022
+ console.log(chalk.yellow(`\n ! ${warnings} warning(s) found. RuVector should work but may have limited features.\n`));
1023
+ } else {
1024
+ console.log(chalk.red(`\n ✗ ${issues} issue(s) and ${warnings} warning(s) found.\n`));
1025
+ console.log(chalk.white(' Run "npx ruvector setup" for installation instructions.\n'));
1026
+ }
1027
+ });
1028
+
1029
+ // =============================================================================
1030
+ // Setup Command - Installation instructions
1031
+ // =============================================================================
1032
+
1033
+ program
1034
+ .command('setup')
1035
+ .description('Show installation and setup instructions')
1036
+ .option('--rust', 'Show Rust installation instructions')
1037
+ .option('--npm', 'Show npm package installation instructions')
1038
+ .option('--all', 'Show all installation instructions')
1039
+ .action((options) => {
1040
+ const showAll = options.all || (!options.rust && !options.npm);
1041
+
1042
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1043
+ console.log(chalk.cyan(' RuVector Setup Guide'));
1044
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1045
+
1046
+ // Quick install
1047
+ console.log(chalk.cyan('Quick Install (one-liner):'));
1048
+ console.log(chalk.white(' curl -fsSL https://raw.githubusercontent.com/ruvnet/ruvector/main/install.sh | bash'));
1049
+ console.log('');
1050
+
1051
+ if (showAll || options.npm) {
1052
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────'));
1053
+ console.log(chalk.cyan('npm Packages'));
1054
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────\n'));
1055
+
1056
+ console.log(chalk.yellow('All-in-one CLI:'));
1057
+ console.log(chalk.white(' npm install -g ruvector'));
1058
+ console.log(chalk.white(' npx ruvector'));
1059
+ console.log('');
1060
+
1061
+ console.log(chalk.yellow('Core packages:'));
1062
+ console.log(chalk.white(' npm install @ruvector/core # Vector database'));
1063
+ console.log(chalk.white(' npm install @ruvector/gnn # Graph Neural Networks'));
1064
+ console.log(chalk.white(' npm install @ruvector/graph-node # Hypergraph database'));
1065
+ console.log('');
1066
+
1067
+ console.log(chalk.yellow('Install all optional packages:'));
1068
+ console.log(chalk.white(' npx ruvector install --all'));
1069
+ console.log('');
1070
+
1071
+ console.log(chalk.yellow('List available packages:'));
1072
+ console.log(chalk.white(' npx ruvector install'));
1073
+ console.log('');
1074
+ }
1075
+
1076
+ if (showAll || options.rust) {
1077
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────'));
1078
+ console.log(chalk.cyan('Rust Installation'));
1079
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────\n'));
1080
+
1081
+ console.log(chalk.yellow('1. Install Rust:'));
1082
+ console.log(chalk.white(' curl --proto \'=https\' --tlsv1.2 -sSf https://sh.rustup.rs | sh'));
1083
+ console.log(chalk.gray(' # Follow the prompts, then restart your terminal or run:'));
1084
+ console.log(chalk.white(' source $HOME/.cargo/env'));
1085
+ console.log('');
1086
+
1087
+ console.log(chalk.yellow('2. Verify installation:'));
1088
+ console.log(chalk.white(' rustc --version'));
1089
+ console.log(chalk.white(' cargo --version'));
1090
+ console.log('');
1091
+
1092
+ console.log(chalk.yellow('3. Add RuVector crates to your project:'));
1093
+ console.log(chalk.white(' cargo add ruvector-core # Vector database'));
1094
+ console.log(chalk.white(' cargo add ruvector-graph # Hypergraph with Cypher'));
1095
+ console.log(chalk.white(' cargo add ruvector-gnn # Graph Neural Networks'));
1096
+ console.log('');
1097
+
1098
+ console.log(chalk.yellow('4. Other available crates:'));
1099
+ console.log(chalk.white(' cargo add ruvector-cluster # Distributed clustering'));
1100
+ console.log(chalk.white(' cargo add ruvector-raft # Raft consensus'));
1101
+ console.log(chalk.white(' cargo add ruvector-replication # Data replication'));
1102
+ console.log(chalk.white(' cargo add ruvector-tiny-dancer-core # AI routing'));
1103
+ console.log(chalk.white(' cargo add ruvector-router-core # Semantic routing'));
1104
+ console.log('');
1105
+
1106
+ console.log(chalk.yellow('Platform-specific notes:'));
1107
+ console.log('');
1108
+
1109
+ if (process.platform === 'darwin') {
1110
+ console.log(chalk.cyan(' macOS:'));
1111
+ console.log(chalk.white(' xcode-select --install # Install command line tools'));
1112
+ console.log('');
1113
+ } else if (process.platform === 'linux') {
1114
+ console.log(chalk.cyan(' Linux (Debian/Ubuntu):'));
1115
+ console.log(chalk.white(' sudo apt-get update'));
1116
+ console.log(chalk.white(' sudo apt-get install build-essential pkg-config libssl-dev'));
1117
+ console.log('');
1118
+ console.log(chalk.cyan(' Linux (RHEL/CentOS):'));
1119
+ console.log(chalk.white(' sudo yum groupinstall "Development Tools"'));
1120
+ console.log(chalk.white(' sudo yum install openssl-devel'));
1121
+ console.log('');
1122
+ } else if (process.platform === 'win32') {
1123
+ console.log(chalk.cyan(' Windows:'));
1124
+ console.log(chalk.white(' # Install Visual Studio Build Tools'));
1125
+ console.log(chalk.white(' # https://visualstudio.microsoft.com/visual-cpp-build-tools/'));
1126
+ console.log(chalk.white(' # Or use WSL2 for best experience'));
1127
+ console.log('');
1128
+ }
1129
+ }
1130
+
1131
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────'));
1132
+ console.log(chalk.cyan('Documentation & Resources'));
1133
+ console.log(chalk.cyan('───────────────────────────────────────────────────────────────\n'));
1134
+
1135
+ console.log(chalk.white(' GitHub: https://github.com/ruvnet/ruvector'));
1136
+ console.log(chalk.white(' npm: https://www.npmjs.com/package/ruvector'));
1137
+ console.log(chalk.white(' crates.io: https://crates.io/crates/ruvector-core'));
1138
+ console.log(chalk.white(' Issues: https://github.com/ruvnet/ruvector/issues'));
1139
+ console.log('');
1140
+
1141
+ console.log(chalk.cyan('Quick Commands:'));
1142
+ console.log(chalk.white(' npx ruvector doctor # Check system health'));
1143
+ console.log(chalk.white(' npx ruvector info # Show version info'));
1144
+ console.log(chalk.white(' npx ruvector benchmark # Run performance test'));
1145
+ console.log(chalk.white(' npx ruvector install # List available packages'));
1146
+ console.log('');
1147
+ });
1148
+
1149
+ // =============================================================================
1150
+ // Graph Commands - Cypher queries and graph operations
1151
+ // =============================================================================
1152
+
1153
+ program
1154
+ .command('graph')
1155
+ .description('Graph database operations (requires @ruvector/graph-node)')
1156
+ .option('-q, --query <cypher>', 'Execute Cypher query')
1157
+ .option('-c, --create <label>', 'Create a node with label')
1158
+ .option('-p, --properties <json>', 'Node properties as JSON')
1159
+ .option('-r, --relate <spec>', 'Create relationship (from:rel:to)')
1160
+ .option('--info', 'Show graph info and stats')
1161
+ .action(async (options) => {
1162
+ let graphNode;
1163
+ try {
1164
+ graphNode = require('@ruvector/graph-node');
1165
+ } catch (e) {
1166
+ console.log(chalk.yellow('\n @ruvector/graph-node is not installed.\n'));
1167
+ console.log(chalk.cyan(' Install with:'));
1168
+ console.log(chalk.white(' npm install @ruvector/graph-node\n'));
1169
+ console.log(chalk.cyan(' Features:'));
1170
+ console.log(chalk.gray(' - Cypher query language support'));
1171
+ console.log(chalk.gray(' - Hypergraph data structure'));
1172
+ console.log(chalk.gray(' - Knowledge graph operations'));
1173
+ console.log(chalk.gray(' - Neo4j-compatible syntax\n'));
1174
+ console.log(chalk.cyan(' Example usage:'));
1175
+ console.log(chalk.white(' npx ruvector graph --query "CREATE (n:Person {name: \'Alice\'})"'));
1176
+ console.log(chalk.white(' npx ruvector graph --query "MATCH (n) RETURN n"'));
1177
+ console.log('');
1178
+ return;
1179
+ }
1180
+
1181
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1182
+ console.log(chalk.cyan(' RuVector Graph'));
1183
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1184
+
1185
+ if (options.info) {
1186
+ console.log(chalk.green(' @ruvector/graph-node is available!'));
1187
+ console.log(chalk.gray(` Platform: ${process.platform}-${process.arch}`));
1188
+ console.log('');
1189
+ console.log(chalk.yellow(' Available operations:'));
1190
+ console.log(chalk.white(' --query <cypher> Execute Cypher query'));
1191
+ console.log(chalk.white(' --create <label> Create node with label'));
1192
+ console.log(chalk.white(' --relate <spec> Create relationship'));
1193
+ console.log('');
1194
+ return;
1195
+ }
1196
+
1197
+ if (options.query) {
1198
+ console.log(chalk.yellow(' Cypher Query:'), chalk.white(options.query));
1199
+ console.log('');
1200
+ // Actual implementation would execute the query
1201
+ console.log(chalk.gray(' Note: Full Cypher execution requires running ruvector-server'));
1202
+ console.log(chalk.gray(' See: npx ruvector server --help'));
1203
+ }
1204
+
1205
+ if (options.create) {
1206
+ const label = options.create;
1207
+ const props = options.properties ? JSON.parse(options.properties) : {};
1208
+ console.log(chalk.yellow(' Creating node:'), chalk.white(label));
1209
+ console.log(chalk.gray(' Properties:'), JSON.stringify(props, null, 2));
1210
+ }
1211
+
1212
+ console.log('');
1213
+ });
1214
+
1215
+ // =============================================================================
1216
+ // Router Commands - AI agent routing
1217
+ // =============================================================================
1218
+
1219
+ program
1220
+ .command('router')
1221
+ .description('AI semantic router operations (requires ruvector-router-core)')
1222
+ .option('--route <text>', 'Route text to best matching intent')
1223
+ .option('--intents <file>', 'Load intents from JSON file')
1224
+ .option('--add-intent <name>', 'Add new intent')
1225
+ .option('--examples <json>', 'Example utterances for intent')
1226
+ .option('--info', 'Show router info')
1227
+ .action(async (options) => {
1228
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1229
+ console.log(chalk.cyan(' RuVector Router'));
1230
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1231
+
1232
+ console.log(chalk.yellow(' Semantic Router for AI Agent Routing\n'));
1233
+
1234
+ if (options.info || (!options.route && !options.intents && !options.addIntent)) {
1235
+ console.log(chalk.cyan(' Features:'));
1236
+ console.log(chalk.gray(' - Semantic intent matching'));
1237
+ console.log(chalk.gray(' - Multi-agent routing'));
1238
+ console.log(chalk.gray(' - Dynamic intent registration'));
1239
+ console.log(chalk.gray(' - Vector-based similarity matching'));
1240
+ console.log('');
1241
+ console.log(chalk.cyan(' Status:'), chalk.yellow('Coming Soon'));
1242
+ console.log(chalk.gray(' The npm package for router is in development.'));
1243
+ console.log(chalk.gray(' Rust crate available: cargo add ruvector-router-core'));
1244
+ console.log('');
1245
+ console.log(chalk.cyan(' Usage (when available):'));
1246
+ console.log(chalk.white(' npx ruvector router --route "What is the weather?"'));
1247
+ console.log(chalk.white(' npx ruvector router --intents intents.json --route "query"'));
1248
+ console.log('');
1249
+ return;
1250
+ }
1251
+
1252
+ if (options.route) {
1253
+ console.log(chalk.yellow(' Input:'), chalk.white(options.route));
1254
+ console.log(chalk.gray(' Router package not yet available in npm.'));
1255
+ console.log(chalk.gray(' Check issue #20 for roadmap.'));
1256
+ }
1257
+
1258
+ console.log('');
1259
+ });
1260
+
1261
+ // =============================================================================
1262
+ // Server Commands - HTTP/gRPC server
1263
+ // =============================================================================
1264
+
1265
+ program
1266
+ .command('server')
1267
+ .description('Start RuVector HTTP/gRPC server')
1268
+ .option('-p, --port <number>', 'HTTP port', '8080')
1269
+ .option('-g, --grpc-port <number>', 'gRPC port', '50051')
1270
+ .option('-d, --data-dir <path>', 'Data directory', './ruvector-data')
1271
+ .option('--http-only', 'Start only HTTP server')
1272
+ .option('--grpc-only', 'Start only gRPC server')
1273
+ .option('--cors', 'Enable CORS for all origins')
1274
+ .option('--info', 'Show server info')
1275
+ .action(async (options) => {
1276
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1277
+ console.log(chalk.cyan(' RuVector Server'));
1278
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1279
+
1280
+ if (options.info || Object.keys(options).filter(k => k !== 'port' && k !== 'grpcPort' && k !== 'dataDir').length === 0) {
1281
+ console.log(chalk.cyan(' Status:'), chalk.yellow('Coming Soon'));
1282
+ console.log('');
1283
+ console.log(chalk.cyan(' Planned Features:'));
1284
+ console.log(chalk.gray(' - REST API for vector operations'));
1285
+ console.log(chalk.gray(' - gRPC high-performance interface'));
1286
+ console.log(chalk.gray(' - WebSocket real-time updates'));
1287
+ console.log(chalk.gray(' - OpenAPI/Swagger documentation'));
1288
+ console.log(chalk.gray(' - Prometheus metrics endpoint'));
1289
+ console.log(chalk.gray(' - Health check endpoints'));
1290
+ console.log('');
1291
+ console.log(chalk.cyan(' Rust binary available:'));
1292
+ console.log(chalk.white(' cargo install ruvector-server # When published'));
1293
+ console.log('');
1294
+ console.log(chalk.cyan(' Configuration (when available):'));
1295
+ console.log(chalk.white(` --port ${options.port} # HTTP port`));
1296
+ console.log(chalk.white(` --grpc-port ${options.grpcPort} # gRPC port`));
1297
+ console.log(chalk.white(` --data-dir ${options.dataDir} # Data directory`));
1298
+ console.log('');
1299
+ console.log(chalk.gray(' Track progress: https://github.com/ruvnet/ruvector/issues/20'));
1300
+ console.log('');
1301
+ return;
1302
+ }
1303
+
1304
+ console.log(chalk.yellow(' Server package not yet available.'));
1305
+ console.log(chalk.gray(' Check issue #20 for roadmap.'));
1306
+ console.log('');
1307
+ });
1308
+
1309
+ // =============================================================================
1310
+ // Cluster Commands - Distributed operations
1311
+ // =============================================================================
1312
+
1313
+ program
1314
+ .command('cluster')
1315
+ .description('Distributed cluster operations')
1316
+ .option('--status', 'Show cluster status')
1317
+ .option('--join <address>', 'Join existing cluster')
1318
+ .option('--leave', 'Leave cluster')
1319
+ .option('--nodes', 'List cluster nodes')
1320
+ .option('--leader', 'Show current leader')
1321
+ .option('--info', 'Show cluster info')
1322
+ .action(async (options) => {
1323
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1324
+ console.log(chalk.cyan(' RuVector Cluster'));
1325
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1326
+
1327
+ console.log(chalk.cyan(' Status:'), chalk.yellow('Coming Soon'));
1328
+ console.log('');
1329
+ console.log(chalk.cyan(' Features:'));
1330
+ console.log(chalk.gray(' - Raft consensus for leader election'));
1331
+ console.log(chalk.gray(' - Automatic failover'));
1332
+ console.log(chalk.gray(' - Data replication'));
1333
+ console.log(chalk.gray(' - Sharding support'));
1334
+ console.log(chalk.gray(' - Distributed queries'));
1335
+ console.log('');
1336
+ console.log(chalk.cyan(' Rust crates available:'));
1337
+ console.log(chalk.white(' cargo add ruvector-cluster # Clustering'));
1338
+ console.log(chalk.white(' cargo add ruvector-raft # Raft consensus'));
1339
+ console.log(chalk.white(' cargo add ruvector-replication # Replication'));
1340
+ console.log('');
1341
+ console.log(chalk.cyan(' Commands (when available):'));
1342
+ console.log(chalk.white(' npx ruvector cluster --status'));
1343
+ console.log(chalk.white(' npx ruvector cluster --join 192.168.1.10:7000'));
1344
+ console.log(chalk.white(' npx ruvector cluster --nodes'));
1345
+ console.log('');
1346
+ console.log(chalk.gray(' Track progress: https://github.com/ruvnet/ruvector/issues/20'));
1347
+ console.log('');
1348
+ });
1349
+
1350
+ // =============================================================================
1351
+ // Export/Import Commands - Database backup/restore
1352
+ // =============================================================================
1353
+
1354
+ program
1355
+ .command('export <database>')
1356
+ .description('Export database to file')
1357
+ .option('-o, --output <file>', 'Output file path')
1358
+ .option('-f, --format <type>', 'Export format (json|binary|parquet)', 'json')
1359
+ .option('--compress', 'Compress output')
1360
+ .option('--vectors-only', 'Export only vectors (no metadata)')
1361
+ .action(async (dbPath, options) => {
1362
+ requireRuvector();
1363
+ const spinner = ora('Exporting database...').start();
1364
+
1365
+ try {
1366
+ const outputFile = options.output || `${dbPath.replace(/\/$/, '')}_export.${options.format}`;
1367
+
1368
+ // Load database
1369
+ const db = new VectorDB({ dimension: 384 }); // Will be overwritten by load
1370
+ if (fs.existsSync(dbPath)) {
1371
+ db.load(dbPath);
1372
+ } else {
1373
+ spinner.fail(chalk.red(`Database not found: ${dbPath}`));
1374
+ process.exit(1);
1375
+ }
1376
+
1377
+ const stats = db.getStats();
1378
+ const data = {
1379
+ version: packageJson.version,
1380
+ exportedAt: new Date().toISOString(),
1381
+ stats: stats,
1382
+ vectors: [] // Would contain actual vector data
1383
+ };
1384
+
1385
+ if (options.format === 'json') {
1386
+ fs.writeFileSync(outputFile, JSON.stringify(data, null, 2));
1387
+ } else {
1388
+ spinner.fail(chalk.yellow(`Format '${options.format}' not yet supported. Using JSON.`));
1389
+ fs.writeFileSync(outputFile.replace(/\.[^.]+$/, '.json'), JSON.stringify(data, null, 2));
1390
+ }
1391
+
1392
+ spinner.succeed(chalk.green(`Exported to: ${outputFile}`));
1393
+ console.log(chalk.gray(` Vectors: ${stats.count || 0}`));
1394
+ console.log(chalk.gray(` Format: ${options.format}`));
1395
+ } catch (error) {
1396
+ spinner.fail(chalk.red('Export failed'));
1397
+ console.error(chalk.red(error.message));
1398
+ process.exit(1);
1399
+ }
1400
+ });
1401
+
1402
+ program
1403
+ .command('import <file>')
1404
+ .description('Import database from file')
1405
+ .option('-d, --database <path>', 'Target database path')
1406
+ .option('--merge', 'Merge with existing data')
1407
+ .option('--replace', 'Replace existing data')
1408
+ .action(async (file, options) => {
1409
+ requireRuvector();
1410
+ const spinner = ora('Importing database...').start();
1411
+
1412
+ try {
1413
+ if (!fs.existsSync(file)) {
1414
+ spinner.fail(chalk.red(`File not found: ${file}`));
1415
+ process.exit(1);
1416
+ }
1417
+
1418
+ const data = JSON.parse(fs.readFileSync(file, 'utf8'));
1419
+ const dbPath = options.database || file.replace(/_export\.json$/, '');
1420
+
1421
+ spinner.text = 'Creating database...';
1422
+
1423
+ const db = new VectorDB({
1424
+ dimension: data.stats?.dimension || 384,
1425
+ path: dbPath,
1426
+ autoPersist: true
1427
+ });
1428
+
1429
+ // Would import actual vectors here
1430
+ db.save(dbPath);
1431
+
1432
+ spinner.succeed(chalk.green(`Imported to: ${dbPath}`));
1433
+ console.log(chalk.gray(` Source version: ${data.version}`));
1434
+ console.log(chalk.gray(` Exported at: ${data.exportedAt}`));
1435
+ } catch (error) {
1436
+ spinner.fail(chalk.red('Import failed'));
1437
+ console.error(chalk.red(error.message));
1438
+ process.exit(1);
1439
+ }
1440
+ });
1441
+
1442
+ // =============================================================================
1443
+ // Embed Command - Generate embeddings
1444
+ // =============================================================================
1445
+
1446
+ program
1447
+ .command('embed')
1448
+ .description('Generate embeddings from text')
1449
+ .option('-t, --text <string>', 'Text to embed')
1450
+ .option('-f, --file <path>', 'File containing text (one per line)')
1451
+ .option('-m, --model <name>', 'Embedding model', 'all-minilm-l6-v2')
1452
+ .option('-o, --output <file>', 'Output file for embeddings')
1453
+ .option('--info', 'Show embedding info')
1454
+ .action(async (options) => {
1455
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1456
+ console.log(chalk.cyan(' RuVector Embed'));
1457
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1458
+
1459
+ if (options.info || (!options.text && !options.file)) {
1460
+ console.log(chalk.cyan(' Generate vector embeddings from text\n'));
1461
+ console.log(chalk.cyan(' Supported Models:'));
1462
+ console.log(chalk.gray(' - all-minilm-l6-v2 (384 dims, fast)'));
1463
+ console.log(chalk.gray(' - nomic-embed-text-v1.5 (768 dims, balanced)'));
1464
+ console.log(chalk.gray(' - openai/text-embedding-3-small (1536 dims, requires API key)'));
1465
+ console.log('');
1466
+ console.log(chalk.cyan(' Status:'), chalk.yellow('Coming Soon'));
1467
+ console.log(chalk.gray(' Built-in embedding generation is planned for future release.'));
1468
+ console.log('');
1469
+ console.log(chalk.cyan(' Current options:'));
1470
+ console.log(chalk.gray(' 1. Use external embedding API (OpenAI, Cohere, etc.)'));
1471
+ console.log(chalk.gray(' 2. Use transformers.js in your application'));
1472
+ console.log(chalk.gray(' 3. Pre-generate embeddings with Python'));
1473
+ console.log('');
1474
+ console.log(chalk.cyan(' Usage (when available):'));
1475
+ console.log(chalk.white(' npx ruvector embed --text "Hello world"'));
1476
+ console.log(chalk.white(' npx ruvector embed --file texts.txt --output embeddings.json'));
1477
+ console.log('');
1478
+ return;
1479
+ }
1480
+
1481
+ if (options.text) {
1482
+ console.log(chalk.yellow(' Input text:'), chalk.white(options.text.substring(0, 50) + '...'));
1483
+ console.log(chalk.yellow(' Model:'), chalk.white(options.model));
1484
+ console.log('');
1485
+ console.log(chalk.gray(' Embedding generation not yet available in CLI.'));
1486
+ console.log(chalk.gray(' Use the SDK or external embedding services.'));
1487
+ }
1488
+
1489
+ console.log('');
1490
+ });
1491
+
1492
+ // =============================================================================
1493
+ // Demo Command - Interactive tutorial
1494
+ // =============================================================================
1495
+
1496
+ program
1497
+ .command('demo')
1498
+ .description('Run interactive demo and tutorials')
1499
+ .option('--basic', 'Basic vector operations demo')
1500
+ .option('--gnn', 'GNN differentiable search demo')
1501
+ .option('--graph', 'Graph database demo')
1502
+ .option('--benchmark', 'Performance benchmark demo')
1503
+ .option('-i, --interactive', 'Interactive mode')
1504
+ .action(async (options) => {
1505
+ console.log(chalk.cyan('\n═══════════════════════════════════════════════════════════════'));
1506
+ console.log(chalk.cyan(' RuVector Demo'));
1507
+ console.log(chalk.cyan('═══════════════════════════════════════════════════════════════\n'));
1508
+
1509
+ const showMenu = !options.basic && !options.gnn && !options.graph && !options.benchmark;
1510
+
1511
+ if (showMenu) {
1512
+ console.log(chalk.yellow(' Available Demos:\n'));
1513
+ console.log(chalk.white(' --basic '), chalk.gray('Basic vector operations (insert, search, delete)'));
1514
+ console.log(chalk.white(' --gnn '), chalk.gray('GNN differentiable search with gradients'));
1515
+ console.log(chalk.white(' --graph '), chalk.gray('Graph database and Cypher queries'));
1516
+ console.log(chalk.white(' --benchmark '), chalk.gray('Performance benchmark suite'));
1517
+ console.log('');
1518
+ console.log(chalk.cyan(' Run a demo:'));
1519
+ console.log(chalk.white(' npx ruvector demo --basic'));
1520
+ console.log(chalk.white(' npx ruvector demo --gnn'));
1521
+ console.log('');
1522
+ return;
1523
+ }
1524
+
1525
+ if (options.basic) {
1526
+ requireRuvector();
1527
+ console.log(chalk.yellow(' Basic Vector Operations Demo\n'));
1528
+
1529
+ const spinner = ora('Creating demo database...').start();
1530
+
1531
+ try {
1532
+ const db = new VectorDB({ dimension: 4, metric: 'cosine' });
1533
+
1534
+ spinner.text = 'Inserting vectors...';
1535
+ db.insert('vec1', [1.0, 0.0, 0.0, 0.0], { label: 'x-axis' });
1536
+ db.insert('vec2', [0.0, 1.0, 0.0, 0.0], { label: 'y-axis' });
1537
+ db.insert('vec3', [0.0, 0.0, 1.0, 0.0], { label: 'z-axis' });
1538
+ db.insert('vec4', [0.7, 0.7, 0.0, 0.0], { label: 'xy-diagonal' });
1539
+
1540
+ spinner.succeed('Demo database created with 4 vectors');
1541
+
1542
+ console.log(chalk.cyan('\n Vectors inserted:'));
1543
+ console.log(chalk.gray(' vec1: [1,0,0,0] - x-axis'));
1544
+ console.log(chalk.gray(' vec2: [0,1,0,0] - y-axis'));
1545
+ console.log(chalk.gray(' vec3: [0,0,1,0] - z-axis'));
1546
+ console.log(chalk.gray(' vec4: [0.7,0.7,0,0] - xy-diagonal'));
1547
+
1548
+ console.log(chalk.cyan('\n Searching for nearest to [0.8, 0.6, 0, 0]:'));
1549
+ const results = db.search([0.8, 0.6, 0.0, 0.0], 3);
1550
+ results.forEach((r, i) => {
1551
+ console.log(chalk.gray(` ${i + 1}. ${r.id} (score: ${r.score.toFixed(4)})`));
1552
+ });
1553
+
1554
+ console.log(chalk.green('\n Demo complete!'));
1555
+ } catch (error) {
1556
+ spinner.fail(chalk.red('Demo failed'));
1557
+ console.error(chalk.red(error.message));
1558
+ }
1559
+ }
1560
+
1561
+ if (options.gnn) {
1562
+ if (!gnnAvailable) {
1563
+ console.log(chalk.yellow(' @ruvector/gnn not installed.'));
1564
+ console.log(chalk.white(' Install with: npm install @ruvector/gnn'));
1565
+ console.log('');
1566
+ return;
1567
+ }
1568
+
1569
+ console.log(chalk.yellow(' GNN Differentiable Search Demo\n'));
1570
+
1571
+ try {
1572
+ console.log(chalk.cyan(' Running differentiable search with gradients...\n'));
1573
+
1574
+ const queryVec = [1.0, 0.5, 0.3, 0.1];
1575
+ const dbVectors = [
1576
+ [1.0, 0.0, 0.0, 0.0],
1577
+ [0.0, 1.0, 0.0, 0.0],
1578
+ [0.5, 0.5, 0.5, 0.5],
1579
+ [0.9, 0.4, 0.2, 0.1]
1580
+ ];
1581
+
1582
+ const result = differentiableSearch(queryVec, dbVectors, 3, 10.0);
1583
+
1584
+ console.log(chalk.cyan(' Query:'), JSON.stringify(queryVec));
1585
+ console.log(chalk.cyan(' Top 3 results:'));
1586
+ result.indices.forEach((idx, i) => {
1587
+ console.log(chalk.gray(` ${i + 1}. Index ${idx} (attention: ${result.attention_weights[i].toFixed(4)})`));
1588
+ });
1589
+
1590
+ console.log(chalk.cyan('\n Gradient flow enabled:'), chalk.green('Yes'));
1591
+ console.log(chalk.gray(' Use for: Neural network training, learned retrieval'));
1592
+
1593
+ console.log(chalk.green('\n GNN demo complete!'));
1594
+ } catch (error) {
1595
+ console.error(chalk.red('GNN demo failed:', error.message));
1596
+ }
1597
+ }
1598
+
1599
+ if (options.graph) {
1600
+ console.log(chalk.yellow(' Graph Database Demo\n'));
1601
+
1602
+ let graphNode;
1603
+ try {
1604
+ graphNode = require('@ruvector/graph-node');
1605
+ console.log(chalk.green(' @ruvector/graph-node is available!'));
1606
+ console.log(chalk.gray(' Full graph demo coming soon.'));
1607
+ } catch (e) {
1608
+ console.log(chalk.yellow(' @ruvector/graph-node not installed.'));
1609
+ console.log(chalk.white(' Install with: npm install @ruvector/graph-node'));
1610
+ }
1611
+ console.log('');
1612
+ }
1613
+
1614
+ if (options.benchmark) {
1615
+ console.log(chalk.yellow(' Redirecting to benchmark command...\n'));
1616
+ console.log(chalk.white(' Run: npx ruvector benchmark'));
1617
+ console.log('');
1618
+ }
1619
+ });
1620
+
858
1621
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruvector",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "High-performance vector database for Node.js with automatic native/WASM fallback",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",