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,569 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates comprehensive reports for file size analysis and refactoring operations.
|
|
5
|
+
* Supports multiple output formats and customizable content.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const RefactoringConfig = require('../config/refactoring-config');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Report types
|
|
14
|
+
*/
|
|
15
|
+
const REPORT_TYPES = {
|
|
16
|
+
ANALYSIS: 'analysis',
|
|
17
|
+
REFACTORING: 'refactoring',
|
|
18
|
+
VALIDATION: 'validation',
|
|
19
|
+
COMPLIANCE: 'compliance'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Output formats
|
|
24
|
+
*/
|
|
25
|
+
const OUTPUT_FORMATS = {
|
|
26
|
+
JSON: 'json',
|
|
27
|
+
MARKDOWN: 'markdown',
|
|
28
|
+
CONSOLE: 'console',
|
|
29
|
+
HTML: 'html'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Report generator class
|
|
34
|
+
*/
|
|
35
|
+
class ReportGenerator {
|
|
36
|
+
constructor(config = RefactoringConfig) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.reportData = null;
|
|
39
|
+
this.metadata = {
|
|
40
|
+
generatedAt: new Date().toISOString(),
|
|
41
|
+
version: '1.0.0',
|
|
42
|
+
config: config.reporting || {}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generate analysis report
|
|
48
|
+
*/
|
|
49
|
+
generateAnalysisReport(analysisData, options = {}) {
|
|
50
|
+
this.reportData = {
|
|
51
|
+
type: REPORT_TYPES.ANALYSIS,
|
|
52
|
+
metadata: this.metadata,
|
|
53
|
+
summary: this.generateAnalysisSummary(analysisData),
|
|
54
|
+
files: analysisData.files || [],
|
|
55
|
+
recommendations: this.generateRecommendations(analysisData),
|
|
56
|
+
statistics: this.generateStatistics(analysisData)
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return this.outputReport(options.format || OUTPUT_FORMATS.JSON, options.outputPath);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Generate refactoring report
|
|
64
|
+
*/
|
|
65
|
+
generateRefactoringReport(refactoringData, options = {}) {
|
|
66
|
+
this.reportData = {
|
|
67
|
+
type: REPORT_TYPES.REFACTORING,
|
|
68
|
+
metadata: this.metadata,
|
|
69
|
+
summary: this.generateRefactoringSummary(refactoringData),
|
|
70
|
+
operations: refactoringData.operations || [],
|
|
71
|
+
results: refactoringData.results || [],
|
|
72
|
+
rollback: refactoringData.rollback || {}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return this.outputReport(options.format || OUTPUT_FORMATS.JSON, options.outputPath);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generate validation report
|
|
80
|
+
*/
|
|
81
|
+
generateValidationReport(validationData, options = {}) {
|
|
82
|
+
this.reportData = {
|
|
83
|
+
type: REPORT_TYPES.VALIDATION,
|
|
84
|
+
metadata: this.metadata,
|
|
85
|
+
summary: this.generateValidationSummary(validationData),
|
|
86
|
+
results: validationData.results || [],
|
|
87
|
+
compliance: this.generateComplianceMetrics(validationData)
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return this.outputReport(options.format || OUTPUT_FORMATS.JSON, options.outputPath);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Generate compliance report
|
|
95
|
+
*/
|
|
96
|
+
generateComplianceReport(complianceData, options = {}) {
|
|
97
|
+
this.reportData = {
|
|
98
|
+
type: REPORT_TYPES.COMPLIANCE,
|
|
99
|
+
metadata: this.metadata,
|
|
100
|
+
summary: this.generateComplianceSummary(complianceData),
|
|
101
|
+
metrics: complianceData.metrics || {},
|
|
102
|
+
violations: complianceData.violations || [],
|
|
103
|
+
trends: complianceData.trends || {}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return this.outputReport(options.format || OUTPUT_FORMATS.JSON, options.outputPath);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Generate analysis summary
|
|
111
|
+
*/
|
|
112
|
+
generateAnalysisSummary(analysisData) {
|
|
113
|
+
const files = analysisData.files || [];
|
|
114
|
+
const totalFiles = files.length;
|
|
115
|
+
const largeFiles = files.filter(f => f.lineCount > 555).length;
|
|
116
|
+
const mediumFiles = files.filter(f => f.lineCount > 300 && f.lineCount <= 555).length;
|
|
117
|
+
const smallFiles = files.filter(f => f.lineCount <= 300).length;
|
|
118
|
+
|
|
119
|
+
const totalLines = files.reduce((sum, f) => sum + f.lineCount, 0);
|
|
120
|
+
const avgLines = totalFiles > 0 ? Math.round(totalLines / totalFiles) : 0;
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
totalFiles,
|
|
124
|
+
totalLines,
|
|
125
|
+
averageLines: avgLines,
|
|
126
|
+
sizeDistribution: {
|
|
127
|
+
small: smallFiles,
|
|
128
|
+
medium: mediumFiles,
|
|
129
|
+
large: largeFiles,
|
|
130
|
+
xlarge: files.filter(f => f.lineCount > 800).length
|
|
131
|
+
},
|
|
132
|
+
complianceRate: totalFiles > 0 ? ((totalFiles - largeFiles) / totalFiles * 100).toFixed(1) : 0,
|
|
133
|
+
needsRefactoring: largeFiles + mediumFiles
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Generate refactoring summary
|
|
139
|
+
*/
|
|
140
|
+
generateRefactoringSummary(refactoringData) {
|
|
141
|
+
const operations = refactoringData.operations || [];
|
|
142
|
+
const successful = operations.filter(op => op.status === 'success').length;
|
|
143
|
+
const failed = operations.filter(op => op.status === 'failed').length;
|
|
144
|
+
const skipped = operations.filter(op => op.status === 'skipped').length;
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
totalOperations: operations.length,
|
|
148
|
+
successful,
|
|
149
|
+
failed,
|
|
150
|
+
skipped,
|
|
151
|
+
successRate: operations.length > 0 ? (successful / operations.length * 100).toFixed(1) : 0,
|
|
152
|
+
filesProcessed: refactoringData.filesProcessed || 0,
|
|
153
|
+
linesReduced: refactoringData.linesReduced || 0,
|
|
154
|
+
modulesCreated: refactoringData.modulesCreated || 0
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Generate validation summary
|
|
160
|
+
*/
|
|
161
|
+
generateValidationSummary(validationData) {
|
|
162
|
+
const results = validationData.results || [];
|
|
163
|
+
const errors = results.filter(r => r.severity === 'error').length;
|
|
164
|
+
const warnings = results.filter(r => r.severity === 'warning').length;
|
|
165
|
+
const info = results.filter(r => r.severity === 'info').length;
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
totalIssues: results.length,
|
|
169
|
+
errors,
|
|
170
|
+
warnings,
|
|
171
|
+
info,
|
|
172
|
+
filesValidated: validationData.filesValidated || 0,
|
|
173
|
+
passed: errors === 0
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Generate compliance summary
|
|
179
|
+
*/
|
|
180
|
+
generateComplianceSummary(complianceData) {
|
|
181
|
+
const metrics = complianceData.metrics || {};
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
overallScore: metrics.overallScore || 0,
|
|
185
|
+
fileComplianceRate: metrics.fileComplianceRate || 0,
|
|
186
|
+
lineComplianceRate: metrics.lineComplianceRate || 0,
|
|
187
|
+
violationCount: metrics.violationCount || 0,
|
|
188
|
+
lastChecked: metrics.lastChecked || new Date().toISOString(),
|
|
189
|
+
status: metrics.status || 'unknown'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Generate recommendations
|
|
195
|
+
*/
|
|
196
|
+
generateRecommendations(analysisData) {
|
|
197
|
+
const recommendations = [];
|
|
198
|
+
const files = analysisData.files || [];
|
|
199
|
+
|
|
200
|
+
// Large file recommendations
|
|
201
|
+
const largeFiles = files.filter(f => f.lineCount > 555);
|
|
202
|
+
if (largeFiles.length > 0) {
|
|
203
|
+
recommendations.push({
|
|
204
|
+
type: 'urgent',
|
|
205
|
+
title: `Refactor ${largeFiles.length} Large Files`,
|
|
206
|
+
description: `${largeFiles.length} files exceed the 555-line limit and require immediate refactoring.`,
|
|
207
|
+
files: largeFiles.map(f => f.path),
|
|
208
|
+
priority: 'high'
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Medium file recommendations
|
|
213
|
+
const mediumFiles = files.filter(f => f.lineCount > 300 && f.lineCount <= 555);
|
|
214
|
+
if (mediumFiles.length > 0) {
|
|
215
|
+
recommendations.push({
|
|
216
|
+
type: 'planning',
|
|
217
|
+
title: `Plan Refactoring for ${mediumFiles.length} Medium Files`,
|
|
218
|
+
description: `${mediumFiles.length} files are approaching the size limit and should be planned for refactoring.`,
|
|
219
|
+
files: mediumFiles.map(f => f.path),
|
|
220
|
+
priority: 'medium'
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Package-specific recommendations
|
|
225
|
+
const packageStats = this.analyzePackageStats(files);
|
|
226
|
+
for (const [pkg, stats] of Object.entries(packageStats)) {
|
|
227
|
+
if (stats.complianceRate < 80) {
|
|
228
|
+
recommendations.push({
|
|
229
|
+
type: 'package',
|
|
230
|
+
title: `Improve ${pkg} Package Compliance`,
|
|
231
|
+
description: `Package ${pkg} has ${stats.complianceRate}% compliance rate and needs attention.`,
|
|
232
|
+
files: stats.files,
|
|
233
|
+
priority: 'medium'
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return recommendations;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Generate statistics
|
|
243
|
+
*/
|
|
244
|
+
generateStatistics(analysisData) {
|
|
245
|
+
const files = analysisData.files || [];
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
fileSizes: this.calculateSizeDistribution(files),
|
|
249
|
+
packageStats: this.analyzePackageStats(files),
|
|
250
|
+
fileTypeStats: this.analyzeFileTypeStats(files),
|
|
251
|
+
complexityMetrics: this.calculateComplexityMetrics(files)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Calculate size distribution
|
|
257
|
+
*/
|
|
258
|
+
calculateSizeDistribution(files) {
|
|
259
|
+
const distribution = {
|
|
260
|
+
'0-100': 0,
|
|
261
|
+
'101-200': 0,
|
|
262
|
+
'201-300': 0,
|
|
263
|
+
'301-400': 0,
|
|
264
|
+
'401-500': 0,
|
|
265
|
+
'501-555': 0,
|
|
266
|
+
'556+': 0
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
for (const file of files) {
|
|
270
|
+
const lines = file.lineCount;
|
|
271
|
+
if (lines <= 100) distribution['0-100']++;
|
|
272
|
+
else if (lines <= 200) distribution['101-200']++;
|
|
273
|
+
else if (lines <= 300) distribution['201-300']++;
|
|
274
|
+
else if (lines <= 400) distribution['301-400']++;
|
|
275
|
+
else if (lines <= 500) distribution['401-500']++;
|
|
276
|
+
else if (lines <= 555) distribution['501-555']++;
|
|
277
|
+
else distribution['556+']++;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return distribution;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Analyze package statistics
|
|
285
|
+
*/
|
|
286
|
+
analyzePackageStats(files) {
|
|
287
|
+
const packageStats = {};
|
|
288
|
+
|
|
289
|
+
for (const file of files) {
|
|
290
|
+
const pkg = this.extractPackageFromPath(file.path);
|
|
291
|
+
if (!packageStats[pkg]) {
|
|
292
|
+
packageStats[pkg] = {
|
|
293
|
+
totalFiles: 0,
|
|
294
|
+
totalLines: 0,
|
|
295
|
+
compliantFiles: 0,
|
|
296
|
+
files: []
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
packageStats[pkg].totalFiles++;
|
|
301
|
+
packageStats[pkg].totalLines += file.lineCount;
|
|
302
|
+
packageStats[pkg].files.push(file.path);
|
|
303
|
+
|
|
304
|
+
if (file.lineCount <= 555) {
|
|
305
|
+
packageStats[pkg].compliantFiles++;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Calculate compliance rates
|
|
310
|
+
for (const stats of Object.values(packageStats)) {
|
|
311
|
+
stats.complianceRate = stats.totalFiles > 0
|
|
312
|
+
? (stats.compliantFiles / stats.totalFiles * 100).toFixed(1)
|
|
313
|
+
: 0;
|
|
314
|
+
stats.averageLines = stats.totalFiles > 0
|
|
315
|
+
? Math.round(stats.totalLines / stats.totalFiles)
|
|
316
|
+
: 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return packageStats;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Analyze file type statistics
|
|
324
|
+
*/
|
|
325
|
+
analyzeFileTypeStats(files) {
|
|
326
|
+
const typeStats = {};
|
|
327
|
+
|
|
328
|
+
for (const file of files) {
|
|
329
|
+
const ext = path.extname(file.path);
|
|
330
|
+
if (!typeStats[ext]) {
|
|
331
|
+
typeStats[ext] = {
|
|
332
|
+
count: 0,
|
|
333
|
+
totalLines: 0,
|
|
334
|
+
averageLines: 0
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
typeStats[ext].count++;
|
|
339
|
+
typeStats[ext].totalLines += file.lineCount;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Calculate averages
|
|
343
|
+
for (const stats of Object.values(typeStats)) {
|
|
344
|
+
stats.averageLines = stats.count > 0
|
|
345
|
+
? Math.round(stats.totalLines / stats.count)
|
|
346
|
+
: 0;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return typeStats;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Calculate complexity metrics (simplified)
|
|
354
|
+
*/
|
|
355
|
+
calculateComplexityMetrics(files) {
|
|
356
|
+
return {
|
|
357
|
+
totalComplexity: 0,
|
|
358
|
+
averageComplexity: 0,
|
|
359
|
+
complexityDistribution: {
|
|
360
|
+
low: 0,
|
|
361
|
+
medium: 0,
|
|
362
|
+
high: 0,
|
|
363
|
+
veryHigh: 0
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Generate compliance metrics
|
|
370
|
+
*/
|
|
371
|
+
generateComplianceMetrics(validationData) {
|
|
372
|
+
const results = validationData.results || [];
|
|
373
|
+
const filesValidated = validationData.filesValidated || 0;
|
|
374
|
+
|
|
375
|
+
const errorCount = results.filter(r => r.severity === 'error').length;
|
|
376
|
+
const warningCount = results.filter(r => r.severity === 'warning').length;
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
overallScore: filesValidated > 0 ? Math.max(0, 100 - (errorCount * 10 + warningCount * 2)) : 0,
|
|
380
|
+
fileComplianceRate: filesValidated > 0 ? ((filesValidated - errorCount) / filesValidated * 100) : 0,
|
|
381
|
+
lineComplianceRate: 0, // Would need line-level analysis
|
|
382
|
+
violationCount: errorCount,
|
|
383
|
+
lastChecked: new Date().toISOString(),
|
|
384
|
+
status: errorCount === 0 ? 'compliant' : warningCount > 0 ? 'warning' : 'non-compliant'
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Output report in specified format
|
|
390
|
+
*/
|
|
391
|
+
outputReport(format, outputPath) {
|
|
392
|
+
switch (format) {
|
|
393
|
+
case OUTPUT_FORMATS.JSON:
|
|
394
|
+
return this.outputJSON(outputPath);
|
|
395
|
+
case OUTPUT_FORMATS.MARKDOWN:
|
|
396
|
+
return this.outputMarkdown(outputPath);
|
|
397
|
+
case OUTPUT_FORMATS.CONSOLE:
|
|
398
|
+
return this.outputConsole();
|
|
399
|
+
case OUTPUT_FORMATS.HTML:
|
|
400
|
+
return this.outputHTML(outputPath);
|
|
401
|
+
default:
|
|
402
|
+
throw new Error(`Unsupported output format: ${format}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Output JSON format
|
|
408
|
+
*/
|
|
409
|
+
outputJSON(outputPath) {
|
|
410
|
+
const json = JSON.stringify(this.reportData, null, 2);
|
|
411
|
+
|
|
412
|
+
if (outputPath) {
|
|
413
|
+
fs.writeFileSync(outputPath, json, 'utf8');
|
|
414
|
+
return { success: true, path: outputPath, format: 'json' };
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return { success: true, content: json, format: 'json' };
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Output Markdown format
|
|
422
|
+
*/
|
|
423
|
+
outputMarkdown(outputPath) {
|
|
424
|
+
const markdown = this.generateMarkdownReport();
|
|
425
|
+
|
|
426
|
+
if (outputPath) {
|
|
427
|
+
fs.writeFileSync(outputPath, markdown, 'utf8');
|
|
428
|
+
return { success: true, path: outputPath, format: 'markdown' };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return { success: true, content: markdown, format: 'markdown' };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Output console format
|
|
436
|
+
*/
|
|
437
|
+
outputConsole() {
|
|
438
|
+
const consoleOutput = this.generateConsoleReport();
|
|
439
|
+
console.log(consoleOutput);
|
|
440
|
+
return { success: true, content: consoleOutput, format: 'console' };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Output HTML format
|
|
445
|
+
*/
|
|
446
|
+
outputHTML(outputPath) {
|
|
447
|
+
const html = this.generateHTMLReport();
|
|
448
|
+
|
|
449
|
+
if (outputPath) {
|
|
450
|
+
fs.writeFileSync(outputPath, html, 'utf8');
|
|
451
|
+
return { success: true, path: outputPath, format: 'html' };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return { success: true, content: html, format: 'html' };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Generate Markdown report
|
|
459
|
+
*/
|
|
460
|
+
generateMarkdownReport() {
|
|
461
|
+
const data = this.reportData;
|
|
462
|
+
let markdown = `# ${data.type.charAt(0).toUpperCase() + data.type.slice(1)} Report\n\n`;
|
|
463
|
+
|
|
464
|
+
// Metadata
|
|
465
|
+
markdown += `**Generated:** ${new Date(data.metadata.generatedAt).toLocaleString()}\n`;
|
|
466
|
+
markdown += `**Version:** ${data.metadata.version}\n\n`;
|
|
467
|
+
|
|
468
|
+
// Summary
|
|
469
|
+
if (data.summary) {
|
|
470
|
+
markdown += `## Summary\n\n`;
|
|
471
|
+
for (const [key, value] of Object.entries(data.summary)) {
|
|
472
|
+
markdown += `- **${key}:** ${value}\n`;
|
|
473
|
+
}
|
|
474
|
+
markdown += `\n`;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// Recommendations
|
|
478
|
+
if (data.recommendations && data.recommendations.length > 0) {
|
|
479
|
+
markdown += `## Recommendations\n\n`;
|
|
480
|
+
for (const rec of data.recommendations) {
|
|
481
|
+
markdown += `### ${rec.title} (${rec.priority})\n`;
|
|
482
|
+
markdown += `${rec.description}\n\n`;
|
|
483
|
+
if (rec.files && rec.files.length > 0) {
|
|
484
|
+
markdown += `**Files:**\n`;
|
|
485
|
+
for (const file of rec.files) {
|
|
486
|
+
markdown += `- \`${file}\`\n`;
|
|
487
|
+
}
|
|
488
|
+
markdown += `\n`;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return markdown;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Generate console report
|
|
498
|
+
*/
|
|
499
|
+
generateConsoleReport() {
|
|
500
|
+
const data = this.reportData;
|
|
501
|
+
let output = `\n=== ${data.type.toUpperCase()} REPORT ===\n\n`;
|
|
502
|
+
|
|
503
|
+
// Summary
|
|
504
|
+
if (data.summary) {
|
|
505
|
+
output += "SUMMARY:\n";
|
|
506
|
+
for (const [key, value] of Object.entries(data.summary)) {
|
|
507
|
+
output += ` ${key}: ${value}\n`;
|
|
508
|
+
}
|
|
509
|
+
output += "\n";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return output;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Generate HTML report
|
|
517
|
+
*/
|
|
518
|
+
generateHTMLReport() {
|
|
519
|
+
const data = this.reportData;
|
|
520
|
+
|
|
521
|
+
return `
|
|
522
|
+
<!DOCTYPE html>
|
|
523
|
+
<html>
|
|
524
|
+
<head>
|
|
525
|
+
<title>${data.type} Report</title>
|
|
526
|
+
<style>
|
|
527
|
+
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
528
|
+
.header { background: #f5f5f5; padding: 20px; border-radius: 5px; }
|
|
529
|
+
.summary { margin: 20px 0; }
|
|
530
|
+
.metric { display: inline-block; margin: 10px; padding: 10px; background: #e9ecef; border-radius: 3px; }
|
|
531
|
+
table { border-collapse: collapse; width: 100%; }
|
|
532
|
+
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
|
|
533
|
+
th { background-color: #f2f2f2; }
|
|
534
|
+
</style>
|
|
535
|
+
</head>
|
|
536
|
+
<body>
|
|
537
|
+
<div class="header">
|
|
538
|
+
<h1>${data.type} Report</h1>
|
|
539
|
+
<p>Generated: ${new Date(data.metadata.generatedAt).toLocaleString()}</p>
|
|
540
|
+
</div>
|
|
541
|
+
|
|
542
|
+
<div class="summary">
|
|
543
|
+
<h2>Summary</h2>
|
|
544
|
+
${Object.entries(data.summary || {}).map(([key, value]) =>
|
|
545
|
+
`<div class="metric"><strong>${key}:</strong> ${value}</div>`
|
|
546
|
+
).join('')}
|
|
547
|
+
</div>
|
|
548
|
+
|
|
549
|
+
<script>
|
|
550
|
+
// Add interactive features here if needed
|
|
551
|
+
</script>
|
|
552
|
+
</body>
|
|
553
|
+
</html>`;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Extract package name from file path
|
|
558
|
+
*/
|
|
559
|
+
extractPackageFromPath(filePath) {
|
|
560
|
+
const match = filePath.match(/packages\/([^\/]+)/);
|
|
561
|
+
return match ? match[1] : 'root';
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
module.exports = {
|
|
566
|
+
ReportGenerator,
|
|
567
|
+
REPORT_TYPES,
|
|
568
|
+
OUTPUT_FORMATS
|
|
569
|
+
};
|