@wildcard-ai/deepcontext
Version:
Advanced codebase indexing and semantic search MCP server
100 lines • 2.87 kB
TypeScript
/**
* Semantic Sub-Chunker
* Intelligently splits large code chunks while preserving semantic structure,
* imports/exports, symbols, and maintaining searchable context.
*/
import { SymbolInfo } from '../types/core.js';
import { ConfigurationService } from './ConfigurationService.js';
export interface CodeChunk {
id: string;
content: string;
filePath: string;
relativePath: string;
startLine: number;
endLine: number;
language: string;
symbols: SymbolInfo[];
imports: Array<{
module: string;
symbols: string[];
line: number;
}>;
}
export interface SubChunkContext {
fileHeader: string;
globalContext: string;
localContext: string;
}
export interface SemanticSection {
content: string;
type: 'header' | 'import' | 'export' | 'class' | 'function' | 'interface' | 'comment' | 'other';
startLine: number;
endLine: number;
symbols: SymbolInfo[];
dependencies: string[];
priority: number;
}
export declare class SemanticSubChunker {
private configurationService;
private logger;
private readonly MIN_OVERLAP_SIZE;
private readonly CONTEXT_WINDOW;
constructor(configurationService: ConfigurationService);
/**
* Main entry point: Split a large chunk into semantic sub-chunks
*/
splitLargeChunk(chunk: CodeChunk): Promise<CodeChunk[]>;
/**
* Parse content into semantic sections with metadata
*/
private parseSemanticSections;
/**
* Detect what type of semantic section a line represents
*/
private detectSectionType;
/**
* Check if this is a natural boundary for section splitting
*/
private isNaturalBoundary;
/**
* Create a semantic section with metadata
*/
private createSemanticSection;
/**
* Assign priority scores to different section types
*/
private getSectionPriority;
/**
* Extract dependencies from content (imports, function calls, etc.)
*/
private extractDependencies;
/**
* Extract global context that should be preserved across all sub-chunks
*/
private extractGlobalContext;
/**
* Create sub-chunks with preserved context and semantic integrity
*/
private createSubChunksWithContext;
/**
* Create overlap context to maintain semantic continuity
*/
private createOverlapContext;
/**
* Create a single sub-chunk with full context
*/
private createSubChunk;
/**
* Validate that sub-chunks maintain semantic quality
*/
validateSubChunks(subChunks: CodeChunk[]): Promise<{
isValid: boolean;
issues: string[];
metrics: {
totalSymbols: number;
averageSize: number;
contextPreservation: number;
};
}>;
}
//# sourceMappingURL=SemanticSubChunker.d.ts.map