UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

146 lines 5.59 kB
import { IntentSnapshot, TodoSyncState, KnowledgeGraphSnapshot } from '../types/knowledge-graph-schemas.js'; /** * Manages knowledge graph snapshots and todo synchronization state * Provides persistent storage and retrieval of architectural knowledge * * @deprecated This class will be replaced by knowledge://graph Resource and update_knowledge tool (ADR-018). * For reading graph data, use knowledge://graph resource (zero token cost). * For modifying graph data, use update_knowledge tool (simple CRUD operations). * Internal use only - external tools should migrate to new patterns. * * Migration Path: * - Reading graph: Use knowledge://graph resource instead of queryKnowledgeGraph() * - Adding entities: Use update_knowledge tool with operation='add_entity' * - Removing entities: Use update_knowledge tool with operation='remove_entity' * - Relationships: Use update_knowledge tool with operation='add_relationship'/'remove_relationship' * * This class will be removed in the next major version (v3.0.0). */ export declare class KnowledgeGraphManager { private cacheDir; private snapshotsFile; private syncStateFile; private memoryScoring; /** * Initialize the knowledge graph manager with cache directory setup */ constructor(); /** * Ensure the cache directory exists, creating it if necessary */ ensureCacheDirectory(): Promise<void>; /** * Load the knowledge graph snapshot from cache * @returns Promise resolving to the knowledge graph snapshot */ loadKnowledgeGraph(): Promise<KnowledgeGraphSnapshot>; saveKnowledgeGraph(snapshot: KnowledgeGraphSnapshot): Promise<void>; createIntent(humanRequest: string, parsedGoals: string[], priority?: 'high' | 'medium' | 'low'): Promise<string>; addToolExecution(intentId: string, toolName: string, parameters: Record<string, any>, result: Record<string, any>, success: boolean, todoTasksCreated?: string[], todoTasksModified?: string[], error?: string): Promise<void>; addMemoryExecution(toolName: string, action: string, entityType: string, success: boolean, details?: Record<string, any>): Promise<void>; private updateMemoryAnalytics; updateIntentStatus(intentId: string, status: 'planning' | 'executing' | 'completed' | 'failed'): Promise<void>; updateTodoSnapshot(intentId: string, todoContent: string): Promise<void>; getSyncState(): Promise<TodoSyncState>; updateSyncState(updates: Partial<TodoSyncState>): Promise<void>; getIntentById(intentId: string): Promise<IntentSnapshot | null>; getActiveIntents(): Promise<IntentSnapshot[]>; getIntentsByStatus(status: 'planning' | 'executing' | 'completed' | 'failed'): Promise<IntentSnapshot[]>; private getDefaultSyncState; private updateAnalytics; calculateTodoMdHash(todoPath: string): Promise<string>; detectTodoChanges(todoPath: string): Promise<{ hasChanges: boolean; currentHash: string; lastHash: string; }>; /** * Update score tracking for an intent after tool execution */ private updateScoreTracking; /** * Get score trends for an intent */ getIntentScoreTrends(intentId: string): Promise<{ initialScore: number; currentScore: number; progress: number; componentTrends: Record<string, number>; scoreHistory: Array<{ timestamp: string; score: number; triggerEvent: string; }>; }>; /** * Get overall project score trends */ getProjectScoreTrends(): Promise<{ currentScore: number; scoreHistory: Array<{ timestamp: string; score: number; triggerEvent: string; intentId?: string; }>; averageImprovement: number; topImpactingIntents: Array<{ intentId: string; humanRequest: string; scoreImprovement: number; }>; }>; /** * Record project structure analysis to knowledge graph */ recordProjectStructure(structureSnapshot: { projectPath: string; analysisDepth: string; recursiveDepth: string; technologyFocus: string[]; analysisScope: string[]; includeEnvironment: boolean; timestamp: string; structureData: any; }): Promise<void>; /** * Query knowledge graph for relevant information based on question */ queryKnowledgeGraph(question: string): Promise<{ found: boolean; nodes: any[]; relationships: any[]; relevantIntents: IntentSnapshot[]; relevantDecisions: any[]; }>; /** * Extract keywords from query for knowledge graph search */ private extractQueryKeywords; /** * Get relationships from knowledge graph * @deprecated Use queryKnowledgeGraph for actual queries */ getRelationships(_nodeType: string, _relationType?: string): Array<any>; /** * Calculate memory-based health score from knowledge graph */ private calculateMemoryScore; /** * Extract memory representations from knowledge graph */ private extractMemoriesFromKG; /** * Calculate retrieval metrics from tool execution patterns */ private calculateRetrievalMetrics; /** * Build entity graph from knowledge graph */ private buildEntityGraph; /** * Calculate relevance score for an intent */ private calculateIntentRelevance; } //# sourceMappingURL=knowledge-graph-manager.d.ts.map