@soulcraft/brainy 0.58.0 → 0.59.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.
- package/bin/brainy.js +539 -387
- package/dist/augmentations/conduitAugmentations.js +1 -1
- package/dist/augmentations/conduitAugmentations.js.map +1 -1
- package/dist/augmentations/cortexSense.js +3 -3
- package/dist/augmentations/cortexSense.js.map +1 -1
- package/dist/brainyData.js +2 -1
- package/dist/brainyData.js.map +1 -1
- package/dist/browserFramework.minimal.d.ts +14 -0
- package/dist/browserFramework.minimal.js +31 -0
- package/dist/browserFramework.minimal.js.map +1 -0
- package/dist/cortex/backupRestore.js +2 -2
- package/dist/cortex/backupRestore.js.map +1 -1
- package/dist/cortex/cortex.d.ts +17 -2
- package/dist/cortex/cortex.js +262 -103
- package/dist/cortex/cortex.js.map +1 -1
- package/dist/cortex/neuralImport.js +2 -2
- package/dist/cortex/neuralImport.js.map +1 -1
- package/dist/cortex/serviceIntegration.js +2 -2
- package/dist/cortex/serviceIntegration.js.map +1 -1
- package/dist/distributed/configManager.js +1 -1
- package/dist/distributed/configManager.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/brainyMCPAdapter.js +1 -1
- package/dist/mcp/brainyMCPAdapter.js.map +1 -1
- package/dist/mcp/brainyMCPBroadcast.d.ts +82 -0
- package/dist/mcp/brainyMCPBroadcast.js +303 -0
- package/dist/mcp/brainyMCPBroadcast.js.map +1 -0
- package/dist/mcp/brainyMCPClient.d.ts +92 -0
- package/dist/mcp/brainyMCPClient.js +254 -0
- package/dist/mcp/brainyMCPClient.js.map +1 -0
- package/dist/mcp/brainyMCPService.js +1 -1
- package/dist/mcp/brainyMCPService.js.map +1 -1
- package/dist/mcp/mcpAugmentationToolset.js +1 -1
- package/dist/mcp/mcpAugmentationToolset.js.map +1 -1
- package/dist/universal/crypto.d.ts +64 -0
- package/dist/universal/crypto.js +215 -0
- package/dist/universal/crypto.js.map +1 -0
- package/dist/universal/events.d.ts +31 -0
- package/dist/universal/events.js +156 -0
- package/dist/universal/events.js.map +1 -0
- package/dist/universal/fs.d.ts +102 -0
- package/dist/universal/fs.js +304 -0
- package/dist/universal/fs.js.map +1 -0
- package/dist/universal/index.d.ts +16 -0
- package/dist/universal/index.js +23 -0
- package/dist/universal/index.js.map +1 -0
- package/dist/universal/path.d.ts +51 -0
- package/dist/universal/path.js +161 -0
- package/dist/universal/path.js.map +1 -0
- package/dist/universal/uuid.d.ts +10 -0
- package/dist/universal/uuid.js +21 -0
- package/dist/universal/uuid.js.map +1 -0
- package/package.json +55 -2
- package/dist/augmentationFactory.d.ts.map +0 -1
- package/dist/augmentationPipeline.d.ts.map +0 -1
- package/dist/augmentationRegistry.d.ts.map +0 -1
- package/dist/augmentationRegistryLoader.d.ts.map +0 -1
- package/dist/augmentations/conduitAugmentations.d.ts.map +0 -1
- package/dist/augmentations/memoryAugmentations.d.ts.map +0 -1
- package/dist/augmentations/serverSearchAugmentations.d.ts.map +0 -1
- package/dist/brainyData.d.ts.map +0 -1
- package/dist/browserFramework.d.ts.map +0 -1
- package/dist/coreTypes.d.ts.map +0 -1
- package/dist/cortex/cli.d.ts +0 -8
- package/dist/cortex/cli.js +0 -207
- package/dist/cortex/cli.js.map +0 -1
- package/dist/cortex/commands/index.d.ts +0 -79
- package/dist/cortex/commands/index.js +0 -614
- package/dist/cortex/commands/index.js.map +0 -1
- package/dist/cortex/config.d.ts +0 -112
- package/dist/cortex/config.js +0 -312
- package/dist/cortex/config.js.map +0 -1
- package/dist/cortex/licensingSystem.d.ts +0 -126
- package/dist/cortex/licensingSystem.js +0 -474
- package/dist/cortex/licensingSystem.js.map +0 -1
- package/dist/cortex/webhookManager.d.ts +0 -39
- package/dist/cortex/webhookManager.js +0 -326
- package/dist/cortex/webhookManager.js.map +0 -1
- package/dist/demo.d.ts.map +0 -1
- package/dist/distributed/configManager.d.ts.map +0 -1
- package/dist/distributed/domainDetector.d.ts.map +0 -1
- package/dist/distributed/hashPartitioner.d.ts.map +0 -1
- package/dist/distributed/healthMonitor.d.ts.map +0 -1
- package/dist/distributed/index.d.ts.map +0 -1
- package/dist/distributed/operationalModes.d.ts.map +0 -1
- package/dist/errors/brainyError.d.ts.map +0 -1
- package/dist/examples/basicUsage.d.ts.map +0 -1
- package/dist/hnsw/distributedSearch.d.ts.map +0 -1
- package/dist/hnsw/hnswIndex.d.ts.map +0 -1
- package/dist/hnsw/hnswIndexOptimized.d.ts.map +0 -1
- package/dist/hnsw/optimizedHNSWIndex.d.ts.map +0 -1
- package/dist/hnsw/partitionedHNSWIndex.d.ts.map +0 -1
- package/dist/hnsw/scaledHNSWSystem.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/brainyMCPAdapter.d.ts.map +0 -1
- package/dist/mcp/brainyMCPService.d.ts.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/mcpAugmentationToolset.d.ts.map +0 -1
- package/dist/pipeline.d.ts.map +0 -1
- package/dist/sequentialPipeline.d.ts.map +0 -1
- package/dist/setup.d.ts.map +0 -1
- package/dist/storage/adapters/baseStorageAdapter.d.ts.map +0 -1
- package/dist/storage/adapters/batchS3Operations.d.ts.map +0 -1
- package/dist/storage/adapters/fileSystemStorage.d.ts.map +0 -1
- package/dist/storage/adapters/memoryStorage.d.ts.map +0 -1
- package/dist/storage/adapters/opfsStorage.d.ts.map +0 -1
- package/dist/storage/adapters/optimizedS3Search.d.ts.map +0 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +0 -1
- package/dist/storage/baseStorage.d.ts.map +0 -1
- package/dist/storage/cacheManager.d.ts.map +0 -1
- package/dist/storage/enhancedCacheManager.d.ts.map +0 -1
- package/dist/storage/readOnlyOptimizations.d.ts.map +0 -1
- package/dist/storage/storageFactory.d.ts.map +0 -1
- package/dist/types/augmentations.d.ts.map +0 -1
- package/dist/types/brainyDataInterface.d.ts.map +0 -1
- package/dist/types/distributedTypes.d.ts.map +0 -1
- package/dist/types/fileSystemTypes.d.ts.map +0 -1
- package/dist/types/graphTypes.d.ts.map +0 -1
- package/dist/types/mcpTypes.d.ts.map +0 -1
- package/dist/types/paginationTypes.d.ts.map +0 -1
- package/dist/types/pipelineTypes.d.ts.map +0 -1
- package/dist/types/tensorflowTypes.d.ts +0 -26
- package/dist/types/tensorflowTypes.d.ts.map +0 -1
- package/dist/types/tensorflowTypes.js +0 -6
- package/dist/types/tensorflowTypes.js.map +0 -1
- package/dist/unified.d.ts.map +0 -1
- package/dist/utils/autoConfiguration.d.ts.map +0 -1
- package/dist/utils/cacheAutoConfig.d.ts.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/distance.d.ts.map +0 -1
- package/dist/utils/embedding.d.ts.map +0 -1
- package/dist/utils/environment.d.ts.map +0 -1
- package/dist/utils/fieldNameTracking.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/jsonProcessing.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/operationUtils.d.ts.map +0 -1
- package/dist/utils/robustModelLoader.d.ts +0 -112
- package/dist/utils/robustModelLoader.d.ts.map +0 -1
- package/dist/utils/robustModelLoader.js +0 -624
- package/dist/utils/robustModelLoader.js.map +0 -1
- package/dist/utils/searchCache.d.ts.map +0 -1
- package/dist/utils/statistics.d.ts.map +0 -1
- package/dist/utils/statisticsCollector.d.ts.map +0 -1
- package/dist/utils/textEncoding.d.ts.map +0 -1
- package/dist/utils/typeUtils.d.ts.map +0 -1
- package/dist/utils/version.d.ts.map +0 -1
- package/dist/utils/workerUtils.d.ts.map +0 -1
- package/dist/webhooks/webhookSystem.d.ts +0 -114
- package/dist/webhooks/webhookSystem.js +0 -321
- package/dist/webhooks/webhookSystem.js.map +0 -1
- 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 -
|
|
4
|
+
* Brainy CLI - Redesigned for Better UX
|
|
5
|
+
* Direct commands + Augmentation system
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
// @ts-ignore
|
|
@@ -13,25 +14,24 @@ import { readFileSync } from 'fs'
|
|
|
13
14
|
import { dirname, join } from 'path'
|
|
14
15
|
import { fileURLToPath } from 'url'
|
|
15
16
|
|
|
17
|
+
// Import fetch for API calls
|
|
18
|
+
import fetch from 'node-fetch'
|
|
19
|
+
|
|
16
20
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
21
|
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'))
|
|
18
22
|
|
|
19
23
|
// Create Cortex instance
|
|
20
24
|
const cortex = new Cortex()
|
|
21
25
|
|
|
22
|
-
// Helper
|
|
26
|
+
// Helper functions
|
|
23
27
|
const exitProcess = (code = 0) => {
|
|
24
|
-
setTimeout(() =>
|
|
25
|
-
process.exit(code)
|
|
26
|
-
}, 100)
|
|
28
|
+
setTimeout(() => process.exit(code), 100)
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
// Wrap async actions to ensure proper exit
|
|
30
31
|
const wrapAction = (fn) => {
|
|
31
32
|
return async (...args) => {
|
|
32
33
|
try {
|
|
33
34
|
await fn(...args)
|
|
34
|
-
// Always exit for non-interactive commands
|
|
35
35
|
exitProcess(0)
|
|
36
36
|
} catch (error) {
|
|
37
37
|
console.error(chalk.red('Error:'), error.message)
|
|
@@ -40,7 +40,6 @@ const wrapAction = (fn) => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// Wrap interactive actions with explicit exit
|
|
44
43
|
const wrapInteractive = (fn) => {
|
|
45
44
|
return async (...args) => {
|
|
46
45
|
try {
|
|
@@ -53,38 +52,34 @@ const wrapInteractive = (fn) => {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
//
|
|
55
|
+
// ========================================
|
|
56
|
+
// MAIN PROGRAM SETUP
|
|
57
|
+
// ========================================
|
|
58
|
+
|
|
57
59
|
program
|
|
58
|
-
.name('
|
|
59
|
-
.description('🧠
|
|
60
|
+
.name('brainy')
|
|
61
|
+
.description('🧠 Brainy - Vector + Graph Database with AI Coordination')
|
|
60
62
|
.version(packageJson.version)
|
|
61
63
|
|
|
62
|
-
//
|
|
64
|
+
// ========================================
|
|
65
|
+
// CORE DATABASE COMMANDS (Direct Access)
|
|
66
|
+
// ========================================
|
|
67
|
+
|
|
63
68
|
program
|
|
64
69
|
.command('init')
|
|
65
|
-
.description('Initialize
|
|
70
|
+
.description('🚀 Initialize Brainy in your project')
|
|
66
71
|
.option('-s, --storage <type>', 'Storage type (filesystem, s3, r2, gcs, memory)')
|
|
67
72
|
.option('-e, --encryption', 'Enable encryption for secrets')
|
|
68
73
|
.action(wrapAction(async (options) => {
|
|
69
74
|
await cortex.init(options)
|
|
70
75
|
}))
|
|
71
76
|
|
|
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
77
|
program
|
|
83
78
|
.command('add [data]')
|
|
84
79
|
.description('📊 Add data to Brainy')
|
|
85
80
|
.option('-m, --metadata <json>', 'Metadata as JSON')
|
|
86
81
|
.option('-i, --id <id>', 'Custom ID')
|
|
87
|
-
.action(async (data, options) => {
|
|
82
|
+
.action(wrapAction(async (data, options) => {
|
|
88
83
|
let metadata = {}
|
|
89
84
|
if (options.metadata) {
|
|
90
85
|
try {
|
|
@@ -98,17 +93,16 @@ program
|
|
|
98
93
|
metadata.id = options.id
|
|
99
94
|
}
|
|
100
95
|
await cortex.add(data, metadata)
|
|
101
|
-
|
|
102
|
-
})
|
|
96
|
+
}))
|
|
103
97
|
|
|
104
98
|
program
|
|
105
99
|
.command('search <query>')
|
|
106
|
-
.description('🔍 Search your database
|
|
100
|
+
.description('🔍 Search your database')
|
|
107
101
|
.option('-l, --limit <number>', 'Number of results', '10')
|
|
108
102
|
.option('-f, --filter <json>', 'MongoDB-style metadata filters')
|
|
109
103
|
.option('-v, --verbs <types>', 'Graph verb types to traverse (comma-separated)')
|
|
110
104
|
.option('-d, --depth <number>', 'Graph traversal depth', '1')
|
|
111
|
-
.action(async (query, options) => {
|
|
105
|
+
.action(wrapAction(async (query, options) => {
|
|
112
106
|
const searchOptions = { limit: parseInt(options.limit) }
|
|
113
107
|
|
|
114
108
|
if (options.filter) {
|
|
@@ -126,189 +120,44 @@ program
|
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
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
123
|
}))
|
|
138
124
|
|
|
139
125
|
program
|
|
140
|
-
.command('
|
|
141
|
-
.description('
|
|
142
|
-
.option('-
|
|
143
|
-
.action(async (
|
|
144
|
-
|
|
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)
|
|
126
|
+
.command('chat [question]')
|
|
127
|
+
.description('💬 Chat with your data (interactive mode if no question)')
|
|
128
|
+
.option('-l, --llm <model>', 'LLM model to use')
|
|
129
|
+
.action(wrapInteractive(async (question, options) => {
|
|
130
|
+
await cortex.chat(question)
|
|
273
131
|
}))
|
|
274
132
|
|
|
275
|
-
// Database operations
|
|
276
133
|
program
|
|
277
134
|
.command('stats')
|
|
278
135
|
.description('📊 Show database statistics')
|
|
279
|
-
.option('-d, --detailed', 'Show detailed
|
|
136
|
+
.option('-d, --detailed', 'Show detailed statistics')
|
|
280
137
|
.action(wrapAction(async (options) => {
|
|
281
138
|
await cortex.stats(options.detailed)
|
|
282
139
|
}))
|
|
283
140
|
|
|
284
141
|
program
|
|
285
|
-
.command('
|
|
286
|
-
.description('
|
|
287
|
-
.
|
|
288
|
-
|
|
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)
|
|
142
|
+
.command('health')
|
|
143
|
+
.description('🔋 Check system health')
|
|
144
|
+
.option('--auto-fix', 'Automatically apply safe repairs')
|
|
145
|
+
.action(wrapAction(async (options) => {
|
|
146
|
+
await cortex.health(options)
|
|
297
147
|
}))
|
|
298
148
|
|
|
299
|
-
// Embedding utilities
|
|
300
149
|
program
|
|
301
|
-
.command('
|
|
302
|
-
.description('
|
|
303
|
-
.action(
|
|
304
|
-
await cortex.
|
|
150
|
+
.command('find')
|
|
151
|
+
.description('🔍 Interactive advanced search')
|
|
152
|
+
.action(wrapInteractive(async () => {
|
|
153
|
+
await cortex.advancedSearch()
|
|
305
154
|
}))
|
|
306
155
|
|
|
307
156
|
program
|
|
308
|
-
.command('
|
|
309
|
-
.description('
|
|
310
|
-
.action(
|
|
311
|
-
await cortex.
|
|
157
|
+
.command('explore [nodeId]')
|
|
158
|
+
.description('🗺️ Interactively explore graph connections')
|
|
159
|
+
.action(wrapInteractive(async (nodeId) => {
|
|
160
|
+
await cortex.explore(nodeId)
|
|
312
161
|
}))
|
|
313
162
|
|
|
314
163
|
program
|
|
@@ -327,266 +176,569 @@ program
|
|
|
327
176
|
await cortex.restore(file)
|
|
328
177
|
}))
|
|
329
178
|
|
|
179
|
+
// ========================================
|
|
180
|
+
// BRAIN CLOUD INTEGRATION
|
|
181
|
+
// ========================================
|
|
182
|
+
|
|
330
183
|
program
|
|
331
|
-
.command('
|
|
332
|
-
.description('
|
|
333
|
-
.action(
|
|
334
|
-
|
|
184
|
+
.command('connect')
|
|
185
|
+
.description('🔗 Connect me to your Brain Cloud so I remember everything')
|
|
186
|
+
.action(wrapInteractive(async () => {
|
|
187
|
+
console.log(chalk.cyan('\n🧠 Setting Up AI Memory...'))
|
|
188
|
+
console.log(chalk.gray('━'.repeat(50)))
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
// Detect customer ID
|
|
192
|
+
const customerId = await detectCustomerId()
|
|
193
|
+
|
|
194
|
+
if (customerId) {
|
|
195
|
+
console.log(chalk.green(`✅ Found your Brain Cloud: ${customerId}`))
|
|
196
|
+
console.log('\n🔧 I can set up AI memory so I remember our conversations:')
|
|
197
|
+
console.log(chalk.yellow(' • Update Claude configuration'))
|
|
198
|
+
console.log(chalk.yellow(' • Add memory instructions'))
|
|
199
|
+
console.log(chalk.yellow(' • Enable cross-session memory'))
|
|
200
|
+
|
|
201
|
+
// For now, auto-proceed (in a real CLI environment, user could be prompted)
|
|
202
|
+
console.log(chalk.cyan('\n🚀 Setting up AI memory...'))
|
|
203
|
+
const proceed = true
|
|
204
|
+
|
|
205
|
+
if (proceed) {
|
|
206
|
+
await setupBrainCloudMemory(customerId)
|
|
207
|
+
console.log(chalk.green('\n🎉 AI Memory Connected!'))
|
|
208
|
+
console.log(chalk.cyan('Restart Claude Code and I\'ll remember everything!'))
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
console.log(chalk.yellow('🤔 No Brain Cloud found. Let me help you set one up:'))
|
|
212
|
+
console.log('\n1. Visit: ' + chalk.cyan('https://app.soulcraftlabs.com'))
|
|
213
|
+
console.log('2. Sign up for Brain Cloud ($19/month)')
|
|
214
|
+
console.log('3. Run ' + chalk.green('brainy connect') + ' again')
|
|
215
|
+
}
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.log(chalk.red('❌ Setup failed:'), error.message)
|
|
218
|
+
}
|
|
335
219
|
}))
|
|
336
220
|
|
|
337
|
-
// Backup & Restore commands
|
|
338
221
|
program
|
|
339
|
-
.command('
|
|
340
|
-
.description('
|
|
341
|
-
.option('
|
|
342
|
-
.option('
|
|
343
|
-
.option('--
|
|
344
|
-
.
|
|
345
|
-
|
|
222
|
+
.command('cloud [action]')
|
|
223
|
+
.description('☁️ Connect to Brain Cloud - AI memory that never forgets')
|
|
224
|
+
.option('--connect <id>', 'Connect to existing Brain Cloud instance')
|
|
225
|
+
.option('--export <id>', 'Export all data from Brain Cloud instance')
|
|
226
|
+
.option('--status <id>', 'Check status of Brain Cloud instance')
|
|
227
|
+
.option('--dashboard <id>', 'Open dashboard for Brain Cloud instance')
|
|
228
|
+
.option('--migrate', 'Migrate between local and cloud')
|
|
229
|
+
.action(wrapInteractive(async (action, options) => {
|
|
230
|
+
// For now, show connection instructions
|
|
231
|
+
console.log(chalk.cyan('\n⚛️ BRAIN CLOUD - AI Memory That Never Forgets'))
|
|
232
|
+
console.log(chalk.gray('━'.repeat(50)))
|
|
233
|
+
|
|
234
|
+
if (options.connect) {
|
|
235
|
+
console.log(chalk.green(`✅ Connecting to Brain Cloud instance: ${options.connect}`))
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
// Test connection to Brain Cloud worker
|
|
239
|
+
const healthUrl = `https://brain-cloud.dpsifr.workers.dev/health`
|
|
240
|
+
const response = await fetch(healthUrl, {
|
|
241
|
+
headers: { 'x-customer-id': options.connect }
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
if (response.ok) {
|
|
245
|
+
const data = await response.json()
|
|
246
|
+
console.log(chalk.green(`🧠 ${data.status}`))
|
|
247
|
+
console.log(chalk.cyan(`💫 Instance: ${data.customerId}`))
|
|
248
|
+
console.log(chalk.gray(`⏰ Connected at: ${new Date(data.timestamp).toLocaleString()}`))
|
|
249
|
+
|
|
250
|
+
// Test memories endpoint
|
|
251
|
+
const memoriesResponse = await fetch(`https://brain-cloud.dpsifr.workers.dev/memories`, {
|
|
252
|
+
headers: { 'x-customer-id': options.connect }
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
if (memoriesResponse.ok) {
|
|
256
|
+
const memoriesData = await memoriesResponse.json()
|
|
257
|
+
console.log(chalk.yellow(`\n${memoriesData.message}`))
|
|
258
|
+
console.log(chalk.gray('📊 Your atomic memories:'))
|
|
259
|
+
memoriesData.memories.forEach(memory => {
|
|
260
|
+
const time = new Date(memory.created).toLocaleString()
|
|
261
|
+
console.log(chalk.gray(` • ${memory.content} (${time})`))
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
} else {
|
|
266
|
+
console.log(chalk.red('❌ Could not connect to Brain Cloud'))
|
|
267
|
+
console.log(chalk.yellow('💡 Make sure you have an active instance'))
|
|
268
|
+
console.log('\nSign up at: ' + chalk.cyan('https://app.soulcraftlabs.com'))
|
|
269
|
+
}
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.log(chalk.red('❌ Connection failed:'), error.message)
|
|
272
|
+
console.log('\nSign up at: ' + chalk.cyan('https://app.soulcraftlabs.com'))
|
|
273
|
+
}
|
|
274
|
+
} else if (options.export) {
|
|
275
|
+
console.log(chalk.green(`📦 Exporting data from Brain Cloud instance: ${options.export}`))
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/export`, {
|
|
279
|
+
headers: { 'x-customer-id': options.export }
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
if (response.ok) {
|
|
283
|
+
const data = await response.json()
|
|
284
|
+
const filename = `brainy-export-${options.export}-${Date.now()}.json`
|
|
285
|
+
|
|
286
|
+
// Write to file
|
|
287
|
+
const fs = await import('fs/promises')
|
|
288
|
+
await fs.writeFile(filename, JSON.stringify(data, null, 2))
|
|
289
|
+
|
|
290
|
+
console.log(chalk.green(`✅ Data exported to: ${filename}`))
|
|
291
|
+
console.log(chalk.gray(`📊 Exported ${data.memories?.length || 0} memories`))
|
|
292
|
+
} else {
|
|
293
|
+
console.log(chalk.red('❌ Export failed - instance not found'))
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.log(chalk.red('❌ Export error:'), error.message)
|
|
297
|
+
}
|
|
298
|
+
} else if (options.status) {
|
|
299
|
+
console.log(chalk.green(`🔍 Checking status of Brain Cloud instance: ${options.status}`))
|
|
300
|
+
|
|
301
|
+
try {
|
|
302
|
+
const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/health`, {
|
|
303
|
+
headers: { 'x-customer-id': options.status }
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
if (response.ok) {
|
|
307
|
+
const data = await response.json()
|
|
308
|
+
console.log(chalk.green(`✅ Instance Status: Active`))
|
|
309
|
+
console.log(chalk.cyan(`🧠 ${data.status}`))
|
|
310
|
+
console.log(chalk.gray(`⏰ Last check: ${new Date(data.timestamp).toLocaleString()}`))
|
|
311
|
+
|
|
312
|
+
// Get memory count
|
|
313
|
+
const memoriesResponse = await fetch(`https://brain-cloud.dpsifr.workers.dev/memories`, {
|
|
314
|
+
headers: { 'x-customer-id': options.status }
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
if (memoriesResponse.ok) {
|
|
318
|
+
const memoriesData = await memoriesResponse.json()
|
|
319
|
+
console.log(chalk.yellow(`📊 Total memories: ${memoriesData.count}`))
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
console.log(chalk.red('❌ Instance not found or inactive'))
|
|
323
|
+
}
|
|
324
|
+
} catch (error) {
|
|
325
|
+
console.log(chalk.red('❌ Status check failed:'), error.message)
|
|
326
|
+
}
|
|
327
|
+
} else if (options.dashboard) {
|
|
328
|
+
console.log(chalk.green(`🌐 Opening dashboard for Brain Cloud instance: ${options.dashboard}`))
|
|
329
|
+
|
|
330
|
+
const dashboardUrl = `https://app.soulcraftlabs.com/dashboard.html?customer_id=${options.dashboard}`
|
|
331
|
+
console.log(chalk.cyan(`\n🔗 Dashboard URL: ${dashboardUrl}`))
|
|
332
|
+
console.log(chalk.gray('Opening in your default browser...'))
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
const { exec } = await import('child_process')
|
|
336
|
+
const { promisify } = await import('util')
|
|
337
|
+
const execAsync = promisify(exec)
|
|
338
|
+
|
|
339
|
+
// Cross-platform browser opening
|
|
340
|
+
const command = process.platform === 'win32' ? 'start' :
|
|
341
|
+
process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
342
|
+
|
|
343
|
+
await execAsync(`${command} "${dashboardUrl}"`)
|
|
344
|
+
console.log(chalk.green('✅ Dashboard opened!'))
|
|
345
|
+
} catch (error) {
|
|
346
|
+
console.log(chalk.yellow('💡 Copy the URL above to open in your browser'))
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
console.log(chalk.yellow('📡 Brain Cloud Setup'))
|
|
350
|
+
console.log('\n1. Sign up at: ' + chalk.cyan('https://app.soulcraftlabs.com'))
|
|
351
|
+
console.log('2. Get your customer ID')
|
|
352
|
+
console.log('3. Connect with: ' + chalk.green('brainy cloud --connect YOUR_ID'))
|
|
353
|
+
console.log('\nBenefits:')
|
|
354
|
+
console.log(' • ' + chalk.green('Never lose AI context again'))
|
|
355
|
+
console.log(' • ' + chalk.green('Sync across all devices'))
|
|
356
|
+
console.log(' • ' + chalk.green('Unlimited memory storage'))
|
|
357
|
+
console.log(' • ' + chalk.green('$19/month or free trial'))
|
|
358
|
+
}
|
|
346
359
|
}))
|
|
347
360
|
|
|
361
|
+
// ========================================
|
|
362
|
+
// AUGMENTATION MANAGEMENT (Direct Commands)
|
|
363
|
+
// ========================================
|
|
364
|
+
|
|
348
365
|
program
|
|
349
|
-
.command('
|
|
350
|
-
.description('
|
|
351
|
-
.option('--
|
|
352
|
-
.option('--
|
|
353
|
-
.action(
|
|
354
|
-
|
|
366
|
+
.command('install <augmentation>')
|
|
367
|
+
.description('📦 Install augmentation')
|
|
368
|
+
.option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
|
|
369
|
+
.option('-c, --config <json>', 'Configuration as JSON')
|
|
370
|
+
.action(wrapAction(async (augmentation, options) => {
|
|
371
|
+
if (augmentation === 'brain-jar') {
|
|
372
|
+
await cortex.brainJarInstall(options.mode)
|
|
373
|
+
} else {
|
|
374
|
+
// Generic augmentation install
|
|
375
|
+
let config = {}
|
|
376
|
+
if (options.config) {
|
|
377
|
+
try {
|
|
378
|
+
config = JSON.parse(options.config)
|
|
379
|
+
} catch {
|
|
380
|
+
console.error(chalk.red('Invalid JSON configuration'))
|
|
381
|
+
process.exit(1)
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
await cortex.addAugmentation(augmentation, undefined, config)
|
|
385
|
+
}
|
|
355
386
|
}))
|
|
356
387
|
|
|
357
388
|
program
|
|
358
|
-
.command('
|
|
359
|
-
.description('
|
|
360
|
-
.option('-
|
|
361
|
-
.action(wrapAction(async (options) => {
|
|
362
|
-
|
|
389
|
+
.command('run <augmentation>')
|
|
390
|
+
.description('⚡ Run augmentation')
|
|
391
|
+
.option('-c, --config <json>', 'Runtime configuration as JSON')
|
|
392
|
+
.action(wrapAction(async (augmentation, options) => {
|
|
393
|
+
if (augmentation === 'brain-jar') {
|
|
394
|
+
await cortex.brainJarStart(options)
|
|
395
|
+
} else {
|
|
396
|
+
// Generic augmentation execution
|
|
397
|
+
const inputData = options.config ? JSON.parse(options.config) : { run: true }
|
|
398
|
+
await cortex.executePipelineStep(augmentation, inputData)
|
|
399
|
+
}
|
|
363
400
|
}))
|
|
364
401
|
|
|
365
|
-
// Augmentation Management commands
|
|
366
402
|
program
|
|
367
|
-
.command('
|
|
368
|
-
.description('
|
|
369
|
-
.
|
|
370
|
-
|
|
371
|
-
|
|
403
|
+
.command('status [augmentation]')
|
|
404
|
+
.description('📊 Show augmentation status')
|
|
405
|
+
.action(wrapAction(async (augmentation) => {
|
|
406
|
+
if (augmentation === 'brain-jar') {
|
|
407
|
+
await cortex.brainJarStatus()
|
|
408
|
+
} else if (augmentation) {
|
|
409
|
+
// Show specific augmentation status
|
|
410
|
+
await cortex.listAugmentations()
|
|
411
|
+
} else {
|
|
412
|
+
// Show all augmentation status
|
|
413
|
+
await cortex.listAugmentations()
|
|
414
|
+
}
|
|
372
415
|
}))
|
|
373
416
|
|
|
374
|
-
// Performance Monitoring & Health Check commands
|
|
375
417
|
program
|
|
376
|
-
.command('
|
|
377
|
-
.description('
|
|
378
|
-
.
|
|
379
|
-
|
|
380
|
-
|
|
418
|
+
.command('stop [augmentation]')
|
|
419
|
+
.description('⏹️ Stop augmentation')
|
|
420
|
+
.action(wrapAction(async (augmentation) => {
|
|
421
|
+
if (augmentation === 'brain-jar') {
|
|
422
|
+
await cortex.brainJarStop()
|
|
423
|
+
} else {
|
|
424
|
+
console.log(chalk.yellow('Stop functionality for generic augmentations not yet implemented'))
|
|
425
|
+
}
|
|
381
426
|
}))
|
|
382
427
|
|
|
383
428
|
program
|
|
384
|
-
.command('
|
|
385
|
-
.description('
|
|
386
|
-
.option('--
|
|
429
|
+
.command('list')
|
|
430
|
+
.description('📋 List installed augmentations')
|
|
431
|
+
.option('-a, --available', 'Show available augmentations')
|
|
387
432
|
.action(wrapAction(async (options) => {
|
|
388
|
-
|
|
433
|
+
if (options.available) {
|
|
434
|
+
console.log(chalk.cyan('🧩 Available Augmentations:'))
|
|
435
|
+
console.log(' • brain-jar - AI coordination and collaboration')
|
|
436
|
+
console.log(' • encryption - Data encryption and security')
|
|
437
|
+
console.log(' • neural-import - AI-powered data analysis')
|
|
438
|
+
console.log(' • performance-monitor - System monitoring')
|
|
439
|
+
console.log('')
|
|
440
|
+
console.log(chalk.dim('Install: brainy install <augmentation>'))
|
|
441
|
+
} else {
|
|
442
|
+
await cortex.listAugmentations()
|
|
443
|
+
}
|
|
389
444
|
}))
|
|
390
445
|
|
|
446
|
+
// ========================================
|
|
447
|
+
// BRAIN CLOUD SUPER COMMAND (New!)
|
|
448
|
+
// ========================================
|
|
449
|
+
|
|
391
450
|
program
|
|
392
|
-
.command('
|
|
393
|
-
.description('
|
|
394
|
-
.option('--
|
|
395
|
-
.
|
|
396
|
-
|
|
451
|
+
.command('cloud')
|
|
452
|
+
.description('☁️ Setup Brain Cloud - AI coordination across all devices')
|
|
453
|
+
.option('-m, --mode <type>', 'Setup mode (free|premium)', 'interactive')
|
|
454
|
+
.option('-k, --key <key>', 'License key for premium features')
|
|
455
|
+
.option('-s, --skip-install', 'Skip Brain Jar installation')
|
|
456
|
+
.action(wrapInteractive(async (options) => {
|
|
457
|
+
await cortex.setupBrainCloud(options)
|
|
397
458
|
}))
|
|
398
459
|
|
|
399
|
-
//
|
|
400
|
-
|
|
401
|
-
|
|
460
|
+
// ========================================
|
|
461
|
+
// BRAIN JAR SPECIFIC COMMANDS (Rich UX)
|
|
462
|
+
// ========================================
|
|
402
463
|
|
|
403
|
-
|
|
404
|
-
.
|
|
405
|
-
.description('📋 Browse premium features catalog')
|
|
406
|
-
.action(wrapAction(async () => {
|
|
407
|
-
await cortex.licenseCatalog()
|
|
408
|
-
}))
|
|
464
|
+
const brainJar = program.command('brain-jar')
|
|
465
|
+
.description('🧠🫙 AI coordination and collaboration')
|
|
409
466
|
|
|
410
|
-
|
|
411
|
-
.command('
|
|
412
|
-
.description('
|
|
413
|
-
.
|
|
414
|
-
|
|
467
|
+
brainJar
|
|
468
|
+
.command('install')
|
|
469
|
+
.description('📦 Install Brain Jar coordination')
|
|
470
|
+
.option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
|
|
471
|
+
.action(wrapAction(async (options) => {
|
|
472
|
+
await cortex.brainJarInstall(options.mode)
|
|
415
473
|
}))
|
|
416
474
|
|
|
417
|
-
|
|
418
|
-
.command('
|
|
419
|
-
.description('
|
|
420
|
-
.option('--
|
|
421
|
-
.option('--
|
|
422
|
-
.
|
|
423
|
-
|
|
475
|
+
brainJar
|
|
476
|
+
.command('start')
|
|
477
|
+
.description('🚀 Start Brain Jar coordination')
|
|
478
|
+
.option('-s, --server <url>', 'Custom server URL')
|
|
479
|
+
.option('-n, --name <name>', 'Agent name')
|
|
480
|
+
.option('-r, --role <role>', 'Agent role')
|
|
481
|
+
.action(wrapAction(async (options) => {
|
|
482
|
+
await cortex.brainJarStart(options)
|
|
424
483
|
}))
|
|
425
484
|
|
|
426
|
-
|
|
427
|
-
.command('
|
|
428
|
-
.description('
|
|
429
|
-
.
|
|
430
|
-
|
|
485
|
+
brainJar
|
|
486
|
+
.command('dashboard')
|
|
487
|
+
.description('📊 Open Brain Jar dashboard')
|
|
488
|
+
.option('-o, --open', 'Auto-open in browser', true)
|
|
489
|
+
.action(wrapAction(async (options) => {
|
|
490
|
+
await cortex.brainJarDashboard(options.open)
|
|
431
491
|
}))
|
|
432
492
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
.description('
|
|
436
|
-
|
|
437
|
-
augment
|
|
438
|
-
.command('list')
|
|
439
|
-
.description('📋 List all augmentations and pipeline status')
|
|
493
|
+
brainJar
|
|
494
|
+
.command('status')
|
|
495
|
+
.description('🔍 Show Brain Jar status')
|
|
440
496
|
.action(wrapAction(async () => {
|
|
441
|
-
await cortex.
|
|
497
|
+
await cortex.brainJarStatus()
|
|
442
498
|
}))
|
|
443
499
|
|
|
444
|
-
|
|
445
|
-
.command('
|
|
446
|
-
.description('
|
|
447
|
-
.
|
|
448
|
-
|
|
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)
|
|
500
|
+
brainJar
|
|
501
|
+
.command('agents')
|
|
502
|
+
.description('👥 List connected agents')
|
|
503
|
+
.action(wrapAction(async () => {
|
|
504
|
+
await cortex.brainJarAgents()
|
|
467
505
|
}))
|
|
468
506
|
|
|
469
|
-
|
|
470
|
-
.command('
|
|
471
|
-
.description('
|
|
472
|
-
.action(wrapAction(async (
|
|
473
|
-
|
|
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)
|
|
507
|
+
brainJar
|
|
508
|
+
.command('message <text>')
|
|
509
|
+
.description('📨 Send message to coordination channel')
|
|
510
|
+
.action(wrapAction(async (text) => {
|
|
511
|
+
await cortex.brainJarMessage(text)
|
|
481
512
|
}))
|
|
482
513
|
|
|
483
|
-
|
|
484
|
-
.command('
|
|
485
|
-
.description('
|
|
486
|
-
.
|
|
487
|
-
|
|
514
|
+
brainJar
|
|
515
|
+
.command('search <query>')
|
|
516
|
+
.description('🔍 Search coordination history')
|
|
517
|
+
.option('-l, --limit <number>', 'Number of results', '10')
|
|
518
|
+
.action(wrapAction(async (query, options) => {
|
|
519
|
+
await cortex.brainJarSearch(query, parseInt(options.limit))
|
|
488
520
|
}))
|
|
489
521
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
.action(wrapAction(async (step, data) => {
|
|
494
|
-
const inputData = data ? JSON.parse(data) : { test: true }
|
|
495
|
-
await cortex.executePipelineStep(step, inputData)
|
|
496
|
-
}))
|
|
522
|
+
// ========================================
|
|
523
|
+
// CONFIGURATION COMMANDS
|
|
524
|
+
// ========================================
|
|
497
525
|
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
}))
|
|
526
|
+
const config = program.command('config')
|
|
527
|
+
.description('⚙️ Manage configuration')
|
|
518
528
|
|
|
519
|
-
|
|
520
|
-
.command('
|
|
521
|
-
.description('
|
|
522
|
-
.
|
|
523
|
-
|
|
529
|
+
config
|
|
530
|
+
.command('set <key> <value>')
|
|
531
|
+
.description('Set configuration value')
|
|
532
|
+
.option('-e, --encrypt', 'Encrypt this value')
|
|
533
|
+
.action(wrapAction(async (key, value, options) => {
|
|
534
|
+
await cortex.configSet(key, value, options)
|
|
524
535
|
}))
|
|
525
536
|
|
|
526
|
-
|
|
527
|
-
.command('
|
|
528
|
-
.description('
|
|
529
|
-
.action(wrapAction(async (
|
|
530
|
-
await cortex.
|
|
537
|
+
config
|
|
538
|
+
.command('get <key>')
|
|
539
|
+
.description('Get configuration value')
|
|
540
|
+
.action(wrapAction(async (key) => {
|
|
541
|
+
const value = await cortex.configGet(key)
|
|
542
|
+
if (value) {
|
|
543
|
+
console.log(chalk.green(`${key}: ${value}`))
|
|
544
|
+
} else {
|
|
545
|
+
console.log(chalk.yellow(`Key not found: ${key}`))
|
|
546
|
+
}
|
|
531
547
|
}))
|
|
532
548
|
|
|
533
|
-
|
|
534
|
-
.command('
|
|
535
|
-
.description('
|
|
549
|
+
config
|
|
550
|
+
.command('list')
|
|
551
|
+
.description('List all configuration')
|
|
536
552
|
.action(wrapAction(async () => {
|
|
537
|
-
await cortex.
|
|
553
|
+
await cortex.configList()
|
|
538
554
|
}))
|
|
539
555
|
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
556
|
+
// ========================================
|
|
557
|
+
// LEGACY CORTEX COMMANDS (Backward Compatibility)
|
|
558
|
+
// ========================================
|
|
543
559
|
|
|
544
|
-
|
|
545
|
-
.
|
|
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
|
-
}))
|
|
560
|
+
const cortexCmd = program.command('cortex')
|
|
561
|
+
.description('🔧 Legacy Cortex commands (deprecated - use direct commands)')
|
|
552
562
|
|
|
553
|
-
|
|
554
|
-
.command('
|
|
555
|
-
.description('
|
|
556
|
-
.action(
|
|
557
|
-
console.log('
|
|
558
|
-
|
|
559
|
-
console.log('✅ Health checks complete (placeholder)')
|
|
563
|
+
cortexCmd
|
|
564
|
+
.command('chat [question]')
|
|
565
|
+
.description('💬 Chat with your data')
|
|
566
|
+
.action(wrapInteractive(async (question) => {
|
|
567
|
+
console.log(chalk.yellow('⚠️ Deprecated: Use "brainy chat" instead'))
|
|
568
|
+
await cortex.chat(question)
|
|
560
569
|
}))
|
|
561
570
|
|
|
562
|
-
|
|
563
|
-
.command('
|
|
564
|
-
.description('
|
|
565
|
-
.
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
console.log(`🚀 Planning migration to ${options.to}...`)
|
|
569
|
-
// This would call CortexServiceIntegration.migrateAll()
|
|
570
|
-
console.log('✅ Migration complete (placeholder)')
|
|
571
|
+
cortexCmd
|
|
572
|
+
.command('add [data]')
|
|
573
|
+
.description('📊 Add data')
|
|
574
|
+
.action(wrapAction(async (data) => {
|
|
575
|
+
console.log(chalk.yellow('⚠️ Deprecated: Use "brainy add" instead'))
|
|
576
|
+
await cortex.add(data, {})
|
|
571
577
|
}))
|
|
572
578
|
|
|
573
|
-
//
|
|
579
|
+
// ========================================
|
|
580
|
+
// INTERACTIVE SHELL
|
|
581
|
+
// ========================================
|
|
582
|
+
|
|
574
583
|
program
|
|
575
584
|
.command('shell')
|
|
576
|
-
.description('🐚 Interactive
|
|
577
|
-
.action(async () => {
|
|
578
|
-
console.log(chalk.cyan('🧠
|
|
585
|
+
.description('🐚 Interactive Brainy shell')
|
|
586
|
+
.action(wrapInteractive(async () => {
|
|
587
|
+
console.log(chalk.cyan('🧠 Brainy Interactive Shell'))
|
|
579
588
|
console.log(chalk.dim('Type "help" for commands, "exit" to quit\n'))
|
|
580
|
-
|
|
581
|
-
// Start interactive mode
|
|
582
589
|
await cortex.chat()
|
|
583
|
-
|
|
584
|
-
|
|
590
|
+
}))
|
|
591
|
+
|
|
592
|
+
// ========================================
|
|
593
|
+
// PARSE AND HANDLE
|
|
594
|
+
// ========================================
|
|
585
595
|
|
|
586
|
-
// Parse arguments
|
|
587
596
|
program.parse(process.argv)
|
|
588
597
|
|
|
589
598
|
// Show help if no command
|
|
590
599
|
if (!process.argv.slice(2).length) {
|
|
600
|
+
console.log(chalk.cyan('🧠☁️ Brainy - AI Coordination Service'))
|
|
601
|
+
console.log('')
|
|
602
|
+
console.log(chalk.bold('One-Command Setup:'))
|
|
603
|
+
console.log(chalk.green(' brainy cloud # Setup Brain Cloud (recommended!)'))
|
|
604
|
+
console.log('')
|
|
605
|
+
console.log(chalk.bold('Quick Start:'))
|
|
606
|
+
console.log(' brainy init # Initialize project')
|
|
607
|
+
console.log(' brainy add "some data" # Add data')
|
|
608
|
+
console.log(' brainy search "query" # Search data')
|
|
609
|
+
console.log(' brainy chat # Chat with data')
|
|
610
|
+
console.log('')
|
|
611
|
+
console.log(chalk.bold('AI Coordination:'))
|
|
612
|
+
console.log(' brainy install brain-jar # Install AI coordination')
|
|
613
|
+
console.log(' brainy brain-jar start # Start coordination')
|
|
614
|
+
console.log(' brainy brain-jar dashboard # View dashboard')
|
|
615
|
+
console.log('')
|
|
591
616
|
program.outputHelp()
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// ========================================
|
|
620
|
+
// BRAIN CLOUD MEMORY SETUP FUNCTIONS
|
|
621
|
+
// ========================================
|
|
622
|
+
|
|
623
|
+
async function detectCustomerId() {
|
|
624
|
+
try {
|
|
625
|
+
// Method 1: Check for existing brainy config
|
|
626
|
+
const { readFile } = await import('fs/promises')
|
|
627
|
+
const { join } = await import('path')
|
|
628
|
+
|
|
629
|
+
try {
|
|
630
|
+
const configPath = join(process.cwd(), 'brainy-config.json')
|
|
631
|
+
const config = JSON.parse(await readFile(configPath, 'utf8'))
|
|
632
|
+
if (config.brainCloudCustomerId) {
|
|
633
|
+
return config.brainCloudCustomerId
|
|
634
|
+
}
|
|
635
|
+
} catch {}
|
|
636
|
+
|
|
637
|
+
// Method 2: Check CLAUDE.md for existing customer ID
|
|
638
|
+
try {
|
|
639
|
+
const claudePath = join(process.cwd(), 'CLAUDE.md')
|
|
640
|
+
const claudeContent = await readFile(claudePath, 'utf8')
|
|
641
|
+
const match = claudeContent.match(/customer.*?([a-z0-9-]+)/i)
|
|
642
|
+
if (match) return match[1]
|
|
643
|
+
} catch {}
|
|
644
|
+
|
|
645
|
+
// Method 3: Test common demo IDs
|
|
646
|
+
const testIds = ['demo-test-auto', 'demo-test123']
|
|
647
|
+
for (const id of testIds) {
|
|
648
|
+
try {
|
|
649
|
+
const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/health`, {
|
|
650
|
+
headers: { 'x-customer-id': id }
|
|
651
|
+
})
|
|
652
|
+
if (response.ok) {
|
|
653
|
+
return id
|
|
654
|
+
}
|
|
655
|
+
} catch {}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return null
|
|
659
|
+
} catch (error) {
|
|
660
|
+
return null
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async function setupBrainCloudMemory(customerId) {
|
|
665
|
+
const { writeFile, mkdir } = await import('fs/promises')
|
|
666
|
+
const { join } = await import('path')
|
|
667
|
+
|
|
668
|
+
console.log(chalk.gray('📝 Setting up AI memory configuration...'))
|
|
669
|
+
|
|
670
|
+
// 1. Create/update .claude directory and MCP config
|
|
671
|
+
try {
|
|
672
|
+
await mkdir('.claude', { recursive: true })
|
|
673
|
+
|
|
674
|
+
const mcpConfig = {
|
|
675
|
+
mcpServers: {
|
|
676
|
+
"brain-cloud": {
|
|
677
|
+
command: "node",
|
|
678
|
+
args: ["brainy-mcp-server.js"],
|
|
679
|
+
env: {
|
|
680
|
+
CUSTOMER_ID: customerId,
|
|
681
|
+
BRAIN_CLOUD_URL: "https://brain-cloud.dpsifr.workers.dev"
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
await writeFile('.claude/mcp_servers.json', JSON.stringify(mcpConfig, null, 2))
|
|
688
|
+
console.log(chalk.green('✅ MCP configuration updated'))
|
|
689
|
+
} catch (error) {
|
|
690
|
+
console.log(chalk.yellow('⚠️ Could not update MCP config:', error.message))
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// 2. Create/update CLAUDE.md with natural language instructions
|
|
694
|
+
const claudeContent = `# 🧠 I Remember Everything Now!
|
|
695
|
+
|
|
696
|
+
Hi! I'm connected to your Brain Cloud (${customerId}) so I actually remember our conversations across sessions.
|
|
697
|
+
|
|
698
|
+
## Try Saying:
|
|
699
|
+
- "What did we build together?"
|
|
700
|
+
- "Remember that React project?"
|
|
701
|
+
- "Show me what we worked on yesterday"
|
|
702
|
+
- "Find my notes about APIs"
|
|
703
|
+
- "Search for that bug we fixed"
|
|
704
|
+
|
|
705
|
+
## I Can Also:
|
|
706
|
+
- Remember context from weeks ago
|
|
707
|
+
- Work with other AI assistants who share the same memory
|
|
708
|
+
- Keep everything synced across your devices
|
|
709
|
+
- Search through all our conversations
|
|
710
|
+
|
|
711
|
+
## Multi-AI Coordination:
|
|
712
|
+
When working with multiple AI assistants, we automatically coordinate:
|
|
713
|
+
- **Jarvis** (Backend): APIs, databases, deployment
|
|
714
|
+
- **Picasso** (Design): UI, themes, visual elements
|
|
715
|
+
- **Claude** (Planning): Coordination, architecture, strategy
|
|
716
|
+
|
|
717
|
+
**Just talk to me normally - no commands needed!**
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
*Brain Cloud Instance: ${customerId}*
|
|
721
|
+
*Last Updated: ${new Date().toLocaleDateString()}*
|
|
722
|
+
`
|
|
723
|
+
|
|
724
|
+
try {
|
|
725
|
+
await writeFile('CLAUDE.md', claudeContent)
|
|
726
|
+
console.log(chalk.green('✅ CLAUDE.md updated with memory instructions'))
|
|
727
|
+
} catch (error) {
|
|
728
|
+
console.log(chalk.yellow('⚠️ Could not update CLAUDE.md:', error.message))
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// 3. Save customer ID to brainy config
|
|
732
|
+
try {
|
|
733
|
+
const brainyConfig = {
|
|
734
|
+
brainCloudCustomerId: customerId,
|
|
735
|
+
brainCloudUrl: 'https://brain-cloud.dpsifr.workers.dev',
|
|
736
|
+
lastConnected: new Date().toISOString()
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
await writeFile('brainy-config.json', JSON.stringify(brainyConfig, null, 2))
|
|
740
|
+
console.log(chalk.green('✅ Brainy configuration saved'))
|
|
741
|
+
} catch (error) {
|
|
742
|
+
console.log(chalk.yellow('⚠️ Could not save brainy config:', error.message))
|
|
743
|
+
}
|
|
592
744
|
}
|