UNPKG

ai-debug-local-mcp

Version:

🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh

222 lines • 10.6 kB
/** * Smart Tool Deduplication - Preserve All Unique Tools * * This removes duplicate variants while preserving all unique base functionality. * Fixes the issue where we accidentally consolidated 273 unique tools down to 22. */ import { COMPLETE_TOOLS } from './complete-tool-discovery.js'; /** * Extract unique base tools by removing variants */ function getUniqueBaseTools() { const uniqueTools = new Map(); for (const tool of COMPLETE_TOOLS) { // Extract base name by removing variant suffixes const baseName = tool.name .replace(/_advanced$/, '') .replace(/_with_options$/, '') .replace(/_batch$/, '') .replace(/_async$/, '') .replace(/_enhanced$/, '') .replace(/_extended$/, '') .replace(/_pro$/, ''); // Skip if we already have this base tool if (uniqueTools.has(baseName)) { continue; } // Categorize tool based on name patterns const category = categorizeTools(baseName); // Create enhanced description const description = enhanceDescription(baseName, tool.description); // Add usage guidance const usageGuidance = createUsageGuidance(baseName, category); // Add context scoping const contexts = getContexts(baseName, category); const projectTypes = getProjectTypes(baseName, category); const smartTool = { name: baseName, description, inputSchema: tool.inputSchema, category, contexts, projectTypes, usageGuidance }; uniqueTools.set(baseName, smartTool); } return Array.from(uniqueTools.values()).sort((a, b) => a.name.localeCompare(b.name)); } /** * Categorize tools based on name patterns */ function categorizeTools(name) { if (name.includes('ai_')) return 'ai-powered'; if (name.includes('debug_')) return 'debugging'; if (name.includes('analyze_')) return 'analysis'; if (name.includes('test_')) return 'testing'; if (name.includes('monitor_')) return 'monitoring'; if (name.includes('audit_')) return 'quality-assurance'; if (name.includes('capture_') || name.includes('screenshot')) return 'visual'; if (name.includes('simulate_') || name.includes('interact_')) return 'automation'; if (name.includes('phoenix_') || name.includes('liveview_')) return 'phoenix'; if (name.includes('nextjs_') || name.includes('react_')) return 'nextjs-react'; if (name.includes('flutter_')) return 'flutter'; if (name.includes('vue_')) return 'vue'; if (name.includes('network_') || name.includes('api_')) return 'network'; if (name.includes('performance_')) return 'performance'; if (name.includes('security_')) return 'security'; if (name.includes('bundle_') || name.includes('build_')) return 'build-tools'; if (name.includes('database_') || name.includes('ecto_')) return 'database'; return 'general'; } /** * Create enhanced descriptions that are specific and actionable */ function enhanceDescription(name, originalDescription) { // Remove generic parts and make specific let enhanced = originalDescription .replace(/^[^-]*-\s*/, '') // Remove "tool name - " prefix .replace(/Advanced core tool with comprehensive debugging capabilities/, '') .replace(/debugging capabilities/, '') .trim(); // Add specific descriptions based on tool name const specificDescriptions = { // AI-powered tools 'ai_code_review': 'AI-powered code review - analyzes code quality, suggests improvements, detects potential bugs', 'ai_performance_insights': 'AI performance analysis - identifies bottlenecks, suggests optimizations, predicts scaling issues', 'ai_test_generation': 'AI test generation - creates comprehensive test suites based on code analysis and usage patterns', // Analysis tools 'analyze_bundle_size': 'Bundle size analysis - identifies large dependencies, suggests optimizations, tracks size over time', 'analyze_hydration': 'SSR hydration analysis - detects hydration mismatches, optimization opportunities in server-side rendered apps', 'analyze_javascript_errors': 'JavaScript error analysis - categorizes errors, tracks patterns, suggests fixes for common issues', 'analyze_performance': 'Performance analysis - Core Web Vitals, resource loading, runtime performance metrics with actionable insights', 'analyze_test_coverage': 'Test coverage analysis - identifies untested code paths, suggests critical areas for testing', // Framework-specific tools 'debug_phoenix_liveview': 'Phoenix LiveView debugging - inspect component state, events, websocket connections, and real-time updates', 'debug_nextjs_routing': 'Next.js routing debug - analyze route resolution, dynamic imports, middleware execution, and navigation issues', 'debug_flutter_web': 'Flutter Web debugging - widget tree inspection, performance profiling, platform-specific issues', 'debug_ecto_queries': 'Ecto query debugging - SQL generation analysis, N+1 detection, query optimization suggestions', // Visual tools 'capture_element_screenshot': 'Element screenshot capture - target specific DOM elements for visual regression testing and documentation', 'compare_visual_states': 'Visual state comparison - detect UI changes, regression testing, layout shift analysis', // Network tools 'debug_network': 'Network debugging - HTTP request/response analysis, CORS issues, API call optimization, timing analysis', 'debug_graphql_schema': 'GraphQL schema debugging - query analysis, resolver performance, schema validation and optimization', // Security tools 'check_accessibility': 'Accessibility audit - WCAG compliance testing, screen reader compatibility, keyboard navigation analysis', // Default fallback }; return specificDescriptions[name] || enhanced || `${name.replace(/_/g, ' ')} - specialized debugging and analysis tool`; } /** * Create usage guidance for each tool */ function createUsageGuidance(name, category) { const guidanceMap = { 'ai_code_review': { whenToUse: 'Code quality concerns, pre-commit reviews, refactoring validation', whenNotToUse: 'Simple syntax errors, runtime debugging, performance issues', commonMistakes: ['Using for runtime errors instead of static analysis', 'Expecting instant results on large codebases'], alternatives: ['static_code_analysis for faster checks', 'manual_code_review for sensitive code'] }, 'analyze_performance': { whenToUse: 'Slow page loads, poor Core Web Vitals, optimization planning', whenNotToUse: 'Network issues, server-side performance, database optimization', commonMistakes: ['Testing on unrealistic network conditions', 'Ignoring mobile performance'], alternatives: ['lighthouse_audit for quick checks', 'browser_profiler for detailed analysis'] }, 'debug_phoenix_liveview': { whenToUse: 'LiveView state issues, real-time update problems, websocket debugging', whenNotToUse: 'Static Phoenix pages, database issues, non-LiveView components', commonMistakes: ['Not checking websocket connection first', 'Confusing LiveView state with client state'], alternatives: ['debug_phoenix_controller for regular pages', 'inspect_websocket for connection issues'] } }; return guidanceMap[name] || { whenToUse: `Debugging and analyzing ${name.replace(/_/g, ' ')} related issues`, whenNotToUse: 'General debugging, unrelated framework issues', commonMistakes: ['Using without proper setup', 'Expecting immediate results'], alternatives: ['General debugging tools for broader issues'] }; } /** * Get contexts where this tool is appropriate */ function getContexts(name, category) { const contexts = []; if (category === 'phoenix') contexts.push('elixir', 'phoenix', 'liveview'); if (category === 'nextjs-react') contexts.push('react', 'nextjs', 'ssr'); if (category === 'flutter') contexts.push('flutter', 'dart', 'mobile-web'); if (category === 'vue') contexts.push('vue', 'spa'); if (category === 'testing') contexts.push('ci-cd', 'quality-assurance'); if (category === 'performance') contexts.push('optimization', 'production'); if (category === 'security') contexts.push('security-audit', 'compliance'); if (category === 'ai-powered') contexts.push('code-review', 'automation'); return contexts.length > 0 ? contexts : ['general']; } /** * Get project types where this tool is most useful */ function getProjectTypes(name, category) { const projectTypes = []; if (name.includes('phoenix')) projectTypes.push('phoenix', 'elixir'); if (name.includes('nextjs')) projectTypes.push('nextjs', 'react'); if (name.includes('flutter')) projectTypes.push('flutter', 'mobile'); if (name.includes('vue')) projectTypes.push('vue', 'spa'); if (name.includes('api') || name.includes('graphql')) projectTypes.push('api', 'backend'); if (category === 'testing') projectTypes.push('any'); if (category === 'performance') projectTypes.push('web-app', 'spa'); return projectTypes.length > 0 ? projectTypes : ['web-app']; } // Export the smart deduplicated tools export const SMART_DEDUPLICATED_TOOLS = getUniqueBaseTools(); export class SmartToolDiscovery { getAllTools() { return SMART_DEDUPLICATED_TOOLS; } getToolsByCategory(category) { return SMART_DEDUPLICATED_TOOLS.filter(tool => tool.category === category); } getToolsForProject(projectType) { return SMART_DEDUPLICATED_TOOLS.filter(tool => tool.projectTypes?.includes(projectType) || tool.projectTypes?.includes('any')); } getToolsForContext(context) { return SMART_DEDUPLICATED_TOOLS.filter(tool => tool.contexts?.includes(context) || tool.contexts?.includes('general')); } getToolCount() { return SMART_DEDUPLICATED_TOOLS.length; } } //# sourceMappingURL=smart-deduplication.js.map