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,431 @@
1
+ /**
2
+ * Code Move Executor
3
+ *
4
+ * Executes code movement operations safely.
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { RollbackManager } = require('../utils/rollback-manager');
10
+ const {
11
+ MOVE_TYPES,
12
+ createMoveOperation,
13
+ validateMoveOperation,
14
+ extractCodeSegment,
15
+ updateImportStatements,
16
+ createFileBackup,
17
+ validateCodeSyntax,
18
+ generateMoveReport,
19
+ calculateImportDependencies
20
+ } = require('./move-utils');
21
+
22
+ /**
23
+ * Move Result class
24
+ */
25
+ class MoveResult {
26
+ constructor(operation) {
27
+ this.operation = operation;
28
+ this.success = false;
29
+ this.sourceModified = false;
30
+ this.targetCreated = false;
31
+ this.importsUpdated = false;
32
+ this.errors = [];
33
+ this.warnings = [];
34
+ this.metadata = {
35
+ executedAt: new Date().toISOString(),
36
+ linesMoved: 0,
37
+ filesAffected: 0
38
+ };
39
+ }
40
+
41
+ addError(error) {
42
+ this.errors.push({
43
+ message: error.message,
44
+ timestamp: new Date().toISOString(),
45
+ stack: error.stack
46
+ });
47
+ }
48
+
49
+ addWarning(warning) {
50
+ this.warnings.push({
51
+ message: warning,
52
+ timestamp: new Date().toISOString()
53
+ });
54
+ }
55
+
56
+ markSuccess() {
57
+ this.success = true;
58
+ }
59
+
60
+ getSummary() {
61
+ return {
62
+ success: this.success,
63
+ operation: this.operation.type,
64
+ filesAffected: this.metadata.filesAffected,
65
+ linesMoved: this.metadata.linesMoved,
66
+ errors: this.errors.length,
67
+ warnings: this.warnings.length
68
+ };
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Move Executor class
74
+ */
75
+ class MoveExecutor {
76
+ constructor(options = {}) {
77
+ this.options = {
78
+ autoBackup: options.autoBackup !== false,
79
+ validateSyntax: options.validateSyntax !== false,
80
+ updateImports: options.updateImports !== false,
81
+ preserveFormatting: options.preserveFormatting !== false,
82
+ ...options
83
+ };
84
+
85
+ this.rollbackManager = new RollbackManager();
86
+ this.history = [];
87
+ }
88
+
89
+ async executeMove(operation) {
90
+ const startTime = Date.now();
91
+ const result = new MoveResult(operation);
92
+
93
+ try {
94
+ // Validate operation
95
+ const validation = validateMoveOperation(operation);
96
+ if (!validation.isValid) {
97
+ validation.errors.forEach(error => result.addError(new Error(error)));
98
+ return result;
99
+ }
100
+
101
+ validation.warnings.forEach(warning => result.addWarning(warning));
102
+
103
+ // Create backup if enabled
104
+ let backupPath = null;
105
+ if (this.options.autoBackup) {
106
+ backupPath = await createFileBackup(operation.source.filePath);
107
+ result.addWarning(`Created backup: ${backupPath}`);
108
+ }
109
+
110
+ // Execute the move
111
+ await this.performMove(operation, result);
112
+
113
+ // Update rollback history
114
+ if (result.success) {
115
+ this.rollbackManager.recordOperation({
116
+ type: 'move',
117
+ operation,
118
+ backupPath,
119
+ timestamp: new Date().toISOString()
120
+ });
121
+ }
122
+
123
+ result.metadata.duration = Date.now() - startTime;
124
+ result.markSuccess();
125
+
126
+ return result;
127
+
128
+ } catch (error) {
129
+ result.addError(error);
130
+ result.metadata.duration = Date.now() - startTime;
131
+
132
+ // Attempt rollback if move failed
133
+ if (backupPath) {
134
+ await this.attemptRollback(operation, backupPath, result);
135
+ }
136
+
137
+ return result;
138
+ }
139
+ }
140
+
141
+ async performMove(operation, result) {
142
+ // Read source file
143
+ const sourceContent = await fs.promises.readFile(operation.source.filePath, 'utf8');
144
+ const sourceLines = sourceContent.split('\n');
145
+
146
+ // Extract code segment
147
+ const codeSegment = extractCodeSegment(sourceLines, operation.source.startLine, operation.source.endLine);
148
+
149
+ // Validate syntax if enabled
150
+ if (this.options.validateSyntax) {
151
+ const syntaxValidation = validateCodeSyntax(codeSegment);
152
+ if (!syntaxValidation.isValid) {
153
+ result.addError(new Error(`Syntax validation failed: ${syntaxValidation.errors[0].message}`));
154
+ return;
155
+ }
156
+ }
157
+
158
+ // Remove code from source
159
+ const updatedSourceContent = this.removeCodeSegment(sourceContent, operation.source.startLine, operation.source.endLine);
160
+ await fs.promises.writeFile(operation.source.filePath, updatedSourceContent, 'utf8');
161
+ result.sourceModified = true;
162
+
163
+ // Add code to target
164
+ await this.addCodeToTarget(operation, codeSegment, result);
165
+
166
+ // Update imports if enabled
167
+ if (this.options.updateImports) {
168
+ await this.updateImports(operation, result);
169
+ }
170
+
171
+ result.metadata.linesMoved = operation.source.endLine - operation.source.startLine + 1;
172
+ result.metadata.filesAffected = 2; // source and target
173
+ }
174
+
175
+ async addCodeToTarget(operation, codeSegment, result) {
176
+ const targetExists = fs.existsSync(operation.target.filePath);
177
+
178
+ if (targetExists) {
179
+ // Insert into existing file
180
+ const targetContent = await fs.promises.readFile(operation.target.filePath, 'utf8');
181
+ const targetLines = targetContent.split('\n');
182
+
183
+ const insertPosition = this.calculateInsertPosition(targetLines, operation.target.insertPosition);
184
+ const updatedTargetContent = this.insertCodeSegment(targetContent, codeSegment, insertPosition);
185
+
186
+ await fs.promises.writeFile(operation.target.filePath, updatedTargetContent, 'utf8');
187
+ } else {
188
+ // Create new file
189
+ await fs.promises.writeFile(operation.target.filePath, codeSegment, 'utf8');
190
+ }
191
+
192
+ result.targetCreated = true;
193
+ }
194
+
195
+ async updateImports(operation, result) {
196
+ try {
197
+ // Update source file imports
198
+ const sourceContent = await fs.promises.readFile(operation.source.filePath, 'utf8');
199
+ const sourceDependencies = calculateImportDependencies(sourceContent);
200
+
201
+ // Update target file imports
202
+ const targetContent = await fs.promises.readFile(operation.target.filePath, 'utf8');
203
+ const targetDependencies = calculateImportDependencies(targetContent);
204
+
205
+ // Calculate import changes
206
+ const importChanges = this.calculateImportChanges(sourceDependencies, targetDependencies, operation);
207
+
208
+ // Apply import changes
209
+ if (importChanges.source.length > 0) {
210
+ const updatedSourceContent = updateImportStatements(sourceContent, importChanges.source);
211
+ await fs.promises.writeFile(operation.source.filePath, updatedSourceContent, 'utf8');
212
+ }
213
+
214
+ if (importChanges.target.length > 0) {
215
+ const updatedTargetContent = updateImportStatements(targetContent, importChanges.target);
216
+ await fs.promises.writeFile(operation.target.filePath, updatedTargetContent, 'utf8');
217
+ }
218
+
219
+ result.importsUpdated = true;
220
+
221
+ } catch (error) {
222
+ result.addWarning(`Failed to update imports: ${error.message}`);
223
+ }
224
+ }
225
+
226
+ removeCodeSegment(content, startLine, endLine) {
227
+ const lines = content.split('\n');
228
+
229
+ // Remove the specified segment
230
+ const beforeSegment = lines.slice(0, startLine - 1);
231
+ const afterSegment = lines.slice(endLine);
232
+
233
+ return [...beforeSegment, ...afterSegment].join('\n');
234
+ }
235
+
236
+ insertCodeSegment(content, codeSegment, insertPosition) {
237
+ const lines = content.split('\n');
238
+ const codeLines = codeSegment.split('\n');
239
+
240
+ // Insert code at specified position
241
+ const beforeInsert = lines.slice(0, insertPosition);
242
+ const afterInsert = lines.slice(insertPosition);
243
+
244
+ return [...beforeInsert, ...codeLines, ...afterInsert].join('\n');
245
+ }
246
+
247
+ calculateInsertPosition(lines, insertPosition) {
248
+ switch (insertPosition) {
249
+ case 'start':
250
+ return 0;
251
+ case 'end':
252
+ return lines.length;
253
+ case 'middle':
254
+ return Math.floor(lines.length / 2);
255
+ default:
256
+ if (typeof insertPosition === 'number') {
257
+ return Math.max(0, Math.min(insertPosition, lines.length));
258
+ }
259
+ return lines.length;
260
+ }
261
+ }
262
+
263
+ calculateImportChanges(sourceDependencies, targetDependencies, operation) {
264
+ const changes = {
265
+ source: [],
266
+ target: []
267
+ };
268
+
269
+ // Calculate relative path between files
270
+ const relativePath = path.relative(
271
+ path.dirname(operation.source.filePath),
272
+ path.dirname(operation.target.filePath)
273
+ );
274
+
275
+ // Source file changes (remove moved dependencies)
276
+ sourceDependencies.forEach(dep => {
277
+ const movedModule = path.basename(operation.source.filePath, '.js');
278
+ if (dep.module.includes(movedModule)) {
279
+ changes.source.push({
280
+ oldPath: dep.module,
281
+ newPath: null,
282
+ type: dep.type
283
+ });
284
+ }
285
+ });
286
+
287
+ // Target file changes (add new dependencies)
288
+ targetDependencies.forEach(dep => {
289
+ const needsUpdate = this.shouldUpdateImport(dep, operation);
290
+ if (needsUpdate) {
291
+ changes.target.push({
292
+ oldPath: dep.module,
293
+ newPath: this.calculateNewImportPath(dep.module, relativePath),
294
+ type: dep.type
295
+ });
296
+ }
297
+ });
298
+
299
+ return changes;
300
+ }
301
+
302
+ shouldUpdateImport(dependency, operation) {
303
+ // Check if dependency needs to be updated based on move operation
304
+ const sourceBase = path.basename(operation.source.filePath, '.js');
305
+ const targetBase = path.basename(operation.target.filePath, '.js');
306
+
307
+ return dependency.module.includes(sourceBase) || dependency.module === './' + sourceBase;
308
+ }
309
+
310
+ calculateNewImportPath(oldPath, relativePath) {
311
+ if (oldPath.startsWith('./')) {
312
+ return path.join(relativePath, oldPath.substring(2));
313
+ } else if (oldPath.startsWith('../')) {
314
+ return path.join('..', relativePath, oldPath.substring(3));
315
+ } else {
316
+ return path.join(relativePath, oldPath);
317
+ }
318
+ }
319
+
320
+ async attemptRollback(operation, backupPath, result) {
321
+ try {
322
+ result.addWarning('Attempting rollback due to move failure');
323
+
324
+ // Restore source file from backup
325
+ if (backupPath && fs.existsSync(backupPath)) {
326
+ const backupContent = await fs.promises.readFile(backupPath, 'utf8');
327
+ await fs.promises.writeFile(operation.source.filePath, backupContent, 'utf8');
328
+ result.addWarning('Source file restored from backup');
329
+ }
330
+
331
+ // Remove target file if it was created
332
+ if (result.targetCreated && fs.existsSync(operation.target.filePath)) {
333
+ await fs.promises.unlink(operation.target.filePath);
334
+ result.addWarning('Target file removed during rollback');
335
+ }
336
+
337
+ } catch (rollbackError) {
338
+ result.addError(new Error(`Rollback failed: ${rollbackError.message}`));
339
+ }
340
+ }
341
+
342
+ async executeBatchMove(operations) {
343
+ const results = [];
344
+ const batchStartTime = Date.now();
345
+
346
+ for (const operation of operations) {
347
+ const result = await this.executeMove(operation);
348
+ results.push(result);
349
+
350
+ // Stop on first failure if not in continue mode
351
+ if (!result.success && !this.options.continueOnError) {
352
+ break;
353
+ }
354
+ }
355
+
356
+ // Record batch operation
357
+ this.rollbackManager.recordOperation({
358
+ type: 'batch_move',
359
+ operations,
360
+ results,
361
+ timestamp: new Date().toISOString(),
362
+ duration: Date.now() - batchStartTime
363
+ });
364
+
365
+ return {
366
+ results,
367
+ summary: {
368
+ total: operations.length,
369
+ successful: results.filter(r => r.success).length,
370
+ failed: results.filter(r => !r.success).length,
371
+ duration: Date.now() - batchStartTime
372
+ }
373
+ };
374
+ }
375
+
376
+ getExecutionHistory() {
377
+ return this.history;
378
+ }
379
+
380
+ async rollbackLastMove() {
381
+ const lastOperation = this.rollbackManager.getLastOperation();
382
+ if (!lastOperation) {
383
+ throw new Error('No operations to rollback');
384
+ }
385
+
386
+ return await this.rollbackManager.rollback(lastOperation.id);
387
+ }
388
+
389
+ generateReport(operation, result) {
390
+ return generateMoveReport(operation, result);
391
+ }
392
+
393
+ getExecutorInfo() {
394
+ return {
395
+ supportedTypes: Object.values(MOVE_TYPES),
396
+ defaultOptions: this.options,
397
+ features: [
398
+ 'code extraction',
399
+ 'import management',
400
+ 'backup creation',
401
+ 'syntax validation',
402
+ 'rollback support',
403
+ 'batch operations'
404
+ ],
405
+ version: '1.0.0'
406
+ };
407
+ }
408
+
409
+ static createDefault(config = {}) {
410
+ return new MoveExecutor({
411
+ autoBackup: true,
412
+ validateSyntax: true,
413
+ updateImports: true,
414
+ preserveFormatting: true,
415
+ ...config
416
+ });
417
+ }
418
+
419
+ static createForRefactoring(config = {}) {
420
+ return new MoveExecutor({
421
+ autoBackup: true,
422
+ validateSyntax: true,
423
+ updateImports: true,
424
+ preserveFormatting: false,
425
+ continueOnError: false,
426
+ ...config
427
+ });
428
+ }
429
+ }
430
+
431
+ module.exports = MoveExecutor;