@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
126 lines (125 loc) • 3.91 kB
TypeScript
/**
* @fileoverview Semantic analysis integration layer
*
* This module provides the main entry point for TreeSitter-based semantic
* code analysis, exposing a unified API for intelligent chunking and
* context-aware code review processing.
*/
export * from './types';
import { SemanticAnalysisResult, ChunkingRecommendation } from './types';
export { SemanticAnalyzer, semanticAnalyzer, analyzeCodeSemantics } from './SemanticAnalyzer';
export { ChunkGenerator, chunkGenerator, generateSemanticChunks } from './ChunkGenerator';
export { SemanticChunkingIntegration } from './SemanticChunkingIntegration';
export { AiGuidedChunking, aiGuidedChunking } from './AiGuidedChunking';
import { SemanticAnalysisConfig } from './types';
/**
* Configuration for the integrated semantic analysis system
*/
export interface SemanticAnalysisSystemConfig {
/** Semantic analyzer configuration */
analyzer?: Partial<SemanticAnalysisConfig>;
/** Chunk generator configuration */
chunkGenerator?: {
maxChunkSize?: number;
minChunkSize?: number;
includeContext?: boolean;
maxContextDeclarations?: number;
tokensPerLine?: number;
highComplexityThreshold?: number;
mediumComplexityThreshold?: number;
};
/** Whether to enable fallback to line-based chunking */
enableFallback?: boolean;
/** Whether to cache analysis results */
enableCaching?: boolean;
}
/**
* Extended result that includes chunking information
*/
export interface SemanticAnalysisSystemResult extends SemanticAnalysisResult {
chunking?: ChunkingRecommendation;
metadata?: {
filePath: string;
language: string;
reviewType: string;
analyzedAt: Date;
fallbackReason?: string;
};
}
/**
* Integrated semantic analysis system
*/
export declare class SemanticAnalysisSystem {
private analyzer;
private chunkGenerator;
private config;
private cache;
constructor(config?: SemanticAnalysisSystemConfig);
/**
* Perform complete semantic analysis and generate intelligent chunks
*/
analyzeAndChunk(content: string, filePath: string, options?: {
language?: string;
reviewType?: string;
useCache?: boolean;
}): Promise<SemanticAnalysisSystemResult>;
/**
* Generate fallback result when semantic analysis fails
*/
private generateFallbackResult;
/**
* Get default review focus for a review type
*/
private getDefaultReviewFocus;
/**
* Generate cache key for analysis results
*/
private generateCacheKey;
/**
* Simple hash function for cache keys
*/
private simpleHash;
/**
* Clear analysis cache
*/
clearCache(): void;
/**
* Get cache statistics
*/
getCacheStats(): {
size: number;
enabled: boolean;
};
/**
* Update system configuration
*/
updateConfig(config: Partial<SemanticAnalysisSystemConfig>): void;
/**
* Get supported languages
*/
getSupportedLanguages(): string[];
/**
* Check if a language is supported
*/
isLanguageSupported(language: string): boolean;
}
/**
* Default semantic analysis system instance
*/
export declare const semanticAnalysisSystem: SemanticAnalysisSystem;
/**
* Convenience function for complete semantic analysis and chunking
*/
export declare function analyzeAndChunkCode(content: string, filePath: string, options?: {
language?: string;
reviewType?: string;
useCache?: boolean;
}): Promise<SemanticAnalysisSystemResult>;
/**
* Convenience function to check if semantic analysis is available for a file
*/
export declare function canAnalyzeFile(filePath: string): boolean;
/**
* Convenience function to detect language from file path
*/
export declare function detectLanguageFromPath(filePath: string): string | null;