UNPKG

remcode

Version:

Turn your AI assistant into a codebase expert. Intelligent code analysis, semantic search, and software engineering guidance through MCP integration.

110 lines (109 loc) 3.16 kB
export interface CodeContext { targetContent: string; surroundingLines: string[]; relatedFunctions: string[]; imports: string[]; classContext?: string; moduleContext?: string; fileStructure?: FileStructure; } export interface FileStructure { classes: ClassInfo[]; functions: FunctionInfo[]; exports: string[]; imports: ImportInfo[]; } export interface ClassInfo { name: string; methods: FunctionInfo[]; properties: string[]; startLine: number; endLine: number; } export interface FunctionInfo { name: string; params: string[]; startLine: number; endLine: number; isMethod: boolean; parentClass?: string; } export interface ImportInfo { source: string; imported: string[]; startLine: number; } export declare class ContextExtractor { /** * Extract code context from a file based on line range * @param filePath Path to the source file * @param startLine Starting line number (0-indexed) * @param endLine Ending line number (0-indexed) * @returns Extracted code context */ extractContext(filePath: string, startLine: number, endLine: number): Promise<CodeContext>; /** * Parse a file and extract its structure (classes, functions, imports, exports) * @param filePath Path to the source file * @returns Structured representation of the file */ getFileStructure(filePath: string): Promise<FileStructure>; /** * Parse TypeScript/JavaScript files to extract their structure * @param content File content * @param isJsx Whether the file contains JSX * @returns Structured representation of the file */ private parseTypescript; /** * Parse non-JS/TS files for a simplified structure * @param content File content * @returns Basic file structure */ private parseGenericFile; /** * Traverse the AST to extract code structure * @param ast AST node to process * @param structure Structure being built */ private traverseAst; /** * Process an import declaration node * @param node Import node * @param imports Collection of imports */ private processImport; /** * Process an export declaration node * @param node Export node * @param exports Collection of exports */ private processExport; /** * Process a class declaration node * @param node Class node * @param classes Collection of classes * @param functions Collection of functions */ private processClass; /** * Process a method definition * @param node Method node * @param className Parent class name * @param methods Collection of class methods * @param functions Collection of all functions */ private processMethod; /** * Process a function declaration * @param node Function node * @param functions Collection of functions */ private processFunction; /** * Extract function parameters * @param node Function node * @returns Array of parameter names */ private extractParams; }