@angular-modernizer/adapter-mcp 0.1.1
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/LICENSE +21 -0
- package/README.md +917 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/project-analyzer.d.ts +59 -0
- package/dist/core/project-analyzer.d.ts.map +1 -0
- package/dist/core/project-analyzer.js +116 -0
- package/dist/core/project-analyzer.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-watcher.d.ts +119 -0
- package/dist/mcp-watcher.d.ts.map +1 -0
- package/dist/mcp-watcher.js +380 -0
- package/dist/mcp-watcher.js.map +1 -0
- package/dist/server/json-rpc-handler.d.ts +57 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -0
- package/dist/server/json-rpc-handler.js +222 -0
- package/dist/server/json-rpc-handler.js.map +1 -0
- package/dist/server/mcp-server.d.ts +62 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +184 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/server/tool-registry.d.ts +73 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +102 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/streaming/progress-store.d.ts +120 -0
- package/dist/streaming/progress-store.d.ts.map +1 -0
- package/dist/streaming/progress-store.js +238 -0
- package/dist/streaming/progress-store.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +127 -0
- package/dist/tools/analyze-build-impact.d.ts.map +1 -0
- package/dist/tools/analyze-build-impact.js +194 -0
- package/dist/tools/analyze-build-impact.js.map +1 -0
- package/dist/tools/analyze-core-to-shared.d.ts +163 -0
- package/dist/tools/analyze-core-to-shared.d.ts.map +1 -0
- package/dist/tools/analyze-core-to-shared.js +436 -0
- package/dist/tools/analyze-core-to-shared.js.map +1 -0
- package/dist/tools/analyze-parser-performance.d.ts +105 -0
- package/dist/tools/analyze-parser-performance.d.ts.map +1 -0
- package/dist/tools/analyze-parser-performance.js +313 -0
- package/dist/tools/analyze-parser-performance.js.map +1 -0
- package/dist/tools/analyze-project.d.ts +277 -0
- package/dist/tools/analyze-project.d.ts.map +1 -0
- package/dist/tools/analyze-project.js +946 -0
- package/dist/tools/analyze-project.js.map +1 -0
- package/dist/tools/check-incremental-compatibility.d.ts +109 -0
- package/dist/tools/check-incremental-compatibility.d.ts.map +1 -0
- package/dist/tools/check-incremental-compatibility.js +302 -0
- package/dist/tools/check-incremental-compatibility.js.map +1 -0
- package/dist/tools/collect-feedback.d.ts +117 -0
- package/dist/tools/collect-feedback.d.ts.map +1 -0
- package/dist/tools/collect-feedback.js +773 -0
- package/dist/tools/collect-feedback.js.map +1 -0
- package/dist/tools/extract-libraries.d.ts +121 -0
- package/dist/tools/extract-libraries.d.ts.map +1 -0
- package/dist/tools/extract-libraries.js +223 -0
- package/dist/tools/extract-libraries.js.map +1 -0
- package/dist/tools/find-angular-symbol.d.ts +55 -0
- package/dist/tools/find-angular-symbol.d.ts.map +1 -0
- package/dist/tools/find-angular-symbol.js +104 -0
- package/dist/tools/find-angular-symbol.js.map +1 -0
- package/dist/tools/find-usages.d.ts +65 -0
- package/dist/tools/find-usages.d.ts.map +1 -0
- package/dist/tools/find-usages.js +108 -0
- package/dist/tools/find-usages.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +61 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +119 -0
- package/dist/tools/get-call-graph.js.map +1 -0
- package/dist/tools/get-operation-progress-tool.d.ts +29 -0
- package/dist/tools/get-operation-progress-tool.d.ts.map +1 -0
- package/dist/tools/get-operation-progress-tool.js +36 -0
- package/dist/tools/get-operation-progress-tool.js.map +1 -0
- package/dist/tools/get-operation-progress.d.ts +51 -0
- package/dist/tools/get-operation-progress.d.ts.map +1 -0
- package/dist/tools/get-operation-progress.js +93 -0
- package/dist/tools/get-operation-progress.js.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts +43 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.js +196 -0
- package/dist/tools/helpers/feedback-analyzer.js.map +1 -0
- package/dist/tools/helpers/find-ts-config.d.ts +10 -0
- package/dist/tools/helpers/find-ts-config.d.ts.map +1 -0
- package/dist/tools/helpers/find-ts-config.js +32 -0
- package/dist/tools/helpers/find-ts-config.js.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +33 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.js +60 -0
- package/dist/tools/helpers/platform-root-resolver.js.map +1 -0
- package/dist/tools/helpers/rule-matcher.d.ts +84 -0
- package/dist/tools/helpers/rule-matcher.d.ts.map +1 -0
- package/dist/tools/helpers/rule-matcher.js +212 -0
- package/dist/tools/helpers/rule-matcher.js.map +1 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +66 -0
- package/dist/tools/helpers/suggestion-generator.d.ts.map +1 -0
- package/dist/tools/helpers/suggestion-generator.js +248 -0
- package/dist/tools/helpers/suggestion-generator.js.map +1 -0
- package/dist/tools/learn-patterns.d.ts +368 -0
- package/dist/tools/learn-patterns.d.ts.map +1 -0
- package/dist/tools/learn-patterns.js +1089 -0
- package/dist/tools/learn-patterns.js.map +1 -0
- package/dist/tools/orchestrate-migration.d.ts +187 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -0
- package/dist/tools/orchestrate-migration.js +235 -0
- package/dist/tools/orchestrate-migration.js.map +1 -0
- package/dist/tools/parse-stack-trace.d.ts +63 -0
- package/dist/tools/parse-stack-trace.d.ts.map +1 -0
- package/dist/tools/parse-stack-trace.js +92 -0
- package/dist/tools/parse-stack-trace.js.map +1 -0
- package/dist/tools/plan-migration.d.ts +388 -0
- package/dist/tools/plan-migration.d.ts.map +1 -0
- package/dist/tools/plan-migration.js +826 -0
- package/dist/tools/plan-migration.js.map +1 -0
- package/dist/tools/resolve-type.d.ts +54 -0
- package/dist/tools/resolve-type.d.ts.map +1 -0
- package/dist/tools/resolve-type.js +101 -0
- package/dist/tools/resolve-type.js.map +1 -0
- package/dist/tools/review-feedback.d.ts +124 -0
- package/dist/tools/review-feedback.d.ts.map +1 -0
- package/dist/tools/review-feedback.js +276 -0
- package/dist/tools/review-feedback.js.map +1 -0
- package/dist/tools/rollback-changes.d.ts +42 -0
- package/dist/tools/rollback-changes.d.ts.map +1 -0
- package/dist/tools/rollback-changes.js +95 -0
- package/dist/tools/rollback-changes.js.map +1 -0
- package/dist/tools/run-angular-cli.d.ts +102 -0
- package/dist/tools/run-angular-cli.d.ts.map +1 -0
- package/dist/tools/run-angular-cli.js +152 -0
- package/dist/tools/run-angular-cli.js.map +1 -0
- package/dist/tools/run-build.d.ts +201 -0
- package/dist/tools/run-build.d.ts.map +1 -0
- package/dist/tools/run-build.js +554 -0
- package/dist/tools/run-build.js.map +1 -0
- package/dist/tools/run-schematic.d.ts +173 -0
- package/dist/tools/run-schematic.d.ts.map +1 -0
- package/dist/tools/run-schematic.js +410 -0
- package/dist/tools/run-schematic.js.map +1 -0
- package/dist/tools/scan-all.d.ts +160 -0
- package/dist/tools/scan-all.d.ts.map +1 -0
- package/dist/tools/scan-all.js +486 -0
- package/dist/tools/scan-all.js.map +1 -0
- package/dist/tools/scan-angular.d.ts +132 -0
- package/dist/tools/scan-angular.d.ts.map +1 -0
- package/dist/tools/scan-angular.js +411 -0
- package/dist/tools/scan-angular.js.map +1 -0
- package/dist/tools/scan-architecture.d.ts +351 -0
- package/dist/tools/scan-architecture.d.ts.map +1 -0
- package/dist/tools/scan-architecture.js +1290 -0
- package/dist/tools/scan-architecture.js.map +1 -0
- package/dist/tools/scan-solid.d.ts +132 -0
- package/dist/tools/scan-solid.d.ts.map +1 -0
- package/dist/tools/scan-solid.js +435 -0
- package/dist/tools/scan-solid.js.map +1 -0
- package/dist/tools/search-codebase.d.ts +64 -0
- package/dist/tools/search-codebase.d.ts.map +1 -0
- package/dist/tools/search-codebase.js +109 -0
- package/dist/tools/search-codebase.js.map +1 -0
- package/dist/tools/shared/scan-types.d.ts +200 -0
- package/dist/tools/shared/scan-types.d.ts.map +1 -0
- package/dist/tools/shared/scan-types.js +7 -0
- package/dist/tools/shared/scan-types.js.map +1 -0
- package/dist/tools/suggest-improvements.d.ts +96 -0
- package/dist/tools/suggest-improvements.d.ts.map +1 -0
- package/dist/tools/suggest-improvements.js +182 -0
- package/dist/tools/suggest-improvements.js.map +1 -0
- package/dist/tools/transform-code-batch.d.ts +57 -0
- package/dist/tools/transform-code-batch.d.ts.map +1 -0
- package/dist/tools/transform-code-batch.js +107 -0
- package/dist/tools/transform-code-batch.js.map +1 -0
- package/dist/tools/transform-code.d.ts +352 -0
- package/dist/tools/transform-code.d.ts.map +1 -0
- package/dist/tools/transform-code.js +1171 -0
- package/dist/tools/transform-code.js.map +1 -0
- package/dist/tools/validate-before-transform.d.ts +54 -0
- package/dist/tools/validate-before-transform.d.ts.map +1 -0
- package/dist/tools/validate-before-transform.js +141 -0
- package/dist/tools/validate-before-transform.js.map +1 -0
- package/dist/tools/validate-project-compatibility.d.ts +119 -0
- package/dist/tools/validate-project-compatibility.d.ts.map +1 -0
- package/dist/tools/validate-project-compatibility.js +243 -0
- package/dist/tools/validate-project-compatibility.js.map +1 -0
- package/dist/tools/validate-transformation.d.ts +105 -0
- package/dist/tools/validate-transformation.d.ts.map +1 -0
- package/dist/tools/validate-transformation.js +391 -0
- package/dist/tools/validate-transformation.js.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +38 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format-tool-response.d.ts +72 -0
- package/dist/utils/format-tool-response.d.ts.map +1 -0
- package/dist/utils/format-tool-response.js +149 -0
- package/dist/utils/format-tool-response.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Plan Migration Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for creating optimal migration strategies based on
|
|
5
|
+
* detected architectural issues, SOLID principle violations,
|
|
6
|
+
* and codebase style conventions. Integrates with the self-learning
|
|
7
|
+
* pattern infrastructure for style-aware migration planning.
|
|
8
|
+
*
|
|
9
|
+
* Enhancement: Style-aware migration planning that respects
|
|
10
|
+
* existing codebase conventions (RxJS patterns, DI style, etc.)
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* MCP tool for planning migrations.
|
|
14
|
+
*/
|
|
15
|
+
export class PlanMigrationTool {
|
|
16
|
+
name = 'plan-migration';
|
|
17
|
+
description = 'Generate comprehensive, style-aware migration plans for architectural improvements';
|
|
18
|
+
inputSchema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
violations: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
description: 'Violations detected by scan-architecture',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
ruleId: { type: 'string' },
|
|
28
|
+
severity: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
enum: ['low', 'medium', 'high', 'critical'],
|
|
31
|
+
},
|
|
32
|
+
category: { type: 'string' },
|
|
33
|
+
},
|
|
34
|
+
required: ['ruleId', 'severity', 'category'],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
architecture: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
description: 'Current architecture analysis',
|
|
40
|
+
properties: {
|
|
41
|
+
pattern: { type: 'string' },
|
|
42
|
+
confidence: { type: 'number' },
|
|
43
|
+
},
|
|
44
|
+
required: ['pattern', 'confidence'],
|
|
45
|
+
},
|
|
46
|
+
constraints: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
description: 'Migration constraints',
|
|
49
|
+
properties: {
|
|
50
|
+
timeline: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
enum: ['aggressive', 'moderate', 'conservative'],
|
|
53
|
+
default: 'moderate',
|
|
54
|
+
},
|
|
55
|
+
riskTolerance: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: ['low', 'medium', 'high'],
|
|
58
|
+
default: 'medium',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
orchestration: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
description: 'Phase 6d/7b orchestration options (subset for migration planning)',
|
|
65
|
+
properties: {
|
|
66
|
+
enableProgress: {
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
description: 'Enable real-time progress reporting for complex migration planning',
|
|
69
|
+
default: false,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
// Phase 8: Style-aware migration planning parameters
|
|
74
|
+
styleProfile: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
description: 'Codebase style profile from learn-patterns tool',
|
|
77
|
+
properties: {
|
|
78
|
+
diRatio: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
constructor: { type: 'number' },
|
|
82
|
+
inject: { type: 'number' },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
rxjsRatio: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
observable: { type: 'number' },
|
|
89
|
+
subject: { type: 'number' },
|
|
90
|
+
behaviorSubject: { type: 'number' },
|
|
91
|
+
replaySubject: { type: 'number' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
stateManagement: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
enum: ['ngrx', 'akita', 'ngxs', 'custom', 'none'],
|
|
97
|
+
},
|
|
98
|
+
namingConventions: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
componentSuffix: { type: 'string' },
|
|
102
|
+
serviceSuffix: { type: 'string' },
|
|
103
|
+
interfacePrefix: { type: 'string' },
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
architectureStyle: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
enum: ['clean', 'feature-modules', 'ddd', 'standard'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
teamContext: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
description: 'Team context for risk assessment',
|
|
115
|
+
properties: {
|
|
116
|
+
velocity: { type: 'number' },
|
|
117
|
+
experienceLevel: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
enum: ['junior', 'mid', 'senior', 'mixed'],
|
|
120
|
+
},
|
|
121
|
+
availability: { type: 'number' },
|
|
122
|
+
specializations: {
|
|
123
|
+
type: 'array',
|
|
124
|
+
items: { type: 'string' },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
enableStyleAwareRisk: {
|
|
129
|
+
type: 'boolean',
|
|
130
|
+
description: 'Enable style-aware risk assessment',
|
|
131
|
+
default: true,
|
|
132
|
+
},
|
|
133
|
+
filterStyleConflicts: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
description: 'Filter out migration steps that conflict with codebase style',
|
|
136
|
+
default: false,
|
|
137
|
+
},
|
|
138
|
+
styleAlignmentThreshold: {
|
|
139
|
+
type: 'number',
|
|
140
|
+
description: 'Style alignment threshold (0.0 - 1.0)',
|
|
141
|
+
default: 0.5,
|
|
142
|
+
},
|
|
143
|
+
includeStyleRecommendations: {
|
|
144
|
+
type: 'boolean',
|
|
145
|
+
description: 'Generate style preservation recommendations',
|
|
146
|
+
default: true,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ['violations', 'architecture'],
|
|
150
|
+
};
|
|
151
|
+
async execute(args) {
|
|
152
|
+
const params = args;
|
|
153
|
+
const violations = params.violations;
|
|
154
|
+
const architecture = params.architecture;
|
|
155
|
+
const constraints = params.constraints;
|
|
156
|
+
const styleProfile = params.styleProfile;
|
|
157
|
+
const teamContext = params.teamContext;
|
|
158
|
+
const enableStyleAwareRisk = params.enableStyleAwareRisk ?? true;
|
|
159
|
+
const filterStyleConflicts = params.filterStyleConflicts ?? false;
|
|
160
|
+
const styleAlignmentThreshold = params.styleAlignmentThreshold ?? 0.5;
|
|
161
|
+
const includeStyleRecommendations = params.includeStyleRecommendations ?? true;
|
|
162
|
+
if (!violations || !Array.isArray(violations)) {
|
|
163
|
+
throw new Error('violations is required and must be an array');
|
|
164
|
+
}
|
|
165
|
+
if (!architecture || typeof architecture !== 'object') {
|
|
166
|
+
throw new Error('architecture is required and must be an object');
|
|
167
|
+
}
|
|
168
|
+
// Generate available strategies based on violations and architecture
|
|
169
|
+
let availableStrategies = this.generateMigrationStrategies(violations, architecture);
|
|
170
|
+
// Style-aware filtering if enabled
|
|
171
|
+
let styleConflictingSteps;
|
|
172
|
+
let stepsWithStyleAnalysis;
|
|
173
|
+
let styleRecommendations;
|
|
174
|
+
let styleAwareRiskAssessment;
|
|
175
|
+
let styleAlignmentScore;
|
|
176
|
+
if (styleProfile && enableStyleAwareRisk) {
|
|
177
|
+
// Analyze style conflicts for all steps across strategies
|
|
178
|
+
const allSteps = availableStrategies.flatMap((s) => s.steps);
|
|
179
|
+
const styleAnalysis = this.analyzeStepsForStyleConflicts(allSteps, styleProfile, styleAlignmentThreshold);
|
|
180
|
+
styleConflictingSteps = styleAnalysis.conflictingSteps;
|
|
181
|
+
stepsWithStyleAnalysis = styleAnalysis.stepsWithAnalysis;
|
|
182
|
+
styleAlignmentScore = styleAnalysis.overallScore;
|
|
183
|
+
// Filter strategies if requested
|
|
184
|
+
if (filterStyleConflicts) {
|
|
185
|
+
availableStrategies = this.filterStrategiesByStyle(availableStrategies, styleProfile, styleAlignmentThreshold);
|
|
186
|
+
}
|
|
187
|
+
// Generate style-aware risk assessment
|
|
188
|
+
styleAwareRiskAssessment = this.generateStyleAwareRiskAssessment(availableStrategies, styleProfile, teamContext);
|
|
189
|
+
// Generate style recommendations
|
|
190
|
+
if (includeStyleRecommendations) {
|
|
191
|
+
styleRecommendations = this.generateStyleRecommendations(availableStrategies, styleProfile);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Select optimal strategy based on constraints (and style if available)
|
|
195
|
+
const recommendedStrategy = this.selectOptimalStrategy(availableStrategies, constraints, styleProfile);
|
|
196
|
+
// Generate alternative strategies
|
|
197
|
+
const alternativeStrategies = availableStrategies.filter((s) => s.id !== recommendedStrategy.id);
|
|
198
|
+
// Create implementation roadmap
|
|
199
|
+
const roadmap = this.createImplementationRoadmap(recommendedStrategy, constraints);
|
|
200
|
+
// Generate reasoning
|
|
201
|
+
const reasoning = this.generateReasoning(recommendedStrategy, violations, constraints);
|
|
202
|
+
return {
|
|
203
|
+
recommendedStrategy,
|
|
204
|
+
alternativeStrategies,
|
|
205
|
+
reasoning,
|
|
206
|
+
roadmap,
|
|
207
|
+
successMetrics: this.generateSuccessMetrics(recommendedStrategy),
|
|
208
|
+
// Style-aware results
|
|
209
|
+
styleAwareRiskAssessment,
|
|
210
|
+
styleConflictingSteps,
|
|
211
|
+
styleRecommendations,
|
|
212
|
+
styleAlignmentScore,
|
|
213
|
+
stepsWithStyleAnalysis,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// ========================================================================
|
|
217
|
+
// Style-Aware Migration Planning Methods
|
|
218
|
+
// ========================================================================
|
|
219
|
+
/**
|
|
220
|
+
* Analyze migration steps for style conflicts.
|
|
221
|
+
*/
|
|
222
|
+
analyzeStepsForStyleConflicts(steps, styleProfile, threshold) {
|
|
223
|
+
const conflictingSteps = [];
|
|
224
|
+
const stepsWithAnalysis = [];
|
|
225
|
+
for (const step of steps) {
|
|
226
|
+
const analysis = this.analyzeStepStyleAlignment(step, styleProfile);
|
|
227
|
+
stepsWithAnalysis.push({
|
|
228
|
+
step,
|
|
229
|
+
styleAlignmentScore: analysis.score,
|
|
230
|
+
alignsWithStyle: analysis.score >= threshold,
|
|
231
|
+
styleWarnings: analysis.warnings,
|
|
232
|
+
});
|
|
233
|
+
if (analysis.score < threshold) {
|
|
234
|
+
conflictingSteps.push({
|
|
235
|
+
stepName: step.name,
|
|
236
|
+
conflictReason: analysis.conflictReason ?? 'Style alignment below threshold',
|
|
237
|
+
styleRecommendation: analysis.recommendation ?? 'Consider alternative approach',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const overallScore = stepsWithAnalysis.length > 0
|
|
242
|
+
? Math.round((stepsWithAnalysis.reduce((sum, s) => sum + s.styleAlignmentScore, 0) /
|
|
243
|
+
stepsWithAnalysis.length) *
|
|
244
|
+
100)
|
|
245
|
+
: 100;
|
|
246
|
+
return { conflictingSteps, stepsWithAnalysis, overallScore };
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Analyze individual step's style alignment.
|
|
250
|
+
*/
|
|
251
|
+
analyzeStepStyleAlignment(step, styleProfile) {
|
|
252
|
+
const warnings = [];
|
|
253
|
+
let score = 1.0;
|
|
254
|
+
let conflictReason;
|
|
255
|
+
let recommendation;
|
|
256
|
+
// Check for DI pattern conflicts
|
|
257
|
+
if (step.action.includes('inject') ||
|
|
258
|
+
step.action.includes('dependency-injection')) {
|
|
259
|
+
if (styleProfile.diRatio.constructor > 0.7) {
|
|
260
|
+
score -= 0.3;
|
|
261
|
+
warnings.push(`Codebase uses constructor injection (${Math.round(styleProfile.diRatio.constructor * 100)}%)`);
|
|
262
|
+
conflictReason = 'DI pattern mismatch';
|
|
263
|
+
recommendation =
|
|
264
|
+
'Consider keeping constructor injection or full migration';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Check for RxJS pattern conflicts
|
|
268
|
+
if (step.action.includes('signal') || step.action.includes('observable')) {
|
|
269
|
+
if (styleProfile.rxjsRatio.behaviorSubject > 0.3) {
|
|
270
|
+
score -= 0.2;
|
|
271
|
+
warnings.push(`Codebase heavily uses BehaviorSubject (${Math.round(styleProfile.rxjsRatio.behaviorSubject * 100)}%)`);
|
|
272
|
+
conflictReason = conflictReason ?? 'RxJS pattern mismatch';
|
|
273
|
+
recommendation =
|
|
274
|
+
recommendation ?? 'Consider incremental Signal adoption';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Check for standalone component conflicts
|
|
278
|
+
if (step.action.includes('standalone') || step.action.includes('module')) {
|
|
279
|
+
if (styleProfile.architectureStyle === 'feature-modules') {
|
|
280
|
+
score -= 0.2;
|
|
281
|
+
warnings.push('Codebase uses feature module architecture');
|
|
282
|
+
conflictReason = conflictReason ?? 'Architecture style mismatch';
|
|
283
|
+
recommendation =
|
|
284
|
+
recommendation ?? 'Plan holistic module-to-standalone migration';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
score: Math.max(0, score),
|
|
289
|
+
warnings,
|
|
290
|
+
conflictReason,
|
|
291
|
+
recommendation,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Filter strategies by style compatibility.
|
|
296
|
+
*/
|
|
297
|
+
filterStrategiesByStyle(strategies, styleProfile, threshold) {
|
|
298
|
+
return strategies
|
|
299
|
+
.map((strategy) => {
|
|
300
|
+
const filteredSteps = strategy.steps.filter((step) => {
|
|
301
|
+
const analysis = this.analyzeStepStyleAlignment(step, styleProfile);
|
|
302
|
+
return analysis.score >= threshold;
|
|
303
|
+
});
|
|
304
|
+
// Keep strategy if it has any compatible steps
|
|
305
|
+
if (filteredSteps.length > 0) {
|
|
306
|
+
return {
|
|
307
|
+
...strategy,
|
|
308
|
+
steps: filteredSteps,
|
|
309
|
+
totalEffort: filteredSteps.reduce((sum, s) => sum + s.effort, 0),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return strategy;
|
|
313
|
+
})
|
|
314
|
+
.filter((strategy) => strategy.steps.length > 0);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Generate style-aware risk assessment.
|
|
318
|
+
*/
|
|
319
|
+
generateStyleAwareRiskAssessment(strategies, styleProfile, teamContext) {
|
|
320
|
+
// Calculate base risk from strategies
|
|
321
|
+
let baseRisk = 0;
|
|
322
|
+
let totalSteps = 0;
|
|
323
|
+
for (const strategy of strategies) {
|
|
324
|
+
for (const step of strategy.steps) {
|
|
325
|
+
const riskValue = step.risk === 'high' ? 80 : step.risk === 'medium' ? 50 : 20;
|
|
326
|
+
baseRisk += riskValue;
|
|
327
|
+
totalSteps++;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const avgBaseRisk = totalSteps > 0 ? baseRisk / totalSteps : 0;
|
|
331
|
+
// Calculate style deviation penalty
|
|
332
|
+
let styleDeviationScore = 0;
|
|
333
|
+
let deviationCount = 0;
|
|
334
|
+
for (const strategy of strategies) {
|
|
335
|
+
for (const step of strategy.steps) {
|
|
336
|
+
const analysis = this.analyzeStepStyleAlignment(step, styleProfile);
|
|
337
|
+
styleDeviationScore += 1 - analysis.score;
|
|
338
|
+
deviationCount++;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const avgStyleDeviation = deviationCount > 0 ? (styleDeviationScore / deviationCount) * 100 : 0;
|
|
342
|
+
// Apply team context adjustments
|
|
343
|
+
let teamAdjustment = 0;
|
|
344
|
+
if (teamContext) {
|
|
345
|
+
switch (teamContext.experienceLevel) {
|
|
346
|
+
case 'junior':
|
|
347
|
+
teamAdjustment = 15;
|
|
348
|
+
break;
|
|
349
|
+
case 'mid':
|
|
350
|
+
teamAdjustment = 5;
|
|
351
|
+
break;
|
|
352
|
+
case 'senior':
|
|
353
|
+
teamAdjustment = -10;
|
|
354
|
+
break;
|
|
355
|
+
case 'mixed':
|
|
356
|
+
teamAdjustment = 0;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
// Calculate overall risk
|
|
361
|
+
const overallRisk = Math.min(100, Math.max(0, avgBaseRisk + avgStyleDeviation * 0.5 + teamAdjustment));
|
|
362
|
+
// Determine risk level
|
|
363
|
+
let riskLevel;
|
|
364
|
+
if (overallRisk < 30) {
|
|
365
|
+
riskLevel = 'low';
|
|
366
|
+
}
|
|
367
|
+
else if (overallRisk < 50) {
|
|
368
|
+
riskLevel = 'medium';
|
|
369
|
+
}
|
|
370
|
+
else if (overallRisk < 70) {
|
|
371
|
+
riskLevel = 'high';
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
riskLevel = 'critical';
|
|
375
|
+
}
|
|
376
|
+
// Generate style recommendations
|
|
377
|
+
const styleRecommendations = [];
|
|
378
|
+
if (styleProfile.diRatio.constructor > 0.6) {
|
|
379
|
+
styleRecommendations.push('Consider keeping constructor injection for consistency');
|
|
380
|
+
}
|
|
381
|
+
if (styleProfile.rxjsRatio.behaviorSubject > 0.3) {
|
|
382
|
+
styleRecommendations.push('BehaviorSubjects are prevalent - plan incremental Signal migration');
|
|
383
|
+
}
|
|
384
|
+
// Generate mitigations
|
|
385
|
+
const mitigations = [];
|
|
386
|
+
if (avgStyleDeviation > 30) {
|
|
387
|
+
mitigations.push({
|
|
388
|
+
category: 'style',
|
|
389
|
+
description: 'Align transformations with codebase conventions',
|
|
390
|
+
riskReduction: 15,
|
|
391
|
+
effort: 'medium',
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (overallRisk > 50) {
|
|
395
|
+
mitigations.push({
|
|
396
|
+
category: 'technical',
|
|
397
|
+
description: 'Break migration into smaller phases',
|
|
398
|
+
riskReduction: 20,
|
|
399
|
+
effort: 'low',
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
if (teamContext?.experienceLevel === 'junior') {
|
|
403
|
+
mitigations.push({
|
|
404
|
+
category: 'organizational',
|
|
405
|
+
description: 'Pair junior developers with seniors during migration',
|
|
406
|
+
riskReduction: 10,
|
|
407
|
+
effort: 'low',
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
overallRisk: Math.round(overallRisk),
|
|
412
|
+
riskLevel,
|
|
413
|
+
styleDeviationScore: Math.round(avgStyleDeviation),
|
|
414
|
+
styleRecommendations,
|
|
415
|
+
mitigations,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Generate style preservation recommendations.
|
|
420
|
+
*/
|
|
421
|
+
generateStyleRecommendations(strategies, styleProfile) {
|
|
422
|
+
const recommendations = [];
|
|
423
|
+
// DI recommendations
|
|
424
|
+
const diSteps = strategies.flatMap((s) => s.steps.filter((step) => step.action.includes('inject') || step.action.includes('dependency')));
|
|
425
|
+
if (diSteps.length > 0 && styleProfile.diRatio.constructor > 0.6) {
|
|
426
|
+
recommendations.push({
|
|
427
|
+
category: 'di',
|
|
428
|
+
currentStyle: `Constructor injection (${Math.round(styleProfile.diRatio.constructor * 100)}%)`,
|
|
429
|
+
recommendation: 'Consider keeping constructor injection for consistency, or plan full migration to inject()',
|
|
430
|
+
reasoning: 'Mixing DI patterns can confuse developers and make the codebase harder to maintain',
|
|
431
|
+
affectedSteps: diSteps.map((s) => s.name),
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
// RxJS recommendations
|
|
435
|
+
const rxjsSteps = strategies.flatMap((s) => s.steps.filter((step) => step.action.includes('signal') ||
|
|
436
|
+
step.action.includes('observable') ||
|
|
437
|
+
step.action.includes('rxjs')));
|
|
438
|
+
if (rxjsSteps.length > 0 && styleProfile.rxjsRatio.behaviorSubject > 0.3) {
|
|
439
|
+
recommendations.push({
|
|
440
|
+
category: 'rxjs',
|
|
441
|
+
currentStyle: `BehaviorSubject usage (${Math.round(styleProfile.rxjsRatio.behaviorSubject * 100)}%)`,
|
|
442
|
+
recommendation: 'Consider incremental Signal adoption, keeping BehaviorSubjects for complex async scenarios',
|
|
443
|
+
reasoning: 'BehaviorSubjects provide features like multicasting that Signals handle differently',
|
|
444
|
+
affectedSteps: rxjsSteps.map((s) => s.name),
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
// Architecture recommendations
|
|
448
|
+
const architectureSteps = strategies.flatMap((s) => s.steps.filter((step) => step.action.includes('standalone') ||
|
|
449
|
+
step.action.includes('module') ||
|
|
450
|
+
step.action.includes('architecture')));
|
|
451
|
+
if (architectureSteps.length > 0 &&
|
|
452
|
+
styleProfile.architectureStyle === 'feature-modules') {
|
|
453
|
+
recommendations.push({
|
|
454
|
+
category: 'architecture',
|
|
455
|
+
currentStyle: 'Feature module-based architecture',
|
|
456
|
+
recommendation: 'Plan complete module-to-standalone migration to avoid hybrid architecture confusion',
|
|
457
|
+
reasoning: 'Mixing NgModules and standalone components can lead to import confusion',
|
|
458
|
+
affectedSteps: architectureSteps.map((s) => s.name),
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return recommendations;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Generate migration strategies based on violations and architecture.
|
|
465
|
+
*/
|
|
466
|
+
generateMigrationStrategies(violations, architecture) {
|
|
467
|
+
const strategies = [];
|
|
468
|
+
// Analyze violation patterns
|
|
469
|
+
const violationCounts = violations.reduce((acc, v) => {
|
|
470
|
+
acc[v.category] = (acc[v.category] ?? 0) + 1;
|
|
471
|
+
return acc;
|
|
472
|
+
}, {});
|
|
473
|
+
// DIP (Dependency Inversion Principle) focused strategy
|
|
474
|
+
if (violationCounts['di-violation'] || violationCounts['solid-violation']) {
|
|
475
|
+
strategies.push({
|
|
476
|
+
id: 'dependency-inversion-migration',
|
|
477
|
+
name: 'Dependency Inversion Migration',
|
|
478
|
+
description: 'Refactor to use dependency injection and interfaces',
|
|
479
|
+
applicableArchitectures: ['universal'],
|
|
480
|
+
complexity: 'medium',
|
|
481
|
+
successRate: 0.85,
|
|
482
|
+
steps: [
|
|
483
|
+
{
|
|
484
|
+
name: 'Identify Service Dependencies',
|
|
485
|
+
action: 'analyze-service-dependencies',
|
|
486
|
+
validation: 'dependencies-identified',
|
|
487
|
+
effort: 3,
|
|
488
|
+
risk: 'low',
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: 'Create Interfaces',
|
|
492
|
+
action: 'generate-interfaces',
|
|
493
|
+
validation: 'interfaces-created',
|
|
494
|
+
effort: 5,
|
|
495
|
+
risk: 'medium',
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: 'Refactor Injectors',
|
|
499
|
+
action: 'update-dependency-injection',
|
|
500
|
+
validation: 'injectors-updated',
|
|
501
|
+
effort: 4,
|
|
502
|
+
risk: 'medium',
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
prerequisites: ['dependency-injection-available'],
|
|
506
|
+
risks: ['breaking-changes', 'testing-required'],
|
|
507
|
+
totalEffort: 12,
|
|
508
|
+
overallRisk: 'medium',
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
// Interface Segregation strategy
|
|
512
|
+
if (violationCounts['solid-violation'] &&
|
|
513
|
+
violations.some((v) => v.ruleId.includes('interface'))) {
|
|
514
|
+
strategies.push({
|
|
515
|
+
id: 'interface-segregation',
|
|
516
|
+
name: 'Interface Segregation',
|
|
517
|
+
description: 'Split large interfaces into smaller, focused ones',
|
|
518
|
+
applicableArchitectures: ['universal'],
|
|
519
|
+
complexity: 'high',
|
|
520
|
+
successRate: 0.75,
|
|
521
|
+
steps: [
|
|
522
|
+
{
|
|
523
|
+
name: 'Analyze Interface Usage',
|
|
524
|
+
action: 'analyze-interface-usage',
|
|
525
|
+
validation: 'usage-analyzed',
|
|
526
|
+
effort: 4,
|
|
527
|
+
risk: 'low',
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: 'Design Segregated Interfaces',
|
|
531
|
+
action: 'design-segregated-interfaces',
|
|
532
|
+
validation: 'interfaces-designed',
|
|
533
|
+
effort: 6,
|
|
534
|
+
risk: 'medium',
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
name: 'Implement Interface Split',
|
|
538
|
+
action: 'implement-interface-split',
|
|
539
|
+
validation: 'interfaces-split',
|
|
540
|
+
effort: 8,
|
|
541
|
+
risk: 'high',
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
prerequisites: ['interface-analysis-capable'],
|
|
545
|
+
risks: ['widespread-changes', 'refactoring-complexity'],
|
|
546
|
+
totalEffort: 18,
|
|
547
|
+
overallRisk: 'high',
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
// Clean Architecture migration
|
|
551
|
+
if (architecture.pattern === 'feature-modules' ||
|
|
552
|
+
architecture.pattern === 'standard-angular') {
|
|
553
|
+
strategies.push({
|
|
554
|
+
id: 'clean-architecture-migration',
|
|
555
|
+
name: 'Clean Architecture Migration',
|
|
556
|
+
description: 'Restructure to follow clean architecture principles',
|
|
557
|
+
applicableArchitectures: ['feature-modules', 'standard-angular'],
|
|
558
|
+
complexity: 'high',
|
|
559
|
+
successRate: 0.7,
|
|
560
|
+
steps: [
|
|
561
|
+
{
|
|
562
|
+
name: 'Define Layer Boundaries',
|
|
563
|
+
action: 'define-layer-boundaries',
|
|
564
|
+
validation: 'boundaries-defined',
|
|
565
|
+
effort: 5,
|
|
566
|
+
risk: 'medium',
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: 'Extract Core Layer',
|
|
570
|
+
action: 'extract-core-layer',
|
|
571
|
+
validation: 'core-extracted',
|
|
572
|
+
effort: 8,
|
|
573
|
+
risk: 'high',
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: 'Migrate Features',
|
|
577
|
+
action: 'migrate-feature-modules',
|
|
578
|
+
validation: 'features-migrated',
|
|
579
|
+
effort: 10,
|
|
580
|
+
risk: 'high',
|
|
581
|
+
},
|
|
582
|
+
],
|
|
583
|
+
prerequisites: ['clean-architecture-knowledge'],
|
|
584
|
+
risks: ['architectural-overhaul', 'extended-timeline'],
|
|
585
|
+
totalEffort: 23,
|
|
586
|
+
overallRisk: 'high',
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
// Standalone component migration (Angular-specific)
|
|
590
|
+
if (architecture.pattern.includes('angular') &&
|
|
591
|
+
!architecture.pattern.includes('standalone')) {
|
|
592
|
+
strategies.push({
|
|
593
|
+
id: 'standalone-migration',
|
|
594
|
+
name: 'Standalone Component Migration',
|
|
595
|
+
description: 'Convert NgModules to standalone components',
|
|
596
|
+
applicableArchitectures: ['angular', 'angular-cli'],
|
|
597
|
+
complexity: 'medium',
|
|
598
|
+
successRate: 0.8,
|
|
599
|
+
steps: [
|
|
600
|
+
{
|
|
601
|
+
name: 'Identify NgModules',
|
|
602
|
+
action: 'identify-ngmodules',
|
|
603
|
+
validation: 'ngmodules-identified',
|
|
604
|
+
effort: 3,
|
|
605
|
+
risk: 'low',
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'Convert Components',
|
|
609
|
+
action: 'convert-to-standalone',
|
|
610
|
+
validation: 'components-converted',
|
|
611
|
+
effort: 6,
|
|
612
|
+
risk: 'medium',
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: 'Update Imports',
|
|
616
|
+
action: 'update-imports',
|
|
617
|
+
validation: 'imports-updated',
|
|
618
|
+
effort: 4,
|
|
619
|
+
risk: 'medium',
|
|
620
|
+
},
|
|
621
|
+
],
|
|
622
|
+
prerequisites: ['angular-standalone-support'],
|
|
623
|
+
risks: ['module-removal', 'import-changes'],
|
|
624
|
+
totalEffort: 13,
|
|
625
|
+
overallRisk: 'medium',
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
// Default strategy if no specific patterns match
|
|
629
|
+
if (strategies.length === 0) {
|
|
630
|
+
strategies.push({
|
|
631
|
+
id: 'incremental-improvement',
|
|
632
|
+
name: 'Incremental Improvement',
|
|
633
|
+
description: 'Gradual improvements to code quality and architecture',
|
|
634
|
+
applicableArchitectures: ['universal'],
|
|
635
|
+
complexity: 'low',
|
|
636
|
+
successRate: 0.9,
|
|
637
|
+
steps: [
|
|
638
|
+
{
|
|
639
|
+
name: 'Prioritize Issues',
|
|
640
|
+
action: 'prioritize-issues',
|
|
641
|
+
validation: 'issues-prioritized',
|
|
642
|
+
effort: 2,
|
|
643
|
+
risk: 'low',
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: 'Implement Quick Wins',
|
|
647
|
+
action: 'implement-quick-wins',
|
|
648
|
+
validation: 'wins-implemented',
|
|
649
|
+
effort: 4,
|
|
650
|
+
risk: 'low',
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: 'Address High-Impact Issues',
|
|
654
|
+
action: 'address-high-impact',
|
|
655
|
+
validation: 'issues-addressed',
|
|
656
|
+
effort: 6,
|
|
657
|
+
risk: 'medium',
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
prerequisites: [],
|
|
661
|
+
risks: ['slow-progress'],
|
|
662
|
+
totalEffort: 12,
|
|
663
|
+
overallRisk: 'low',
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
return strategies;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Select optimal strategy based on constraints and style alignment.
|
|
670
|
+
*/
|
|
671
|
+
selectOptimalStrategy(strategies, constraints, styleProfile) {
|
|
672
|
+
if (strategies.length === 0) {
|
|
673
|
+
throw new Error('No migration strategies available');
|
|
674
|
+
}
|
|
675
|
+
const timeline = constraints?.timeline ?? 'moderate';
|
|
676
|
+
const riskTolerance = constraints?.riskTolerance ?? 'medium';
|
|
677
|
+
// Score strategies based on constraints
|
|
678
|
+
const scored = strategies.map((strategy) => {
|
|
679
|
+
let score = 0;
|
|
680
|
+
// Timeline preference
|
|
681
|
+
if (timeline === 'aggressive' && strategy.complexity === 'low') {
|
|
682
|
+
score += 3;
|
|
683
|
+
}
|
|
684
|
+
if (timeline === 'moderate' && strategy.complexity === 'medium') {
|
|
685
|
+
score += 3;
|
|
686
|
+
}
|
|
687
|
+
if (timeline === 'conservative' && strategy.complexity === 'low') {
|
|
688
|
+
score += 3;
|
|
689
|
+
}
|
|
690
|
+
// Risk tolerance
|
|
691
|
+
if (riskTolerance === 'high' && strategy.overallRisk === 'high') {
|
|
692
|
+
score += 2;
|
|
693
|
+
}
|
|
694
|
+
if (riskTolerance === 'medium' && strategy.overallRisk === 'medium') {
|
|
695
|
+
score += 2;
|
|
696
|
+
}
|
|
697
|
+
if (riskTolerance === 'low' && strategy.overallRisk === 'low') {
|
|
698
|
+
score += 2;
|
|
699
|
+
}
|
|
700
|
+
// Success rate bonus
|
|
701
|
+
score += strategy.successRate * 2;
|
|
702
|
+
// Phase 8: Style alignment bonus (if styleProfile provided)
|
|
703
|
+
if (styleProfile) {
|
|
704
|
+
let styleScore = 0;
|
|
705
|
+
let stepCount = 0;
|
|
706
|
+
for (const step of strategy.steps) {
|
|
707
|
+
const analysis = this.analyzeStepStyleAlignment(step, styleProfile);
|
|
708
|
+
styleScore += analysis.score;
|
|
709
|
+
stepCount++;
|
|
710
|
+
}
|
|
711
|
+
const avgStyleAlignment = stepCount > 0 ? styleScore / stepCount : 1;
|
|
712
|
+
// Add up to 3 points for style alignment
|
|
713
|
+
score += avgStyleAlignment * 3;
|
|
714
|
+
}
|
|
715
|
+
return { strategy, score };
|
|
716
|
+
});
|
|
717
|
+
// Return highest scoring strategy
|
|
718
|
+
scored.sort((a, b) => b.score - a.score);
|
|
719
|
+
const topStrategy = scored[0];
|
|
720
|
+
if (!topStrategy) {
|
|
721
|
+
throw new Error('No suitable migration strategy found');
|
|
722
|
+
}
|
|
723
|
+
return topStrategy.strategy;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Create implementation roadmap.
|
|
727
|
+
*/
|
|
728
|
+
createImplementationRoadmap(strategy, constraints) {
|
|
729
|
+
const timeline = constraints?.timeline ?? 'moderate';
|
|
730
|
+
// Estimate phase durations based on timeline
|
|
731
|
+
const durationMultiplier = {
|
|
732
|
+
aggressive: 0.7,
|
|
733
|
+
moderate: 1.0,
|
|
734
|
+
conservative: 1.5,
|
|
735
|
+
}[timeline];
|
|
736
|
+
const phases = [
|
|
737
|
+
{
|
|
738
|
+
name: 'Preparation',
|
|
739
|
+
duration: `${Math.ceil(2 * durationMultiplier)} weeks`,
|
|
740
|
+
steps: strategy.steps.slice(0, 1),
|
|
741
|
+
deliverables: ['Migration plan', 'Team training', 'Backup strategy'],
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: 'Implementation',
|
|
745
|
+
duration: `${Math.ceil(4 * durationMultiplier)} weeks`,
|
|
746
|
+
steps: strategy.steps.slice(1, -1),
|
|
747
|
+
deliverables: ['Migrated components', 'Updated tests', 'Documentation'],
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
name: 'Validation',
|
|
751
|
+
duration: `${Math.ceil(2 * durationMultiplier)} weeks`,
|
|
752
|
+
steps: strategy.steps.slice(-1),
|
|
753
|
+
deliverables: [
|
|
754
|
+
'Validation report',
|
|
755
|
+
'Performance metrics',
|
|
756
|
+
'Go-live readiness',
|
|
757
|
+
],
|
|
758
|
+
},
|
|
759
|
+
];
|
|
760
|
+
const totalWeeks = phases.reduce((sum, phase) => {
|
|
761
|
+
const durationParts = phase.duration.split(' ');
|
|
762
|
+
const weeksStr = durationParts[0];
|
|
763
|
+
const weeks = weeksStr ? Number.parseInt(weeksStr) : 0;
|
|
764
|
+
return sum + weeks;
|
|
765
|
+
}, 0);
|
|
766
|
+
return {
|
|
767
|
+
phases,
|
|
768
|
+
totalDuration: `${totalWeeks} weeks`,
|
|
769
|
+
milestones: [
|
|
770
|
+
'Planning complete',
|
|
771
|
+
'50% implementation done',
|
|
772
|
+
'All features migrated',
|
|
773
|
+
'Testing complete',
|
|
774
|
+
'Production deployment',
|
|
775
|
+
],
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Generate reasoning for strategy selection.
|
|
780
|
+
*/
|
|
781
|
+
generateReasoning(strategy, violations, constraints) {
|
|
782
|
+
const primaryFactors = [
|
|
783
|
+
`Strategy addresses ${violations.length} architectural violations`,
|
|
784
|
+
`Success rate: ${(strategy.successRate * 100).toFixed(0)}%`,
|
|
785
|
+
`Complexity level: ${strategy.complexity}`,
|
|
786
|
+
];
|
|
787
|
+
const constraintImpact = [];
|
|
788
|
+
if (constraints?.timeline) {
|
|
789
|
+
constraintImpact.push(`Timeline preference: ${constraints.timeline}`);
|
|
790
|
+
}
|
|
791
|
+
if (constraints?.riskTolerance) {
|
|
792
|
+
constraintImpact.push(`Risk tolerance: ${constraints.riskTolerance}`);
|
|
793
|
+
}
|
|
794
|
+
const riskAssessment = `Overall risk: ${strategy.overallRisk} (based on ${strategy.risks.join(', ')})`;
|
|
795
|
+
return {
|
|
796
|
+
primaryFactors,
|
|
797
|
+
constraintImpact,
|
|
798
|
+
riskAssessment,
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Generate success metrics.
|
|
803
|
+
*/
|
|
804
|
+
generateSuccessMetrics(strategy) {
|
|
805
|
+
const baseMetrics = [
|
|
806
|
+
'Reduction in architectural violations',
|
|
807
|
+
'Improved code maintainability',
|
|
808
|
+
'Faster development cycles',
|
|
809
|
+
'Reduced bug rates',
|
|
810
|
+
];
|
|
811
|
+
if (strategy.id.includes('dependency')) {
|
|
812
|
+
baseMetrics.push('Better testability through dependency injection');
|
|
813
|
+
}
|
|
814
|
+
if (strategy.id.includes('interface')) {
|
|
815
|
+
baseMetrics.push('Improved API design and client satisfaction');
|
|
816
|
+
}
|
|
817
|
+
if (strategy.id.includes('clean')) {
|
|
818
|
+
baseMetrics.push('Enhanced long-term maintainability');
|
|
819
|
+
}
|
|
820
|
+
if (strategy.id.includes('standalone')) {
|
|
821
|
+
baseMetrics.push('Simplified Angular module system');
|
|
822
|
+
}
|
|
823
|
+
return baseMetrics;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
//# sourceMappingURL=plan-migration.js.map
|