UNPKG

task-master-neo-sdlc

Version:

Enhanced task management system with Neo SDLC agents and MCP tools for comprehensive, AI-driven software development lifecycle management.

219 lines (186 loc) 7.45 kB
/** * Task Master Integration for QA Agent and TDD Framework * * Integrates the QA Agent and TDD Framework with the Task Master system. */ import { log } from '../../../utils/logging.js'; import { QAAgent } from '../agents/qa-agent.js'; import { TDDFramework } from '../tdd-framework.js'; import { detectTestFrameworks, recommendTestFrameworks } from '../testing/test-frameworks.js'; import { moduleEnvironment } from '../../../utils/module-loader.js'; /** * Initialize QA Agent and TDD Framework for Task Master * @param {Object} agentWorkflowSystem - Agent Workflow System * @param {Object} options - Initialization options * @returns {Object} Initialized QA Agent and TDD Framework */ export async function initializeQAForTaskMaster(agentWorkflowSystem, options = {}) { log.info('Initializing QA Agent and TDD Framework for Task Master'); try { // Create QA Agent const qaAgent = new QAAgent('qa-agent', { capabilities: [ 'testing', 'quality-assurance', 'test-automation', 'tdd', 'bdd', 'unit-testing', 'integration-testing', 'e2e-testing' ], knowledgeDomains: [ 'jest', 'mocha', 'chai', 'cypress', 'selenium', 'testing-library', 'test-driven-development', 'behavior-driven-development' ], preferredFramework: options.preferredFramework || 'jest', coverageThreshold: options.coverageThreshold || 80, useAI: options.useAI !== undefined ? options.useAI : true, cicdIntegration: options.cicdIntegration !== undefined ? options.cicdIntegration : true, collectMetrics: options.collectMetrics !== undefined ? options.collectMetrics : true }); // Register QA Agent with Agent Workflow System await agentWorkflowSystem.registerAgent(qaAgent); // Get TDD Framework from Agent Workflow System const tddFramework = agentWorkflowSystem.tddFramework; // Detect project type const projectRoot = agentWorkflowSystem.projectRoot; const projectType = tddFramework.determineProjectType(projectRoot); // Detect existing test frameworks const existingFrameworks = detectTestFrameworks(projectRoot); // Recommend test frameworks based on project type const recommendedFrameworks = recommendTestFrameworks({ type: projectType, features: options.features || [], projectRoot }); log.info(`Project type: ${projectType}`); log.info(`Existing test frameworks: ${existingFrameworks.join(', ')}`); log.info(`Recommended test frameworks: ${JSON.stringify(recommendedFrameworks)}`); return { qaAgent, tddFramework, projectType, existingFrameworks, recommendedFrameworks, moduleEnvironment }; } catch (error) { log.error(`Error initializing QA Agent and TDD Framework: ${error.message}`); throw error; } } /** * Create TDD workflow from Task Master task * @param {Object} tddFramework - TDD Framework * @param {Object} task - Task Master task * @param {Object} options - Workflow options * @returns {Promise<Object>} Created TDD workflow */ export async function createTDDWorkflowFromTask(tddFramework, task, options = {}) { log.info(`Creating TDD workflow for task ${task.id}: ${task.title}`); try { // Determine test types based on task const testTypes = determineTestTypesForTask(task, options.testTypes); // Determine test framework based on task const testFramework = options.testFramework || determineTestFrameworkForTask(task, options.recommendedFrameworks); // Create TDD workflow const workflow = await tddFramework.createTDDWorkflow({ id: `tdd-workflow-${task.id}`, taskMasterId: task.id, makerAgentId: options.makerAgentId || 'dev-agent', checkerAgentId: options.checkerAgentId || 'qa-agent', testConfig: { framework: testFramework, coverage: options.coverage || 80, testTypes, useAI: options.useAI !== undefined ? options.useAI : true, setupCICD: options.setupCICD !== undefined ? options.setupCICD : false, collectMetrics: options.collectMetrics !== undefined ? options.collectMetrics : true } }); log.info(`Created TDD workflow ${workflow.id} for task ${task.id}`); return workflow; } catch (error) { log.error(`Error creating TDD workflow for task ${task.id}: ${error.message}`); throw error; } } /** * Execute TDD workflow for Task Master task * @param {Object} tddFramework - TDD Framework * @param {string} workflowId - TDD workflow ID * @param {Object} options - Execution options * @returns {Promise<Object>} Execution result */ export async function executeTDDWorkflowForTask(tddFramework, workflowId, options = {}) { log.info(`Executing TDD workflow ${workflowId}`); try { // Execute TDD workflow const result = await tddFramework.executeTDDWorkflow(workflowId); log.info(`TDD workflow ${workflowId} execution ${result.success ? 'succeeded' : 'failed'}`); // Generate report if requested if (options.generateReport) { // TODO: Generate report } return result; } catch (error) { log.error(`Error executing TDD workflow ${workflowId}: ${error.message}`); throw error; } } /** * Determine test types for task * @param {Object} task - Task Master task * @param {Array<string>} defaultTestTypes - Default test types * @returns {Array<string>} Test types */ function determineTestTypesForTask(task, defaultTestTypes = ['unit']) { // Check if task has test types specified if (task.testTypes && Array.isArray(task.testTypes)) { return task.testTypes; } // Check task title and description for test type hints const title = task.title?.toLowerCase() || ''; const description = task.description?.toLowerCase() || ''; const combined = `${title} ${description}`; const testTypes = []; // Check for unit test hints if (combined.includes('unit test') || combined.includes('component test') || combined.includes('function test')) { testTypes.push('unit'); } // Check for integration test hints if (combined.includes('integration test') || combined.includes('api test') || combined.includes('service test')) { testTypes.push('integration'); } // Check for e2e test hints if (combined.includes('e2e test') || combined.includes('end-to-end test') || combined.includes('ui test') || combined.includes('browser test')) { testTypes.push('e2e'); } // Return detected test types or default return testTypes.length > 0 ? testTypes : defaultTestTypes; } /** * Determine test framework for task * @param {Object} task - Task Master task * @param {Object} recommendedFrameworks - Recommended test frameworks * @returns {string} Test framework */ function determineTestFrameworkForTask(task, recommendedFrameworks = {}) { // Check if task has test framework specified if (task.testFramework) { return task.testFramework; } // Get test types for task const testTypes = determineTestTypesForTask(task); // Use recommended framework for highest priority test type const highestPriorityType = testTypes[0]; if (recommendedFrameworks && recommendedFrameworks[highestPriorityType]) { return recommendedFrameworks[highestPriorityType]; } // Default to Jest return 'jest'; }