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.
Files changed (202) hide show
  1. package/README.md +240 -0
  2. package/package.json +10 -2
  3. package/src/agents/Agent.js +300 -0
  4. package/src/agents/AgentAdditionService.js +311 -0
  5. package/src/agents/AgentCheckService.js +690 -0
  6. package/src/agents/AgentInstallationService.js +140 -0
  7. package/src/agents/AgentSetupService.js +467 -0
  8. package/src/agents/AgentStatus.js +183 -0
  9. package/src/agents/AgentVerificationService.js +634 -0
  10. package/src/agents/ConfigurationSchemaValidator.js +543 -0
  11. package/src/agents/EnvironmentConfigurationManager.js +602 -0
  12. package/src/agents/InstallationErrorHandler.js +372 -0
  13. package/src/agents/InstallationLog.js +363 -0
  14. package/src/agents/InstallationMethod.js +510 -0
  15. package/src/agents/InstallationOrchestrator.js +352 -0
  16. package/src/agents/InstallationProgressReporter.js +372 -0
  17. package/src/agents/InstallationRetryManager.js +322 -0
  18. package/src/agents/InstallationType.js +254 -0
  19. package/src/agents/OperationTypes.js +310 -0
  20. package/src/agents/PerformanceMetricsCollector.js +493 -0
  21. package/src/agents/SecurityValidationService.js +534 -0
  22. package/src/agents/VerificationTest.js +354 -0
  23. package/src/agents/VerificationType.js +226 -0
  24. package/src/agents/WindowsPermissionHandler.js +518 -0
  25. package/src/agents/config/AgentConfigManager.js +393 -0
  26. package/src/agents/config/AgentDefaultsRegistry.js +373 -0
  27. package/src/agents/config/ConfigValidator.js +281 -0
  28. package/src/agents/discovery/AgentDiscoveryService.js +707 -0
  29. package/src/agents/logging/AgentLogger.js +511 -0
  30. package/src/agents/status/AgentStatusManager.js +481 -0
  31. package/src/agents/storage/FileManager.js +454 -0
  32. package/src/agents/verification/AgentCommunicationTester.js +474 -0
  33. package/src/agents/verification/BaseVerifier.js +430 -0
  34. package/src/agents/verification/CommandVerifier.js +480 -0
  35. package/src/agents/verification/FileOperationVerifier.js +453 -0
  36. package/src/agents/verification/ResultAnalyzer.js +707 -0
  37. package/src/agents/verification/TestRequirementManager.js +495 -0
  38. package/src/agents/verification/VerificationRunner.js +433 -0
  39. package/src/agents/windows/BaseWindowsInstaller.js +441 -0
  40. package/src/agents/windows/ChocolateyInstaller.js +509 -0
  41. package/src/agents/windows/DirectInstaller.js +443 -0
  42. package/src/agents/windows/InstallerFactory.js +391 -0
  43. package/src/agents/windows/NpmInstaller.js +505 -0
  44. package/src/agents/windows/PowerShellInstaller.js +458 -0
  45. package/src/agents/windows/WinGetInstaller.js +390 -0
  46. package/src/analysis/analysis-reporter.js +132 -0
  47. package/src/analysis/boundary-detector.js +712 -0
  48. package/src/analysis/categorizer.js +340 -0
  49. package/src/analysis/codebase-scanner.js +384 -0
  50. package/src/analysis/line-counter.js +513 -0
  51. package/src/analysis/priority-calculator.js +679 -0
  52. package/src/analysis/report/analysis-report.js +250 -0
  53. package/src/analysis/report/package-analyzer.js +278 -0
  54. package/src/analysis/report/recommendation-generator.js +382 -0
  55. package/src/analysis/report/statistics-generator.js +515 -0
  56. package/src/analysis/reports/analysis-report-model.js +101 -0
  57. package/src/analysis/reports/recommendation-generator.js +283 -0
  58. package/src/analysis/reports/report-generators.js +191 -0
  59. package/src/analysis/reports/statistics-calculator.js +231 -0
  60. package/src/analysis/reports/trend-analyzer.js +219 -0
  61. package/src/analysis/strategy-generator.js +814 -0
  62. package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
  63. package/src/config/refactoring-config.js +307 -0
  64. package/src/health-tracking/json-storage.js +38 -2
  65. package/src/ide-integration/applescript-manager-core.js +233 -0
  66. package/src/ide-integration/applescript-manager.cjs +357 -28
  67. package/src/ide-integration/applescript-manager.js +89 -3599
  68. package/src/ide-integration/cdp-manager.js +306 -0
  69. package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
  70. package/src/ide-integration/continuation-handler.js +337 -0
  71. package/src/ide-integration/ide-status-checker.js +292 -0
  72. package/src/ide-integration/macos-ide-manager.js +627 -0
  73. package/src/ide-integration/macos-text-sender.js +528 -0
  74. package/src/ide-integration/response-reader.js +548 -0
  75. package/src/ide-integration/windows-automation-manager.js +121 -0
  76. package/src/ide-integration/windows-ide-manager.js +373 -0
  77. package/src/index.cjs +25 -3
  78. package/src/index.js +15 -1
  79. package/src/llm/direct-llm-manager.cjs +90 -2
  80. package/src/models/compliance-report.js +538 -0
  81. package/src/models/file-analysis.js +681 -0
  82. package/src/models/refactoring-plan.js +770 -0
  83. package/src/monitoring/alert-system.js +834 -0
  84. package/src/monitoring/compliance-progress-tracker.js +437 -0
  85. package/src/monitoring/continuous-scan-notifications.js +661 -0
  86. package/src/monitoring/continuous-scanner.js +279 -0
  87. package/src/monitoring/file-monitor/file-analyzer.js +262 -0
  88. package/src/monitoring/file-monitor/file-monitor.js +237 -0
  89. package/src/monitoring/file-monitor/watcher.js +194 -0
  90. package/src/monitoring/file-monitor.js +17 -0
  91. package/src/monitoring/notification-manager.js +437 -0
  92. package/src/monitoring/scanner-core.js +368 -0
  93. package/src/monitoring/scanner-events.js +214 -0
  94. package/src/monitoring/violation-notification-system.js +515 -0
  95. package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
  96. package/src/refactoring/boundaries/extraction-result.js +285 -0
  97. package/src/refactoring/boundaries/extraction-strategies.js +392 -0
  98. package/src/refactoring/boundaries/module-boundary.js +209 -0
  99. package/src/refactoring/boundary/boundary-detector.js +741 -0
  100. package/src/refactoring/boundary/boundary-types.js +405 -0
  101. package/src/refactoring/boundary/extraction-strategies.js +554 -0
  102. package/src/refactoring/boundary-extraction-result.js +77 -0
  103. package/src/refactoring/boundary-extraction-strategies.js +330 -0
  104. package/src/refactoring/boundary-extractor.js +384 -0
  105. package/src/refactoring/boundary-types.js +46 -0
  106. package/src/refactoring/circular/circular-dependency.js +88 -0
  107. package/src/refactoring/circular/cycle-detection.js +147 -0
  108. package/src/refactoring/circular/dependency-node.js +82 -0
  109. package/src/refactoring/circular/dependency-result.js +107 -0
  110. package/src/refactoring/circular/dependency-types.js +58 -0
  111. package/src/refactoring/circular/graph-builder.js +213 -0
  112. package/src/refactoring/circular/resolution-strategy.js +72 -0
  113. package/src/refactoring/circular/strategy-generator.js +229 -0
  114. package/src/refactoring/circular-dependency-resolver-original.js +809 -0
  115. package/src/refactoring/circular-dependency-resolver.js +200 -0
  116. package/src/refactoring/code-mover.js +761 -0
  117. package/src/refactoring/file-splitter.js +696 -0
  118. package/src/refactoring/functionality-validator.js +816 -0
  119. package/src/refactoring/import-manager.js +774 -0
  120. package/src/refactoring/module-boundary.js +107 -0
  121. package/src/refactoring/refactoring-executor.js +672 -0
  122. package/src/refactoring/refactoring-rollback.js +614 -0
  123. package/src/refactoring/test-validator.js +631 -0
  124. package/src/requirement-management/default-requirement-manager.js +321 -0
  125. package/src/requirement-management/requirement-file-parser.js +159 -0
  126. package/src/requirement-management/requirement-sequencer.js +221 -0
  127. package/src/rui/commands/AgentCommandParser.js +600 -0
  128. package/src/rui/commands/AgentCommands.js +487 -0
  129. package/src/rui/commands/AgentResponseFormatter.js +832 -0
  130. package/src/scripts/verify-full-compliance.js +269 -0
  131. package/src/sync/sync-engine-core.js +1 -0
  132. package/src/sync/sync-engine-remote-handlers.js +135 -0
  133. package/src/task-generation/automated-task-generator.js +351 -0
  134. package/src/task-generation/prioritizer.js +287 -0
  135. package/src/task-generation/task-list-updater.js +215 -0
  136. package/src/task-generation/task-management-integration.js +480 -0
  137. package/src/task-generation/task-manager-integration.js +270 -0
  138. package/src/task-generation/violation-task-generator.js +474 -0
  139. package/src/task-management/continuous-scan-integration.js +342 -0
  140. package/src/timeout-management/index.js +12 -3
  141. package/src/timeout-management/response-time-tracker.js +167 -0
  142. package/src/timeout-management/timeout-calculator.js +159 -0
  143. package/src/timeout-management/timeout-config-manager.js +172 -0
  144. package/src/utils/ast-analyzer.js +417 -0
  145. package/src/utils/current-requirement-manager.js +276 -0
  146. package/src/utils/current-requirement-operations.js +472 -0
  147. package/src/utils/dependency-mapper.js +456 -0
  148. package/src/utils/download-with-progress.js +4 -2
  149. package/src/utils/electron-update-checker.js +4 -1
  150. package/src/utils/file-size-analyzer.js +272 -0
  151. package/src/utils/import-updater.js +280 -0
  152. package/src/utils/refactoring-tools.js +512 -0
  153. package/src/utils/report-generator.js +569 -0
  154. package/src/utils/reports/report-analysis.js +218 -0
  155. package/src/utils/reports/report-types.js +55 -0
  156. package/src/utils/reports/summary-generators.js +102 -0
  157. package/src/utils/requirement-file-management.js +157 -0
  158. package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
  159. package/src/utils/requirement-helpers/requirement-mover.js +414 -0
  160. package/src/utils/requirement-helpers/requirement-parser.js +326 -0
  161. package/src/utils/requirement-helpers/requirement-status.js +320 -0
  162. package/src/utils/requirement-helpers-new.js +55 -0
  163. package/src/utils/requirement-helpers-refactored.js +367 -0
  164. package/src/utils/requirement-helpers.js +291 -1191
  165. package/src/utils/requirement-movement-operations.js +450 -0
  166. package/src/utils/requirement-movement.js +312 -0
  167. package/src/utils/requirement-parsing-helpers.js +56 -0
  168. package/src/utils/requirement-statistics.js +200 -0
  169. package/src/utils/requirement-text-utils.js +58 -0
  170. package/src/utils/rollback/rollback-handlers.js +125 -0
  171. package/src/utils/rollback/rollback-operation.js +63 -0
  172. package/src/utils/rollback/rollback-recorder.js +166 -0
  173. package/src/utils/rollback/rollback-state-manager.js +175 -0
  174. package/src/utils/rollback/rollback-types.js +33 -0
  175. package/src/utils/rollback/rollback-utils.js +110 -0
  176. package/src/utils/rollback-manager-original.js +569 -0
  177. package/src/utils/rollback-manager.js +202 -0
  178. package/src/utils/smoke-test-cli.js +362 -0
  179. package/src/utils/smoke-test-gui.js +351 -0
  180. package/src/utils/smoke-test-orchestrator.js +321 -0
  181. package/src/utils/smoke-test-runner.js +60 -0
  182. package/src/utils/smoke-test-web.js +347 -0
  183. package/src/utils/specification-helpers.js +39 -13
  184. package/src/utils/specification-migration.js +97 -0
  185. package/src/utils/test-runner.js +579 -0
  186. package/src/utils/validation-framework.js +518 -0
  187. package/src/validation/compliance-analyzer.js +197 -0
  188. package/src/validation/compliance-report-generator.js +343 -0
  189. package/src/validation/compliance-reporter.js +711 -0
  190. package/src/validation/compliance-rules.js +127 -0
  191. package/src/validation/constitution-validator-new.js +196 -0
  192. package/src/validation/constitution-validator.js +17 -0
  193. package/src/validation/file-validators.js +170 -0
  194. package/src/validation/line-limit/file-analyzer.js +201 -0
  195. package/src/validation/line-limit/line-limit-validator.js +208 -0
  196. package/src/validation/line-limit/validation-result.js +144 -0
  197. package/src/validation/line-limit-core.js +225 -0
  198. package/src/validation/line-limit-reporter.js +134 -0
  199. package/src/validation/line-limit-result.js +125 -0
  200. package/src/validation/line-limit-validator.js +41 -0
  201. package/src/validation/metrics-calculator.js +660 -0
  202. package/src/sync/sync-engine-backup.js +0 -559
@@ -0,0 +1,351 @@
1
+ /**
2
+ * Automated Task Generator
3
+ *
4
+ * Automatically generates refactoring tasks for new file size violations
5
+ * and integrates them into the task management system.
6
+ */
7
+
8
+ const fs = require('fs').promises;
9
+ const path = require('path');
10
+ const TaskManagerIntegration = require('./task-manager-integration');
11
+ const violationTaskGenerator = require('./violation-task-generator');
12
+ const prioritizer = require('./prioritizer');
13
+
14
+ class AutomatedTaskGenerator {
15
+ constructor(options = {}) {
16
+ this.taskManager = new TaskManagerIntegration(options);
17
+ this.autoGenerate = options.autoGenerate !== false;
18
+ this.notificationThreshold = options.notificationThreshold || 5;
19
+ this.taskTemplate = options.taskTemplate || this.getDefaultTaskTemplate();
20
+ }
21
+
22
+ /**
23
+ * Automatically generate tasks for new violations
24
+ */
25
+ async generateTasksForViolations(violations, options = {}) {
26
+ if (!this.autoGenerate && !options.force) {
27
+ console.log('Auto-generation disabled. Use --force to override.');
28
+ return { generated: 0, tasks: [] };
29
+ }
30
+
31
+ try {
32
+ console.log(`🤖 Auto-generating tasks for ${violations.length} violations...`);
33
+
34
+ // Generate tasks for each violation
35
+ const generatedTasks = [];
36
+ let taskId = this.getNextTaskId();
37
+
38
+ for (const violation of violations) {
39
+ const task = await this.generateTaskForViolation(violation, taskId);
40
+ generatedTasks.push(task);
41
+ taskId++;
42
+ }
43
+
44
+ // Prioritize tasks
45
+ const prioritizedTasks = this.prioritizeGeneratedTasks(generatedTasks);
46
+
47
+ // Integrate with task manager
48
+ const integrationResult = await this.taskManager.integrateScanResults(
49
+ { violations },
50
+ { autoGenerate: true, ...options }
51
+ );
52
+
53
+ // Send notifications if threshold exceeded
54
+ if (violations.length >= this.notificationThreshold) {
55
+ await this.sendViolationNotification(violations.length, prioritizedTasks);
56
+ }
57
+
58
+ return {
59
+ generated: generatedTasks.length,
60
+ tasks: prioritizedTasks,
61
+ integrationResult,
62
+ summary: this.generateSummary(violations, prioritizedTasks)
63
+ };
64
+
65
+ } catch (error) {
66
+ console.error('Automated task generation failed:', error);
67
+ throw error;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Generate a single task for a violation
73
+ */
74
+ async generateTaskForViolation(violation, taskId) {
75
+ const priority = prioritizer.calculatePriority(violation);
76
+ const refactoringStrategy = this.determineRefactoringStrategy(violation);
77
+ const estimatedEffort = this.estimateEffort(violation);
78
+
79
+ return {
80
+ id: `T${String(taskId).padStart(3, '0')}`,
81
+ priority: priority.level,
82
+ priorityLabel: priority.label,
83
+ description: this.generateTaskDescription(violation, refactoringStrategy),
84
+ filePath: violation.filePath,
85
+ lineCount: violation.lineCount,
86
+ violationType: this.categorizeViolation(violation),
87
+ refactoringStrategy,
88
+ estimatedEffort,
89
+ dependencies: this.identifyDependencies(violation),
90
+ generatedAt: new Date().toISOString(),
91
+ autoGenerated: true
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Generate task description based on violation analysis
97
+ */
98
+ generateTaskDescription(violation, strategy) {
99
+ const action = strategy.suggestedAction;
100
+ const target = this.extractTargetName(violation.filePath);
101
+
102
+ return `Refactor ${target} - ${action} (${violation.lineCount} lines)`;
103
+ }
104
+
105
+ /**
106
+ * Determine refactoring strategy for a violation
107
+ */
108
+ determineRefactoringStrategy(violation) {
109
+ const strategies = {
110
+ 'component': {
111
+ suggestedAction: 'split into component modules',
112
+ approach: 'component-extraction',
113
+ difficulty: 'medium'
114
+ },
115
+ 'utility': {
116
+ suggestedAction: 'extract utility functions',
117
+ approach: 'utility-extraction',
118
+ difficulty: 'low'
119
+ },
120
+ 'handler': {
121
+ suggestedAction: 'split into event handlers',
122
+ approach: 'handler-separation',
123
+ difficulty: 'medium'
124
+ },
125
+ 'config': {
126
+ suggestedAction: 'extract configuration data',
127
+ approach: 'config-extraction',
128
+ difficulty: 'low'
129
+ },
130
+ 'mixed': {
131
+ suggestedAction: 'refactor into logical modules',
132
+ approach: 'modular-refactoring',
133
+ difficulty: 'high'
134
+ }
135
+ };
136
+
137
+ const category = this.categorizeViolation(violation);
138
+ return strategies[category] || strategies.mixed;
139
+ }
140
+
141
+ /**
142
+ * Categorize violation type based on file path and content analysis
143
+ */
144
+ categorizeViolation(violation) {
145
+ const filePath = violation.filePath.toLowerCase();
146
+
147
+ if (filePath.includes('component') || filePath.includes('.jsx') || filePath.includes('.tsx')) {
148
+ return 'component';
149
+ }
150
+ if (filePath.includes('util') || filePath.includes('helper')) {
151
+ return 'utility';
152
+ }
153
+ if (filePath.includes('handler') || filePath.includes('event')) {
154
+ return 'handler';
155
+ }
156
+ if (filePath.includes('config') || filePath.includes('setting')) {
157
+ return 'config';
158
+ }
159
+
160
+ return 'mixed';
161
+ }
162
+
163
+ /**
164
+ * Estimate effort for refactoring
165
+ */
166
+ estimateEffort(violation) {
167
+ const baseEffort = Math.ceil(violation.lineCount / 100); // Base effort per 100 lines
168
+ const complexityMultiplier = this.getComplexityMultiplier(violation);
169
+
170
+ return {
171
+ hours: baseEffort * complexityMultiplier,
172
+ complexity: this.getComplexityLevel(violation),
173
+ confidence: this.getConfidenceLevel(violation)
174
+ };
175
+ }
176
+
177
+ /**
178
+ * Get complexity multiplier based on file characteristics
179
+ */
180
+ getComplexityMultiplier(violation) {
181
+ let multiplier = 1.0;
182
+
183
+ // Increase complexity for very large files
184
+ if (violation.lineCount > 2000) multiplier += 0.5;
185
+ if (violation.lineCount > 5000) multiplier += 0.5;
186
+
187
+ // Increase complexity for certain file types
188
+ if (violation.filePath.includes('integration') || violation.filePath.includes('e2e')) {
189
+ multiplier += 0.3;
190
+ }
191
+
192
+ return multiplier;
193
+ }
194
+
195
+ /**
196
+ * Get complexity level
197
+ */
198
+ getComplexityLevel(violation) {
199
+ if (violation.lineCount > 5000) return 'very-high';
200
+ if (violation.lineCount > 2000) return 'high';
201
+ if (violation.lineCount > 1000) return 'medium';
202
+ return 'low';
203
+ }
204
+
205
+ /**
206
+ * Get confidence level for automated analysis
207
+ */
208
+ getConfidenceLevel(violation) {
209
+ // Higher confidence for files with clear patterns
210
+ if (this.hasClearPatterns(violation)) return 'high';
211
+ if (violation.lineCount < 1000) return 'medium';
212
+ return 'low';
213
+ }
214
+
215
+ /**
216
+ * Check if file has clear refactoring patterns
217
+ */
218
+ hasClearPatterns(violation) {
219
+ const patterns = [
220
+ /export\s+function\s+\w+/g, // Multiple function exports
221
+ /class\s+\w+\s*{/g, // Multiple class definitions
222
+ /const\s+\w+\s*=\s*\(/g, // Multiple component definitions
223
+ ];
224
+
225
+ // This would need actual file content analysis
226
+ // For now, return true for common patterns
227
+ return violation.filePath.includes('component') ||
228
+ violation.filePath.includes('util');
229
+ }
230
+
231
+ /**
232
+ * Identify dependencies for the task
233
+ */
234
+ identifyDependencies(violation) {
235
+ const dependencies = [];
236
+
237
+ // Core infrastructure dependencies
238
+ dependencies.push('T001', 'T002', 'T003', 'T004', 'T005'); // Setup tasks
239
+
240
+ // Analysis dependencies
241
+ dependencies.push('T011', 'T012', 'T013', 'T014'); // Analysis tools
242
+
243
+ // Refactoring tool dependencies
244
+ dependencies.push('T022', 'T023', 'T024', 'T025'); // Refactoring tools
245
+
246
+ return dependencies;
247
+ }
248
+
249
+ /**
250
+ * Prioritize generated tasks
251
+ */
252
+ prioritizeGeneratedTasks(tasks) {
253
+ return tasks.sort((a, b) => {
254
+ // Sort by priority first
255
+ const priorityOrder = { 'critical': 0, 'high': 1, 'medium': 2, 'low': 3 };
256
+ const aPriority = priorityOrder[a.priority] || 999;
257
+ const bPriority = priorityOrder[b.priority] || 999;
258
+
259
+ if (aPriority !== bPriority) {
260
+ return aPriority - bPriority;
261
+ }
262
+
263
+ // Then by line count (larger files first)
264
+ return b.lineCount - a.lineCount;
265
+ });
266
+ }
267
+
268
+ /**
269
+ * Get next task ID
270
+ */
271
+ getNextTaskId() {
272
+ // This would scan the current tasks file to find the highest ID
273
+ // For now, return a default starting point
274
+ return 99; // Starting after existing tasks
275
+ }
276
+
277
+ /**
278
+ * Extract target name from file path
279
+ */
280
+ extractTargetName(filePath) {
281
+ const parts = filePath.split('/');
282
+ const fileName = parts[parts.length - 1];
283
+ return fileName.replace(/\.(js|jsx|ts|tsx)$/, '');
284
+ }
285
+
286
+ /**
287
+ * Generate summary of task generation
288
+ */
289
+ generateSummary(violations, tasks) {
290
+ const priorityCounts = tasks.reduce((acc, task) => {
291
+ acc[task.priority] = (acc[task.priority] || 0) + 1;
292
+ return acc;
293
+ }, {});
294
+
295
+ return {
296
+ totalViolations: violations.length,
297
+ totalTasks: tasks.length,
298
+ priorityBreakdown: priorityCounts,
299
+ averageLineCount: violations.reduce((sum, v) => sum + v.lineCount, 0) / violations.length,
300
+ estimatedTotalHours: tasks.reduce((sum, task) => sum + task.estimatedEffort.hours, 0)
301
+ };
302
+ }
303
+
304
+ /**
305
+ * Send notification for high volume of violations
306
+ */
307
+ async sendViolationNotification(violationCount, tasks) {
308
+ const message = `🚨 High volume of violations detected: ${violationCount} files need refactoring\n` +
309
+ `Generated ${tasks.length} tasks with priority breakdown:\n` +
310
+ `- Critical: ${tasks.filter(t => t.priority === 'critical').length}\n` +
311
+ `- High: ${tasks.filter(t => t.priority === 'high').length}\n` +
312
+ `- Medium: ${tasks.filter(t => t.priority === 'medium').length}\n` +
313
+ `- Low: ${tasks.filter(t => t.priority === 'low').length}`;
314
+
315
+ console.log(message);
316
+
317
+ // Could integrate with email, Slack, or other notification systems
318
+ if (this.notificationCallback) {
319
+ await this.notificationCallback(message);
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Get default task template
325
+ */
326
+ getDefaultTaskTemplate() {
327
+ return `- [ ] [ID] [P?] [Story?] Description with file path`;
328
+ }
329
+
330
+ /**
331
+ * Set notification callback
332
+ */
333
+ setNotificationCallback(callback) {
334
+ this.notificationCallback = callback;
335
+ }
336
+
337
+ /**
338
+ * Get generation statistics
339
+ */
340
+ async getGenerationStats() {
341
+ const status = await this.taskManager.getIntegrationStatus();
342
+
343
+ return {
344
+ ...status,
345
+ autoGenerationEnabled: this.autoGenerate,
346
+ notificationThreshold: this.notificationThreshold
347
+ };
348
+ }
349
+ }
350
+
351
+ module.exports = AutomatedTaskGenerator;
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Violation Prioritizer
3
+ *
4
+ * Prioritizes file violations for refactoring based on multiple factors
5
+ * including severity, impact, and dependencies.
6
+ */
7
+
8
+ const path = require('path');
9
+
10
+ /**
11
+ * Violation prioritizer class
12
+ */
13
+ class ViolationPrioritizer {
14
+ constructor(options = {}) {
15
+ this.options = {
16
+ maxFileSize: options.maxFileSize || 555,
17
+ priorityWeights: {
18
+ size: options.priorityWeights?.size || 0.4, // How much over the limit
19
+ impact: options.priorityWeights?.impact || 0.3, // Impact on system
20
+ complexity: options.priorityWeights?.complexity || 0.2, // Code complexity
21
+ dependencies: options.priorityWeights?.dependencies || 0.1 // Number of dependents
22
+ },
23
+ ...options
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Prioritize violations for refactoring
29
+ */
30
+ prioritizeViolations(violations) {
31
+ const prioritized = violations.map(violation => ({
32
+ ...violation,
33
+ priority: this.calculatePriority(violation),
34
+ priorityScore: this.calculatePriorityScore(violation),
35
+ reasons: this.getPriorityReasons(violation)
36
+ }));
37
+
38
+ // Sort by priority score (highest first)
39
+ prioritized.sort((a, b) => b.priorityScore - a.priorityScore);
40
+
41
+ return {
42
+ violations: prioritized,
43
+ summary: this.generatePrioritySummary(prioritized),
44
+ recommendations: this.generateRecommendations(prioritized)
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Calculate priority for a violation
50
+ */
51
+ calculatePriority(violation) {
52
+ const score = this.calculatePriorityScore(violation);
53
+
54
+ if (score >= 80) return 'P1'; // Critical
55
+ if (score >= 60) return 'P2'; // High
56
+ if (score >= 40) return 'P3'; // Medium
57
+ return 'P4'; // Low
58
+ }
59
+
60
+ /**
61
+ * Calculate priority score (0-100)
62
+ */
63
+ calculatePriorityScore(violation) {
64
+ let score = 0;
65
+
66
+ // Size factor (0-40 points)
67
+ const sizeFactor = this.calculateSizeFactor(violation);
68
+ score += sizeFactor * this.options.priorityWeights.size;
69
+
70
+ // Impact factor (0-30 points)
71
+ const impactFactor = this.calculateImpactFactor(violation);
72
+ score += impactFactor * this.options.priorityWeights.impact;
73
+
74
+ // Complexity factor (0-20 points)
75
+ const complexityFactor = this.calculateComplexityFactor(violation);
76
+ score += complexityFactor * this.options.priorityWeights.complexity;
77
+
78
+ // Dependencies factor (0-10 points)
79
+ const dependenciesFactor = this.calculateDependenciesFactor(violation);
80
+ score += dependenciesFactor * this.options.priorityWeights.dependencies;
81
+
82
+ return Math.min(100, Math.round(score));
83
+ }
84
+
85
+ /**
86
+ * Calculate size factor based on how much the file exceeds the limit
87
+ */
88
+ calculateSizeFactor(violation) {
89
+ if (!violation.lineCount || !violation.limit) return 0;
90
+
91
+ const excess = violation.lineCount - violation.limit;
92
+ const excessPercentage = (excess / violation.limit) * 100;
93
+
94
+ if (excessPercentage >= 200) return 40; // 3x+ the limit
95
+ if (excessPercentage >= 100) return 35; // 2x the limit
96
+ if (excessPercentage >= 50) return 30; // 1.5x the limit
97
+ if (excessPercentage >= 25) return 25; // 1.25x the limit
98
+ if (excessPercentage >= 10) return 20; // 1.1x the limit
99
+ if (excessPercentage >= 5) return 15; // Just over limit
100
+ return 10; // Slightly over limit
101
+ }
102
+
103
+ /**
104
+ * Calculate impact factor based on file type and location
105
+ */
106
+ calculateImpactFactor(violation) {
107
+ const filePath = violation.filePath;
108
+
109
+ // Core files have highest impact
110
+ if (filePath.includes('/packages/core/')) {
111
+ if (filePath.includes('/src/validation/') || filePath.includes('/src/analysis/')) {
112
+ return 30; // Core validation/analysis files
113
+ }
114
+ if (filePath.includes('/src/rui/') || filePath.includes('/src/commands/')) {
115
+ return 25; // Core RUI and command files
116
+ }
117
+ return 20; // Other core files
118
+ }
119
+
120
+ // CLI files
121
+ if (filePath.includes('/packages/cli/')) {
122
+ if (filePath.includes('/commands/') || filePath.includes('/utils/')) {
123
+ return 20; // CLI commands and utilities
124
+ }
125
+ return 15; // Other CLI files
126
+ }
127
+
128
+ // Electron app files
129
+ if (filePath.includes('/packages/electron-app/')) {
130
+ if (filePath.includes('/src/main/') || filePath.includes('/src/ui/')) {
131
+ return 18; // Main process and UI files
132
+ }
133
+ return 12; // Other Electron files
134
+ }
135
+
136
+ // Other packages
137
+ if (filePath.includes('/packages/web/') || filePath.includes('/packages/admin/')) {
138
+ return 10; // Web and admin packages
139
+ }
140
+
141
+ return 5; // Other files
142
+ }
143
+
144
+ /**
145
+ * Calculate complexity factor based on file characteristics
146
+ */
147
+ calculateComplexityFactor(violation) {
148
+ let complexity = 0;
149
+
150
+ // More lines generally means more complexity
151
+ if (violation.lineCount > 2000) complexity += 20;
152
+ else if (violation.lineCount > 1500) complexity += 18;
153
+ else if (violation.lineCount > 1000) complexity += 15;
154
+ else if (violation.lineCount > 750) complexity += 12;
155
+ else if (violation.lineCount > 600) complexity += 8;
156
+ else complexity += 5;
157
+
158
+ // File extension indicates complexity
159
+ const ext = path.extname(violation.filePath);
160
+ if (['.js', '.jsx', '.ts', '.tsx'].includes(ext)) {
161
+ complexity += 5; // JavaScript/TypeScript can be complex
162
+ }
163
+
164
+ // Directory structure indicates complexity
165
+ if (violation.filePath.includes('/src/') && violation.filePath.includes('/test/')) {
166
+ complexity += 3; // Test files
167
+ }
168
+
169
+ return Math.min(20, complexity);
170
+ }
171
+
172
+ /**
173
+ * Calculate dependencies factor
174
+ */
175
+ calculateDependenciesFactor(violation) {
176
+ // This is a simplified calculation
177
+ // In a real implementation, you would analyze import statements
178
+
179
+ let dependencies = 0;
180
+
181
+ // Files in core likely have more dependents
182
+ if (violation.filePath.includes('/packages/core/')) {
183
+ dependencies += 8;
184
+ }
185
+
186
+ // Utility files likely have more dependents
187
+ if (violation.filePath.includes('/utils/')) {
188
+ dependencies += 6;
189
+ }
190
+
191
+ // Main entry points have more dependents
192
+ if (violation.filePath.includes('index.js') || violation.filePath.includes('app.js')) {
193
+ dependencies += 10;
194
+ }
195
+
196
+ return Math.min(10, dependencies);
197
+ }
198
+
199
+ /**
200
+ * Get reasons for the priority assignment
201
+ */
202
+ getPriorityReasons(violation) {
203
+ const reasons = [];
204
+
205
+ if (violation.lineCount > violation.limit * 2) {
206
+ reasons.push(`File is ${Math.round((violation.lineCount / violation.limit) * 100)}% over the limit`);
207
+ }
208
+
209
+ if (violation.filePath.includes('/packages/core/')) {
210
+ reasons.push('Core package file - high impact');
211
+ }
212
+
213
+ if (violation.filePath.includes('/validation/') || violation.filePath.includes('/analysis/')) {
214
+ reasons.push('Critical system component');
215
+ }
216
+
217
+ if (violation.lineCount > 1000) {
218
+ reasons.push('Very large file - complex refactoring needed');
219
+ }
220
+
221
+ return reasons;
222
+ }
223
+
224
+ /**
225
+ * Generate priority summary
226
+ */
227
+ generatePrioritySummary(prioritizedViolations) {
228
+ const summary = {
229
+ total: prioritizedViolations.length,
230
+ byPriority: {
231
+ P1: 0,
232
+ P2: 0,
233
+ P3: 0,
234
+ P4: 0
235
+ },
236
+ averageScore: 0,
237
+ topViolations: prioritizedViolations.slice(0, 5)
238
+ };
239
+
240
+ prioritizedViolations.forEach(violation => {
241
+ summary.byPriority[violation.priority]++;
242
+ });
243
+
244
+ if (prioritizedViolations.length > 0) {
245
+ const totalScore = prioritizedViolations.reduce((sum, v) => sum + v.priorityScore, 0);
246
+ summary.averageScore = Math.round(totalScore / prioritizedViolations.length);
247
+ }
248
+
249
+ return summary;
250
+ }
251
+
252
+ /**
253
+ * Generate recommendations based on priorities
254
+ */
255
+ generateRecommendations(prioritizedViolations) {
256
+ const recommendations = [];
257
+
258
+ const p1Count = prioritizedViolations.filter(v => v.priority === 'P1').length;
259
+ const p2Count = prioritizedViolations.filter(v => v.priority === 'P2').length;
260
+
261
+ if (p1Count > 0) {
262
+ recommendations.push(`Address ${p1Count} P1 (Critical) violations first - these significantly exceed limits`);
263
+ }
264
+
265
+ if (p2Count > 0) {
266
+ recommendations.push(`Focus on ${p2Count} P2 (High) violations next - these impact core functionality`);
267
+ }
268
+
269
+ // Recommend batch processing
270
+ if (prioritizedViolations.length > 10) {
271
+ recommendations.push('Consider processing violations in batches of 5-10 files to manage complexity');
272
+ }
273
+
274
+ // Recommend parallel processing
275
+ const independentFiles = prioritizedViolations.filter(v =>
276
+ !v.filePath.includes('/packages/core/') || v.filePath.includes('/utils/')
277
+ );
278
+
279
+ if (independentFiles.length > 3) {
280
+ recommendations.push(`${independentFiles.length} files can be refactored in parallel`);
281
+ }
282
+
283
+ return recommendations;
284
+ }
285
+ }
286
+
287
+ module.exports = ViolationPrioritizer;