vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850

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 (192) hide show
  1. package/package.json +1 -1
  2. package/src/agents/AgentCheckDiscoveryService.js +180 -0
  3. package/src/agents/AgentCheckService.js +18 -261
  4. package/src/agents/AgentCheckStatisticsService.js +195 -0
  5. package/src/agents/EnvironmentConfigurationManager.js +31 -380
  6. package/src/agents/InstallationType.js +19 -6
  7. package/src/agents/SimpleAgentCheckService.js +472 -0
  8. package/src/agents/config-managers/ConfigUtils.js +72 -0
  9. package/src/agents/config-managers/DefaultConfig.js +58 -0
  10. package/src/agents/config-managers/EnvVarLoader.js +66 -0
  11. package/src/agents/config-managers/FileConfigLoader.js +124 -0
  12. package/src/agents/config-managers/TypeConverters.js +61 -0
  13. package/src/agents/config-managers/VariableMappings.js +92 -0
  14. package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
  15. package/src/agents/discovery/AgentDiscoveryService.js +29 -403
  16. package/src/agents/discovery/agent-validator.js +262 -0
  17. package/src/agents/discovery/discovery-results.js +176 -0
  18. package/src/agents/discovery/discovery-scanner.js +268 -0
  19. package/src/agents/discovery/discovery-utils.js +161 -0
  20. package/src/agents/discovery/executable-analyzer.js +290 -0
  21. package/src/agents/discovery/history-manager.js +310 -0
  22. package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
  23. package/src/agents/verification/ResultAnalyzer.js +30 -431
  24. package/src/agents/verification/analysis-utils.js +310 -0
  25. package/src/agents/verification/batch-analyzer.js +440 -0
  26. package/src/agents/verification/pattern-recognizer.js +369 -0
  27. package/src/agents/verification/report-generator.js +320 -0
  28. package/src/agents/verification/test-analyzer.js +290 -0
  29. package/src/agents/windows/InstallerFactory.js +4 -0
  30. package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
  31. package/src/analysis/analysis-engine.js +314 -0
  32. package/src/analysis/ast-analyzer.js +342 -0
  33. package/src/analysis/boundary-detector-refactored.js +378 -0
  34. package/src/analysis/boundary-detector.js +200 -603
  35. package/src/analysis/boundary-scanner.js +609 -0
  36. package/src/analysis/boundary-types.js +118 -0
  37. package/src/analysis/boundary-utils.js +293 -0
  38. package/src/analysis/deadline-priority-calculator.js +18 -0
  39. package/src/analysis/detection-methods.js +347 -0
  40. package/src/analysis/importance-priority-calculator.js +18 -0
  41. package/src/analysis/priority/factor-calculators.js +204 -0
  42. package/src/analysis/priority/factor-helpers.js +71 -0
  43. package/src/analysis/priority/priority-constants.js +73 -0
  44. package/src/analysis/priority/priority-factor-calculators.js +301 -0
  45. package/src/analysis/priority/reasons-generator.js +44 -0
  46. package/src/analysis/priority-calculator.js +15 -580
  47. package/src/analysis/strategy-generator.js +16 -66
  48. package/src/analysis/type-priority-calculator.js +18 -0
  49. package/src/analysis/urgency-priority-calculator.js +18 -0
  50. package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
  51. package/src/commands/disable-requirement.js +60 -0
  52. package/src/commands/disable-spec.js +60 -0
  53. package/src/commands/enable-requirement.js +60 -0
  54. package/src/commands/enable-spec.js +60 -0
  55. package/src/commands/registry.js +1 -6
  56. package/src/commands/requirements.js +8 -2
  57. package/src/ide-integration/applescript-manager.cjs +9 -24
  58. package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
  59. package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
  60. package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
  61. package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
  62. package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
  63. package/src/ide-integration/cdp-manager.js +28 -573
  64. package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
  65. package/src/ide-integration/ide-openers/claude-opener.js +171 -0
  66. package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
  67. package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
  68. package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
  69. package/src/ide-integration/macos-ide-manager.js +20 -582
  70. package/src/ide-integration/macos-quota-checker.js +164 -0
  71. package/src/ide-integration/macos-text-sender.js +19 -38
  72. package/src/ide-integration/provider-manager.cjs +52 -7
  73. package/src/index.cjs +6 -0
  74. package/src/index.js +10 -0
  75. package/src/llm/direct-llm-manager.cjs +501 -0
  76. package/src/localization/translations/en-part1.js +363 -0
  77. package/src/localization/translations/en-part2.js +320 -0
  78. package/src/localization/translations/en.js +4 -687
  79. package/src/localization/translations/es-part1.js +363 -0
  80. package/src/localization/translations/es-part2.js +320 -0
  81. package/src/localization/translations/es.js +4 -688
  82. package/src/models/file-analysis-collection.js +139 -0
  83. package/src/models/file-analysis-metrics.js +50 -0
  84. package/src/models/file-analysis.js +15 -262
  85. package/src/models/plan-manager.js +410 -0
  86. package/src/models/refactoring-models.js +380 -0
  87. package/src/models/refactoring-plan-refactored.js +81 -0
  88. package/src/models/refactoring-plan.js +2 -663
  89. package/src/monitoring/alert-system.js +4 -45
  90. package/src/monitoring/continuous-scan-notifications.js +37 -191
  91. package/src/monitoring/notification-handlers/base-handler.js +58 -0
  92. package/src/monitoring/notification-handlers/error-handler.js +36 -0
  93. package/src/monitoring/notification-handlers/index.js +21 -0
  94. package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
  95. package/src/monitoring/notification-handlers/progress-handler.js +48 -0
  96. package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
  97. package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
  98. package/src/provider-registry.js +8 -0
  99. package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
  100. package/src/refactoring/boundary/boundary-detector.js +26 -596
  101. package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
  102. package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
  103. package/src/refactoring/boundary/detectors/class-detector.js +247 -0
  104. package/src/refactoring/boundary/detectors/config-detector.js +270 -0
  105. package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
  106. package/src/refactoring/boundary/detectors/function-detector.js +248 -0
  107. package/src/refactoring/boundary/detectors/module-detector.js +249 -0
  108. package/src/refactoring/boundary/detectors/object-detector.js +247 -0
  109. package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
  110. package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
  111. package/src/refactoring/circular-dependency-resolver-original.js +16 -76
  112. package/src/refactoring/code-mover-refactored.js +309 -0
  113. package/src/refactoring/code-mover.js +48 -355
  114. package/src/refactoring/execution-status.js +18 -0
  115. package/src/refactoring/execution-strategies.js +172 -0
  116. package/src/refactoring/file-splitter-core.js +568 -0
  117. package/src/refactoring/file-splitter-types.js +136 -0
  118. package/src/refactoring/file-splitter.js +2 -682
  119. package/src/refactoring/functionality-validator.js +11 -51
  120. package/src/refactoring/import-manager-refactored.js +385 -0
  121. package/src/refactoring/import-manager.js +112 -487
  122. package/src/refactoring/import-models.js +189 -0
  123. package/src/refactoring/import-parser.js +306 -0
  124. package/src/refactoring/move-executor.js +431 -0
  125. package/src/refactoring/move-utils.js +368 -0
  126. package/src/refactoring/operation-executor.js +76 -0
  127. package/src/refactoring/plan-creator.js +36 -0
  128. package/src/refactoring/plan-executor.js +143 -0
  129. package/src/refactoring/plan-validator.js +68 -0
  130. package/src/refactoring/refactoring-executor-result.js +70 -0
  131. package/src/refactoring/refactoring-executor.js +34 -569
  132. package/src/refactoring/refactoring-operation.js +94 -0
  133. package/src/refactoring/refactoring-plan.js +69 -0
  134. package/src/refactoring/refactoring-rollback.js +22 -527
  135. package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
  136. package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
  137. package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
  138. package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
  139. package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
  140. package/src/refactoring/test-validator.js +32 -448
  141. package/src/refactoring/validation/baseline-runner.js +71 -0
  142. package/src/refactoring/validation/report-generator.js +136 -0
  143. package/src/refactoring/validation/result-comparator.js +92 -0
  144. package/src/refactoring/validation/test-suite.js +59 -0
  145. package/src/refactoring/validation/test-validation-result.js +83 -0
  146. package/src/refactoring/validation/validation-runner.js +95 -0
  147. package/src/refactoring/validation/validation-status.js +18 -0
  148. package/src/rui/commands/AgentCommandParser.js +60 -369
  149. package/src/rui/commands/AgentResponseFormatter.js +7 -47
  150. package/src/rui/commands/parsers/CommandMapper.js +148 -0
  151. package/src/rui/commands/parsers/CommandValidator.js +228 -0
  152. package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
  153. package/src/rui/commands/parsers/TokenParser.js +69 -0
  154. package/src/rui/commands/parsers/tokenizer.js +153 -0
  155. package/src/utils/current-requirement-operations.js +50 -1
  156. package/src/utils/report-generator.js +18 -514
  157. package/src/utils/report-generators/analysis-generator.js +115 -0
  158. package/src/utils/report-generators/base-generator.js +141 -0
  159. package/src/utils/report-generators/compliance-generator.js +41 -0
  160. package/src/utils/report-generators/format-handlers.js +185 -0
  161. package/src/utils/report-generators/refactoring-generator.js +46 -0
  162. package/src/utils/report-generators/validation-generator.js +63 -0
  163. package/src/utils/requirement-enable-disable.js +265 -0
  164. package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
  165. package/src/utils/requirement-helpers/requirement-mover.js +88 -1
  166. package/src/utils/requirement-helpers.js +5 -2
  167. package/src/utils/smoke-test-cli.js +45 -8
  168. package/src/utils/specification-enable-disable.js +122 -0
  169. package/src/utils/specification-helpers.js +30 -4
  170. package/src/utils/specification-migration.js +5 -5
  171. package/src/utils/test-comparator.js +118 -0
  172. package/src/utils/test-config.js +54 -0
  173. package/src/utils/test-executor.js +133 -0
  174. package/src/utils/test-parser.js +215 -0
  175. package/src/utils/test-runner-baseline.js +63 -0
  176. package/src/utils/test-runner-core.js +98 -0
  177. package/src/utils/test-runner-report.js +39 -0
  178. package/src/utils/test-runner-validation.js +71 -0
  179. package/src/utils/test-runner.js +11 -535
  180. package/src/validation/comparison-analyzer.js +333 -0
  181. package/src/validation/compliance-reporter-new.js +282 -0
  182. package/src/validation/compliance-reporter-refactored.js +344 -0
  183. package/src/validation/compliance-reporter.js +278 -591
  184. package/src/validation/compliance-utils.js +278 -0
  185. package/src/validation/html-generator.js +446 -0
  186. package/src/validation/metrics/category-calculator.js +137 -0
  187. package/src/validation/metrics/metrics-helpers.js +155 -0
  188. package/src/validation/metrics/overview-calculator.js +85 -0
  189. package/src/validation/metrics/overview-metrics.js +41 -0
  190. package/src/validation/metrics/quality-calculator.js +166 -0
  191. package/src/validation/metrics/size-calculator.js +69 -0
  192. package/src/validation/metrics-calculator.js +27 -551
@@ -0,0 +1,139 @@
1
+ /**
2
+ * File analysis collection model - holds multiple FileAnalysis instances.
3
+ */
4
+
5
+ const { FileAnalysis } = require('./file-analysis');
6
+
7
+ class FileAnalysisCollection {
8
+ constructor() {
9
+ this.analyses = new Map();
10
+ this.metadata = {
11
+ createdAt: new Date().toISOString(),
12
+ version: '1.0.0',
13
+ totalFiles: 0,
14
+ totalLines: 0
15
+ };
16
+ }
17
+
18
+ add(analysis) {
19
+ if (!(analysis instanceof FileAnalysis)) {
20
+ throw new Error('Analysis must be a FileAnalysis instance');
21
+ }
22
+ this.analyses.set(analysis.filePath, analysis);
23
+ this.updateMetadata();
24
+ }
25
+
26
+ get(filePath) {
27
+ return this.analyses.get(filePath);
28
+ }
29
+
30
+ remove(filePath) {
31
+ const removed = this.analyses.delete(filePath);
32
+ if (removed) this.updateMetadata();
33
+ return removed;
34
+ }
35
+
36
+ getAll() {
37
+ return Array.from(this.analyses.values());
38
+ }
39
+
40
+ getByPackage(packageName) {
41
+ return this.getAll().filter(analysis => analysis.package === packageName);
42
+ }
43
+
44
+ getNeedingRefactoring() {
45
+ return this.getAll().filter(analysis => analysis.needsRefactoring);
46
+ }
47
+
48
+ getUrgentRefactoring() {
49
+ return this.getAll().filter(analysis => analysis.urgentRefactoring);
50
+ }
51
+
52
+ getExceedingLimit(limit = 555) {
53
+ return this.getAll().filter(analysis => analysis.exceedsSizeLimit(limit));
54
+ }
55
+
56
+ getApproachingLimit(limit = 555, threshold = 0.9) {
57
+ return this.getAll().filter(analysis => analysis.approachesSizeLimit(limit, threshold));
58
+ }
59
+
60
+ getLargestFiles(count = 10) {
61
+ return this.getAll()
62
+ .sort((a, b) => b.lineCount - a.lineCount)
63
+ .slice(0, count);
64
+ }
65
+
66
+ getMostComplexFiles(count = 10) {
67
+ return this.getAll()
68
+ .sort((a, b) => b.getComplexityScore() - a.getComplexityScore())
69
+ .slice(0, count);
70
+ }
71
+
72
+ getSummary() {
73
+ const analyses = this.getAll();
74
+ const summary = {
75
+ totalFiles: analyses.length,
76
+ totalLines: analyses.reduce((sum, a) => sum + a.lineCount, 0),
77
+ totalCodeLines: analyses.reduce((sum, a) => sum + a.codeLines, 0),
78
+ totalCommentLines: analyses.reduce((sum, a) => sum + a.commentLines, 0),
79
+ totalBlankLines: analyses.reduce((sum, a) => sum + a.blankLines, 0),
80
+ averageLines: 0,
81
+ largestFile: null,
82
+ smallestFile: null,
83
+ needsRefactoring: analyses.filter(a => a.needsRefactoring).length,
84
+ urgentRefactoring: analyses.filter(a => a.urgentRefactoring).length,
85
+ byPackage: {},
86
+ byCategory: {},
87
+ byPriority: {},
88
+ errors: 0,
89
+ warnings: 0
90
+ };
91
+ summary.averageLines = summary.totalFiles > 0
92
+ ? Math.round(summary.totalLines / summary.totalFiles) : 0;
93
+ summary.largestFile = analyses.reduce((largest, a) =>
94
+ a.lineCount > (largest?.lineCount || 0) ? a : largest, null);
95
+ summary.smallestFile = analyses.reduce((smallest, a) =>
96
+ a.lineCount < (smallest?.lineCount || Infinity) ? a : smallest, null);
97
+ for (const analysis of analyses) {
98
+ if (!summary.byPackage[analysis.package]) summary.byPackage[analysis.package] = 0;
99
+ summary.byPackage[analysis.package]++;
100
+ }
101
+ for (const analysis of analyses) {
102
+ const category = analysis.getSizeCategory();
103
+ if (!summary.byCategory[category]) summary.byCategory[category] = 0;
104
+ summary.byCategory[category]++;
105
+ }
106
+ for (const analysis of analyses) {
107
+ if (!summary.byPriority[analysis.priority]) summary.byPriority[analysis.priority] = 0;
108
+ summary.byPriority[analysis.priority]++;
109
+ }
110
+ summary.errors = analyses.reduce((sum, a) => sum + a.errors.length, 0);
111
+ summary.warnings = analyses.reduce((sum, a) => sum + a.warnings.length, 0);
112
+ return summary;
113
+ }
114
+
115
+ updateMetadata() {
116
+ const analyses = this.getAll();
117
+ this.metadata.totalFiles = analyses.length;
118
+ this.metadata.totalLines = analyses.reduce((sum, a) => sum + a.lineCount, 0);
119
+ }
120
+
121
+ toJSON() {
122
+ return {
123
+ metadata: this.metadata,
124
+ analyses: this.getAll().map(a => a.toJSON())
125
+ };
126
+ }
127
+
128
+ static fromJSON(data) {
129
+ const collection = new FileAnalysisCollection();
130
+ for (const analysisData of data.analyses) {
131
+ const analysis = FileAnalysis.fromJSON(analysisData);
132
+ collection.add(analysis);
133
+ }
134
+ collection.metadata = { ...collection.metadata, ...data.metadata };
135
+ return collection;
136
+ }
137
+ }
138
+
139
+ module.exports = { FileAnalysisCollection };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Computed metrics for FileAnalysis (complexity score, size category, refactoring difficulty).
3
+ * Used by FileAnalysis and other analysis consumers.
4
+ */
5
+
6
+ function getSizeCategory(lineCount) {
7
+ if (lineCount <= 100) return 'tiny';
8
+ if (lineCount <= 300) return 'small';
9
+ if (lineCount <= 555) return 'medium';
10
+ if (lineCount <= 800) return 'large';
11
+ return 'xlarge';
12
+ }
13
+
14
+ function getComplexityScoreFromMetrics(metrics) {
15
+ let score = 0;
16
+ const { lineCount, functionCount, classCount, dependencyCount, nestingDepth } = metrics;
17
+ if (lineCount > 1000) score += 30;
18
+ else if (lineCount > 555) score += 25;
19
+ else if (lineCount > 300) score += 15;
20
+ else if (lineCount > 100) score += 5;
21
+ if (functionCount > 20) score += 20;
22
+ else if (functionCount > 10) score += 15;
23
+ else if (functionCount > 5) score += 10;
24
+ else if (functionCount > 2) score += 5;
25
+ if (classCount > 5) score += 15;
26
+ else if (classCount > 3) score += 10;
27
+ else if (classCount > 1) score += 5;
28
+ if (dependencyCount > 20) score += 20;
29
+ else if (dependencyCount > 10) score += 15;
30
+ else if (dependencyCount > 5) score += 10;
31
+ else if (dependencyCount > 2) score += 5;
32
+ if (nestingDepth > 8) score += 15;
33
+ else if (nestingDepth > 5) score += 10;
34
+ else if (nestingDepth > 3) score += 5;
35
+ return Math.min(score, 100);
36
+ }
37
+
38
+ function getRefactoringDifficultyFromScore(complexityScore) {
39
+ if (complexityScore >= 80) return 'very_difficult';
40
+ if (complexityScore >= 60) return 'difficult';
41
+ if (complexityScore >= 40) return 'moderate';
42
+ if (complexityScore >= 20) return 'easy';
43
+ return 'very_easy';
44
+ }
45
+
46
+ module.exports = {
47
+ getSizeCategory,
48
+ getComplexityScoreFromMetrics,
49
+ getRefactoringDifficultyFromScore
50
+ };
@@ -6,6 +6,11 @@
6
6
  */
7
7
 
8
8
  const path = require('path');
9
+ const {
10
+ getSizeCategory: getSizeCategoryFromMetrics,
11
+ getComplexityScoreFromMetrics,
12
+ getRefactoringDifficultyFromScore
13
+ } = require('./file-analysis-metrics');
9
14
 
10
15
  /**
11
16
  * File analysis class
@@ -216,65 +221,22 @@ class FileAnalysis {
216
221
  });
217
222
  }
218
223
 
219
- /**
220
- * Get size category
221
- */
222
224
  getSizeCategory() {
223
- if (this.lineCount <= 100) return 'tiny';
224
- if (this.lineCount <= 300) return 'small';
225
- if (this.lineCount <= 555) return 'medium';
226
- if (this.lineCount <= 800) return 'large';
227
- return 'xlarge';
225
+ return getSizeCategoryFromMetrics(this.lineCount);
228
226
  }
229
227
 
230
- /**
231
- * Get complexity score (0-100)
232
- */
233
228
  getComplexityScore() {
234
- let score = 0;
235
-
236
- // Line count contribution (0-30 points)
237
- if (this.lineCount > 1000) score += 30;
238
- else if (this.lineCount > 555) score += 25;
239
- else if (this.lineCount > 300) score += 15;
240
- else if (this.lineCount > 100) score += 5;
241
-
242
- // Function count contribution (0-20 points)
243
- if (this.functionCount > 20) score += 20;
244
- else if (this.functionCount > 10) score += 15;
245
- else if (this.functionCount > 5) score += 10;
246
- else if (this.functionCount > 2) score += 5;
247
-
248
- // Class count contribution (0-15 points)
249
- if (this.classCount > 5) score += 15;
250
- else if (this.classCount > 3) score += 10;
251
- else if (this.classCount > 1) score += 5;
252
-
253
- // Dependency count contribution (0-20 points)
254
- if (this.dependencyCount > 20) score += 20;
255
- else if (this.dependencyCount > 10) score += 15;
256
- else if (this.dependencyCount > 5) score += 10;
257
- else if (this.dependencyCount > 2) score += 5;
258
-
259
- // Nesting depth contribution (0-15 points)
260
- if (this.nestingDepth > 8) score += 15;
261
- else if (this.nestingDepth > 5) score += 10;
262
- else if (this.nestingDepth > 3) score += 5;
263
-
264
- return Math.min(score, 100);
229
+ return getComplexityScoreFromMetrics({
230
+ lineCount: this.lineCount,
231
+ functionCount: this.functionCount,
232
+ classCount: this.classCount,
233
+ dependencyCount: this.dependencyCount,
234
+ nestingDepth: this.nestingDepth
235
+ });
265
236
  }
266
237
 
267
- /**
268
- * Get refactoring difficulty
269
- */
270
238
  getRefactoringDifficulty() {
271
- const complexityScore = this.getComplexityScore();
272
-
273
- if (complexityScore >= 80) return 'very_difficult';
274
- if (complexityScore >= 60) return 'difficult';
275
- if (complexityScore >= 40) return 'moderate';
276
- if (complexityScore >= 20) return 'easy';
277
- return 'very_easy';
239
+ return getRefactoringDifficultyFromScore(this.getComplexityScore());
278
240
  }
279
241
 
280
242
  /**
@@ -469,213 +431,4 @@ class FileAnalysis {
469
431
  }
470
432
  }
471
433
 
472
- /**
473
- * File analysis collection class
474
- */
475
- class FileAnalysisCollection {
476
- constructor() {
477
- this.analyses = new Map();
478
- this.metadata = {
479
- createdAt: new Date().toISOString(),
480
- version: '1.0.0',
481
- totalFiles: 0,
482
- totalLines: 0
483
- };
484
- }
485
-
486
- /**
487
- * Add file analysis
488
- */
489
- add(analysis) {
490
- if (!(analysis instanceof FileAnalysis)) {
491
- throw new Error('Analysis must be a FileAnalysis instance');
492
- }
493
-
494
- this.analyses.set(analysis.filePath, analysis);
495
- this.updateMetadata();
496
- }
497
-
498
- /**
499
- * Get file analysis
500
- */
501
- get(filePath) {
502
- return this.analyses.get(filePath);
503
- }
504
-
505
- /**
506
- * Remove file analysis
507
- */
508
- remove(filePath) {
509
- const removed = this.analyses.delete(filePath);
510
- if (removed) {
511
- this.updateMetadata();
512
- }
513
- return removed;
514
- }
515
-
516
- /**
517
- * Get all analyses
518
- */
519
- getAll() {
520
- return Array.from(this.analyses.values());
521
- }
522
-
523
- /**
524
- * Get analyses by package
525
- */
526
- getByPackage(packageName) {
527
- return this.getAll().filter(analysis => analysis.package === packageName);
528
- }
529
-
530
- /**
531
- * Get analyses needing refactoring
532
- */
533
- getNeedingRefactoring() {
534
- return this.getAll().filter(analysis => analysis.needsRefactoring);
535
- }
536
-
537
- /**
538
- * Get urgent refactoring candidates
539
- */
540
- getUrgentRefactoring() {
541
- return this.getAll().filter(analysis => analysis.urgentRefactoring);
542
- }
543
-
544
- /**
545
- * Get files exceeding size limit
546
- */
547
- getExceedingLimit(limit = 555) {
548
- return this.getAll().filter(analysis => analysis.exceedsSizeLimit(limit));
549
- }
550
-
551
- /**
552
- * Get files approaching size limit
553
- */
554
- getApproachingLimit(limit = 555, threshold = 0.9) {
555
- return this.getAll().filter(analysis => analysis.approachesSizeLimit(limit, threshold));
556
- }
557
-
558
- /**
559
- * Get largest files
560
- */
561
- getLargestFiles(count = 10) {
562
- return this.getAll()
563
- .sort((a, b) => b.lineCount - a.lineCount)
564
- .slice(0, count);
565
- }
566
-
567
- /**
568
- * Get most complex files
569
- */
570
- getMostComplexFiles(count = 10) {
571
- return this.getAll()
572
- .sort((a, b) => b.getComplexityScore() - a.getComplexityScore())
573
- .slice(0, count);
574
- }
575
-
576
- /**
577
- * Get summary statistics
578
- */
579
- getSummary() {
580
- const analyses = this.getAll();
581
-
582
- const summary = {
583
- totalFiles: analyses.length,
584
- totalLines: analyses.reduce((sum, a) => sum + a.lineCount, 0),
585
- totalCodeLines: analyses.reduce((sum, a) => sum + a.codeLines, 0),
586
- totalCommentLines: analyses.reduce((sum, a) => sum + a.commentLines, 0),
587
- totalBlankLines: analyses.reduce((sum, a) => sum + a.blankLines, 0),
588
- averageLines: 0,
589
- largestFile: null,
590
- smallestFile: null,
591
- needsRefactoring: analyses.filter(a => a.needsRefactoring).length,
592
- urgentRefactoring: analyses.filter(a => a.urgentRefactoring).length,
593
- byPackage: {},
594
- byCategory: {},
595
- byPriority: {},
596
- errors: 0,
597
- warnings: 0
598
- };
599
-
600
- // Calculate averages
601
- summary.averageLines = summary.totalFiles > 0 ?
602
- Math.round(summary.totalLines / summary.totalFiles) : 0;
603
-
604
- // Find largest and smallest
605
- summary.largestFile = analyses.reduce((largest, a) =>
606
- a.lineCount > (largest?.lineCount || 0) ? a : largest, null);
607
- summary.smallestFile = analyses.reduce((smallest, a) =>
608
- a.lineCount < (smallest?.lineCount || Infinity) ? a : smallest, null);
609
-
610
- // Group by package
611
- for (const analysis of analyses) {
612
- if (!summary.byPackage[analysis.package]) {
613
- summary.byPackage[analysis.package] = 0;
614
- }
615
- summary.byPackage[analysis.package]++;
616
- }
617
-
618
- // Group by category
619
- for (const analysis of analyses) {
620
- const category = analysis.getSizeCategory();
621
- if (!summary.byCategory[category]) {
622
- summary.byCategory[category] = 0;
623
- }
624
- summary.byCategory[category]++;
625
- }
626
-
627
- // Group by priority
628
- for (const analysis of analyses) {
629
- if (!summary.byPriority[analysis.priority]) {
630
- summary.byPriority[analysis.priority] = 0;
631
- }
632
- summary.byPriority[analysis.priority]++;
633
- }
634
-
635
- // Count errors and warnings
636
- summary.errors = analyses.reduce((sum, a) => sum + a.errors.length, 0);
637
- summary.warnings = analyses.reduce((sum, a) => sum + a.warnings.length, 0);
638
-
639
- return summary;
640
- }
641
-
642
- /**
643
- * Update metadata
644
- */
645
- updateMetadata() {
646
- const analyses = this.getAll();
647
- this.metadata.totalFiles = analyses.length;
648
- this.metadata.totalLines = analyses.reduce((sum, a) => sum + a.lineCount, 0);
649
- }
650
-
651
- /**
652
- * Convert to JSON
653
- */
654
- toJSON() {
655
- return {
656
- metadata: this.metadata,
657
- analyses: this.getAll().map(a => a.toJSON())
658
- };
659
- }
660
-
661
- /**
662
- * Create from JSON
663
- */
664
- static fromJSON(data) {
665
- const collection = new FileAnalysisCollection();
666
-
667
- for (const analysisData of data.analyses) {
668
- const analysis = FileAnalysis.fromJSON(analysisData);
669
- collection.add(analysis);
670
- }
671
-
672
- collection.metadata = { ...collection.metadata, ...data.metadata };
673
-
674
- return collection;
675
- }
676
- }
677
-
678
- module.exports = {
679
- FileAnalysis,
680
- FileAnalysisCollection
681
- };
434
+ module.exports = { FileAnalysis };