claude-flow 3.5.64 → 3.5.65

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.
@@ -255,6 +255,36 @@ async function doImport() {
255
255
  dim(`├─ Learning: ${config.learningBridge.enabled ? 'active' : 'disabled'}`);
256
256
  dim(`├─ Graph: ${config.memoryGraph.enabled ? 'active' : 'disabled'}`);
257
257
  dim(`└─ Agent scopes: ${config.agentScopes.enabled ? 'active' : 'disabled'}`);
258
+
259
+ // Bridge to AgentDB: store entries with ONNX vector embeddings for semantic search
260
+ let vectorized = 0;
261
+ try {
262
+ const cliDistPath = join(PROJECT_ROOT, 'v3/@claude-flow/cli/dist/src/memory/memory-initializer.js');
263
+ if (existsSync(cliDistPath)) {
264
+ const memInit = await import(`file://${cliDistPath}`);
265
+ await memInit.initializeMemoryDatabase({ force: false, verbose: false });
266
+
267
+ const entries = await backend.query({});
268
+ for (const entry of entries) {
269
+ if (!entry.content || entry.content.length < 10) continue;
270
+ try {
271
+ await memInit.storeEntry({
272
+ key: entry.key || entry.id,
273
+ value: entry.content,
274
+ namespace: entry.namespace || 'auto-memory',
275
+ generateEmbeddingFlag: true,
276
+ });
277
+ vectorized++;
278
+ } catch { /* skip entries that fail to embed */ }
279
+ }
280
+
281
+ if (vectorized > 0) {
282
+ success(`Vectorized ${vectorized} entries into AgentDB (ONNX 384-dim)`);
283
+ }
284
+ }
285
+ } catch (vecErr) {
286
+ dim(`AgentDB vectorization skipped: ${vecErr.message?.slice(0, 60)}`);
287
+ }
258
288
  } catch (err) {
259
289
  dim(`Import failed (non-critical): ${err.message}`);
260
290
  }
@@ -313,6 +343,21 @@ async function doSync() {
313
343
  // Curate MEMORY.md index with graph-aware ordering
314
344
  await bridge.curateIndex();
315
345
  success('Curated MEMORY.md index');
346
+
347
+ // Flush intelligence patterns to disk (SONA + ReasoningBank)
348
+ try {
349
+ const intPath = join(PROJECT_ROOT, 'v3/@claude-flow/cli/dist/src/memory/intelligence.js');
350
+ if (existsSync(intPath)) {
351
+ const intelligence = await import(`file://${intPath}`);
352
+ if (intelligence.flushPatterns) {
353
+ intelligence.flushPatterns();
354
+ const stats = intelligence.getIntelligenceStats?.();
355
+ if (stats && stats.patternsLearned > 0) {
356
+ success(`Flushed ${stats.patternsLearned} learned patterns to disk`);
357
+ }
358
+ }
359
+ }
360
+ } catch { /* non-critical */ }
316
361
  } catch (err) {
317
362
  dim(`Sync failed (non-critical): ${err.message}`);
318
363
  }
@@ -339,9 +384,158 @@ async function doStatus() {
339
384
  } catch { /* ignore */ }
340
385
  }
341
386
 
387
+ // AgentDB vector status
388
+ try {
389
+ const dbPath = join(PROJECT_ROOT, '.claude-flow', 'memory', 'memory.db');
390
+ const swarmDbPath = join(PROJECT_ROOT, '.swarm', 'memory.db');
391
+ const hasDb = existsSync(dbPath) || existsSync(swarmDbPath);
392
+ console.log(` AgentDB: ${hasDb ? '✅ sql.js database exists' : '⏸ Not initialized'}`);
393
+
394
+ const intPath = join(PROJECT_ROOT, 'v3/@claude-flow/cli/dist/src/memory/intelligence.js');
395
+ if (existsSync(intPath)) {
396
+ const intelligence = await import(`file://${intPath}`);
397
+ const stats = intelligence.getIntelligenceStats?.();
398
+ if (stats) {
399
+ console.log(` SONA: ${stats.sonaEnabled ? '✅ Active' : '⏸ Not initialized'}`);
400
+ console.log(` Patterns: ${stats.patternsLearned} learned`);
401
+ console.log(` Trajectories: ${stats.trajectoriesRecorded} recorded`);
402
+ }
403
+ }
404
+ } catch { /* ignore */ }
405
+
342
406
  console.log('');
343
407
  }
344
408
 
409
+ // ============================================================================
410
+ // Import ALL Claude Code memories from all projects into AgentDB
411
+ // ============================================================================
412
+
413
+ async function doImportAll() {
414
+ log('Importing ALL Claude Code memories into AgentDB...');
415
+
416
+ const { homedir } = await import('os');
417
+ const { readdirSync } = await import('fs');
418
+ const claudeProjectsDir = join(homedir(), '.claude', 'projects');
419
+
420
+ if (!existsSync(claudeProjectsDir)) {
421
+ dim('No Claude Code projects found at ' + claudeProjectsDir);
422
+ return;
423
+ }
424
+
425
+ // Find all memory files across all projects
426
+ const memoryFiles = [];
427
+ try {
428
+ const projects = readdirSync(claudeProjectsDir, { withFileTypes: true });
429
+ for (const project of projects) {
430
+ if (!project.isDirectory()) continue;
431
+ const memDir = join(claudeProjectsDir, project.name, 'memory');
432
+ if (!existsSync(memDir)) continue;
433
+ const files = readdirSync(memDir).filter(f => f.endsWith('.md'));
434
+ for (const file of files) {
435
+ memoryFiles.push({
436
+ path: join(memDir, file),
437
+ project: project.name,
438
+ file,
439
+ });
440
+ }
441
+ }
442
+ } catch (err) {
443
+ dim('Error scanning projects: ' + err.message);
444
+ return;
445
+ }
446
+
447
+ if (memoryFiles.length === 0) {
448
+ dim('No memory files found');
449
+ return;
450
+ }
451
+
452
+ log(`Found ${memoryFiles.length} memory files across ${new Set(memoryFiles.map(f => f.project)).size} projects`);
453
+
454
+ // Load memory-initializer for vectorized storage
455
+ let memInit = null;
456
+ try {
457
+ const cliDistPath = join(PROJECT_ROOT, 'v3/@claude-flow/cli/dist/src/memory/memory-initializer.js');
458
+ if (existsSync(cliDistPath)) {
459
+ memInit = await import(`file://${cliDistPath}`);
460
+ await memInit.initializeMemoryDatabase({ force: false, verbose: false });
461
+ }
462
+ } catch (err) {
463
+ dim('Memory initializer not available: ' + err.message?.slice(0, 60));
464
+ }
465
+
466
+ if (!memInit) {
467
+ dim('Cannot vectorize without memory-initializer. Run: cd v3/@claude-flow/cli && npm run build');
468
+ return;
469
+ }
470
+
471
+ let imported = 0;
472
+ let skipped = 0;
473
+
474
+ for (const memFile of memoryFiles) {
475
+ try {
476
+ const content = readFileSync(memFile.path, 'utf-8');
477
+
478
+ // Parse YAML frontmatter + body
479
+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
480
+ let name = memFile.file.replace('.md', '');
481
+ let description = '';
482
+ let type = 'auto-memory';
483
+ let body = content;
484
+
485
+ if (frontmatterMatch) {
486
+ const yaml = frontmatterMatch[1];
487
+ body = frontmatterMatch[2].trim();
488
+ const nameMatch = yaml.match(/^name:\s*(.+)$/m);
489
+ const descMatch = yaml.match(/^description:\s*(.+)$/m);
490
+ const typeMatch = yaml.match(/^type:\s*(.+)$/m);
491
+ if (nameMatch) name = nameMatch[1].trim();
492
+ if (descMatch) description = descMatch[1].trim();
493
+ if (typeMatch) type = typeMatch[1].trim();
494
+ }
495
+
496
+ // Split body into sections (## headers) for granular entries
497
+ const sections = body.split(/^(?=## )/m).filter(s => s.trim().length > 20);
498
+
499
+ if (sections.length === 0) {
500
+ // Store whole file as one entry
501
+ if (body.length > 10) {
502
+ await memInit.storeEntry({
503
+ key: `claude-memory:${memFile.project}:${name}`,
504
+ value: body.slice(0, 4096),
505
+ namespace: 'claude-memories',
506
+ generateEmbeddingFlag: true,
507
+ });
508
+ imported++;
509
+ }
510
+ } else {
511
+ // Store each section separately for better search granularity
512
+ for (const section of sections) {
513
+ const titleMatch = section.match(/^##\s+(.+)/);
514
+ const sectionTitle = titleMatch ? titleMatch[1].trim() : name;
515
+ const sectionBody = section.replace(/^##\s+.+\n/, '').trim();
516
+ if (sectionBody.length < 10) continue;
517
+
518
+ await memInit.storeEntry({
519
+ key: `claude-memory:${memFile.project}:${name}:${sectionTitle.slice(0, 50)}`,
520
+ value: sectionBody.slice(0, 4096),
521
+ namespace: 'claude-memories',
522
+ generateEmbeddingFlag: true,
523
+ });
524
+ imported++;
525
+ }
526
+ }
527
+
528
+ dim(` ✓ ${memFile.project}/${memFile.file} (${sections.length || 1} entries)`);
529
+ } catch (err) {
530
+ dim(` ✗ ${memFile.project}/${memFile.file}: ${err.message?.slice(0, 60)}`);
531
+ skipped++;
532
+ }
533
+ }
534
+
535
+ success(`Imported ${imported} entries from ${memoryFiles.length} files (${skipped} skipped)`);
536
+ success('All Claude Code memories now searchable via AgentDB vector search');
537
+ }
538
+
345
539
  // ============================================================================
346
540
  // Main
347
541
  // ============================================================================
@@ -355,6 +549,7 @@ process.on('unhandledRejection', () => {});
355
549
  try {
356
550
  switch (command) {
357
551
  case 'import': await doImport(); break;
552
+ case 'import-all': await doImportAll(); break;
358
553
  case 'sync': await doSync(); break;
359
554
  case 'status': await doStatus(); break;
360
555
  default: