@angular-modernizer/adapter-mcp 1.2.0 → 2.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/CHANGELOG.md +688 -0
- package/README.md +84 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +10 -0
- 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 +7 -4
- package/dist/tools/analyze-build-impact.js +8 -3
- 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 +55 -4
- package/dist/tools/analyze-project.js +104 -15
- 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/compare-health.d.ts +40 -4
- package/dist/tools/compare-health.js +22 -5
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.js +3 -2
- package/dist/tools/find-component-hosts.js +3 -2
- package/dist/tools/find-usages.js +21 -12
- package/dist/tools/get-call-graph.js +15 -2
- 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 +25 -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/health-delta.d.ts +6 -0
- package/dist/tools/helpers/health-delta.js +4 -1
- package/dist/tools/helpers/library-import-warning.d.ts +33 -0
- package/dist/tools/helpers/library-import-warning.js +38 -0
- package/dist/tools/helpers/library-imports.d.ts +38 -14
- package/dist/tools/helpers/library-imports.js +128 -23
- package/dist/tools/helpers/output-contract.d.ts +64 -0
- package/dist/tools/helpers/output-contract.js +67 -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 +5 -4
- package/dist/tools/helpers/project-cache.js +21 -16
- 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 +631 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +117 -5
- package/dist/tools/helpers/scan-cache.js +179 -6
- package/dist/tools/helpers/scan-engine.d.ts +43 -6
- package/dist/tools/helpers/scan-engine.js +141 -22
- 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.js +5 -0
- package/dist/tools/inspect-i18n.d.ts +1 -1
- package/dist/tools/inspect-template.js +8 -2
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +1 -1
- 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.js +22 -10
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.js +10 -3
- 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 +37 -15
- package/dist/tools/scan-all.js +76 -115
- package/dist/tools/scan-angular.d.ts +33 -14
- package/dist/tools/scan-angular.js +77 -94
- package/dist/tools/scan-architecture.d.ts +37 -12
- package/dist/tools/scan-architecture.js +220 -139
- package/dist/tools/scan-solid.d.ts +33 -14
- package/dist/tools/scan-solid.js +80 -91
- package/dist/tools/search-codebase.d.ts +6 -1
- package/dist/tools/search-codebase.js +13 -7
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.js +3 -2
- 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 +715 -206
- 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
|
@@ -2,46 +2,59 @@ import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
|
2
2
|
import { type IncompatibilityCheck } from '@angular-modernizer/core';
|
|
3
3
|
/**
|
|
4
4
|
* Recommendation type for incremental build usage.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated check-incremental-compatibility always answers `use-full`:
|
|
7
|
+
* run-build and validate-transformation have no incremental mode.
|
|
5
8
|
*/
|
|
6
9
|
export type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
|
|
7
10
|
/**
|
|
8
11
|
* Output result of compatibility check.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated check-incremental-compatibility is deprecated: its fields keep
|
|
14
|
+
* their 1.x shape, `compatible` is always `false`, `issues` empty and
|
|
15
|
+
* `estimatedSpeedup` `null`.
|
|
9
16
|
*/
|
|
10
17
|
export interface CompatibilityCheckOutput {
|
|
11
18
|
/**
|
|
12
|
-
*
|
|
19
|
+
* Always `false`: there is no incremental build to be compatible with.
|
|
13
20
|
*/
|
|
14
21
|
compatible: boolean;
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
23
|
+
* Angular version from package.json.
|
|
17
24
|
*/
|
|
18
25
|
angularVersion: string | null;
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
27
|
+
* Always empty.
|
|
21
28
|
*/
|
|
22
29
|
issues: IncompatibilityCheck[];
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
31
|
+
* Always `use-full`.
|
|
25
32
|
*/
|
|
26
33
|
recommendation: RecommendationType;
|
|
27
34
|
/**
|
|
28
|
-
*
|
|
29
|
-
* Null if incremental mode is not compatible.
|
|
35
|
+
* Always `null`.
|
|
30
36
|
*/
|
|
31
37
|
estimatedSpeedup: number | null;
|
|
32
38
|
/**
|
|
33
|
-
*
|
|
39
|
+
* Always `true`.
|
|
40
|
+
*/
|
|
41
|
+
deprecated: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The deprecation notice and where to go instead.
|
|
34
44
|
*/
|
|
35
45
|
message: string;
|
|
36
46
|
/**
|
|
37
|
-
* Short text:
|
|
47
|
+
* Short text: the deprecation notice.
|
|
38
48
|
*/
|
|
39
49
|
summary: string;
|
|
40
50
|
}
|
|
41
51
|
/**
|
|
42
|
-
* MCP tool
|
|
43
|
-
*
|
|
44
|
-
*
|
|
52
|
+
* Deprecated MCP tool that used to check a project for incremental build
|
|
53
|
+
* validation. run-build and validate-transformation have one build path, so
|
|
54
|
+
* there is nothing to check; the tool stays registered in 2.x and answers at
|
|
55
|
+
* once with a deprecation notice, without loading the project.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Use analyze-build-impact for the affected files; removal planned for 3.0.
|
|
45
58
|
*/
|
|
46
59
|
export declare class CheckIncrementalCompatibilityTool implements MCPTool {
|
|
47
60
|
name: string;
|
|
@@ -63,17 +76,17 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
|
|
|
63
76
|
maxCircularDeps: {
|
|
64
77
|
type: string;
|
|
65
78
|
description: string;
|
|
66
|
-
|
|
79
|
+
deprecated: boolean;
|
|
67
80
|
};
|
|
68
81
|
minAngularVersion: {
|
|
69
82
|
type: string;
|
|
70
83
|
description: string;
|
|
71
|
-
|
|
84
|
+
deprecated: boolean;
|
|
72
85
|
};
|
|
73
86
|
maxInterProjectDeps: {
|
|
74
87
|
type: string;
|
|
75
88
|
description: string;
|
|
76
|
-
|
|
89
|
+
deprecated: boolean;
|
|
77
90
|
};
|
|
78
91
|
};
|
|
79
92
|
required: string[];
|
|
@@ -126,6 +139,9 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
|
|
|
126
139
|
estimatedSpeedup: {
|
|
127
140
|
type: string[];
|
|
128
141
|
};
|
|
142
|
+
deprecated: {
|
|
143
|
+
type: string;
|
|
144
|
+
};
|
|
129
145
|
message: {
|
|
130
146
|
type: string;
|
|
131
147
|
};
|
|
@@ -140,32 +156,5 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
|
|
|
140
156
|
* Extracts Angular version from package.json
|
|
141
157
|
*/
|
|
142
158
|
private extractAngularVersion;
|
|
143
|
-
/**
|
|
144
|
-
* Determines recommendation based on blockers and warnings
|
|
145
|
-
*/
|
|
146
|
-
private determineRecommendation;
|
|
147
|
-
/**
|
|
148
|
-
* Calculates estimated speedup for incremental builds
|
|
149
|
-
*
|
|
150
|
-
* Estimates based on:
|
|
151
|
-
* - Project size (number of files)
|
|
152
|
-
* - Typical change patterns (10-20% of files modified)
|
|
153
|
-
* - Build time heuristics
|
|
154
|
-
*
|
|
155
|
-
* Returns speedup factor (e.g., 5.2 = 5.2x faster)
|
|
156
|
-
*/
|
|
157
|
-
private calculateSpeedup;
|
|
158
|
-
/**
|
|
159
|
-
* Formats user-facing message with compatibility status, issues, and recommendations
|
|
160
|
-
*/
|
|
161
|
-
private formatMessage;
|
|
162
|
-
/**
|
|
163
|
-
* Gets version status indicator (supported/too old)
|
|
164
|
-
*/
|
|
165
|
-
private getVersionStatus;
|
|
166
|
-
/**
|
|
167
|
-
* Formats issue details for display
|
|
168
|
-
*/
|
|
169
|
-
private formatDetails;
|
|
170
159
|
}
|
|
171
160
|
//# sourceMappingURL=check-incremental-compatibility.d.ts.map
|
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
import { Project } from 'ts-morph';
|
|
2
|
-
import { IncompatibilityDetector, } from '@angular-modernizer/core';
|
|
3
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
2
|
import { join } from 'node:path';
|
|
5
3
|
import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const blockers = detected.filter((i) => i.severity === 'blocker');
|
|
10
|
-
const verdict = !output.compatible
|
|
11
|
-
? 'Not compatible with incremental builds'
|
|
12
|
-
: output.recommendation === 'use-with-caution'
|
|
13
|
-
? 'Compatible with incremental builds, with caution'
|
|
14
|
-
: 'Compatible with incremental builds';
|
|
15
|
-
const lines = [
|
|
16
|
-
`${verdict} (Angular ${output.angularVersion ?? 'not detected'}); recommendation ${output.recommendation}; ` +
|
|
17
|
-
`${blockers.length} blocker(s), ${detected.length - blockers.length} warning(s)` +
|
|
18
|
-
(output.estimatedSpeedup === null
|
|
19
|
-
? '.'
|
|
20
|
-
: `; estimated speedup ${output.estimatedSpeedup}x.`),
|
|
21
|
-
];
|
|
22
|
-
for (const issue of detected) {
|
|
23
|
-
lines.push(`- ${issue.severity} ${issue.type}: ${issue.message} ${issue.recommendation}`);
|
|
24
|
-
}
|
|
25
|
-
return lines.join('\n');
|
|
26
|
-
}
|
|
4
|
+
/** What the tool answers on every call. */
|
|
5
|
+
const DEPRECATION_MESSAGE = 'check-incremental-compatibility is deprecated and checks nothing: run-build and validate-transformation always run the full build command of the project (the Angular CLI has no file-scoped build). ' +
|
|
6
|
+
'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
|
|
27
7
|
/**
|
|
28
|
-
* MCP tool
|
|
29
|
-
*
|
|
30
|
-
*
|
|
8
|
+
* Deprecated MCP tool that used to check a project for incremental build
|
|
9
|
+
* validation. run-build and validate-transformation have one build path, so
|
|
10
|
+
* there is nothing to check; the tool stays registered in 2.x and answers at
|
|
11
|
+
* once with a deprecation notice, without loading the project.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use analyze-build-impact for the affected files; removal planned for 3.0.
|
|
31
14
|
*/
|
|
32
15
|
export class CheckIncrementalCompatibilityTool {
|
|
33
16
|
name = 'check-incremental-compatibility';
|
|
34
|
-
title = 'Check Incremental Build Compatibility';
|
|
17
|
+
title = 'Check Incremental Build Compatibility (deprecated)';
|
|
35
18
|
annotations = {
|
|
36
19
|
readOnlyHint: true,
|
|
37
20
|
destructiveHint: false,
|
|
38
21
|
idempotentHint: true,
|
|
39
22
|
openWorldHint: false,
|
|
40
23
|
};
|
|
41
|
-
description = '
|
|
42
|
-
'
|
|
24
|
+
description = 'Deprecated, checks nothing: run-build and validate-transformation always run the full build command of the project. Answers compatible false, recommendation use-full and no issues. ' +
|
|
25
|
+
'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
|
|
43
26
|
/**
|
|
44
27
|
* JSON Schema of the tool arguments.
|
|
45
28
|
* @hidden
|
|
@@ -50,22 +33,22 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
50
33
|
properties: {
|
|
51
34
|
projectPath: {
|
|
52
35
|
type: 'string',
|
|
53
|
-
description: 'Project root path
|
|
36
|
+
description: 'Project root path',
|
|
54
37
|
},
|
|
55
38
|
maxCircularDeps: {
|
|
56
39
|
type: 'number',
|
|
57
|
-
description: '
|
|
58
|
-
|
|
40
|
+
description: 'Deprecated, no effect',
|
|
41
|
+
deprecated: true,
|
|
59
42
|
},
|
|
60
43
|
minAngularVersion: {
|
|
61
44
|
type: 'string',
|
|
62
|
-
description: '
|
|
63
|
-
|
|
45
|
+
description: 'Deprecated, no effect',
|
|
46
|
+
deprecated: true,
|
|
64
47
|
},
|
|
65
48
|
maxInterProjectDeps: {
|
|
66
49
|
type: 'number',
|
|
67
|
-
description: '
|
|
68
|
-
|
|
50
|
+
description: 'Deprecated, no effect',
|
|
51
|
+
deprecated: true,
|
|
69
52
|
},
|
|
70
53
|
},
|
|
71
54
|
required: ['projectPath'],
|
|
@@ -85,6 +68,7 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
85
68
|
enum: ['use-incremental', 'use-full', 'use-with-caution'],
|
|
86
69
|
},
|
|
87
70
|
estimatedSpeedup: { type: ['number', 'null'] },
|
|
71
|
+
deprecated: { type: 'boolean' },
|
|
88
72
|
message: { type: 'string' },
|
|
89
73
|
summary: { type: 'string' },
|
|
90
74
|
},
|
|
@@ -103,49 +87,19 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
103
87
|
if (!params.projectPath) {
|
|
104
88
|
throw new Error('projectPath is required');
|
|
105
89
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
skipAddingFilesFromTsConfig: false,
|
|
119
|
-
});
|
|
120
|
-
// Create IncompatibilityDetector with optional config
|
|
121
|
-
const detector = new IncompatibilityDetector(project, projectPath, {
|
|
122
|
-
maxCircularDeps: params.maxCircularDeps,
|
|
123
|
-
minAngularVersion: params.minAngularVersion,
|
|
124
|
-
maxInterProjectDeps: params.maxInterProjectDeps,
|
|
125
|
-
});
|
|
126
|
-
// Run compatibility checks
|
|
127
|
-
const issues = await detector.checkProjectCompatibility();
|
|
128
|
-
// Extract Angular version
|
|
129
|
-
const angularVersion = this.extractAngularVersion(projectPath);
|
|
130
|
-
// Determine compatibility (no blockers detected)
|
|
131
|
-
const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
|
|
132
|
-
const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
|
|
133
|
-
const compatible = blockers.length === 0;
|
|
134
|
-
// Determine recommendation
|
|
135
|
-
const recommendation = this.determineRecommendation(blockers, warnings);
|
|
136
|
-
// Calculate estimated speedup
|
|
137
|
-
const estimatedSpeedup = compatible ? this.calculateSpeedup(project) : null;
|
|
138
|
-
// Format user-facing message
|
|
139
|
-
const message = this.formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup);
|
|
140
|
-
const output = {
|
|
141
|
-
compatible,
|
|
142
|
-
angularVersion,
|
|
143
|
-
issues,
|
|
144
|
-
recommendation,
|
|
145
|
-
estimatedSpeedup,
|
|
146
|
-
message,
|
|
90
|
+
if (!existsSync(params.projectPath)) {
|
|
91
|
+
throw new Error(`Project path does not exist: ${params.projectPath}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
compatible: false,
|
|
95
|
+
angularVersion: this.extractAngularVersion(params.projectPath),
|
|
96
|
+
issues: [],
|
|
97
|
+
recommendation: 'use-full',
|
|
98
|
+
estimatedSpeedup: null,
|
|
99
|
+
deprecated: true,
|
|
100
|
+
message: DEPRECATION_MESSAGE,
|
|
101
|
+
summary: DEPRECATION_MESSAGE,
|
|
147
102
|
};
|
|
148
|
-
return { ...output, summary: describeCompatibility(output) };
|
|
149
103
|
}
|
|
150
104
|
/**
|
|
151
105
|
* Extracts Angular version from package.json
|
|
@@ -171,191 +125,5 @@ export class CheckIncrementalCompatibilityTool {
|
|
|
171
125
|
return null;
|
|
172
126
|
}
|
|
173
127
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Determines recommendation based on blockers and warnings
|
|
176
|
-
*/
|
|
177
|
-
determineRecommendation(blockers, warnings) {
|
|
178
|
-
if (blockers.length > 0) {
|
|
179
|
-
return 'use-full';
|
|
180
|
-
}
|
|
181
|
-
if (warnings.length > 0) {
|
|
182
|
-
return 'use-with-caution';
|
|
183
|
-
}
|
|
184
|
-
return 'use-incremental';
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Calculates estimated speedup for incremental builds
|
|
188
|
-
*
|
|
189
|
-
* Estimates based on:
|
|
190
|
-
* - Project size (number of files)
|
|
191
|
-
* - Typical change patterns (10-20% of files modified)
|
|
192
|
-
* - Build time heuristics
|
|
193
|
-
*
|
|
194
|
-
* Returns speedup factor (e.g., 5.2 = 5.2x faster)
|
|
195
|
-
*/
|
|
196
|
-
calculateSpeedup(project) {
|
|
197
|
-
const sourceFiles = project.getSourceFiles();
|
|
198
|
-
const fileCount = sourceFiles.length;
|
|
199
|
-
// Estimate full build time based on file count
|
|
200
|
-
// Heuristic: 50 files = 30s, 500 files = 4min (240s)
|
|
201
|
-
// Linear interpolation with some diminishing returns at scale
|
|
202
|
-
let fullBuildTimeSeconds;
|
|
203
|
-
if (fileCount <= 50) {
|
|
204
|
-
fullBuildTimeSeconds = 30;
|
|
205
|
-
}
|
|
206
|
-
else if (fileCount <= 500) {
|
|
207
|
-
// Linear interpolation: 30s to 240s
|
|
208
|
-
const ratio = (fileCount - 50) / (500 - 50);
|
|
209
|
-
fullBuildTimeSeconds = 30 + ratio * (240 - 30);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
// Large projects: 240s + additional time
|
|
213
|
-
const extraFiles = fileCount - 500;
|
|
214
|
-
fullBuildTimeSeconds = 240 + extraFiles * 0.3; // 0.3s per extra file
|
|
215
|
-
}
|
|
216
|
-
// Estimate incremental build time
|
|
217
|
-
// Typically validates 10-20% of files for small changes
|
|
218
|
-
// Heuristic: 10-15% of full build time + 5s overhead
|
|
219
|
-
const incrementalBuildTimeSeconds = fullBuildTimeSeconds * 0.12 + 5;
|
|
220
|
-
// Calculate speedup ratio
|
|
221
|
-
const speedup = fullBuildTimeSeconds / incrementalBuildTimeSeconds;
|
|
222
|
-
// Round to 1 decimal place
|
|
223
|
-
return Math.round(speedup * 10) / 10;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Formats user-facing message with compatibility status, issues, and recommendations
|
|
227
|
-
*/
|
|
228
|
-
formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup) {
|
|
229
|
-
const lines = [];
|
|
230
|
-
// Status header
|
|
231
|
-
if (compatible && recommendation === 'use-incremental') {
|
|
232
|
-
lines.push('✅ Incremental build compatible with this project');
|
|
233
|
-
}
|
|
234
|
-
else if (compatible && recommendation === 'use-with-caution') {
|
|
235
|
-
lines.push('⚠️ Incremental build compatible with caution');
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
lines.push('❌ Incremental build not compatible with this project');
|
|
239
|
-
}
|
|
240
|
-
lines.push('');
|
|
241
|
-
// Angular version
|
|
242
|
-
if (angularVersion) {
|
|
243
|
-
const versionStatus = this.getVersionStatus(angularVersion);
|
|
244
|
-
lines.push(`Angular version: ${angularVersion} ${versionStatus}`);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
lines.push('Angular version: Not detected');
|
|
248
|
-
}
|
|
249
|
-
lines.push('');
|
|
250
|
-
// Issues section
|
|
251
|
-
const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
|
|
252
|
-
const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
|
|
253
|
-
if (blockers.length > 0 || warnings.length > 0) {
|
|
254
|
-
lines.push('Issues:');
|
|
255
|
-
blockers.forEach((issue) => {
|
|
256
|
-
lines.push(` [BLOCKER] ${issue.message}`);
|
|
257
|
-
lines.push(` → ${issue.recommendation}`);
|
|
258
|
-
if (issue.details) {
|
|
259
|
-
const detailsStr = this.formatDetails(issue.details);
|
|
260
|
-
if (detailsStr) {
|
|
261
|
-
lines.push(` ${detailsStr}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
lines.push('');
|
|
265
|
-
});
|
|
266
|
-
warnings.forEach((issue) => {
|
|
267
|
-
lines.push(` [WARNING] ${issue.message}`);
|
|
268
|
-
lines.push(` → ${issue.recommendation}`);
|
|
269
|
-
if (issue.details) {
|
|
270
|
-
const detailsStr = this.formatDetails(issue.details);
|
|
271
|
-
if (detailsStr) {
|
|
272
|
-
lines.push(` ${detailsStr}`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
lines.push('');
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
lines.push('No compatibility issues detected');
|
|
280
|
-
lines.push('');
|
|
281
|
-
}
|
|
282
|
-
// Recommendation
|
|
283
|
-
lines.push('Recommendation:');
|
|
284
|
-
switch (recommendation) {
|
|
285
|
-
case 'use-incremental':
|
|
286
|
-
lines.push(' Use incremental build mode for faster validation');
|
|
287
|
-
if (estimatedSpeedup) {
|
|
288
|
-
lines.push(` Estimated speedup: ${estimatedSpeedup}x faster on incremental changes`);
|
|
289
|
-
}
|
|
290
|
-
break;
|
|
291
|
-
case 'use-with-caution':
|
|
292
|
-
lines.push(' Incremental build may work, but test thoroughly');
|
|
293
|
-
lines.push(' Consider using full build if issues occur');
|
|
294
|
-
if (estimatedSpeedup) {
|
|
295
|
-
lines.push(` Potential speedup: ${estimatedSpeedup}x faster (if warnings resolved)`);
|
|
296
|
-
}
|
|
297
|
-
break;
|
|
298
|
-
case 'use-full':
|
|
299
|
-
lines.push(' Use full build mode for this project');
|
|
300
|
-
lines.push(' Address blockers above to enable incremental builds');
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
return lines.join('\n');
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Gets version status indicator (supported/too old)
|
|
307
|
-
*/
|
|
308
|
-
getVersionStatus(version) {
|
|
309
|
-
const majorVersion = Number.parseInt(version.split('.')[0] ?? '0', 10);
|
|
310
|
-
if (majorVersion >= 12) {
|
|
311
|
-
return '(supported)';
|
|
312
|
-
}
|
|
313
|
-
else if (majorVersion >= 10) {
|
|
314
|
-
return '(old, upgrade recommended)';
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
return '(too old, upgrade required)';
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Formats issue details for display
|
|
322
|
-
*/
|
|
323
|
-
formatDetails(details) {
|
|
324
|
-
const parts = [];
|
|
325
|
-
const count = details['count'];
|
|
326
|
-
if (count !== undefined &&
|
|
327
|
-
(typeof count === 'number' || typeof count === 'string')) {
|
|
328
|
-
parts.push(`Count: ${count}`);
|
|
329
|
-
}
|
|
330
|
-
if (details['examples'] && Array.isArray(details['examples'])) {
|
|
331
|
-
const examples = details['examples'].slice(0, 2);
|
|
332
|
-
if (examples.length > 0) {
|
|
333
|
-
parts.push(`Examples: ${examples.join('; ')}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const currentVersion = details['currentVersion'];
|
|
337
|
-
if (currentVersion !== undefined && typeof currentVersion === 'string') {
|
|
338
|
-
parts.push(`Current: ${currentVersion}`);
|
|
339
|
-
}
|
|
340
|
-
const minVersion = details['minVersion'];
|
|
341
|
-
if (minVersion !== undefined && typeof minVersion === 'string') {
|
|
342
|
-
parts.push(`Required: ${minVersion}`);
|
|
343
|
-
}
|
|
344
|
-
const projectCount = details['projectCount'];
|
|
345
|
-
if (projectCount !== undefined &&
|
|
346
|
-
(typeof projectCount === 'number' || typeof projectCount === 'string')) {
|
|
347
|
-
parts.push(`Projects: ${projectCount}`);
|
|
348
|
-
}
|
|
349
|
-
const interProjectDeps = details['interProjectDeps'];
|
|
350
|
-
if (interProjectDeps !== undefined &&
|
|
351
|
-
(typeof interProjectDeps === 'number' ||
|
|
352
|
-
typeof interProjectDeps === 'string')) {
|
|
353
|
-
parts.push(`Inter-project deps: ${interProjectDeps}`);
|
|
354
|
-
}
|
|
355
|
-
if (details['configs'] && Array.isArray(details['configs'])) {
|
|
356
|
-
parts.push(`Configs: ${details['configs'].join(', ')}`);
|
|
357
|
-
}
|
|
358
|
-
return parts.length > 0 ? parts.join(', ') : '';
|
|
359
|
-
}
|
|
360
128
|
}
|
|
361
129
|
//# sourceMappingURL=check-incremental-compatibility.js.map
|
|
@@ -632,8 +632,7 @@ export class CollectFeedbackTool {
|
|
|
632
632
|
storageLocations,
|
|
633
633
|
learnings,
|
|
634
634
|
validationResult: {
|
|
635
|
-
valid: validationResult
|
|
636
|
-
.length === 0,
|
|
635
|
+
valid: isValidFeedback(validationResult, config),
|
|
637
636
|
score: validationResult.score,
|
|
638
637
|
issues: validationResult.issues.map((issue) => ({
|
|
639
638
|
type: ValidationType.SCHEMA, // Use ValidationType enum for validation module
|
|
@@ -798,6 +797,20 @@ async function estimateComplexity(filePath) {
|
|
|
798
797
|
return { linesOfCode: 100, complexity: 5 };
|
|
799
798
|
}
|
|
800
799
|
}
|
|
800
|
+
/**
|
|
801
|
+
* Whether collected feedback counts as valid: no errors, and the
|
|
802
|
+
* `tools['collect-feedback']` checks that are set (`strictMode`: no warnings
|
|
803
|
+
* either, `minCompletenessScore`: at least that score). Unset, only errors
|
|
804
|
+
* count, as before the fields were read.
|
|
805
|
+
*/
|
|
806
|
+
function isValidFeedback(result, config) {
|
|
807
|
+
const hasErrors = result.issues.some((issue) => issue.severity === 'error');
|
|
808
|
+
const hasStrictWarnings = config.strictMode === true &&
|
|
809
|
+
result.issues.some((issue) => issue.severity === 'warning');
|
|
810
|
+
const belowMinimum = config.minCompletenessScore !== undefined &&
|
|
811
|
+
result.score < config.minCompletenessScore;
|
|
812
|
+
return !hasErrors && !hasStrictWarnings && !belowMinimum;
|
|
813
|
+
}
|
|
801
814
|
/**
|
|
802
815
|
* Type guard to validate if a parsed value matches the StructuredDiff interface.
|
|
803
816
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FileSystemAdapter } from '@angular-modernizer/core';
|
|
2
2
|
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
3
3
|
import { type FileDelta, type HealthViolation, type RuleDelta } from './helpers/health-delta.js';
|
|
4
|
+
import { type UnresolvedLibraryImports } from './helpers/library-import-warning.js';
|
|
4
5
|
/** The part of a scan-all result the comparison needs. */
|
|
5
6
|
export interface HealthScanResult {
|
|
6
7
|
/** All violations of the scan. */
|
|
@@ -28,6 +29,8 @@ export interface HealthScanResult {
|
|
|
28
29
|
/** Ids of the rules that ran. */
|
|
29
30
|
rulesExecuted: string[];
|
|
30
31
|
};
|
|
32
|
+
/** Library imports that do not resolve; absent when all resolve. */
|
|
33
|
+
unresolvedLibraryImports?: UnresolvedLibraryImports;
|
|
31
34
|
/** Set by scan-all when the client cancelled the scan. */
|
|
32
35
|
execution?: {
|
|
33
36
|
/** `cancelled` when the client cancelled the scan. */
|
|
@@ -43,9 +46,12 @@ export type HealthScan = (args: Record<string, unknown>, ctx?: ToolContext) => P
|
|
|
43
46
|
* - `no-baseline`: no snapshot existed and `updateSnapshot` was `false`.
|
|
44
47
|
* - `scope-mismatch`: the snapshot used other rules or include/exclude
|
|
45
48
|
* patterns; nothing was compared.
|
|
49
|
+
* - `environment-mismatch`: library imports resolved in one run and not in
|
|
50
|
+
* the other (node_modules missing or incomplete), so rules that need
|
|
51
|
+
* library types are not comparable; nothing was compared.
|
|
46
52
|
* - `invalid-snapshot`: the snapshot could not be read; nothing was compared.
|
|
47
53
|
*/
|
|
48
|
-
export type CompareHealthStatus = 'compared' | 'baseline-created' | 'no-baseline' | 'scope-mismatch' | 'invalid-snapshot';
|
|
54
|
+
export type CompareHealthStatus = 'compared' | 'baseline-created' | 'no-baseline' | 'scope-mismatch' | 'environment-mismatch' | 'invalid-snapshot';
|
|
49
55
|
/** Counts of one run. */
|
|
50
56
|
export interface HealthRunInfo {
|
|
51
57
|
/** Time of the run (ISO 8601). */
|
|
@@ -111,6 +117,10 @@ export interface CompareHealthOutput {
|
|
|
111
117
|
scopeDifferences: string[];
|
|
112
118
|
/** `true` when `maxResults` cut one of the lists. */
|
|
113
119
|
truncated: boolean;
|
|
120
|
+
/** The warning of a run whose library imports do not resolve. */
|
|
121
|
+
warnings?: string[];
|
|
122
|
+
/** Library imports of the current run that do not resolve; absent when all resolve. */
|
|
123
|
+
unresolvedLibraryImports?: UnresolvedLibraryImports;
|
|
114
124
|
/** Human-readable summary for LLM consumption. */
|
|
115
125
|
summary: string;
|
|
116
126
|
}
|
|
@@ -204,6 +214,35 @@ export declare class CompareHealthTool implements MCPTool {
|
|
|
204
214
|
readonly outputSchema: {
|
|
205
215
|
type: string;
|
|
206
216
|
properties: {
|
|
217
|
+
summary: {
|
|
218
|
+
type: string;
|
|
219
|
+
};
|
|
220
|
+
unresolvedLibraryImports: {
|
|
221
|
+
readonly type: "object";
|
|
222
|
+
readonly description: "Library imports of the scanned files that do not resolve (node_modules missing or incomplete); rules that need library types can report less. Absent when all resolve.";
|
|
223
|
+
readonly properties: {
|
|
224
|
+
readonly imports: {
|
|
225
|
+
readonly type: "integer";
|
|
226
|
+
};
|
|
227
|
+
readonly packages: {
|
|
228
|
+
readonly type: "integer";
|
|
229
|
+
};
|
|
230
|
+
readonly examples: {
|
|
231
|
+
readonly type: "array";
|
|
232
|
+
readonly items: {
|
|
233
|
+
readonly type: "string";
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
readonly required: readonly ["imports", "packages", "examples"];
|
|
238
|
+
};
|
|
239
|
+
warnings: {
|
|
240
|
+
readonly type: "array";
|
|
241
|
+
readonly items: {
|
|
242
|
+
readonly type: "string";
|
|
243
|
+
};
|
|
244
|
+
readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
|
|
245
|
+
};
|
|
207
246
|
status: {
|
|
208
247
|
type: string;
|
|
209
248
|
enum: string[];
|
|
@@ -400,9 +439,6 @@ export declare class CompareHealthTool implements MCPTool {
|
|
|
400
439
|
truncated: {
|
|
401
440
|
type: string;
|
|
402
441
|
};
|
|
403
|
-
summary: {
|
|
404
|
-
type: string;
|
|
405
|
-
};
|
|
406
442
|
};
|
|
407
443
|
required: string[];
|
|
408
444
|
};
|