🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat: Phase 2 MCP tools for Claude Code ↔ AgentDB bridge (ADR-076)
Reuven223d6c732716
diff --git a/package.json b/package.jsonindex a90f91f381..6a7ed224c1 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "claude-flow",- "version": "3.5.64",+ "version": "3.5.65","description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "dist/index.js","type": "module",diff --git a/ruflo/package.json b/ruflo/package.jsonindex 9c35c9d287..5094f8cf60 100644--- a/ruflo/package.json+++ b/ruflo/package.json@@ -1,6 +1,6 @@{"name": "ruflo",- "version": "3.5.64",+ "version": "3.5.65","description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "bin/ruflo.js","type": "module",diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.jsonindex f772d38b5b..2176f53cec 100644--- a/v3/@claude-flow/cli/package.json+++ b/v3/@claude-flow/cli/package.json@@ -1,6 +1,6 @@{"name": "@claude-flow/cli",- "version": "3.5.64",+ "version": "3.5.65","type": "module","description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code","main": "dist/src/index.js",diff --git a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.tsindex ec9c51c507..674a556bd9 100644--- a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts@@ -577,4 +577,233 @@ export const memoryTools: MCPTool[] = [};},},++ // ===== Claude Code Memory Bridge Tools =====++ {+ name: 'memory_import_claude',+ description: 'Import Claude Code auto-memory files into AgentDB with ONNX vector embeddings. Reads ~/.claude/projects/*/memory/*.md files, parses YAML frontmatter, splits into sections, and stores with 384-dim embeddings for semantic search. Use allProjects=true to import from ALL Claude projects.',+ category: 'memory',+ inputSchema: {+ type: 'object',+ properties: {+ allProjects: { type: 'boolean', description: 'Import from all Claude projects (default: current project only)' },+ namespace: { type: 'string', description: 'Target namespace (default: "claude-memories")' },+ },+ },+ handler: async (input) => {+ await ensureInitialized();+ const { storeEntry } = await getMemoryFunctions();+ const { homedir } = await import('os');++ const ns = (input.namespace as string) || 'claude-memories';+ const allProjects = input.allProjects as boolean;+ const claudeProjectsDir = join(homedir(), '.claude', 'projects');++ // Find memory files+ const memoryFiles: Array<{ path: string; project: string; file: string }> = [];++ if (allProjects) {+ // Scan all projects+ if (existsSync(claudeProjectsDir)) {+ try {+ const projects = readFileSync; // just need fs methods already imported+ const { readdirSync: readDir } = await import('fs');+ for (const project of readDir(claudeProjectsDir, { withFileTypes: true })) {+ if (!project.isDirectory()) continue;+ const memDir = join(claudeProjectsDir, project.name, 'memory');+ if (!existsSync(memDir)) continue;+ for (const file of readDir(memDir).filter((f: string) => f.endsWith('.md'))) {+ memoryFiles.push({ path: join(memDir, file), project: project.name, file });+ }+ }+ } catch { /* scan error */ }+ }+ } else {+ // Current project only — find by CWD hash+ const cwd = process.cwd();+ const projectHash = cwd.replace(/\//g, '-');+ const memDir = join(claudeProjectsDir, projectHash, 'memory');+ if (existsSync(memDir)) {+ try {+ const { readdirSync: readDir } = await import('fs');+ for (const file of readDir(memDir).filter((f: string) => f.endsWith('.md'))) {+ memoryFiles.push({ path: join(memDir, file), project: projectHash, file });+ }+ } catch { /* scan error */ }+ }+ }++ if (memoryFiles.length === 0) {+ return { success: true, imported: 0, message: 'No Claude memory files found' };+ }++ let imported = 0;+ let skipped = 0;+ const projects = new Set<string>();++ for (const memFile of memoryFiles) {+ projects.add(memFile.project);+ try {+ const content = readFileSync(memFile.path, 'utf-8');+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);+ let name = memFile.file.replace('.md', '');+ let body = content;++ if (frontmatterMatch) {+ const yaml = frontmatterMatch[1];+ body = frontmatterMatch[2].trim();+ const nameMatch = yaml.match(/^name:\s*(.+)$/m);+ if (nameMatch) name = nameMatch[1].trim();+ }++ // Split into sections for granular search+ const sections = body.split(/^(?=## )/m).filter(s => s.trim().length > 20);++ if (sections.length === 0 && body.length > 10) {+ await storeEntry({ key: `claude:${memFile.project}:${name}`, value: body.slice(0, 4096), namespace: ns, generateEmbeddingFlag: true });+ imported++;+ } else {+ for (const section of sections) {+ const titleMatch = section.match(/^##\s+(.+)/);+ const sectionTitle = titleMatch ? titleMatch[1].trim() : name;+ const sectionBody = section.replace(/^##\s+.+\n/, '').trim();+ if (sectionBody.length < 10) continue;+ await storeEntry({ key: `claude:${memFile.project}:${name}:${sectionTitle.slice(0, 50)}`, value: sectionBody.slice(0, 4096), namespace: ns, generateEmbeddingFlag: true });+ imported++;+ }+ }+ } catch {+ skipped++;+ }+ }++ return {+ success: true,+ imported,+ skipped,+ files: memoryFiles.length,+ projects: projects.size,+ namespace: ns,+ embedding: 'ONNX all-MiniLM-L6-v2 (384-dim)',+ };+ },+ },++ {+ name: 'memory_bridge_status',+ description: 'Show Claude Code memory bridge status — AgentDB vectors, SONA learning, intelligence patterns, and connection health.',+ category: 'memory',+ inputSchema: { type: 'object', properties: {} },+ handler: async () => {+ await ensureInitialized();+ const { homedir } = await import('os');++ // Count Claude memory files+ const claudeProjectsDir = join(homedir(), '.claude', 'projects');+ let claudeFiles = 0;+ let claudeProjects = 0;+ if (existsSync(claudeProjectsDir)) {+ try {+ const { readdirSync: readDir } = await import('fs');+ for (const project of readDir(claudeProjectsDir, { withFileTypes: true })) {+ if (!project.isDirectory()) continue;+ const memDir = join(claudeProjectsDir, project.name, 'memory');+ if (!existsSync(memDir)) continue;+ const files = readDir(memDir).filter((f: string) => f.endsWith('.md'));+ if (files.length > 0) { claudeProjects++; claudeFiles += files.length; }+ }+ } catch { /* ignore */ }+ }++ // AgentDB status+ let agentdbEntries = 0;+ let claudeMemoryEntries = 0;+ try {+ const { listEntries } = await getMemoryFunctions();+ const allEntries = await listEntries({});+ agentdbEntries = allEntries?.entries?.length ?? 0;+ const claudeEntries = await listEntries({ namespace: 'claude-memories' });+ claudeMemoryEntries = claudeEntries?.entries?.length ?? 0;+ } catch { /* ignore */ }++ // Intelligence status+ let intelligence = { sonaEnabled: false, patternsLearned: 0, trajectoriesRecorded: 0 };+ try {+ const int = await import('../memory/intelligence.js');+ const stats = int.getIntelligenceStats?.();+ if (stats) intelligence = { sonaEnabled: stats.sonaEnabled, patternsLearned: stats.patternsLearned, trajectoriesRecorded: stats.trajectoriesRecorded };+ } catch { /* not initialized */ }++ return {+ claudeCode: { memoryFiles: claudeFiles, projects: claudeProjects },+ agentdb: { totalEntries: agentdbEntries, claudeMemoryEntries, backend: 'sql.js + ONNX' },+ intelligence,+ bridge: { status: claudeMemoryEntries > 0 ? 'connected' : 'not-synced', embedding: 'all-MiniLM-L6-v2 (384-dim)' },+ };+ },+ },++ {+ name: 'memory_search_unified',+ description: 'Search across both Claude Code memories and AgentDB entries using semantic vector similarity. Returns merged, deduplicated results from all namespaces.',+ category: 'memory',+ inputSchema: {+ type: 'object',+ properties: {+ query: { type: 'string', description: 'Search query (natural language)' },+ limit: { type: 'number', description: 'Max results (default: 10)' },+ namespace: { type: 'string', description: 'Filter to namespace (omit for all)' },+ },+ required: ['query'],+ },+ handler: async (input) => {+ await ensureInitialized();+ const { searchEntries } = await getMemoryFunctions();+ validateMemoryInput(undefined, undefined, input.query as string);++ const query = input.query as string;+ const limit = (input.limit as number) || 10;+ const ns = input.namespace as string | undefined;++ // Search all namespaces unless filtered+ const namespaces = ns ? [ns] : ['default', 'claude-memories', 'auto-memory', 'patterns', 'tasks', 'feedback'];+ const allResults: Array<{ key: string; content: string; score: number; namespace: string; source: string }> = [];++ for (const searchNs of namespaces) {+ try {+ const r = await searchEntries({ query, namespace: searchNs, limit: limit * 2 });+ if (r?.results) {+ for (const entry of r.results) {+ allResults.push({+ key: entry.key || entry.id || '',+ content: (entry.content || (entry as any).value || '').toString().slice(0, 200),+ score: entry.score || 0,+ namespace: searchNs,+ source: searchNs === 'claude-memories' ? 'claude-code' : searchNs === 'auto-memory' ? 'auto-memory' : 'agentdb',+ });+ }+ }+ } catch { /* namespace may not exist */ }+ }++ // Sort by score, deduplicate by key, take top N+ allResults.sort((a, b) => b.score - a.score);+ const seen = new Set<string>();+ const deduplicated = allResults.filter(r => {+ if (seen.has(r.key)) return false;+ seen.add(r.key);+ return true;+ }).slice(0, limit);++ return {+ success: true,+ query,+ results: deduplicated,+ total: deduplicated.length,+ searchedNamespaces: namespaces,+ searchTime: Date.now(),+ };+ },+ },];