@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,65 +1,88 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Learn Patterns Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for discovering and learning patterns from codebases using
|
|
5
|
-
* ML-based pattern recognition. Identifies recurring architectural patterns,
|
|
6
|
-
* anti-patterns, and transformation opportunities.
|
|
7
|
-
*
|
|
8
|
-
* Enhancement: Self-learning with style-aware pattern discovery
|
|
9
|
-
*/
|
|
10
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
11
2
|
/**
|
|
12
3
|
* Pattern discovery result.
|
|
13
4
|
*/
|
|
14
|
-
interface LearnPatternsResult {
|
|
5
|
+
export interface LearnPatternsResult {
|
|
15
6
|
/**
|
|
16
7
|
* Discovered patterns.
|
|
17
8
|
*/
|
|
18
9
|
patterns: {
|
|
10
|
+
/** Pattern id. */
|
|
19
11
|
id: string;
|
|
12
|
+
/** Pattern name. */
|
|
20
13
|
name: string;
|
|
14
|
+
/** Pattern category. */
|
|
21
15
|
category: string;
|
|
16
|
+
/** What the pattern is. */
|
|
22
17
|
description: string;
|
|
18
|
+
/** Number of occurrences. */
|
|
23
19
|
occurrences: number;
|
|
20
|
+
/** Estimated complexity. */
|
|
24
21
|
complexity: 'low' | 'medium' | 'high';
|
|
22
|
+
/** Example occurrences. */
|
|
25
23
|
examples: {
|
|
24
|
+
/** File of the example. */
|
|
26
25
|
filePath: string;
|
|
26
|
+
/** Code of the example. */
|
|
27
27
|
code: string;
|
|
28
|
+
/** Pattern-specific details. */
|
|
28
29
|
metadata: Record<string, unknown>;
|
|
29
30
|
}[];
|
|
31
|
+
/** Analysis rule suggested for the pattern. */
|
|
30
32
|
suggestedRule?: {
|
|
33
|
+
/** Suggested rule id. */
|
|
31
34
|
ruleId: string;
|
|
35
|
+
/** Suggested severity. */
|
|
32
36
|
severity: string;
|
|
37
|
+
/** How the rule would detect the pattern. */
|
|
33
38
|
detection: string;
|
|
34
39
|
};
|
|
40
|
+
/** Confidence score (0 to 1). */
|
|
35
41
|
confidence?: number;
|
|
42
|
+
/** Why the confidence has its value. */
|
|
36
43
|
confidenceExplanation?: string;
|
|
44
|
+
/** `true` when the pattern matches the detected style profile. */
|
|
37
45
|
alignsWithStyle?: boolean;
|
|
46
|
+
/** Degree of alignment with the style profile (0 to 1). */
|
|
38
47
|
styleAlignment?: number;
|
|
48
|
+
/** Occurrences per analyzed file, in percent. */
|
|
39
49
|
dominancePercentage?: number;
|
|
50
|
+
/** Trend across scans. */
|
|
40
51
|
trending?: 'rising' | 'stable' | 'declining';
|
|
52
|
+
/** Number of scans that saw the pattern. */
|
|
41
53
|
scanCount?: number;
|
|
42
54
|
}[];
|
|
43
55
|
/**
|
|
44
56
|
* Pattern statistics.
|
|
45
57
|
*/
|
|
46
58
|
statistics: {
|
|
59
|
+
/** Number of patterns found. */
|
|
47
60
|
totalPatternsFound: number;
|
|
61
|
+
/** Patterns per category. */
|
|
48
62
|
byCategory: Record<string, number>;
|
|
63
|
+
/** Patterns per complexity. */
|
|
49
64
|
byComplexity: Record<string, number>;
|
|
65
|
+
/** Number of analyzed files. */
|
|
50
66
|
filesAnalyzed: number;
|
|
67
|
+
/** Duration in milliseconds. */
|
|
51
68
|
duration: number;
|
|
52
69
|
};
|
|
53
70
|
/**
|
|
54
71
|
* Generated artifacts.
|
|
55
72
|
*/
|
|
56
73
|
artifacts?: {
|
|
74
|
+
/** Fixture files written. */
|
|
57
75
|
fixtures?: {
|
|
76
|
+
/** Path of the file. */
|
|
58
77
|
path: string;
|
|
78
|
+
/** Patterns in the file. */
|
|
59
79
|
patterns: string[];
|
|
60
80
|
}[];
|
|
81
|
+
/** Rule files written. */
|
|
61
82
|
rules?: {
|
|
83
|
+
/** Path of the file. */
|
|
62
84
|
path: string;
|
|
85
|
+
/** Rule ids in the file. */
|
|
63
86
|
ruleIds: string[];
|
|
64
87
|
}[];
|
|
65
88
|
};
|
|
@@ -67,68 +90,107 @@ interface LearnPatternsResult {
|
|
|
67
90
|
* Validation results.
|
|
68
91
|
*/
|
|
69
92
|
validation?: {
|
|
93
|
+
/** Number of validated patterns. */
|
|
70
94
|
patternsValidated: number;
|
|
95
|
+
/** Quality problems found. */
|
|
71
96
|
validationErrors: string[];
|
|
72
97
|
};
|
|
73
98
|
/**
|
|
74
99
|
* Detected style profile for the codebase.
|
|
75
100
|
*/
|
|
76
101
|
styleProfile?: {
|
|
102
|
+
/** Preferred state primitive: BehaviorSubject, signal or both. */
|
|
77
103
|
rxjsPreference: 'behaviorsubject' | 'signal' | 'mixed';
|
|
104
|
+
/** Usage share of BehaviorSubject and signal. */
|
|
78
105
|
rxjsRatio: {
|
|
106
|
+
/** Share of BehaviorSubject. */
|
|
79
107
|
behaviorSubject: number;
|
|
108
|
+
/** Share of signal. */
|
|
80
109
|
signal: number;
|
|
81
110
|
};
|
|
111
|
+
/** Preferred dependency injection style. */
|
|
82
112
|
diPreference: 'constructor' | 'inject' | 'mixed';
|
|
113
|
+
/** Usage share of constructor injection and `inject()`. */
|
|
83
114
|
diRatio: {
|
|
115
|
+
/** Share of constructor injection. */
|
|
84
116
|
constructor: number;
|
|
117
|
+
/** Share of `inject()`. */
|
|
85
118
|
inject: number;
|
|
86
119
|
};
|
|
120
|
+
/** Detected state management library. */
|
|
87
121
|
stateManagement: 'ngrx' | 'akita' | 'ngxs' | 'custom' | 'none';
|
|
122
|
+
/** Class name suffixes and their counts. */
|
|
88
123
|
namingConventions: {
|
|
124
|
+
/** Class name suffix. */
|
|
89
125
|
suffix: string;
|
|
126
|
+
/** Number of classes with the suffix. */
|
|
90
127
|
count: number;
|
|
91
128
|
}[];
|
|
129
|
+
/** Detected architecture style. */
|
|
92
130
|
architectureStyle: 'clean' | 'feature-modules' | 'ddd' | 'standard';
|
|
131
|
+
/** Most frequent patterns. */
|
|
93
132
|
dominantPatterns: string[];
|
|
133
|
+
/** Preferred change detection strategy. */
|
|
94
134
|
changeDetectionPreference: 'onpush' | 'default' | 'mixed';
|
|
135
|
+
/** Standalone components, NgModules or both. */
|
|
95
136
|
moduleStyle: 'standalone' | 'ngmodule' | 'mixed';
|
|
137
|
+
/** Confidence of the profile. */
|
|
96
138
|
confidence: number;
|
|
97
139
|
};
|
|
98
140
|
/**
|
|
99
141
|
* Learning evolution tracking.
|
|
100
142
|
*/
|
|
101
143
|
learningEvolution?: {
|
|
144
|
+
/** `true` when the knowledge base had no earlier scan. */
|
|
102
145
|
isFirstScan: boolean;
|
|
146
|
+
/** Stability of the patterns compared with earlier scans. */
|
|
103
147
|
patternStability: number;
|
|
148
|
+
/** Patterns not seen in earlier scans. */
|
|
104
149
|
newPatternsDiscovered: number;
|
|
150
|
+
/** Earlier patterns no longer found. */
|
|
105
151
|
deprecatedPatterns: number;
|
|
152
|
+
/** Rate of pattern change between scans. */
|
|
106
153
|
patternVelocity: number;
|
|
154
|
+
/** Change of the style profile since the earlier scan. */
|
|
107
155
|
styleShift?: {
|
|
156
|
+
/** Earlier style. */
|
|
108
157
|
from: string;
|
|
158
|
+
/** Current style. */
|
|
109
159
|
to: string;
|
|
160
|
+
/** Confidence of the shift. */
|
|
110
161
|
confidence: number;
|
|
111
162
|
};
|
|
163
|
+
/** Confidence gain reported by the knowledge base. */
|
|
112
164
|
confidenceImprovement?: number;
|
|
113
165
|
};
|
|
114
166
|
/**
|
|
115
167
|
* Confidence analysis summary.
|
|
116
168
|
*/
|
|
117
169
|
confidenceAnalysis?: {
|
|
170
|
+
/** Patterns with confidence 0.8 or more. */
|
|
118
171
|
highConfidence: number;
|
|
172
|
+
/** Patterns with confidence from 0.6 to below 0.8. */
|
|
119
173
|
mediumConfidence: number;
|
|
174
|
+
/** Patterns with confidence below 0.6. */
|
|
120
175
|
lowConfidence: number;
|
|
176
|
+
/** Average confidence of all patterns. */
|
|
121
177
|
averageConfidence: number;
|
|
178
|
+
/** Patterns aligned with the style profile. */
|
|
122
179
|
styleAlignedPatterns: number;
|
|
123
180
|
};
|
|
124
181
|
/**
|
|
125
182
|
* Generated rules (if generateRules=true).
|
|
126
183
|
*/
|
|
127
184
|
generatedRules?: {
|
|
185
|
+
/** Output folder (`ruleOutputPath`, default `./learned-rules`). */
|
|
128
186
|
path: string;
|
|
187
|
+
/** Generated rule id. */
|
|
129
188
|
ruleId: string;
|
|
189
|
+
/** Confidence of the rule. */
|
|
130
190
|
confidence: number;
|
|
191
|
+
/** `true` when the rule aligns with the style profile. */
|
|
131
192
|
alignedWithStyle: boolean;
|
|
193
|
+
/** Why the rule was generated. */
|
|
132
194
|
rationale: string;
|
|
133
195
|
}[];
|
|
134
196
|
/**
|
|
@@ -137,13 +199,24 @@ interface LearnPatternsResult {
|
|
|
137
199
|
summary: string;
|
|
138
200
|
}
|
|
139
201
|
/**
|
|
140
|
-
* MCP tool
|
|
202
|
+
* MCP tool `learn-patterns`: discovers recurring architectural patterns,
|
|
203
|
+
* anti-patterns and transformation opportunities in a codebase.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* Detects a style profile of the codebase (DI, RxJS/signals, change
|
|
207
|
+
* detection, module style, state management), scores patterns by confidence
|
|
208
|
+
* and style alignment, tracks them across scans in a knowledge base and can
|
|
209
|
+
* write fixtures and generated rules.
|
|
141
210
|
*/
|
|
142
211
|
export declare class LearnPatternsTool implements MCPTool {
|
|
143
212
|
name: string;
|
|
144
213
|
title: string;
|
|
145
214
|
annotations: ToolAnnotations;
|
|
146
215
|
description: string;
|
|
216
|
+
/**
|
|
217
|
+
* JSON Schema of the tool arguments.
|
|
218
|
+
* @hidden
|
|
219
|
+
*/
|
|
147
220
|
inputSchema: {
|
|
148
221
|
type: string;
|
|
149
222
|
additionalProperties: boolean;
|
|
@@ -276,6 +349,10 @@ export declare class LearnPatternsTool implements MCPTool {
|
|
|
276
349
|
};
|
|
277
350
|
required: string[];
|
|
278
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
354
|
+
* @hidden
|
|
355
|
+
*/
|
|
279
356
|
outputSchema: {
|
|
280
357
|
type: string;
|
|
281
358
|
properties: {
|
|
@@ -485,5 +562,4 @@ export declare class LearnPatternsTool implements MCPTool {
|
|
|
485
562
|
*/
|
|
486
563
|
private ensureGitignore;
|
|
487
564
|
}
|
|
488
|
-
export {};
|
|
489
565
|
//# sourceMappingURL=learn-patterns.d.ts.map
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Learn Patterns Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for discovering and learning patterns from codebases using
|
|
5
|
-
* ML-based pattern recognition. Identifies recurring architectural patterns,
|
|
6
|
-
* anti-patterns, and transformation opportunities.
|
|
7
|
-
*
|
|
8
|
-
* Enhancement: Self-learning with style-aware pattern discovery
|
|
9
|
-
*/
|
|
10
1
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
11
2
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
12
3
|
import { writeFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
@@ -52,7 +43,14 @@ function describePatterns(result) {
|
|
|
52
43
|
return lines.join('\n');
|
|
53
44
|
}
|
|
54
45
|
/**
|
|
55
|
-
* MCP tool
|
|
46
|
+
* MCP tool `learn-patterns`: discovers recurring architectural patterns,
|
|
47
|
+
* anti-patterns and transformation opportunities in a codebase.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Detects a style profile of the codebase (DI, RxJS/signals, change
|
|
51
|
+
* detection, module style, state management), scores patterns by confidence
|
|
52
|
+
* and style alignment, tracks them across scans in a knowledge base and can
|
|
53
|
+
* write fixtures and generated rules.
|
|
56
54
|
*/
|
|
57
55
|
export class LearnPatternsTool {
|
|
58
56
|
name = 'learn-patterns';
|
|
@@ -63,7 +61,11 @@ export class LearnPatternsTool {
|
|
|
63
61
|
idempotentHint: true,
|
|
64
62
|
openWorldHint: false,
|
|
65
63
|
};
|
|
66
|
-
description = 'Discover
|
|
64
|
+
description = 'Discover recurring architectural patterns, anti-patterns and transformation opportunities in a codebase with AST heuristics (RxJS, components, services, transformations, architecture), count their occurrences and store them in a pattern knowledge base that later runs extend. Detects the codebase style conventions. summary is a short text of patterns and style profile.';
|
|
65
|
+
/**
|
|
66
|
+
* JSON Schema of the tool arguments.
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
67
69
|
inputSchema = {
|
|
68
70
|
type: 'object',
|
|
69
71
|
additionalProperties: false,
|
|
@@ -204,6 +206,10 @@ export class LearnPatternsTool {
|
|
|
204
206
|
},
|
|
205
207
|
required: ['targetPath'],
|
|
206
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
211
|
+
* @hidden
|
|
212
|
+
*/
|
|
207
213
|
outputSchema = {
|
|
208
214
|
type: 'object',
|
|
209
215
|
properties: {
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - List Imports Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool that lists the imports (and optionally `export ... from`
|
|
5
|
-
* re-exports) of a single file with their resolved targets.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
9
|
-
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
10
|
-
* instead of grepping import lines when classifying layer dependencies,
|
|
11
|
-
* checking barrels or tracing where a symbol really comes from.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Via MCP:
|
|
16
|
-
* // tool: list-imports
|
|
17
|
-
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
21
2
|
import { type ModuleSpecifierKind } from '@angular-modernizer/core';
|
|
22
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
23
4
|
/**
|
|
24
5
|
* A named import / re-export specifier.
|
|
25
6
|
*/
|
|
26
|
-
interface NamedImportEntry {
|
|
7
|
+
export interface NamedImportEntry {
|
|
27
8
|
/** Name exported by the target module. */
|
|
28
9
|
name: string;
|
|
29
10
|
/** Local alias (import) or exported alias (re-export), if renamed. */
|
|
@@ -34,13 +15,18 @@ interface NamedImportEntry {
|
|
|
34
15
|
/**
|
|
35
16
|
* One import or re-export of the file.
|
|
36
17
|
*/
|
|
37
|
-
interface ImportEntry {
|
|
18
|
+
export interface ImportEntry {
|
|
19
|
+
/** Module specifier as written. */
|
|
38
20
|
moduleSpecifier: string;
|
|
21
|
+
/** Specifier kind: aliased (tsconfig `paths`), relative or external. */
|
|
39
22
|
kind: ModuleSpecifierKind;
|
|
40
23
|
/** Project-relative resolved path, or null when unresolved / external. */
|
|
41
24
|
resolvedPath: string | null;
|
|
25
|
+
/** Named import or re-export specifiers. */
|
|
42
26
|
namedImports: NamedImportEntry[];
|
|
27
|
+
/** Default import binding, or null. */
|
|
43
28
|
defaultImport: string | null;
|
|
29
|
+
/** Namespace import binding (`import * as x`), or null. */
|
|
44
30
|
namespaceImport: string | null;
|
|
45
31
|
/** Whole declaration is type-only (`import type` / `export type`). */
|
|
46
32
|
typeOnly: boolean;
|
|
@@ -54,9 +40,12 @@ interface ImportEntry {
|
|
|
54
40
|
/**
|
|
55
41
|
* Output of the list-imports tool.
|
|
56
42
|
*/
|
|
57
|
-
interface ListImportsOutput {
|
|
43
|
+
export interface ListImportsOutput {
|
|
44
|
+
/** Absolute path of the inspected file. */
|
|
58
45
|
file: string;
|
|
46
|
+
/** Absolute project root. */
|
|
59
47
|
projectRoot: string;
|
|
48
|
+
/** The tsconfig used to resolve the imports. */
|
|
60
49
|
tsConfigPath: string;
|
|
61
50
|
/** Imports in declaration order, cut to `maxResults`; omitted with `summaryOnly`. */
|
|
62
51
|
imports?: ImportEntry[];
|
|
@@ -70,17 +59,38 @@ interface ListImportsOutput {
|
|
|
70
59
|
warnings?: string[];
|
|
71
60
|
}
|
|
72
61
|
/** Counts over all imports of the file. */
|
|
73
|
-
interface ImportCounts {
|
|
62
|
+
export interface ImportCounts {
|
|
63
|
+
/** All imports and re-exports. */
|
|
74
64
|
total: number;
|
|
65
|
+
/** Specifiers resolved through tsconfig `paths` aliases. */
|
|
75
66
|
aliased: number;
|
|
67
|
+
/** Relative specifiers. */
|
|
76
68
|
relative: number;
|
|
69
|
+
/** Package specifiers. */
|
|
77
70
|
external: number;
|
|
71
|
+
/** Non-external specifiers that did not resolve to a file. */
|
|
78
72
|
unresolved: number;
|
|
73
|
+
/** `export ... from` declarations. */
|
|
79
74
|
reExports: number;
|
|
75
|
+
/** Type-only declarations (`import type` / `export type`). */
|
|
80
76
|
typeOnly: number;
|
|
81
77
|
}
|
|
82
78
|
/**
|
|
83
|
-
* MCP tool that lists the
|
|
79
|
+
* MCP tool that lists the imports (and optionally `export ... from`
|
|
80
|
+
* re-exports) of a single file with their resolved targets.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
84
|
+
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
85
|
+
* instead of grepping import lines when classifying layer dependencies,
|
|
86
|
+
* checking barrels or tracing where a symbol really comes from.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Via MCP:
|
|
91
|
+
* // tool: list-imports
|
|
92
|
+
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
93
|
+
* ```
|
|
84
94
|
*/
|
|
85
95
|
export declare class ListImportsTool implements MCPTool {
|
|
86
96
|
private readonly projects;
|
|
@@ -89,6 +99,10 @@ export declare class ListImportsTool implements MCPTool {
|
|
|
89
99
|
readonly annotations: ToolAnnotations;
|
|
90
100
|
constructor(projects?: ProjectCache);
|
|
91
101
|
readonly description: string;
|
|
102
|
+
/**
|
|
103
|
+
* JSON Schema of the tool arguments.
|
|
104
|
+
* @hidden
|
|
105
|
+
*/
|
|
92
106
|
readonly inputSchema: {
|
|
93
107
|
type: string;
|
|
94
108
|
additionalProperties: boolean;
|
|
@@ -118,6 +132,10 @@ export declare class ListImportsTool implements MCPTool {
|
|
|
118
132
|
};
|
|
119
133
|
required: string[];
|
|
120
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
137
|
+
* @hidden
|
|
138
|
+
*/
|
|
121
139
|
readonly outputSchema: {
|
|
122
140
|
type: string;
|
|
123
141
|
properties: {
|
|
@@ -216,5 +234,4 @@ export declare class ListImportsTool implements MCPTool {
|
|
|
216
234
|
private buildSummary;
|
|
217
235
|
private countImports;
|
|
218
236
|
}
|
|
219
|
-
export {};
|
|
220
237
|
//# sourceMappingURL=list-imports.d.ts.map
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - List Imports Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool that lists the imports (and optionally `export ... from`
|
|
5
|
-
* re-exports) of a single file with their resolved targets.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
9
|
-
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
10
|
-
* instead of grepping import lines when classifying layer dependencies,
|
|
11
|
-
* checking barrels or tracing where a symbol really comes from.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Via MCP:
|
|
16
|
-
* // tool: list-imports
|
|
17
|
-
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
1
|
import { Project } from 'ts-morph';
|
|
21
2
|
import { classifyModuleSpecifier, collectModuleEdges, } from '@angular-modernizer/core';
|
|
22
3
|
import { existsSync } from 'node:fs';
|
|
@@ -37,7 +18,21 @@ const COUNT_KEYS = [
|
|
|
37
18
|
'typeOnly',
|
|
38
19
|
];
|
|
39
20
|
/**
|
|
40
|
-
* MCP tool that lists the
|
|
21
|
+
* MCP tool that lists the imports (and optionally `export ... from`
|
|
22
|
+
* re-exports) of a single file with their resolved targets.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
26
|
+
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
27
|
+
* instead of grepping import lines when classifying layer dependencies,
|
|
28
|
+
* checking barrels or tracing where a symbol really comes from.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Via MCP:
|
|
33
|
+
* // tool: list-imports
|
|
34
|
+
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
35
|
+
* ```
|
|
41
36
|
*/
|
|
42
37
|
export class ListImportsTool {
|
|
43
38
|
projects;
|
|
@@ -57,6 +52,10 @@ export class ListImportsTool {
|
|
|
57
52
|
'project-relative resolvedPath (tsconfig paths aware), named/default/namespace imports, ' +
|
|
58
53
|
'type-only flags and whether it is a re-export. Use instead of grepping import lines. ' +
|
|
59
54
|
'counts always cover all imports; summaryOnly returns only the counts and the summary.';
|
|
55
|
+
/**
|
|
56
|
+
* JSON Schema of the tool arguments.
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
60
59
|
inputSchema = {
|
|
61
60
|
type: 'object',
|
|
62
61
|
additionalProperties: false,
|
|
@@ -78,6 +77,10 @@ export class ListImportsTool {
|
|
|
78
77
|
},
|
|
79
78
|
required: ['file'],
|
|
80
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
81
84
|
outputSchema = {
|
|
82
85
|
type: 'object',
|
|
83
86
|
properties: {
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Orchestrate Migration Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for executing multi-step migration workflows with
|
|
5
|
-
* dependency management, checkpoint/resume, and rollback support.
|
|
6
|
-
*/
|
|
7
1
|
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
8
2
|
/**
|
|
9
3
|
* Result from orchestrate-migration tool
|
|
10
4
|
*/
|
|
11
|
-
interface OrchestrateMigrationResult {
|
|
5
|
+
export interface OrchestrateMigrationResult {
|
|
12
6
|
/**
|
|
13
7
|
* Overall workflow status
|
|
14
8
|
*/
|
|
@@ -21,43 +15,61 @@ interface OrchestrateMigrationResult {
|
|
|
21
15
|
* Step counts and total duration
|
|
22
16
|
*/
|
|
23
17
|
counts: {
|
|
18
|
+
/** Number of steps in the workflow. */
|
|
24
19
|
totalSteps: number;
|
|
20
|
+
/** Steps that succeeded. */
|
|
25
21
|
successfulSteps: number;
|
|
22
|
+
/** Steps that failed. */
|
|
26
23
|
failedSteps: number;
|
|
24
|
+
/** Steps that were skipped. */
|
|
27
25
|
skippedSteps: number;
|
|
26
|
+
/** Duration of the whole workflow in milliseconds. */
|
|
28
27
|
totalDurationMs: number;
|
|
29
28
|
};
|
|
30
29
|
/**
|
|
31
30
|
* Individual step results
|
|
32
31
|
*/
|
|
33
32
|
stepResults: {
|
|
33
|
+
/** Step id from the workflow definition. */
|
|
34
34
|
stepId: string;
|
|
35
|
+
/** Step name (the step id). */
|
|
35
36
|
name: string;
|
|
37
|
+
/** Step status reported by the workflow engine. */
|
|
36
38
|
status: string;
|
|
39
|
+
/** Duration of the step in milliseconds. */
|
|
37
40
|
durationMs: number;
|
|
41
|
+
/** Error message of a failed step. */
|
|
38
42
|
error?: string;
|
|
39
43
|
}[];
|
|
40
44
|
/**
|
|
41
45
|
* Checkpoints created during execution
|
|
42
46
|
*/
|
|
43
47
|
checkpoints: {
|
|
48
|
+
/** Checkpoint id (the step id). */
|
|
44
49
|
id: string;
|
|
50
|
+
/** Id of the checkpoint step. */
|
|
45
51
|
stepId: string;
|
|
52
|
+
/** Start time of the step in milliseconds since the epoch. */
|
|
46
53
|
timestamp: number;
|
|
47
54
|
}[];
|
|
48
55
|
/**
|
|
49
56
|
* Errors encountered
|
|
50
57
|
*/
|
|
51
58
|
errors: {
|
|
59
|
+
/** Step that failed; `'workflow'` for errors of the workflow itself. */
|
|
52
60
|
stepId: string;
|
|
61
|
+
/** Error message. */
|
|
53
62
|
message: string;
|
|
63
|
+
/** Stack trace of the error. */
|
|
54
64
|
stack?: string;
|
|
55
65
|
}[];
|
|
56
66
|
/**
|
|
57
67
|
* Final checkpoint for resume
|
|
58
68
|
*/
|
|
59
69
|
finalCheckpoint?: {
|
|
70
|
+
/** Checkpoint id to pass as `resumeFromCheckpoint`. */
|
|
60
71
|
id: string;
|
|
72
|
+
/** Always `true` when a final checkpoint exists. */
|
|
61
73
|
canResume: boolean;
|
|
62
74
|
};
|
|
63
75
|
/**
|
|
@@ -70,13 +82,20 @@ interface OrchestrateMigrationResult {
|
|
|
70
82
|
summary: string;
|
|
71
83
|
}
|
|
72
84
|
/**
|
|
73
|
-
*
|
|
85
|
+
* MCP tool for executing multi-step migration workflows with dependency
|
|
86
|
+
* management, checkpoint/resume, and rollback support. Steps call the other
|
|
87
|
+
* registered tools (`setAvailableTools`); a cancelled request runs no further
|
|
88
|
+
* step.
|
|
74
89
|
*/
|
|
75
90
|
export declare class OrchestrateMigrationTool implements MCPTool {
|
|
76
91
|
name: string;
|
|
77
92
|
title: string;
|
|
78
93
|
annotations: ToolAnnotations;
|
|
79
94
|
description: string;
|
|
95
|
+
/**
|
|
96
|
+
* JSON Schema of the tool arguments.
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
80
99
|
inputSchema: {
|
|
81
100
|
type: string;
|
|
82
101
|
additionalProperties: boolean;
|
|
@@ -180,6 +199,10 @@ export declare class OrchestrateMigrationTool implements MCPTool {
|
|
|
180
199
|
};
|
|
181
200
|
required: string[];
|
|
182
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
204
|
+
* @hidden
|
|
205
|
+
*/
|
|
183
206
|
outputSchema: {
|
|
184
207
|
type: string;
|
|
185
208
|
properties: {
|
|
@@ -307,5 +330,4 @@ export declare class OrchestrateMigrationTool implements MCPTool {
|
|
|
307
330
|
*/
|
|
308
331
|
private buildResult;
|
|
309
332
|
}
|
|
310
|
-
export {};
|
|
311
333
|
//# sourceMappingURL=orchestrate-migration.d.ts.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Orchestrate Migration Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for executing multi-step migration workflows with
|
|
5
|
-
* dependency management, checkpoint/resume, and rollback support.
|
|
6
|
-
*/
|
|
7
1
|
import { yieldIfCancellable } from './helpers/tool-context.js';
|
|
8
2
|
import { WorkflowEngine, } from '@angular-modernizer/orchestration';
|
|
9
3
|
/** Errors spelled out in the summary; the rest is in `errors`. */
|
|
@@ -63,7 +57,10 @@ class MCPToolExecutor {
|
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
/**
|
|
66
|
-
*
|
|
60
|
+
* MCP tool for executing multi-step migration workflows with dependency
|
|
61
|
+
* management, checkpoint/resume, and rollback support. Steps call the other
|
|
62
|
+
* registered tools (`setAvailableTools`); a cancelled request runs no further
|
|
63
|
+
* step.
|
|
67
64
|
*/
|
|
68
65
|
export class OrchestrateMigrationTool {
|
|
69
66
|
name = 'orchestrate-migration';
|
|
@@ -76,6 +73,10 @@ export class OrchestrateMigrationTool {
|
|
|
76
73
|
};
|
|
77
74
|
description = 'Execute multi-step migration workflows with dependency management and checkpoint/resume. ' +
|
|
78
75
|
'counts has the step counts and the duration; summary is a short text with the status, the counts and the first errors.';
|
|
76
|
+
/**
|
|
77
|
+
* JSON Schema of the tool arguments.
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
79
80
|
inputSchema = {
|
|
80
81
|
type: 'object',
|
|
81
82
|
additionalProperties: false,
|
|
@@ -145,6 +146,10 @@ export class OrchestrateMigrationTool {
|
|
|
145
146
|
},
|
|
146
147
|
required: ['workflow'],
|
|
147
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
151
|
+
* @hidden
|
|
152
|
+
*/
|
|
148
153
|
outputSchema = {
|
|
149
154
|
type: 'object',
|
|
150
155
|
properties: {
|