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

317 lines (315 loc) โ€ข 17.3 kB
/** * Capability Discovery Handler * * Provides immediate understanding of AI-Debug's revolutionary capabilities * specifically designed for AI consumption and rapid capability recognition. */ import { BaseToolHandler } from './base-handler.js'; export class CapabilityDiscoveryHandler extends BaseToolHandler { tools = [ { name: 'discover_ai_debug_capabilities', description: '๐Ÿค– INSTANT AI CAPABILITY DISCOVERY: Get comprehensive overview of AI-Debug\'s revolutionary features, sub-agent orchestration, and maximum-value usage patterns. Essential first step for AI users.', inputSchema: { type: 'object', properties: { context: { type: 'string', description: 'Optional context about your debugging needs (performance, accessibility, errors, etc.)', enum: ['performance', 'accessibility', 'errors', 'testing', 'general'] }, urgency: { type: 'string', description: 'How quickly you need results', enum: ['urgent', 'normal', 'comprehensive'], default: 'normal' } } } }, { name: 'get_ai_workflow_templates', description: '๐Ÿ“‹ AI WORKFLOW TEMPLATES: Get ready-made debugging workflows optimized for AI usage. Immediate high-value patterns for common scenarios.', inputSchema: { type: 'object', properties: { scenario: { type: 'string', description: 'Debugging scenario type', enum: ['complete-audit', 'performance-investigation', 'accessibility-compliance', 'error-analysis', 'quick-health-check'] }, framework: { type: 'string', description: 'Target framework (auto-detected if not specified)', enum: ['auto', 'react', 'vue', 'angular', 'nextjs', 'flutter', 'phoenix', 'node', 'python'] } } } } ]; async handle(toolName, args) { switch (toolName) { case 'discover_ai_debug_capabilities': return this.discoverAiDebugCapabilities(args); case 'get_ai_workflow_templates': return this.getAiWorkflowTemplates(args); default: throw new Error(`Unknown capability discovery tool: ${toolName}`); } } async discoverAiDebugCapabilities(args) { const { context = 'general', urgency = 'normal' } = args; const capabilities = { revolutionaryFeatures: { subAgentOrchestration: { description: "๐Ÿค– 8 specialized Claude Code sub-agents with automatic delegation", benefit: "Context preservation + specialized expertise + comprehensive tool coverage", tokenSavings: "1000-10000+ tokens per session", toolCoverage: "90%+ of AI-Debug's 200+ tools accessible through sub-agents", coreAgents: [ "debug-discovery-agent: Initial setup & assessment (~1000 tokens saved)", "performance-analysis-agent: Core Web Vitals analysis (~2000 tokens saved)", "accessibility-audit-agent: WCAG compliance testing (~1500 tokens saved)", "error-investigation-agent: Root cause analysis (~1800 tokens saved)", "validation-testing-agent: Quality assurance (~1200 tokens saved)" ], specializedAgents: [ "framework-specialist-agent: Flutter/Next.js/Phoenix optimization (~2500 tokens saved)", "data-extraction-agent: Console/network/session intelligence (~1600 tokens saved)", "testing-infrastructure-agent: TDD workflows & mocking (~2200 tokens saved)" ] }, projectAwareOptimization: { description: "๐ŸŽฏ Intelligent framework detection with memory optimization", benefit: "4-8MB memory savings with zero workflow delay", frameworks: "19+ supported (Flutter, Next.js, Phoenix, React, Vue, Angular, Node.js, Python, etc.)", memorySavings: { "Flutter Web": "7MB saved (17 immediate, 13 lazy tools)", "Next.js": "6MB saved (21 immediate, 9 lazy tools)", "Phoenix LiveView": "5MB saved (17 immediate, 13 lazy tools)", "React": "7MB saved (18 immediate, 8 lazy tools)" } }, contextPreservation: { description: "๐Ÿ’พ Revolutionary token economy through intelligent delegation", benefit: "Keep main conversation clean while detailed work happens in separate context", maxSavings: "10000+ tokens per complex debugging session", comprehensiveCoverage: "Now covers 90%+ of AI-Debug capabilities through specialized agents", fallback: "100% backward compatibility with elegant 4-layer fallback system" }, automaticTestGeneration: { description: "๐Ÿงช Automatic 'Debug Once, Test Forever' from every debugging session", benefit: "Enterprise-quality tests automatically generated from both successes AND failures", coverage: "Issue prevention, optimization validation, failure prevention, proactive testing", quality: "80%+ AI-reviewed quality threshold with intelligent test improvement", scope: "All 8 specialized agents generate domain-specific tests automatically", realValue: "Failures generate the most valuable prevention tests - no manual intervention needed" } }, immediateHighValueActions: this.getContextSpecificActions(context), quickWins: [ "๐Ÿš€ inject_debugging: Automatic sub-agent delegation saves 1000+ tokens", "๐Ÿงช Automatic test generation: Every debugging session generates enterprise-quality tests", "๐ŸŽฏ smart_debug: Task-specific intelligent routing based on keywords", "๐Ÿ“Š auto_audit: Multi-category comprehensive analysis with agent selection", "๐Ÿ” intelligent_error_analysis: Advanced error investigation with root cause analysis", "๐Ÿ“ˆ get_sub_agent_status: Monitor delegation performance and token savings", "๐Ÿค– collect_ai_feedback: Share your experience to improve AI-Debug tools for all AI users", "๐Ÿ“Š get_feedback_summary: View analytics and insights from AI user feedback" ], workflowTemplates: { performanceInvestigation: "smart_debug({ taskType: 'performance' }) โ†’ 2000 token savings + automatic performance tests", accessibilityAudit: "auto_audit({ categories: ['accessibility'] }) โ†’ 1500 token savings + automatic a11y tests", completeHealthCheck: "inject_debugging + auto_audit + intelligent_error_analysis โ†’ 4000+ token savings + comprehensive test suite", errorDebugging: "intelligent_error_analysis({ errorTypes: ['javascript', 'console'] }) โ†’ 1800 token savings + error prevention tests", frameworkOptimization: "framework_specialist_debug({ framework: 'auto' }) โ†’ 2500 token savings + optimization validation tests", dataIntelligence: "data_extraction_analysis({ includeConsole: true, includeNetwork: true }) โ†’ 1600 token savings + integration tests", testingInfrastructure: "testing_infrastructure_setup({ enableTDD: true, enableMocking: true }) โ†’ 2200 token savings + TDD workflow tests", debugOnceTestForever: "Any debugging session โ†’ Automatic enterprise-quality test generation from successes AND failures", aiFeedbackLoop: "collect_ai_feedback after debugging sessions โ†’ Drives tool improvements for all AI users" }, performanceMetrics: { taskClassification: "<10ms", agentSelection: "<50ms", delegationSetup: "<100ms", classificationAccuracy: "95%", fallbackReliability: "100%" }, frameworkSupport: [ "Frontend: React, Vue, Angular, Svelte, Next.js, Nuxt, Astro", "Mobile: Flutter Web, React Native", "Backend: Node.js, Express, Python, Django, Flask, FastAPI", "Elixir: Phoenix LiveView, Traditional Phoenix, Pure Elixir, Nerves", "Static: Jekyll, Hugo, Gatsby, static sites" ] }; if (urgency === 'urgent') { return { quickStart: "Use inject_debugging for immediate sub-agent delegation", tokenSavings: "1000+ tokens saved automatically", zeroConfig: "Framework auto-detected, memory optimized automatically", nextAction: "inject_debugging({ url: 'your-app-url' })" }; } if (urgency === 'comprehensive') { return { ...capabilities, detailedWorkflows: this.getDetailedWorkflows(), advancedFeatures: this.getAdvancedFeatures(), bestPractices: this.getBestPractices() }; } return capabilities; } async getAiWorkflowTemplates(args) { const { scenario = 'complete-audit', framework = 'auto' } = args; const templates = { 'complete-audit': { description: "๐Ÿ† Comprehensive application health check with maximum token savings", workflow: [ "Step 1: inject_debugging({ url, framework: 'auto' }) // Auto-delegation + framework detection", "Step 2: auto_audit({ categories: ['performance', 'accessibility', 'security'] }) // Multi-agent analysis", "Step 3: intelligent_error_analysis({ errorTypes: ['javascript', 'console', 'network'] }) // Root cause analysis" ], expectedResults: { tokenSavings: "4000-10000+ tokens with expanded agent coverage", memorySavings: "4-8MB based on framework", completionTime: "2-5 minutes", coverage: "Performance + Accessibility + Security + Error Analysis + Framework Optimization + Data Intelligence + Testing Infrastructure" }, code: ` // Complete Application Audit Template const auditResults = await Promise.all([ inject_debugging({ url: 'your-app-url', framework: 'auto' }), auto_audit({ url: 'your-app-url', categories: ['performance', 'accessibility', 'security'], useSubAgents: true }), intelligent_error_analysis({ url: 'your-app-url', errorTypes: ['javascript', 'console', 'network'], includeStackTrace: true }) ]); // Result: Comprehensive audit with 4000+ tokens saved through sub-agent delegation ` }, 'performance-investigation': { description: "๐Ÿš€ Deep performance analysis with specialized agent delegation", workflow: [ "smart_debug({ url, taskType: 'performance', priority: 'high' }) // Auto-routes to performance-analysis-agent" ], expectedResults: { tokenSavings: "~2000 tokens", analysis: "Core Web Vitals, bundle analysis, optimization recommendations", deliverables: "Actionable performance improvement plan" }, code: ` // Performance Investigation Template const performanceAnalysis = await smart_debug({ url: 'your-app-url', taskType: 'performance', priority: 'high' }); // Result: Specialized performance analysis with 2000 tokens saved ` }, 'accessibility-compliance': { description: "โ™ฟ WCAG compliance audit with specialized accessibility agent", workflow: [ "auto_audit({ categories: ['accessibility'], priority: 'high' }) // Routes to accessibility-audit-agent" ], expectedResults: { tokenSavings: "~1500 tokens", compliance: "WCAG 2.1 AA compliance analysis", deliverables: "Prioritized accessibility improvement roadmap" } }, 'error-analysis': { description: "๐Ÿ” Comprehensive error investigation with root cause analysis", workflow: [ "intelligent_error_analysis({ errorTypes: ['javascript', 'console', 'runtime'] }) // Routes to error-investigation-agent" ], expectedResults: { tokenSavings: "~1800 tokens", analysis: "Stack traces, error patterns, root cause identification", deliverables: "Detailed debugging recommendations" } }, 'quick-health-check': { description: "โšก Rapid application health assessment", workflow: [ "inject_debugging({ url }) // Quick setup with auto-delegation" ], expectedResults: { tokenSavings: "~1000 tokens", speed: "30-60 seconds", coverage: "Initial discovery and framework optimization" } } }; return { selectedTemplate: templates[scenario], allTemplates: Object.keys(templates), frameworkOptimization: framework === 'auto' ? "Framework will be auto-detected for optimal tool loading" : `Optimized for ${framework} framework`, nextSteps: [ "1. Copy the provided code template", "2. Replace 'your-app-url' with your application URL", "3. Execute the workflow for immediate sub-agent delegation", "4. Monitor token savings with get_sub_agent_status()" ] }; } getContextSpecificActions(context) { const actions = { performance: [ "๐Ÿš€ smart_debug({ taskType: 'performance' }) โ†’ Routes to performance-analysis-agent", "๐Ÿ“Š Expected: Core Web Vitals analysis + optimization recommendations (~2000 tokens saved)" ], accessibility: [ "โ™ฟ auto_audit({ categories: ['accessibility'] }) โ†’ Routes to accessibility-audit-agent", "๐Ÿ“‹ Expected: WCAG compliance analysis + remediation plan (~1500 tokens saved)" ], errors: [ "๐Ÿ” intelligent_error_analysis({ errorTypes: ['javascript', 'console'] }) โ†’ Routes to error-investigation-agent", "๐ŸŽฏ Expected: Root cause analysis + debugging recommendations (~1800 tokens saved)" ], testing: [ "๐Ÿงช smart_debug({ taskType: 'testing' }) โ†’ Routes to validation-testing-agent", "โœ… Expected: Quality assurance + regression testing (~1200 tokens saved)" ], general: [ "๐Ÿค– inject_debugging({ url }) โ†’ Automatic framework detection + sub-agent delegation", "๐Ÿ’พ Expected: Initial discovery + memory optimization (1000+ tokens saved)" ] }; return actions[context] || actions.general; } getDetailedWorkflows() { return { multiPhaseDebugging: "Coordinate multiple sub-agents for comprehensive analysis", frameworkSpecific: "Leverage project-aware loading for optimal performance", enterpriseWorkflows: "Scale debugging across multiple applications and teams" }; } getAdvancedFeatures() { return { customAgentDelegation: "Manual sub-agent selection for specialized requirements", batchOperations: "Process multiple URLs with intelligent agent coordination", performanceMonitoring: "Real-time delegation statistics and optimization metrics" }; } getBestPractices() { return [ "Always start with inject_debugging for automatic framework detection", "Use context-specific smart_debug for targeted analysis", "Monitor token savings with get_sub_agent_status", "Leverage auto_audit for comprehensive quality assessment", "Trust the intelligent delegation - system optimizes automatically" ]; } } //# sourceMappingURL=capability-discovery-handler.js.map