@soulcraft/brainy 0.58.1 ā 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 +283 -2
- package/package.json +2 -1
package/bin/brainy.js
CHANGED
|
@@ -14,6 +14,9 @@ import { readFileSync } from 'fs'
|
|
|
14
14
|
import { dirname, join } from 'path'
|
|
15
15
|
import { fileURLToPath } from 'url'
|
|
16
16
|
|
|
17
|
+
// Import fetch for API calls
|
|
18
|
+
import fetch from 'node-fetch'
|
|
19
|
+
|
|
17
20
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
18
21
|
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'))
|
|
19
22
|
|
|
@@ -177,10 +180,51 @@ program
|
|
|
177
180
|
// BRAIN CLOUD INTEGRATION
|
|
178
181
|
// ========================================
|
|
179
182
|
|
|
183
|
+
program
|
|
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
|
+
}
|
|
219
|
+
}))
|
|
220
|
+
|
|
180
221
|
program
|
|
181
222
|
.command('cloud [action]')
|
|
182
223
|
.description('āļø Connect to Brain Cloud - AI memory that never forgets')
|
|
183
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')
|
|
184
228
|
.option('--migrate', 'Migrate between local and cloud')
|
|
185
229
|
.action(wrapInteractive(async (action, options) => {
|
|
186
230
|
// For now, show connection instructions
|
|
@@ -189,8 +233,118 @@ program
|
|
|
189
233
|
|
|
190
234
|
if (options.connect) {
|
|
191
235
|
console.log(chalk.green(`ā
Connecting to Brain Cloud instance: ${options.connect}`))
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
}
|
|
194
348
|
} else {
|
|
195
349
|
console.log(chalk.yellow('š” Brain Cloud Setup'))
|
|
196
350
|
console.log('\n1. Sign up at: ' + chalk.cyan('https://app.soulcraftlabs.com'))
|
|
@@ -460,4 +614,131 @@ if (!process.argv.slice(2).length) {
|
|
|
460
614
|
console.log(' brainy brain-jar dashboard # View dashboard')
|
|
461
615
|
console.log('')
|
|
462
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
|
+
}
|
|
463
744
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.0",
|
|
4
4
|
"description": "A vector graph database using HNSW indexing with Origin Private File System storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -219,6 +219,7 @@
|
|
|
219
219
|
"cli-table3": "^0.6.3",
|
|
220
220
|
"commander": "^11.1.0",
|
|
221
221
|
"dotenv": "^16.4.5",
|
|
222
|
+
"inquirer": "^12.9.1",
|
|
222
223
|
"ora": "^8.0.1",
|
|
223
224
|
"prompts": "^2.4.2",
|
|
224
225
|
"uuid": "^9.0.1"
|