@soulcraft/brainy 0.55.0 → 0.57.0

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.
Files changed (128) hide show
  1. package/README.md +172 -730
  2. package/bin/brainy.js +592 -0
  3. package/dist/augmentations/cortexSense.d.ts +196 -0
  4. package/dist/augmentations/cortexSense.js +747 -0
  5. package/dist/augmentations/cortexSense.js.map +1 -0
  6. package/dist/augmentations/memoryAugmentations.d.ts.map +1 -1
  7. package/dist/augmentations/neuralImportSense.d.ts +196 -0
  8. package/dist/augmentations/neuralImportSense.js +747 -0
  9. package/dist/augmentations/neuralImportSense.js.map +1 -0
  10. package/dist/brainyData.d.ts.map +1 -1
  11. package/dist/brainyData.js +12 -0
  12. package/dist/brainyData.js.map +1 -1
  13. package/dist/chat/brainyChat.d.ts +42 -0
  14. package/dist/chat/brainyChat.js +340 -0
  15. package/dist/chat/brainyChat.js.map +1 -0
  16. package/dist/connectors/interfaces/IConnector.d.ts +143 -0
  17. package/dist/connectors/interfaces/IConnector.js +8 -0
  18. package/dist/connectors/interfaces/IConnector.js.map +1 -0
  19. package/dist/coreTypes.d.ts.map +1 -1
  20. package/dist/cortex/backupRestore.d.ts +85 -0
  21. package/dist/cortex/backupRestore.js +326 -0
  22. package/dist/cortex/backupRestore.js.map +1 -0
  23. package/dist/cortex/cortex.d.ts +249 -0
  24. package/dist/cortex/cortex.js +2304 -0
  25. package/dist/cortex/cortex.js.map +1 -0
  26. package/dist/cortex/healthCheck.d.ts +85 -0
  27. package/dist/cortex/healthCheck.js +546 -0
  28. package/dist/cortex/healthCheck.js.map +1 -0
  29. package/dist/cortex/licensingSystem.d.ts +126 -0
  30. package/dist/cortex/licensingSystem.js +474 -0
  31. package/dist/cortex/licensingSystem.js.map +1 -0
  32. package/dist/cortex/neuralImport.d.ts +145 -0
  33. package/dist/cortex/neuralImport.js +620 -0
  34. package/dist/cortex/neuralImport.js.map +1 -0
  35. package/dist/cortex/performanceMonitor.d.ts +150 -0
  36. package/dist/cortex/performanceMonitor.js +371 -0
  37. package/dist/cortex/performanceMonitor.js.map +1 -0
  38. package/dist/cortex/serviceIntegration.d.ts +156 -0
  39. package/dist/cortex/serviceIntegration.js +384 -0
  40. package/dist/cortex/serviceIntegration.js.map +1 -0
  41. package/dist/cortex/webhookManager.d.ts +39 -0
  42. package/dist/cortex/webhookManager.js +326 -0
  43. package/dist/cortex/webhookManager.js.map +1 -0
  44. package/dist/hnsw/hnswIndex.d.ts.map +1 -1
  45. package/dist/hnsw/hnswIndexOptimized.d.ts.map +1 -1
  46. package/dist/index.d.ts +4 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +5 -0
  49. package/dist/index.js.map +1 -1
  50. package/dist/patched-platform-node.d.ts +17 -0
  51. package/dist/patched-platform-node.d.ts.map +1 -0
  52. package/dist/shared/default-augmentations.d.ts +41 -0
  53. package/dist/shared/default-augmentations.js +112 -0
  54. package/dist/shared/default-augmentations.js.map +1 -0
  55. package/dist/storage/adapters/baseStorageAdapter.d.ts.map +1 -1
  56. package/dist/storage/adapters/fileSystemStorage.d.ts +14 -0
  57. package/dist/storage/adapters/fileSystemStorage.d.ts.map +1 -1
  58. package/dist/storage/adapters/fileSystemStorage.js +68 -0
  59. package/dist/storage/adapters/fileSystemStorage.js.map +1 -1
  60. package/dist/storage/adapters/memoryStorage.d.ts +13 -0
  61. package/dist/storage/adapters/memoryStorage.d.ts.map +1 -1
  62. package/dist/storage/adapters/memoryStorage.js +19 -0
  63. package/dist/storage/adapters/memoryStorage.js.map +1 -1
  64. package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
  65. package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
  66. package/dist/storage/baseStorage.d.ts.map +1 -1
  67. package/dist/storage/storageFactory.d.ts.map +1 -1
  68. package/dist/testing/prettyReporter.d.ts +23 -0
  69. package/dist/testing/prettyReporter.d.ts.map +1 -0
  70. package/dist/testing/prettySummaryReporter.d.ts +22 -0
  71. package/dist/testing/prettySummaryReporter.d.ts.map +1 -0
  72. package/dist/types/augmentations.d.ts +48 -1
  73. package/dist/unified.min.js +12511 -0
  74. package/dist/unified.min.js.map +1 -0
  75. package/dist/utils/embedding.d.ts.map +1 -1
  76. package/dist/utils/embedding.js +1 -0
  77. package/dist/utils/embedding.js.map +1 -1
  78. package/dist/utils/index.d.ts.map +1 -1
  79. package/dist/utils/tensorflowUtils.d.ts +17 -0
  80. package/dist/utils/tensorflowUtils.d.ts.map +1 -0
  81. package/dist/webhooks/webhookSystem.d.ts +114 -0
  82. package/dist/webhooks/webhookSystem.js +321 -0
  83. package/dist/webhooks/webhookSystem.js.map +1 -0
  84. package/package.json +11 -1
  85. package/dist/browserFramework.d.ts.map +0 -1
  86. package/dist/cortex/cli.d.ts +0 -8
  87. package/dist/cortex/cli.js +0 -207
  88. package/dist/cortex/cli.js.map +0 -1
  89. package/dist/cortex/commands/index.d.ts +0 -79
  90. package/dist/cortex/commands/index.js +0 -614
  91. package/dist/cortex/commands/index.js.map +0 -1
  92. package/dist/cortex/config.d.ts +0 -112
  93. package/dist/cortex/config.js +0 -312
  94. package/dist/cortex/config.js.map +0 -1
  95. package/dist/demo.d.ts.map +0 -1
  96. package/dist/distributed/configManager.d.ts.map +0 -1
  97. package/dist/distributed/domainDetector.d.ts.map +0 -1
  98. package/dist/distributed/hashPartitioner.d.ts.map +0 -1
  99. package/dist/distributed/healthMonitor.d.ts.map +0 -1
  100. package/dist/distributed/index.d.ts.map +0 -1
  101. package/dist/distributed/operationalModes.d.ts.map +0 -1
  102. package/dist/hnsw/distributedSearch.d.ts.map +0 -1
  103. package/dist/hnsw/optimizedHNSWIndex.d.ts.map +0 -1
  104. package/dist/hnsw/partitionedHNSWIndex.d.ts.map +0 -1
  105. package/dist/hnsw/scaledHNSWSystem.d.ts.map +0 -1
  106. package/dist/storage/adapters/batchS3Operations.d.ts.map +0 -1
  107. package/dist/storage/adapters/optimizedS3Search.d.ts.map +0 -1
  108. package/dist/storage/cacheManager.d.ts.map +0 -1
  109. package/dist/storage/enhancedCacheManager.d.ts.map +0 -1
  110. package/dist/storage/readOnlyOptimizations.d.ts.map +0 -1
  111. package/dist/types/distributedTypes.d.ts.map +0 -1
  112. package/dist/types/paginationTypes.d.ts.map +0 -1
  113. package/dist/types/tensorflowTypes.js +0 -6
  114. package/dist/types/tensorflowTypes.js.map +0 -1
  115. package/dist/utils/autoConfiguration.d.ts.map +0 -1
  116. package/dist/utils/cacheAutoConfig.d.ts.map +0 -1
  117. package/dist/utils/crypto.d.ts.map +0 -1
  118. package/dist/utils/fieldNameTracking.d.ts.map +0 -1
  119. package/dist/utils/jsonProcessing.d.ts.map +0 -1
  120. package/dist/utils/logger.d.ts.map +0 -1
  121. package/dist/utils/robustModelLoader.d.ts +0 -112
  122. package/dist/utils/robustModelLoader.d.ts.map +0 -1
  123. package/dist/utils/robustModelLoader.js +0 -624
  124. package/dist/utils/robustModelLoader.js.map +0 -1
  125. package/dist/utils/searchCache.d.ts.map +0 -1
  126. package/dist/utils/statisticsCollector.d.ts.map +0 -1
  127. package/dist/utils/typeUtils.d.ts.map +0 -1
  128. package/dist/utils/version.d.ts.map +0 -1
package/bin/brainy.js ADDED
@@ -0,0 +1,592 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Brainy CLI - Beautiful command center for the vector + graph database
5
+ */
6
+
7
+ // @ts-ignore
8
+ import { program } from 'commander'
9
+ import { Cortex } from '../dist/cortex/cortex.js'
10
+ // @ts-ignore
11
+ import chalk from 'chalk'
12
+ import { readFileSync } from 'fs'
13
+ import { dirname, join } from 'path'
14
+ import { fileURLToPath } from 'url'
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url))
17
+ const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'))
18
+
19
+ // Create Cortex instance
20
+ const cortex = new Cortex()
21
+
22
+ // Helper to ensure proper process exit
23
+ const exitProcess = (code = 0) => {
24
+ setTimeout(() => {
25
+ process.exit(code)
26
+ }, 100)
27
+ }
28
+
29
+ // Wrap async actions to ensure proper exit
30
+ const wrapAction = (fn) => {
31
+ return async (...args) => {
32
+ try {
33
+ await fn(...args)
34
+ // Always exit for non-interactive commands
35
+ exitProcess(0)
36
+ } catch (error) {
37
+ console.error(chalk.red('Error:'), error.message)
38
+ exitProcess(1)
39
+ }
40
+ }
41
+ }
42
+
43
+ // Wrap interactive actions with explicit exit
44
+ const wrapInteractive = (fn) => {
45
+ return async (...args) => {
46
+ try {
47
+ await fn(...args)
48
+ exitProcess(0)
49
+ } catch (error) {
50
+ console.error(chalk.red('Error:'), error.message)
51
+ exitProcess(1)
52
+ }
53
+ }
54
+ }
55
+
56
+ // Setup program
57
+ program
58
+ .name('cortex')
59
+ .description('🧠 Cortex - Command Center for Brainy')
60
+ .version(packageJson.version)
61
+
62
+ // Initialize command
63
+ program
64
+ .command('init')
65
+ .description('Initialize Cortex in your project')
66
+ .option('-s, --storage <type>', 'Storage type (filesystem, s3, r2, gcs, memory)')
67
+ .option('-e, --encryption', 'Enable encryption for secrets')
68
+ .action(wrapAction(async (options) => {
69
+ await cortex.init(options)
70
+ }))
71
+
72
+ // Chat commands (simplified - just 'chat', no alias)
73
+ program
74
+ .command('chat [question]')
75
+ .description('💬 Chat with your data (interactive mode if no question)')
76
+ .option('-l, --llm <model>', 'LLM model to use')
77
+ .action(wrapInteractive(async (question, options) => {
78
+ await cortex.chat(question)
79
+ }))
80
+
81
+ // Data management commands
82
+ program
83
+ .command('add [data]')
84
+ .description('📊 Add data to Brainy')
85
+ .option('-m, --metadata <json>', 'Metadata as JSON')
86
+ .option('-i, --id <id>', 'Custom ID')
87
+ .action(async (data, options) => {
88
+ let metadata = {}
89
+ if (options.metadata) {
90
+ try {
91
+ metadata = JSON.parse(options.metadata)
92
+ } catch {
93
+ console.error(chalk.red('Invalid JSON metadata'))
94
+ process.exit(1)
95
+ }
96
+ }
97
+ if (options.id) {
98
+ metadata.id = options.id
99
+ }
100
+ await cortex.add(data, metadata)
101
+ exitProcess(0)
102
+ })
103
+
104
+ program
105
+ .command('search <query>')
106
+ .description('🔍 Search your database with advanced options')
107
+ .option('-l, --limit <number>', 'Number of results', '10')
108
+ .option('-f, --filter <json>', 'MongoDB-style metadata filters')
109
+ .option('-v, --verbs <types>', 'Graph verb types to traverse (comma-separated)')
110
+ .option('-d, --depth <number>', 'Graph traversal depth', '1')
111
+ .action(async (query, options) => {
112
+ const searchOptions = { limit: parseInt(options.limit) }
113
+
114
+ if (options.filter) {
115
+ try {
116
+ searchOptions.filter = JSON.parse(options.filter)
117
+ } catch {
118
+ console.error(chalk.red('Invalid filter JSON'))
119
+ process.exit(1)
120
+ }
121
+ }
122
+
123
+ if (options.verbs) {
124
+ searchOptions.verbs = options.verbs.split(',').map(v => v.trim())
125
+ searchOptions.depth = parseInt(options.depth)
126
+ }
127
+
128
+ await cortex.search(query, searchOptions)
129
+ exitProcess(0)
130
+ })
131
+
132
+ program
133
+ .command('find')
134
+ .description('🔍 Interactive advanced search with filters and graph traversal')
135
+ .action(wrapInteractive(async () => {
136
+ await cortex.advancedSearch()
137
+ }))
138
+
139
+ program
140
+ .command('update <id> <data>')
141
+ .description('✏️ Update existing data')
142
+ .option('-m, --metadata <json>', 'New metadata as JSON')
143
+ .action(async (id, data, options) => {
144
+ let metadata = {}
145
+ if (options.metadata) {
146
+ try {
147
+ metadata = JSON.parse(options.metadata)
148
+ } catch {
149
+ console.error(chalk.red('Invalid metadata JSON'))
150
+ process.exit(1)
151
+ }
152
+ }
153
+ await cortex.update(id, data, metadata)
154
+ exitProcess(0)
155
+ })
156
+
157
+ program
158
+ .command('delete <id>')
159
+ .description('🗑️ Delete data by ID')
160
+ .action(wrapAction(async (id) => {
161
+ await cortex.delete(id)
162
+ }))
163
+
164
+ // Graph commands
165
+ program
166
+ .command('verb <subject> <verb> <object>')
167
+ .description('🔗 Add graph relationship between nodes')
168
+ .option('-m, --metadata <json>', 'Relationship metadata')
169
+ .action(async (subject, verb, object, options) => {
170
+ let metadata = {}
171
+ if (options.metadata) {
172
+ try {
173
+ metadata = JSON.parse(options.metadata)
174
+ } catch {
175
+ console.error(chalk.red('Invalid metadata JSON'))
176
+ process.exit(1)
177
+ }
178
+ }
179
+ await cortex.addVerb(subject, verb, object, metadata)
180
+ exitProcess(0)
181
+ })
182
+
183
+ program
184
+ .command('explore [nodeId]')
185
+ .description('🗺️ Interactively explore graph connections')
186
+ .action(wrapInteractive(async (nodeId) => {
187
+ await cortex.explore(nodeId)
188
+ }))
189
+
190
+ // Configuration commands
191
+ const config = program.command('config')
192
+ .description('⚙️ Manage configuration')
193
+
194
+ config
195
+ .command('set <key> <value>')
196
+ .description('Set configuration value')
197
+ .option('-e, --encrypt', 'Encrypt this value')
198
+ .action(wrapAction(async (key, value, options) => {
199
+ await cortex.configSet(key, value, options)
200
+ }))
201
+
202
+ config
203
+ .command('get <key>')
204
+ .description('Get configuration value')
205
+ .action(async (key) => {
206
+ const value = await cortex.configGet(key)
207
+ if (value) {
208
+ console.log(chalk.green(`${key}: ${value}`))
209
+ } else {
210
+ console.log(chalk.yellow(`Key not found: ${key}`))
211
+ }
212
+ exitProcess(0)
213
+ })
214
+
215
+ config
216
+ .command('list')
217
+ .description('List all configuration')
218
+ .action(wrapAction(async () => {
219
+ await cortex.configList()
220
+ }))
221
+
222
+ config
223
+ .command('import <file>')
224
+ .description('Import configuration from .env file')
225
+ .action(wrapAction(async (file) => {
226
+ await cortex.importEnv(file)
227
+ }))
228
+
229
+ config
230
+ .command('export <file>')
231
+ .description('Export configuration to .env file')
232
+ .action(wrapAction(async (file) => {
233
+ await cortex.exportEnv(file)
234
+ }))
235
+
236
+ config
237
+ .command('key-rotate')
238
+ .description('🔄 Rotate master encryption key')
239
+ .action(wrapInteractive(async () => {
240
+ await cortex.resetMasterKey()
241
+ }))
242
+
243
+ config
244
+ .command('secrets-patterns')
245
+ .description('🛡️ List secret detection patterns')
246
+ .action(wrapAction(async () => {
247
+ await cortex.listSecretPatterns()
248
+ }))
249
+
250
+ config
251
+ .command('secrets-add <pattern>')
252
+ .description('➕ Add custom secret detection pattern')
253
+ .action(wrapAction(async (pattern) => {
254
+ await cortex.addSecretPattern(pattern)
255
+ }))
256
+
257
+ config
258
+ .command('secrets-remove <pattern>')
259
+ .description('➖ Remove custom secret detection pattern')
260
+ .action(wrapAction(async (pattern) => {
261
+ await cortex.removeSecretPattern(pattern)
262
+ }))
263
+
264
+ // Migration commands
265
+ program
266
+ .command('migrate')
267
+ .description('📦 Migrate to different storage')
268
+ .requiredOption('-t, --to <type>', 'Target storage type (filesystem, s3, r2, gcs, memory)')
269
+ .option('-b, --bucket <name>', 'Bucket name for cloud storage')
270
+ .option('-s, --strategy <type>', 'Migration strategy', 'immediate')
271
+ .action(wrapInteractive(async (options) => {
272
+ await cortex.migrate(options)
273
+ }))
274
+
275
+ // Database operations
276
+ program
277
+ .command('stats')
278
+ .description('📊 Show database statistics')
279
+ .option('-d, --detailed', 'Show detailed field statistics')
280
+ .action(wrapAction(async (options) => {
281
+ await cortex.stats(options.detailed)
282
+ }))
283
+
284
+ program
285
+ .command('fields')
286
+ .description('📋 List all searchable fields with samples')
287
+ .action(wrapAction(async () => {
288
+ await cortex.listFields()
289
+ }))
290
+
291
+ // LLM setup
292
+ program
293
+ .command('llm [provider]')
294
+ .description('🤖 Setup or change LLM provider')
295
+ .action(wrapInteractive(async (provider) => {
296
+ await cortex.setupLLM(provider)
297
+ }))
298
+
299
+ // Embedding utilities
300
+ program
301
+ .command('embed <text>')
302
+ .description('✨ Generate embedding vector for text')
303
+ .action(wrapAction(async (text) => {
304
+ await cortex.embed(text)
305
+ }))
306
+
307
+ program
308
+ .command('similarity <text1> <text2>')
309
+ .description('🔍 Calculate semantic similarity between texts')
310
+ .action(wrapAction(async (text1, text2) => {
311
+ await cortex.similarity(text1, text2)
312
+ }))
313
+
314
+ program
315
+ .command('backup')
316
+ .description('💾 Create database backup')
317
+ .option('-c, --compress', 'Compress backup')
318
+ .option('-o, --output <file>', 'Output file')
319
+ .action(wrapAction(async (options) => {
320
+ await cortex.backup(options)
321
+ }))
322
+
323
+ program
324
+ .command('restore <file>')
325
+ .description('♻️ Restore from backup')
326
+ .action(wrapInteractive(async (file) => {
327
+ await cortex.restore(file)
328
+ }))
329
+
330
+ program
331
+ .command('health')
332
+ .description('🏥 Check database health')
333
+ .action(wrapAction(async () => {
334
+ await cortex.health()
335
+ }))
336
+
337
+ // Backup & Restore commands
338
+ program
339
+ .command('backup')
340
+ .description('💾 Create atomic vault backup')
341
+ .option('-c, --compress', 'Enable quantum compression')
342
+ .option('-o, --output <file>', 'Output file path')
343
+ .option('--password <password>', 'Encrypt backup with password')
344
+ .action(wrapAction(async (options) => {
345
+ await cortex.backup(options)
346
+ }))
347
+
348
+ program
349
+ .command('restore <file>')
350
+ .description('♻️ Restore from atomic vault')
351
+ .option('--password <password>', 'Decrypt backup with password')
352
+ .option('--dry-run', 'Simulate restore without making changes')
353
+ .action(wrapInteractive(async (file, options) => {
354
+ await cortex.restore(file, options)
355
+ }))
356
+
357
+ program
358
+ .command('backups')
359
+ .description('📋 List available atomic vault backups')
360
+ .option('-d, --directory <path>', 'Backup directory', './backups')
361
+ .action(wrapAction(async (options) => {
362
+ await cortex.listBackups(options.directory)
363
+ }))
364
+
365
+ // Augmentation Management commands
366
+ program
367
+ .command('augmentations')
368
+ .description('🧠 Show augmentation status and management')
369
+ .option('-v, --verbose', 'Show detailed augmentation information')
370
+ .action(wrapInteractive(async (options) => {
371
+ await cortex.augmentations(options)
372
+ }))
373
+
374
+ // Performance Monitoring & Health Check commands
375
+ program
376
+ .command('monitor')
377
+ .description('📊 Monitor vector + graph database performance')
378
+ .option('-d, --dashboard', 'Launch interactive performance dashboard')
379
+ .action(wrapInteractive(async (options) => {
380
+ await cortex.monitor(options)
381
+ }))
382
+
383
+ program
384
+ .command('health')
385
+ .description('🔋 Check system health and diagnostics')
386
+ .option('--auto-fix', 'Automatically apply safe repairs')
387
+ .action(wrapAction(async (options) => {
388
+ await cortex.health(options)
389
+ }))
390
+
391
+ program
392
+ .command('performance')
393
+ .description('⚡ Analyze database performance metrics')
394
+ .option('--analyze', 'Deep performance analysis with trends')
395
+ .action(wrapAction(async (options) => {
396
+ await cortex.performance(options)
397
+ }))
398
+
399
+ // Premium Licensing commands
400
+ const license = program.command('license')
401
+ .description('👑 Manage premium licenses and features')
402
+
403
+ license
404
+ .command('catalog')
405
+ .description('📋 Browse premium features catalog')
406
+ .action(wrapAction(async () => {
407
+ await cortex.licenseCatalog()
408
+ }))
409
+
410
+ license
411
+ .command('status [license-id]')
412
+ .description('📊 Check license status and usage')
413
+ .action(wrapAction(async (licenseId) => {
414
+ await cortex.licenseStatus(licenseId)
415
+ }))
416
+
417
+ license
418
+ .command('trial <feature>')
419
+ .description('⏰ Start free trial for premium feature')
420
+ .option('--name <name>', 'Your name')
421
+ .option('--email <email>', 'Your email address')
422
+ .action(wrapAction(async (feature, options) => {
423
+ await cortex.licenseTrial(feature, options.name, options.email)
424
+ }))
425
+
426
+ license
427
+ .command('validate <feature>')
428
+ .description('✅ Validate feature license availability')
429
+ .action(wrapAction(async (feature) => {
430
+ await cortex.licenseValidate(feature)
431
+ }))
432
+
433
+ // Augmentation management commands
434
+ const augment = program.command('augment')
435
+ .description('🧩 Manage augmentation pipeline')
436
+
437
+ augment
438
+ .command('list')
439
+ .description('📋 List all augmentations and pipeline status')
440
+ .action(wrapAction(async () => {
441
+ await cortex.listAugmentations()
442
+ }))
443
+
444
+ augment
445
+ .command('add <type>')
446
+ .description('➕ Add augmentation to pipeline')
447
+ .option('-p, --position <number>', 'Pipeline position')
448
+ .option('-c, --config <json>', 'Configuration as JSON')
449
+ .action(wrapAction(async (type, options) => {
450
+ let config = {}
451
+ if (options.config) {
452
+ try {
453
+ config = JSON.parse(options.config)
454
+ } catch {
455
+ console.error(chalk.red('Invalid JSON configuration'))
456
+ process.exit(1)
457
+ }
458
+ }
459
+ await cortex.addAugmentation(type, options.position ? parseInt(options.position) : undefined, config)
460
+ }))
461
+
462
+ augment
463
+ .command('remove <type>')
464
+ .description('➖ Remove augmentation from pipeline')
465
+ .action(wrapAction(async (type) => {
466
+ await cortex.removeAugmentation(type)
467
+ }))
468
+
469
+ augment
470
+ .command('configure <type> <config>')
471
+ .description('⚙️ Configure existing augmentation')
472
+ .action(wrapAction(async (type, configJson) => {
473
+ let config = {}
474
+ try {
475
+ config = JSON.parse(configJson)
476
+ } catch {
477
+ console.error(chalk.red('Invalid JSON configuration'))
478
+ process.exit(1)
479
+ }
480
+ await cortex.configureAugmentation(type, config)
481
+ }))
482
+
483
+ augment
484
+ .command('reset')
485
+ .description('🔄 Reset pipeline to defaults')
486
+ .action(wrapInteractive(async () => {
487
+ await cortex.resetPipeline()
488
+ }))
489
+
490
+ augment
491
+ .command('execute <step> [data]')
492
+ .description('⚡ Execute specific pipeline step')
493
+ .action(wrapAction(async (step, data) => {
494
+ const inputData = data ? JSON.parse(data) : { test: true }
495
+ await cortex.executePipelineStep(step, inputData)
496
+ }))
497
+
498
+ // Neural Import commands - The AI-Powered Data Understanding System
499
+ const neural = program.command('neural')
500
+ .description('🧠 AI-powered data analysis and import')
501
+
502
+ neural
503
+ .command('import <file>')
504
+ .description('🧠 Smart import with AI analysis')
505
+ .option('-c, --confidence <threshold>', 'Confidence threshold (0-1)', '0.7')
506
+ .option('-a, --auto-apply', 'Auto-apply without confirmation')
507
+ .option('-w, --enable-weights', 'Enable relationship weights', true)
508
+ .option('--skip-duplicates', 'Skip duplicate detection', true)
509
+ .action(wrapInteractive(async (file, options) => {
510
+ const importOptions = {
511
+ confidenceThreshold: parseFloat(options.confidence),
512
+ autoApply: options.autoApply,
513
+ enableWeights: options.enableWeights,
514
+ skipDuplicates: options.skipDuplicates
515
+ }
516
+ await cortex.neuralImport(file, importOptions)
517
+ }))
518
+
519
+ neural
520
+ .command('analyze <file>')
521
+ .description('🔬 Analyze data structure without importing')
522
+ .action(wrapAction(async (file) => {
523
+ await cortex.neuralAnalyze(file)
524
+ }))
525
+
526
+ neural
527
+ .command('validate <file>')
528
+ .description('✅ Validate data import compatibility')
529
+ .action(wrapAction(async (file) => {
530
+ await cortex.neuralValidate(file)
531
+ }))
532
+
533
+ neural
534
+ .command('types')
535
+ .description('📋 Show available noun and verb types')
536
+ .action(wrapAction(async () => {
537
+ await cortex.neuralTypes()
538
+ }))
539
+
540
+ // Service integration commands
541
+ const service = program.command('service')
542
+ .description('🛠️ Service integration and management')
543
+
544
+ service
545
+ .command('discover')
546
+ .description('🔍 Discover Brainy services in environment')
547
+ .action(wrapAction(async () => {
548
+ console.log('🔍 Discovering services...')
549
+ // This would call CortexServiceIntegration.discoverBrainyInstances()
550
+ console.log('📋 Service discovery complete (placeholder)')
551
+ }))
552
+
553
+ service
554
+ .command('health-all')
555
+ .description('🩺 Health check all discovered services')
556
+ .action(wrapAction(async () => {
557
+ console.log('🩺 Running health checks on all services...')
558
+ // This would call CortexServiceIntegration.healthCheckAll()
559
+ console.log('✅ Health checks complete (placeholder)')
560
+ }))
561
+
562
+ service
563
+ .command('migrate-all')
564
+ .description('🚀 Migrate all services to new storage')
565
+ .requiredOption('-t, --to <type>', 'Target storage type')
566
+ .option('-s, --strategy <type>', 'Migration strategy', 'immediate')
567
+ .action(wrapInteractive(async (options) => {
568
+ console.log(`🚀 Planning migration to ${options.to}...`)
569
+ // This would call CortexServiceIntegration.migrateAll()
570
+ console.log('✅ Migration complete (placeholder)')
571
+ }))
572
+
573
+ // Interactive shell
574
+ program
575
+ .command('shell')
576
+ .description('🐚 Interactive Cortex shell')
577
+ .action(async () => {
578
+ console.log(chalk.cyan('🧠 Cortex Interactive Shell'))
579
+ console.log(chalk.dim('Type "help" for commands, "exit" to quit\n'))
580
+
581
+ // Start interactive mode
582
+ await cortex.chat()
583
+ exitProcess(0)
584
+ })
585
+
586
+ // Parse arguments
587
+ program.parse(process.argv)
588
+
589
+ // Show help if no command
590
+ if (!process.argv.slice(2).length) {
591
+ program.outputHelp()
592
+ }