/** * Codebase mapping tool implementation * * Implements the scampi_map_codebase MCP tool which: * 1. Walks the directory with ignore patterns * 2. Loads or creates cache * 3. Detects changed files (added, modified, deleted) * 4. Summarizes new/modified files using the flash model * 5. Updates cache with new summaries * 6. Returns mapping statistics */ import { type ProgressCallback } from "../../llm/pool.js"; /** * Options for the mapCodebase function */ export interface MapCodebaseOptions { /** * Force full rescan, ignoring cache * @default false */ forceRescan?: boolean; /** * Maximum number of files to summarize in a single run * Useful for large codebases to avoid long-running operations * @default 0 (no limit) */ maxFilesToSummarize?: number; /** * Custom concurrency limit (overrides config) * @default config.concurrency */ concurrency?: number; /** Progress callback for reporting mapping progress */ onProgress?: ProgressCallback; } /** * Result of the mapCodebase operation */ export interface MapCodebaseResult { /** Total number of files scanned (matching extensions and not ignored) */ files_scanned: number; /** Number of files with cached summaries (unchanged since last scan) */ files_cached: number; /** Human-readable summary of the operation */ summary: string; /** Number of files that were newly summarized */ files_summarized?: number; /** Number of files removed from cache (deleted from disk) */ files_removed?: number; /** Number of files that failed to summarize */ files_failed?: number; /** Error messages from failed summarizations (first few unique errors) */ errors?: string[]; } /** * Error thrown when mapping fails due to configuration issues */ export declare class MapCodebaseError extends Error { readonly code: string; constructor(message: string, code: string); } /** * Map a codebase directory, building or updating the cache * * This is the main implementation for the scampi_map_codebase MCP tool. * It performs the following steps: * * 1. Load configuration and create LLM client * 2. Walk the directory with extension filtering * 3. Apply ignore patterns from .scampiignore * 4. Load or create the cache * 5. Detect changed files (added, modified, deleted) * 6. Summarize new/modified files using the flash model * 7. Update cache with new summaries * 8. Save cache to disk * 9. Return statistics * * @param directory - Absolute path to the directory to map * @param options - Optional configuration for the mapping operation * @returns Promise resolving to MapCodebaseResult * @throws MapCodebaseError if configuration is missing or invalid * * @example * ```typescript * const result = await mapCodebase('/path/to/project'); * console.log(result.summary); * // "Scanned 42 files, 35 from cache, 7 newly summarized" * ``` * * @example * ```typescript * // Force full rescan * const result = await mapCodebase('/path/to/project', { * forceRescan: true, * maxFilesToSummarize: 50, * }); * ``` */ export declare function mapCodebase(directory: string, options?: MapCodebaseOptions): Promise; //# sourceMappingURL=map.d.ts.map