vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/package.json +1 -1
  2. package/src/agents/AgentCheckDiscoveryService.js +180 -0
  3. package/src/agents/AgentCheckService.js +18 -261
  4. package/src/agents/AgentCheckStatisticsService.js +195 -0
  5. package/src/agents/EnvironmentConfigurationManager.js +31 -380
  6. package/src/agents/InstallationType.js +19 -6
  7. package/src/agents/SimpleAgentCheckService.js +472 -0
  8. package/src/agents/config-managers/ConfigUtils.js +72 -0
  9. package/src/agents/config-managers/DefaultConfig.js +58 -0
  10. package/src/agents/config-managers/EnvVarLoader.js +66 -0
  11. package/src/agents/config-managers/FileConfigLoader.js +124 -0
  12. package/src/agents/config-managers/TypeConverters.js +61 -0
  13. package/src/agents/config-managers/VariableMappings.js +92 -0
  14. package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
  15. package/src/agents/discovery/AgentDiscoveryService.js +29 -403
  16. package/src/agents/discovery/agent-validator.js +262 -0
  17. package/src/agents/discovery/discovery-results.js +176 -0
  18. package/src/agents/discovery/discovery-scanner.js +268 -0
  19. package/src/agents/discovery/discovery-utils.js +161 -0
  20. package/src/agents/discovery/executable-analyzer.js +290 -0
  21. package/src/agents/discovery/history-manager.js +310 -0
  22. package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
  23. package/src/agents/verification/ResultAnalyzer.js +30 -431
  24. package/src/agents/verification/analysis-utils.js +310 -0
  25. package/src/agents/verification/batch-analyzer.js +440 -0
  26. package/src/agents/verification/pattern-recognizer.js +369 -0
  27. package/src/agents/verification/report-generator.js +320 -0
  28. package/src/agents/verification/test-analyzer.js +290 -0
  29. package/src/agents/windows/InstallerFactory.js +4 -0
  30. package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
  31. package/src/analysis/analysis-engine.js +314 -0
  32. package/src/analysis/ast-analyzer.js +342 -0
  33. package/src/analysis/boundary-detector-refactored.js +378 -0
  34. package/src/analysis/boundary-detector.js +200 -603
  35. package/src/analysis/boundary-scanner.js +609 -0
  36. package/src/analysis/boundary-types.js +118 -0
  37. package/src/analysis/boundary-utils.js +293 -0
  38. package/src/analysis/deadline-priority-calculator.js +18 -0
  39. package/src/analysis/detection-methods.js +347 -0
  40. package/src/analysis/importance-priority-calculator.js +18 -0
  41. package/src/analysis/priority/factor-calculators.js +204 -0
  42. package/src/analysis/priority/factor-helpers.js +71 -0
  43. package/src/analysis/priority/priority-constants.js +73 -0
  44. package/src/analysis/priority/priority-factor-calculators.js +301 -0
  45. package/src/analysis/priority/reasons-generator.js +44 -0
  46. package/src/analysis/priority-calculator.js +15 -580
  47. package/src/analysis/strategy-generator.js +16 -66
  48. package/src/analysis/type-priority-calculator.js +18 -0
  49. package/src/analysis/urgency-priority-calculator.js +18 -0
  50. package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
  51. package/src/commands/disable-requirement.js +60 -0
  52. package/src/commands/disable-spec.js +60 -0
  53. package/src/commands/enable-requirement.js +60 -0
  54. package/src/commands/enable-spec.js +60 -0
  55. package/src/commands/registry.js +1 -6
  56. package/src/commands/requirements.js +8 -2
  57. package/src/ide-integration/applescript-manager.cjs +9 -24
  58. package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
  59. package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
  60. package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
  61. package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
  62. package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
  63. package/src/ide-integration/cdp-manager.js +28 -573
  64. package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
  65. package/src/ide-integration/ide-openers/claude-opener.js +171 -0
  66. package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
  67. package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
  68. package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
  69. package/src/ide-integration/macos-ide-manager.js +20 -582
  70. package/src/ide-integration/macos-quota-checker.js +164 -0
  71. package/src/ide-integration/macos-text-sender.js +19 -38
  72. package/src/ide-integration/provider-manager.cjs +52 -7
  73. package/src/index.cjs +6 -0
  74. package/src/index.js +10 -0
  75. package/src/llm/direct-llm-manager.cjs +501 -0
  76. package/src/localization/translations/en-part1.js +363 -0
  77. package/src/localization/translations/en-part2.js +320 -0
  78. package/src/localization/translations/en.js +4 -687
  79. package/src/localization/translations/es-part1.js +363 -0
  80. package/src/localization/translations/es-part2.js +320 -0
  81. package/src/localization/translations/es.js +4 -688
  82. package/src/models/file-analysis-collection.js +139 -0
  83. package/src/models/file-analysis-metrics.js +50 -0
  84. package/src/models/file-analysis.js +15 -262
  85. package/src/models/plan-manager.js +410 -0
  86. package/src/models/refactoring-models.js +380 -0
  87. package/src/models/refactoring-plan-refactored.js +81 -0
  88. package/src/models/refactoring-plan.js +2 -663
  89. package/src/monitoring/alert-system.js +4 -45
  90. package/src/monitoring/continuous-scan-notifications.js +37 -191
  91. package/src/monitoring/notification-handlers/base-handler.js +58 -0
  92. package/src/monitoring/notification-handlers/error-handler.js +36 -0
  93. package/src/monitoring/notification-handlers/index.js +21 -0
  94. package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
  95. package/src/monitoring/notification-handlers/progress-handler.js +48 -0
  96. package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
  97. package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
  98. package/src/provider-registry.js +8 -0
  99. package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
  100. package/src/refactoring/boundary/boundary-detector.js +26 -596
  101. package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
  102. package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
  103. package/src/refactoring/boundary/detectors/class-detector.js +247 -0
  104. package/src/refactoring/boundary/detectors/config-detector.js +270 -0
  105. package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
  106. package/src/refactoring/boundary/detectors/function-detector.js +248 -0
  107. package/src/refactoring/boundary/detectors/module-detector.js +249 -0
  108. package/src/refactoring/boundary/detectors/object-detector.js +247 -0
  109. package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
  110. package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
  111. package/src/refactoring/circular-dependency-resolver-original.js +16 -76
  112. package/src/refactoring/code-mover-refactored.js +309 -0
  113. package/src/refactoring/code-mover.js +48 -355
  114. package/src/refactoring/execution-status.js +18 -0
  115. package/src/refactoring/execution-strategies.js +172 -0
  116. package/src/refactoring/file-splitter-core.js +568 -0
  117. package/src/refactoring/file-splitter-types.js +136 -0
  118. package/src/refactoring/file-splitter.js +2 -682
  119. package/src/refactoring/functionality-validator.js +11 -51
  120. package/src/refactoring/import-manager-refactored.js +385 -0
  121. package/src/refactoring/import-manager.js +112 -487
  122. package/src/refactoring/import-models.js +189 -0
  123. package/src/refactoring/import-parser.js +306 -0
  124. package/src/refactoring/move-executor.js +431 -0
  125. package/src/refactoring/move-utils.js +368 -0
  126. package/src/refactoring/operation-executor.js +76 -0
  127. package/src/refactoring/plan-creator.js +36 -0
  128. package/src/refactoring/plan-executor.js +143 -0
  129. package/src/refactoring/plan-validator.js +68 -0
  130. package/src/refactoring/refactoring-executor-result.js +70 -0
  131. package/src/refactoring/refactoring-executor.js +34 -569
  132. package/src/refactoring/refactoring-operation.js +94 -0
  133. package/src/refactoring/refactoring-plan.js +69 -0
  134. package/src/refactoring/refactoring-rollback.js +22 -527
  135. package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
  136. package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
  137. package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
  138. package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
  139. package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
  140. package/src/refactoring/test-validator.js +32 -448
  141. package/src/refactoring/validation/baseline-runner.js +71 -0
  142. package/src/refactoring/validation/report-generator.js +136 -0
  143. package/src/refactoring/validation/result-comparator.js +92 -0
  144. package/src/refactoring/validation/test-suite.js +59 -0
  145. package/src/refactoring/validation/test-validation-result.js +83 -0
  146. package/src/refactoring/validation/validation-runner.js +95 -0
  147. package/src/refactoring/validation/validation-status.js +18 -0
  148. package/src/rui/commands/AgentCommandParser.js +60 -369
  149. package/src/rui/commands/AgentResponseFormatter.js +7 -47
  150. package/src/rui/commands/parsers/CommandMapper.js +148 -0
  151. package/src/rui/commands/parsers/CommandValidator.js +228 -0
  152. package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
  153. package/src/rui/commands/parsers/TokenParser.js +69 -0
  154. package/src/rui/commands/parsers/tokenizer.js +153 -0
  155. package/src/utils/current-requirement-operations.js +50 -1
  156. package/src/utils/report-generator.js +18 -514
  157. package/src/utils/report-generators/analysis-generator.js +115 -0
  158. package/src/utils/report-generators/base-generator.js +141 -0
  159. package/src/utils/report-generators/compliance-generator.js +41 -0
  160. package/src/utils/report-generators/format-handlers.js +185 -0
  161. package/src/utils/report-generators/refactoring-generator.js +46 -0
  162. package/src/utils/report-generators/validation-generator.js +63 -0
  163. package/src/utils/requirement-enable-disable.js +265 -0
  164. package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
  165. package/src/utils/requirement-helpers/requirement-mover.js +88 -1
  166. package/src/utils/requirement-helpers.js +5 -2
  167. package/src/utils/smoke-test-cli.js +45 -8
  168. package/src/utils/specification-enable-disable.js +122 -0
  169. package/src/utils/specification-helpers.js +30 -4
  170. package/src/utils/specification-migration.js +5 -5
  171. package/src/utils/test-comparator.js +118 -0
  172. package/src/utils/test-config.js +54 -0
  173. package/src/utils/test-executor.js +133 -0
  174. package/src/utils/test-parser.js +215 -0
  175. package/src/utils/test-runner-baseline.js +63 -0
  176. package/src/utils/test-runner-core.js +98 -0
  177. package/src/utils/test-runner-report.js +39 -0
  178. package/src/utils/test-runner-validation.js +71 -0
  179. package/src/utils/test-runner.js +11 -535
  180. package/src/validation/comparison-analyzer.js +333 -0
  181. package/src/validation/compliance-reporter-new.js +282 -0
  182. package/src/validation/compliance-reporter-refactored.js +344 -0
  183. package/src/validation/compliance-reporter.js +278 -591
  184. package/src/validation/compliance-utils.js +278 -0
  185. package/src/validation/html-generator.js +446 -0
  186. package/src/validation/metrics/category-calculator.js +137 -0
  187. package/src/validation/metrics/metrics-helpers.js +155 -0
  188. package/src/validation/metrics/overview-calculator.js +85 -0
  189. package/src/validation/metrics/overview-metrics.js +41 -0
  190. package/src/validation/metrics/quality-calculator.js +166 -0
  191. package/src/validation/metrics/size-calculator.js +69 -0
  192. package/src/validation/metrics-calculator.js +27 -551
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Object Boundary Detection
3
+ */
4
+
5
+ const { BOUNDARY_TYPES } = require('../boundary-types');
6
+
7
+ /**
8
+ * Object boundary detector
9
+ */
10
+ class ObjectDetector {
11
+ constructor() {
12
+ this.patterns = this.initializePatterns();
13
+ }
14
+
15
+ /**
16
+ * Initialize detection patterns
17
+ * @returns {Object} Detection patterns
18
+ */
19
+ initializePatterns() {
20
+ return {
21
+ declaration: /(?:const|let|var)\s+(\w+)\s*=\s*{/g,
22
+ property: /(\w+)\s*:/g,
23
+ method: /(\w+)\s*\([^)]*\)\s*{/g
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Detect object boundaries
29
+ * @param {Array} lines - Source code lines
30
+ * @param {string} filePath - File path
31
+ * @returns {Array} Array of object boundaries
32
+ */
33
+ detectObjectBoundaries(lines, filePath) {
34
+ const boundaries = [];
35
+ const sourceCode = lines.join('\n');
36
+
37
+ // Find object declarations
38
+ const matches = [...sourceCode.matchAll(this.patterns.declaration)];
39
+
40
+ for (const match of matches) {
41
+ const objectName = match[1];
42
+ if (objectName) {
43
+ const boundary = this.createBoundary(
44
+ BOUNDARY_TYPES.OBJECT,
45
+ objectName,
46
+ lines,
47
+ filePath,
48
+ match.index
49
+ );
50
+
51
+ if (boundary) {
52
+ boundaries.push(boundary);
53
+ }
54
+ }
55
+ }
56
+
57
+ return boundaries;
58
+ }
59
+
60
+ /**
61
+ * Create boundary from detection
62
+ * @param {string} type - Boundary type
63
+ * @param {string} name - Boundary name
64
+ * @param {Array} lines - Source code lines
65
+ * @param {string} filePath - File path
66
+ * @param {number} startIndex - Start index in source
67
+ * @returns {Object|null} Boundary object or null
68
+ */
69
+ createBoundary(type, name, lines, filePath, startIndex) {
70
+ const { startLine, endLine } = this.findBoundaryExtent(lines, startIndex, type);
71
+
72
+ if (startLine === -1 || endLine === -1) {
73
+ return null;
74
+ }
75
+
76
+ const { ModuleBoundary } = require('../boundary-types');
77
+ const boundary = new ModuleBoundary(type, name, startLine + 1, endLine + 1, filePath);
78
+
79
+ // Basic analysis
80
+ this.analyzeBoundary(boundary, lines, startLine, endLine);
81
+
82
+ return boundary;
83
+ }
84
+
85
+ /**
86
+ * Find extent of a boundary
87
+ * @param {Array} lines - Source code lines
88
+ * @param {number} startIndex - Start index
89
+ * @param {string} type - Boundary type
90
+ * @returns {Object} Start and end line numbers
91
+ */
92
+ findBoundaryExtent(lines, startIndex, type) {
93
+ let startLine = -1;
94
+ let endLine = -1;
95
+ let braceCount = 0;
96
+ let inString = false;
97
+ let stringChar = null;
98
+
99
+ for (let i = startIndex; i < lines.length; i++) {
100
+ const line = lines[i];
101
+
102
+ // Track string literals
103
+ for (let j = 0; j < line.length; j++) {
104
+ const char = line[j];
105
+
106
+ if (!inString && (char === '"' || char === "'" || char === '`')) {
107
+ inString = true;
108
+ stringChar = char;
109
+ } else if (inString && char === stringChar) {
110
+ inString = false;
111
+ stringChar = null;
112
+ }
113
+ }
114
+
115
+ // Skip lines inside strings
116
+ if (inString) continue;
117
+
118
+ // Count braces for block detection
119
+ const openBraces = (line.match(/\{/g) || []).length;
120
+ const closeBraces = (line.match(/\}/g) || []).length;
121
+
122
+ braceCount += openBraces - closeBraces;
123
+
124
+ // Set start line on first detection
125
+ if (startLine === -1) {
126
+ startLine = i;
127
+ }
128
+
129
+ // End when braces are balanced and we're past start
130
+ if (braceCount <= 0 && i > startIndex) {
131
+ endLine = i;
132
+ break;
133
+ }
134
+ }
135
+
136
+ return { startLine, endLine };
137
+ }
138
+
139
+ /**
140
+ * Analyze boundary properties
141
+ * @param {Object} boundary - Boundary object
142
+ * @param {Array} lines - Source code lines
143
+ * @param {number} startLine - Start line number
144
+ * @param {number} endLine - End line number
145
+ */
146
+ analyzeBoundary(boundary, lines, startLine, endLine) {
147
+ const boundaryLines = lines.slice(startLine, endLine + 1);
148
+ const sourceCode = boundaryLines.join('\n');
149
+
150
+ // Calculate complexity
151
+ const complexity = this.calculateComplexity(sourceCode);
152
+ boundary.setComplexity(complexity);
153
+
154
+ // Find dependencies
155
+ const dependencies = this.findDependencies(sourceCode);
156
+ for (const dep of dependencies) {
157
+ boundary.addDependency(dep);
158
+ }
159
+
160
+ // Find exports
161
+ const exports = this.findExports(sourceCode, boundary.type);
162
+ for (const exp of exports) {
163
+ boundary.addExport(exp);
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Calculate complexity score
169
+ * @param {string} sourceCode - Source code
170
+ * @returns {number} Complexity score
171
+ */
172
+ calculateComplexity(sourceCode) {
173
+ let complexity = 0;
174
+
175
+ // Cyclomatic complexity indicators
176
+ complexity += (sourceCode.match(/if\s*\(/g) || []).length * 1;
177
+ complexity += (sourceCode.match(/else\s+if/g) || []).length * 1;
178
+ complexity += (sourceCode.match(/while\s*\(/g) || []).length * 2;
179
+ complexity += (sourceCode.match(/for\s*\(/g) || []).length * 2;
180
+ complexity += (sourceCode.match(/switch\s*\(/g) || []).length * 2;
181
+ complexity += (sourceCode.match(/catch\s*\(/g) || []).length * 2;
182
+ complexity += (sourceCode.match(/&&/g) || []).length * 1;
183
+ complexity += (sourceCode.match(/\|\|/g) || []).length * 1;
184
+
185
+ // Length complexity
186
+ const lineCount = sourceCode.split('\n').length;
187
+ if (lineCount > 50) complexity += 5;
188
+ if (lineCount > 100) complexity += 10;
189
+ if (lineCount > 200) complexity += 20;
190
+
191
+ return Math.min(100, complexity);
192
+ }
193
+
194
+ /**
195
+ * Find dependencies in boundary
196
+ * @param {string} sourceCode - Source code
197
+ * @returns {Array} Array of dependencies
198
+ */
199
+ findDependencies(sourceCode) {
200
+ const dependencies = [];
201
+
202
+ // Import statements
203
+ const importMatches = sourceCode.match(/import\s+.+from\s+['"]([^'"]+)['"]/g);
204
+ if (importMatches) {
205
+ for (const match of importMatches) {
206
+ dependencies.push(match[1]);
207
+ }
208
+ }
209
+
210
+ // Require statements
211
+ const requireMatches = sourceCode.match(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g);
212
+ if (requireMatches) {
213
+ for (const match of requireMatches) {
214
+ dependencies.push(match[1]);
215
+ }
216
+ }
217
+
218
+ return [...new Set(dependencies)];
219
+ }
220
+
221
+ /**
222
+ * Find exports in boundary
223
+ * @param {string} sourceCode - Source code
224
+ * @param {string} type - Boundary type
225
+ * @returns {Array} Array of exports
226
+ */
227
+ findExports(sourceCode, type) {
228
+ const exports = [];
229
+
230
+ if (type === BOUNDARY_TYPES.OBJECT) {
231
+ // Look for explicit exports
232
+ const exportMatches = sourceCode.match(/export\s+(?:default\s+)?(?:\w+|\{[^}]+\})/g);
233
+ if (exportMatches) {
234
+ for (const match of exportMatches) {
235
+ const exportName = match.replace(/export\s+(?:default\s+)?/, '').trim();
236
+ if (exportName && exportName !== '{' && exportName !== '}') {
237
+ exports.push(exportName);
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ return exports;
244
+ }
245
+ }
246
+
247
+ module.exports = ObjectDetector;
@@ -0,0 +1,338 @@
1
+ /**
2
+ * Type-specific Boundary Detection Logic
3
+ */
4
+
5
+ const { BOUNDARY_TYPES } = require('../boundary-types');
6
+
7
+ /**
8
+ * Type-specific boundary detectors
9
+ */
10
+ class TypeDetectors {
11
+ constructor(patterns) {
12
+ this.patterns = patterns;
13
+ }
14
+
15
+ /**
16
+ * Detect function boundaries
17
+ * @param {Array} lines - Source code lines
18
+ * @param {string} filePath - File path
19
+ * @returns {Array} Array of function boundaries
20
+ */
21
+ detectFunctionBoundaries(lines, filePath) {
22
+ const boundaries = [];
23
+ const sourceCode = lines.join('\n');
24
+
25
+ // Find function declarations
26
+ const functionMatches = [...sourceCode.matchAll(this.patterns.function.declaration)];
27
+
28
+ for (const match of functionMatches) {
29
+ const functionName = match[1] || match[2];
30
+ if (functionName) {
31
+ const boundary = this.createBoundary(
32
+ BOUNDARY_TYPES.FUNCTION,
33
+ functionName,
34
+ lines,
35
+ filePath,
36
+ match.index
37
+ );
38
+
39
+ if (boundary) {
40
+ boundaries.push(boundary);
41
+ }
42
+ }
43
+ }
44
+
45
+ return boundaries;
46
+ }
47
+
48
+ /**
49
+ * Detect class boundaries
50
+ * @param {Array} lines - Source code lines
51
+ * @param {string} filePath - File path
52
+ * @returns {Array} Array of class boundaries
53
+ */
54
+ detectClassBoundaries(lines, filePath) {
55
+ const boundaries = [];
56
+ const sourceCode = lines.join('\n');
57
+
58
+ // Find class declarations
59
+ const classMatches = [...sourceCode.matchAll(this.patterns.class.declaration)];
60
+
61
+ for (const match of classMatches) {
62
+ const className = match[1] || match[2];
63
+ if (className) {
64
+ const boundary = this.createBoundary(
65
+ BOUNDARY_TYPES.CLASS,
66
+ className,
67
+ lines,
68
+ filePath,
69
+ match.index
70
+ );
71
+
72
+ if (boundary) {
73
+ boundaries.push(boundary);
74
+ }
75
+ }
76
+ }
77
+
78
+ return boundaries;
79
+ }
80
+
81
+ /**
82
+ * Detect object boundaries
83
+ * @param {Array} lines - Source code lines
84
+ * @param {string} filePath - File path
85
+ * @returns {Array} Array of object boundaries
86
+ */
87
+ detectObjectBoundaries(lines, filePath) {
88
+ const boundaries = [];
89
+ const sourceCode = lines.join('\n');
90
+
91
+ // Find object declarations
92
+ const objectMatches = [...sourceCode.matchAll(this.patterns.object.declaration)];
93
+
94
+ for (const match of objectMatches) {
95
+ const objectName = match[1];
96
+ if (objectName) {
97
+ const boundary = this.createBoundary(
98
+ BOUNDARY_TYPES.OBJECT,
99
+ objectName,
100
+ lines,
101
+ filePath,
102
+ match.index
103
+ );
104
+
105
+ if (boundary) {
106
+ boundaries.push(boundary);
107
+ }
108
+ }
109
+ }
110
+
111
+ return boundaries;
112
+ }
113
+
114
+ /**
115
+ * Detect module boundaries
116
+ * @param {Array} lines - Source code lines
117
+ * @param {string} filePath - File path
118
+ * @returns {Array} Array of module boundaries
119
+ */
120
+ detectModuleBoundaries(lines, filePath) {
121
+ const boundaries = [];
122
+ const sourceCode = lines.join('\n');
123
+
124
+ // Find export statements
125
+ const exportMatches = [...sourceCode.matchAll(this.patterns.module.export)];
126
+
127
+ for (const match of exportMatches) {
128
+ const exportNames = [];
129
+
130
+ // Named exports
131
+ if (match[1]) {
132
+ exportNames.push(...match[1].split(',').map(name => name.trim()));
133
+ }
134
+
135
+ // Default exports
136
+ if (match[2]) {
137
+ exportNames.push(match[2]);
138
+ }
139
+
140
+ for (const exportName of exportNames) {
141
+ if (exportName && exportName !== 'default') {
142
+ const boundary = this.createBoundary(
143
+ BOUNDARY_TYPES.MODULE,
144
+ exportName,
145
+ lines,
146
+ filePath,
147
+ match.index
148
+ );
149
+
150
+ if (boundary) {
151
+ boundaries.push(boundary);
152
+ }
153
+ }
154
+ }
155
+ }
156
+
157
+ return boundaries;
158
+ }
159
+
160
+ /**
161
+ * Detect utility boundaries
162
+ * @param {Array} lines - Source code lines
163
+ * @param {string} filePath - File path
164
+ * @returns {Array} Array of utility boundaries
165
+ */
166
+ detectUtilityBoundaries(lines, filePath) {
167
+ const boundaries = [];
168
+
169
+ // Look for utility function patterns
170
+ for (let i = 0; i < lines.length; i++) {
171
+ const line = lines[i].trim();
172
+
173
+ // Helper function patterns
174
+ if (this.isUtilityFunction(line)) {
175
+ const functionName = this.extractUtilityFunctionName(line);
176
+ if (functionName) {
177
+ const boundary = this.createBoundary(
178
+ BOUNDARY_TYPES.UTILITY,
179
+ functionName,
180
+ lines,
181
+ filePath,
182
+ i
183
+ );
184
+
185
+ if (boundary) {
186
+ boundaries.push(boundary);
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ return boundaries;
193
+ }
194
+
195
+ /**
196
+ * Detect config boundaries
197
+ * @param {Array} lines - Source code lines
198
+ * @param {string} filePath - File path
199
+ * @returns {Array} Array of config boundaries
200
+ */
201
+ detectConfigBoundaries(lines, filePath) {
202
+ const boundaries = [];
203
+
204
+ // Look for config object patterns
205
+ for (let i = 0; i < lines.length; i++) {
206
+ const line = lines[i].trim();
207
+
208
+ if (this.isConfigObject(line)) {
209
+ const configName = this.extractConfigObjectName(line);
210
+ if (configName) {
211
+ const boundary = this.createBoundary(
212
+ BOUNDARY_TYPES.CONFIG,
213
+ configName,
214
+ lines,
215
+ filePath,
216
+ i
217
+ );
218
+
219
+ if (boundary) {
220
+ boundaries.push(boundary);
221
+ }
222
+ }
223
+ }
224
+ }
225
+
226
+ return boundaries;
227
+ }
228
+
229
+ /**
230
+ * Detect constant boundaries
231
+ * @param {Array} lines - Source code lines
232
+ * @param {string} filePath - File path
233
+ * @returns {Array} Array of constant boundaries
234
+ */
235
+ detectConstantBoundaries(lines, filePath) {
236
+ const boundaries = [];
237
+
238
+ // Look for constant patterns
239
+ for (let i = 0; i < lines.length; i++) {
240
+ const line = lines[i].trim();
241
+
242
+ if (this.isConstantDeclaration(line)) {
243
+ const constantName = this.extractConstantName(line);
244
+ if (constantName) {
245
+ const boundary = this.createBoundary(
246
+ BOUNDARY_TYPES.CONSTANT,
247
+ constantName,
248
+ lines,
249
+ filePath,
250
+ i
251
+ );
252
+
253
+ if (boundary) {
254
+ boundaries.push(boundary);
255
+ }
256
+ }
257
+ }
258
+ }
259
+
260
+ return boundaries;
261
+ }
262
+
263
+ /**
264
+ * Check if line is utility function
265
+ * @param {string} line - Code line
266
+ * @returns {boolean} Whether line is utility function
267
+ */
268
+ isUtilityFunction(line) {
269
+ const utilityPatterns = [
270
+ /(?:const|let|var)\s+\w+\s*=\s*\([^)]*\)\s*=>/,
271
+ /function\s+(?:is|has|get|set|calculate|compute|parse|format|validate|check)/,
272
+ /\w+(?:is|has|get|set|calculate|compute|parse|format|validate|check)\s*\(/
273
+ ];
274
+
275
+ return utilityPatterns.some(pattern => pattern.test(line));
276
+ }
277
+
278
+ /**
279
+ * Extract utility function name
280
+ * @param {string} line - Code line
281
+ * @returns {string|null} Function name
282
+ */
283
+ extractUtilityFunctionName(line) {
284
+ const match = line.match(/(?:const|let|var)\s+(\w+)\s*=|function\s+(\w+)/);
285
+ return match ? match[1] || match[2] : null;
286
+ }
287
+
288
+ /**
289
+ * Check if line is config object
290
+ * @param {string} line - Code line
291
+ * @returns {boolean} Whether line is config object
292
+ */
293
+ isConfigObject(line) {
294
+ const configPatterns = [
295
+ /(?:const|let|var)\s+\w*config\w*\s*=/,
296
+ /(?:const|let|var)\s+\w*Config\w*\s*=/,
297
+ /(?:const|let|var)\s+\w*Settings\w*\s*=/
298
+ ];
299
+
300
+ return configPatterns.some(pattern => pattern.test(line));
301
+ }
302
+
303
+ /**
304
+ * Extract config object name
305
+ * @param {string} line - Code line
306
+ * @returns {string|null} Config name
307
+ */
308
+ extractConfigObjectName(line) {
309
+ const match = line.match(/(?:const|let|var)\s+(\w*config\w*|\w*Config\w*|\w*Settings\w*)\s*=/);
310
+ return match ? match[1] : null;
311
+ }
312
+
313
+ /**
314
+ * Check if line is constant declaration
315
+ * @param {string} line - Code line
316
+ * @returns {boolean} Whether line is constant declaration
317
+ */
318
+ isConstantDeclaration(line) {
319
+ const constantPatterns = [
320
+ /const\s+[A-Z_][A-Z0-9_]*\s*=/,
321
+ /(?:const|let|var)\s+[A-Z_][A-Z0-9_]*\s*=/
322
+ ];
323
+
324
+ return constantPatterns.some(pattern => pattern.test(line));
325
+ }
326
+
327
+ /**
328
+ * Extract constant name
329
+ * @param {string} line - Code line
330
+ * @returns {string|null} Constant name
331
+ */
332
+ extractConstantName(line) {
333
+ const match = line.match(/(?:const|let|var)\s+([A-Z_][A-Z0-9_]*)\s*=/);
334
+ return match ? match[1] : null;
335
+ }
336
+ }
337
+
338
+ module.exports = { TypeDetectors };