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,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Mapping Utility
|
|
3
|
+
* Maps and analyzes file dependencies for refactoring planning
|
|
4
|
+
* Part of specs/010-555-max-file-size implementation (Task T003)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Map dependencies for a given file
|
|
12
|
+
* @param {string} filePath - Path to file to analyze
|
|
13
|
+
* @param {Object} options - Analysis options
|
|
14
|
+
* @returns {Object} Dependency analysis results
|
|
15
|
+
*/
|
|
16
|
+
function mapFileDependencies(filePath, options = {}) {
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
19
|
+
const lines = content.split('\n');
|
|
20
|
+
|
|
21
|
+
const analysis = {
|
|
22
|
+
filePath,
|
|
23
|
+
dependencies: [],
|
|
24
|
+
dependents: [],
|
|
25
|
+
circularDependencies: [],
|
|
26
|
+
externalDependencies: [],
|
|
27
|
+
internalDependencies: [],
|
|
28
|
+
dependencyGraph: {},
|
|
29
|
+
complexity: 'LOW'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Extract imports/requires
|
|
33
|
+
const imports = extractImports(lines);
|
|
34
|
+
|
|
35
|
+
// Categorize dependencies
|
|
36
|
+
imports.forEach(imp => {
|
|
37
|
+
const depInfo = analyzeDependency(imp, filePath, options);
|
|
38
|
+
|
|
39
|
+
if (depInfo.isExternal) {
|
|
40
|
+
analysis.externalDependencies.push(depInfo);
|
|
41
|
+
} else {
|
|
42
|
+
analysis.internalDependencies.push(depInfo);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
analysis.dependencies.push(depInfo);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Build dependency graph
|
|
49
|
+
analysis.dependencyGraph = buildDependencyGraph(filePath, analysis.dependencies);
|
|
50
|
+
|
|
51
|
+
// Assess complexity
|
|
52
|
+
analysis.complexity = assessDependencyComplexity(analysis);
|
|
53
|
+
|
|
54
|
+
return analysis;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
filePath,
|
|
58
|
+
error: error.message,
|
|
59
|
+
dependencies: []
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extract import/require statements from file content
|
|
66
|
+
* @param {Array} lines - File lines
|
|
67
|
+
* @returns {Array} Array of import objects
|
|
68
|
+
*/
|
|
69
|
+
function extractImports(lines) {
|
|
70
|
+
const imports = [];
|
|
71
|
+
|
|
72
|
+
lines.forEach((line, index) => {
|
|
73
|
+
const trimmed = line.trim();
|
|
74
|
+
|
|
75
|
+
// ES6 imports
|
|
76
|
+
const es6Match = trimmed.match(/^import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"]([^'"]+)['"]/);
|
|
77
|
+
if (es6Match) {
|
|
78
|
+
imports.push({
|
|
79
|
+
type: 'es6',
|
|
80
|
+
module: es6Match[1],
|
|
81
|
+
line: index + 1,
|
|
82
|
+
statement: trimmed
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// CommonJS requires
|
|
88
|
+
const cjsMatch = trimmed.match(/(?:const|let|var)\s+(?:\{[^}]+\}|\w+)\s*=\s*require\(['"]([^'"]+)['"]\)/);
|
|
89
|
+
if (cjsMatch) {
|
|
90
|
+
imports.push({
|
|
91
|
+
type: 'commonjs',
|
|
92
|
+
module: cjsMatch[1],
|
|
93
|
+
line: index + 1,
|
|
94
|
+
statement: trimmed
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Direct require calls
|
|
100
|
+
const directMatch = trimmed.match(/require\(['"]([^'"]+)['"]\)/);
|
|
101
|
+
if (directMatch) {
|
|
102
|
+
imports.push({
|
|
103
|
+
type: 'direct',
|
|
104
|
+
module: directMatch[1],
|
|
105
|
+
line: index + 1,
|
|
106
|
+
statement: trimmed
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return imports;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Analyze a dependency
|
|
116
|
+
* @param {Object} importObj - Import object
|
|
117
|
+
* @param {string} sourceFile - Source file path
|
|
118
|
+
* @param {Object} options - Analysis options
|
|
119
|
+
* @returns {Object} Dependency analysis
|
|
120
|
+
*/
|
|
121
|
+
function analyzeDependency(importObj, sourceFile, options = {}) {
|
|
122
|
+
const modulePath = importObj.module;
|
|
123
|
+
const resolvedPath = resolveModulePath(modulePath, sourceFile);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
type: importObj.type,
|
|
127
|
+
module: modulePath,
|
|
128
|
+
resolvedPath,
|
|
129
|
+
line: importObj.line,
|
|
130
|
+
statement: importObj.statement,
|
|
131
|
+
isExternal: isExternalDependency(modulePath, resolvedPath, options),
|
|
132
|
+
isRelative: isRelativePath(modulePath),
|
|
133
|
+
isNodeModule: isNodeModule(modulePath),
|
|
134
|
+
isLocalModule: isLocalModule(modulePath, resolvedPath)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Resolve module path to absolute path
|
|
140
|
+
* @param {string} modulePath - Module path from import
|
|
141
|
+
* @param {string} sourceFile - Source file path
|
|
142
|
+
* @returns {string|null} Resolved absolute path
|
|
143
|
+
*/
|
|
144
|
+
function resolveModulePath(modulePath, sourceFile) {
|
|
145
|
+
try {
|
|
146
|
+
if (isNodeModule(modulePath)) {
|
|
147
|
+
return null; // Node modules don't resolve to local files
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (isRelativePath(modulePath)) {
|
|
151
|
+
const sourceDir = path.dirname(sourceFile);
|
|
152
|
+
const resolved = path.resolve(sourceDir, modulePath);
|
|
153
|
+
|
|
154
|
+
// Try different extensions
|
|
155
|
+
const extensions = ['.js', '.json', '.jsx', '.ts', '.tsx'];
|
|
156
|
+
for (const ext of extensions) {
|
|
157
|
+
const fullPath = resolved.endsWith(ext) ? resolved : resolved + ext;
|
|
158
|
+
if (fs.existsSync(fullPath)) {
|
|
159
|
+
return fullPath;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Try index.js in directory
|
|
164
|
+
const indexPath = path.join(resolved, 'index.js');
|
|
165
|
+
if (fs.existsSync(indexPath)) {
|
|
166
|
+
return indexPath;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Absolute path
|
|
173
|
+
if (path.isAbsolute(modulePath)) {
|
|
174
|
+
return fs.existsSync(modulePath) ? modulePath : null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return null;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Check if dependency is external (third-party)
|
|
185
|
+
* @param {string} modulePath - Module path
|
|
186
|
+
* @param {string} resolvedPath - Resolved path
|
|
187
|
+
* @param {Object} options - Analysis options
|
|
188
|
+
* @returns {boolean}
|
|
189
|
+
*/
|
|
190
|
+
function isExternalDependency(modulePath, resolvedPath, options = {}) {
|
|
191
|
+
// Node modules are external
|
|
192
|
+
if (isNodeModule(modulePath)) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// If we have a list of external modules, check against it
|
|
197
|
+
if (options.externalModules && Array.isArray(options.externalModules)) {
|
|
198
|
+
return options.externalModules.includes(modulePath);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// If resolved path is outside project root, it's external
|
|
202
|
+
if (resolvedPath && options.projectRoot) {
|
|
203
|
+
return !resolvedPath.startsWith(options.projectRoot);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Default: non-relative paths without resolution are external
|
|
207
|
+
return !isRelativePath(modulePath) && !resolvedPath;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Check if path is relative
|
|
212
|
+
* @param {string} modulePath - Module path
|
|
213
|
+
* @returns {boolean}
|
|
214
|
+
*/
|
|
215
|
+
function isRelativePath(modulePath) {
|
|
216
|
+
return modulePath.startsWith('./') || modulePath.startsWith('../');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Check if module is a Node.js module
|
|
221
|
+
* @param {string} modulePath - Module path
|
|
222
|
+
* @returns {boolean}
|
|
223
|
+
*/
|
|
224
|
+
function isNodeModule(modulePath) {
|
|
225
|
+
// Common Node.js modules
|
|
226
|
+
const nodeModules = new Set([
|
|
227
|
+
'fs', 'path', 'os', 'util', 'events', 'stream', 'crypto', 'http', 'https',
|
|
228
|
+
'url', 'querystring', 'assert', 'buffer', 'child_process', 'cluster', 'dgram',
|
|
229
|
+
'dns', 'net', 'readline', 'repl', 'tls', 'tty', 'vm', 'zlib', 'console',
|
|
230
|
+
'timers', 'process', 'module', 'sys'
|
|
231
|
+
]);
|
|
232
|
+
|
|
233
|
+
return nodeModules.has(modulePath) || !modulePath.startsWith('.') && !path.isAbsolute(modulePath);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Check if module is a local module
|
|
238
|
+
* @param {string} modulePath - Module path
|
|
239
|
+
* @param {string} resolvedPath - Resolved path
|
|
240
|
+
* @returns {boolean}
|
|
241
|
+
*/
|
|
242
|
+
function isLocalModule(modulePath, resolvedPath) {
|
|
243
|
+
return resolvedPath !== null && fs.existsSync(resolvedPath);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Build dependency graph
|
|
248
|
+
* @param {string} filePath - Source file path
|
|
249
|
+
* @param {Array} dependencies - Array of dependencies
|
|
250
|
+
* @returns {Object} Dependency graph
|
|
251
|
+
*/
|
|
252
|
+
function buildDependencyGraph(filePath, dependencies) {
|
|
253
|
+
const graph = {
|
|
254
|
+
nodes: [{ id: filePath, type: 'source' }],
|
|
255
|
+
edges: []
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
dependencies.forEach(dep => {
|
|
259
|
+
if (dep.resolvedPath) {
|
|
260
|
+
// Add dependency node if not already present
|
|
261
|
+
if (!graph.nodes.find(n => n.id === dep.resolvedPath)) {
|
|
262
|
+
graph.nodes.push({
|
|
263
|
+
id: dep.resolvedPath,
|
|
264
|
+
type: dep.isExternal ? 'external' : 'internal'
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Add edge
|
|
269
|
+
graph.edges.push({
|
|
270
|
+
from: filePath,
|
|
271
|
+
to: dep.resolvedPath,
|
|
272
|
+
type: dep.type,
|
|
273
|
+
line: dep.line
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return graph;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Assess dependency complexity
|
|
283
|
+
* @param {Object} analysis - Dependency analysis
|
|
284
|
+
* @returns {string} Complexity level
|
|
285
|
+
*/
|
|
286
|
+
function assessDependencyComplexity(analysis) {
|
|
287
|
+
const totalDeps = analysis.dependencies.length;
|
|
288
|
+
const externalDeps = analysis.externalDependencies.length;
|
|
289
|
+
const internalDeps = analysis.internalDependencies.length;
|
|
290
|
+
|
|
291
|
+
if (totalDeps > 20 || internalDeps > 10) {
|
|
292
|
+
return 'HIGH';
|
|
293
|
+
} else if (totalDeps > 10 || internalDeps > 5) {
|
|
294
|
+
return 'MEDIUM';
|
|
295
|
+
} else {
|
|
296
|
+
return 'LOW';
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Find circular dependencies in a set of files
|
|
302
|
+
* @param {Array} filePaths - Array of file paths to analyze
|
|
303
|
+
* @param {Object} options - Analysis options
|
|
304
|
+
* @returns {Array} Array of circular dependency cycles
|
|
305
|
+
*/
|
|
306
|
+
function findCircularDependencies(filePaths, options = {}) {
|
|
307
|
+
const dependencyMap = new Map();
|
|
308
|
+
const cycles = [];
|
|
309
|
+
|
|
310
|
+
// Build dependency map for all files
|
|
311
|
+
filePaths.forEach(filePath => {
|
|
312
|
+
const analysis = mapFileDependencies(filePath, options);
|
|
313
|
+
dependencyMap.set(filePath, analysis.internalDependencies.map(dep => dep.resolvedPath).filter(Boolean));
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Detect cycles using DFS
|
|
317
|
+
const visited = new Set();
|
|
318
|
+
const recursionStack = new Set();
|
|
319
|
+
const pathStack = [];
|
|
320
|
+
|
|
321
|
+
function dfs(node, currentPath) {
|
|
322
|
+
if (recursionStack.has(node)) {
|
|
323
|
+
// Found a cycle
|
|
324
|
+
const cycleStart = currentPath.indexOf(node);
|
|
325
|
+
if (cycleStart !== -1) {
|
|
326
|
+
cycles.push(currentPath.slice(cycleStart).concat(node));
|
|
327
|
+
}
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (visited.has(node)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
visited.add(node);
|
|
336
|
+
recursionStack.add(node);
|
|
337
|
+
currentPath.push(node);
|
|
338
|
+
|
|
339
|
+
const dependencies = dependencyMap.get(node) || [];
|
|
340
|
+
dependencies.forEach(dep => {
|
|
341
|
+
if (filePaths.includes(dep)) {
|
|
342
|
+
dfs(dep, [...currentPath]);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
recursionStack.delete(node);
|
|
347
|
+
currentPath.pop();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
filePaths.forEach(filePath => {
|
|
351
|
+
if (!visited.has(filePath)) {
|
|
352
|
+
dfs(filePath, []);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
return cycles;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Generate dependency report
|
|
361
|
+
* @param {Array} filePaths - Array of file paths to analyze
|
|
362
|
+
* @param {Object} options - Analysis options
|
|
363
|
+
* @returns {Object} Comprehensive dependency report
|
|
364
|
+
*/
|
|
365
|
+
function generateDependencyReport(filePaths, options = {}) {
|
|
366
|
+
const report = {
|
|
367
|
+
summary: {
|
|
368
|
+
totalFiles: filePaths.length,
|
|
369
|
+
totalDependencies: 0,
|
|
370
|
+
externalDependencies: 0,
|
|
371
|
+
internalDependencies: 0,
|
|
372
|
+
circularDependencies: 0,
|
|
373
|
+
highComplexityFiles: 0
|
|
374
|
+
},
|
|
375
|
+
files: [],
|
|
376
|
+
circularDependencies: [],
|
|
377
|
+
recommendations: []
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// Analyze each file
|
|
381
|
+
filePaths.forEach(filePath => {
|
|
382
|
+
const analysis = mapFileDependencies(filePath, options);
|
|
383
|
+
report.files.push(analysis);
|
|
384
|
+
|
|
385
|
+
// Update summary
|
|
386
|
+
report.summary.totalDependencies += analysis.dependencies.length;
|
|
387
|
+
report.summary.externalDependencies += analysis.externalDependencies.length;
|
|
388
|
+
report.summary.internalDependencies += analysis.internalDependencies.length;
|
|
389
|
+
|
|
390
|
+
if (analysis.complexity === 'HIGH') {
|
|
391
|
+
report.summary.highComplexityFiles++;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// Find circular dependencies
|
|
396
|
+
report.circularDependencies = findCircularDependencies(filePaths, options);
|
|
397
|
+
report.summary.circularDependencies = report.circularDependencies.length;
|
|
398
|
+
|
|
399
|
+
// Generate recommendations
|
|
400
|
+
report.recommendations = generateDependencyRecommendations(report);
|
|
401
|
+
|
|
402
|
+
return report;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Generate refactoring recommendations based on dependency analysis
|
|
407
|
+
* @param {Object} report - Dependency report
|
|
408
|
+
* @returns {Array} Array of recommendations
|
|
409
|
+
*/
|
|
410
|
+
function generateDependencyRecommendations(report) {
|
|
411
|
+
const recommendations = [];
|
|
412
|
+
|
|
413
|
+
// High complexity files
|
|
414
|
+
if (report.summary.highComplexityFiles > 0) {
|
|
415
|
+
recommendations.push({
|
|
416
|
+
type: 'complexity',
|
|
417
|
+
priority: 'HIGH',
|
|
418
|
+
description: `${report.summary.highComplexityFiles} files have high dependency complexity`,
|
|
419
|
+
action: 'Consider refactoring to reduce coupling'
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Circular dependencies
|
|
424
|
+
if (report.summary.circularDependencies > 0) {
|
|
425
|
+
recommendations.push({
|
|
426
|
+
type: 'circular',
|
|
427
|
+
priority: 'HIGH',
|
|
428
|
+
description: `${report.summary.circularDependencies} circular dependency cycles detected`,
|
|
429
|
+
action: 'Resolve circular dependencies before refactoring'
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Many external dependencies
|
|
434
|
+
if (report.summary.externalDependencies > report.summary.totalDependencies * 0.7) {
|
|
435
|
+
recommendations.push({
|
|
436
|
+
type: 'external',
|
|
437
|
+
priority: 'MEDIUM',
|
|
438
|
+
description: 'High ratio of external dependencies',
|
|
439
|
+
action: 'Review external dependencies for consolidation'
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return recommendations;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
module.exports = {
|
|
447
|
+
mapFileDependencies,
|
|
448
|
+
findCircularDependencies,
|
|
449
|
+
generateDependencyReport,
|
|
450
|
+
extractImports,
|
|
451
|
+
analyzeDependency,
|
|
452
|
+
resolveModulePath,
|
|
453
|
+
isExternalDependency,
|
|
454
|
+
isNodeModule,
|
|
455
|
+
isLocalModule
|
|
456
|
+
};
|
|
@@ -2,7 +2,8 @@ const fs = require('fs');
|
|
|
2
2
|
const { pipeline } = require('stream');
|
|
3
3
|
const { promisify } = require('util');
|
|
4
4
|
const streamPipeline = promisify(pipeline);
|
|
5
|
-
const
|
|
5
|
+
const oraModule = require('ora');
|
|
6
|
+
const ora = oraModule.default || oraModule;
|
|
6
7
|
|
|
7
8
|
function progressBar(percent, width) {
|
|
8
9
|
const fill = Math.round((percent / 100) * width);
|
|
@@ -18,7 +19,8 @@ function formatEta(sec) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async function downloadWithProgress(url, dest, opts = {}) {
|
|
21
|
-
const
|
|
22
|
+
const fetchModule = require('node-fetch');
|
|
23
|
+
const fetch = fetchModule.default || fetchModule;
|
|
22
24
|
const spinner = opts.spinner || ora();
|
|
23
25
|
const label = opts.label || 'Downloading...';
|
|
24
26
|
const onProgress = typeof opts.onProgress === 'function' ? opts.onProgress : null;
|
|
@@ -48,7 +48,10 @@ const { shouldCheckUpdates } = require('./env-helpers');
|
|
|
48
48
|
*/
|
|
49
49
|
async function checkForElectronUpdates(currentVersion) {
|
|
50
50
|
if (!shouldCheckUpdates()) {
|
|
51
|
-
|
|
51
|
+
// Quiet development message - only show in debug mode
|
|
52
|
+
if (process.env.NODE_ENV === 'development' && process.env.DEBUG) {
|
|
53
|
+
console.log('ℹ️ [UPDATE CHECK] Skipped in development environment');
|
|
54
|
+
}
|
|
52
55
|
return { hasUpdate: false, currentVersion };
|
|
53
56
|
}
|
|
54
57
|
|