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,681 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Analysis Data Model
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive data model for file analysis results.
|
|
5
|
+
* Provides structure for storing and accessing file analysis data.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* File analysis class
|
|
12
|
+
*/
|
|
13
|
+
class FileAnalysis {
|
|
14
|
+
constructor(filePath) {
|
|
15
|
+
this.filePath = filePath;
|
|
16
|
+
this.relativePath = path.relative(process.cwd(), filePath);
|
|
17
|
+
this.basename = path.basename(filePath);
|
|
18
|
+
this.extension = path.extname(filePath);
|
|
19
|
+
this.directory = path.dirname(filePath);
|
|
20
|
+
this.package = this.extractPackage();
|
|
21
|
+
|
|
22
|
+
// Size metrics
|
|
23
|
+
this.lineCount = 0;
|
|
24
|
+
this.codeLines = 0;
|
|
25
|
+
this.commentLines = 0;
|
|
26
|
+
this.blankLines = 0;
|
|
27
|
+
this.fileSize = 0;
|
|
28
|
+
|
|
29
|
+
// Complexity metrics
|
|
30
|
+
this.complexity = 'unknown';
|
|
31
|
+
this.cyclomaticComplexity = 0;
|
|
32
|
+
this.nestingDepth = 0;
|
|
33
|
+
this.functionCount = 0;
|
|
34
|
+
this.classCount = 0;
|
|
35
|
+
|
|
36
|
+
// Dependencies
|
|
37
|
+
this.imports = [];
|
|
38
|
+
this.exports = [];
|
|
39
|
+
this.dependencyCount = 0;
|
|
40
|
+
this.dependents = [];
|
|
41
|
+
|
|
42
|
+
// Structure
|
|
43
|
+
this.boundaries = null;
|
|
44
|
+
this.functions = [];
|
|
45
|
+
this.classes = [];
|
|
46
|
+
this.utilities = [];
|
|
47
|
+
|
|
48
|
+
// Classification
|
|
49
|
+
this.category = 'unknown';
|
|
50
|
+
this.priority = 'unknown';
|
|
51
|
+
this.riskLevel = 'unknown';
|
|
52
|
+
this.needsRefactoring = false;
|
|
53
|
+
this.urgentRefactoring = false;
|
|
54
|
+
|
|
55
|
+
// Metadata
|
|
56
|
+
this.isTestFile = false;
|
|
57
|
+
this.isConfigFile = false;
|
|
58
|
+
this.isGeneratedFile = false;
|
|
59
|
+
this.lastModified = null;
|
|
60
|
+
this.createdAt = null;
|
|
61
|
+
|
|
62
|
+
// Analysis metadata
|
|
63
|
+
this.analyzedAt = new Date().toISOString();
|
|
64
|
+
this.analysisVersion = '1.0.0';
|
|
65
|
+
this.errors = [];
|
|
66
|
+
this.warnings = [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Extract package from file path
|
|
71
|
+
*/
|
|
72
|
+
extractPackage() {
|
|
73
|
+
const match = this.filePath.match(/packages\/([^\/]+)/);
|
|
74
|
+
return match ? match[1] : 'root';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Set line count metrics
|
|
79
|
+
*/
|
|
80
|
+
setLineCountMetrics(total, code, comment, blank) {
|
|
81
|
+
this.lineCount = total;
|
|
82
|
+
this.codeLines = code;
|
|
83
|
+
this.commentLines = comment;
|
|
84
|
+
this.blankLines = blank;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Set complexity metrics
|
|
89
|
+
*/
|
|
90
|
+
setComplexityMetrics(complexity, cyclomatic, nesting, functions, classes) {
|
|
91
|
+
this.complexity = complexity;
|
|
92
|
+
this.cyclomaticComplexity = cyclomatic;
|
|
93
|
+
this.nestingDepth = nesting;
|
|
94
|
+
this.functionCount = functions;
|
|
95
|
+
this.classCount = classes;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Add import
|
|
100
|
+
*/
|
|
101
|
+
addImport(importPath, isRelative = false) {
|
|
102
|
+
this.imports.push({
|
|
103
|
+
path: importPath,
|
|
104
|
+
isRelative,
|
|
105
|
+
addedAt: new Date().toISOString()
|
|
106
|
+
});
|
|
107
|
+
this.dependencyCount = this.imports.length;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Add export
|
|
112
|
+
*/
|
|
113
|
+
addExport(exportName, type = 'default') {
|
|
114
|
+
this.exports.push({
|
|
115
|
+
name: exportName,
|
|
116
|
+
type,
|
|
117
|
+
addedAt: new Date().toISOString()
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Add dependent file
|
|
123
|
+
*/
|
|
124
|
+
addDependent(dependentPath) {
|
|
125
|
+
if (!this.dependents.includes(dependentPath)) {
|
|
126
|
+
this.dependents.push(dependentPath);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Set boundaries analysis
|
|
132
|
+
*/
|
|
133
|
+
setBoundaries(boundaries) {
|
|
134
|
+
this.boundaries = boundaries;
|
|
135
|
+
|
|
136
|
+
// Extract functions and classes from boundaries
|
|
137
|
+
if (boundaries.boundaries) {
|
|
138
|
+
this.functions = boundaries.boundaries
|
|
139
|
+
.filter(b => b.type === 'function')
|
|
140
|
+
.map(b => ({
|
|
141
|
+
name: b.name,
|
|
142
|
+
startLine: b.startLine,
|
|
143
|
+
endLine: b.endLine,
|
|
144
|
+
lineCount: b.lineCount,
|
|
145
|
+
complexity: b.complexity || 0
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
this.classes = boundaries.boundaries
|
|
149
|
+
.filter(b => b.type === 'class')
|
|
150
|
+
.map(b => ({
|
|
151
|
+
name: b.name,
|
|
152
|
+
startLine: b.startLine,
|
|
153
|
+
endLine: b.endLine,
|
|
154
|
+
lineCount: b.lineCount,
|
|
155
|
+
complexity: b.complexity || 0
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
this.utilities = boundaries.boundaries
|
|
159
|
+
.filter(b => b.type === 'utility')
|
|
160
|
+
.map(b => ({
|
|
161
|
+
name: b.name,
|
|
162
|
+
startLine: b.startLine,
|
|
163
|
+
endLine: b.endLine,
|
|
164
|
+
lineCount: b.lineCount
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Set classification
|
|
171
|
+
*/
|
|
172
|
+
setClassification(category, priority, riskLevel, needsRefactoring, urgentRefactoring) {
|
|
173
|
+
this.category = category;
|
|
174
|
+
this.priority = priority;
|
|
175
|
+
this.riskLevel = riskLevel;
|
|
176
|
+
this.needsRefactoring = needsRefactoring;
|
|
177
|
+
this.urgentRefactoring = urgentRefactoring;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Set file type flags
|
|
182
|
+
*/
|
|
183
|
+
setFileTypeFlags(isTest, isConfig, isGenerated) {
|
|
184
|
+
this.isTestFile = isTest;
|
|
185
|
+
this.isConfigFile = isConfig;
|
|
186
|
+
this.isGeneratedFile = isGenerated;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Set file timestamps
|
|
191
|
+
*/
|
|
192
|
+
setTimestamps(lastModified, createdAt) {
|
|
193
|
+
this.lastModified = lastModified;
|
|
194
|
+
this.createdAt = createdAt;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Add error
|
|
199
|
+
*/
|
|
200
|
+
addError(message, details = null) {
|
|
201
|
+
this.errors.push({
|
|
202
|
+
message,
|
|
203
|
+
details,
|
|
204
|
+
timestamp: new Date().toISOString()
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Add warning
|
|
210
|
+
*/
|
|
211
|
+
addWarning(message, details = null) {
|
|
212
|
+
this.warnings.push({
|
|
213
|
+
message,
|
|
214
|
+
details,
|
|
215
|
+
timestamp: new Date().toISOString()
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Get size category
|
|
221
|
+
*/
|
|
222
|
+
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';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Get complexity score (0-100)
|
|
232
|
+
*/
|
|
233
|
+
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);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Get refactoring difficulty
|
|
269
|
+
*/
|
|
270
|
+
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';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Get largest functions
|
|
282
|
+
*/
|
|
283
|
+
getLargestFunctions(count = 5) {
|
|
284
|
+
return this.functions
|
|
285
|
+
.sort((a, b) => b.lineCount - a.lineCount)
|
|
286
|
+
.slice(0, count);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Get largest classes
|
|
291
|
+
*/
|
|
292
|
+
getLargestClasses(count = 5) {
|
|
293
|
+
return this.classes
|
|
294
|
+
.sort((a, b) => b.lineCount - a.lineCount)
|
|
295
|
+
.slice(0, count);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Get functions that could be extracted
|
|
300
|
+
*/
|
|
301
|
+
getExtractableFunctions(minSize = 20) {
|
|
302
|
+
return this.functions.filter(f =>
|
|
303
|
+
f.lineCount >= minSize &&
|
|
304
|
+
f.name !== '' &&
|
|
305
|
+
!f.name.startsWith('_') // Skip private functions
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Get classes that could be extracted
|
|
311
|
+
*/
|
|
312
|
+
getExtractableClasses(minSize = 50) {
|
|
313
|
+
return this.classes.filter(c =>
|
|
314
|
+
c.lineCount >= minSize &&
|
|
315
|
+
c.name !== ''
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Check if file exceeds size limit
|
|
321
|
+
*/
|
|
322
|
+
exceedsSizeLimit(limit = 555) {
|
|
323
|
+
return this.lineCount > limit;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Check if file approaches size limit
|
|
328
|
+
*/
|
|
329
|
+
approachesSizeLimit(limit = 555, threshold = 0.9) {
|
|
330
|
+
return this.lineCount > (limit * threshold) && this.lineCount <= limit;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get summary object
|
|
335
|
+
*/
|
|
336
|
+
getSummary() {
|
|
337
|
+
return {
|
|
338
|
+
filePath: this.filePath,
|
|
339
|
+
relativePath: this.relativePath,
|
|
340
|
+
package: this.package,
|
|
341
|
+
lineCount: this.lineCount,
|
|
342
|
+
category: this.getSizeCategory(),
|
|
343
|
+
priority: this.priority,
|
|
344
|
+
needsRefactoring: this.needsRefactoring,
|
|
345
|
+
urgentRefactoring: this.urgentRefactoring,
|
|
346
|
+
complexity: this.complexity,
|
|
347
|
+
complexityScore: this.getComplexityScore(),
|
|
348
|
+
functionCount: this.functionCount,
|
|
349
|
+
classCount: this.classCount,
|
|
350
|
+
dependencyCount: this.dependencyCount,
|
|
351
|
+
errors: this.errors.length,
|
|
352
|
+
warnings: this.warnings.length
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Convert to JSON
|
|
358
|
+
*/
|
|
359
|
+
toJSON() {
|
|
360
|
+
return {
|
|
361
|
+
// Basic info
|
|
362
|
+
filePath: this.filePath,
|
|
363
|
+
relativePath: this.relativePath,
|
|
364
|
+
basename: this.basename,
|
|
365
|
+
extension: this.extension,
|
|
366
|
+
directory: this.directory,
|
|
367
|
+
package: this.package,
|
|
368
|
+
|
|
369
|
+
// Size metrics
|
|
370
|
+
lineCount: this.lineCount,
|
|
371
|
+
codeLines: this.codeLines,
|
|
372
|
+
commentLines: this.commentLines,
|
|
373
|
+
blankLines: this.blankLines,
|
|
374
|
+
fileSize: this.fileSize,
|
|
375
|
+
|
|
376
|
+
// Complexity metrics
|
|
377
|
+
complexity: this.complexity,
|
|
378
|
+
cyclomaticComplexity: this.cyclomaticComplexity,
|
|
379
|
+
nestingDepth: this.nestingDepth,
|
|
380
|
+
functionCount: this.functionCount,
|
|
381
|
+
classCount: this.classCount,
|
|
382
|
+
|
|
383
|
+
// Dependencies
|
|
384
|
+
imports: this.imports,
|
|
385
|
+
exports: this.exports,
|
|
386
|
+
dependencyCount: this.dependencyCount,
|
|
387
|
+
dependents: this.dependents,
|
|
388
|
+
|
|
389
|
+
// Structure
|
|
390
|
+
functions: this.functions,
|
|
391
|
+
classes: this.classes,
|
|
392
|
+
utilities: this.utilities,
|
|
393
|
+
|
|
394
|
+
// Classification
|
|
395
|
+
category: this.category,
|
|
396
|
+
priority: this.priority,
|
|
397
|
+
riskLevel: this.riskLevel,
|
|
398
|
+
needsRefactoring: this.needsRefactoring,
|
|
399
|
+
urgentRefactoring: this.urgentRefactoring,
|
|
400
|
+
|
|
401
|
+
// Metadata
|
|
402
|
+
isTestFile: this.isTestFile,
|
|
403
|
+
isConfigFile: this.isConfigFile,
|
|
404
|
+
isGeneratedFile: this.isGeneratedFile,
|
|
405
|
+
lastModified: this.lastModified,
|
|
406
|
+
createdAt: this.createdAt,
|
|
407
|
+
|
|
408
|
+
// Analysis metadata
|
|
409
|
+
analyzedAt: this.analyzedAt,
|
|
410
|
+
analysisVersion: this.analysisVersion,
|
|
411
|
+
errors: this.errors,
|
|
412
|
+
warnings: this.warnings,
|
|
413
|
+
|
|
414
|
+
// Computed metrics
|
|
415
|
+
complexityScore: this.getComplexityScore(),
|
|
416
|
+
refactoringDifficulty: this.getRefactoringDifficulty(),
|
|
417
|
+
sizeCategory: this.getSizeCategory()
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Create from JSON
|
|
423
|
+
*/
|
|
424
|
+
static fromJSON(data) {
|
|
425
|
+
const analysis = new FileAnalysis(data.filePath);
|
|
426
|
+
|
|
427
|
+
// Restore all properties
|
|
428
|
+
Object.assign(analysis, data);
|
|
429
|
+
|
|
430
|
+
return analysis;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Validate analysis data
|
|
435
|
+
*/
|
|
436
|
+
validate() {
|
|
437
|
+
const issues = [];
|
|
438
|
+
|
|
439
|
+
// Check required fields
|
|
440
|
+
if (!this.filePath) {
|
|
441
|
+
issues.push('Missing file path');
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (this.lineCount < 0) {
|
|
445
|
+
issues.push('Invalid line count');
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (this.functionCount < 0) {
|
|
449
|
+
issues.push('Invalid function count');
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (this.classCount < 0) {
|
|
453
|
+
issues.push('Invalid class count');
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Check logical consistency
|
|
457
|
+
if (this.codeLines + this.commentLines + this.blankLines !== this.lineCount) {
|
|
458
|
+
issues.push('Line count metrics are inconsistent');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (this.imports.length !== this.dependencyCount) {
|
|
462
|
+
issues.push('Dependency count is inconsistent with imports');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return {
|
|
466
|
+
isValid: issues.length === 0,
|
|
467
|
+
issues
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
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
|
+
};
|