/** * RAGgrep - Local filesystem-based RAG system for codebases * * Provides semantic search over code using local embeddings. * * @example * ```ts * import raggrep from 'raggrep'; * * // Index a directory (automatically cleans up deleted files) * await raggrep.index('/path/to/project'); * * // Search the index * const results = await raggrep.search('/path/to/project', 'user authentication'); * * // Reset (clear) the index completely * await raggrep.reset('/path/to/project'); * ``` * * @example With custom logger * ```ts * import raggrep, { createLogger, createInlineLogger } from 'raggrep'; * * // Create a logger (defaults to console) * const logger = createLogger({ verbose: true }); * * // Or use inline logger for CLI-style progress * const inlineLogger = createInlineLogger({ verbose: false }); * * await raggrep.index('/path/to/project', { logger: inlineLogger }); * ``` */ import type { IndexResult, IndexOptions, CleanupResult, CleanupOptions, ResetResult } from "./app/indexer"; import { formatSearchResults, formatHybridSearchResults } from "./app/search"; import type { SearchOptions, SearchResult, HybridSearchResults } from "./types"; import { ConsoleLogger, InlineProgressLogger, SilentLogger, createLogger, createInlineLogger, createSilentLogger } from "./infrastructure/logger"; export type { IndexResult, IndexOptions, CleanupResult, CleanupOptions, ResetResult, } from "./app/indexer"; export type { SearchOptions, SearchResult, HybridSearchResults, RankBy, Chunk, FileIndex, RankingWeightsPartial, RankingWeightsConfig, LiteralBoostWeights, } from "./types"; export type { Logger, LoggerFactory } from "./domain/ports"; export { mergeRankingWeights, mergeLiteralWeights, DEFAULT_RANKING_WEIGHTS, DEFAULT_LITERAL_BOOST_WEIGHTS, } from "./domain/entities"; export { ConsoleLogger, InlineProgressLogger, SilentLogger, createLogger, createInlineLogger, createSilentLogger, }; /** * Index a directory for semantic search. * * Creates a `.raggrep/` folder with the index data. * Automatically cleans up stale entries for deleted files. * * @param directory - Path to the directory to index * @param options - Index options * @returns Array of results per module * * @example * ```ts * // Basic indexing * await raggrep.index('./my-project'); * * // With options * await raggrep.index('./my-project', { * model: 'bge-small-en-v1.5', * verbose: true * }); * ``` */ export declare function index(directory: string, options?: IndexOptions): Promise; /** * Search the indexed codebase. * * @param directory - Path to the indexed directory * @param query - Natural language search query * @param options - Search options * @returns Array of search results sorted by relevance * * @example * ```ts * // Basic search * const results = await raggrep.search('./my-project', 'user login'); * * // With options * const results = await raggrep.search('./my-project', 'database query', { * topK: 5, * minScore: 0.2, * filePatterns: ['*.ts'] * }); * ``` */ export declare function search(directory: string, query: string, options?: SearchOptions): Promise; /** * Clean up stale index entries for files that no longer exist. * * Note: Cleanup is now automatic during indexing. This function is provided * for explicit cleanup without re-indexing. * * @param directory - Path to the indexed directory * @param options - Cleanup options * @returns Array of cleanup results per module * * @example * ```ts * const results = await raggrep.cleanup('./my-project'); * console.log(`Removed ${results[0].removed} stale entries`); * ``` */ export declare function cleanup(directory: string, options?: CleanupOptions): Promise; /** * Reset (completely clear) the index for a directory. * * @param directory - Path to the indexed directory * @returns Result with success status and removed index path * @throws Error if no index exists for the directory * * @example * ```ts * try { * const result = await raggrep.reset('./my-project'); * console.log(`Cleared index at: ${result.indexDir}`); * } catch (error) { * console.error('No index found'); * } * ``` */ export declare function reset(directory: string): Promise; /** * Hybrid search with both semantic and exact match tracks. * * Returns semantic results with optional exact match results for identifier queries. * Exact matches are found using grep-like text search and are displayed separately. * * @param directory - Path to the indexed directory * @param query - Natural language or identifier search query * @param options - Search options * @returns Hybrid search results with both tracks * * @example * ```ts * // Search for an identifier (triggers exact match) * const results = await raggrep.hybridSearch('./my-project', 'AUTH_SERVICE_URL'); * * // Check for exact matches * if (results.exactMatches) { * console.log(`Found ${results.exactMatches.totalMatches} exact matches`); * } * * // Semantic results (with fusion boost if exact matches found) * console.log(`${results.results.length} semantic results`); * ``` */ export declare function hybridSearch(directory: string, query: string, options?: SearchOptions): Promise; /** * Format search results for display. * * @param results - Array of search results * @returns Formatted string for console output */ export { formatSearchResults }; /** * Format hybrid search results including exact matches. * * @param results - Hybrid search results * @returns Formatted string for console output */ export { formatHybridSearchResults }; declare const raggrep: { index: typeof index; search: typeof search; hybridSearch: typeof hybridSearch; cleanup: typeof cleanup; reset: typeof reset; formatSearchResults: typeof formatSearchResults; formatHybridSearchResults: typeof formatHybridSearchResults; }; export default raggrep;