UNPKG

code-auditor-mcp

Version:

Multi-language code quality auditor with MCP server - Analyze TypeScript, JavaScript, and Go code for SOLID principles, DRY violations, security patterns, and more

181 lines 4.96 kB
/** * Language Orchestrator * Coordinates multiple language analyzers and merges results */ import { RuntimeManager } from './RuntimeManager.js'; import { CodeIndexDB } from '../codeIndexDB.js'; import { Violation } from '../types.js'; export interface PolyglotAnalysisOptions { languages?: string[]; autoDetect?: boolean; analyzers?: string[]; minSeverity?: 'info' | 'warning' | 'critical'; enableCrossLanguageAnalysis?: boolean; buildCrossReferences?: boolean; validateAPIContracts?: boolean; maxConcurrency?: number; timeout?: number; updateIndex?: boolean; indexFunctions?: boolean; includeMetrics?: boolean; generateDependencyGraph?: boolean; } export interface PolyglotAnalysisResult { violations: Violation[]; errors: any[]; crossLanguageViolations: CrossLanguageViolation[]; dependencyGraph?: DependencyGraph; apiContracts?: APIContractAnalysis[]; metrics: PolyglotMetrics; languageStats: Map<string, LanguageStats>; indexEntries?: any[]; crossReferences?: CrossReference[]; } export interface CrossLanguageViolation extends Violation { crossLanguageType: 'api-mismatch' | 'type-mismatch' | 'contract-violation' | 'unused-export'; relatedFiles: string[]; relatedLanguages: string[]; } export interface DependencyGraph { nodes: DependencyNode[]; edges: DependencyEdge[]; cycles?: DependencyCycle[]; metrics?: DependencyMetrics; } export interface DependencyNode { id: string; name: string; language: string; type: string; file: string; weight?: number; cluster?: string; } export interface DependencyEdge { from: string; to: string; type: string; protocol?: string; weight?: number; } export interface DependencyCycle { nodes: string[]; severity: 'warning' | 'critical'; suggestion?: string; } export interface DependencyMetrics { totalNodes: number; totalEdges: number; cycleCount: number; averageDepth: number; maxDepth: number; stronglyConnectedComponents: number; } export interface APIContractAnalysis { endpoint: string; method: string; frontendUsage: any[]; backendImplementation: any; mismatches: string[]; } export interface PolyglotMetrics { totalFiles: number; totalViolations: number; languagesAnalyzed: string[]; executionTime: number; crossLanguageReferences: number; apiContractsChecked: number; } export interface LanguageStats { filesAnalyzed: number; violations: number; functions: number; classes: number; interfaces: number; executionTime: number; } export interface CrossReference { sourceId: string; targetId: string; type: 'calls' | 'implements' | 'api-call'; sourceLanguage: string; targetLanguage: string; confidence: number; } export declare class LanguageOrchestrator { private runtimeManager; private codeIndex; constructor(runtimeManager: RuntimeManager, codeIndex: CodeIndexDB); /** * Analyze a polyglot project */ analyzePolyglotProject(projectPath: string, options?: PolyglotAnalysisOptions): Promise<PolyglotAnalysisResult>; /** * Discover files and group by language */ private discoverAndGroupFiles; /** * Detect programming language from file extension */ private detectLanguage; /** * Select which languages to analyze based on options and availability */ private selectLanguages; /** * Map language names to runtime names */ private mapLanguageToRuntime; /** * Analyze files for a specific language */ private analyzeLanguage; /** * Merge results from multiple language analyses */ private mergeLanguageResults; /** * Build cross-references between languages */ private buildCrossReferences; /** * Detect violations that span multiple languages */ private detectCrossLanguageViolations; /** * Validate API contracts between frontend and backend */ private validateAPIContracts; /** * Generate dependency graph across languages */ private generateDependencyGraph; /** * Update the unified code index */ private updateCodeIndex; /** * Get orchestrator statistics */ getStats(): { runtimes: { total: number; available: number; withAnalyzers: number; runtimes: { [k: string]: { available: boolean; version: string; hasAnalyzer: boolean; }; }; }; capabilities: { crossLanguageAnalysis: boolean; apiContractValidation: boolean; dependencyGraphGeneration: boolean; unifiedIndexing: boolean; }; }; } //# sourceMappingURL=LanguageOrchestrator.d.ts.map