/** * Enriches code chunks with metadata context before embedding * Improves search relevance by giving embedding model more semantic information */ import type { CodeBlock } from '../types/models.js'; export interface EnrichmentOptions { includeFilePath?: boolean; includeBlockType?: boolean; includeBlockName?: boolean; includeComments?: boolean; format?: 'compact' | 'descriptive' | 'structured'; } /** * Enriches code blocks with contextual metadata for better embeddings */ export declare class EmbeddingEnricher { private readonly defaultOptions; /** * Enrich a code block with metadata context * Returns text that will be embedded instead of raw code */ enrich(block: CodeBlock, options?: EnrichmentOptions): string; /** * Compact format: Brief metadata prefix + code * Example: "file.ts|function:doSomething| " */ private enrichCompact; /** * Descriptive format: Natural language description + code * Example: "This is a function called 'doSomething' in file.ts:\n" */ private enrichDescriptive; /** * Structured format: Clear sections for metadata and code * Example: * File: src/utils/file.ts * Type: function * Name: readFile * --- * */ private enrichStructured; /** * Build a natural language description of the code block */ private buildDescription; /** * Get meaningful file context (path + filename) * Extracts semantic information from path */ private getFileContext; /** * Clean comment text for embedding */ private cleanComments; /** * Get appropriate article for a word * Note: Simple heuristic based on first letter; edge cases like "hour", "utility" may be incorrect */ private getArticle; /** * Batch enrich multiple blocks * Note: Processes all blocks in memory sequentially. For very large batches (>10,000 blocks), * consider processing in smaller chunks to avoid memory issues. */ enrichBatch(blocks: CodeBlock[], options?: EnrichmentOptions): string[]; } export declare const embeddingEnricher: EmbeddingEnricher; //# sourceMappingURL=embedding-enricher.d.ts.map