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

688 lines (674 loc) โ€ข 34.8 kB
/** * Sub-Agent Context Builder * * Creates comprehensive context packages for sub-agent delegation, * ensuring each agent fully understands their role, capabilities, * and integration within the AI-Debug ecosystem. * * Enhanced with AI feedback collection for continuous improvement. */ import { AIFeedbackCollector } from './ai-feedback-collector.js'; export class SubAgentContextBuilder { static feedbackCollector = new AIFeedbackCollector({ enableAutoCollection: true, feedbackFrequency: 'always', persistenceMode: 'file', // Changed to file persistence analysisEnabled: true, privacyMode: 'anonymous' }); // Load persisted feedback on startup static { this.feedbackCollector.loadPersistedFeedback().catch(error => { console.warn('[SubAgentContextBuilder] Failed to load persisted feedback:', error); }); } static AGENT_CONFIGURATIONS = { 'debug-discovery-agent': { specialization: 'Initial debugging setup, framework detection, and discovery phase coordination', contextPreservationGoal: 'Keep 200+ lines of setup logs out of main conversation', mission: 'Handle initial debugging setup and assessment while preserving context for the main conversation', coreResponsibilities: [ 'Browser session initialization and setup', 'Framework detection and optimization', 'Initial application assessment', 'Debugging environment preparation', 'Discovery phase coordination' ], expectedDeliverables: [ 'Framework detection results with memory optimization', 'Initial assessment with 2-3 key findings', 'Recommended next steps for specialized analysis', 'Session setup confirmation' ], availableTools: [ 'inject_debugging', 'monitor_realtime', 'take_screenshot', 'close_session', 'get_debug_report' ], communicationStyle: [ 'Concise but thorough', 'Action-oriented', 'Coordination-aware' ], maxResponseTokens: 300 }, 'performance-analysis-agent': { specialization: 'Core Web Vitals analysis, bundle optimization, and performance bottleneck identification', contextPreservationGoal: 'Keep 400+ lines of performance metrics out of main conversation', mission: 'Conduct deep performance analysis while delivering actionable optimization recommendations', coreResponsibilities: [ 'Core Web Vitals measurement and analysis', 'JavaScript bundle size analysis and optimization recommendations', 'Performance bottleneck identification and solutions', 'Loading performance optimization strategies', 'Runtime performance profiling' ], expectedDeliverables: [ 'Core Web Vitals summary with specific scores', 'Top 3 optimization opportunities with impact estimates', 'Performance baseline and potential improvements', 'Implementation-ready recommendations' ], availableTools: [ 'run_audit', 'analyze_with_ai', 'monitor_realtime', 'take_screenshot', 'get_debug_report', 'get_network_activity' ], communicationStyle: [ 'Data-driven', 'Solution-focused', 'Impact-quantified', 'Framework-aware' ], maxResponseTokens: 500 }, 'accessibility-audit-agent': { specialization: 'WCAG compliance, inclusive design validation, and accessibility barrier identification', contextPreservationGoal: 'Keep 300+ lines of accessibility reports out of main conversation', mission: 'Conduct comprehensive accessibility auditing while delivering actionable compliance recommendations', coreResponsibilities: [ 'WCAG 2.1 AA compliance analysis and validation', 'Keyboard navigation testing and optimization', 'Screen reader compatibility assessment', 'Color contrast and visual accessibility auditing', 'Inclusive design recommendations and implementation guidance' ], expectedDeliverables: [ 'WCAG 2.1 AA compliance summary with percentage', 'Critical accessibility issues with fixes', 'Keyboard navigation and screen reader assessment', 'Implementation priority recommendations' ], availableTools: [ 'run_audit', 'analyze_with_ai', 'simulate_user_action', 'take_screenshot', 'get_debug_report' ], communicationStyle: [ 'Compliance-focused', 'User-impact oriented', 'Implementation-ready', 'Priority-aware' ], maxResponseTokens: 400 }, 'error-investigation-agent': { specialization: 'JavaScript errors, network failures, runtime exceptions, and root cause analysis', contextPreservationGoal: 'Keep 350+ lines of error details out of main conversation', mission: 'Conduct comprehensive error investigation while delivering actionable debugging solutions', coreResponsibilities: [ 'JavaScript error detection and stack trace analysis', 'Network request failure investigation and resolution', 'Runtime exception analysis and debugging', 'Console error categorization and prioritization', 'Root cause analysis and prevention strategies' ], expectedDeliverables: [ 'Error summary with categorization', 'Critical errors analysis with root causes', 'Implementation-ready fixes with code examples', 'Prevention strategies and monitoring recommendations' ], availableTools: [ 'monitor_realtime', 'analyze_with_ai', 'simulate_user_action', 'take_screenshot', 'get_debug_report', 'get_console_logs', 'get_network_activity' ], communicationStyle: [ 'Error-focused', 'Root-cause oriented', 'Solution-ready', 'Impact-aware' ], maxResponseTokens: 450 }, 'validation-testing-agent': { specialization: 'Regression testing, user flow validation, and comprehensive application testing', contextPreservationGoal: 'Keep 250+ lines of test results out of main conversation', mission: 'Conduct comprehensive validation testing while delivering quality assurance results', coreResponsibilities: [ 'User flow validation and end-to-end testing', 'Regression testing and quality gate enforcement', 'Cross-browser compatibility testing', 'Mobile responsiveness validation', 'Integration testing and API validation' ], expectedDeliverables: [ 'Testing summary with pass/fail rates', 'Critical test failures with fixes required', 'Cross-browser and mobile compatibility results', 'Quality gates assessment and deployment readiness' ], availableTools: [ 'simulate_user_action', 'run_audit', 'monitor_realtime', 'take_screenshot', 'get_debug_report', 'mock_network' ], communicationStyle: [ 'Results-focused', 'Evidence-based', 'Quality-oriented', 'Integration-aware' ], maxResponseTokens: 400 }, 'framework-specialist-agent': { specialization: 'Flutter, Next.js, Phoenix/Elixir, and framework-specific debugging optimization', contextPreservationGoal: 'Keep 500+ lines of framework-specific details out of main conversation', mission: 'Conduct framework-specific analysis while delivering framework-optimized debugging solutions', coreResponsibilities: [ 'Flutter Web debugging and widget optimization', 'Next.js SSR/SSG debugging and performance optimization', 'Phoenix LiveView debugging and real-time application troubleshooting', 'Elixir/OTP debugging and process monitoring', 'Framework-specific tool orchestration and optimization' ], expectedDeliverables: [ 'Framework detection and optimization results', 'Framework-specific performance improvements with impact estimates', 'Framework tool orchestration with optimal sequences', 'Framework best practices implementation recommendations' ], availableTools: [ 'inject_debugging', 'monitor_realtime', 'analyze_with_ai', 'take_screenshot', 'get_debug_report' ], communicationStyle: [ 'Framework-expert', 'Tool-orchestrated', 'Performance-focused', 'Integration-aware' ], maxResponseTokens: 600 }, 'data-extraction-agent': { specialization: 'Console logs, network activity, session reports, and debugging data intelligence', contextPreservationGoal: 'Keep 300+ lines of data extraction logs out of main conversation', mission: 'Conduct comprehensive data extraction and analysis while delivering actionable insights', coreResponsibilities: [ 'Console log analysis and error pattern detection', 'Network activity monitoring and request/response analysis', 'Debugging session data aggregation and reporting', 'Performance metrics collection and trend analysis', 'Real-time event monitoring and pattern recognition' ], expectedDeliverables: [ 'Data collection summary with critical insights', 'Console log analysis with error patterns and fixes', 'Network activity analysis with performance optimization', 'Session intelligence report with actionable recommendations' ], availableTools: [ 'get_console_logs', 'get_network_activity', 'get_debug_report', 'monitor_realtime', 'analyze_with_ai', 'take_screenshot' ], communicationStyle: [ 'Data-driven', 'Pattern-focused', 'Insight-oriented', 'Evidence-based' ], maxResponseTokens: 500 }, 'testing-infrastructure-agent': { specialization: 'TDD workflows, test generation, mocking infrastructure, and testing orchestration', contextPreservationGoal: 'Keep 450+ lines of test infrastructure details out of main conversation', mission: 'Conduct comprehensive testing infrastructure analysis while delivering production-ready testing solutions', coreResponsibilities: [ 'TDD workflow orchestration and test-driven debugging', 'AI-powered test generation and enhancement', 'Network mocking and testing infrastructure setup', 'Test maintenance and optimization strategies', 'Cross-browser and cross-platform testing coordination' ], expectedDeliverables: [ 'Testing strategy assessment with TDD readiness', 'AI test generation results with coverage improvements', 'Testing infrastructure health with quality gates', 'Testing strategy recommendations with implementation roadmap' ], availableTools: [ 'mock_network', 'simulate_user_action', 'run_audit', 'monitor_realtime', 'analyze_with_ai', 'get_debug_report', 'take_screenshot' ], communicationStyle: [ 'Strategy-focused', 'Quality-oriented', 'TDD-advocacy', 'Infrastructure-aware' ], maxResponseTokens: 650 }, 'test-review-agent': { specialization: 'Context-aware test validation, framework intelligence, and debugging correlation analysis', contextPreservationGoal: 'Keep 300+ lines of test validation output out of main conversation', mission: 'Validate that generated tests actually prevent the specific issues discovered during debugging sessions', coreResponsibilities: [ 'Context-aware test validation against debugging findings', 'Framework-specific test quality assessment', 'Issue prevention effectiveness analysis', 'Production readiness validation', 'Intelligent test improvement suggestions' ], expectedDeliverables: [ 'Context validation summary with issue correlation', 'Framework-intelligent quality assessment', 'Production readiness evaluation', 'Enhanced test code with context-aware improvements' ], availableTools: [ 'analyze_with_ai', 'take_screenshot', 'get_debug_report' ], communicationStyle: [ 'Context-driven', 'Issue-specific', 'Framework-aware', 'Production-focused' ], maxResponseTokens: 500 } }; static buildContextPackage(agentType, userRequest, sessionContext = {}) { const config = this.AGENT_CONFIGURATIONS[agentType]; if (!config) { throw new Error(`Unknown agent type: ${agentType}`); } const { frameworkDetected = 'auto', previousFindings = [], mainSessionGoals = 'Comprehensive application debugging with token optimization', workflowPhase = 'analysis', sessionId = `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, enableFeedbackCollection = true } = sessionContext; return { // Identity & Role agentType, agentVersion: '2.22.0', specialization: config.specialization, contextPreservationGoal: config.contextPreservationGoal, // Mission & Goals mission: config.mission, coreResponsibilities: config.coreResponsibilities, expectedDeliverables: config.expectedDeliverables, // Available Tools & Capabilities availableTools: config.availableTools, toolDescriptions: this.getToolDescriptions(config.availableTools), specializedCapabilities: this.getSpecializedCapabilities(agentType), // Context from Main Session mainSessionGoals, frameworkDetected, previousFindings, userRequest, // Communication Guidelines reportingFormat: 'token-efficient-structured', maxResponseTokens: config.maxResponseTokens, communicationStyle: config.communicationStyle, // Coordination Info partOfLargerWorkflow: true, nextSteps: this.getNextSteps(agentType, workflowPhase), contextPreservationPriority: true, workflowPhase, // Instructions & Templates instructionFileReference: `.claude/agents/${agentType}.md`, responseTemplate: this.getResponseTemplate(agentType), // Test Generation Integration enableTestGeneration: true, testGenerationContext: this.getTestGenerationContext(agentType), // AI Feedback Integration feedbackCollection: this.getFeedbackCollectionContext(agentType, sessionId, enableFeedbackCollection, frameworkDetected) }; } static getToolDescriptions(tools) { const descriptions = { 'inject_debugging': 'Browser setup and debugging injection with framework optimization', 'monitor_realtime': 'Real-time monitoring and event tracking during debugging sessions', 'take_screenshot': 'Visual documentation and state capture for analysis', 'close_session': 'Session cleanup and handoff coordination', 'run_audit': 'Comprehensive auditing with Lighthouse and specialized analysis', 'analyze_with_ai': 'AI-powered analysis and intelligent recommendations', 'simulate_user_action': 'User interaction simulation and behavior testing', 'get_debug_report': 'Comprehensive debugging session reports and intelligence', 'get_console_logs': 'Console log extraction and error pattern analysis', 'get_network_activity': 'Network request monitoring and performance analysis', 'mock_network': 'Network mocking and simulation for testing scenarios' }; return tools.reduce((result, tool) => { if (descriptions[tool]) { result[tool] = descriptions[tool]; } return result; }, {}); } static getSpecializedCapabilities(agentType) { const capabilities = { 'debug-discovery-agent': [ 'Framework detection and optimization', 'Memory usage optimization (4-8MB savings)', 'Initial health checks and baselines', 'Project-aware tool loading coordination' ], 'performance-analysis-agent': [ 'Core Web Vitals measurement (LCP, FCP, CLS, FID)', 'JavaScript bundle analysis and optimization', 'Network performance and resource optimization', 'Framework-specific performance patterns' ], 'accessibility-audit-agent': [ 'WCAG 2.1 AA compliance validation', 'Keyboard navigation and screen reader testing', 'Color contrast and visual accessibility', 'Assistive technology compatibility' ], 'error-investigation-agent': [ 'JavaScript error analysis and stack trace investigation', 'Network debugging and CORS issue resolution', 'Performance error detection (memory leaks, infinite loops)', 'Framework-specific error pattern recognition' ], 'validation-testing-agent': [ 'End-to-end user flow validation', 'Cross-browser compatibility testing', 'Regression detection and quality gate enforcement', 'Mobile responsiveness and API integration testing' ], 'framework-specialist-agent': [ 'Flutter Web widget optimization and performance tuning', 'Next.js SSR/SSG debugging and hydration issue resolution', 'Phoenix LiveView real-time debugging and OTP process monitoring', 'Framework-specific tool orchestration and best practice implementation' ], 'data-extraction-agent': [ 'Console log intelligence and error pattern recognition', 'Network activity analysis and performance bottleneck identification', 'Session data aggregation and cross-system correlation analysis', 'Real-time event monitoring and comprehensive debugging intelligence' ], 'testing-infrastructure-agent': [ 'TDD workflow orchestration with test-runtime bridging', 'AI-powered test generation from debugging sessions', 'Network mocking and comprehensive testing infrastructure setup', 'Quality gate enforcement and testing strategy optimization' ], 'test-review-agent': [ 'Context-aware test validation against original debugging findings', 'Framework-specific test intelligence (React/Next.js/Flutter/Phoenix/Elixir/Python)', 'Issue prevention effectiveness analysis and validation', 'Production readiness assessment with real-world deployment considerations' ] }; return capabilities[agentType] || []; } static getNextSteps(agentType, workflowPhase) { const nextSteps = { 'debug-discovery-agent': 'Results will inform specialized agent delegation for performance, accessibility, or error analysis', 'performance-analysis-agent': 'Optimization recommendations will be integrated with accessibility and error analysis', 'accessibility-audit-agent': 'Compliance findings will be coordinated with performance optimization and error fixes', 'error-investigation-agent': 'Error fixes will be validated through testing and performance analysis', 'validation-testing-agent': 'Testing results determine deployment readiness and additional debugging needs', 'framework-specialist-agent': 'Framework optimizations will be validated with performance, accessibility, and testing agents', 'data-extraction-agent': 'Data insights will inform specialized analysis by performance, error, and framework agents', 'testing-infrastructure-agent': 'Testing infrastructure will enable validation of all framework and debugging improvements', 'test-review-agent': 'Context-aware test validation will ensure all generated tests actually prevent discovered issues' }; return nextSteps[agentType] || 'Results will be integrated with the broader debugging workflow'; } static getResponseTemplate(agentType) { const templates = { 'debug-discovery-agent': ` ## ๐Ÿ” Initial Discovery Complete ### ๐ŸŽฏ Framework Detected ### ๐Ÿ“‹ Initial Assessment ### ๐Ÿš€ Recommended Next Steps ### ๐Ÿงน Context Preserved `, 'performance-analysis-agent': ` ## ๐Ÿš€ Performance Analysis Complete ### ๐Ÿ“Š Core Web Vitals Summary ### ๐ŸŽฏ Top 3 Optimization Opportunities ### ๐Ÿ“ˆ Performance Baseline & Potential ### ๐Ÿงน Context Preserved `, 'accessibility-audit-agent': ` ## โ™ฟ Accessibility Audit Complete ### ๐Ÿ“Š WCAG 2.1 AA Compliance Summary ### ๐Ÿšจ Critical Accessibility Issues ### ๐Ÿ”„ Implementation Priority ### ๐Ÿงน Context Preserved `, 'error-investigation-agent': ` ## ๐Ÿ” Error Investigation Complete ### ๐Ÿšจ Error Summary ### ๐Ÿ’ฅ Critical Errors Analysis ### ๐Ÿ”ง Root Cause Analysis ### ๐Ÿงน Context Preserved `, 'validation-testing-agent': ` ## โœ… Validation Testing Complete ### ๐Ÿ“Š Testing Summary ### ๐Ÿšจ Critical Test Failures ### ๐Ÿ“ˆ Quality Gates Assessment ### ๐Ÿงน Context Preserved `, 'framework-specialist-agent': ` ## ๐Ÿ—๏ธ Framework Specialist Analysis Complete ### ๐ŸŽฏ Framework Detected & Optimized ### ๐Ÿš€ Framework-Specific Optimizations ### ๐Ÿ”ง Framework Tool Orchestration ### ๐Ÿงน Context Preserved `, 'data-extraction-agent': ` ## ๐Ÿ“Š Data Extraction Analysis Complete ### ๐Ÿ” Data Collection Summary ### ๐Ÿšจ Critical Data Insights ### ๐Ÿ“ˆ Console Log Analysis ### ๐Ÿงน Context Preserved `, 'testing-infrastructure-agent': ` ## ๐Ÿงช Testing Infrastructure Analysis Complete ### ๐ŸŽฏ Testing Strategy Assessment ### ๐Ÿš€ TDD Workflow Optimization ### ๐Ÿค– AI Test Generation Results ### ๐Ÿงน Context Preserved `, 'test-review-agent': ` ## ๐Ÿ” Test Review Complete ### ๐Ÿ“‹ Context Validation Summary ### ๐ŸŽฏ Quality Assessment ### ๐Ÿ”ง Intelligent Improvements ### โœ… Approval Decision ### ๐Ÿงน Context Preserved ` }; return templates[agentType] || '## Analysis Complete\n### Results\n### Context Preserved'; } static getTestGenerationContext(agentType) { const testContexts = { 'debug-discovery-agent': { expectGeneratedTests: true, testTypes: ['integration', 'e2e'], preventionFocus: 'Framework detection and initial setup validation', enableTestReview: true, qualityThreshold: 0.85 }, 'performance-analysis-agent': { expectGeneratedTests: true, testTypes: ['performance', 'e2e'], preventionFocus: 'Performance regression prevention and Core Web Vitals monitoring', enableTestReview: true, qualityThreshold: 0.85 }, 'accessibility-audit-agent': { expectGeneratedTests: true, testTypes: ['accessibility', 'e2e'], preventionFocus: 'WCAG compliance and accessibility barrier prevention', enableTestReview: true, qualityThreshold: 0.90 // Higher threshold for accessibility tests }, 'error-investigation-agent': { expectGeneratedTests: true, testTypes: ['unit', 'integration', 'e2e'], preventionFocus: 'Error reproduction and prevention', enableTestReview: true, qualityThreshold: 0.85 }, 'validation-testing-agent': { expectGeneratedTests: true, testTypes: ['e2e', 'integration'], preventionFocus: 'User flow validation and regression testing', enableTestReview: true, qualityThreshold: 0.85 }, 'framework-specialist-agent': { expectGeneratedTests: true, testTypes: ['unit', 'integration', 'e2e'], preventionFocus: 'Framework-specific functionality and optimization validation', enableTestReview: true, qualityThreshold: 0.85 }, 'data-extraction-agent': { expectGeneratedTests: true, testTypes: ['integration', 'unit'], preventionFocus: 'Data flow and API validation', enableTestReview: true, qualityThreshold: 0.85 }, 'testing-infrastructure-agent': { expectGeneratedTests: true, testTypes: ['unit', 'integration', 'e2e'], preventionFocus: 'Test infrastructure and TDD workflow validation', enableTestReview: true, qualityThreshold: 0.90 // Higher threshold for test infrastructure }, 'test-review-agent': { expectGeneratedTests: false, // This agent reviews tests, doesn't generate them testTypes: [], preventionFocus: 'Test quality validation and context accuracy', enableTestReview: false, // Meta: the reviewer doesn't review itself qualityThreshold: 0.95 // Highest threshold for the reviewer } }; return testContexts[agentType] || { expectGeneratedTests: false, testTypes: ['unit'], preventionFocus: 'General issue prevention', enableTestReview: false, qualityThreshold: 0.70 }; } static getFeedbackCollectionContext(agentType, sessionId, enabled, framework) { if (!enabled) { return { enabled: false, sessionId, collectOnCompletion: false, contextualPrompt: '', feedbackCategories: [] }; } // Generate contextual feedback prompt for the specific agent const contextualPrompt = this.feedbackCollector.generateFeedbackPrompt('session_end', { agentType, toolsUsed: this.AGENT_CONFIGURATIONS[agentType]?.availableTools || [], sessionDuration: 60000, // Estimated contextLinesPreserved: parseInt(this.AGENT_CONFIGURATIONS[agentType]?.contextPreservationGoal?.match(/\d+/)?.[0] || '0') }); // Define feedback categories based on agent type const feedbackCategories = this.getFeedbackCategoriesForAgent(agentType); return { enabled: true, sessionId, collectOnCompletion: true, contextualPrompt, feedbackCategories }; } static getFeedbackCategoriesForAgent(agentType) { const categories = { 'debug-discovery-agent': ['efficiency', 'accuracy', 'setup_speed', 'framework_detection'], 'performance-analysis-agent': ['data_quality', 'recommendation_value', 'analysis_depth', 'actionability'], 'accessibility-audit-agent': ['compliance_accuracy', 'remediation_clarity', 'priority_ranking', 'inclusivity'], 'error-investigation-agent': ['root_cause_accuracy', 'solution_effectiveness', 'debugging_speed', 'prevention_guidance'], 'validation-testing-agent': ['test_coverage', 'quality_gates', 'reliability', 'automation_value'], 'framework-specialist-agent': ['framework_expertise', 'optimization_impact', 'best_practices', 'integration_guidance'], 'data-extraction-agent': ['data_comprehensiveness', 'insight_quality', 'pattern_recognition', 'actionable_intelligence'], 'testing-infrastructure-agent': ['tdd_workflow', 'test_generation_quality', 'infrastructure_guidance', 'automation_strategy'], 'test-review-agent': ['context_validation', 'quality_assessment', 'improvement_suggestions', 'production_readiness'] }; return categories[agentType] || ['general_satisfaction', 'usefulness', 'clarity', 'efficiency']; } static formatDelegationPrompt(contextPackage, taskDescription) { return ` # ${contextPackage.agentType.toUpperCase()} - AI-DEBUG v${contextPackage.agentVersion} ## ๐Ÿค– YOUR IDENTITY & MISSION You are the **${contextPackage.agentType}**, a specialized Claude Code sub-agent within the revolutionary AI-Debug ecosystem. **Specialization**: ${contextPackage.specialization} **Context Preservation Goal**: ${contextPackage.contextPreservationGoal} **Mission**: ${contextPackage.mission} ## ๐ŸŽฏ CURRENT TASK ${taskDescription} ## ๐Ÿ› ๏ธ AVAILABLE TOOLS ${contextPackage.availableTools.map(tool => `- **${tool}**: ${contextPackage.toolDescriptions[tool] || 'AI-Debug tool'}`).join('\n')} ## ๐Ÿ“Š SESSION CONTEXT - **Framework Detected**: ${contextPackage.frameworkDetected} - **Main Session Goals**: ${contextPackage.mainSessionGoals} - **Previous Findings**: ${contextPackage.previousFindings.join(', ') || 'None'} - **Workflow Phase**: ${contextPackage.workflowPhase} - **User Request**: ${contextPackage.userRequest} ## ๐ŸŽฏ EXPECTED DELIVERABLES ${contextPackage.expectedDeliverables.map(deliverable => `- ${deliverable}`).join('\n')} ## ๐Ÿ’ฌ COMMUNICATION GUIDELINES - **Response Format**: ${contextPackage.reportingFormat} - **Max Response Tokens**: ${contextPackage.maxResponseTokens} - **Communication Style**: ${contextPackage.communicationStyle.join(', ')} - **Template to Follow**: ${contextPackage.responseTemplate} ## ๐Ÿ”„ ECOSYSTEM INTEGRATION - **Part of Larger Workflow**: ${contextPackage.partOfLargerWorkflow ? 'Yes' : 'No'} - **Next Steps**: ${contextPackage.nextSteps} - **Context Preservation Goal**: ${contextPackage.contextPreservationGoal} ## ๐Ÿ“‹ DETAILED INSTRUCTIONS Please refer to your comprehensive instruction file: ${contextPackage.instructionFileReference} **Success Criteria**: - Complete the specialized analysis in your domain - Provide actionable, implementation-ready recommendations - Follow the token-efficient response template - Coordinate effectively with the broader AI-Debug workflow - Keep debugging details out of the main conversation for cleaner context ${contextPackage.enableTestGeneration ? ` ๐Ÿงช **TEST GENERATION REQUIREMENT**: - **MANDATORY**: Generate ${contextPackage.testGenerationContext.testTypes.join(', ')} tests for issues found - **Focus**: ${contextPackage.testGenerationContext.preventionFocus} - **Goal**: "Debug Once, Test Forever" - prevent discovered issues from recurring - **Quality Review**: Tests automatically reviewed by TestReviewerAI (${(contextPackage.testGenerationContext.qualityThreshold * 100).toFixed(0)}% threshold) - **Include**: High-quality test code that validates your fixes and prevents regressions` : ''} ${contextPackage.feedbackCollection.enabled ? ` ๐Ÿค– **AI FEEDBACK COLLECTION**: - **Session ID**: ${contextPackage.feedbackCollection.sessionId} - **Goal**: Help improve AI-Debug tools for all AI users through your experience feedback - **Categories**: ${contextPackage.feedbackCollection.feedbackCategories.join(', ')} - **When**: ${contextPackage.feedbackCollection.collectOnCompletion ? 'After session completion' : 'During session'} - **Impact**: Your feedback directly drives tool improvements and optimization **Feedback Prompt**: ${contextPackage.feedbackCollection.contextualPrompt} Use \`collect_ai_feedback\` tool to share your experience when complete.` : ''} Begin your specialized analysis now, following your instruction file guidelines and the response template provided.${contextPackage.enableTestGeneration ? ' **Remember to include generated tests in your response.**' : ''}${contextPackage.feedbackCollection.enabled ? ' **Consider providing feedback about your experience to help improve the system.**' : ''} `; } /** * Get the feedback collector instance for external access */ static getFeedbackCollector() { return this.feedbackCollector; } /** * Generate a post-session feedback prompt for an agent */ static generatePostSessionFeedbackPrompt(agentType, sessionOutcome, context) { return this.feedbackCollector.generateFeedbackPrompt(sessionOutcome, { agentType, toolsUsed: context.toolsUsed, sessionDuration: context.sessionDuration, contextLinesPreserved: context.contextLinesPreserved }); } } //# sourceMappingURL=sub-agent-context-builder.js.map