vibecodingmachine-core 2026.2.20-438 → 2026.2.26-1739
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +240 -0
- package/package.json +10 -2
- package/src/agents/Agent.js +300 -0
- package/src/agents/AgentAdditionService.js +311 -0
- package/src/agents/AgentCheckService.js +690 -0
- package/src/agents/AgentInstallationService.js +140 -0
- package/src/agents/AgentSetupService.js +467 -0
- package/src/agents/AgentStatus.js +183 -0
- package/src/agents/AgentVerificationService.js +634 -0
- package/src/agents/ConfigurationSchemaValidator.js +543 -0
- package/src/agents/EnvironmentConfigurationManager.js +602 -0
- package/src/agents/InstallationErrorHandler.js +372 -0
- package/src/agents/InstallationLog.js +363 -0
- package/src/agents/InstallationMethod.js +510 -0
- package/src/agents/InstallationOrchestrator.js +352 -0
- package/src/agents/InstallationProgressReporter.js +372 -0
- package/src/agents/InstallationRetryManager.js +322 -0
- package/src/agents/InstallationType.js +254 -0
- package/src/agents/OperationTypes.js +310 -0
- package/src/agents/PerformanceMetricsCollector.js +493 -0
- package/src/agents/SecurityValidationService.js +534 -0
- package/src/agents/VerificationTest.js +354 -0
- package/src/agents/VerificationType.js +226 -0
- package/src/agents/WindowsPermissionHandler.js +518 -0
- package/src/agents/config/AgentConfigManager.js +393 -0
- package/src/agents/config/AgentDefaultsRegistry.js +373 -0
- package/src/agents/config/ConfigValidator.js +281 -0
- package/src/agents/discovery/AgentDiscoveryService.js +707 -0
- package/src/agents/logging/AgentLogger.js +511 -0
- package/src/agents/status/AgentStatusManager.js +481 -0
- package/src/agents/storage/FileManager.js +454 -0
- package/src/agents/verification/AgentCommunicationTester.js +474 -0
- package/src/agents/verification/BaseVerifier.js +430 -0
- package/src/agents/verification/CommandVerifier.js +480 -0
- package/src/agents/verification/FileOperationVerifier.js +453 -0
- package/src/agents/verification/ResultAnalyzer.js +707 -0
- package/src/agents/verification/TestRequirementManager.js +495 -0
- package/src/agents/verification/VerificationRunner.js +433 -0
- package/src/agents/windows/BaseWindowsInstaller.js +441 -0
- package/src/agents/windows/ChocolateyInstaller.js +509 -0
- package/src/agents/windows/DirectInstaller.js +443 -0
- package/src/agents/windows/InstallerFactory.js +391 -0
- package/src/agents/windows/NpmInstaller.js +505 -0
- package/src/agents/windows/PowerShellInstaller.js +458 -0
- package/src/agents/windows/WinGetInstaller.js +390 -0
- package/src/analysis/analysis-reporter.js +132 -0
- package/src/analysis/boundary-detector.js +712 -0
- package/src/analysis/categorizer.js +340 -0
- package/src/analysis/codebase-scanner.js +384 -0
- package/src/analysis/line-counter.js +513 -0
- package/src/analysis/priority-calculator.js +679 -0
- package/src/analysis/report/analysis-report.js +250 -0
- package/src/analysis/report/package-analyzer.js +278 -0
- package/src/analysis/report/recommendation-generator.js +382 -0
- package/src/analysis/report/statistics-generator.js +515 -0
- package/src/analysis/reports/analysis-report-model.js +101 -0
- package/src/analysis/reports/recommendation-generator.js +283 -0
- package/src/analysis/reports/report-generators.js +191 -0
- package/src/analysis/reports/statistics-calculator.js +231 -0
- package/src/analysis/reports/trend-analyzer.js +219 -0
- package/src/analysis/strategy-generator.js +814 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
- package/src/config/refactoring-config.js +307 -0
- package/src/health-tracking/json-storage.js +38 -2
- package/src/ide-integration/applescript-manager-core.js +233 -0
- package/src/ide-integration/applescript-manager.cjs +357 -28
- package/src/ide-integration/applescript-manager.js +89 -3599
- package/src/ide-integration/cdp-manager.js +306 -0
- package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
- package/src/ide-integration/continuation-handler.js +337 -0
- package/src/ide-integration/ide-status-checker.js +292 -0
- package/src/ide-integration/macos-ide-manager.js +627 -0
- package/src/ide-integration/macos-text-sender.js +528 -0
- package/src/ide-integration/response-reader.js +548 -0
- package/src/ide-integration/windows-automation-manager.js +121 -0
- package/src/ide-integration/windows-ide-manager.js +373 -0
- package/src/index.cjs +25 -3
- package/src/index.js +15 -1
- package/src/llm/direct-llm-manager.cjs +90 -2
- package/src/models/compliance-report.js +538 -0
- package/src/models/file-analysis.js +681 -0
- package/src/models/refactoring-plan.js +770 -0
- package/src/monitoring/alert-system.js +834 -0
- package/src/monitoring/compliance-progress-tracker.js +437 -0
- package/src/monitoring/continuous-scan-notifications.js +661 -0
- package/src/monitoring/continuous-scanner.js +279 -0
- package/src/monitoring/file-monitor/file-analyzer.js +262 -0
- package/src/monitoring/file-monitor/file-monitor.js +237 -0
- package/src/monitoring/file-monitor/watcher.js +194 -0
- package/src/monitoring/file-monitor.js +17 -0
- package/src/monitoring/notification-manager.js +437 -0
- package/src/monitoring/scanner-core.js +368 -0
- package/src/monitoring/scanner-events.js +214 -0
- package/src/monitoring/violation-notification-system.js +515 -0
- package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
- package/src/refactoring/boundaries/extraction-result.js +285 -0
- package/src/refactoring/boundaries/extraction-strategies.js +392 -0
- package/src/refactoring/boundaries/module-boundary.js +209 -0
- package/src/refactoring/boundary/boundary-detector.js +741 -0
- package/src/refactoring/boundary/boundary-types.js +405 -0
- package/src/refactoring/boundary/extraction-strategies.js +554 -0
- package/src/refactoring/boundary-extraction-result.js +77 -0
- package/src/refactoring/boundary-extraction-strategies.js +330 -0
- package/src/refactoring/boundary-extractor.js +384 -0
- package/src/refactoring/boundary-types.js +46 -0
- package/src/refactoring/circular/circular-dependency.js +88 -0
- package/src/refactoring/circular/cycle-detection.js +147 -0
- package/src/refactoring/circular/dependency-node.js +82 -0
- package/src/refactoring/circular/dependency-result.js +107 -0
- package/src/refactoring/circular/dependency-types.js +58 -0
- package/src/refactoring/circular/graph-builder.js +213 -0
- package/src/refactoring/circular/resolution-strategy.js +72 -0
- package/src/refactoring/circular/strategy-generator.js +229 -0
- package/src/refactoring/circular-dependency-resolver-original.js +809 -0
- package/src/refactoring/circular-dependency-resolver.js +200 -0
- package/src/refactoring/code-mover.js +761 -0
- package/src/refactoring/file-splitter.js +696 -0
- package/src/refactoring/functionality-validator.js +816 -0
- package/src/refactoring/import-manager.js +774 -0
- package/src/refactoring/module-boundary.js +107 -0
- package/src/refactoring/refactoring-executor.js +672 -0
- package/src/refactoring/refactoring-rollback.js +614 -0
- package/src/refactoring/test-validator.js +631 -0
- package/src/requirement-management/default-requirement-manager.js +321 -0
- package/src/requirement-management/requirement-file-parser.js +159 -0
- package/src/requirement-management/requirement-sequencer.js +221 -0
- package/src/rui/commands/AgentCommandParser.js +600 -0
- package/src/rui/commands/AgentCommands.js +487 -0
- package/src/rui/commands/AgentResponseFormatter.js +832 -0
- package/src/scripts/verify-full-compliance.js +269 -0
- package/src/sync/sync-engine-core.js +1 -0
- package/src/sync/sync-engine-remote-handlers.js +135 -0
- package/src/task-generation/automated-task-generator.js +351 -0
- package/src/task-generation/prioritizer.js +287 -0
- package/src/task-generation/task-list-updater.js +215 -0
- package/src/task-generation/task-management-integration.js +480 -0
- package/src/task-generation/task-manager-integration.js +270 -0
- package/src/task-generation/violation-task-generator.js +474 -0
- package/src/task-management/continuous-scan-integration.js +342 -0
- package/src/timeout-management/index.js +12 -3
- package/src/timeout-management/response-time-tracker.js +167 -0
- package/src/timeout-management/timeout-calculator.js +159 -0
- package/src/timeout-management/timeout-config-manager.js +172 -0
- package/src/utils/ast-analyzer.js +417 -0
- package/src/utils/current-requirement-manager.js +276 -0
- package/src/utils/current-requirement-operations.js +472 -0
- package/src/utils/dependency-mapper.js +456 -0
- package/src/utils/download-with-progress.js +4 -2
- package/src/utils/electron-update-checker.js +4 -1
- package/src/utils/file-size-analyzer.js +272 -0
- package/src/utils/import-updater.js +280 -0
- package/src/utils/refactoring-tools.js +512 -0
- package/src/utils/report-generator.js +569 -0
- package/src/utils/reports/report-analysis.js +218 -0
- package/src/utils/reports/report-types.js +55 -0
- package/src/utils/reports/summary-generators.js +102 -0
- package/src/utils/requirement-file-management.js +157 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
- package/src/utils/requirement-helpers/requirement-mover.js +414 -0
- package/src/utils/requirement-helpers/requirement-parser.js +326 -0
- package/src/utils/requirement-helpers/requirement-status.js +320 -0
- package/src/utils/requirement-helpers-new.js +55 -0
- package/src/utils/requirement-helpers-refactored.js +367 -0
- package/src/utils/requirement-helpers.js +291 -1191
- package/src/utils/requirement-movement-operations.js +450 -0
- package/src/utils/requirement-movement.js +312 -0
- package/src/utils/requirement-parsing-helpers.js +56 -0
- package/src/utils/requirement-statistics.js +200 -0
- package/src/utils/requirement-text-utils.js +58 -0
- package/src/utils/rollback/rollback-handlers.js +125 -0
- package/src/utils/rollback/rollback-operation.js +63 -0
- package/src/utils/rollback/rollback-recorder.js +166 -0
- package/src/utils/rollback/rollback-state-manager.js +175 -0
- package/src/utils/rollback/rollback-types.js +33 -0
- package/src/utils/rollback/rollback-utils.js +110 -0
- package/src/utils/rollback-manager-original.js +569 -0
- package/src/utils/rollback-manager.js +202 -0
- package/src/utils/smoke-test-cli.js +362 -0
- package/src/utils/smoke-test-gui.js +351 -0
- package/src/utils/smoke-test-orchestrator.js +321 -0
- package/src/utils/smoke-test-runner.js +60 -0
- package/src/utils/smoke-test-web.js +347 -0
- package/src/utils/specification-helpers.js +39 -13
- package/src/utils/specification-migration.js +97 -0
- package/src/utils/test-runner.js +579 -0
- package/src/utils/validation-framework.js +518 -0
- package/src/validation/compliance-analyzer.js +197 -0
- package/src/validation/compliance-report-generator.js +343 -0
- package/src/validation/compliance-reporter.js +711 -0
- package/src/validation/compliance-rules.js +127 -0
- package/src/validation/constitution-validator-new.js +196 -0
- package/src/validation/constitution-validator.js +17 -0
- package/src/validation/file-validators.js +170 -0
- package/src/validation/line-limit/file-analyzer.js +201 -0
- package/src/validation/line-limit/line-limit-validator.js +208 -0
- package/src/validation/line-limit/validation-result.js +144 -0
- package/src/validation/line-limit-core.js +225 -0
- package/src/validation/line-limit-reporter.js +134 -0
- package/src/validation/line-limit-result.js +125 -0
- package/src/validation/line-limit-validator.js +41 -0
- package/src/validation/metrics-calculator.js +660 -0
- package/src/sync/sync-engine-backup.js +0 -559
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task List Updater
|
|
3
|
+
*
|
|
4
|
+
* Dynamically updates the tasks.md file with new refactoring tasks
|
|
5
|
+
* for files that violate the 555-line limit and other requirements.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const ViolationTaskGenerator = require('./violation-task-generator');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Task list updater class
|
|
14
|
+
*/
|
|
15
|
+
class TaskListUpdater {
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.options = {
|
|
18
|
+
tasksFilePath: options.tasksFilePath || path.resolve(__dirname, '../../../specs/010-555-max-file-size/tasks.md'),
|
|
19
|
+
maxFileSize: options.maxFileSize || 555,
|
|
20
|
+
backupOriginal: options.backupOriginal !== false,
|
|
21
|
+
...options
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
this.taskGenerator = new ViolationTaskGenerator(this.options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Update the tasks file with new violation tasks
|
|
29
|
+
*/
|
|
30
|
+
async updateTasks(violations) {
|
|
31
|
+
try {
|
|
32
|
+
// Read the current tasks file
|
|
33
|
+
const currentContent = fs.readFileSync(this.options.tasksFilePath, 'utf8');
|
|
34
|
+
|
|
35
|
+
// Create backup if requested
|
|
36
|
+
if (this.options.backupOriginal) {
|
|
37
|
+
const backupPath = this.options.tasksFilePath + '.backup';
|
|
38
|
+
fs.writeFileSync(backupPath, currentContent);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Generate new tasks for violations
|
|
42
|
+
const newTasks = this.taskGenerator.generateTasks(violations);
|
|
43
|
+
|
|
44
|
+
// Find where to insert the new tasks
|
|
45
|
+
const insertionPoint = this.findInsertionPoint(currentContent);
|
|
46
|
+
|
|
47
|
+
// Insert the new tasks
|
|
48
|
+
const updatedContent = this.insertTasks(currentContent, newTasks, insertionPoint);
|
|
49
|
+
|
|
50
|
+
// Write the updated content
|
|
51
|
+
fs.writeFileSync(this.options.tasksFilePath, updatedContent);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
success: true,
|
|
55
|
+
tasksAdded: newTasks.length,
|
|
56
|
+
violationsProcessed: violations.length,
|
|
57
|
+
backupCreated: this.options.backupOriginal
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw new Error(`Failed to update tasks file: ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Find the appropriate insertion point in the tasks file
|
|
67
|
+
*/
|
|
68
|
+
findInsertionPoint(content) {
|
|
69
|
+
// Look for the end of User Story 4 implementation section
|
|
70
|
+
const userStory4Section = content.match(/## Phase 6: User Story 4.*?### Implementation for User Story 4\s*\n([\s\S]*?)(?=\n##|\n---|$)/);
|
|
71
|
+
|
|
72
|
+
if (userStory4Section) {
|
|
73
|
+
const implementationContent = userStory4Section[1];
|
|
74
|
+
|
|
75
|
+
// Find the last task in User Story 4
|
|
76
|
+
const taskMatches = implementationContent.match(/- \[ \] T\d+.*$/gm);
|
|
77
|
+
|
|
78
|
+
if (taskMatches && taskMatches.length > 0) {
|
|
79
|
+
const lastTask = taskMatches[taskMatches.length - 1];
|
|
80
|
+
const lastTaskIndex = implementationContent.lastIndexOf(lastTask);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
section: userStory4Section.index,
|
|
84
|
+
implementationStart: userStory4Section.index + userStory4Section[0].indexOf(implementationContent),
|
|
85
|
+
insertAfter: userStory4Section.index + userStory4Section[0].indexOf(implementationContent) + lastTaskIndex + lastTask.length
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fallback: insert before the next section or end of file
|
|
91
|
+
const nextSection = content.indexOf('\n---', content.indexOf('## Phase 6'));
|
|
92
|
+
return {
|
|
93
|
+
insertAfter: nextSection !== -1 ? nextSection : content.length
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Insert new tasks into the content
|
|
99
|
+
*/
|
|
100
|
+
insertTasks(content, newTasks, insertionPoint) {
|
|
101
|
+
if (newTasks.length === 0) {
|
|
102
|
+
return content;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const before = content.substring(0, insertionPoint.insertAfter);
|
|
106
|
+
const after = content.substring(insertionPoint.insertAfter);
|
|
107
|
+
|
|
108
|
+
const tasksText = newTasks.map(task => `- [ ] ${task.id} ${task.priority ? '[P] ' : ''}[${task.story}] ${task.description}`).join('\n');
|
|
109
|
+
|
|
110
|
+
return before + '\n' + tasksText + '\n' + after;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check if a task already exists for a file
|
|
115
|
+
*/
|
|
116
|
+
taskExists(filePath) {
|
|
117
|
+
try {
|
|
118
|
+
const content = fs.readFileSync(this.options.tasksFilePath, 'utf8');
|
|
119
|
+
return content.includes(filePath);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get current task statistics
|
|
127
|
+
*/
|
|
128
|
+
getTaskStats() {
|
|
129
|
+
try {
|
|
130
|
+
const content = fs.readFileSync(this.options.tasksFilePath, 'utf8');
|
|
131
|
+
|
|
132
|
+
const totalTasks = (content.match(/- \[.\] T\d+/g) || []).length;
|
|
133
|
+
const completedTasks = (content.match(/- \[x\] T\d+/g) || []).length;
|
|
134
|
+
const pendingTasks = totalTasks - completedTasks;
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
total: totalTasks,
|
|
138
|
+
completed: completedTasks,
|
|
139
|
+
pending: pendingTasks,
|
|
140
|
+
completionPercentage: totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return {
|
|
145
|
+
total: 0,
|
|
146
|
+
completed: 0,
|
|
147
|
+
pending: 0,
|
|
148
|
+
completionPercentage: 0,
|
|
149
|
+
error: error.message
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Update task completion status
|
|
156
|
+
*/
|
|
157
|
+
updateTaskStatus(taskId, completed) {
|
|
158
|
+
try {
|
|
159
|
+
const content = fs.readFileSync(this.options.tasksFilePath, 'utf8');
|
|
160
|
+
|
|
161
|
+
// Find and replace the task checkbox
|
|
162
|
+
const taskPattern = new RegExp(`(- \\[)(${completed ? ' ' : 'x'})(\\] ${taskId})`, 'g');
|
|
163
|
+
const updatedContent = content.replace(taskPattern, `$1${completed ? 'x' : ' '}$3`);
|
|
164
|
+
|
|
165
|
+
if (updatedContent !== content) {
|
|
166
|
+
fs.writeFileSync(this.options.tasksFilePath, updatedContent);
|
|
167
|
+
return { success: true, updated: true };
|
|
168
|
+
} else {
|
|
169
|
+
return { success: true, updated: false, message: 'Task not found' };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw new Error(`Failed to update task status: ${error.message}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Validate the tasks file structure
|
|
179
|
+
*/
|
|
180
|
+
validateTasksFile() {
|
|
181
|
+
try {
|
|
182
|
+
const content = fs.readFileSync(this.options.tasksFilePath, 'utf8');
|
|
183
|
+
|
|
184
|
+
const issues = [];
|
|
185
|
+
|
|
186
|
+
// Check for required sections
|
|
187
|
+
if (!content.includes('## Phase 6: User Story 4')) {
|
|
188
|
+
issues.push('Missing Phase 6: User Story 4 section');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!content.includes('### Implementation for User Story 4')) {
|
|
192
|
+
issues.push('Missing Implementation for User Story 4 section');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Check task format
|
|
196
|
+
const invalidTasks = content.match(/- \[.\] [^T\d]/g) || [];
|
|
197
|
+
if (invalidTasks.length > 0) {
|
|
198
|
+
issues.push(`Found ${invalidTasks.length} tasks with invalid format`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
valid: issues.length === 0,
|
|
203
|
+
issues
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
} catch (error) {
|
|
207
|
+
return {
|
|
208
|
+
valid: false,
|
|
209
|
+
issues: [`Failed to read tasks file: ${error.message}`]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
module.exports = TaskListUpdater;
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Management Integration
|
|
3
|
+
*
|
|
4
|
+
* Integrates continuous scanning with the task management system
|
|
5
|
+
* to provide automated task generation and tracking.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const EventEmitter = require('events');
|
|
9
|
+
const { ContinuousScanner } = require('../monitoring/continuous-scanner');
|
|
10
|
+
const { TaskListUpdater } = require('./task-list-updater');
|
|
11
|
+
const { ViolationTaskGenerator } = require('./violation-task-generator');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Task Management Integration class
|
|
15
|
+
*/
|
|
16
|
+
class TaskManagementIntegration extends EventEmitter {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
this.options = {
|
|
21
|
+
// Scanner configuration
|
|
22
|
+
scanIntervalMs: options.scanIntervalMs || 60000,
|
|
23
|
+
maxFileSize: options.maxFileSize || 555,
|
|
24
|
+
watchPaths: options.watchPaths || [process.cwd()],
|
|
25
|
+
|
|
26
|
+
// Task generation configuration
|
|
27
|
+
autoGenerateTasks: options.autoGenerateTasks !== false,
|
|
28
|
+
autoMarkCompleted: options.autoMarkCompleted !== false,
|
|
29
|
+
taskUpdateDelay: options.taskUpdateDelay || 5000, // 5 seconds
|
|
30
|
+
|
|
31
|
+
// Integration settings
|
|
32
|
+
enableRealTimeUpdates: options.enableRealTimeUpdates !== false,
|
|
33
|
+
batchTaskUpdates: options.batchTaskUpdates !== false,
|
|
34
|
+
maxBatchSize: options.maxBatchSize || 10,
|
|
35
|
+
|
|
36
|
+
...options
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Components
|
|
40
|
+
this.scanner = null;
|
|
41
|
+
this.taskUpdater = new TaskListUpdater();
|
|
42
|
+
this.taskGenerator = new ViolationTaskGenerator();
|
|
43
|
+
|
|
44
|
+
// State
|
|
45
|
+
this.isRunning = false;
|
|
46
|
+
this.pendingTaskUpdates = new Map(); // filePath -> violation
|
|
47
|
+
this.taskUpdateTimer = null;
|
|
48
|
+
|
|
49
|
+
// Statistics
|
|
50
|
+
this.stats = {
|
|
51
|
+
totalViolationsDetected: 0,
|
|
52
|
+
totalTasksGenerated: 0,
|
|
53
|
+
totalTasksCompleted: 0,
|
|
54
|
+
totalViolationsResolved: 0,
|
|
55
|
+
startTime: new Date(),
|
|
56
|
+
lastTaskGeneration: null,
|
|
57
|
+
lastTaskCompletion: null
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Start the integrated system
|
|
63
|
+
*/
|
|
64
|
+
async start() {
|
|
65
|
+
if (this.isRunning) {
|
|
66
|
+
throw new Error('Task management integration is already running');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('🚀 Starting task management integration...');
|
|
70
|
+
|
|
71
|
+
// Initialize scanner
|
|
72
|
+
this.scanner = new ContinuousScanner({
|
|
73
|
+
scanIntervalMs: this.options.scanIntervalMs,
|
|
74
|
+
maxFileSize: this.options.maxFileSize,
|
|
75
|
+
watchPaths: this.options.watchPaths,
|
|
76
|
+
enableFileWatching: true
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Setup event listeners
|
|
80
|
+
this.setupScannerListeners();
|
|
81
|
+
|
|
82
|
+
// Start scanner
|
|
83
|
+
await this.scanner.start();
|
|
84
|
+
|
|
85
|
+
// Start batch processing if enabled
|
|
86
|
+
if (this.options.batchTaskUpdates) {
|
|
87
|
+
this.startBatchProcessing();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.isRunning = true;
|
|
91
|
+
this.emit('started');
|
|
92
|
+
|
|
93
|
+
console.log('✅ Task management integration started');
|
|
94
|
+
console.log(` Auto-generate tasks: ${this.options.autoGenerateTasks}`);
|
|
95
|
+
console.log(` Real-time updates: ${this.options.enableRealTimeUpdates}`);
|
|
96
|
+
console.log(` Batch processing: ${this.options.batchTaskUpdates}`);
|
|
97
|
+
|
|
98
|
+
return { success: true, started: true };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Stop the integrated system
|
|
103
|
+
*/
|
|
104
|
+
async stop() {
|
|
105
|
+
if (!this.isRunning) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log('🛑 Stopping task management integration...');
|
|
110
|
+
|
|
111
|
+
this.isRunning = false;
|
|
112
|
+
|
|
113
|
+
// Stop scanner
|
|
114
|
+
if (this.scanner) {
|
|
115
|
+
this.scanner.stop();
|
|
116
|
+
this.scanner = null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Stop batch processing
|
|
120
|
+
if (this.taskUpdateTimer) {
|
|
121
|
+
clearInterval(this.taskUpdateTimer);
|
|
122
|
+
this.taskUpdateTimer = null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Process any remaining pending updates
|
|
126
|
+
if (this.options.enableRealTimeUpdates && this.pendingTaskUpdates.size > 0) {
|
|
127
|
+
await this.processPendingUpdates();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
this.emit('stopped');
|
|
131
|
+
|
|
132
|
+
console.log('✅ Task management integration stopped');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Setup scanner event listeners
|
|
137
|
+
*/
|
|
138
|
+
setupScannerListeners() {
|
|
139
|
+
if (!this.scanner) return;
|
|
140
|
+
|
|
141
|
+
// Handle new violations
|
|
142
|
+
this.scanner.on('violationDetected', async (event) => {
|
|
143
|
+
await this.handleViolationDetected(event);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Handle resolved violations
|
|
147
|
+
this.scanner.on('violationResolved', async (event) => {
|
|
148
|
+
await this.handleViolationResolved(event);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Handle scan completion
|
|
152
|
+
this.scanner.on('scanCompleted', async (event) => {
|
|
153
|
+
await this.handleScanCompleted(event);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Handle scanner errors
|
|
157
|
+
this.scanner.on('scanError', (error) => {
|
|
158
|
+
this.emit('error', error);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Handle violation detected event
|
|
164
|
+
*/
|
|
165
|
+
async handleViolationDetected(event) {
|
|
166
|
+
const { filePath, result, eventType } = event;
|
|
167
|
+
|
|
168
|
+
this.stats.totalViolationsDetected++;
|
|
169
|
+
|
|
170
|
+
console.log(`🚨 Violation detected: ${filePath} (${result.lineCount} lines)`);
|
|
171
|
+
|
|
172
|
+
if (this.options.autoGenerateTasks) {
|
|
173
|
+
if (this.options.enableRealTimeUpdates) {
|
|
174
|
+
// Real-time task generation
|
|
175
|
+
await this.generateTaskForViolation(result);
|
|
176
|
+
} else {
|
|
177
|
+
// Batch task generation
|
|
178
|
+
this.pendingTaskUpdates.set(filePath, result);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.emit('violationDetected', event);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Handle violation resolved event
|
|
187
|
+
*/
|
|
188
|
+
async handleViolationResolved(event) {
|
|
189
|
+
const { filePath, result, previousResult } = event;
|
|
190
|
+
|
|
191
|
+
this.stats.totalViolationsResolved++;
|
|
192
|
+
|
|
193
|
+
console.log(`✅ Violation resolved: ${filePath}`);
|
|
194
|
+
|
|
195
|
+
if (this.options.autoMarkCompleted) {
|
|
196
|
+
await this.markTaskCompleted(filePath);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.emit('violationResolved', event);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Handle scan completed event
|
|
204
|
+
*/
|
|
205
|
+
async handleScanCompleted(event) {
|
|
206
|
+
const { results, scanTime, stats } = event;
|
|
207
|
+
const violations = results.filter(r => r.hasViolations);
|
|
208
|
+
|
|
209
|
+
console.log(`🔍 Scan completed: ${violations.length} violations found`);
|
|
210
|
+
|
|
211
|
+
// Process any pending updates if not using real-time
|
|
212
|
+
if (!this.options.enableRealTimeUpdates && this.pendingTaskUpdates.size > 0) {
|
|
213
|
+
await this.processPendingUpdates();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
this.emit('scanCompleted', event);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Generate task for a single violation
|
|
221
|
+
*/
|
|
222
|
+
async generateTaskForViolation(violation) {
|
|
223
|
+
try {
|
|
224
|
+
const result = await this.taskUpdater.updateTasksWithViolations([violation]);
|
|
225
|
+
|
|
226
|
+
if (result.success && result.tasksAdded > 0) {
|
|
227
|
+
this.stats.totalTasksGenerated += result.tasksAdded;
|
|
228
|
+
this.stats.lastTaskGeneration = new Date();
|
|
229
|
+
|
|
230
|
+
console.log(`📝 Generated ${result.tasksAdded} task(s) for ${violation.filePath}`);
|
|
231
|
+
|
|
232
|
+
this.emit('taskGenerated', {
|
|
233
|
+
filePath: violation.filePath,
|
|
234
|
+
tasksAdded: result.tasksAdded,
|
|
235
|
+
totalTasks: result.totalTasks
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error(`❌ Failed to generate task for ${violation.filePath}:`, error.message);
|
|
242
|
+
this.emit('error', error);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return { success: false, tasksAdded: 0 };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Mark task as completed for a file
|
|
250
|
+
*/
|
|
251
|
+
async markTaskCompleted(filePath) {
|
|
252
|
+
try {
|
|
253
|
+
// Load current tasks to find task for this file
|
|
254
|
+
const currentTasks = await this.taskUpdater.loadCurrentTasks();
|
|
255
|
+
const taskForFile = currentTasks.find(task => task.description.includes(filePath));
|
|
256
|
+
|
|
257
|
+
if (taskForFile && !taskForFile.completed) {
|
|
258
|
+
const result = await this.taskUpdater.markTaskCompleted(taskForFile.id);
|
|
259
|
+
|
|
260
|
+
if (result.success) {
|
|
261
|
+
this.stats.totalTasksCompleted++;
|
|
262
|
+
this.stats.lastTaskCompletion = new Date();
|
|
263
|
+
|
|
264
|
+
console.log(`✅ Marked task ${taskForFile.id} as completed for ${filePath}`);
|
|
265
|
+
|
|
266
|
+
this.emit('taskCompleted', {
|
|
267
|
+
filePath,
|
|
268
|
+
taskId: taskForFile.id,
|
|
269
|
+
totalCompleted: this.stats.totalTasksCompleted
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error(`❌ Failed to mark task completed for ${filePath}:`, error.message);
|
|
277
|
+
this.emit('error', error);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { success: false };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Start batch processing
|
|
285
|
+
*/
|
|
286
|
+
startBatchProcessing() {
|
|
287
|
+
this.taskUpdateTimer = setInterval(async () => {
|
|
288
|
+
if (this.pendingTaskUpdates.size > 0) {
|
|
289
|
+
await this.processPendingUpdates();
|
|
290
|
+
}
|
|
291
|
+
}, this.options.taskUpdateDelay);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Process pending task updates
|
|
296
|
+
*/
|
|
297
|
+
async processPendingUpdates() {
|
|
298
|
+
if (this.pendingTaskUpdates.size === 0) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
console.log(`📋 Processing ${this.pendingTaskUpdates.size} pending task updates...`);
|
|
303
|
+
|
|
304
|
+
const violations = Array.from(this.pendingTaskUpdates.values());
|
|
305
|
+
this.pendingTaskUpdates.clear();
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
// Batch process violations
|
|
309
|
+
const batchSize = Math.min(violations.length, this.options.maxBatchSize);
|
|
310
|
+
const batches = [];
|
|
311
|
+
|
|
312
|
+
for (let i = 0; i < violations.length; i += batchSize) {
|
|
313
|
+
batches.push(violations.slice(i, i + batchSize));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
let totalTasksGenerated = 0;
|
|
317
|
+
|
|
318
|
+
for (const batch of batches) {
|
|
319
|
+
const result = await this.taskUpdater.updateTasksWithViolations(batch);
|
|
320
|
+
|
|
321
|
+
if (result.success) {
|
|
322
|
+
totalTasksGenerated += result.tasksAdded;
|
|
323
|
+
|
|
324
|
+
if (result.tasksAdded > 0) {
|
|
325
|
+
console.log(`📝 Generated ${result.tasksAdded} tasks in batch`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (totalTasksGenerated > 0) {
|
|
331
|
+
this.stats.totalTasksGenerated += totalTasksGenerated;
|
|
332
|
+
this.stats.lastTaskGeneration = new Date();
|
|
333
|
+
|
|
334
|
+
this.emit('batchTaskGenerated', {
|
|
335
|
+
violationsProcessed: violations.length,
|
|
336
|
+
tasksGenerated: totalTasksGenerated
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error('❌ Failed to process pending updates:', error.message);
|
|
342
|
+
this.emit('error', error);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get integration statistics
|
|
348
|
+
*/
|
|
349
|
+
getStats() {
|
|
350
|
+
const uptime = Date.now() - this.stats.startTime.getTime();
|
|
351
|
+
|
|
352
|
+
return {
|
|
353
|
+
...this.stats,
|
|
354
|
+
uptime,
|
|
355
|
+
isRunning: this.isRunning,
|
|
356
|
+
pendingUpdates: this.pendingTaskUpdates.size,
|
|
357
|
+
violationsPerHour: this.stats.totalViolationsDetected / (uptime / 1000 / 60 / 60) || 0,
|
|
358
|
+
tasksPerHour: this.stats.totalTasksGenerated / (uptime / 1000 / 60 / 60) || 0,
|
|
359
|
+
completionRate: this.stats.totalViolationsDetected > 0
|
|
360
|
+
? (this.stats.totalViolationsResolved / this.stats.totalViolationsDetected * 100).toFixed(1)
|
|
361
|
+
: 0
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Get current status
|
|
367
|
+
*/
|
|
368
|
+
async getStatus() {
|
|
369
|
+
const stats = this.getStats();
|
|
370
|
+
const scannerStats = this.scanner ? this.scanner.getStats() : null;
|
|
371
|
+
const taskStats = await this.taskUpdater.getTaskStatistics();
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
integration: {
|
|
375
|
+
isRunning: this.isRunning,
|
|
376
|
+
uptime: stats.uptime,
|
|
377
|
+
autoGenerateTasks: this.options.autoGenerateTasks,
|
|
378
|
+
realTimeUpdates: this.options.enableRealTimeUpdates,
|
|
379
|
+
batchProcessing: this.options.batchTaskUpdates
|
|
380
|
+
},
|
|
381
|
+
statistics: stats,
|
|
382
|
+
scanner: scannerStats,
|
|
383
|
+
tasks: taskStats
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Force task generation for all current violations
|
|
389
|
+
*/
|
|
390
|
+
async generateTasksForAllViolations() {
|
|
391
|
+
if (!this.scanner) {
|
|
392
|
+
throw new Error('Scanner not initialized');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
console.log('🔨 Generating tasks for all current violations...');
|
|
396
|
+
|
|
397
|
+
const violations = this.scanner.getViolations();
|
|
398
|
+
|
|
399
|
+
if (violations.length === 0) {
|
|
400
|
+
console.log('✅ No violations found');
|
|
401
|
+
return { success: true, tasksGenerated: 0 };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const result = await this.taskUpdater.updateTasksWithViolations(violations);
|
|
405
|
+
|
|
406
|
+
if (result.success) {
|
|
407
|
+
this.stats.totalTasksGenerated += result.tasksAdded;
|
|
408
|
+
console.log(`✅ Generated ${result.tasksAdded} tasks for ${violations.length} violations`);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Mark all resolved violations as completed
|
|
416
|
+
*/
|
|
417
|
+
async markResolvedViolationsCompleted() {
|
|
418
|
+
if (!this.scanner) {
|
|
419
|
+
throw new Error('Scanner not initialized');
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
console.log('✅ Marking resolved violations as completed...');
|
|
423
|
+
|
|
424
|
+
// Get current violations and tasks
|
|
425
|
+
const currentViolations = new Set(
|
|
426
|
+
this.scanner.getViolations().map(v => v.filePath)
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
const currentTasks = await this.taskUpdater.loadCurrentTasks();
|
|
430
|
+
const completedTasks = [];
|
|
431
|
+
|
|
432
|
+
for (const task of currentTasks) {
|
|
433
|
+
if (task.completed) continue;
|
|
434
|
+
|
|
435
|
+
// Extract file path from task description
|
|
436
|
+
const filePathMatch = task.description.match(/([^\\]+)\(\d+ lines\)/);
|
|
437
|
+
if (filePathMatch) {
|
|
438
|
+
const filePath = filePathMatch[1].trim();
|
|
439
|
+
|
|
440
|
+
// If file is not in current violations, mark as completed
|
|
441
|
+
if (!currentViolations.has(filePath)) {
|
|
442
|
+
const result = await this.taskUpdater.markTaskCompleted(task.id);
|
|
443
|
+
if (result.success) {
|
|
444
|
+
completedTasks.push(task.id);
|
|
445
|
+
this.stats.totalTasksCompleted++;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
console.log(`✅ Marked ${completedTasks.length} tasks as completed`);
|
|
452
|
+
|
|
453
|
+
return {
|
|
454
|
+
success: true,
|
|
455
|
+
tasksCompleted: completedTasks.length,
|
|
456
|
+
taskIds: completedTasks
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Export integration data
|
|
462
|
+
*/
|
|
463
|
+
exportData() {
|
|
464
|
+
return {
|
|
465
|
+
metadata: {
|
|
466
|
+
exportedAt: new Date().toISOString(),
|
|
467
|
+
integrationVersion: '1.0.0',
|
|
468
|
+
options: this.options
|
|
469
|
+
},
|
|
470
|
+
statistics: this.getStats(),
|
|
471
|
+
pendingUpdates: Array.from(this.pendingTaskUpdates.entries()).map(([filePath, violation]) => ({
|
|
472
|
+
filePath,
|
|
473
|
+
lineCount: violation.lineCount,
|
|
474
|
+
detectedAt: violation.scannedAt
|
|
475
|
+
}))
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
module.exports = TaskManagementIntegration;
|