/** * @nahisaho/musubix-codegraph - CodeGraph Facade * * Main entry point for code graph analysis * * @packageDocumentation * @module @nahisaho/musubix-codegraph * * @see REQ-CG-API-001 * @see REQ-CG-API-002 * @see REQ-CG-API-003 * @see DES-CG-001 */ import type { CodeGraphOptions, Entity, QueryResult, IndexResult, GraphStatistics, CallPath, ModuleAnalysis, CodeSnippet, FileStructure, SearchResult, GraphQuery, DependencyOptions, LocalSearchOptions, GlobalSearchOptions } from './types.js'; import { CodeGraphEventEmitter } from './events/index.js'; /** * CodeGraph - Main facade for code graph analysis * * Provides a unified API for: * - AST parsing and entity extraction * - Graph construction and querying * - Dependency and call graph analysis * - GraphRAG-based semantic search * * @example * ```typescript * // Basic usage * const codeGraph = new CodeGraph({ storage: 'memory' }); * await codeGraph.index('/path/to/repo'); * * const deps = await codeGraph.findDependencies('UserService'); * const callers = await codeGraph.findCallers('authenticate'); * const results = await codeGraph.globalSearch('authentication'); * ``` * * @see REQ-CG-API-001 - Library as standalone * @see REQ-CG-API-002 - Programmatic API */ export declare class CodeGraph extends CodeGraphEventEmitter { private options; private storage; private initialized; /** * Create a new CodeGraph instance * * @param options - Configuration options */ constructor(options?: CodeGraphOptions); /** * Register a handler for indexing start events */ onIndexingStart(handler: (path: string) => void): this; /** * Register a handler for indexing complete events */ onIndexingComplete(handler: (result: { entitiesIndexed: number; relationsIndexed: number; errors: unknown[]; }) => void): this; /** * Register a handler for indexing progress events */ onIndexingProgress(handler: (processed: number, total: number, currentFile: string) => void): this; /** * Register a handler for indexing error events */ onIndexingError(handler: (error: Error, file?: string) => void): this; /** * Register a handler for query start events */ onQueryStart(handler: (query: GraphQuery) => void): this; /** * Register a handler for query complete events */ onQueryComplete(handler: (result: QueryResult, durationMs: number) => void): this; /** * Initialize the CodeGraph instance * * @internal */ private ensureInitialized; /** * Create storage adapter based on options * * @internal */ private createStorage; /** * Index a repository or directory * * @param path - Path to repository or directory * @returns Index result with statistics * * @see REQ-CG-IDX-001 * * @example * ```typescript * const result = await codeGraph.index('/path/to/repo'); * console.log(`Indexed ${result.entitiesIndexed} entities`); * ``` */ index(path: string): Promise; /** * Reindex a repository (clear and index fresh) * * @param path - Path to repository or directory * @returns Index result with statistics */ reindex(path: string): Promise; /** * Query the code graph * * @param query - Search query string or query object * @returns Query result with matching entities * * @see REQ-CG-GRF-003 */ query(query: string | GraphQuery): Promise; /** * Find dependencies of an entity * * @param entityName - Name or ID of the entity * @param options - Dependency analysis options * @returns List of dependent entities * * @see REQ-CG-GRF-004 */ findDependencies(entityName: string, options?: DependencyOptions): Promise; /** * Find callers of a function or method * * @param entityName - Name or ID of the function/method * @returns List of call paths * * @see REQ-CG-GRF-005 */ findCallers(entityName: string): Promise; /** * Find callees of a function or method * * @param entityName - Name or ID of the function/method * @returns List of call paths * * @see REQ-CG-GRF-005 */ findCallees(entityName: string): Promise; /** * Find implementations of an interface * * @param interfaceName - Name or ID of the interface * @returns List of implementing entities */ findImplementations(interfaceName: string): Promise; /** * Analyze module structure * * @param path - Path to module/file * @returns Module analysis result */ analyzeModule(path: string): Promise; /** * Get source code snippet for an entity * * @param entityId - Entity ID * @returns Code snippet with context */ getSnippet(entityId: string): Promise; /** * Get file structure overview * * @param path - File path * @returns File structure with entities */ getFileStructure(path: string): Promise; /** * Global search across all code communities * * @param query - Search query * @param options - Search options * @returns Search results with relevance scores * * @see REQ-CG-RAG-002 */ globalSearch(query: string, options?: GlobalSearchOptions): Promise; /** * Local search in entity neighborhood * * @param entityName - Entity name or ID * @param options - Search options * @returns Search results from entity neighborhood * * @see REQ-CG-RAG-003 */ localSearch(entityName: string, options?: LocalSearchOptions): Promise; /** * Get graph statistics * * @returns Graph statistics */ getStats(): Promise; /** * Close the CodeGraph instance and release resources */ close(): Promise; /** * Check if instance is initialized */ isInitialized(): boolean; } /** * Create a new CodeGraph instance * * @param options - Configuration options * @returns CodeGraph instance */ export declare function createCodeGraph(options?: CodeGraphOptions): CodeGraph; //# sourceMappingURL=codegraph.d.ts.map