@knath2000/codebase-indexing-mcp
Version:
MCP server for codebase indexing with Voyage AI embeddings and Qdrant vector storage
76 lines (75 loc) • 2.34 kB
TypeScript
import { SearchResult, CodeReference, ContextWindow, TokenBudget, Config } from '../types.js';
export declare class ContextManagerService {
private tokenBudget;
constructor(config: Config);
/**
* Convert search results to Cursor-style code references with token budgeting
*/
formatAsCodeReferences(results: SearchResult[], maxTokens?: number): {
references: CodeReference[];
contextWindow: ContextWindow;
truncated: boolean;
};
/**
* Group consecutive chunks from the same file to reduce UI clutter
*/
private groupConsecutiveChunks;
/**
* Determine if two chunks should be grouped together
*/
private shouldGroupChunks;
/**
* Create a Cursor-style code reference from a group of chunks
*/
private createCodeReference;
/**
* Combine snippets from multiple chunks with proper formatting
*/
private combineSnippets;
/**
* Estimate token count for a text snippet
* This is a rough approximation - in production, use a proper tokenizer
*/
private estimateTokens;
/**
* Generate a summary when results are truncated
*/
private generateTruncationSummary;
/**
* Boost results based on file metadata (recently modified, currently open)
*/
boostResultsByMetadata(results: SearchResult[]): SearchResult[];
/**
* Filter and prioritize results for optimal context usage
*/
optimizeForContext(results: SearchResult[], _query: string, preferences?: {
preferFunctions?: boolean;
preferClasses?: boolean;
maxFilesPerType?: number;
diversifyLanguages?: boolean;
}): SearchResult[];
/**
* Boost results of a specific chunk type
*/
private boostByChunkType;
/**
* Diversify results by language to provide broader context
*/
private diversifyByLanguage;
/**
* Limit the number of results per file to avoid overwhelming from a single file
*/
private limitPerFileType;
/**
* Get current token budget status
*/
getTokenBudget(): TokenBudget;
/**
* Update the token budget based on usage
*/
updateTokenUsage(usedTokens: number): void;
/**
* Reset the token budget for a new context window
*/
resetTokenBudget(): void;
}