/**
 * Dependency-Aware RAG System
 *
 * Enhanced RAG that integrates dependency graph analysis for better context retrieval.
 * Based on CodeRAG research for repo-level code generation.
 *
 * Key improvements:
 * - Dependency-aware retrieval: when finding code, also retrieve dependencies
 * - Call graph context: understand caller/callee relationships
 * - Import chain resolution: follow import paths for complete context
 * - Smart context expansion: prioritize relevant connected code
 *
 * Research basis:
 * - CodeRAG (2024): Repository-level code generation with dependency graphs
 * - CRAG (2024): Corrective RAG for knowledge-intensive tasks
 */
import { EventEmitter } from 'events';
import { DependencyAnalysisResult } from '../tools/intelligence/dependency-analyzer.js';
import { CodeChunk, RetrievalResult } from './codebase-rag/types.js';
/**
 * Configuration for dependency-aware RAG
 */
export interface DependencyRAGConfig {
    dependencyDepth: number;
    dependentDepth: number;
    maxDependencyFiles: number;
    maxDependencyTokens: number;
    dependencyWeight: number;
    includeImportExports: boolean;
    analyzeCallGraph: boolean;
    cacheTTL: number;
}
/**
 * Extended retrieval result with dependency information
 */
export interface DependencyAwareResult extends RetrievalResult {
    dependencies: DependencyContext[];
    dependents: DependencyContext[];
    graphStats: {
        filesAnalyzed: number;
        totalDependencies: number;
        dependencyDepth: number;
    };
}
/**
 * Dependency context information
 */
export interface DependencyContext {
    filePath: string;
    relativePath: string;
    imports: string[];
    exports: string[];
    relevanceScore: number;
    summary?: string;
    keyChunks: CodeChunk[];
    relationship: 'imports' | 'imported_by' | 'calls' | 'called_by' | 'related';
}
/**
 * Dependency-Aware RAG class
 */
export declare class DependencyAwareRAG extends EventEmitter {
    private config;
    private baseRAG;
    private depAnalyzer;
    private analysisCache;
    private isInitialized;
    private currentAnalysis;
    constructor(config?: Partial<DependencyRAGConfig>);
    /**
     * Initialize the dependency-aware RAG system
     */
    initialize(rootPath: string): Promise<void>;
    /**
     * Retrieve code with dependency-aware context
     */
    retrieve(query: string, rootPath: string, options?: {
        topK?: number;
        minScore?: number;
        includeDependencies?: boolean;
        includeDependents?: boolean;
        filters?: {
            languages?: string[];
            filePatterns?: string[];
        };
    }): Promise<DependencyAwareResult>;
    /**
     * Find dependencies of given files
     */
    private findDependencies;
    /**
     * Find dependents of given files (files that import them)
     */
    private findDependents;
    /**
     * Build dependency context for a file
     */
    private buildDependencyContext;
    /**
     * Generate a summary of a file based on its node and chunks
     */
    private generateFileSummary;
    /**
     * Score dependency contexts based on query relevance
     */
    private scoreDependencyContexts;
    /**
     * Re-rank chunks incorporating dependency information
     */
    private reRankWithDependencies;
    /**
     * Get expanded context for a specific file
     */
    getExpandedContext(filePath: string, rootPath: string, options?: {
        includeImports?: boolean;
        includeExports?: boolean;
        maxTokens?: number;
    }): Promise<{
        file: DependencyContext;
        imports: DependencyContext[];
        exports: DependencyContext[];
        totalTokens: number;
    }>;
    /**
     * Find the shortest path between two files in the dependency graph
     */
    getDependencyPath(fromFile: string, toFile: string): string[] | null;
    /**
     * Get all files that would be affected by changes to a file
     */
    getImpactedFiles(filePath: string): string[];
    /**
     * Format results for display
     */
    formatResult(result: DependencyAwareResult): string;
    /**
     * Tokenize text for scoring
     */
    private tokenize;
    /**
     * Estimate token count
     */
    private estimateTokens;
    /**
     * Clear the cache
     */
    clearCache(): void;
    /**
     * Get current statistics
     */
    getStats(): {
        isInitialized: boolean;
        cacheSize: number;
        graphStats: DependencyAnalysisResult['stats'] | null;
    };
    /**
     * Dispose resources and cleanup
     */
    dispose(): void;
}
/**
 * Create a DependencyAwareRAG instance
 */
export declare function createDependencyAwareRAG(config?: Partial<DependencyRAGConfig>): DependencyAwareRAG;
export declare function getDependencyAwareRAG(config?: Partial<DependencyRAGConfig>): DependencyAwareRAG;
export declare function resetDependencyAwareRAG(): void;
