| |
| |
| |
|
|
| class PhaseAnalyzer {
|
| constructor() {
|
| this.version = '1.0.0';
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| analyze(tasks, files) {
|
| const phases = this.identifyPhases(tasks, files);
|
| const dependencies = this.analyzeDependencies(phases);
|
| const timeline = this.estimateTimeline(phases);
|
| const completionMetrics = this.calculatePhaseCompletion(phases);
|
|
|
| return {
|
| phases,
|
| dependencies,
|
| timeline,
|
| completionMetrics,
|
| summary: this.generatePhaseSummary(phases)
|
| };
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| identifyPhases(tasks, files) {
|
| const phases = [];
|
|
|
|
|
| phases.push({
|
| id: 1,
|
| name: 'Setup & Infrastructure',
|
| description: 'Establish project foundation, configuration, and dependencies',
|
| status: this.determinePhaseStatus(tasks, ['setup', 'config', 'infrastructure']),
|
| tasks: tasks.filter(t => this.isSetupTask(t)),
|
| estimatedDays: 3,
|
| priority: 'HIGH',
|
| blockers: []
|
| });
|
|
|
|
|
| phases.push({
|
| id: 2,
|
| name: 'Core Implementation',
|
| description: 'Implement main business logic and core features',
|
| status: this.determinePhaseStatus(tasks, ['implementation', 'feature', 'core']),
|
| tasks: tasks.filter(t => this.isCoreTask(t)),
|
| estimatedDays: 10,
|
| priority: 'CRITICAL',
|
| blockers: ['Phase 1']
|
| });
|
|
|
|
|
| phases.push({
|
| id: 3,
|
| name: 'Testing & Quality Assurance',
|
| description: 'Comprehensive testing, bug fixes, and quality improvements',
|
| status: this.determinePhaseStatus(tasks, ['test', 'quality', 'bug']),
|
| tasks: tasks.filter(t => this.isTestingTask(t)),
|
| estimatedDays: 5,
|
| priority: 'HIGH',
|
| blockers: ['Phase 2']
|
| });
|
|
|
|
|
| phases.push({
|
| id: 4,
|
| name: 'Documentation & Polish',
|
| description: 'Write documentation, refine UI, and prepare for release',
|
| status: this.determinePhaseStatus(tasks, ['documentation', 'docs', 'polish']),
|
| tasks: tasks.filter(t => this.isDocumentationTask(t)),
|
| estimatedDays: 3,
|
| priority: 'MEDIUM',
|
| blockers: ['Phase 3']
|
| });
|
|
|
|
|
| const migrationTasks = tasks.filter(t => this.isMigrationTask(t));
|
| if (migrationTasks.length > 0) {
|
| phases.push({
|
| id: 5,
|
| name: 'Migration & Refactoring',
|
| description: 'System-wide migration, refactoring, and modernization',
|
| status: this.determinePhaseStatus(tasks, ['migration', 'refactor', 'modernize']),
|
| tasks: migrationTasks,
|
| estimatedDays: 7,
|
| priority: 'HIGH',
|
| blockers: ['Phase 2']
|
| });
|
| }
|
|
|
|
|
| const securityTasks = tasks.filter(t => this.isSecurityTask(t));
|
| if (securityTasks.length > 0) {
|
| phases.push({
|
| id: 6,
|
| name: 'Security & Performance',
|
| description: 'Security hardening, performance optimization, and auditing',
|
| status: this.determinePhaseStatus(tasks, ['security', 'performance', 'optimization']),
|
| tasks: securityTasks,
|
| estimatedDays: 5,
|
| priority: 'CRITICAL',
|
| blockers: ['Phase 3']
|
| });
|
| }
|
|
|
| return phases;
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| determinePhaseStatus(tasks, keywords) {
|
| const phaseTasks = tasks.filter(t => {
|
| const text = `${t.title} ${t.message} ${t.type}`.toLowerCase();
|
| return keywords.some(kw => text.includes(kw));
|
| });
|
|
|
| if (phaseTasks.length === 0) return 'NOT_STARTED';
|
|
|
| const completed = phaseTasks.filter(t => t.completed).length;
|
| const total = phaseTasks.length;
|
| const percentage = (completed / total) * 100;
|
|
|
| if (percentage === 100) return 'COMPLETED';
|
| if (percentage >= 50) return 'IN_PROGRESS';
|
| if (percentage > 0) return 'STARTED';
|
| return 'NOT_STARTED';
|
| }
|
|
|
| |
| |
|
|
| isSetupTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return text.includes('setup') ||
|
| text.includes('config') ||
|
| text.includes('install') ||
|
| text.includes('initialize') ||
|
| text.includes('package.json') ||
|
| text.includes('dependency');
|
| }
|
|
|
| |
| |
|
|
| isCoreTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return text.includes('implement') ||
|
| text.includes('feature') ||
|
| text.includes('function') ||
|
| text.includes('class') ||
|
| text.includes('module') ||
|
| (task.type === 'quality' && !text.includes('test'));
|
| }
|
|
|
| |
| |
|
|
| isTestingTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return text.includes('test') ||
|
| text.includes('bug') ||
|
| text.includes('fix') ||
|
| text.includes('coverage') ||
|
| text.includes('quality');
|
| }
|
|
|
| |
| |
|
|
| isDocumentationTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return text.includes('doc') ||
|
| text.includes('readme') ||
|
| text.includes('comment') ||
|
| text.includes('polish') ||
|
| text.includes('ui') ||
|
| text.includes('ux');
|
| }
|
|
|
| |
| |
|
|
| isMigrationTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return text.includes('migrat') ||
|
| text.includes('refactor') ||
|
| text.includes('moderniz') ||
|
| text.includes('upgrade') ||
|
| text.includes('convert');
|
| }
|
|
|
| |
| |
|
|
| isSecurityTask(task) {
|
| const text = `${task.title} ${task.message} ${task.type}`.toLowerCase();
|
| return task.type === 'security' ||
|
| text.includes('security') ||
|
| text.includes('vulnerab') ||
|
| text.includes('performance') ||
|
| text.includes('optimiz');
|
| }
|
|
|
| |
| |
| |
| |
|
|
| analyzeDependencies(phases) {
|
| const graph = {};
|
|
|
| phases.forEach(phase => {
|
| graph[phase.name] = {
|
| dependsOn: phase.blockers || [],
|
| blockedBy: phases
|
| .filter(p => (p.blockers || []).includes(`Phase ${phase.id}`))
|
| .map(p => p.name)
|
| };
|
| });
|
|
|
| return graph;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| estimateTimeline(phases) {
|
| const today = new Date();
|
| let currentDate = new Date(today);
|
| const schedule = [];
|
|
|
| phases.forEach(phase => {
|
| const startDate = new Date(currentDate);
|
| currentDate.setDate(currentDate.getDate() + phase.estimatedDays);
|
| const endDate = new Date(currentDate);
|
|
|
| schedule.push({
|
| phase: phase.name,
|
| startDate: startDate.toISOString().split('T')[0],
|
| endDate: endDate.toISOString().split('T')[0],
|
| duration: phase.estimatedDays,
|
| status: phase.status
|
| });
|
| });
|
|
|
| const totalDays = phases.reduce((sum, p) => sum + p.estimatedDays, 0);
|
| const completionDate = new Date(today);
|
| completionDate.setDate(completionDate.getDate() + totalDays);
|
|
|
| return {
|
| schedule,
|
| totalDays,
|
| estimatedCompletion: completionDate.toISOString().split('T')[0]
|
| };
|
| }
|
|
|
| |
| |
| |
| |
|
|
| calculatePhaseCompletion(phases) {
|
| const metrics = {
|
| totalPhases: phases.length,
|
| completed: phases.filter(p => p.status === 'COMPLETED').length,
|
| inProgress: phases.filter(p => p.status === 'IN_PROGRESS' || p.status === 'STARTED').length,
|
| notStarted: phases.filter(p => p.status === 'NOT_STARTED').length
|
| };
|
|
|
| metrics.completionPercentage = Math.round((metrics.completed / metrics.totalPhases) * 100);
|
|
|
| return metrics;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| generatePhaseSummary(phases) {
|
| return {
|
| totalPhases: phases.length,
|
| criticalPhases: phases.filter(p => p.priority === 'CRITICAL').length,
|
| totalTasks: phases.reduce((sum, p) => sum + p.tasks.length, 0),
|
| totalDays: phases.reduce((sum, p) => sum + p.estimatedDays, 0),
|
| currentPhase: phases.find(p => p.status === 'IN_PROGRESS' || p.status === 'STARTED')?.name || 'Not Started'
|
| };
|
| }
|
| }
|
|
|
| module.exports = PhaseAnalyzer;
|
|
|