@opichi/smartcode
Version:
Universal code intelligence MCP server - analyze any codebase with TypeScript excellence and multi-language support
160 lines • 3.74 kB
TypeScript
/**
* Code Indexer - Builds and caches project "table of contents"
* Provides AI with instant overview of all important code structures
*/
export interface CodeIndex {
lastUpdated: string;
projectPath: string;
routes: RouteInfo[];
functions: FunctionInfo[];
types: TypeInfo[];
components: ComponentInfo[];
constants: ConstantInfo[];
exports: ExportInfo[];
}
export interface RouteInfo {
method: string;
path: string;
handler: string;
file: string;
line: number;
middleware?: string[];
}
export interface FunctionInfo {
name: string;
file: string;
line: number;
signature: string;
isExported: boolean;
isAsync: boolean;
documentation?: string;
}
export interface TypeInfo {
name: string;
file: string;
line: number;
kind: 'interface' | 'type' | 'enum' | 'class';
isExported: boolean;
documentation?: string;
properties?: string[];
}
export interface ComponentInfo {
name: string;
file: string;
line: number;
props?: string[];
isExported: boolean;
documentation?: string;
}
export interface ConstantInfo {
name: string;
file: string;
line: number;
value?: string;
type?: string;
isExported: boolean;
}
export interface ExportInfo {
name: string;
file: string;
line: number;
kind: string;
isDefault: boolean;
}
export declare class CodeIndexer {
private projectRoot;
private cacheDir;
private indexFile;
private isProcessing;
private requestQueue;
constructor(projectRoot: string);
/**
* Get the code index, building it if necessary
*/
getIndex(): Promise<CodeIndex>;
/**
* Force rebuild the index
*/
rebuildIndex(): Promise<CodeIndex>;
/**
* Concurrency protection wrapper
*/
private withLock;
/**
* Process queued requests
*/
private processQueue;
/**
* Get lightweight project overview
*/
getProjectOverview(): Promise<{
summary: string;
structure: string[];
keyFiles: string[];
entryPoints: string[];
stats: {
functions: number;
types: number;
components: number;
routes: number;
constants: number;
};
}>;
/**
* Get functions in a specific file
*/
getFunctionsByFile(filePath: string): Promise<FunctionInfo[]>;
/**
* Get types matching a pattern
*/
getTypesByPattern(pattern: string): Promise<TypeInfo[]>;
/**
* Search functions by name or documentation
*/
searchFunctions(query: string): Promise<FunctionInfo[]>;
/**
* Get components by file or name pattern
*/
getComponentsByPattern(pattern: string): Promise<ComponentInfo[]>;
/**
* Get routes by method or path pattern
*/
getRoutesByPattern(pattern: string): Promise<RouteInfo[]>;
/**
* Load cached index from disk
*/
private loadCachedIndex;
/**
* Check if cached index is still fresh
*/
private isCacheFresh;
/**
* Build complete code index
*/
private buildIndex;
/**
* Extract information from file structure
*/
private extractFromStructure;
/**
* Extract API routes from code patterns
*/
private extractRoutes;
/**
* Extract handler function name from route code
*/
private extractHandlerName;
/**
* Build function signature string
*/
private buildFunctionSignature;
/**
* Find all source files to analyze
*/
private findSourceFiles;
/**
* Save index to cache
*/
private saveIndex;
}
//# sourceMappingURL=indexer.d.ts.map