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.

221 lines (192 loc) 5.79 kB
import { readJSON, writeJSON } from '../utils/file-utils.js'; import { log } from '../utils/logging.js'; import { findNextTask, generateTaskFiles } from './task-manager.js'; class NeoOrchestrator { constructor(projectRoot) { this.projectRoot = projectRoot; this.contextPath = `${projectRoot}/.context`; this.agentStatuses = new Map(); this.activeWorkflows = new Map(); } async initialize() { try { // Initialize project context await this.initializeContext(); // Activate core agents await this.activateAgents([ 'project_coordinator', 'quality_controller', 'process_manager', 'resource_orchestrator', 'communication_hub' ]); return { success: true, message: 'Neo Orchestrator initialized successfully' }; } catch (error) { log('error', `Failed to initialize Neo Orchestrator: ${error.message}`); throw error; } } async initializeContext() { const contextData = { project: { root: this.projectRoot, initialized: Date.now(), lastUpdated: Date.now() }, agents: {}, workflows: {}, metrics: { taskCompletionRate: 0, qualityScore: 0, processEfficiency: 0 } }; await writeJSON(`${this.contextPath}/project/context.json`, contextData); } async activateAgents(agentIds) { for (const agentId of agentIds) { try { await this.activateAgent(agentId); this.agentStatuses.set(agentId, 'active'); } catch (error) { log('error', `Failed to activate agent ${agentId}: ${error.message}`); this.agentStatuses.set(agentId, 'failed'); } } } async activateAgent(agentId) { // Read agent configuration const agentConfig = await readJSON(`${this.projectRoot}/config/agents/${agentId}.json`); // Initialize agent context const agentContext = { id: agentId, status: 'active', capabilities: agentConfig.capabilities, workflows: agentConfig.workflows, activated: Date.now() }; await writeJSON(`${this.contextPath}/agents/${agentId}.json`, agentContext); } async orchestrateTask(taskId) { try { const tasksData = await readJSON(`${this.projectRoot}/tasks/tasks.json`); const task = tasksData.tasks.find(t => t.id === taskId); if (!task) { throw new Error(`Task ${taskId} not found`); } // Create workflow for task const workflow = { id: `workflow_${taskId}`, taskId, status: 'pending', phases: [ { name: 'analysis', agent: 'architect', status: 'pending' }, { name: 'implementation', agent: 'developer', status: 'pending' }, { name: 'testing', agent: 'test_engineer', status: 'pending' }, { name: 'deployment', agent: 'devops_engineer', status: 'pending' } ] }; this.activeWorkflows.set(taskId, workflow); await this.executeWorkflow(workflow); return { success: true, message: `Task ${taskId} orchestration completed` }; } catch (error) { log('error', `Failed to orchestrate task ${taskId}: ${error.message}`); throw error; } } async executeWorkflow(workflow) { for (const phase of workflow.phases) { try { // Check agent availability if (this.agentStatuses.get(phase.agent) !== 'active') { throw new Error(`Agent ${phase.agent} is not active`); } // Execute phase phase.status = 'in-progress'; await this.executePhase(workflow.taskId, phase); phase.status = 'completed'; } catch (error) { phase.status = 'failed'; phase.error = error.message; throw error; } } } async executePhase(taskId, phase) { // Implement phase execution logic based on agent type switch (phase.agent) { case 'architect': await this.executeArchitectPhase(taskId); break; case 'developer': await this.executeDeveloperPhase(taskId); break; case 'test_engineer': await this.executeTestPhase(taskId); break; case 'devops_engineer': await this.executeDeploymentPhase(taskId); break; default: throw new Error(`Unknown agent type: ${phase.agent}`); } } // Phase execution methods async executeArchitectPhase(taskId) { // Implement architect phase logic } async executeDeveloperPhase(taskId) { // Implement developer phase logic } async executeTestPhase(taskId) { // Implement test phase logic } async executeDeploymentPhase(taskId) { // Implement deployment phase logic } // Monitoring and metrics async updateMetrics() { const tasksData = await readJSON(`${this.projectRoot}/tasks/tasks.json`); const totalTasks = tasksData.tasks.length; const completedTasks = tasksData.tasks.filter(t => t.status === 'done' || t.status === 'completed' ).length; const metrics = { taskCompletionRate: totalTasks > 0 ? completedTasks / totalTasks : 0, qualityScore: this.calculateQualityScore(), processEfficiency: this.calculateProcessEfficiency() }; await writeJSON(`${this.contextPath}/metrics/current.json`, metrics); } calculateQualityScore() { // Implement quality score calculation return 0; } calculateProcessEfficiency() { // Implement process efficiency calculation return 0; } } export default NeoOrchestrator;