@soulcraft/brainy 0.58.0 → 0.58.1

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 (154) hide show
  1. package/bin/brainy.js +260 -389
  2. package/dist/augmentations/conduitAugmentations.js +1 -1
  3. package/dist/augmentations/conduitAugmentations.js.map +1 -1
  4. package/dist/augmentations/cortexSense.js +3 -3
  5. package/dist/augmentations/cortexSense.js.map +1 -1
  6. package/dist/brainyData.js +2 -1
  7. package/dist/brainyData.js.map +1 -1
  8. package/dist/browserFramework.minimal.d.ts +14 -0
  9. package/dist/browserFramework.minimal.js +31 -0
  10. package/dist/browserFramework.minimal.js.map +1 -0
  11. package/dist/cortex/backupRestore.js +2 -2
  12. package/dist/cortex/backupRestore.js.map +1 -1
  13. package/dist/cortex/cortex.d.ts +17 -2
  14. package/dist/cortex/cortex.js +262 -103
  15. package/dist/cortex/cortex.js.map +1 -1
  16. package/dist/cortex/neuralImport.js +2 -2
  17. package/dist/cortex/neuralImport.js.map +1 -1
  18. package/dist/cortex/serviceIntegration.js +2 -2
  19. package/dist/cortex/serviceIntegration.js.map +1 -1
  20. package/dist/distributed/configManager.js +1 -1
  21. package/dist/distributed/configManager.js.map +1 -1
  22. package/dist/index.d.ts +0 -1
  23. package/dist/index.js +2 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/mcp/brainyMCPAdapter.js +1 -1
  26. package/dist/mcp/brainyMCPAdapter.js.map +1 -1
  27. package/dist/mcp/brainyMCPBroadcast.d.ts +82 -0
  28. package/dist/mcp/brainyMCPBroadcast.js +303 -0
  29. package/dist/mcp/brainyMCPBroadcast.js.map +1 -0
  30. package/dist/mcp/brainyMCPClient.d.ts +92 -0
  31. package/dist/mcp/brainyMCPClient.js +254 -0
  32. package/dist/mcp/brainyMCPClient.js.map +1 -0
  33. package/dist/mcp/brainyMCPService.js +1 -1
  34. package/dist/mcp/brainyMCPService.js.map +1 -1
  35. package/dist/mcp/mcpAugmentationToolset.js +1 -1
  36. package/dist/mcp/mcpAugmentationToolset.js.map +1 -1
  37. package/dist/universal/crypto.d.ts +64 -0
  38. package/dist/universal/crypto.js +215 -0
  39. package/dist/universal/crypto.js.map +1 -0
  40. package/dist/universal/events.d.ts +31 -0
  41. package/dist/universal/events.js +156 -0
  42. package/dist/universal/events.js.map +1 -0
  43. package/dist/universal/fs.d.ts +102 -0
  44. package/dist/universal/fs.js +304 -0
  45. package/dist/universal/fs.js.map +1 -0
  46. package/dist/universal/index.d.ts +16 -0
  47. package/dist/universal/index.js +23 -0
  48. package/dist/universal/index.js.map +1 -0
  49. package/dist/universal/path.d.ts +51 -0
  50. package/dist/universal/path.js +161 -0
  51. package/dist/universal/path.js.map +1 -0
  52. package/dist/universal/uuid.d.ts +10 -0
  53. package/dist/universal/uuid.js +21 -0
  54. package/dist/universal/uuid.js.map +1 -0
  55. package/package.json +54 -2
  56. package/dist/augmentationFactory.d.ts.map +0 -1
  57. package/dist/augmentationPipeline.d.ts.map +0 -1
  58. package/dist/augmentationRegistry.d.ts.map +0 -1
  59. package/dist/augmentationRegistryLoader.d.ts.map +0 -1
  60. package/dist/augmentations/conduitAugmentations.d.ts.map +0 -1
  61. package/dist/augmentations/memoryAugmentations.d.ts.map +0 -1
  62. package/dist/augmentations/serverSearchAugmentations.d.ts.map +0 -1
  63. package/dist/brainyData.d.ts.map +0 -1
  64. package/dist/browserFramework.d.ts.map +0 -1
  65. package/dist/coreTypes.d.ts.map +0 -1
  66. package/dist/cortex/cli.d.ts +0 -8
  67. package/dist/cortex/cli.js +0 -207
  68. package/dist/cortex/cli.js.map +0 -1
  69. package/dist/cortex/commands/index.d.ts +0 -79
  70. package/dist/cortex/commands/index.js +0 -614
  71. package/dist/cortex/commands/index.js.map +0 -1
  72. package/dist/cortex/config.d.ts +0 -112
  73. package/dist/cortex/config.js +0 -312
  74. package/dist/cortex/config.js.map +0 -1
  75. package/dist/cortex/licensingSystem.d.ts +0 -126
  76. package/dist/cortex/licensingSystem.js +0 -474
  77. package/dist/cortex/licensingSystem.js.map +0 -1
  78. package/dist/cortex/webhookManager.d.ts +0 -39
  79. package/dist/cortex/webhookManager.js +0 -326
  80. package/dist/cortex/webhookManager.js.map +0 -1
  81. package/dist/demo.d.ts.map +0 -1
  82. package/dist/distributed/configManager.d.ts.map +0 -1
  83. package/dist/distributed/domainDetector.d.ts.map +0 -1
  84. package/dist/distributed/hashPartitioner.d.ts.map +0 -1
  85. package/dist/distributed/healthMonitor.d.ts.map +0 -1
  86. package/dist/distributed/index.d.ts.map +0 -1
  87. package/dist/distributed/operationalModes.d.ts.map +0 -1
  88. package/dist/errors/brainyError.d.ts.map +0 -1
  89. package/dist/examples/basicUsage.d.ts.map +0 -1
  90. package/dist/hnsw/distributedSearch.d.ts.map +0 -1
  91. package/dist/hnsw/hnswIndex.d.ts.map +0 -1
  92. package/dist/hnsw/hnswIndexOptimized.d.ts.map +0 -1
  93. package/dist/hnsw/optimizedHNSWIndex.d.ts.map +0 -1
  94. package/dist/hnsw/partitionedHNSWIndex.d.ts.map +0 -1
  95. package/dist/hnsw/scaledHNSWSystem.d.ts.map +0 -1
  96. package/dist/index.d.ts.map +0 -1
  97. package/dist/mcp/brainyMCPAdapter.d.ts.map +0 -1
  98. package/dist/mcp/brainyMCPService.d.ts.map +0 -1
  99. package/dist/mcp/index.d.ts.map +0 -1
  100. package/dist/mcp/mcpAugmentationToolset.d.ts.map +0 -1
  101. package/dist/pipeline.d.ts.map +0 -1
  102. package/dist/sequentialPipeline.d.ts.map +0 -1
  103. package/dist/setup.d.ts.map +0 -1
  104. package/dist/storage/adapters/baseStorageAdapter.d.ts.map +0 -1
  105. package/dist/storage/adapters/batchS3Operations.d.ts.map +0 -1
  106. package/dist/storage/adapters/fileSystemStorage.d.ts.map +0 -1
  107. package/dist/storage/adapters/memoryStorage.d.ts.map +0 -1
  108. package/dist/storage/adapters/opfsStorage.d.ts.map +0 -1
  109. package/dist/storage/adapters/optimizedS3Search.d.ts.map +0 -1
  110. package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +0 -1
  111. package/dist/storage/baseStorage.d.ts.map +0 -1
  112. package/dist/storage/cacheManager.d.ts.map +0 -1
  113. package/dist/storage/enhancedCacheManager.d.ts.map +0 -1
  114. package/dist/storage/readOnlyOptimizations.d.ts.map +0 -1
  115. package/dist/storage/storageFactory.d.ts.map +0 -1
  116. package/dist/types/augmentations.d.ts.map +0 -1
  117. package/dist/types/brainyDataInterface.d.ts.map +0 -1
  118. package/dist/types/distributedTypes.d.ts.map +0 -1
  119. package/dist/types/fileSystemTypes.d.ts.map +0 -1
  120. package/dist/types/graphTypes.d.ts.map +0 -1
  121. package/dist/types/mcpTypes.d.ts.map +0 -1
  122. package/dist/types/paginationTypes.d.ts.map +0 -1
  123. package/dist/types/pipelineTypes.d.ts.map +0 -1
  124. package/dist/types/tensorflowTypes.d.ts +0 -26
  125. package/dist/types/tensorflowTypes.d.ts.map +0 -1
  126. package/dist/types/tensorflowTypes.js +0 -6
  127. package/dist/types/tensorflowTypes.js.map +0 -1
  128. package/dist/unified.d.ts.map +0 -1
  129. package/dist/utils/autoConfiguration.d.ts.map +0 -1
  130. package/dist/utils/cacheAutoConfig.d.ts.map +0 -1
  131. package/dist/utils/crypto.d.ts.map +0 -1
  132. package/dist/utils/distance.d.ts.map +0 -1
  133. package/dist/utils/embedding.d.ts.map +0 -1
  134. package/dist/utils/environment.d.ts.map +0 -1
  135. package/dist/utils/fieldNameTracking.d.ts.map +0 -1
  136. package/dist/utils/index.d.ts.map +0 -1
  137. package/dist/utils/jsonProcessing.d.ts.map +0 -1
  138. package/dist/utils/logger.d.ts.map +0 -1
  139. package/dist/utils/operationUtils.d.ts.map +0 -1
  140. package/dist/utils/robustModelLoader.d.ts +0 -112
  141. package/dist/utils/robustModelLoader.d.ts.map +0 -1
  142. package/dist/utils/robustModelLoader.js +0 -624
  143. package/dist/utils/robustModelLoader.js.map +0 -1
  144. package/dist/utils/searchCache.d.ts.map +0 -1
  145. package/dist/utils/statistics.d.ts.map +0 -1
  146. package/dist/utils/statisticsCollector.d.ts.map +0 -1
  147. package/dist/utils/textEncoding.d.ts.map +0 -1
  148. package/dist/utils/typeUtils.d.ts.map +0 -1
  149. package/dist/utils/version.d.ts.map +0 -1
  150. package/dist/utils/workerUtils.d.ts.map +0 -1
  151. package/dist/webhooks/webhookSystem.d.ts +0 -114
  152. package/dist/webhooks/webhookSystem.js +0 -321
  153. package/dist/webhooks/webhookSystem.js.map +0 -1
  154. package/dist/worker.d.ts.map +0 -1
package/bin/brainy.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Brainy CLI - Beautiful command center for the vector + graph database
4
+ * Brainy CLI - Redesigned for Better UX
5
+ * Direct commands + Augmentation system
5
6
  */
6
7
 
7
8
  // @ts-ignore
@@ -19,19 +20,15 @@ const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'
19
20
  // Create Cortex instance
20
21
  const cortex = new Cortex()
21
22
 
22
- // Helper to ensure proper process exit
23
+ // Helper functions
23
24
  const exitProcess = (code = 0) => {
24
- setTimeout(() => {
25
- process.exit(code)
26
- }, 100)
25
+ setTimeout(() => process.exit(code), 100)
27
26
  }
28
27
 
29
- // Wrap async actions to ensure proper exit
30
28
  const wrapAction = (fn) => {
31
29
  return async (...args) => {
32
30
  try {
33
31
  await fn(...args)
34
- // Always exit for non-interactive commands
35
32
  exitProcess(0)
36
33
  } catch (error) {
37
34
  console.error(chalk.red('Error:'), error.message)
@@ -40,7 +37,6 @@ const wrapAction = (fn) => {
40
37
  }
41
38
  }
42
39
 
43
- // Wrap interactive actions with explicit exit
44
40
  const wrapInteractive = (fn) => {
45
41
  return async (...args) => {
46
42
  try {
@@ -53,38 +49,34 @@ const wrapInteractive = (fn) => {
53
49
  }
54
50
  }
55
51
 
56
- // Setup program
52
+ // ========================================
53
+ // MAIN PROGRAM SETUP
54
+ // ========================================
55
+
57
56
  program
58
- .name('cortex')
59
- .description('🧠 Cortex - Command Center for Brainy')
57
+ .name('brainy')
58
+ .description('🧠 Brainy - Vector + Graph Database with AI Coordination')
60
59
  .version(packageJson.version)
61
60
 
62
- // Initialize command
61
+ // ========================================
62
+ // CORE DATABASE COMMANDS (Direct Access)
63
+ // ========================================
64
+
63
65
  program
64
66
  .command('init')
65
- .description('Initialize Cortex in your project')
67
+ .description('🚀 Initialize Brainy in your project')
66
68
  .option('-s, --storage <type>', 'Storage type (filesystem, s3, r2, gcs, memory)')
67
69
  .option('-e, --encryption', 'Enable encryption for secrets')
68
70
  .action(wrapAction(async (options) => {
69
71
  await cortex.init(options)
70
72
  }))
71
73
 
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
74
  program
83
75
  .command('add [data]')
84
76
  .description('📊 Add data to Brainy')
85
77
  .option('-m, --metadata <json>', 'Metadata as JSON')
86
78
  .option('-i, --id <id>', 'Custom ID')
87
- .action(async (data, options) => {
79
+ .action(wrapAction(async (data, options) => {
88
80
  let metadata = {}
89
81
  if (options.metadata) {
90
82
  try {
@@ -98,17 +90,16 @@ program
98
90
  metadata.id = options.id
99
91
  }
100
92
  await cortex.add(data, metadata)
101
- exitProcess(0)
102
- })
93
+ }))
103
94
 
104
95
  program
105
96
  .command('search <query>')
106
- .description('🔍 Search your database with advanced options')
97
+ .description('🔍 Search your database')
107
98
  .option('-l, --limit <number>', 'Number of results', '10')
108
99
  .option('-f, --filter <json>', 'MongoDB-style metadata filters')
109
100
  .option('-v, --verbs <types>', 'Graph verb types to traverse (comma-separated)')
110
101
  .option('-d, --depth <number>', 'Graph traversal depth', '1')
111
- .action(async (query, options) => {
102
+ .action(wrapAction(async (query, options) => {
112
103
  const searchOptions = { limit: parseInt(options.limit) }
113
104
 
114
105
  if (options.filter) {
@@ -126,189 +117,44 @@ program
126
117
  }
127
118
 
128
119
  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
120
  }))
256
121
 
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
122
  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)
123
+ .command('chat [question]')
124
+ .description('💬 Chat with your data (interactive mode if no question)')
125
+ .option('-l, --llm <model>', 'LLM model to use')
126
+ .action(wrapInteractive(async (question, options) => {
127
+ await cortex.chat(question)
273
128
  }))
274
129
 
275
- // Database operations
276
130
  program
277
131
  .command('stats')
278
132
  .description('📊 Show database statistics')
279
- .option('-d, --detailed', 'Show detailed field statistics')
133
+ .option('-d, --detailed', 'Show detailed statistics')
280
134
  .action(wrapAction(async (options) => {
281
135
  await cortex.stats(options.detailed)
282
136
  }))
283
137
 
284
138
  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)
139
+ .command('health')
140
+ .description('🔋 Check system health')
141
+ .option('--auto-fix', 'Automatically apply safe repairs')
142
+ .action(wrapAction(async (options) => {
143
+ await cortex.health(options)
297
144
  }))
298
145
 
299
- // Embedding utilities
300
146
  program
301
- .command('embed <text>')
302
- .description(' Generate embedding vector for text')
303
- .action(wrapAction(async (text) => {
304
- await cortex.embed(text)
147
+ .command('find')
148
+ .description('🔍 Interactive advanced search')
149
+ .action(wrapInteractive(async () => {
150
+ await cortex.advancedSearch()
305
151
  }))
306
152
 
307
153
  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)
154
+ .command('explore [nodeId]')
155
+ .description('🗺️ Interactively explore graph connections')
156
+ .action(wrapInteractive(async (nodeId) => {
157
+ await cortex.explore(nodeId)
312
158
  }))
313
159
 
314
160
  program
@@ -327,266 +173,291 @@ program
327
173
  await cortex.restore(file)
328
174
  }))
329
175
 
330
- program
331
- .command('health')
332
- .description('🏥 Check database health')
333
- .action(wrapAction(async () => {
334
- await cortex.health()
335
- }))
176
+ // ========================================
177
+ // BRAIN CLOUD INTEGRATION
178
+ // ========================================
336
179
 
337
- // Backup & Restore commands
338
180
  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)
181
+ .command('cloud [action]')
182
+ .description('☁️ Connect to Brain Cloud - AI memory that never forgets')
183
+ .option('--connect <id>', 'Connect to existing Brain Cloud instance')
184
+ .option('--migrate', 'Migrate between local and cloud')
185
+ .action(wrapInteractive(async (action, options) => {
186
+ // For now, show connection instructions
187
+ console.log(chalk.cyan('\n⚛️ BRAIN CLOUD - AI Memory That Never Forgets'))
188
+ console.log(chalk.gray('━'.repeat(50)))
189
+
190
+ if (options.connect) {
191
+ console.log(chalk.green(`✅ Connecting to Brain Cloud instance: ${options.connect}`))
192
+ console.log(chalk.yellow('\nNote: Full cloud integration coming soon!'))
193
+ console.log('\nFor now, visit: ' + chalk.cyan('https://app.soulcraftlabs.com'))
194
+ } else {
195
+ console.log(chalk.yellow('📡 Brain Cloud Setup'))
196
+ console.log('\n1. Sign up at: ' + chalk.cyan('https://app.soulcraftlabs.com'))
197
+ console.log('2. Get your customer ID')
198
+ console.log('3. Connect with: ' + chalk.green('brainy cloud --connect YOUR_ID'))
199
+ console.log('\nBenefits:')
200
+ console.log(' • ' + chalk.green('Never lose AI context again'))
201
+ console.log(' • ' + chalk.green('Sync across all devices'))
202
+ console.log(' • ' + chalk.green('Unlimited memory storage'))
203
+ console.log(' • ' + chalk.green('$19/month or free trial'))
204
+ }
346
205
  }))
347
206
 
207
+ // ========================================
208
+ // AUGMENTATION MANAGEMENT (Direct Commands)
209
+ // ========================================
210
+
348
211
  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)
212
+ .command('install <augmentation>')
213
+ .description('📦 Install augmentation')
214
+ .option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
215
+ .option('-c, --config <json>', 'Configuration as JSON')
216
+ .action(wrapAction(async (augmentation, options) => {
217
+ if (augmentation === 'brain-jar') {
218
+ await cortex.brainJarInstall(options.mode)
219
+ } else {
220
+ // Generic augmentation install
221
+ let config = {}
222
+ if (options.config) {
223
+ try {
224
+ config = JSON.parse(options.config)
225
+ } catch {
226
+ console.error(chalk.red('Invalid JSON configuration'))
227
+ process.exit(1)
228
+ }
229
+ }
230
+ await cortex.addAugmentation(augmentation, undefined, config)
231
+ }
355
232
  }))
356
233
 
357
234
  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)
235
+ .command('run <augmentation>')
236
+ .description(' Run augmentation')
237
+ .option('-c, --config <json>', 'Runtime configuration as JSON')
238
+ .action(wrapAction(async (augmentation, options) => {
239
+ if (augmentation === 'brain-jar') {
240
+ await cortex.brainJarStart(options)
241
+ } else {
242
+ // Generic augmentation execution
243
+ const inputData = options.config ? JSON.parse(options.config) : { run: true }
244
+ await cortex.executePipelineStep(augmentation, inputData)
245
+ }
363
246
  }))
364
247
 
365
- // Augmentation Management commands
366
248
  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)
249
+ .command('status [augmentation]')
250
+ .description('📊 Show augmentation status')
251
+ .action(wrapAction(async (augmentation) => {
252
+ if (augmentation === 'brain-jar') {
253
+ await cortex.brainJarStatus()
254
+ } else if (augmentation) {
255
+ // Show specific augmentation status
256
+ await cortex.listAugmentations()
257
+ } else {
258
+ // Show all augmentation status
259
+ await cortex.listAugmentations()
260
+ }
372
261
  }))
373
262
 
374
- // Performance Monitoring & Health Check commands
375
263
  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)
264
+ .command('stop [augmentation]')
265
+ .description('⏹️ Stop augmentation')
266
+ .action(wrapAction(async (augmentation) => {
267
+ if (augmentation === 'brain-jar') {
268
+ await cortex.brainJarStop()
269
+ } else {
270
+ console.log(chalk.yellow('Stop functionality for generic augmentations not yet implemented'))
271
+ }
381
272
  }))
382
273
 
383
274
  program
384
- .command('health')
385
- .description('🔋 Check system health and diagnostics')
386
- .option('--auto-fix', 'Automatically apply safe repairs')
275
+ .command('list')
276
+ .description('📋 List installed augmentations')
277
+ .option('-a, --available', 'Show available augmentations')
387
278
  .action(wrapAction(async (options) => {
388
- await cortex.health(options)
279
+ if (options.available) {
280
+ console.log(chalk.cyan('🧩 Available Augmentations:'))
281
+ console.log(' • brain-jar - AI coordination and collaboration')
282
+ console.log(' • encryption - Data encryption and security')
283
+ console.log(' • neural-import - AI-powered data analysis')
284
+ console.log(' • performance-monitor - System monitoring')
285
+ console.log('')
286
+ console.log(chalk.dim('Install: brainy install <augmentation>'))
287
+ } else {
288
+ await cortex.listAugmentations()
289
+ }
389
290
  }))
390
291
 
292
+ // ========================================
293
+ // BRAIN CLOUD SUPER COMMAND (New!)
294
+ // ========================================
295
+
391
296
  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)
297
+ .command('cloud')
298
+ .description('☁️ Setup Brain Cloud - AI coordination across all devices')
299
+ .option('-m, --mode <type>', 'Setup mode (free|premium)', 'interactive')
300
+ .option('-k, --key <key>', 'License key for premium features')
301
+ .option('-s, --skip-install', 'Skip Brain Jar installation')
302
+ .action(wrapInteractive(async (options) => {
303
+ await cortex.setupBrainCloud(options)
397
304
  }))
398
305
 
399
- // Premium Licensing commands
400
- const license = program.command('license')
401
- .description('👑 Manage premium licenses and features')
306
+ // ========================================
307
+ // BRAIN JAR SPECIFIC COMMANDS (Rich UX)
308
+ // ========================================
402
309
 
403
- license
404
- .command('catalog')
405
- .description('📋 Browse premium features catalog')
406
- .action(wrapAction(async () => {
407
- await cortex.licenseCatalog()
408
- }))
310
+ const brainJar = program.command('brain-jar')
311
+ .description('🧠🫙 AI coordination and collaboration')
409
312
 
410
- license
411
- .command('status [license-id]')
412
- .description('📊 Check license status and usage')
413
- .action(wrapAction(async (licenseId) => {
414
- await cortex.licenseStatus(licenseId)
313
+ brainJar
314
+ .command('install')
315
+ .description('📦 Install Brain Jar coordination')
316
+ .option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
317
+ .action(wrapAction(async (options) => {
318
+ await cortex.brainJarInstall(options.mode)
415
319
  }))
416
320
 
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)
321
+ brainJar
322
+ .command('start')
323
+ .description('🚀 Start Brain Jar coordination')
324
+ .option('-s, --server <url>', 'Custom server URL')
325
+ .option('-n, --name <name>', 'Agent name')
326
+ .option('-r, --role <role>', 'Agent role')
327
+ .action(wrapAction(async (options) => {
328
+ await cortex.brainJarStart(options)
424
329
  }))
425
330
 
426
- license
427
- .command('validate <feature>')
428
- .description(' Validate feature license availability')
429
- .action(wrapAction(async (feature) => {
430
- await cortex.licenseValidate(feature)
331
+ brainJar
332
+ .command('dashboard')
333
+ .description('📊 Open Brain Jar dashboard')
334
+ .option('-o, --open', 'Auto-open in browser', true)
335
+ .action(wrapAction(async (options) => {
336
+ await cortex.brainJarDashboard(options.open)
431
337
  }))
432
338
 
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')
339
+ brainJar
340
+ .command('status')
341
+ .description('🔍 Show Brain Jar status')
440
342
  .action(wrapAction(async () => {
441
- await cortex.listAugmentations()
343
+ await cortex.brainJarStatus()
442
344
  }))
443
345
 
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)
346
+ brainJar
347
+ .command('agents')
348
+ .description('👥 List connected agents')
349
+ .action(wrapAction(async () => {
350
+ await cortex.brainJarAgents()
467
351
  }))
468
352
 
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)
353
+ brainJar
354
+ .command('message <text>')
355
+ .description('📨 Send message to coordination channel')
356
+ .action(wrapAction(async (text) => {
357
+ await cortex.brainJarMessage(text)
481
358
  }))
482
359
 
483
- augment
484
- .command('reset')
485
- .description('🔄 Reset pipeline to defaults')
486
- .action(wrapInteractive(async () => {
487
- await cortex.resetPipeline()
360
+ brainJar
361
+ .command('search <query>')
362
+ .description('🔍 Search coordination history')
363
+ .option('-l, --limit <number>', 'Number of results', '10')
364
+ .action(wrapAction(async (query, options) => {
365
+ await cortex.brainJarSearch(query, parseInt(options.limit))
488
366
  }))
489
367
 
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
- }))
368
+ // ========================================
369
+ // CONFIGURATION COMMANDS
370
+ // ========================================
497
371
 
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
- }))
372
+ const config = program.command('config')
373
+ .description('⚙️ Manage configuration')
518
374
 
519
- neural
520
- .command('analyze <file>')
521
- .description('🔬 Analyze data structure without importing')
522
- .action(wrapAction(async (file) => {
523
- await cortex.neuralAnalyze(file)
375
+ config
376
+ .command('set <key> <value>')
377
+ .description('Set configuration value')
378
+ .option('-e, --encrypt', 'Encrypt this value')
379
+ .action(wrapAction(async (key, value, options) => {
380
+ await cortex.configSet(key, value, options)
524
381
  }))
525
382
 
526
- neural
527
- .command('validate <file>')
528
- .description(' Validate data import compatibility')
529
- .action(wrapAction(async (file) => {
530
- await cortex.neuralValidate(file)
383
+ config
384
+ .command('get <key>')
385
+ .description('Get configuration value')
386
+ .action(wrapAction(async (key) => {
387
+ const value = await cortex.configGet(key)
388
+ if (value) {
389
+ console.log(chalk.green(`${key}: ${value}`))
390
+ } else {
391
+ console.log(chalk.yellow(`Key not found: ${key}`))
392
+ }
531
393
  }))
532
394
 
533
- neural
534
- .command('types')
535
- .description('📋 Show available noun and verb types')
395
+ config
396
+ .command('list')
397
+ .description('List all configuration')
536
398
  .action(wrapAction(async () => {
537
- await cortex.neuralTypes()
399
+ await cortex.configList()
538
400
  }))
539
401
 
540
- // Service integration commands
541
- const service = program.command('service')
542
- .description('🛠️ Service integration and management')
402
+ // ========================================
403
+ // LEGACY CORTEX COMMANDS (Backward Compatibility)
404
+ // ========================================
543
405
 
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
- }))
406
+ const cortexCmd = program.command('cortex')
407
+ .description('🔧 Legacy Cortex commands (deprecated - use direct commands)')
552
408
 
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)')
409
+ cortexCmd
410
+ .command('chat [question]')
411
+ .description('💬 Chat with your data')
412
+ .action(wrapInteractive(async (question) => {
413
+ console.log(chalk.yellow('⚠️ Deprecated: Use "brainy chat" instead'))
414
+ await cortex.chat(question)
560
415
  }))
561
416
 
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)')
417
+ cortexCmd
418
+ .command('add [data]')
419
+ .description('📊 Add data')
420
+ .action(wrapAction(async (data) => {
421
+ console.log(chalk.yellow('⚠️ Deprecated: Use "brainy add" instead'))
422
+ await cortex.add(data, {})
571
423
  }))
572
424
 
573
- // Interactive shell
425
+ // ========================================
426
+ // INTERACTIVE SHELL
427
+ // ========================================
428
+
574
429
  program
575
430
  .command('shell')
576
- .description('🐚 Interactive Cortex shell')
577
- .action(async () => {
578
- console.log(chalk.cyan('🧠 Cortex Interactive Shell'))
431
+ .description('🐚 Interactive Brainy shell')
432
+ .action(wrapInteractive(async () => {
433
+ console.log(chalk.cyan('🧠 Brainy Interactive Shell'))
579
434
  console.log(chalk.dim('Type "help" for commands, "exit" to quit\n'))
580
-
581
- // Start interactive mode
582
435
  await cortex.chat()
583
- exitProcess(0)
584
- })
436
+ }))
437
+
438
+ // ========================================
439
+ // PARSE AND HANDLE
440
+ // ========================================
585
441
 
586
- // Parse arguments
587
442
  program.parse(process.argv)
588
443
 
589
444
  // Show help if no command
590
445
  if (!process.argv.slice(2).length) {
446
+ console.log(chalk.cyan('🧠☁️ Brainy - AI Coordination Service'))
447
+ console.log('')
448
+ console.log(chalk.bold('One-Command Setup:'))
449
+ console.log(chalk.green(' brainy cloud # Setup Brain Cloud (recommended!)'))
450
+ console.log('')
451
+ console.log(chalk.bold('Quick Start:'))
452
+ console.log(' brainy init # Initialize project')
453
+ console.log(' brainy add "some data" # Add data')
454
+ console.log(' brainy search "query" # Search data')
455
+ console.log(' brainy chat # Chat with data')
456
+ console.log('')
457
+ console.log(chalk.bold('AI Coordination:'))
458
+ console.log(' brainy install brain-jar # Install AI coordination')
459
+ console.log(' brainy brain-jar start # Start coordination')
460
+ console.log(' brainy brain-jar dashboard # View dashboard')
461
+ console.log('')
591
462
  program.outputHelp()
592
463
  }