UNPKG

memory-engineering

Version:

Advanced Memory-Aware Code Context System with claude-flow-inspired architecture, showcasing MongoDB + Voyage AI strategic positioning

65 lines (55 loc) • 2.3 kB
/** * Memory Init Tool * Initialize memory system for a project */ import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { IMemoryManager } from '../memory/memory-manager.js'; import { logger } from '../utils/logger.js'; export const memoryInitTool: Tool = { name: 'memory_init', description: 'Initialize memory system for a project', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Project path to initialize' } }, required: ['projectPath'] } }; export function createMemoryInitHandler(memoryManager: IMemoryManager) { return async (args: any) => { try { const { projectPath } = args; // Check health status const health = await memoryManager.getHealthStatus(); if (!health.healthy) { throw new Error(`Memory system not healthy: ${health.error}`); } // Query existing memories for this project const existingMemories = await memoryManager.query({ projectPath, limit: 10 }); logger.info('Memory system initialized', { projectPath, existingMemoriesCount: existingMemories.length, healthy: health.healthy, metrics: health.metrics }); const memoryTypes = [...new Set(existingMemories.map(m => m.memoryType))]; return { content: [{ type: 'text', text: `āœ… Memory system initialized for project!\n\nšŸ“Š **Status:**\n- Health: ${health.healthy ? 'āœ… Healthy' : 'āŒ Unhealthy'}\n- Existing memories: ${existingMemories.length}\n- Memory types: ${memoryTypes.join(', ') || 'None yet'}\n\nšŸš€ **Available Tools:**\n1. memory_project_brief - Define project requirements\n2. memory_product_context - Product vision\n3. memory_active_context - Current work tracking\n4. memory_search - Search memories\n5. memory_codebase_embed - Index codebase\n\nšŸ’” Start with 'memory_project_brief' to establish project identity.` }], isError: false }; } catch (error) { logger.error('Failed to initialize memory system', error); return { content: [{ type: 'text', text: `āŒ Initialization error: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } }; }