vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agents/AgentCheckDiscoveryService.js +180 -0
- package/src/agents/AgentCheckService.js +18 -261
- package/src/agents/AgentCheckStatisticsService.js +195 -0
- package/src/agents/EnvironmentConfigurationManager.js +31 -380
- package/src/agents/InstallationType.js +19 -6
- package/src/agents/SimpleAgentCheckService.js +472 -0
- package/src/agents/config-managers/ConfigUtils.js +72 -0
- package/src/agents/config-managers/DefaultConfig.js +58 -0
- package/src/agents/config-managers/EnvVarLoader.js +66 -0
- package/src/agents/config-managers/FileConfigLoader.js +124 -0
- package/src/agents/config-managers/TypeConverters.js +61 -0
- package/src/agents/config-managers/VariableMappings.js +92 -0
- package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
- package/src/agents/discovery/AgentDiscoveryService.js +29 -403
- package/src/agents/discovery/agent-validator.js +262 -0
- package/src/agents/discovery/discovery-results.js +176 -0
- package/src/agents/discovery/discovery-scanner.js +268 -0
- package/src/agents/discovery/discovery-utils.js +161 -0
- package/src/agents/discovery/executable-analyzer.js +290 -0
- package/src/agents/discovery/history-manager.js +310 -0
- package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
- package/src/agents/verification/ResultAnalyzer.js +30 -431
- package/src/agents/verification/analysis-utils.js +310 -0
- package/src/agents/verification/batch-analyzer.js +440 -0
- package/src/agents/verification/pattern-recognizer.js +369 -0
- package/src/agents/verification/report-generator.js +320 -0
- package/src/agents/verification/test-analyzer.js +290 -0
- package/src/agents/windows/InstallerFactory.js +4 -0
- package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
- package/src/analysis/analysis-engine.js +314 -0
- package/src/analysis/ast-analyzer.js +342 -0
- package/src/analysis/boundary-detector-refactored.js +378 -0
- package/src/analysis/boundary-detector.js +200 -603
- package/src/analysis/boundary-scanner.js +609 -0
- package/src/analysis/boundary-types.js +118 -0
- package/src/analysis/boundary-utils.js +293 -0
- package/src/analysis/deadline-priority-calculator.js +18 -0
- package/src/analysis/detection-methods.js +347 -0
- package/src/analysis/importance-priority-calculator.js +18 -0
- package/src/analysis/priority/factor-calculators.js +204 -0
- package/src/analysis/priority/factor-helpers.js +71 -0
- package/src/analysis/priority/priority-constants.js +73 -0
- package/src/analysis/priority/priority-factor-calculators.js +301 -0
- package/src/analysis/priority/reasons-generator.js +44 -0
- package/src/analysis/priority-calculator.js +15 -580
- package/src/analysis/strategy-generator.js +16 -66
- package/src/analysis/type-priority-calculator.js +18 -0
- package/src/analysis/urgency-priority-calculator.js +18 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
- package/src/commands/disable-requirement.js +60 -0
- package/src/commands/disable-spec.js +60 -0
- package/src/commands/enable-requirement.js +60 -0
- package/src/commands/enable-spec.js +60 -0
- package/src/commands/registry.js +1 -6
- package/src/commands/requirements.js +8 -2
- package/src/ide-integration/applescript-manager.cjs +9 -24
- package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
- package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
- package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
- package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
- package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
- package/src/ide-integration/cdp-manager.js +28 -573
- package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
- package/src/ide-integration/ide-openers/claude-opener.js +171 -0
- package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
- package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
- package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
- package/src/ide-integration/macos-ide-manager.js +20 -582
- package/src/ide-integration/macos-quota-checker.js +164 -0
- package/src/ide-integration/macos-text-sender.js +19 -38
- package/src/ide-integration/provider-manager.cjs +52 -7
- package/src/index.cjs +6 -0
- package/src/index.js +10 -0
- package/src/llm/direct-llm-manager.cjs +501 -0
- package/src/localization/translations/en-part1.js +363 -0
- package/src/localization/translations/en-part2.js +320 -0
- package/src/localization/translations/en.js +4 -687
- package/src/localization/translations/es-part1.js +363 -0
- package/src/localization/translations/es-part2.js +320 -0
- package/src/localization/translations/es.js +4 -688
- package/src/models/file-analysis-collection.js +139 -0
- package/src/models/file-analysis-metrics.js +50 -0
- package/src/models/file-analysis.js +15 -262
- package/src/models/plan-manager.js +410 -0
- package/src/models/refactoring-models.js +380 -0
- package/src/models/refactoring-plan-refactored.js +81 -0
- package/src/models/refactoring-plan.js +2 -663
- package/src/monitoring/alert-system.js +4 -45
- package/src/monitoring/continuous-scan-notifications.js +37 -191
- package/src/monitoring/notification-handlers/base-handler.js +58 -0
- package/src/monitoring/notification-handlers/error-handler.js +36 -0
- package/src/monitoring/notification-handlers/index.js +21 -0
- package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
- package/src/monitoring/notification-handlers/progress-handler.js +48 -0
- package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
- package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
- package/src/provider-registry.js +8 -0
- package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
- package/src/refactoring/boundary/boundary-detector.js +26 -596
- package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
- package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
- package/src/refactoring/boundary/detectors/class-detector.js +247 -0
- package/src/refactoring/boundary/detectors/config-detector.js +270 -0
- package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
- package/src/refactoring/boundary/detectors/function-detector.js +248 -0
- package/src/refactoring/boundary/detectors/module-detector.js +249 -0
- package/src/refactoring/boundary/detectors/object-detector.js +247 -0
- package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
- package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
- package/src/refactoring/circular-dependency-resolver-original.js +16 -76
- package/src/refactoring/code-mover-refactored.js +309 -0
- package/src/refactoring/code-mover.js +48 -355
- package/src/refactoring/execution-status.js +18 -0
- package/src/refactoring/execution-strategies.js +172 -0
- package/src/refactoring/file-splitter-core.js +568 -0
- package/src/refactoring/file-splitter-types.js +136 -0
- package/src/refactoring/file-splitter.js +2 -682
- package/src/refactoring/functionality-validator.js +11 -51
- package/src/refactoring/import-manager-refactored.js +385 -0
- package/src/refactoring/import-manager.js +112 -487
- package/src/refactoring/import-models.js +189 -0
- package/src/refactoring/import-parser.js +306 -0
- package/src/refactoring/move-executor.js +431 -0
- package/src/refactoring/move-utils.js +368 -0
- package/src/refactoring/operation-executor.js +76 -0
- package/src/refactoring/plan-creator.js +36 -0
- package/src/refactoring/plan-executor.js +143 -0
- package/src/refactoring/plan-validator.js +68 -0
- package/src/refactoring/refactoring-executor-result.js +70 -0
- package/src/refactoring/refactoring-executor.js +34 -569
- package/src/refactoring/refactoring-operation.js +94 -0
- package/src/refactoring/refactoring-plan.js +69 -0
- package/src/refactoring/refactoring-rollback.js +22 -527
- package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
- package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
- package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
- package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
- package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
- package/src/refactoring/test-validator.js +32 -448
- package/src/refactoring/validation/baseline-runner.js +71 -0
- package/src/refactoring/validation/report-generator.js +136 -0
- package/src/refactoring/validation/result-comparator.js +92 -0
- package/src/refactoring/validation/test-suite.js +59 -0
- package/src/refactoring/validation/test-validation-result.js +83 -0
- package/src/refactoring/validation/validation-runner.js +95 -0
- package/src/refactoring/validation/validation-status.js +18 -0
- package/src/rui/commands/AgentCommandParser.js +60 -369
- package/src/rui/commands/AgentResponseFormatter.js +7 -47
- package/src/rui/commands/parsers/CommandMapper.js +148 -0
- package/src/rui/commands/parsers/CommandValidator.js +228 -0
- package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
- package/src/rui/commands/parsers/TokenParser.js +69 -0
- package/src/rui/commands/parsers/tokenizer.js +153 -0
- package/src/utils/current-requirement-operations.js +50 -1
- package/src/utils/report-generator.js +18 -514
- package/src/utils/report-generators/analysis-generator.js +115 -0
- package/src/utils/report-generators/base-generator.js +141 -0
- package/src/utils/report-generators/compliance-generator.js +41 -0
- package/src/utils/report-generators/format-handlers.js +185 -0
- package/src/utils/report-generators/refactoring-generator.js +46 -0
- package/src/utils/report-generators/validation-generator.js +63 -0
- package/src/utils/requirement-enable-disable.js +265 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
- package/src/utils/requirement-helpers/requirement-mover.js +88 -1
- package/src/utils/requirement-helpers.js +5 -2
- package/src/utils/smoke-test-cli.js +45 -8
- package/src/utils/specification-enable-disable.js +122 -0
- package/src/utils/specification-helpers.js +30 -4
- package/src/utils/specification-migration.js +5 -5
- package/src/utils/test-comparator.js +118 -0
- package/src/utils/test-config.js +54 -0
- package/src/utils/test-executor.js +133 -0
- package/src/utils/test-parser.js +215 -0
- package/src/utils/test-runner-baseline.js +63 -0
- package/src/utils/test-runner-core.js +98 -0
- package/src/utils/test-runner-report.js +39 -0
- package/src/utils/test-runner-validation.js +71 -0
- package/src/utils/test-runner.js +11 -535
- package/src/validation/comparison-analyzer.js +333 -0
- package/src/validation/compliance-reporter-new.js +282 -0
- package/src/validation/compliance-reporter-refactored.js +344 -0
- package/src/validation/compliance-reporter.js +278 -591
- package/src/validation/compliance-utils.js +278 -0
- package/src/validation/html-generator.js +446 -0
- package/src/validation/metrics/category-calculator.js +137 -0
- package/src/validation/metrics/metrics-helpers.js +155 -0
- package/src/validation/metrics/overview-calculator.js +85 -0
- package/src/validation/metrics/overview-metrics.js +41 -0
- package/src/validation/metrics/quality-calculator.js +166 -0
- package/src/validation/metrics/size-calculator.js +69 -0
- package/src/validation/metrics-calculator.js +27 -551
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boundary Analysis Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for boundary detection and analysis.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Boundary types
|
|
9
|
+
*/
|
|
10
|
+
const BOUNDARY_TYPES = {
|
|
11
|
+
FUNCTION: 'function',
|
|
12
|
+
CLASS: 'class',
|
|
13
|
+
MODULE: 'module',
|
|
14
|
+
BLOCK: 'block',
|
|
15
|
+
IMPORT: 'import',
|
|
16
|
+
EXPORT: 'export',
|
|
17
|
+
COMMENT: 'comment',
|
|
18
|
+
UTILITY: 'utility',
|
|
19
|
+
CONSTANT: 'constant'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create boundary object
|
|
24
|
+
* @param {string} type - Boundary type
|
|
25
|
+
* @param {number} start - Start position
|
|
26
|
+
* @param {number} end - End position
|
|
27
|
+
* @param {string} name - Boundary name
|
|
28
|
+
* @param {Object} metadata - Additional metadata
|
|
29
|
+
* @returns {Object} - Boundary object
|
|
30
|
+
*/
|
|
31
|
+
function createBoundary(type, start, end, name, metadata = {}) {
|
|
32
|
+
return {
|
|
33
|
+
type,
|
|
34
|
+
start,
|
|
35
|
+
end,
|
|
36
|
+
name,
|
|
37
|
+
size: end - start,
|
|
38
|
+
complexity: metadata.complexity || 1,
|
|
39
|
+
dependencies: metadata.dependencies || [],
|
|
40
|
+
exports: metadata.exports || [],
|
|
41
|
+
imports: metadata.imports || [],
|
|
42
|
+
metadata
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Analyze boundary complexity
|
|
48
|
+
* @param {Object} boundary - Boundary object
|
|
49
|
+
* @returns {number} - Complexity score
|
|
50
|
+
*/
|
|
51
|
+
function analyzeBoundaryComplexity(boundary) {
|
|
52
|
+
let complexity = 1;
|
|
53
|
+
|
|
54
|
+
// Base complexity by type
|
|
55
|
+
const typeComplexity = {
|
|
56
|
+
[BOUNDARY_TYPES.CLASS]: 3,
|
|
57
|
+
[BOUNDARY_TYPES.FUNCTION]: 2,
|
|
58
|
+
[BOUNDARY_TYPES.MODULE]: 4,
|
|
59
|
+
[BOUNDARY_TYPES.BLOCK]: 1,
|
|
60
|
+
[BOUNDARY_TYPES.UTILITY]: 2,
|
|
61
|
+
[BOUNDARY_TYPES.CONSTANT]: 1
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
complexity += typeComplexity[boundary.type] || 1;
|
|
65
|
+
|
|
66
|
+
// Add dependency complexity
|
|
67
|
+
if (boundary.dependencies) {
|
|
68
|
+
complexity += boundary.dependencies.length * 0.5;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Add size complexity
|
|
72
|
+
if (boundary.size > 100) {
|
|
73
|
+
complexity += 2;
|
|
74
|
+
} else if (boundary.size > 50) {
|
|
75
|
+
complexity += 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return Math.round(complexity);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Calculate boundary cohesion
|
|
83
|
+
* @param {Object} boundary - Boundary object
|
|
84
|
+
* @returns {string} - Cohesion level
|
|
85
|
+
*/
|
|
86
|
+
function calculateBoundaryCohesion(boundary) {
|
|
87
|
+
if (!boundary.dependencies || boundary.dependencies.length === 0) {
|
|
88
|
+
return 'high';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const relatedDependencies = boundary.dependencies.filter(dep =>
|
|
92
|
+
boundary.name && dep.includes(boundary.name.toLowerCase())
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const cohesionRatio = relatedDependencies.length / boundary.dependencies.length;
|
|
96
|
+
|
|
97
|
+
if (cohesionRatio > 0.8) return 'high';
|
|
98
|
+
if (cohesionRatio > 0.6) return 'medium';
|
|
99
|
+
if (cohesionRatio > 0.4) return 'low';
|
|
100
|
+
return 'very_low';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Calculate boundary coupling
|
|
105
|
+
* @param {Object} boundary - Boundary object
|
|
106
|
+
* @param {Array} allBoundaries - All boundaries in file
|
|
107
|
+
* @returns {string} - Coupling level
|
|
108
|
+
*/
|
|
109
|
+
function calculateBoundaryCoupling(boundary, allBoundaries) {
|
|
110
|
+
const externalDependencies = boundary.dependencies.filter(dep => {
|
|
111
|
+
return !allBoundaries.some(other =>
|
|
112
|
+
other.name && other.name !== boundary.name && dep.includes(other.name.toLowerCase())
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const couplingRatio = externalDependencies.length / (boundary.dependencies.length || 1);
|
|
117
|
+
|
|
118
|
+
if (couplingRatio > 0.7) return 'high';
|
|
119
|
+
if (couplingRatio > 0.5) return 'medium';
|
|
120
|
+
if (couplingRatio > 0.3) return 'low';
|
|
121
|
+
return 'very_low';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Group boundaries by type
|
|
126
|
+
* @param {Array} boundaries - Array of boundaries
|
|
127
|
+
* @returns {Object} - Boundaries grouped by type
|
|
128
|
+
*/
|
|
129
|
+
function groupBoundariesByType(boundaries) {
|
|
130
|
+
const grouped = {};
|
|
131
|
+
|
|
132
|
+
boundaries.forEach(boundary => {
|
|
133
|
+
if (!grouped[boundary.type]) {
|
|
134
|
+
grouped[boundary.type] = [];
|
|
135
|
+
}
|
|
136
|
+
grouped[boundary.type].push(boundary);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return grouped;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Find boundary relationships
|
|
144
|
+
* @param {Array} boundaries - Array of boundaries
|
|
145
|
+
* @returns {Array} - Array of relationships
|
|
146
|
+
*/
|
|
147
|
+
function findBoundaryRelationships(boundaries) {
|
|
148
|
+
const relationships = [];
|
|
149
|
+
|
|
150
|
+
boundaries.forEach(boundary => {
|
|
151
|
+
if (boundary.dependencies) {
|
|
152
|
+
boundary.dependencies.forEach(dep => {
|
|
153
|
+
const target = boundaries.find(b =>
|
|
154
|
+
b.name && dep.includes(b.name.toLowerCase())
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
if (target) {
|
|
158
|
+
relationships.push({
|
|
159
|
+
source: boundary.name,
|
|
160
|
+
target: target.name,
|
|
161
|
+
type: 'dependency',
|
|
162
|
+
strength: calculateDependencyStrength(boundary, target)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return relationships;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Calculate dependency strength
|
|
174
|
+
* @param {Object} source - Source boundary
|
|
175
|
+
* @param {Object} target - Target boundary
|
|
176
|
+
* @returns {number} - Dependency strength
|
|
177
|
+
*/
|
|
178
|
+
function calculateDependencyStrength(source, target) {
|
|
179
|
+
let strength = 1;
|
|
180
|
+
|
|
181
|
+
// Same type increases strength
|
|
182
|
+
if (source.type === target.type) {
|
|
183
|
+
strength += 0.5;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Size difference affects strength
|
|
187
|
+
const sizeRatio = Math.min(source.size, target.size) / Math.max(source.size, target.size);
|
|
188
|
+
strength += sizeRatio;
|
|
189
|
+
|
|
190
|
+
return Math.round(strength * 10) / 10;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Generate boundary recommendations
|
|
195
|
+
* @param {Array} boundaries - Array of boundaries
|
|
196
|
+
* @returns {Array} - Array of recommendations
|
|
197
|
+
*/
|
|
198
|
+
function generateBoundaryRecommendations(boundaries) {
|
|
199
|
+
const recommendations = [];
|
|
200
|
+
|
|
201
|
+
// Check for large boundaries
|
|
202
|
+
const largeBoundaries = boundaries.filter(b => b.size > 100);
|
|
203
|
+
if (largeBoundaries.length > 0) {
|
|
204
|
+
recommendations.push({
|
|
205
|
+
type: 'size',
|
|
206
|
+
priority: 'high',
|
|
207
|
+
message: `${largeBoundaries.length} boundaries exceed 100 lines`,
|
|
208
|
+
action: 'split_large_boundaries'
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Check for high complexity
|
|
213
|
+
const highComplexity = boundaries.filter(b => analyzeBoundaryComplexity(b) > 5);
|
|
214
|
+
if (highComplexity.length > 0) {
|
|
215
|
+
recommendations.push({
|
|
216
|
+
type: 'complexity',
|
|
217
|
+
priority: 'medium',
|
|
218
|
+
message: `${highComplexity.length} boundaries have high complexity`,
|
|
219
|
+
action: 'reduce_complexity'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Check for low cohesion
|
|
224
|
+
const lowCohesion = boundaries.filter(b => calculateBoundaryCohesion(b) === 'low' || calculateBoundaryCohesion(b) === 'very_low');
|
|
225
|
+
if (lowCohesion.length > 0) {
|
|
226
|
+
recommendations.push({
|
|
227
|
+
type: 'cohesion',
|
|
228
|
+
priority: 'medium',
|
|
229
|
+
message: `${lowCohesion.length} boundaries have low cohesion`,
|
|
230
|
+
action: 'improve_cohesion'
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return recommendations;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Validate boundary object
|
|
239
|
+
* @param {Object} boundary - Boundary to validate
|
|
240
|
+
* @returns {Object} - Validation result
|
|
241
|
+
*/
|
|
242
|
+
function validateBoundary(boundary) {
|
|
243
|
+
const validation = {
|
|
244
|
+
isValid: true,
|
|
245
|
+
errors: [],
|
|
246
|
+
warnings: []
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Check required fields
|
|
250
|
+
if (!boundary.type) {
|
|
251
|
+
validation.isValid = false;
|
|
252
|
+
validation.errors.push('Missing boundary type');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (typeof boundary.start !== 'number') {
|
|
256
|
+
validation.isValid = false;
|
|
257
|
+
validation.errors.push('Invalid start position');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (typeof boundary.end !== 'number') {
|
|
261
|
+
validation.isValid = false;
|
|
262
|
+
validation.errors.push('Invalid end position');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (boundary.start >= boundary.end) {
|
|
266
|
+
validation.isValid = false;
|
|
267
|
+
validation.errors.push('Start position must be less than end position');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Warnings
|
|
271
|
+
if (boundary.size > 200) {
|
|
272
|
+
validation.warnings.push('Boundary is very large (>200 lines)');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (analyzeBoundaryComplexity(boundary) > 10) {
|
|
276
|
+
validation.warnings.push('Boundary has very high complexity (>10)');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return validation;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
module.exports = {
|
|
283
|
+
BOUNDARY_TYPES,
|
|
284
|
+
createBoundary,
|
|
285
|
+
analyzeBoundaryComplexity,
|
|
286
|
+
calculateBoundaryCohesion,
|
|
287
|
+
calculateBoundaryCoupling,
|
|
288
|
+
groupBoundariesByType,
|
|
289
|
+
findBoundaryRelationships,
|
|
290
|
+
calculateDependencyStrength,
|
|
291
|
+
generateBoundaryRecommendations,
|
|
292
|
+
validateBoundary
|
|
293
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadline Priority Calculator
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function calculateDeadlinePriority(data) {
|
|
6
|
+
// Calculate deadline priority
|
|
7
|
+
const deadlinePriority = 0;
|
|
8
|
+
if (data.deadline === 'soon') {
|
|
9
|
+
deadlinePriority += 40;
|
|
10
|
+
} else if (data.deadline === 'medium') {
|
|
11
|
+
deadlinePriority += 20;
|
|
12
|
+
} else {
|
|
13
|
+
deadlinePriority += 4;
|
|
14
|
+
}
|
|
15
|
+
return deadlinePriority;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { calculateDeadlinePriority };
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boundary Detection - Detection Methods
|
|
3
|
+
*
|
|
4
|
+
* Methods for detecting different types of boundaries in code.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { BOUNDARY_TYPES, Boundary } = require('./boundary-types');
|
|
8
|
+
const {
|
|
9
|
+
findMethodBoundary,
|
|
10
|
+
findClassBoundary,
|
|
11
|
+
findModuleBoundary,
|
|
12
|
+
extractFunctionName,
|
|
13
|
+
extractClassName,
|
|
14
|
+
extractModuleName,
|
|
15
|
+
calculateBoundaryComplexity,
|
|
16
|
+
findDependencies,
|
|
17
|
+
findExports
|
|
18
|
+
} = require('./ast-analyzer');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Detect function boundaries
|
|
22
|
+
* @param {Array} lines - File lines
|
|
23
|
+
* @param {Object} result - Detection result
|
|
24
|
+
*/
|
|
25
|
+
function detectFunctions(lines, result) {
|
|
26
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27
|
+
const line = lines[i].trim();
|
|
28
|
+
|
|
29
|
+
// Function patterns
|
|
30
|
+
const patterns = [
|
|
31
|
+
/function\s+(\w+)\s*\(/, // function name()
|
|
32
|
+
/const\s+(\w+)\s*=\s*(async\s+)?/, // const name = async
|
|
33
|
+
/let\s+(\w+)\s*=\s*(async\s+)?/, // let name = async
|
|
34
|
+
/var\s+(\w+)\s*=\s*(async\s+)?/, // var name = async
|
|
35
|
+
/(\w+)\s*:\s*function\s*\(/, // name: function()
|
|
36
|
+
/(\w+)\s*=>\s*\(/, // arrow function
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
for (const pattern of patterns) {
|
|
40
|
+
const match = line.match(pattern);
|
|
41
|
+
if (match) {
|
|
42
|
+
const functionName = match[1];
|
|
43
|
+
const boundary = findMethodBoundary(lines, i, functionName);
|
|
44
|
+
|
|
45
|
+
if (boundary) {
|
|
46
|
+
boundary.metadata = {
|
|
47
|
+
pattern: pattern.source,
|
|
48
|
+
extractedName: functionName
|
|
49
|
+
};
|
|
50
|
+
result.addBoundary(boundary);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Detect class boundaries
|
|
59
|
+
* @param {Array} lines - File lines
|
|
60
|
+
* @param {Object} result - Detection result
|
|
61
|
+
*/
|
|
62
|
+
function detectClasses(lines, result) {
|
|
63
|
+
for (let i = 0; i < lines.length; i++) {
|
|
64
|
+
const line = lines[i].trim();
|
|
65
|
+
|
|
66
|
+
const classMatch = line.match(/^class\s+(\w+)/);
|
|
67
|
+
if (classMatch) {
|
|
68
|
+
const className = classMatch[1];
|
|
69
|
+
const boundary = findClassBoundary(lines, i, className);
|
|
70
|
+
|
|
71
|
+
if (boundary) {
|
|
72
|
+
boundary.metadata = {
|
|
73
|
+
pattern: 'class',
|
|
74
|
+
extractedName: className
|
|
75
|
+
};
|
|
76
|
+
result.addBoundary(boundary);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Detect module boundaries
|
|
84
|
+
* @param {Array} lines - File lines
|
|
85
|
+
* @param {Object} result - Detection result
|
|
86
|
+
*/
|
|
87
|
+
function detectModules(lines, result) {
|
|
88
|
+
for (let i = 0; i < lines.length; i++) {
|
|
89
|
+
const line = lines[i].trim();
|
|
90
|
+
|
|
91
|
+
// Module patterns
|
|
92
|
+
const patterns = [
|
|
93
|
+
/module\.exports\s*=\s*(\w+)/, // module.exports = Name
|
|
94
|
+
/exports\.(\w+)\s*=/, // exports.Name =
|
|
95
|
+
/export\s+default\s+(\w+)/, // export default Name
|
|
96
|
+
/export\s+{\s*(\w+)\s*:/, // export { Name }:
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
for (const pattern of patterns) {
|
|
100
|
+
const match = line.match(pattern);
|
|
101
|
+
if (match) {
|
|
102
|
+
const moduleName = match[1];
|
|
103
|
+
const boundary = findModuleBoundary(lines, i, moduleName);
|
|
104
|
+
|
|
105
|
+
if (boundary) {
|
|
106
|
+
boundary.metadata = {
|
|
107
|
+
pattern: pattern.source,
|
|
108
|
+
extractedName: moduleName
|
|
109
|
+
};
|
|
110
|
+
result.addBoundary(boundary);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Detect utility sections
|
|
119
|
+
* @param {Array} lines - File lines
|
|
120
|
+
* @param {Object} result - Detection result
|
|
121
|
+
*/
|
|
122
|
+
function detectUtilities(lines, result) {
|
|
123
|
+
// Look for sections with utility functions
|
|
124
|
+
let utilityStart = null;
|
|
125
|
+
let utilityName = null;
|
|
126
|
+
|
|
127
|
+
for (let i = 0; i < lines.length; i++) {
|
|
128
|
+
const line = lines[i].trim();
|
|
129
|
+
|
|
130
|
+
// Detect utility section comments
|
|
131
|
+
if (line.includes('// Utilities') || line.includes('/* Utilities')) {
|
|
132
|
+
utilityStart = i + 1;
|
|
133
|
+
const commentMatch = line.match(/\/\*\s*(\w+)/);
|
|
134
|
+
if (commentMatch) {
|
|
135
|
+
utilityName = commentMatch[1];
|
|
136
|
+
}
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// If we found a utility section, look for its end
|
|
141
|
+
if (utilityStart !== null) {
|
|
142
|
+
const boundary = findBlockBoundary(lines, utilityStart, utilityName || 'utilities');
|
|
143
|
+
|
|
144
|
+
if (boundary) {
|
|
145
|
+
boundary.type = BOUNDARY_TYPES.UTILITY;
|
|
146
|
+
boundary.metadata = {
|
|
147
|
+
section: 'utilities',
|
|
148
|
+
extractedName: utilityName
|
|
149
|
+
};
|
|
150
|
+
result.addBoundary(boundary);
|
|
151
|
+
utilityStart = null;
|
|
152
|
+
utilityName = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Detect import boundaries
|
|
160
|
+
* @param {Array} lines - File lines
|
|
161
|
+
* @param {Object} result - Detection result
|
|
162
|
+
*/
|
|
163
|
+
function detectImports(lines, result) {
|
|
164
|
+
for (let i = 0; i < lines.length; i++) {
|
|
165
|
+
const line = lines[i].trim();
|
|
166
|
+
|
|
167
|
+
// Import patterns
|
|
168
|
+
const patterns = [
|
|
169
|
+
/require\s*\(\s*['"]([^'"]+)['"]\s*\)/,
|
|
170
|
+
/import\s+.*\s+from\s+['"]([^'"]+)['"]/,
|
|
171
|
+
/import\s*\(\s*['"]([^'"]+)['"]\s*\)/
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
for (const pattern of patterns) {
|
|
175
|
+
const match = line.match(pattern);
|
|
176
|
+
if (match) {
|
|
177
|
+
const importName = match[1];
|
|
178
|
+
const boundary = new Boundary(
|
|
179
|
+
BOUNDARY_TYPES.IMPORT,
|
|
180
|
+
i,
|
|
181
|
+
i,
|
|
182
|
+
importName
|
|
183
|
+
);
|
|
184
|
+
boundary.metadata = {
|
|
185
|
+
pattern: pattern.source,
|
|
186
|
+
extractedName: importName
|
|
187
|
+
};
|
|
188
|
+
result.addBoundary(boundary);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Detect export boundaries
|
|
196
|
+
* @param {Array} lines - File lines
|
|
197
|
+
* @param {Object} result - Detection result
|
|
198
|
+
*/
|
|
199
|
+
function detectExports(lines, result) {
|
|
200
|
+
for (let i = 0; i < lines.length; i++) {
|
|
201
|
+
const line = lines[i].trim();
|
|
202
|
+
|
|
203
|
+
// Export patterns
|
|
204
|
+
const patterns = [
|
|
205
|
+
/module\.exports\.(\w+)\s*=/,
|
|
206
|
+
/exports\.(\w+)\s*=/,
|
|
207
|
+
/export\s+default\s+(\w+)/,
|
|
208
|
+
/export\s+{\s*(\w+)\s*[,}]/,
|
|
209
|
+
/export\s+{\s*(\w+)\s+as\s+(\w+)\s*[,}]/
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
for (const pattern of patterns) {
|
|
213
|
+
const match = line.match(pattern);
|
|
214
|
+
if (match) {
|
|
215
|
+
const exportName = match[1] || match[2];
|
|
216
|
+
const boundary = new Boundary(
|
|
217
|
+
BOUNDARY_TYPES.EXPORT,
|
|
218
|
+
i,
|
|
219
|
+
i,
|
|
220
|
+
exportName
|
|
221
|
+
);
|
|
222
|
+
boundary.metadata = {
|
|
223
|
+
pattern: pattern.source,
|
|
224
|
+
extractedName: exportName
|
|
225
|
+
};
|
|
226
|
+
result.addBoundary(boundary);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Detect comment boundaries
|
|
234
|
+
* @param {Array} lines - File lines
|
|
235
|
+
* @param {Object} result - Detection result
|
|
236
|
+
*/
|
|
237
|
+
function detectComments(lines, result) {
|
|
238
|
+
let inBlockComment = false;
|
|
239
|
+
let blockCommentStart = null;
|
|
240
|
+
|
|
241
|
+
for (let i = 0; i < lines.length; i++) {
|
|
242
|
+
const line = lines[i].trim();
|
|
243
|
+
|
|
244
|
+
// Block comment start
|
|
245
|
+
if (line.includes('/*')) {
|
|
246
|
+
inBlockComment = true;
|
|
247
|
+
blockCommentStart = i;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Block comment end
|
|
252
|
+
if (line.includes('*/') && inBlockComment) {
|
|
253
|
+
inBlockComment = false;
|
|
254
|
+
const boundary = new Boundary(
|
|
255
|
+
BOUNDARY_TYPES.COMMENT,
|
|
256
|
+
blockCommentStart,
|
|
257
|
+
i,
|
|
258
|
+
'block-comment'
|
|
259
|
+
);
|
|
260
|
+
boundary.metadata = {
|
|
261
|
+
type: 'block'
|
|
262
|
+
};
|
|
263
|
+
result.addBoundary(boundary);
|
|
264
|
+
blockCommentStart = null;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Line comments
|
|
269
|
+
if (!inBlockComment && (line.includes('//') || line.includes('#'))) {
|
|
270
|
+
const boundary = new Boundary(
|
|
271
|
+
BOUNDARY_TYPES.COMMENT,
|
|
272
|
+
i,
|
|
273
|
+
i,
|
|
274
|
+
'line-comment'
|
|
275
|
+
);
|
|
276
|
+
boundary.metadata = {
|
|
277
|
+
type: 'line'
|
|
278
|
+
};
|
|
279
|
+
result.addBoundary(boundary);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Detect constant boundaries
|
|
286
|
+
* @param {Array} lines - File lines
|
|
287
|
+
* @param {Object} result - Detection result
|
|
288
|
+
*/
|
|
289
|
+
function detectConstants(lines, result) {
|
|
290
|
+
for (let i = 0; i < lines.length; i++) {
|
|
291
|
+
const line = lines[i].trim();
|
|
292
|
+
|
|
293
|
+
// Constant patterns
|
|
294
|
+
const patterns = [
|
|
295
|
+
/const\s+(\w+)\s*=\s*[^;]+/, // const NAME = value
|
|
296
|
+
/let\s+(\w+)\s*=\s*[^;]+/, // let NAME = value (immutable)
|
|
297
|
+
/var\s+(\w+)\s*=\s*[^;]+/, // var NAME = value (immutable)
|
|
298
|
+
];
|
|
299
|
+
|
|
300
|
+
for (const pattern of patterns) {
|
|
301
|
+
const match = line.match(pattern);
|
|
302
|
+
if (match) {
|
|
303
|
+
const constantName = match[1];
|
|
304
|
+
const boundary = new Boundary(
|
|
305
|
+
BOUNDARY_TYPES.CONSTANT,
|
|
306
|
+
i,
|
|
307
|
+
i,
|
|
308
|
+
constantName
|
|
309
|
+
);
|
|
310
|
+
boundary.metadata = {
|
|
311
|
+
pattern: pattern.source,
|
|
312
|
+
extractedName: constantName
|
|
313
|
+
};
|
|
314
|
+
result.addBoundary(boundary);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Calculate complexity for all boundaries
|
|
322
|
+
* @param {Array} lines - File lines
|
|
323
|
+
* @param {Object} result - Detection result
|
|
324
|
+
*/
|
|
325
|
+
function calculateComplexity(lines, result) {
|
|
326
|
+
for (const boundary of result.boundaries) {
|
|
327
|
+
const boundaryLines = lines.slice(boundary.startLine, boundary.endLine + 1);
|
|
328
|
+
boundary.setComplexity(calculateBoundaryComplexity(boundaryLines, boundary.type));
|
|
329
|
+
|
|
330
|
+
// Add dependencies and exports
|
|
331
|
+
const boundaryLinesText = boundaryLines.join('\n');
|
|
332
|
+
boundary.dependencies = findDependencies(boundaryLinesText.split('\n'));
|
|
333
|
+
boundary.exports = findExports(boundaryLinesText.split('\n'));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
module.exports = {
|
|
338
|
+
detectFunctions,
|
|
339
|
+
detectClasses,
|
|
340
|
+
detectModules,
|
|
341
|
+
detectUtilities,
|
|
342
|
+
detectImports,
|
|
343
|
+
detectExports,
|
|
344
|
+
detectComments,
|
|
345
|
+
detectConstants,
|
|
346
|
+
calculateComplexity
|
|
347
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Importance Priority Calculator
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function calculateImportancePriority(data) {
|
|
6
|
+
// Calculate importance priority
|
|
7
|
+
const importancePriority = 0;
|
|
8
|
+
if (data.importance === 'high') {
|
|
9
|
+
importancePriority += 30;
|
|
10
|
+
} else if (data.importance === 'medium') {
|
|
11
|
+
importancePriority += 15;
|
|
12
|
+
} else {
|
|
13
|
+
importancePriority += 3;
|
|
14
|
+
}
|
|
15
|
+
return importancePriority;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { calculateImportancePriority };
|