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,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactoring Plan Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages refactoring plans and operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const {
|
|
10
|
+
RefactoringOperation,
|
|
11
|
+
RefactoringStep,
|
|
12
|
+
RefactoringPlan,
|
|
13
|
+
RefactoringResult
|
|
14
|
+
} = require('./refactoring-models');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Plan Manager class
|
|
18
|
+
*/
|
|
19
|
+
class PlanManager {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this.options = {
|
|
22
|
+
autoSave: options.autoSave !== false,
|
|
23
|
+
backupPlans: options.backupPlans !== false,
|
|
24
|
+
planDirectory: options.planDirectory || './refactoring-plans',
|
|
25
|
+
...options
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
this.plans = new Map();
|
|
29
|
+
this.currentPlan = null;
|
|
30
|
+
this.history = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createPlan(name, description = '') {
|
|
34
|
+
const plan = new RefactoringPlan(name, description);
|
|
35
|
+
this.plans.set(plan.id, plan);
|
|
36
|
+
|
|
37
|
+
if (this.options.autoSave) {
|
|
38
|
+
this.savePlan(plan);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return plan;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
loadPlan(planId) {
|
|
45
|
+
const plan = this.plans.get(planId);
|
|
46
|
+
if (!plan) {
|
|
47
|
+
throw new Error(`Plan not found: ${planId}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.currentPlan = plan;
|
|
51
|
+
return plan;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
savePlan(plan) {
|
|
55
|
+
if (!this.plans.has(plan.id)) {
|
|
56
|
+
this.plans.set(plan.id, plan);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (this.options.autoSave) {
|
|
60
|
+
const planPath = path.join(this.options.planDirectory, `${plan.id}.json`);
|
|
61
|
+
|
|
62
|
+
// Ensure directory exists
|
|
63
|
+
fs.mkdirSync(this.options.planDirectory, { recursive: true });
|
|
64
|
+
|
|
65
|
+
// Save plan
|
|
66
|
+
fs.writeFileSync(planPath, JSON.stringify(plan.toJSON(), null, 2), 'utf8');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
deletePlan(planId) {
|
|
71
|
+
const plan = this.plans.get(planId);
|
|
72
|
+
if (!plan) {
|
|
73
|
+
throw new Error(`Plan not found: ${planId}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.plans.delete(planId);
|
|
77
|
+
|
|
78
|
+
if (this.currentPlan?.id === planId) {
|
|
79
|
+
this.currentPlan = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Delete plan file
|
|
83
|
+
const planPath = path.join(this.options.planDirectory, `${planId}.json`);
|
|
84
|
+
if (fs.existsSync(planPath)) {
|
|
85
|
+
fs.unlinkSync(planPath);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
listPlans() {
|
|
90
|
+
return Array.from(this.plans.values()).map(plan => plan.getSummary());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getPlan(planId) {
|
|
94
|
+
return this.plans.get(planId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getCurrentPlan() {
|
|
98
|
+
return this.currentPlan;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setCurrentPlan(planId) {
|
|
102
|
+
return this.loadPlan(planId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
addOperationToCurrentPlan(operationData) {
|
|
106
|
+
if (!this.currentPlan) {
|
|
107
|
+
throw new Error('No current plan set');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const operation = new RefactoringOperation(
|
|
111
|
+
operationData.type,
|
|
112
|
+
operationData.targetPath,
|
|
113
|
+
operationData.options
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
this.currentPlan.addOperation(operation);
|
|
117
|
+
|
|
118
|
+
if (this.options.autoSave) {
|
|
119
|
+
this.savePlan(this.currentPlan);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return operation;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
addStepToOperation(operationId, stepData) {
|
|
126
|
+
const operation = this.getOperation(operationId);
|
|
127
|
+
if (!operation) {
|
|
128
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const step = new RefactoringStep(
|
|
132
|
+
stepData.name,
|
|
133
|
+
stepData.type,
|
|
134
|
+
stepData.options
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
operation.addStep(step);
|
|
138
|
+
|
|
139
|
+
if (this.options.autoSave) {
|
|
140
|
+
this.savePlan(this.currentPlan);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return step;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
getOperation(operationId) {
|
|
147
|
+
for (const plan of this.plans.values()) {
|
|
148
|
+
const operation = plan.operations.find(op => op.id === operationId);
|
|
149
|
+
if (operation) return operation;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
executePlan(planId, options = {}) {
|
|
155
|
+
const plan = this.getPlan(planId);
|
|
156
|
+
if (!plan) {
|
|
157
|
+
throw new Error(`Plan not found: ${planId}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const executionOptions = {
|
|
161
|
+
continueOnError: options.continueOnError || false,
|
|
162
|
+
parallel: options.parallel || false,
|
|
163
|
+
timeout: options.timeout || 300000, // 5 minutes
|
|
164
|
+
...options
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return this.executePlanOperations(plan, executionOptions);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async executePlanOperations(plan, options) {
|
|
171
|
+
const results = [];
|
|
172
|
+
const startTime = Date.now();
|
|
173
|
+
|
|
174
|
+
if (options.parallel) {
|
|
175
|
+
// Execute operations in parallel
|
|
176
|
+
const promises = plan.operations.map(op => this.executeOperation(op, options));
|
|
177
|
+
const operationResults = await Promise.allSettled(promises);
|
|
178
|
+
|
|
179
|
+
operationResults.forEach((result, index) => {
|
|
180
|
+
if (result.status === 'fulfilled') {
|
|
181
|
+
results.push(result.value);
|
|
182
|
+
} else {
|
|
183
|
+
results.push({
|
|
184
|
+
success: false,
|
|
185
|
+
error: result.reason,
|
|
186
|
+
operationId: plan.operations[index].id
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
// Execute operations sequentially
|
|
192
|
+
for (const operation of plan.operations) {
|
|
193
|
+
const result = await this.executeOperation(operation, options);
|
|
194
|
+
results.push(result);
|
|
195
|
+
|
|
196
|
+
// Stop on first failure if not continuing on error
|
|
197
|
+
if (!result.success && !options.continueOnError) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const planResult = {
|
|
204
|
+
planId: plan.id,
|
|
205
|
+
success: results.every(r => r.success),
|
|
206
|
+
duration: Date.now() - startTime,
|
|
207
|
+
results,
|
|
208
|
+
summary: {
|
|
209
|
+
total: plan.operations.length,
|
|
210
|
+
successful: results.filter(r => r.success).length,
|
|
211
|
+
failed: results.filter(r => !r.success).length
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Record in history
|
|
216
|
+
this.history.push(planResult);
|
|
217
|
+
|
|
218
|
+
return planResult;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async executeOperation(operation, options) {
|
|
222
|
+
const result = new RefactoringResult(operation.id);
|
|
223
|
+
|
|
224
|
+
try {
|
|
225
|
+
// Update operation status
|
|
226
|
+
operation.updateStatus('in_progress');
|
|
227
|
+
|
|
228
|
+
// Execute steps
|
|
229
|
+
for (const step of operation.steps) {
|
|
230
|
+
const stepResult = await this.executeStep(step, options);
|
|
231
|
+
|
|
232
|
+
if (!stepResult.success && !options.continueOnError) {
|
|
233
|
+
operation.updateStatus('failed');
|
|
234
|
+
result.fail(new Error(`Step ${step.name} failed`));
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Mark operation as completed
|
|
240
|
+
operation.updateStatus('completed');
|
|
241
|
+
operation.setResults(result.outputs);
|
|
242
|
+
|
|
243
|
+
result.complete(result.outputs, {
|
|
244
|
+
filesModified: operation.steps.length,
|
|
245
|
+
linesChanged: operation.steps.reduce((sum, step) => sum + (step.options.linesChanged || 0), 0)
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
return result;
|
|
249
|
+
|
|
250
|
+
} catch (error) {
|
|
251
|
+
operation.updateStatus('failed');
|
|
252
|
+
operation.addError(error);
|
|
253
|
+
result.fail(error);
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async executeStep(step, options) {
|
|
259
|
+
step.start();
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
// Simulate step execution (in real scenario, this would call actual refactoring logic)
|
|
263
|
+
await this.simulateStepExecution(step);
|
|
264
|
+
|
|
265
|
+
step.complete({
|
|
266
|
+
success: true,
|
|
267
|
+
message: `Step ${step.name} completed successfully`
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
success: true,
|
|
272
|
+
stepId: step.id,
|
|
273
|
+
duration: step.duration
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
} catch (error) {
|
|
277
|
+
step.fail(error);
|
|
278
|
+
return {
|
|
279
|
+
success: false,
|
|
280
|
+
stepId: step.id,
|
|
281
|
+
error: error.message
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async simulateStepExecution(step) {
|
|
287
|
+
// Simulate different step types
|
|
288
|
+
switch (step.type) {
|
|
289
|
+
case 'extract':
|
|
290
|
+
await this.simulateExtract(step);
|
|
291
|
+
break;
|
|
292
|
+
case 'move':
|
|
293
|
+
await this.simulateMove(step);
|
|
294
|
+
break;
|
|
295
|
+
case 'refactor':
|
|
296
|
+
await this.simulateRefactor(step);
|
|
297
|
+
break;
|
|
298
|
+
default:
|
|
299
|
+
await this.simulateGeneric(step);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async simulateExtract(step) {
|
|
305
|
+
// Simulate extraction delay
|
|
306
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
307
|
+
step.updateProgress(50);
|
|
308
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
309
|
+
step.updateProgress(100);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async simulateMove(step) {
|
|
313
|
+
// Simulate move delay
|
|
314
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
315
|
+
step.updateProgress(33);
|
|
316
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
317
|
+
step.updateProgress(66);
|
|
318
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
319
|
+
step.updateProgress(100);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
async simulateRefactor(step) {
|
|
323
|
+
// Simulate refactor delay
|
|
324
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
325
|
+
step.updateProgress(25);
|
|
326
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
327
|
+
step.updateProgress(50);
|
|
328
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
329
|
+
step.updateProgress(75);
|
|
330
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
331
|
+
step.updateProgress(100);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async simulateGeneric(step) {
|
|
335
|
+
// Simulate generic step delay
|
|
336
|
+
const delay = step.options.estimatedDuration || 100;
|
|
337
|
+
await new Promise(resolve => setTimeout(resolve, delay / 2));
|
|
338
|
+
step.updateProgress(50);
|
|
339
|
+
await new Promise(resolve => setTimeout(resolve, delay / 2));
|
|
340
|
+
step.updateProgress(100);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
getExecutionHistory() {
|
|
344
|
+
return this.history;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
exportPlan(planId, outputPath) {
|
|
348
|
+
const plan = this.getPlan(planId);
|
|
349
|
+
if (!plan) {
|
|
350
|
+
throw new Error(`Plan not found: ${planId}`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const exportData = {
|
|
354
|
+
plan: plan.toJSON(),
|
|
355
|
+
exportedAt: new Date().toISOString(),
|
|
356
|
+
version: '1.0.0'
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
fs.writeFileSync(outputPath, JSON.stringify(exportData, null, 2), 'utf8');
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
importPlan(planPath) {
|
|
363
|
+
const planData = JSON.parse(fs.readFileSync(planPath, 'utf8'));
|
|
364
|
+
|
|
365
|
+
const plan = new RefactoringPlan(planData.name, planData.description);
|
|
366
|
+
plan.id = planData.id;
|
|
367
|
+
plan.status = planData.status;
|
|
368
|
+
plan.priority = planData.priority;
|
|
369
|
+
plan.tags = planData.tags || [];
|
|
370
|
+
plan.metadata = planData.metadata;
|
|
371
|
+
|
|
372
|
+
// Restore operations
|
|
373
|
+
planData.operations.forEach(opData => {
|
|
374
|
+
const operation = new RefactoringOperation(opData.type, opData.targetPath, opData.options);
|
|
375
|
+
Object.assign(operation, opData);
|
|
376
|
+
plan.addOperation(operation);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
this.plans.set(plan.id, plan);
|
|
380
|
+
return plan;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
getManagerInfo() {
|
|
384
|
+
return {
|
|
385
|
+
supportedOperations: ['extract', 'move', 'refactor', 'consolidate'],
|
|
386
|
+
supportedStepTypes: ['extract', 'move', 'refactor', 'validate', 'test'],
|
|
387
|
+
defaultOptions: this.options,
|
|
388
|
+
features: [
|
|
389
|
+
'plan management',
|
|
390
|
+
'operation execution',
|
|
391
|
+
'step tracking',
|
|
392
|
+
'history recording',
|
|
393
|
+
'import/export',
|
|
394
|
+
'parallel execution'
|
|
395
|
+
],
|
|
396
|
+
version: '1.0.0'
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
static createDefault(config = {}) {
|
|
401
|
+
return new PlanManager({
|
|
402
|
+
autoSave: true,
|
|
403
|
+
backupPlans: true,
|
|
404
|
+
planDirectory: './refactoring-plans',
|
|
405
|
+
...config
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
module.exports = PlanManager;
|