@angular-modernizer/adapter-mcp 1.1.0 → 2.0.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/CHANGELOG.md +662 -0
- package/README.md +86 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -0
- package/dist/scan-host/scan-host.d.ts +7 -0
- package/dist/scan-host/scan-host.js +73 -10
- package/dist/scan-host/scan-protocol.d.ts +2 -0
- package/dist/scan-host/scan-worker.js +14 -8
- package/dist/server/limited-stdio-transport.d.ts +6 -3
- package/dist/server/limited-stdio-transport.js +26 -9
- package/dist/server/mcp-server.js +1 -1
- package/dist/server/sdk-server.d.ts +14 -3
- package/dist/server/sdk-server.js +54 -6
- package/dist/server/tool-registry.d.ts +3 -1
- package/dist/server/tool-registry.js +8 -3
- package/dist/streaming/progress-store.d.ts +19 -7
- package/dist/streaming/progress-store.js +19 -8
- package/dist/tools/analyze-build-impact.d.ts +9 -6
- package/dist/tools/analyze-build-impact.js +14 -7
- package/dist/tools/analyze-core-to-shared.d.ts +10 -6
- package/dist/tools/analyze-core-to-shared.js +63 -60
- package/dist/tools/analyze-parser-performance.d.ts +57 -13
- package/dist/tools/analyze-parser-performance.js +67 -6
- package/dist/tools/analyze-project.d.ts +35 -6
- package/dist/tools/analyze-project.js +141 -36
- package/dist/tools/check-incremental-compatibility.d.ts +30 -41
- package/dist/tools/check-incremental-compatibility.js +32 -264
- package/dist/tools/collect-feedback.js +15 -2
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.d.ts +2 -2
- package/dist/tools/find-angular-symbol.js +6 -5
- package/dist/tools/find-component-hosts.d.ts +2 -2
- package/dist/tools/find-component-hosts.js +6 -5
- package/dist/tools/find-usages.d.ts +2 -2
- package/dist/tools/find-usages.js +24 -15
- package/dist/tools/get-bootstrap-execution.d.ts +2 -2
- package/dist/tools/get-bootstrap-execution.js +3 -3
- package/dist/tools/get-call-graph.d.ts +2 -2
- package/dist/tools/get-call-graph.js +18 -5
- package/dist/tools/get-operation-progress-tool.d.ts +1 -1
- package/dist/tools/get-operation-progress-tool.js +2 -2
- package/dist/tools/get-operation-progress.d.ts +4 -1
- package/dist/tools/get-operation-progress.js +6 -2
- package/dist/tools/helpers/analysis-output.d.ts +32 -1
- package/dist/tools/helpers/analysis-output.js +22 -1
- package/dist/tools/helpers/build-cache.d.ts +27 -0
- package/dist/tools/helpers/build-cache.js +86 -0
- package/dist/tools/helpers/class-filter.d.ts +18 -0
- package/dist/tools/helpers/class-filter.js +30 -0
- package/dist/tools/helpers/cli-arguments.d.ts +23 -0
- package/dist/tools/helpers/cli-arguments.js +35 -0
- package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
- package/dist/tools/helpers/feedback-catalog.js +196 -0
- package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
- package/dist/tools/helpers/feedback-sidecar.js +381 -0
- package/dist/tools/helpers/file-type-check.d.ts +34 -0
- package/dist/tools/helpers/file-type-check.js +56 -0
- package/dist/tools/helpers/output-contract.d.ts +42 -0
- package/dist/tools/helpers/output-contract.js +54 -0
- package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
- package/dist/tools/helpers/pattern-anonymizer.js +159 -0
- package/dist/tools/helpers/project-cache.d.ts +78 -6
- package/dist/tools/helpers/project-cache.js +205 -15
- package/dist/tools/helpers/project-decorators.d.ts +11 -4
- package/dist/tools/helpers/project-decorators.js +13 -6
- package/dist/tools/helpers/refresh-apply.d.ts +94 -0
- package/dist/tools/helpers/refresh-apply.js +460 -0
- package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
- package/dist/tools/helpers/refresh-inventory.js +610 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +74 -5
- package/dist/tools/helpers/scan-cache.js +134 -6
- package/dist/tools/helpers/scan-engine.d.ts +30 -6
- package/dist/tools/helpers/scan-engine.js +131 -22
- package/dist/tools/helpers/scan-plan.d.ts +1 -1
- package/dist/tools/helpers/scan-plan.js +16 -2
- package/dist/tools/helpers/source-map-loader.d.ts +55 -0
- package/dist/tools/helpers/source-map-loader.js +226 -0
- package/dist/tools/helpers/template-check.d.ts +76 -0
- package/dist/tools/helpers/template-check.js +158 -0
- package/dist/tools/helpers/tool-cache.d.ts +7 -2
- package/dist/tools/helpers/tool-cache.js +9 -3
- package/dist/tools/helpers/tool-context.d.ts +18 -0
- package/dist/tools/helpers/tool-context.js +29 -0
- package/dist/tools/helpers/transform-safety.d.ts +151 -1
- package/dist/tools/helpers/transform-safety.js +357 -4
- package/dist/tools/inspect-form-group.d.ts +2 -2
- package/dist/tools/inspect-form-group.js +8 -3
- package/dist/tools/inspect-i18n.d.ts +2 -2
- package/dist/tools/inspect-i18n.js +3 -3
- package/dist/tools/inspect-template.d.ts +2 -2
- package/dist/tools/inspect-template.js +11 -5
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +2 -2
- package/dist/tools/list-imports.js +3 -3
- package/dist/tools/orchestrate-migration.d.ts +19 -1
- package/dist/tools/orchestrate-migration.js +52 -10
- package/dist/tools/parse-stack-trace.d.ts +48 -1
- package/dist/tools/parse-stack-trace.js +108 -9
- package/dist/tools/plan-migration.d.ts +2 -2
- package/dist/tools/plan-migration.js +25 -12
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.d.ts +2 -2
- package/dist/tools/resolve-type.js +13 -6
- package/dist/tools/review-feedback.d.ts +42 -7
- package/dist/tools/review-feedback.js +24 -17
- package/dist/tools/rollback-changes.d.ts +5 -0
- package/dist/tools/rollback-changes.js +7 -2
- package/dist/tools/run-angular-cli.js +36 -22
- package/dist/tools/run-build.d.ts +33 -28
- package/dist/tools/run-build.js +136 -438
- package/dist/tools/run-schematic.d.ts +8 -2
- package/dist/tools/run-schematic.js +80 -50
- package/dist/tools/scan-all.d.ts +31 -15
- package/dist/tools/scan-all.js +75 -109
- package/dist/tools/scan-angular.d.ts +27 -14
- package/dist/tools/scan-angular.js +70 -92
- package/dist/tools/scan-architecture.d.ts +29 -12
- package/dist/tools/scan-architecture.js +205 -135
- package/dist/tools/scan-solid.d.ts +27 -14
- package/dist/tools/scan-solid.js +73 -89
- package/dist/tools/search-codebase.d.ts +8 -3
- package/dist/tools/search-codebase.js +16 -10
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.d.ts +2 -2
- package/dist/tools/trace-output-flow.js +6 -5
- package/dist/tools/transform-code-batch.d.ts +9 -9
- package/dist/tools/transform-code.d.ts +161 -12
- package/dist/tools/transform-code.js +782 -197
- package/dist/tools/validate-before-transform.js +2 -1
- package/dist/tools/validate-project-compatibility.d.ts +28 -55
- package/dist/tools/validate-project-compatibility.js +33 -225
- package/dist/tools/validate-transformation.d.ts +40 -26
- package/dist/tools/validate-transformation.js +115 -294
- package/dist/tools/verify-citations.js +8 -2
- package/dist/types.d.ts +9 -9
- package/dist/utils/format-tool-response.d.ts +3 -1
- package/dist/utils/format-tool-response.js +8 -3
- package/package.json +14 -13
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { PostTransformValidator, loadConfig, } from '@angular-modernizer/core';
|
|
2
|
-
import { Project } from 'ts-morph';
|
|
3
2
|
import { existsSync } from 'node:fs';
|
|
4
|
-
import { join, dirname } from 'node:path';
|
|
5
|
-
import { execSync } from 'node:child_process';
|
|
3
|
+
import { join, dirname, resolve } from 'node:path';
|
|
6
4
|
import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
|
|
5
|
+
import { clearBuildCaches } from './helpers/build-cache.js';
|
|
6
|
+
import { typeCheckFile } from './helpers/file-type-check.js';
|
|
7
7
|
import { VALIDATION_ISSUES_SCHEMA, issueCount, issueLines, } from './helpers/validation-output.js';
|
|
8
|
-
/**
|
|
8
|
+
/** Where the deprecation notices send the caller for scope information. */
|
|
9
|
+
const SCOPE_HINT = 'validate-transformation always runs the project build command; analyze-build-impact lists the affected files';
|
|
10
|
+
/** Text summary: verdict, checks that ran, counts per severity, warnings and the first issues. */
|
|
9
11
|
function describeTransformationValidation(result) {
|
|
10
12
|
const checks = [
|
|
13
|
+
result.metadata.typeValidation === true ? 'types' : undefined,
|
|
11
14
|
result.metadata.buildValidation ? 'build' : undefined,
|
|
12
15
|
result.metadata.testValidation ? 'tests' : undefined,
|
|
13
16
|
result.metadata.lintValidation ? 'lint' : undefined,
|
|
@@ -17,26 +20,37 @@ function describeTransformationValidation(result) {
|
|
|
17
20
|
`(${checks.length > 0 ? checks.join(', ') : 'no checks'}; ${result.duration} ms); ` +
|
|
18
21
|
`${issueCount(result.issues)}.`,
|
|
19
22
|
];
|
|
20
|
-
const inc = result.incremental;
|
|
21
|
-
if (inc !== undefined) {
|
|
22
|
-
lines.push(inc.enabled
|
|
23
|
-
? `Incremental (${inc.scope ?? 'unknown scope'}): ${inc.filesValidated ?? 0} file(s) validated, ` +
|
|
24
|
-
`${inc.filesSkipped ?? 0} skipped${inc.speedup === undefined ? '' : `; ${inc.speedup}`}.`
|
|
25
|
-
: `Full validation${inc.fallbackReason === undefined ? '' : `: ${inc.fallbackReason}`}.`);
|
|
26
|
-
}
|
|
27
23
|
if (result.metadata.buildCommand !== undefined) {
|
|
28
24
|
lines.push(`Build command: ${result.metadata.buildCommand} (${result.metadata.buildCommandSource ?? 'unknown source'}).`);
|
|
29
25
|
}
|
|
26
|
+
lines.push(...(result.warnings ?? []).map((w) => `Warning: ${w}`));
|
|
30
27
|
lines.push(...issueLines(result.issues));
|
|
31
28
|
return lines.join('\n');
|
|
32
29
|
}
|
|
30
|
+
/** Deprecation notices for the parameters that no longer have an effect. */
|
|
31
|
+
function deprecationWarnings(args) {
|
|
32
|
+
const deprecated = [];
|
|
33
|
+
if (args.incrementalMode !== undefined) {
|
|
34
|
+
deprecated.push('incrementalMode');
|
|
35
|
+
}
|
|
36
|
+
if (args.transformedFiles !== undefined) {
|
|
37
|
+
deprecated.push('transformedFiles');
|
|
38
|
+
}
|
|
39
|
+
if (args.forceFullBuild !== undefined) {
|
|
40
|
+
deprecated.push('forceFullBuild');
|
|
41
|
+
}
|
|
42
|
+
if (args.cacheStrategy === 'skip') {
|
|
43
|
+
deprecated.push("cacheStrategy 'skip'");
|
|
44
|
+
}
|
|
45
|
+
return deprecated.map((name) => `${name} is deprecated and has no effect: ${SCOPE_HINT}.`);
|
|
46
|
+
}
|
|
33
47
|
/**
|
|
34
48
|
* MCP tool for validating code after a transformation to make sure the
|
|
35
|
-
* changes did not break anything
|
|
49
|
+
* changes did not break anything.
|
|
36
50
|
*
|
|
37
51
|
* @remarks
|
|
38
|
-
*
|
|
39
|
-
*
|
|
52
|
+
* Runs build, tests and lint through `PostTransformValidator`; the build is
|
|
53
|
+
* the project's build command (core `resolveBuildCommand`).
|
|
40
54
|
*/
|
|
41
55
|
export class ValidateTransformationTool {
|
|
42
56
|
name = 'validate-transformation';
|
|
@@ -47,8 +61,8 @@ export class ValidateTransformationTool {
|
|
|
47
61
|
idempotentHint: true,
|
|
48
62
|
openWorldHint: false,
|
|
49
63
|
};
|
|
50
|
-
description =
|
|
51
|
-
'summary is a short text with the verdict, the
|
|
64
|
+
description = "Validate code after transformation to ensure changes did not break anything: type-checks the file, runs the project's build command (build.command of .angular-modernizer.json, else the detected build system, else the build script of package.json) with the Angular build cache on, and, when asked, the test and lint scripts of package.json. Every validation is a full build; analyze-build-impact lists the files a change affects. " +
|
|
65
|
+
'summary is a short text with the verdict, the checks that ran, the issue counts and the first issues.';
|
|
52
66
|
/**
|
|
53
67
|
* JSON Schema of the tool arguments.
|
|
54
68
|
* @hidden
|
|
@@ -61,6 +75,11 @@ export class ValidateTransformationTool {
|
|
|
61
75
|
type: 'string',
|
|
62
76
|
description: 'Path to the file to validate (or project root for batch validation)',
|
|
63
77
|
},
|
|
78
|
+
validateTypes: {
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
description: 'Whether to type-check the file with the compiler options of its tsconfig (tsconfig.spec.json for spec files), without a build (default: true)',
|
|
81
|
+
default: true,
|
|
82
|
+
},
|
|
64
83
|
validateBuild: {
|
|
65
84
|
type: 'boolean',
|
|
66
85
|
description: 'Whether to perform build validation (default: true)',
|
|
@@ -68,12 +87,12 @@ export class ValidateTransformationTool {
|
|
|
68
87
|
},
|
|
69
88
|
validateTests: {
|
|
70
89
|
type: 'boolean',
|
|
71
|
-
description: 'Whether to
|
|
90
|
+
description: 'Whether to run the test script of package.json (default: false). Tests can be slow.',
|
|
72
91
|
default: false,
|
|
73
92
|
},
|
|
74
93
|
validateLint: {
|
|
75
94
|
type: 'boolean',
|
|
76
|
-
description: 'Whether to
|
|
95
|
+
description: 'Whether to run the lint script of package.json (default: true); without a lint script nothing runs and lint is not reported as validated',
|
|
77
96
|
default: true,
|
|
78
97
|
},
|
|
79
98
|
buildTimeout: {
|
|
@@ -97,29 +116,30 @@ export class ValidateTransformationTool {
|
|
|
97
116
|
},
|
|
98
117
|
incrementalMode: {
|
|
99
118
|
type: 'boolean',
|
|
100
|
-
description: '
|
|
119
|
+
description: 'Deprecated, no effect: every validation runs the full build command. Use analyze-build-impact for the affected files.',
|
|
120
|
+
deprecated: true,
|
|
101
121
|
},
|
|
102
122
|
transformedFiles: {
|
|
103
123
|
type: 'array',
|
|
104
124
|
items: { type: 'string' },
|
|
105
|
-
description: '
|
|
125
|
+
description: 'Deprecated, no effect: use analyze-build-impact for the affected files.',
|
|
126
|
+
deprecated: true,
|
|
106
127
|
},
|
|
107
128
|
forceFullBuild: {
|
|
108
129
|
type: 'boolean',
|
|
109
|
-
description: '
|
|
110
|
-
|
|
130
|
+
description: 'Deprecated, no effect: every validation is a full build.',
|
|
131
|
+
deprecated: true,
|
|
111
132
|
},
|
|
112
133
|
cacheStrategy: {
|
|
113
134
|
type: 'string',
|
|
114
|
-
description: '
|
|
135
|
+
description: "'clear' removes .angular/cache (and .nx/cache in an Nx workspace) inside the project before the build, never under node_modules; 'skip' is deprecated and has no effect",
|
|
115
136
|
enum: ['use', 'clear', 'skip'],
|
|
116
137
|
default: 'use',
|
|
117
138
|
},
|
|
118
139
|
buildConfig: {
|
|
119
140
|
type: 'string',
|
|
120
|
-
description: 'Build configuration (default:
|
|
141
|
+
description: 'Build configuration, passed as --configuration when set (default: none, the build command as configured)',
|
|
121
142
|
enum: ['development', 'production'],
|
|
122
|
-
default: 'development',
|
|
123
143
|
},
|
|
124
144
|
},
|
|
125
145
|
required: ['filePath'],
|
|
@@ -138,6 +158,7 @@ export class ValidateTransformationTool {
|
|
|
138
158
|
type: 'object',
|
|
139
159
|
properties: {
|
|
140
160
|
filePath: { type: 'string' },
|
|
161
|
+
typeValidation: { type: 'boolean' },
|
|
141
162
|
buildValidation: { type: 'boolean' },
|
|
142
163
|
testValidation: { type: 'boolean' },
|
|
143
164
|
lintValidation: { type: 'boolean' },
|
|
@@ -152,8 +173,14 @@ export class ValidateTransformationTool {
|
|
|
152
173
|
'lintValidation',
|
|
153
174
|
],
|
|
154
175
|
},
|
|
176
|
+
warnings: {
|
|
177
|
+
type: 'array',
|
|
178
|
+
items: { type: 'string' },
|
|
179
|
+
description: 'Deprecation notices of parameters without effect.',
|
|
180
|
+
},
|
|
155
181
|
incremental: {
|
|
156
182
|
type: 'object',
|
|
183
|
+
description: 'Deprecated, no longer set.',
|
|
157
184
|
properties: {
|
|
158
185
|
enabled: { type: 'boolean' },
|
|
159
186
|
scope: { type: 'string' },
|
|
@@ -176,6 +203,10 @@ export class ValidateTransformationTool {
|
|
|
176
203
|
}
|
|
177
204
|
async runValidation(args, signal) {
|
|
178
205
|
const typedArgs = args;
|
|
206
|
+
const startTime = Date.now();
|
|
207
|
+
if (!existsSync(typedArgs.filePath)) {
|
|
208
|
+
throw new Error(`File not found: ${typedArgs.filePath}`);
|
|
209
|
+
}
|
|
179
210
|
// Determine project root
|
|
180
211
|
const projectRoot = typedArgs.cwd ?? this.detectProjectRoot(typedArgs.filePath);
|
|
181
212
|
// Load config from .angular-modernizer.json and merge with args
|
|
@@ -185,252 +216,73 @@ export class ValidateTransformationTool {
|
|
|
185
216
|
...config,
|
|
186
217
|
...typedArgs,
|
|
187
218
|
};
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
?
|
|
198
|
-
:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
fallbackReason = `Incremental validation failed: ${message}`;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
// Use legacy PostTransformValidator
|
|
214
|
-
return this.executeLegacyValidation(typedArgs.filePath, typedArgs, fallbackReason, signal);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Executes incremental build validation using IncrementalBuildValidator
|
|
218
|
-
*/
|
|
219
|
-
async executeIncrementalValidation(filePath, projectRoot, args, signal) {
|
|
220
|
-
// Dynamic imports to avoid circular dependencies
|
|
221
|
-
const { IncompatibilityDetector, IncrementalBuildValidator, IncrementalAnalyzer, CacheManager, RealFileSystemAdapter, } = await import('@angular-modernizer/core');
|
|
222
|
-
const startTime = Date.now();
|
|
223
|
-
// Initialize ts-morph project
|
|
224
|
-
const tsConfigPath = join(projectRoot, 'tsconfig.json');
|
|
225
|
-
if (!existsSync(tsConfigPath)) {
|
|
226
|
-
throw new Error(`tsconfig.json not found in project root: ${projectRoot}. Falling back to legacy validation.`);
|
|
227
|
-
}
|
|
228
|
-
const project = new Project({
|
|
229
|
-
tsConfigFilePath: tsConfigPath,
|
|
230
|
-
skipAddingFilesFromTsConfig: false,
|
|
231
|
-
});
|
|
232
|
-
// Check project compatibility
|
|
233
|
-
const detector = new IncompatibilityDetector(project, projectRoot);
|
|
234
|
-
const incompatibilityIssues = await detector.checkProjectCompatibility();
|
|
235
|
-
// Check for blockers
|
|
236
|
-
const blockers = incompatibilityIssues.filter((issue) => issue.severity === 'blocker' && issue.detected);
|
|
237
|
-
if (blockers.length > 0) {
|
|
238
|
-
// Fallback to legacy validation
|
|
239
|
-
const fallbackReason = `Incompatible: ${blockers.map((b) => b.type).join(', ')}`;
|
|
240
|
-
throw new Error(fallbackReason);
|
|
241
|
-
}
|
|
242
|
-
// Auto-detect transformed files if not provided
|
|
243
|
-
let filesToValidate = args.transformedFiles;
|
|
244
|
-
let wasAutoDetected = false;
|
|
245
|
-
if (!filesToValidate || filesToValidate.length === 0) {
|
|
246
|
-
filesToValidate = this.detectTransformedFiles(projectRoot);
|
|
247
|
-
wasAutoDetected = true;
|
|
248
|
-
}
|
|
249
|
-
// Warning: Too many files for auto-detection
|
|
250
|
-
const warnings = [];
|
|
251
|
-
if (wasAutoDetected && filesToValidate.length >= 50) {
|
|
252
|
-
warnings.push({
|
|
253
|
-
type: 'build',
|
|
254
|
-
severity: 'warning',
|
|
255
|
-
message: `Auto-detected ${filesToValidate.length} changed files. Consider explicitly providing transformedFiles parameter for better performance when modifying many files.`,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
if (filesToValidate.length === 0) {
|
|
259
|
-
// No transformed files detected, return success
|
|
260
|
-
return {
|
|
261
|
-
valid: true,
|
|
262
|
-
issues: [],
|
|
263
|
-
duration: Date.now() - startTime,
|
|
264
|
-
metadata: {
|
|
265
|
-
filePath,
|
|
266
|
-
buildValidation: args.validateBuild ?? true,
|
|
267
|
-
testValidation: args.validateTests ?? false,
|
|
268
|
-
lintValidation: args.validateLint ?? true,
|
|
269
|
-
cwd: projectRoot,
|
|
270
|
-
},
|
|
271
|
-
incremental: {
|
|
272
|
-
enabled: true,
|
|
273
|
-
scope: 'affected-only',
|
|
274
|
-
filesValidated: 0,
|
|
275
|
-
filesSkipped: project.getSourceFiles().length,
|
|
276
|
-
cacheHit: true,
|
|
277
|
-
speedup: 'Validation skipped (no changes detected)',
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
// Create incremental analyzer and validator
|
|
282
|
-
const fileSystem = new RealFileSystemAdapter();
|
|
283
|
-
const cacheManager = new CacheManager(fileSystem);
|
|
284
|
-
const incrementalAnalyzer = new IncrementalAnalyzer(project, cacheManager);
|
|
285
|
-
// Handle cache strategy
|
|
286
|
-
if (args.cacheStrategy === 'clear') {
|
|
287
|
-
try {
|
|
288
|
-
// Clear Angular CLI cache
|
|
289
|
-
execSync('rm -rf .angular/cache', {
|
|
290
|
-
cwd: projectRoot,
|
|
291
|
-
stdio: 'ignore',
|
|
292
|
-
});
|
|
293
|
-
// Clear Nx cache if Nx project detected
|
|
294
|
-
const isNxProject = existsSync(join(projectRoot, 'nx.json'));
|
|
295
|
-
if (isNxProject) {
|
|
296
|
-
execSync('rm -rf .nx/cache node_modules/.cache/nx', {
|
|
297
|
-
cwd: projectRoot,
|
|
298
|
-
stdio: 'ignore',
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
catch {
|
|
303
|
-
// Ignore cache clear errors
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
const validator = new IncrementalBuildValidator(incrementalAnalyzer, project);
|
|
307
|
-
// Run incremental validation
|
|
308
|
-
const buildConfiguration = args.buildConfig ?? 'development';
|
|
309
|
-
const validationResult = await validator.validate(projectRoot, {
|
|
310
|
-
buildConfig: buildConfiguration,
|
|
311
|
-
baseBranch: 'HEAD',
|
|
312
|
-
forceFiles: filesToValidate,
|
|
313
|
-
includeDependents: true,
|
|
219
|
+
const validateBuild = mergedArgs.validateBuild ?? true;
|
|
220
|
+
const warnings = deprecationWarnings(mergedArgs);
|
|
221
|
+
// Caches inside the project only, never under node_modules; what stays is a build warning
|
|
222
|
+
const cacheWarnings = validateBuild && mergedArgs.cacheStrategy === 'clear'
|
|
223
|
+
? clearBuildCaches(projectRoot).warnings
|
|
224
|
+
: [];
|
|
225
|
+
// The file itself first: a build without the file's own errors (or no
|
|
226
|
+
// build at all) said nothing about it
|
|
227
|
+
const typeCheck = (mergedArgs.validateTypes ?? true)
|
|
228
|
+
? typeCheckFile(resolve(typedArgs.filePath), projectRoot)
|
|
229
|
+
: { checked: false, issues: [] };
|
|
230
|
+
const validation = {
|
|
231
|
+
validateBuild,
|
|
232
|
+
validateTests: mergedArgs.validateTests ?? false,
|
|
233
|
+
validateLint: mergedArgs.validateLint ?? true,
|
|
234
|
+
buildTimeout: mergedArgs.buildTimeout ?? 300000,
|
|
235
|
+
testTimeout: mergedArgs.testTimeout ?? 600000,
|
|
236
|
+
lintTimeout: mergedArgs.lintTimeout ?? 120000,
|
|
237
|
+
cwd: projectRoot,
|
|
238
|
+
buildArgs: mergedArgs.buildConfig === undefined
|
|
239
|
+
? []
|
|
240
|
+
: ['--configuration', mergedArgs.buildConfig],
|
|
314
241
|
signal,
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const timeStr = estimatedMinutes > 0
|
|
327
|
-
? `${estimatedMinutes}m ${estimatedSeconds}s`
|
|
328
|
-
: `${estimatedSeconds}s`;
|
|
329
|
-
speedup = `${speedupFactor.toFixed(1)}x faster (${actualSeconds}s vs ~${timeStr} full validation)`;
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
speedup = `${speedupFactor.toFixed(1)}x faster (${actualSeconds}s vs ${estimatedSeconds}s full validation)`;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
speedup = `Completed in ${Math.round(actualTime / 1000)}s`;
|
|
337
|
-
}
|
|
338
|
-
// Convert validation result to MCP format
|
|
339
|
-
const issues = [];
|
|
340
|
-
if (!validationResult.success) {
|
|
341
|
-
// Parse build errors from stderr
|
|
342
|
-
const errorLines = validationResult.stderr.split('\n');
|
|
343
|
-
for (const line of errorLines) {
|
|
344
|
-
if (line.trim() &&
|
|
345
|
-
!line.includes('npm') &&
|
|
346
|
-
!line.includes('ng build')) {
|
|
347
|
-
issues.push({
|
|
348
|
-
type: 'build',
|
|
349
|
-
severity: 'error',
|
|
350
|
-
message: line.trim(),
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
// Add validation warnings
|
|
356
|
-
for (const warning of validationResult.warnings) {
|
|
357
|
-
issues.push({
|
|
358
|
-
type: 'build',
|
|
359
|
-
severity: 'warning',
|
|
360
|
-
message: warning.message,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
// Add file count warnings
|
|
364
|
-
for (const warning of warnings) {
|
|
365
|
-
issues.push(warning);
|
|
366
|
-
}
|
|
242
|
+
};
|
|
243
|
+
const result = await new PostTransformValidator().validate(typedArgs.filePath, validation);
|
|
244
|
+
const build = buildCommandOf(result.metadata);
|
|
245
|
+
const typeIssues = typeCheck.issues.map((issue) => ({
|
|
246
|
+
type: 'type',
|
|
247
|
+
severity: issue.severity,
|
|
248
|
+
message: issue.message,
|
|
249
|
+
filePath: resolve(typedArgs.filePath),
|
|
250
|
+
...(issue.line === undefined ? {} : { line: issue.line, column: issue.column }),
|
|
251
|
+
details: issue.code,
|
|
252
|
+
}));
|
|
367
253
|
return {
|
|
368
|
-
valid:
|
|
369
|
-
issues
|
|
254
|
+
valid: result.valid && !typeIssues.some((issue) => issue.severity === 'error'),
|
|
255
|
+
issues: [
|
|
256
|
+
...typeIssues,
|
|
257
|
+
...cacheWarnings.map((message) => ({
|
|
258
|
+
type: 'build',
|
|
259
|
+
severity: 'warning',
|
|
260
|
+
message,
|
|
261
|
+
})),
|
|
262
|
+
...result.issues.map((issue) => ({
|
|
263
|
+
type: issue.type,
|
|
264
|
+
severity: issue.severity,
|
|
265
|
+
message: issue.message,
|
|
266
|
+
filePath: issue.filePath,
|
|
267
|
+
line: issue.line,
|
|
268
|
+
column: issue.column,
|
|
269
|
+
details: issue.details,
|
|
270
|
+
})),
|
|
271
|
+
],
|
|
272
|
+
// Type check, cache clearing and the validator's commands
|
|
370
273
|
duration: Date.now() - startTime,
|
|
371
274
|
metadata: {
|
|
372
|
-
filePath,
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
275
|
+
filePath: typedArgs.filePath,
|
|
276
|
+
typeValidation: typeCheck.checked,
|
|
277
|
+
buildValidation: build.buildCommand !== undefined,
|
|
278
|
+
testValidation: result.metadata?.['testValidation'] === true,
|
|
279
|
+
lintValidation: result.metadata?.['lintValidation'] === true,
|
|
376
280
|
cwd: projectRoot,
|
|
281
|
+
...build,
|
|
377
282
|
},
|
|
378
|
-
|
|
379
|
-
enabled: true,
|
|
380
|
-
scope: validationResult.scope.strategy,
|
|
381
|
-
filesValidated: validationResult.affectedFiles.length,
|
|
382
|
-
filesSkipped: project.getSourceFiles().length -
|
|
383
|
-
validationResult.affectedFiles.length,
|
|
384
|
-
cacheHit: validationResult.cacheStatus.exists,
|
|
385
|
-
speedup,
|
|
386
|
-
incompatibilityIssues: incompatibilityIssues.filter((i) => i.detected),
|
|
387
|
-
},
|
|
283
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
388
284
|
};
|
|
389
285
|
}
|
|
390
|
-
/**
|
|
391
|
-
* Executes legacy validation using PostTransformValidator
|
|
392
|
-
*/
|
|
393
|
-
async executeLegacyValidation(filePath, args, fallbackReason, signal) {
|
|
394
|
-
const validator = new PostTransformValidator();
|
|
395
|
-
const config = {
|
|
396
|
-
validateBuild: args.validateBuild ?? true,
|
|
397
|
-
validateTests: args.validateTests ?? false,
|
|
398
|
-
validateLint: args.validateLint ?? true,
|
|
399
|
-
buildTimeout: args.buildTimeout ?? 300000,
|
|
400
|
-
testTimeout: args.testTimeout ?? 600000,
|
|
401
|
-
lintTimeout: args.lintTimeout ?? 120000,
|
|
402
|
-
cwd: args.cwd,
|
|
403
|
-
signal,
|
|
404
|
-
};
|
|
405
|
-
const result = await validator.validate(filePath, config);
|
|
406
|
-
// Transform ValidationResult from core to MCP format
|
|
407
|
-
const response = {
|
|
408
|
-
valid: result.valid,
|
|
409
|
-
issues: result.issues.map((issue) => ({
|
|
410
|
-
type: issue.type,
|
|
411
|
-
severity: issue.severity,
|
|
412
|
-
message: issue.message,
|
|
413
|
-
filePath: issue.filePath,
|
|
414
|
-
line: issue.line,
|
|
415
|
-
column: issue.column,
|
|
416
|
-
details: issue.details,
|
|
417
|
-
})),
|
|
418
|
-
duration: result.duration,
|
|
419
|
-
metadata: {
|
|
420
|
-
filePath,
|
|
421
|
-
buildValidation: args.validateBuild ?? true,
|
|
422
|
-
testValidation: args.validateTests ?? false,
|
|
423
|
-
lintValidation: args.validateLint ?? true,
|
|
424
|
-
cwd: args.cwd,
|
|
425
|
-
...buildCommandOf(result.metadata),
|
|
426
|
-
},
|
|
427
|
-
// Only a build has an incremental mode to fall back from
|
|
428
|
-
incremental: args.incrementalMode === false || args.validateBuild === false
|
|
429
|
-
? undefined
|
|
430
|
-
: { enabled: false, fallbackReason },
|
|
431
|
-
};
|
|
432
|
-
return response;
|
|
433
|
-
}
|
|
434
286
|
/**
|
|
435
287
|
* Detects project root from file path
|
|
436
288
|
*/
|
|
@@ -451,37 +303,6 @@ export class ValidateTransformationTool {
|
|
|
451
303
|
// Default to current directory if no project root found
|
|
452
304
|
return process.cwd();
|
|
453
305
|
}
|
|
454
|
-
/**
|
|
455
|
-
* Detects transformed files using git status
|
|
456
|
-
*/
|
|
457
|
-
detectTransformedFiles(projectRoot) {
|
|
458
|
-
try {
|
|
459
|
-
const output = execSync('git status --porcelain', {
|
|
460
|
-
cwd: projectRoot,
|
|
461
|
-
encoding: 'utf-8',
|
|
462
|
-
stdio: ['pipe', 'pipe', 'ignore'],
|
|
463
|
-
});
|
|
464
|
-
const lines = output.split('\n').filter((line) => line.trim());
|
|
465
|
-
const transformedFiles = [];
|
|
466
|
-
for (const line of lines) {
|
|
467
|
-
// Parse git status format: "XY filename"
|
|
468
|
-
const match = /^\s*[MADRCU?!]{1,2}\s+(.+)$/.exec(line);
|
|
469
|
-
if (match?.[1]) {
|
|
470
|
-
const fileName = match[1];
|
|
471
|
-
// Only include TypeScript files
|
|
472
|
-
if (fileName.endsWith('.ts') || fileName.endsWith('.tsx')) {
|
|
473
|
-
transformedFiles.push(fileName);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return transformedFiles;
|
|
478
|
-
}
|
|
479
|
-
catch (_error) {
|
|
480
|
-
// Git not available or not a git repository
|
|
481
|
-
// Return empty array to skip incremental validation
|
|
482
|
-
return [];
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
306
|
}
|
|
486
307
|
/** Build command and its source from the validator's metadata. */
|
|
487
308
|
function buildCommandOf(metadata) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute, relative, resolve } from 'node:path';
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
2
2
|
import { CITATION_ATTENTION_STATUSES, CitationVerifier, } from '@angular-modernizer/api';
|
|
3
3
|
import { createNodeCitationFileSource } from './helpers/citation-file-source.js';
|
|
4
4
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
@@ -135,7 +135,13 @@ export class VerifyCitationsTool {
|
|
|
135
135
|
throw new Error(`Plan file not found: ${missing.join(', ')}`);
|
|
136
136
|
}
|
|
137
137
|
const reports = new CitationVerifier(root, source).verifyPlans(plans);
|
|
138
|
-
|
|
138
|
+
// Relative only inside the root; a plan elsewhere keeps its absolute path
|
|
139
|
+
const label = (plan) => {
|
|
140
|
+
const rel = relative(root, plan);
|
|
141
|
+
const outside = rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel);
|
|
142
|
+
const inside = rel !== '' && !outside;
|
|
143
|
+
return inside ? rel : plan;
|
|
144
|
+
};
|
|
139
145
|
const all = reports.flatMap((r) => r.results.map((c) => toVerified(label(r.plan), c)));
|
|
140
146
|
const attention = all.filter((c) => CITATION_ATTENTION_STATUSES.has(c.status));
|
|
141
147
|
const counts = Object.fromEntries(STATUSES.map((s) => [s, all.filter((c) => c.status === s).length]));
|
package/dist/types.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface ToolAnnotations {
|
|
|
69
69
|
/**
|
|
70
70
|
* JSON-RPC 2.0 request message.
|
|
71
71
|
*
|
|
72
|
-
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in
|
|
72
|
+
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in 3.0.
|
|
73
73
|
*/
|
|
74
74
|
export interface JsonRpcRequest {
|
|
75
75
|
/** Protocol version, always `'2.0'`. */
|
|
@@ -84,7 +84,7 @@ export interface JsonRpcRequest {
|
|
|
84
84
|
/**
|
|
85
85
|
* JSON-RPC 2.0 response message.
|
|
86
86
|
*
|
|
87
|
-
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in
|
|
87
|
+
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in 3.0.
|
|
88
88
|
*/
|
|
89
89
|
export interface JsonRpcResponse {
|
|
90
90
|
/** Protocol version, always `'2.0'`. */
|
|
@@ -99,7 +99,7 @@ export interface JsonRpcResponse {
|
|
|
99
99
|
/**
|
|
100
100
|
* JSON-RPC 2.0 error object.
|
|
101
101
|
*
|
|
102
|
-
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in
|
|
102
|
+
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in 3.0.
|
|
103
103
|
*/
|
|
104
104
|
export interface JsonRpcError {
|
|
105
105
|
/** JSON-RPC error code, e.g. `-32602` for invalid params. */
|
|
@@ -112,7 +112,7 @@ export interface JsonRpcError {
|
|
|
112
112
|
/**
|
|
113
113
|
* JSON-RPC 2.0 notification message (no response expected).
|
|
114
114
|
*
|
|
115
|
-
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in
|
|
115
|
+
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in 3.0.
|
|
116
116
|
*/
|
|
117
117
|
export interface JsonRpcNotification {
|
|
118
118
|
/** Protocol version, always `'2.0'`. */
|
|
@@ -128,17 +128,17 @@ export interface JsonRpcNotification {
|
|
|
128
128
|
export interface MCPServerConfig {
|
|
129
129
|
/**
|
|
130
130
|
* Port for HTTP transport. Never read: the server speaks stdio only.
|
|
131
|
-
* @deprecated Will be removed in
|
|
131
|
+
* @deprecated Will be removed in 3.0.
|
|
132
132
|
*/
|
|
133
133
|
port?: number;
|
|
134
134
|
/**
|
|
135
135
|
* Tool execution timeout in milliseconds. Not enforced by the server.
|
|
136
|
-
* @deprecated Will be removed in
|
|
136
|
+
* @deprecated Will be removed in 3.0.
|
|
137
137
|
*/
|
|
138
138
|
timeout?: number;
|
|
139
139
|
/**
|
|
140
140
|
* Maximum number of concurrent tool executions. Not enforced by the server.
|
|
141
|
-
* @deprecated Will be removed in
|
|
141
|
+
* @deprecated Will be removed in 3.0.
|
|
142
142
|
*/
|
|
143
143
|
maxConcurrentTools?: number;
|
|
144
144
|
/**
|
|
@@ -147,7 +147,7 @@ export interface MCPServerConfig {
|
|
|
147
147
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
148
148
|
/**
|
|
149
149
|
* Enable performance metrics collection. Not read by the server.
|
|
150
|
-
* @deprecated Will be removed in
|
|
150
|
+
* @deprecated Will be removed in 3.0.
|
|
151
151
|
*/
|
|
152
152
|
enableMetrics?: boolean;
|
|
153
153
|
/**
|
|
@@ -161,7 +161,7 @@ export interface MCPServerConfig {
|
|
|
161
161
|
/**
|
|
162
162
|
* Tool execution context for tracking and metrics.
|
|
163
163
|
*
|
|
164
|
-
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in
|
|
164
|
+
* @deprecated Not used since the server runs on the MCP TypeScript SDK; will be removed in 3.0.
|
|
165
165
|
*/
|
|
166
166
|
export interface ToolExecutionContext {
|
|
167
167
|
/**
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* A result that reports its own failure: top-level `success: false` or
|
|
9
9
|
* `status: 'failed'` (transform-code, run-angular-cli, run-build,
|
|
10
10
|
* run-schematic, rollback-changes, orchestrate-migration). It goes out with
|
|
11
|
-
* `isError: true` with the same content. `status: 'partial'` is a success
|
|
11
|
+
* `isError: true` with the same content. `status: 'partial'` is a success,
|
|
12
|
+
* and so is `status: 'running'` (the immediate answer of a streaming
|
|
13
|
+
* transform-code: `success: false` there means nothing has run yet).
|
|
12
14
|
*/
|
|
13
15
|
export declare function reportsFailure(result: object): boolean;
|
|
14
16
|
/**
|
|
@@ -8,11 +8,16 @@
|
|
|
8
8
|
* A result that reports its own failure: top-level `success: false` or
|
|
9
9
|
* `status: 'failed'` (transform-code, run-angular-cli, run-build,
|
|
10
10
|
* run-schematic, rollback-changes, orchestrate-migration). It goes out with
|
|
11
|
-
* `isError: true` with the same content. `status: 'partial'` is a success
|
|
11
|
+
* `isError: true` with the same content. `status: 'partial'` is a success,
|
|
12
|
+
* and so is `status: 'running'` (the immediate answer of a streaming
|
|
13
|
+
* transform-code: `success: false` there means nothing has run yet).
|
|
12
14
|
*/
|
|
13
15
|
export function reportsFailure(result) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const status = 'status' in result ? result.status : undefined;
|
|
17
|
+
if (status === 'running') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return ('success' in result && result.success === false) || status === 'failed';
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* Tool result as MCP content: the object itself as `structuredContent`, and a
|