/**
 * Codebase RAG System
 *
 * Main RAG (Retrieval-Augmented Generation) system for codebase search.
 * Implements semantic code search with intelligent chunking and retrieval.
 *
 * Based on research from:
 * - Corrective RAG (CRAG, 2024)
 * - RAG for Large Scale Code Repos (Qodo)
 * - RAG Comprehensive Survey (arXiv 2506.00054)
 */
import { EventEmitter } from "events";
import { CodeChunk, RetrievalResult, QueryFilters, RAGConfig, IndexStats, FileIndexResult } from "./types.js";
import { RerankerStats } from "../cross-encoder-reranker.js";
/**
 * Main Codebase RAG class
 */
export declare class CodebaseRAG extends EventEmitter {
    private config;
    private chunker;
    private embedder;
    private vectorStore;
    private chunkStore;
    private fileIndex;
    private indexStats;
    private isIndexing;
    private rerankingLatencyHistogram;
    private lastRerankingStats;
    constructor(config?: Partial<RAGConfig>);
    /**
     * Initialize reranking latency metrics histogram
     */
    private initializeRerankingMetrics;
    /**
     * Index an entire codebase
     */
    indexCodebase(rootPath: string, options?: {
        includePatterns?: string[];
        excludePatterns?: string[];
        onProgress?: (current: number, total: number, file: string) => void;
    }): Promise<IndexStats>;
    /**
     * Index a single file
     */
    indexFile(filePath: string): Promise<FileIndexResult>;
    /**
     * Retrieve relevant code chunks for a query
     */
    retrieve(query: string, options?: {
        topK?: number;
        minScore?: number;
        filters?: QueryFilters;
        strategy?: "semantic" | "keyword" | "hybrid" | "reranked" | "corrective";
    }): Promise<RetrievalResult>;
    /**
     * Semantic search using embeddings
     */
    private semanticSearch;
    /**
     * Keyword-based search
     */
    private keywordSearch;
    /**
     * Hybrid search combining semantic and keyword
     */
    private hybridSearch;
    /**
     * Reranked search with cross-encoder scoring
     *
     * This method implements a two-stage retrieval process:
     * 1. Fast bi-encoder retrieval via hybrid search (top-20 candidates)
     * 2. Cross-encoder reranking for improved relevance (top-5 results)
     *
     * The cross-encoder jointly encodes query and document for more accurate
     * relevance scoring compared to independent embedding similarity.
     *
     * Research basis:
     * - "Sentence-BERT" (Reimers & Gurevych, 2019): Cross-encoder architecture
     * - Expected 25-35% improvement in retrieval quality
     */
    private rerankedSearch;
    /**
     * Calculate average score improvement from reranking
     */
    private calculateScoreImprovement;
    /**
     * Get the last reranking statistics
     */
    getLastRerankingStats(): RerankerStats | null;
    /**
     * Corrective RAG search
     * Evaluates relevance and refines query if needed
     */
    private correctiveSearch;
    /**
     * Evaluate relevance of retrieved chunks
     */
    private evaluateRelevance;
    /**
     * Expand query with related terms
     */
    private expandQuery;
    /**
     * Classify query intent
     */
    private classifyQueryIntent;
    /**
     * Prepare text for embedding (combines metadata with content)
     */
    private prepareTextForEmbedding;
    /**
     * Build filter object from QueryFilters
     */
    private buildFilter;
    /**
     * Check if chunk matches filter
     */
    private matchesFilter;
    /**
     * Find text highlights
     */
    private findHighlights;
    /**
     * Remove chunks for a file
     */
    private removeFileChunks;
    /**
     * Find files to index
     */
    private findFiles;
    /**
     * Check if path matches any pattern
     */
    private matchesPatterns;
    /**
     * Simple glob pattern matching
     */
    private matchesPattern;
    /**
     * Check if content appears to be binary
     */
    private isBinaryContent;
    /**
     * Tokenize text
     */
    private tokenize;
    /**
     * Estimate token count
     */
    private estimateTokens;
    /**
     * Save index to disk
     */
    saveIndex(): Promise<void>;
    /**
     * Load index from disk
     */
    loadIndex(): Promise<boolean>;
    /**
     * Get index statistics
     */
    getStats(): IndexStats;
    /**
     * Get a chunk by ID
     */
    getChunk(id: string): CodeChunk | undefined;
    /**
     * Get chunks for a file
     */
    getFileChunks(filePath: string): CodeChunk[];
    /**
     * Clear the index
     */
    clear(): Promise<void>;
    /**
     * Dispose resources
     */
    dispose(): Promise<void>;
}
/**
 * Create a CodebaseRAG instance
 */
export declare function createCodebaseRAG(config?: Partial<RAGConfig>): CodebaseRAG;
export declare function getCodebaseRAG(config?: Partial<RAGConfig>): CodebaseRAG;
export declare function resetCodebaseRAG(): void;
