UNPKG

@aaswe/codebase-ai

Version:

AI-Assisted Software Engineering (AASWE) - Rich codebase context for IDE LLMs

121 lines 3.4 kB
import { Neo4jDatabaseService } from '../layer2/neo4j-database/Neo4jDatabaseService'; export interface CodeEntity { id: string; name: string; type: 'File' | 'Class' | 'Method' | 'Interface' | 'Function'; sourceCode: string; filePath: string; startLine: number; endLine: number; version: string; lastModified: Date; metadata: Record<string, any>; } export interface CodeRelationship { from: string; to: string; type: 'IMPORTS' | 'EXTENDS' | 'IMPLEMENTS' | 'CALLS' | 'USES' | 'CONTAINS' | 'DEPENDS_ON'; metadata: Record<string, any>; version: string; } export interface VersionedCodeGraph { version: string; timestamp: Date; entities: CodeEntity[]; relationships: CodeRelationship[]; ttlSyncHash: string; gitCommit?: string | undefined; } /** * CodeGraphAnalyzer - Advanced code graph analysis with versioning and TTL synchronization * * This service creates a comprehensive code graph by: * 1. Using ts-morph for TypeScript AST analysis * 2. Using dependency-cruiser for module dependency analysis * 3. Storing actual source code content in Neo4j * 4. Maintaining version synchronization with TTL files * 5. Providing rich context for LLM queries */ export declare class CodeGraphAnalyzer { private project; private neo4jService; private currentVersion; constructor(neo4jService: Neo4jDatabaseService); /** * Analyze entire codebase and create versioned code graph */ analyzeCodebase(projectPath: string): Promise<VersionedCodeGraph>; /** * Analyze TypeScript files using ts-morph */ private analyzeTypeScriptFiles; /** * Create file entity from source file */ private createFileEntity; /** * Create class entity from class declaration */ private createClassEntity; /** * Create method entity from method declaration */ private createMethodEntity; /** * Create import relationship */ private createImportRelationship; /** * Analyze function calls (simplified pattern matching) */ private analyzeFunctionCalls; /** * Analyze module dependencies using dependency-cruiser */ private analyzeDependencies; /** * Store versioned graph in Neo4j */ private storeVersionedGraph; /** * Generate TTL sync hash for version correlation */ private generateTTLSyncHash; /** * Find all TTL files in the project */ private findTTLFiles; /** * Find files recursively */ private findFilesRecursive; /** * Get current Git commit hash */ private getCurrentGitCommit; /** * Generate version string */ private generateVersion; /** * Calculate cyclomatic complexity (simplified) */ private calculateCyclomaticComplexity; /** * Get line number from character index */ private getLineNumber; /** * Query code graph */ queryCodeGraph(query: string, version?: string): Promise<any[]>; /** * Get source code for entity */ getSourceCode(entityId: string, version?: string): Promise<string | null>; /** * Search code patterns across versions */ searchCodePatterns(pattern: string, entityType?: string, version?: string): Promise<any[]>; } //# sourceMappingURL=CodeGraphAnalyzer.d.ts.map