/** * File Processor for Gemini RAG Service * * Handles file reading, chunking, glob pattern matching, * exclusion patterns, and metadata extraction. */ import { ChunkOptions, TextChunk } from './chunker'; /** * Options for file processing */ export interface FileProcessorOptions { /** Base directory for relative paths */ basePath?: string; /** Glob patterns to include - defaults to all files */ includePatterns?: string[]; /** Glob patterns to exclude */ excludePatterns?: string[]; /** Maximum file size in bytes - defaults to 10MB */ maxFileSize?: number; /** File extensions to process - defaults to common code and text files */ extensions?: string[]; /** Chunking options */ chunkOptions?: ChunkOptions; /** Extract code metadata such as language and imports */ extractMetadata?: boolean; } /** * Metadata extracted from a file */ export interface FileMetadata { /** Full file path */ filePath: string; /** File name */ fileName: string; /** File extension */ extension: string; /** File size in bytes */ size: number; /** Last modified timestamp */ lastModified: Date; /** Detected programming language */ language?: string; /** Relative path from base directory */ relativePath?: string; /** Number of lines */ lineCount?: number; /** Extracted imports/dependencies */ imports?: string[]; /** Extracted exports */ exports?: string[]; /** Custom metadata */ custom?: Record; } /** * Processed file chunk with metadata */ export interface ProcessedChunk extends TextChunk { /** Source file metadata */ fileMetadata: FileMetadata; /** Unique chunk identifier */ chunkId: string; } /** * Result of processing files */ export interface ProcessResult { /** All processed chunks */ chunks: ProcessedChunk[]; /** Files processed successfully */ filesProcessed: string[]; /** Files that failed to process */ filesFailed: Array<{ path: string; error: string; }>; /** Total chunks created */ totalChunks: number; /** Total tokens estimated */ totalTokens: number; /** Processing statistics */ stats: { totalFiles: number; successfulFiles: number; failedFiles: number; totalBytes: number; totalLines: number; averageChunksPerFile: number; }; } /** * File Processor class */ export declare class FileProcessor { private readonly options; private readonly chunker; constructor(options?: FileProcessorOptions); /** * Check if a path matches a glob pattern */ private matchesGlob; /** * Check if a file should be included based on patterns */ private shouldInclude; /** * Recursively discover files matching patterns */ discoverFiles(directory?: string): Promise; /** * Extract metadata from file content */ private extractMetadataFromContent; /** * Extract metadata from a file */ extractFileMetadata(filePath: string, content?: string): Promise; /** * Process a single file */ processFile(filePath: string): Promise; /** * Process multiple files */ processFiles(filePaths: string[]): Promise; /** * Process all files in a directory */ processDirectory(directory?: string): Promise; /** * Process files matching specific glob patterns */ processGlob(patterns: string[], basePath?: string): Promise; } /** * Create a file processor with default options */ export declare function createFileProcessor(options?: FileProcessorOptions): FileProcessor; //# sourceMappingURL=file-processor.d.ts.map