@angular-modernizer/adapter-mcp 1.0.0 → 1.1.0
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/README.md +78 -64
- package/dist/cli.js +8 -0
- package/dist/core/project-analyzer.d.ts +3 -12
- package/dist/core/project-analyzer.js +3 -12
- package/dist/index.d.ts +118 -3
- package/dist/index.js +46 -3
- package/dist/mcp-watcher.d.ts +28 -8
- package/dist/mcp-watcher.js +7 -7
- package/dist/scan-host/scan-host.d.ts +119 -0
- package/dist/scan-host/scan-host.js +376 -0
- package/dist/scan-host/scan-protocol.d.ts +35 -0
- package/dist/scan-host/scan-protocol.js +6 -0
- package/dist/scan-host/scan-worker.d.ts +14 -0
- package/dist/scan-host/scan-worker.js +48 -0
- package/dist/server/limited-stdio-transport.d.ts +7 -0
- package/dist/server/mcp-server.d.ts +11 -7
- package/dist/server/mcp-server.js +4 -7
- package/dist/server/sdk-server.d.ts +1 -0
- package/dist/server/tool-registry.d.ts +3 -7
- package/dist/server/tool-registry.js +1 -7
- package/dist/streaming/progress-store.d.ts +22 -5
- package/dist/streaming/progress-store.js +9 -5
- package/dist/tools/analyze-build-impact.d.ts +56 -34
- package/dist/tools/analyze-build-impact.js +30 -25
- package/dist/tools/analyze-core-to-shared.d.ts +42 -12
- package/dist/tools/analyze-core-to-shared.js +11 -10
- package/dist/tools/analyze-parser-performance.d.ts +23 -22
- package/dist/tools/analyze-parser-performance.js +20 -18
- package/dist/tools/analyze-project.d.ts +82 -12
- package/dist/tools/analyze-project.js +98 -101
- package/dist/tools/check-incremental-compatibility.d.ts +13 -11
- package/dist/tools/check-incremental-compatibility.js +11 -8
- package/dist/tools/collect-feedback.d.ts +41 -26
- package/dist/tools/collect-feedback.js +32 -23
- package/dist/tools/compare-health.d.ts +76 -19
- package/dist/tools/compare-health.js +26 -19
- package/dist/tools/extract-libraries.d.ts +44 -20
- package/dist/tools/extract-libraries.js +16 -17
- package/dist/tools/find-angular-symbol.d.ts +25 -23
- package/dist/tools/find-angular-symbol.js +17 -14
- package/dist/tools/find-component-hosts.d.ts +31 -25
- package/dist/tools/find-component-hosts.js +24 -21
- package/dist/tools/find-usages.d.ts +23 -21
- package/dist/tools/find-usages.js +19 -16
- package/dist/tools/get-bootstrap-execution.d.ts +33 -25
- package/dist/tools/get-bootstrap-execution.js +25 -22
- package/dist/tools/get-call-graph.d.ts +18 -13
- package/dist/tools/get-call-graph.js +24 -21
- package/dist/tools/get-operation-progress-tool.d.ts +12 -6
- package/dist/tools/get-operation-progress-tool.js +11 -6
- package/dist/tools/get-operation-progress.d.ts +26 -0
- package/dist/tools/helpers/analysis-output.d.ts +5 -0
- package/dist/tools/helpers/batch-kernel.d.ts +14 -0
- package/dist/tools/helpers/batch-kernel.js +12 -0
- package/dist/tools/helpers/compact-output.d.ts +2 -1
- package/dist/tools/helpers/compact-output.js +2 -1
- package/dist/tools/helpers/health-delta.d.ts +27 -14
- package/dist/tools/helpers/health-delta.js +11 -14
- package/dist/tools/helpers/project-cache.d.ts +50 -34
- package/dist/tools/helpers/project-cache.js +33 -34
- package/dist/tools/helpers/rule-runner.d.ts +23 -16
- package/dist/tools/helpers/rule-runner.js +24 -17
- package/dist/tools/helpers/scan-engine.d.ts +107 -0
- package/dist/tools/helpers/scan-engine.js +197 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
- package/dist/tools/helpers/suggestion-generator.js +0 -12
- package/dist/tools/helpers/tool-cache.d.ts +11 -0
- package/dist/tools/helpers/tool-cache.js +15 -0
- package/dist/tools/helpers/tool-context.d.ts +11 -8
- package/dist/tools/helpers/tool-context.js +5 -8
- package/dist/tools/inspect-form-group.d.ts +32 -25
- package/dist/tools/inspect-form-group.js +24 -21
- package/dist/tools/inspect-i18n.d.ts +28 -22
- package/dist/tools/inspect-i18n.js +20 -17
- package/dist/tools/inspect-template.d.ts +31 -24
- package/dist/tools/inspect-template.js +23 -20
- package/dist/tools/learn-patterns.d.ts +88 -12
- package/dist/tools/learn-patterns.js +17 -11
- package/dist/tools/list-imports.d.ts +42 -25
- package/dist/tools/list-imports.js +23 -20
- package/dist/tools/orchestrate-migration.d.ts +31 -9
- package/dist/tools/orchestrate-migration.js +12 -7
- package/dist/tools/parse-stack-trace.d.ts +23 -21
- package/dist/tools/parse-stack-trace.js +10 -7
- package/dist/tools/plan-migration.d.ts +65 -25
- package/dist/tools/plan-migration.js +19 -19
- package/dist/tools/resolve-type.d.ts +19 -9
- package/dist/tools/resolve-type.js +19 -11
- package/dist/tools/review-feedback.d.ts +27 -24
- package/dist/tools/review-feedback.js +24 -20
- package/dist/tools/rollback-changes.d.ts +13 -9
- package/dist/tools/rollback-changes.js +10 -7
- package/dist/tools/run-angular-cli.d.ts +12 -10
- package/dist/tools/run-angular-cli.js +11 -8
- package/dist/tools/run-build.d.ts +13 -11
- package/dist/tools/run-build.js +11 -8
- package/dist/tools/run-schematic.d.ts +12 -10
- package/dist/tools/run-schematic.js +11 -8
- package/dist/tools/scan-all.d.ts +69 -12
- package/dist/tools/scan-all.js +55 -122
- package/dist/tools/scan-angular.d.ts +41 -9
- package/dist/tools/scan-angular.js +66 -135
- package/dist/tools/scan-architecture.d.ts +75 -14
- package/dist/tools/scan-architecture.js +180 -185
- package/dist/tools/scan-solid.d.ts +40 -9
- package/dist/tools/scan-solid.js +64 -133
- package/dist/tools/search-codebase.d.ts +30 -24
- package/dist/tools/search-codebase.js +13 -10
- package/dist/tools/server-status.d.ts +116 -24
- package/dist/tools/server-status.js +85 -26
- package/dist/tools/suggest-improvements.d.ts +22 -19
- package/dist/tools/suggest-improvements.js +21 -17
- package/dist/tools/trace-output-flow.d.ts +32 -25
- package/dist/tools/trace-output-flow.js +24 -21
- package/dist/tools/transform-code.d.ts +71 -10
- package/dist/tools/transform-code.js +60 -42
- package/dist/tools/validate-before-transform.d.ts +24 -9
- package/dist/tools/validate-before-transform.js +10 -7
- package/dist/tools/validate-project-compatibility.d.ts +18 -13
- package/dist/tools/validate-project-compatibility.js +17 -11
- package/dist/tools/validate-transformation.d.ts +28 -11
- package/dist/tools/validate-transformation.js +14 -8
- package/dist/tools/verify-citations.d.ts +37 -16
- package/dist/tools/verify-citations.js +19 -16
- package/dist/types.d.ts +40 -10
- package/dist/types.js +0 -5
- package/package.json +12 -18
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.js +0 -7
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Transform Code Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for performing surgical code transformations to fix
|
|
5
|
-
* architectural issues, including standalone component migration.
|
|
6
|
-
*/
|
|
7
1
|
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
8
2
|
/**
|
|
9
3
|
* Plugin config of a transformation: the plugins read `transformationType`
|
|
@@ -13,7 +7,7 @@ export declare function pluginConfigFor(transformation: string | undefined, opti
|
|
|
13
7
|
/**
|
|
14
8
|
* Transformation result.
|
|
15
9
|
*/
|
|
16
|
-
interface TransformationResult {
|
|
10
|
+
export interface TransformationResult {
|
|
17
11
|
/**
|
|
18
12
|
* Operation ID for streaming mode (when streaming=true).
|
|
19
13
|
*/
|
|
@@ -30,8 +24,11 @@ interface TransformationResult {
|
|
|
30
24
|
* Batch transformation results (batch mode).
|
|
31
25
|
*/
|
|
32
26
|
files?: {
|
|
27
|
+
/** File path. */
|
|
33
28
|
path: string;
|
|
29
|
+
/** Whether the file was transformed. */
|
|
34
30
|
success: boolean;
|
|
31
|
+
/** Error message of a failed file. */
|
|
35
32
|
error?: string;
|
|
36
33
|
}[];
|
|
37
34
|
/**
|
|
@@ -42,21 +39,32 @@ interface TransformationResult {
|
|
|
42
39
|
* Summary of changes made.
|
|
43
40
|
*/
|
|
44
41
|
changes: {
|
|
42
|
+
/** Changed lines. */
|
|
45
43
|
linesChanged: number;
|
|
44
|
+
/** Added lines. */
|
|
46
45
|
additions: number;
|
|
46
|
+
/** Removed lines. */
|
|
47
47
|
deletions: number;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* Pre-validation results (if performed).
|
|
51
51
|
*/
|
|
52
52
|
preValidation?: {
|
|
53
|
+
/** `true` when the file may be transformed. */
|
|
53
54
|
valid: boolean;
|
|
55
|
+
/** Issues found by the pre-transformation validator. */
|
|
54
56
|
issues: {
|
|
57
|
+
/** Validation type. */
|
|
55
58
|
type: string;
|
|
59
|
+
/** Issue severity. */
|
|
56
60
|
severity: string;
|
|
61
|
+
/** Issue message. */
|
|
57
62
|
message: string;
|
|
63
|
+
/** File of the issue. */
|
|
58
64
|
filePath?: string;
|
|
65
|
+
/** Line of the issue. */
|
|
59
66
|
line?: number;
|
|
67
|
+
/** Column of the issue. */
|
|
60
68
|
column?: number;
|
|
61
69
|
}[];
|
|
62
70
|
};
|
|
@@ -64,8 +72,11 @@ interface TransformationResult {
|
|
|
64
72
|
* Validation results.
|
|
65
73
|
*/
|
|
66
74
|
validation: {
|
|
75
|
+
/** `true` when the transformation introduced no syntax error. */
|
|
67
76
|
syntaxValid: boolean;
|
|
77
|
+
/** `true` when the transformation introduced no type error. */
|
|
68
78
|
typeCheckPassed: boolean;
|
|
79
|
+
/** Test outcome, when tests ran. */
|
|
69
80
|
testsPass?: boolean;
|
|
70
81
|
/**
|
|
71
82
|
* Type errors the transformation introduced into the file.
|
|
@@ -76,8 +87,11 @@ interface TransformationResult {
|
|
|
76
87
|
* Backup information (if backup was created).
|
|
77
88
|
*/
|
|
78
89
|
backup?: {
|
|
90
|
+
/** `true` when a backup was written. */
|
|
79
91
|
created: boolean;
|
|
92
|
+
/** Path of the backup copy. */
|
|
80
93
|
backupPath?: string;
|
|
94
|
+
/** Backup strategy. */
|
|
81
95
|
strategy: 'git-stash' | 'file-backup';
|
|
82
96
|
/**
|
|
83
97
|
* Git snapshot commit recorded with the backup (inside a git repository).
|
|
@@ -88,8 +102,11 @@ interface TransformationResult {
|
|
|
88
102
|
* Rollback information (if rollback was performed).
|
|
89
103
|
*/
|
|
90
104
|
rollback?: {
|
|
105
|
+
/** `true` when the backup was restored. */
|
|
91
106
|
performed: boolean;
|
|
107
|
+
/** Why the rollback ran. */
|
|
92
108
|
reason?: string;
|
|
109
|
+
/** `true` when the restore succeeded. */
|
|
93
110
|
success?: boolean;
|
|
94
111
|
};
|
|
95
112
|
/**
|
|
@@ -97,25 +114,37 @@ interface TransformationResult {
|
|
|
97
114
|
*/
|
|
98
115
|
warnings?: string[];
|
|
99
116
|
/**
|
|
100
|
-
* Orchestration metrics
|
|
117
|
+
* Orchestration metrics.
|
|
101
118
|
*/
|
|
102
119
|
orchestration?: {
|
|
120
|
+
/** Files were transformed in parallel. */
|
|
103
121
|
parallel: boolean;
|
|
122
|
+
/** Batch mode (`files`) was used. */
|
|
104
123
|
batchMode: boolean;
|
|
124
|
+
/** Files processed. */
|
|
105
125
|
filesProcessed: number;
|
|
126
|
+
/** Files transformed successfully. */
|
|
106
127
|
filesSucceeded: number;
|
|
128
|
+
/** Files that failed. */
|
|
107
129
|
filesFailed: number;
|
|
130
|
+
/** Duration in milliseconds. */
|
|
108
131
|
duration: number;
|
|
132
|
+
/** Files per second. */
|
|
109
133
|
throughput: number;
|
|
110
134
|
};
|
|
111
135
|
/**
|
|
112
136
|
* Progress state (if enableProgress was true).
|
|
113
137
|
*/
|
|
114
138
|
progress?: {
|
|
139
|
+
/** Processed items. */
|
|
115
140
|
current: number;
|
|
141
|
+
/** Items in total. */
|
|
116
142
|
total: number;
|
|
143
|
+
/** Progress in percent. */
|
|
117
144
|
percentage: number;
|
|
145
|
+
/** Estimated time to completion. */
|
|
118
146
|
eta: number;
|
|
147
|
+
/** Current step. */
|
|
119
148
|
phase: string;
|
|
120
149
|
};
|
|
121
150
|
/**
|
|
@@ -128,9 +157,13 @@ interface TransformationResult {
|
|
|
128
157
|
*/
|
|
129
158
|
intermediateResults?: {
|
|
130
159
|
[stageName: string]: {
|
|
160
|
+
/** Whether the stage succeeded. */
|
|
131
161
|
success: boolean;
|
|
162
|
+
/** Violations found by the stage. */
|
|
132
163
|
violations?: number;
|
|
164
|
+
/** Files processed by the stage. */
|
|
133
165
|
filesProcessed?: number;
|
|
166
|
+
/** Stage message. */
|
|
134
167
|
message?: string;
|
|
135
168
|
};
|
|
136
169
|
};
|
|
@@ -138,14 +171,23 @@ interface TransformationResult {
|
|
|
138
171
|
* Build validation result (if buildCheck or validateBuild was enabled).
|
|
139
172
|
*/
|
|
140
173
|
buildValidation?: {
|
|
174
|
+
/** `true` when the build reported no error. */
|
|
141
175
|
passed: boolean;
|
|
176
|
+
/** Same as `passed`. */
|
|
142
177
|
success: boolean;
|
|
178
|
+
/** Exit code of the build. */
|
|
143
179
|
exitCode?: number;
|
|
180
|
+
/** Build errors. */
|
|
144
181
|
errors?: string[];
|
|
182
|
+
/** Build warnings. */
|
|
145
183
|
warnings?: string[];
|
|
184
|
+
/** Build duration in milliseconds. */
|
|
146
185
|
duration?: number;
|
|
186
|
+
/** Build command that ran. */
|
|
147
187
|
buildCommand?: string;
|
|
188
|
+
/** Detected build system. */
|
|
148
189
|
buildSystem?: string;
|
|
190
|
+
/** `true` when the build hit its timeout. */
|
|
149
191
|
timedOut?: boolean;
|
|
150
192
|
};
|
|
151
193
|
/**
|
|
@@ -165,11 +207,27 @@ interface TransformationResult {
|
|
|
165
207
|
*/
|
|
166
208
|
summary: string;
|
|
167
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* MCP tool `transform-code`: applies one of the transformation types to a
|
|
212
|
+
* file (or, with `files`, to a batch) to fix architectural issues, including
|
|
213
|
+
* standalone component migration.
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* Runs inside a safety envelope: pre-validation, a backup in the project
|
|
217
|
+
* (file copy plus git snapshot inside a repository) that rollback-changes can
|
|
218
|
+
* restore, a type check of the transformed file that rolls back on newly
|
|
219
|
+
* introduced errors (`autoRollback`, default true), and an optional build or
|
|
220
|
+
* lint check. A cancelled call restores the backup.
|
|
221
|
+
*/
|
|
168
222
|
export declare class TransformCodeTool implements MCPTool {
|
|
169
223
|
name: string;
|
|
170
224
|
title: string;
|
|
171
225
|
annotations: ToolAnnotations;
|
|
172
226
|
description: string;
|
|
227
|
+
/**
|
|
228
|
+
* JSON Schema of the tool arguments.
|
|
229
|
+
* @hidden
|
|
230
|
+
*/
|
|
173
231
|
inputSchema: {
|
|
174
232
|
type: string;
|
|
175
233
|
additionalProperties: boolean;
|
|
@@ -327,6 +385,10 @@ export declare class TransformCodeTool implements MCPTool {
|
|
|
327
385
|
};
|
|
328
386
|
required: string[];
|
|
329
387
|
};
|
|
388
|
+
/**
|
|
389
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
390
|
+
* @hidden
|
|
391
|
+
*/
|
|
330
392
|
outputSchema: {
|
|
331
393
|
type: string;
|
|
332
394
|
properties: {
|
|
@@ -643,7 +705,7 @@ export declare class TransformCodeTool implements MCPTool {
|
|
|
643
705
|
*/
|
|
644
706
|
private executeStreaming;
|
|
645
707
|
/**
|
|
646
|
-
* Execute batch transformation
|
|
708
|
+
* Execute batch transformation.
|
|
647
709
|
*/
|
|
648
710
|
private executeBatch;
|
|
649
711
|
/**
|
|
@@ -671,5 +733,4 @@ export declare class TransformCodeTool implements MCPTool {
|
|
|
671
733
|
*/
|
|
672
734
|
private validateTransformationType;
|
|
673
735
|
}
|
|
674
|
-
export {};
|
|
675
736
|
//# sourceMappingURL=transform-code.d.ts.map
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Transform Code Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for performing surgical code transformations to fix
|
|
5
|
-
* architectural issues, including standalone component migration.
|
|
6
|
-
*/
|
|
7
1
|
import { yieldIfCancellable } from './helpers/tool-context.js';
|
|
8
2
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
3
|
+
import { createBatchKernel } from './helpers/batch-kernel.js';
|
|
9
4
|
import { Kernel, FluentKernel, PreTransformValidator, PostTransformValidator, ValidationSeverity, ValidationType, loadConfig, } from '@angular-modernizer/core';
|
|
10
5
|
import { AngularPlugin } from '@angular-modernizer/plugin-angular';
|
|
11
6
|
import { readFileSync } from 'node:fs';
|
|
@@ -127,6 +122,40 @@ function describeTransformation(result) {
|
|
|
127
122
|
/**
|
|
128
123
|
* MCP tool for code transformations.
|
|
129
124
|
*/
|
|
125
|
+
/** Loads the kernel a batch shares: the project's tsconfig program with the Angular plugin. */
|
|
126
|
+
async function loadBatchKernel(projectRoot) {
|
|
127
|
+
const tsConfigPath = findTsConfig(projectRoot);
|
|
128
|
+
if (!tsConfigPath) {
|
|
129
|
+
throw new Error('Could not find tsconfig.json');
|
|
130
|
+
}
|
|
131
|
+
const kernel = new Kernel({
|
|
132
|
+
tsConfigPath,
|
|
133
|
+
plugins: [new AngularPlugin()],
|
|
134
|
+
});
|
|
135
|
+
await kernel.initialize();
|
|
136
|
+
return kernel;
|
|
137
|
+
}
|
|
138
|
+
/** Transforms one batch file on the shared kernel and saves it. */
|
|
139
|
+
async function transformWithKernel(kernel, filePath, params) {
|
|
140
|
+
const project = kernel.getProject();
|
|
141
|
+
const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPath(filePath);
|
|
142
|
+
const linesBefore = sourceFile.getFullText().split('\n').length;
|
|
143
|
+
const result = (await kernel.transformFile(sourceFile, {
|
|
144
|
+
dryRun: false,
|
|
145
|
+
autoSave: true,
|
|
146
|
+
pluginConfig: pluginConfigFor(params.transformation, params.options),
|
|
147
|
+
}));
|
|
148
|
+
await sourceFile.save();
|
|
149
|
+
const linesAfter = sourceFile.getFullText().split('\n').length;
|
|
150
|
+
return {
|
|
151
|
+
success: result.success,
|
|
152
|
+
changes: {
|
|
153
|
+
linesChanged: result.ruleResults.reduce((sum, r) => sum + (r.changeCount ?? 0), 0),
|
|
154
|
+
additions: Math.max(0, linesAfter - linesBefore),
|
|
155
|
+
deletions: Math.max(0, linesBefore - linesAfter),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
130
159
|
/**
|
|
131
160
|
* Files a batch restores after a failure: all-or-nothing every file,
|
|
132
161
|
* selective only the failed ones, none nothing.
|
|
@@ -147,6 +176,18 @@ class TransformCancelledError extends Error {
|
|
|
147
176
|
super('Transformation cancelled by the client');
|
|
148
177
|
}
|
|
149
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* MCP tool `transform-code`: applies one of the transformation types to a
|
|
181
|
+
* file (or, with `files`, to a batch) to fix architectural issues, including
|
|
182
|
+
* standalone component migration.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* Runs inside a safety envelope: pre-validation, a backup in the project
|
|
186
|
+
* (file copy plus git snapshot inside a repository) that rollback-changes can
|
|
187
|
+
* restore, a type check of the transformed file that rolls back on newly
|
|
188
|
+
* introduced errors (`autoRollback`, default true), and an optional build or
|
|
189
|
+
* lint check. A cancelled call restores the backup.
|
|
190
|
+
*/
|
|
150
191
|
export class TransformCodeTool {
|
|
151
192
|
name = 'transform-code';
|
|
152
193
|
title = 'Transform Code';
|
|
@@ -158,6 +199,10 @@ export class TransformCodeTool {
|
|
|
158
199
|
};
|
|
159
200
|
description = 'Apply surgical code transformations to fix architectural issues. ' +
|
|
160
201
|
'summary is a short text with the outcome, the changes, the type check, backup and rollback.';
|
|
202
|
+
/**
|
|
203
|
+
* JSON Schema of the tool arguments.
|
|
204
|
+
* @hidden
|
|
205
|
+
*/
|
|
161
206
|
inputSchema = {
|
|
162
207
|
type: 'object',
|
|
163
208
|
additionalProperties: false,
|
|
@@ -338,6 +383,10 @@ export class TransformCodeTool {
|
|
|
338
383
|
},
|
|
339
384
|
required: ['transformation'],
|
|
340
385
|
};
|
|
386
|
+
/**
|
|
387
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
388
|
+
* @hidden
|
|
389
|
+
*/
|
|
341
390
|
outputSchema = {
|
|
342
391
|
type: 'object',
|
|
343
392
|
properties: {
|
|
@@ -889,7 +938,7 @@ export class TransformCodeTool {
|
|
|
889
938
|
};
|
|
890
939
|
}
|
|
891
940
|
/**
|
|
892
|
-
* Execute batch transformation
|
|
941
|
+
* Execute batch transformation.
|
|
893
942
|
*/
|
|
894
943
|
async executeBatch(params, orchestration, ctx) {
|
|
895
944
|
if (!params.files || params.files.length === 0) {
|
|
@@ -955,8 +1004,9 @@ export class TransformCodeTool {
|
|
|
955
1004
|
gitSnapshot: backupResult.metadata?.gitStashRef,
|
|
956
1005
|
};
|
|
957
1006
|
}
|
|
1007
|
+
const batchKernel = createBatchKernel(() => loadBatchKernel(projectRoot));
|
|
958
1008
|
const result = await executeBatchTransformation(batchOptions, async (filePath) => {
|
|
959
|
-
return this.transformSingleFile(filePath, params,
|
|
1009
|
+
return this.transformSingleFile(filePath, params, batchKernel);
|
|
960
1010
|
});
|
|
961
1011
|
const failedFiles = result.files
|
|
962
1012
|
.filter((f) => !f.success)
|
|
@@ -1006,41 +1056,9 @@ export class TransformCodeTool {
|
|
|
1006
1056
|
/**
|
|
1007
1057
|
* Transform a single file (internal helper for batch mode).
|
|
1008
1058
|
*/
|
|
1009
|
-
async transformSingleFile(filePath, params,
|
|
1059
|
+
async transformSingleFile(filePath, params, batchKernel) {
|
|
1010
1060
|
try {
|
|
1011
|
-
|
|
1012
|
-
if (!tsConfigPath) {
|
|
1013
|
-
return {
|
|
1014
|
-
success: false,
|
|
1015
|
-
error: 'Could not find tsconfig.json',
|
|
1016
|
-
changes: { linesChanged: 0, additions: 0, deletions: 0 },
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
const kernel = new Kernel({
|
|
1020
|
-
tsConfigPath,
|
|
1021
|
-
plugins: [new AngularPlugin()],
|
|
1022
|
-
});
|
|
1023
|
-
await kernel.initialize();
|
|
1024
|
-
const project = kernel.getProject();
|
|
1025
|
-
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
1026
|
-
const linesBefore = sourceFile.getFullText().split('\n').length;
|
|
1027
|
-
const transformConfig = {
|
|
1028
|
-
dryRun: false,
|
|
1029
|
-
autoSave: true,
|
|
1030
|
-
pluginConfig: pluginConfigFor(params.transformation, params.options),
|
|
1031
|
-
};
|
|
1032
|
-
const result = (await kernel.transformFile(sourceFile, transformConfig));
|
|
1033
|
-
if (!transformConfig.dryRun && transformConfig.autoSave) {
|
|
1034
|
-
await sourceFile.save();
|
|
1035
|
-
}
|
|
1036
|
-
const linesAfter = sourceFile.getFullText().split('\n').length;
|
|
1037
|
-
const additions = Math.max(0, linesAfter - linesBefore);
|
|
1038
|
-
const deletions = Math.max(0, linesBefore - linesAfter);
|
|
1039
|
-
const linesChanged = result.ruleResults.reduce((sum, r) => sum + (r.changeCount ?? 0), 0);
|
|
1040
|
-
return {
|
|
1041
|
-
success: result.success,
|
|
1042
|
-
changes: { linesChanged, additions, deletions },
|
|
1043
|
-
};
|
|
1061
|
+
return await batchKernel.run((kernel) => transformWithKernel(kernel, filePath, params));
|
|
1044
1062
|
}
|
|
1045
1063
|
catch (error) {
|
|
1046
1064
|
return {
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Validate Before Transform Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for validating code BEFORE transformation to ensure it's safe
|
|
5
|
-
* to modify. Performs syntax, dependency, type, and schema validation.
|
|
6
|
-
*/
|
|
7
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
8
2
|
/**
|
|
9
3
|
* Validation result.
|
|
10
4
|
*/
|
|
11
|
-
interface ValidationResult {
|
|
5
|
+
export interface ValidationResult {
|
|
12
6
|
/**
|
|
13
7
|
* Whether validation passed (no errors).
|
|
14
8
|
*/
|
|
@@ -17,12 +11,19 @@ interface ValidationResult {
|
|
|
17
11
|
* Validation issues found.
|
|
18
12
|
*/
|
|
19
13
|
issues: {
|
|
14
|
+
/** Check that reported the issue. */
|
|
20
15
|
type: 'syntax' | 'dependency' | 'type' | 'schema';
|
|
16
|
+
/** Severity; only errors make the file not valid. */
|
|
21
17
|
severity: 'error' | 'warning' | 'info';
|
|
18
|
+
/** Issue description. */
|
|
22
19
|
message: string;
|
|
20
|
+
/** File the issue was found in. */
|
|
23
21
|
filePath?: string;
|
|
22
|
+
/** Line of the issue (1-based). */
|
|
24
23
|
line?: number;
|
|
24
|
+
/** Column of the issue. */
|
|
25
25
|
column?: number;
|
|
26
|
+
/** Additional details of the issue. */
|
|
26
27
|
details?: string;
|
|
27
28
|
}[];
|
|
28
29
|
/**
|
|
@@ -33,11 +34,17 @@ interface ValidationResult {
|
|
|
33
34
|
* Metadata about validation.
|
|
34
35
|
*/
|
|
35
36
|
metadata: {
|
|
37
|
+
/** Validated file. */
|
|
36
38
|
filePath: string;
|
|
39
|
+
/** Whether syntax validation ran. */
|
|
37
40
|
syntaxValidation: boolean;
|
|
41
|
+
/** Whether dependency validation ran. */
|
|
38
42
|
dependencyValidation: boolean;
|
|
43
|
+
/** Whether type validation ran. */
|
|
39
44
|
typeValidation: boolean;
|
|
45
|
+
/** Whether schema validation ran. */
|
|
40
46
|
schemaValidation: boolean;
|
|
47
|
+
/** Schema used for schema validation. */
|
|
41
48
|
schema?: Record<string, unknown>;
|
|
42
49
|
};
|
|
43
50
|
/**
|
|
@@ -46,13 +53,18 @@ interface ValidationResult {
|
|
|
46
53
|
summary: string;
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
|
-
* MCP tool for
|
|
56
|
+
* MCP tool for validating code before a transformation to make sure it is
|
|
57
|
+
* safe to modify. Performs syntax, dependency, type, and schema validation.
|
|
50
58
|
*/
|
|
51
59
|
export declare class ValidateBeforeTransformTool implements MCPTool {
|
|
52
60
|
name: string;
|
|
53
61
|
title: string;
|
|
54
62
|
annotations: ToolAnnotations;
|
|
55
63
|
description: string;
|
|
64
|
+
/**
|
|
65
|
+
* JSON Schema of the tool arguments.
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
56
68
|
inputSchema: {
|
|
57
69
|
type: string;
|
|
58
70
|
additionalProperties: boolean;
|
|
@@ -88,6 +100,10 @@ export declare class ValidateBeforeTransformTool implements MCPTool {
|
|
|
88
100
|
};
|
|
89
101
|
required: string[];
|
|
90
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
105
|
+
* @hidden
|
|
106
|
+
*/
|
|
91
107
|
outputSchema: {
|
|
92
108
|
type: string;
|
|
93
109
|
properties: {
|
|
@@ -164,5 +180,4 @@ export declare class ValidateBeforeTransformTool implements MCPTool {
|
|
|
164
180
|
*/
|
|
165
181
|
private findProjectRoot;
|
|
166
182
|
}
|
|
167
|
-
export {};
|
|
168
183
|
//# sourceMappingURL=validate-before-transform.d.ts.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Validate Before Transform Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for validating code BEFORE transformation to ensure it's safe
|
|
5
|
-
* to modify. Performs syntax, dependency, type, and schema validation.
|
|
6
|
-
*/
|
|
7
1
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
8
2
|
import { PreTransformValidator, Kernel, } from '@angular-modernizer/core';
|
|
9
3
|
import { AngularPlugin } from '@angular-modernizer/plugin-angular';
|
|
@@ -26,7 +20,8 @@ function describeValidation(result) {
|
|
|
26
20
|
].join('\n');
|
|
27
21
|
}
|
|
28
22
|
/**
|
|
29
|
-
* MCP tool for
|
|
23
|
+
* MCP tool for validating code before a transformation to make sure it is
|
|
24
|
+
* safe to modify. Performs syntax, dependency, type, and schema validation.
|
|
30
25
|
*/
|
|
31
26
|
export class ValidateBeforeTransformTool {
|
|
32
27
|
name = 'validate-before-transform';
|
|
@@ -39,6 +34,10 @@ export class ValidateBeforeTransformTool {
|
|
|
39
34
|
};
|
|
40
35
|
description = 'Validate code before transformation to ensure it is safe to modify. Performs syntax, dependency, type, and schema validation. ' +
|
|
41
36
|
'summary is a short text with the verdict, the issue counts and the first issues.';
|
|
37
|
+
/**
|
|
38
|
+
* JSON Schema of the tool arguments.
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
42
41
|
inputSchema = {
|
|
43
42
|
type: 'object',
|
|
44
43
|
additionalProperties: false,
|
|
@@ -74,6 +73,10 @@ export class ValidateBeforeTransformTool {
|
|
|
74
73
|
},
|
|
75
74
|
required: ['filePath'],
|
|
76
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
77
80
|
outputSchema = {
|
|
78
81
|
type: 'object',
|
|
79
82
|
properties: {
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Validate Project Compatibility Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for validating project compatibility with the parser before running transformations.
|
|
5
|
-
* Detects incompatibility patterns such as external decorators, path aliases, and complex constructor
|
|
6
|
-
* patterns that may cause parsing issues. Provides actionable recommendations for parser selection.
|
|
7
|
-
*/
|
|
8
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
9
2
|
import { type CompatibilityCheck, type ProjectType, type OverallCompatibility, type RecommendedParser } from '@angular-modernizer/core';
|
|
10
3
|
/**
|
|
11
4
|
* Output result of project compatibility validation.
|
|
12
5
|
*/
|
|
13
|
-
interface ValidateProjectCompatibilityOutput {
|
|
6
|
+
export interface ValidateProjectCompatibilityOutput {
|
|
14
7
|
/**
|
|
15
8
|
* Project type classification.
|
|
16
9
|
*/
|
|
@@ -49,23 +42,32 @@ interface ValidateProjectCompatibilityOutput {
|
|
|
49
42
|
summary: string;
|
|
50
43
|
}
|
|
51
44
|
/**
|
|
52
|
-
* MCP tool for validating project compatibility with the parser
|
|
45
|
+
* MCP tool for validating project compatibility with the parser before
|
|
46
|
+
* running transformations. Detects incompatibility patterns such as external
|
|
47
|
+
* decorators, path aliases and complex constructor patterns that may cause
|
|
48
|
+
* parsing issues, and recommends a parser strategy.
|
|
53
49
|
*
|
|
54
|
-
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Checks:
|
|
55
52
|
* - Detects custom decorators (any decorator outside the known frameworks)
|
|
56
53
|
* - Detects path aliases (@shared/, @domain/, @features/, @core/, @lib/)
|
|
57
54
|
* - Detects complex constructor patterns (importService variables, public params)
|
|
58
55
|
* - Runs sample transformation test to verify actual compatibility
|
|
59
56
|
* - Classifies project type and recommends parser strategy
|
|
60
57
|
*
|
|
61
|
-
*
|
|
62
|
-
* Completes validation in
|
|
58
|
+
* Avoids running transformations that would fail due to parser
|
|
59
|
+
* incompatibilities. Completes validation in under 5 seconds for typical
|
|
60
|
+
* projects.
|
|
63
61
|
*/
|
|
64
62
|
export declare class ValidateProjectCompatibilityTool implements MCPTool {
|
|
65
63
|
name: string;
|
|
66
64
|
title: string;
|
|
67
65
|
annotations: ToolAnnotations;
|
|
68
66
|
description: string;
|
|
67
|
+
/**
|
|
68
|
+
* JSON Schema of the tool arguments.
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
69
71
|
inputSchema: {
|
|
70
72
|
type: string;
|
|
71
73
|
additionalProperties: boolean;
|
|
@@ -96,6 +98,10 @@ export declare class ValidateProjectCompatibilityTool implements MCPTool {
|
|
|
96
98
|
};
|
|
97
99
|
required: string[];
|
|
98
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
99
105
|
outputSchema: {
|
|
100
106
|
type: string;
|
|
101
107
|
properties: {
|
|
@@ -177,5 +183,4 @@ export declare class ValidateProjectCompatibilityTool implements MCPTool {
|
|
|
177
183
|
*/
|
|
178
184
|
private getOverallRecommendation;
|
|
179
185
|
}
|
|
180
|
-
export {};
|
|
181
186
|
//# sourceMappingURL=validate-project-compatibility.d.ts.map
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Validate Project Compatibility Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for validating project compatibility with the parser before running transformations.
|
|
5
|
-
* Detects incompatibility patterns such as external decorators, path aliases, and complex constructor
|
|
6
|
-
* patterns that may cause parsing issues. Provides actionable recommendations for parser selection.
|
|
7
|
-
*/
|
|
8
1
|
import { ProjectCompatibilityValidator, } from '@angular-modernizer/core';
|
|
9
2
|
import { existsSync } from 'node:fs';
|
|
10
3
|
/** Text summary: verdict, parser, success rate, sample size and one line per failed check. */
|
|
@@ -23,17 +16,22 @@ function describeProjectCompatibility(output) {
|
|
|
23
16
|
return lines.join('\n');
|
|
24
17
|
}
|
|
25
18
|
/**
|
|
26
|
-
* MCP tool for validating project compatibility with the parser
|
|
19
|
+
* MCP tool for validating project compatibility with the parser before
|
|
20
|
+
* running transformations. Detects incompatibility patterns such as external
|
|
21
|
+
* decorators, path aliases and complex constructor patterns that may cause
|
|
22
|
+
* parsing issues, and recommends a parser strategy.
|
|
27
23
|
*
|
|
28
|
-
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Checks:
|
|
29
26
|
* - Detects custom decorators (any decorator outside the known frameworks)
|
|
30
27
|
* - Detects path aliases (@shared/, @domain/, @features/, @core/, @lib/)
|
|
31
28
|
* - Detects complex constructor patterns (importService variables, public params)
|
|
32
29
|
* - Runs sample transformation test to verify actual compatibility
|
|
33
30
|
* - Classifies project type and recommends parser strategy
|
|
34
31
|
*
|
|
35
|
-
*
|
|
36
|
-
* Completes validation in
|
|
32
|
+
* Avoids running transformations that would fail due to parser
|
|
33
|
+
* incompatibilities. Completes validation in under 5 seconds for typical
|
|
34
|
+
* projects.
|
|
37
35
|
*/
|
|
38
36
|
export class ValidateProjectCompatibilityTool {
|
|
39
37
|
name = 'validate-project-compatibility';
|
|
@@ -46,6 +44,10 @@ export class ValidateProjectCompatibilityTool {
|
|
|
46
44
|
};
|
|
47
45
|
description = 'Validate project compatibility with the parser before running transformations. Detects incompatibility patterns such as external decorators, path aliases, and complex constructor patterns. Returns project type, compatibility status, recommended parser, estimated success rate, and actionable recommendations. Prevents wasted effort on transformation tests that will fail. Completes in <5 seconds. ' +
|
|
48
46
|
'summary is a short text with the verdict, the parser and the failed checks.';
|
|
47
|
+
/**
|
|
48
|
+
* JSON Schema of the tool arguments.
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
49
51
|
inputSchema = {
|
|
50
52
|
type: 'object',
|
|
51
53
|
additionalProperties: false,
|
|
@@ -76,6 +78,10 @@ export class ValidateProjectCompatibilityTool {
|
|
|
76
78
|
},
|
|
77
79
|
required: ['projectPath'],
|
|
78
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
79
85
|
outputSchema = {
|
|
80
86
|
type: 'object',
|
|
81
87
|
properties: {
|