/** * AI Enhancer Module * Uses AI to analyze the codebase for deeper insights */ import type { ScanResult } from '../scanner/types.js'; import { type AIProvider } from './providers.js'; import { type ProgressCallback, type ToolCallCallback } from './agents/index.js'; /** * Project context from AI analysis - key structure information */ export interface ProjectContext { /** Key entry point files */ entryPoints?: string[]; /** Important directories and their purposes */ keyDirectories?: Record; /** Naming conventions used in the project */ namingConventions?: string; } /** * Detected commands from package.json scripts or common patterns */ export interface DetectedCommands { test?: string; lint?: string; typecheck?: string; build?: string; dev?: string; format?: string; } /** * MCP server recommendations (categorized) */ export interface McpRecommendations { /** Essential MCP servers for this stack */ essential?: string[]; /** Recommended but optional MCP servers */ recommended?: string[]; } /** * Technology-specific testing and debugging tools */ export interface TechnologyTools { /** Testing commands specific to the detected technologies */ testing?: string[]; /** Debugging/inspection tools for the stack */ debugging?: string[]; /** Linting/validation tools beyond the standard ones */ validation?: string[]; } /** * Technology-specific best practices */ export interface TechnologyPractices { /** The primary project type (e.g., "MCP Server", "REST API", "React SPA") */ projectType?: string; /** Practices specific to the detected technologies */ practices?: string[]; /** Anti-patterns to avoid for this stack */ antiPatterns?: string[]; /** Links to relevant documentation (optional) */ documentationHints?: string[]; } /** * E2E testing tools recommendation * Distinguishes between MCP servers (like playwright) and standalone tools (like MCP Inspector) */ export interface E2ETools { /** The tool or MCP server name */ tool: string; /** How to run/invoke the tool */ command: string; /** Brief description of what it does */ description: string; /** Whether this is an MCP server or a standalone tool */ isMcpServer: boolean; } /** * AI analysis result - focused on actionable outputs */ export interface AIAnalysisResult { /** Project structure and context */ projectContext?: ProjectContext; /** Detected commands from package.json */ commands?: DetectedCommands; /** Short, actionable implementation guidelines */ implementationGuidelines?: string[]; /** MCP server recommendations (database, deployment, etc.) */ mcpServers?: McpRecommendations; /** E2E testing tools (playwright MCP or MCP Inspector) */ e2eTools?: E2ETools; /** Additional technologies that may have been missed */ possibleMissedTechnologies?: string[]; /** Technology-specific tools for testing/debugging */ technologyTools?: TechnologyTools; /** Technology-specific best practices based on detected stack */ technologyPractices?: TechnologyPractices; /** Technology notes captured during codebase analysis (optional) */ technologyNotes?: { testingApproach?: string; buildSystem?: string; keyPatterns?: string[]; }; } /** * Token usage from AI calls */ export interface TokenUsage { inputTokens: number; outputTokens: number; totalTokens: number; } /** * Enhanced scan result with AI insights */ export interface EnhancedScanResult extends ScanResult { aiAnalysis?: AIAnalysisResult; aiEnhanced: boolean; aiProvider?: AIProvider; aiError?: string; /** Token usage from AI analysis */ tokenUsage?: TokenUsage; } /** * Options for the AI enhancer */ export interface EnhancerOptions { provider?: AIProvider; model?: string; verbose?: boolean; /** Use agentic mode with tools for deeper codebase exploration */ agentic?: boolean; /** Tavily API key for web search (optional) */ tavilyApiKey?: string; /** Context7 API key for documentation lookup (optional) */ context7ApiKey?: string; /** Progress callback for phase updates */ onProgress?: ProgressCallback; /** Tool call callback for tracking agent actions */ onToolCall?: ToolCallCallback; } /** * AI Enhancer class * Provides AI-powered analysis to enhance scan results */ export declare class AIEnhancer { private provider; private model?; private verbose; private agentic; private tavilyApiKey?; private context7ApiKey?; private onProgress?; private onToolCall?; constructor(options?: EnhancerOptions); /** * Check if AI enhancement is available */ isAvailable(): boolean; /** * Get the required environment variable for the current provider */ getRequiredEnvVar(): string; /** * Enhance scan results with AI analysis */ enhance(scanResult: ScanResult): Promise; /** * Simple enhancement mode - analyze detected stack without tools */ private enhanceSimple; /** * Agentic enhancement mode - use multi-agent system to explore codebase */ private enhanceAgentic; /** * Legacy agentic mode (fallback when multi-agent fails) */ private enhanceLegacyAgentic; } /** * Convenience function to enhance scan results with AI */ export declare function enhanceWithAI(scanResult: ScanResult, options?: EnhancerOptions): Promise; /** * Format AI analysis result for display */ export declare function formatAIAnalysis(analysis: AIAnalysisResult): string;