@angular-modernizer/adapter-mcp 1.0.0 → 1.2.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 +81 -65
- 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 +58 -36
- package/dist/tools/analyze-build-impact.js +36 -29
- 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 +87 -14
- package/dist/tools/analyze-project.js +140 -122
- 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 +27 -25
- package/dist/tools/find-angular-symbol.js +19 -16
- package/dist/tools/find-component-hosts.d.ts +33 -27
- package/dist/tools/find-component-hosts.js +27 -24
- package/dist/tools/find-usages.d.ts +25 -23
- package/dist/tools/find-usages.js +21 -18
- package/dist/tools/get-bootstrap-execution.d.ts +35 -27
- package/dist/tools/get-bootstrap-execution.js +28 -25
- package/dist/tools/get-call-graph.d.ts +19 -14
- package/dist/tools/get-call-graph.js +26 -23
- 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 +123 -36
- package/dist/tools/helpers/project-cache.js +227 -43
- 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/scan-plan.d.ts +1 -1
- package/dist/tools/helpers/scan-plan.js +1 -1
- 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 +34 -27
- package/dist/tools/inspect-form-group.js +27 -24
- package/dist/tools/inspect-i18n.d.ts +31 -25
- package/dist/tools/inspect-i18n.js +23 -20
- package/dist/tools/inspect-template.d.ts +32 -25
- package/dist/tools/inspect-template.js +26 -23
- package/dist/tools/learn-patterns.d.ts +88 -12
- package/dist/tools/learn-patterns.js +17 -11
- package/dist/tools/list-imports.d.ts +45 -28
- package/dist/tools/list-imports.js +26 -23
- 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 +67 -27
- package/dist/tools/plan-migration.js +22 -21
- package/dist/tools/resolve-type.d.ts +20 -10
- package/dist/tools/resolve-type.js +21 -13
- 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 +32 -26
- package/dist/tools/search-codebase.js +15 -12
- 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 +34 -27
- package/dist/tools/trace-output-flow.js +27 -24
- package/dist/tools/transform-code.d.ts +71 -10
- package/dist/tools/transform-code.js +148 -54
- package/dist/tools/validate-before-transform.d.ts +24 -9
- package/dist/tools/validate-before-transform.js +10 -7
- package/dist/tools/validate-project-compatibility.d.ts +18 -13
- package/dist/tools/validate-project-compatibility.js +17 -11
- package/dist/tools/validate-transformation.d.ts +28 -11
- package/dist/tools/validate-transformation.js +14 -8
- package/dist/tools/verify-citations.d.ts +37 -16
- package/dist/tools/verify-citations.js +19 -16
- package/dist/types.d.ts +40 -10
- package/dist/types.js +0 -5
- package/package.json +12 -18
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.js +0 -7
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - 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: {
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Parse Stack Trace Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for parsing Node.js/Angular/Zone.js/browser stack traces into structured frames.
|
|
5
|
-
* Maps each frame to its source file and classifies it as a project file or external dependency.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Use this as the first step in bug investigation when a stack trace is available.
|
|
9
|
-
* The structured output can be fed directly into `find-usages` or `get-call-graph`
|
|
10
|
-
* to trace the root cause of an error.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Via MCP:
|
|
15
|
-
* // tool: parse-stack-trace
|
|
16
|
-
* // args: { stackTrace: error.stack, projectRoot: '/my/project/src' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
20
2
|
import { type StackFrame, type StackFrameFileIndex } from '@angular-modernizer/api';
|
|
21
3
|
/**
|
|
22
4
|
* Output of the parse-stack-trace tool.
|
|
23
5
|
*/
|
|
24
|
-
interface ParseStackTraceOutput {
|
|
6
|
+
export interface ParseStackTraceOutput {
|
|
25
7
|
/** All parsed frames (or only project frames when `projectFramesOnly` is true). */
|
|
26
8
|
frames: StackFrame[];
|
|
27
9
|
/** Number of frames that belong to the project. */
|
|
@@ -32,7 +14,20 @@ interface ParseStackTraceOutput {
|
|
|
32
14
|
summary: string;
|
|
33
15
|
}
|
|
34
16
|
/**
|
|
35
|
-
* MCP tool
|
|
17
|
+
* MCP tool for parsing Node.js/Angular/Zone.js/browser stack traces into structured frames.
|
|
18
|
+
* Maps each frame to its source file and classifies it as a project file or external dependency.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Use this as the first step in bug investigation when a stack trace is available.
|
|
22
|
+
* The structured output can be fed directly into `find-usages` or `get-call-graph`
|
|
23
|
+
* to trace the root cause of an error.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Via MCP:
|
|
28
|
+
* // tool: parse-stack-trace
|
|
29
|
+
* // args: { stackTrace: error.stack, projectRoot: '/my/project/src' }
|
|
30
|
+
* ```
|
|
36
31
|
*/
|
|
37
32
|
export declare class ParseStackTraceTool implements MCPTool {
|
|
38
33
|
private readonly createFileIndex;
|
|
@@ -41,6 +36,10 @@ export declare class ParseStackTraceTool implements MCPTool {
|
|
|
41
36
|
readonly annotations: ToolAnnotations;
|
|
42
37
|
constructor(createFileIndex?: (projectRoot: string) => StackFrameFileIndex);
|
|
43
38
|
readonly description: string;
|
|
39
|
+
/**
|
|
40
|
+
* JSON Schema of the tool arguments.
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
44
43
|
readonly inputSchema: {
|
|
45
44
|
type: string;
|
|
46
45
|
additionalProperties: boolean;
|
|
@@ -61,6 +60,10 @@ export declare class ParseStackTraceTool implements MCPTool {
|
|
|
61
60
|
};
|
|
62
61
|
required: string[];
|
|
63
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
64
67
|
readonly outputSchema: {
|
|
65
68
|
type: string;
|
|
66
69
|
properties: {
|
|
@@ -116,5 +119,4 @@ export declare class ParseStackTraceTool implements MCPTool {
|
|
|
116
119
|
execute(args: Record<string, unknown>): Promise<ParseStackTraceOutput>;
|
|
117
120
|
private buildSummary;
|
|
118
121
|
}
|
|
119
|
-
export {};
|
|
120
122
|
//# sourceMappingURL=parse-stack-trace.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StackTraceParser, } from '@angular-modernizer/api';
|
|
2
|
+
import { createNodeStackFrameFileIndex } from './helpers/stack-frame-file-index.js';
|
|
1
3
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Parse Stack Trace Tool
|
|
3
|
-
*
|
|
4
4
|
* MCP tool for parsing Node.js/Angular/Zone.js/browser stack traces into structured frames.
|
|
5
5
|
* Maps each frame to its source file and classifies it as a project file or external dependency.
|
|
6
6
|
*
|
|
@@ -16,11 +16,6 @@
|
|
|
16
16
|
* // args: { stackTrace: error.stack, projectRoot: '/my/project/src' }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { StackTraceParser, } from '@angular-modernizer/api';
|
|
20
|
-
import { createNodeStackFrameFileIndex } from './helpers/stack-frame-file-index.js';
|
|
21
|
-
/**
|
|
22
|
-
* MCP tool that parses stack traces into structured, LLM-consumable frames.
|
|
23
|
-
*/
|
|
24
19
|
export class ParseStackTraceTool {
|
|
25
20
|
createFileIndex;
|
|
26
21
|
name = 'parse-stack-trace';
|
|
@@ -40,6 +35,10 @@ export class ParseStackTraceTool {
|
|
|
40
35
|
'Browser frames (http://host/src/..., webpack:///, ng:///, bare file names) are mapped ' +
|
|
41
36
|
'onto project files via resolvedFile; an ambiguous file name lists candidates. ' +
|
|
42
37
|
'Use as the first step in bug investigation when a stack trace is available.';
|
|
38
|
+
/**
|
|
39
|
+
* JSON Schema of the tool arguments.
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
43
42
|
inputSchema = {
|
|
44
43
|
type: 'object',
|
|
45
44
|
additionalProperties: false,
|
|
@@ -60,6 +59,10 @@ export class ParseStackTraceTool {
|
|
|
60
59
|
},
|
|
61
60
|
required: ['stackTrace', 'projectRoot'],
|
|
62
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
63
66
|
outputSchema = {
|
|
64
67
|
type: 'object',
|
|
65
68
|
properties: {
|
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Plan Migration Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for creating optimal migration strategies based on
|
|
5
|
-
* detected architectural issues, SOLID principle violations,
|
|
6
|
-
* and codebase style conventions. Integrates with the self-learning
|
|
7
|
-
* pattern infrastructure for style-aware migration planning.
|
|
8
|
-
*
|
|
9
|
-
* Enhancement: Style-aware migration planning that respects
|
|
10
|
-
* existing codebase conventions (RxJS patterns, DI style, etc.)
|
|
11
|
-
*
|
|
12
|
-
* Scan-based planning: when violations carry `filePath` (inline or from a
|
|
13
|
-
* saved scan-architecture result via `scanResultFile`) and `projectRoot` is
|
|
14
|
-
* set, the roadmap is built from the files themselves: grouped per file and
|
|
15
|
-
* layer, ordered dependencies first along the import graph, import cycles
|
|
16
|
-
* kept together (core `buildViolationPlan`). Otherwise the strategy templates
|
|
17
|
-
* decide the roadmap as before.
|
|
18
|
-
*/
|
|
19
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
20
2
|
import { type ProjectCache } from './helpers/project-cache.js';
|
|
21
3
|
import type { PlannedFile, PlannedPhase, ViolationPlan } from '@angular-modernizer/core';
|
|
22
4
|
/**
|
|
23
5
|
* Style-aware risk assessment result
|
|
24
6
|
*/
|
|
25
|
-
interface StyleAwareRiskAssessment {
|
|
7
|
+
export interface StyleAwareRiskAssessment {
|
|
8
|
+
/** Overall risk from 0 to 100: base risk, style deviation and team context. */
|
|
26
9
|
overallRisk: number;
|
|
10
|
+
/** Risk level of `overallRisk`: below 30 low, below 50 medium, below 70 high, else critical. */
|
|
27
11
|
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
12
|
+
/** Average deviation of the steps from the codebase style, 0 to 100. */
|
|
28
13
|
styleDeviationScore: number;
|
|
14
|
+
/** Recommendations to keep the codebase style. */
|
|
29
15
|
styleRecommendations: string[];
|
|
16
|
+
/** Measures that lower the risk. */
|
|
30
17
|
mitigations: {
|
|
18
|
+
/** Area of the mitigation, e.g. `style` or `technical`. */
|
|
31
19
|
category: string;
|
|
20
|
+
/** What to do. */
|
|
32
21
|
description: string;
|
|
22
|
+
/** Expected risk reduction in points. */
|
|
33
23
|
riskReduction: number;
|
|
24
|
+
/** Effort of the mitigation. */
|
|
34
25
|
effort: 'low' | 'medium' | 'high';
|
|
35
26
|
}[];
|
|
36
27
|
}
|
|
37
28
|
/**
|
|
38
29
|
* Migration step definition.
|
|
39
30
|
*/
|
|
40
|
-
interface MigrationStep {
|
|
31
|
+
export interface MigrationStep {
|
|
41
32
|
/**
|
|
42
33
|
* Step name.
|
|
43
34
|
*/
|
|
@@ -62,7 +53,7 @@ interface MigrationStep {
|
|
|
62
53
|
/**
|
|
63
54
|
* Migration strategy definition.
|
|
64
55
|
*/
|
|
65
|
-
interface MigrationStrategy {
|
|
56
|
+
export interface MigrationStrategy {
|
|
66
57
|
/**
|
|
67
58
|
* Strategy ID.
|
|
68
59
|
*/
|
|
@@ -111,7 +102,7 @@ interface MigrationStrategy {
|
|
|
111
102
|
/**
|
|
112
103
|
* Plan migration tool result.
|
|
113
104
|
*/
|
|
114
|
-
interface PlanMigrationResult {
|
|
105
|
+
export interface PlanMigrationResult {
|
|
115
106
|
/**
|
|
116
107
|
* Recommended migration strategy.
|
|
117
108
|
*/
|
|
@@ -124,21 +115,31 @@ interface PlanMigrationResult {
|
|
|
124
115
|
* Strategy selection reasoning.
|
|
125
116
|
*/
|
|
126
117
|
reasoning: {
|
|
118
|
+
/** Main factors behind the choice. */
|
|
127
119
|
primaryFactors: string[];
|
|
120
|
+
/** How the constraints influenced the choice. */
|
|
128
121
|
constraintImpact: string[];
|
|
122
|
+
/** Risk assessment of the choice. */
|
|
129
123
|
riskAssessment: string;
|
|
130
124
|
};
|
|
131
125
|
/**
|
|
132
126
|
* Implementation roadmap.
|
|
133
127
|
*/
|
|
134
128
|
roadmap: {
|
|
129
|
+
/** Roadmap stages in execution order. */
|
|
135
130
|
phases: {
|
|
131
|
+
/** Stage name. */
|
|
136
132
|
name: string;
|
|
133
|
+
/** Estimated duration as text. */
|
|
137
134
|
duration: string;
|
|
135
|
+
/** Steps of the stage. */
|
|
138
136
|
steps: MigrationStep[];
|
|
137
|
+
/** Results of the stage. */
|
|
139
138
|
deliverables: string[];
|
|
140
139
|
}[];
|
|
140
|
+
/** Estimated total duration as text. */
|
|
141
141
|
totalDuration: string;
|
|
142
|
+
/** Milestones of the roadmap. */
|
|
142
143
|
milestones: string[];
|
|
143
144
|
};
|
|
144
145
|
/**
|
|
@@ -166,18 +167,26 @@ interface PlanMigrationResult {
|
|
|
166
167
|
* Steps that conflict with codebase style conventions.
|
|
167
168
|
*/
|
|
168
169
|
styleConflictingSteps?: {
|
|
170
|
+
/** Name of the conflicting step. */
|
|
169
171
|
stepName: string;
|
|
172
|
+
/** Why the step conflicts with the codebase style. */
|
|
170
173
|
conflictReason: string;
|
|
174
|
+
/** How to keep the style. */
|
|
171
175
|
styleRecommendation: string;
|
|
172
176
|
}[];
|
|
173
177
|
/**
|
|
174
178
|
* Style preservation recommendations.
|
|
175
179
|
*/
|
|
176
180
|
styleRecommendations?: {
|
|
181
|
+
/** Style area. */
|
|
177
182
|
category: 'rxjs' | 'di' | 'state-management' | 'naming' | 'architecture';
|
|
183
|
+
/** Current style of the codebase. */
|
|
178
184
|
currentStyle: string;
|
|
185
|
+
/** Recommendation. */
|
|
179
186
|
recommendation: string;
|
|
187
|
+
/** Why the recommendation applies. */
|
|
180
188
|
reasoning: string;
|
|
189
|
+
/** Names of the affected steps. */
|
|
181
190
|
affectedSteps: string[];
|
|
182
191
|
}[];
|
|
183
192
|
/**
|
|
@@ -188,9 +197,13 @@ interface PlanMigrationResult {
|
|
|
188
197
|
* Migration steps with style alignment scores.
|
|
189
198
|
*/
|
|
190
199
|
stepsWithStyleAnalysis?: {
|
|
200
|
+
/** The analyzed step. */
|
|
191
201
|
step: MigrationStep;
|
|
202
|
+
/** Style alignment score of the step. */
|
|
192
203
|
styleAlignmentScore: number;
|
|
204
|
+
/** `true` when the score reaches `styleAlignmentThreshold`. */
|
|
193
205
|
alignsWithStyle: boolean;
|
|
206
|
+
/** Style problems of the step. */
|
|
194
207
|
styleWarnings: string[];
|
|
195
208
|
}[];
|
|
196
209
|
/**
|
|
@@ -206,24 +219,44 @@ interface PlanMigrationResult {
|
|
|
206
219
|
/**
|
|
207
220
|
* File-level plan in the tool output.
|
|
208
221
|
*/
|
|
209
|
-
interface ScanPlanOutput {
|
|
222
|
+
export interface ScanPlanOutput {
|
|
223
|
+
/** Short text of the file-level plan. */
|
|
210
224
|
summary: string;
|
|
211
225
|
/** List cap in effect (files per phase, violations per file); absent with summaryOnly. */
|
|
212
226
|
maxResults?: number;
|
|
227
|
+
/** Where the layers came from: `layersSource`, `layers` or none. */
|
|
213
228
|
layerSource: 'layersSource' | 'layers' | 'none';
|
|
229
|
+
/** Files of the import graph (size of the analyzed program). */
|
|
214
230
|
graphFiles: number;
|
|
231
|
+
/** Plan statistics from core `buildViolationPlan`. */
|
|
215
232
|
stats: ViolationPlan['stats'];
|
|
233
|
+
/** Import cycles kept together in the plan. */
|
|
216
234
|
cycles: ViolationPlan['cycles'];
|
|
235
|
+
/** Plan phases, one per dependency level, dependencies first. */
|
|
217
236
|
phases: (Omit<PlannedPhase, 'files'> & {
|
|
237
|
+
/** Files of the phase, cut to `maxResults`; absent with summaryOnly. */
|
|
218
238
|
files?: (PlannedFile & {
|
|
239
|
+
/** `true` when `maxResults` cut the violations of the file. */
|
|
219
240
|
violationsTruncated?: boolean;
|
|
220
241
|
})[];
|
|
242
|
+
/** `true` when `maxResults` cut the file list. */
|
|
221
243
|
truncated?: boolean;
|
|
222
244
|
})[];
|
|
245
|
+
/** Problems while building the plan, e.g. violation files outside the TypeScript program. */
|
|
223
246
|
warnings: string[];
|
|
224
247
|
}
|
|
225
248
|
/**
|
|
226
|
-
* MCP tool
|
|
249
|
+
* MCP tool `plan-migration`: builds a migration strategy and roadmap from
|
|
250
|
+
* detected architecture and SOLID violations and, with a style profile from
|
|
251
|
+
* learn-patterns, from the codebase conventions (RxJS patterns, DI style).
|
|
252
|
+
*
|
|
253
|
+
* @remarks
|
|
254
|
+
* Scan-based planning: when violations carry `filePath` (inline or from a
|
|
255
|
+
* saved scan-architecture result via `scanResultFile`) and `projectRoot` is
|
|
256
|
+
* set, the roadmap is built from the files themselves: grouped per file and
|
|
257
|
+
* layer, ordered dependencies first along the import graph, import cycles
|
|
258
|
+
* kept together (core `buildViolationPlan`, `planSource: 'scan'`). Otherwise
|
|
259
|
+
* the strategy templates decide the roadmap (`planSource: 'template'`).
|
|
227
260
|
*/
|
|
228
261
|
export declare class PlanMigrationTool implements MCPTool {
|
|
229
262
|
private readonly projects?;
|
|
@@ -236,6 +269,10 @@ export declare class PlanMigrationTool implements MCPTool {
|
|
|
236
269
|
title: string;
|
|
237
270
|
annotations: ToolAnnotations;
|
|
238
271
|
description: string;
|
|
272
|
+
/**
|
|
273
|
+
* JSON Schema of the tool arguments.
|
|
274
|
+
* @hidden
|
|
275
|
+
*/
|
|
239
276
|
inputSchema: {
|
|
240
277
|
type: string;
|
|
241
278
|
additionalProperties: boolean;
|
|
@@ -432,6 +469,10 @@ export declare class PlanMigrationTool implements MCPTool {
|
|
|
432
469
|
};
|
|
433
470
|
required: never[];
|
|
434
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
474
|
+
* @hidden
|
|
475
|
+
*/
|
|
435
476
|
outputSchema: {
|
|
436
477
|
type: string;
|
|
437
478
|
properties: {
|
|
@@ -749,7 +790,7 @@ export declare class PlanMigrationTool implements MCPTool {
|
|
|
749
790
|
};
|
|
750
791
|
required: string[];
|
|
751
792
|
};
|
|
752
|
-
execute(args: Record<string, unknown
|
|
793
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<PlanMigrationResult>;
|
|
753
794
|
/**
|
|
754
795
|
* Inline violations plus the ones from scanResultFile.
|
|
755
796
|
*/
|
|
@@ -801,5 +842,4 @@ export declare class PlanMigrationTool implements MCPTool {
|
|
|
801
842
|
*/
|
|
802
843
|
private generateSuccessMetrics;
|
|
803
844
|
}
|
|
804
|
-
export {};
|
|
805
845
|
//# sourceMappingURL=plan-migration.d.ts.map
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Plan Migration Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for creating optimal migration strategies based on
|
|
5
|
-
* detected architectural issues, SOLID principle violations,
|
|
6
|
-
* and codebase style conventions. Integrates with the self-learning
|
|
7
|
-
* pattern infrastructure for style-aware migration planning.
|
|
8
|
-
*
|
|
9
|
-
* Enhancement: Style-aware migration planning that respects
|
|
10
|
-
* existing codebase conventions (RxJS patterns, DI style, etc.)
|
|
11
|
-
*
|
|
12
|
-
* Scan-based planning: when violations carry `filePath` (inline or from a
|
|
13
|
-
* saved scan-architecture result via `scanResultFile`) and `projectRoot` is
|
|
14
|
-
* set, the roadmap is built from the files themselves: grouped per file and
|
|
15
|
-
* layer, ordered dependencies first along the import graph, import cycles
|
|
16
|
-
* kept together (core `buildViolationPlan`). Otherwise the strategy templates
|
|
17
|
-
* decide the roadmap as before.
|
|
18
|
-
*/
|
|
19
1
|
import { isAbsolute, resolve } from 'node:path';
|
|
2
|
+
import { acquireProject } from './helpers/project-cache.js';
|
|
20
3
|
import { nameList } from './helpers/analysis-output.js';
|
|
21
4
|
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
22
5
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings } from './helpers/output-contract.js';
|
|
@@ -94,7 +77,17 @@ function describePlan(plan) {
|
|
|
94
77
|
return lines.join('\n');
|
|
95
78
|
}
|
|
96
79
|
/**
|
|
97
|
-
* MCP tool
|
|
80
|
+
* MCP tool `plan-migration`: builds a migration strategy and roadmap from
|
|
81
|
+
* detected architecture and SOLID violations and, with a style profile from
|
|
82
|
+
* learn-patterns, from the codebase conventions (RxJS patterns, DI style).
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* Scan-based planning: when violations carry `filePath` (inline or from a
|
|
86
|
+
* saved scan-architecture result via `scanResultFile`) and `projectRoot` is
|
|
87
|
+
* set, the roadmap is built from the files themselves: grouped per file and
|
|
88
|
+
* layer, ordered dependencies first along the import graph, import cycles
|
|
89
|
+
* kept together (core `buildViolationPlan`, `planSource: 'scan'`). Otherwise
|
|
90
|
+
* the strategy templates decide the roadmap (`planSource: 'template'`).
|
|
98
91
|
*/
|
|
99
92
|
export class PlanMigrationTool {
|
|
100
93
|
projects;
|
|
@@ -118,6 +111,10 @@ export class PlanMigrationTool {
|
|
|
118
111
|
'scanResultFile) the roadmap names concrete files: grouped per file and layer, ordered dependencies ' +
|
|
119
112
|
'first along the import graph, import cycles kept together (planSource "scan"). Without file paths ' +
|
|
120
113
|
'the strategy templates decide the roadmap (planSource "template"). summary is a short text of strategy and roadmap.';
|
|
114
|
+
/**
|
|
115
|
+
* JSON Schema of the tool arguments.
|
|
116
|
+
* @hidden
|
|
117
|
+
*/
|
|
121
118
|
inputSchema = {
|
|
122
119
|
type: 'object',
|
|
123
120
|
additionalProperties: false,
|
|
@@ -280,6 +277,10 @@ export class PlanMigrationTool {
|
|
|
280
277
|
// (scanResultFile or violations with filePath); checked in execute()
|
|
281
278
|
required: [],
|
|
282
279
|
};
|
|
280
|
+
/**
|
|
281
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
282
|
+
* @hidden
|
|
283
|
+
*/
|
|
283
284
|
outputSchema = {
|
|
284
285
|
type: 'object',
|
|
285
286
|
properties: {
|
|
@@ -350,7 +351,7 @@ export class PlanMigrationTool {
|
|
|
350
351
|
'summary',
|
|
351
352
|
],
|
|
352
353
|
};
|
|
353
|
-
async execute(args) {
|
|
354
|
+
async execute(args, ctx = {}) {
|
|
354
355
|
const params = args;
|
|
355
356
|
const compact = parseCompactOptions(args);
|
|
356
357
|
const projectRoot = typeof params.projectRoot === 'string' ? params.projectRoot : undefined;
|
|
@@ -422,7 +423,7 @@ export class PlanMigrationTool {
|
|
|
422
423
|
? {
|
|
423
424
|
loadProject: (path) => {
|
|
424
425
|
cachedTsConfig = path;
|
|
425
|
-
return projects
|
|
426
|
+
return acquireProject(projects, path, ctx);
|
|
426
427
|
},
|
|
427
428
|
}
|
|
428
429
|
: {}),
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
|
+
import { type ResolvedTypeInfo } from '@angular-modernizer/api';
|
|
3
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
1
4
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Resolve Type Tool
|
|
3
|
-
*
|
|
4
5
|
* MCP tool for resolving the TypeScript type at a given source position.
|
|
5
6
|
* Returns the type string, nullability, async status, and declaration origin.
|
|
6
7
|
*
|
|
7
8
|
* @remarks
|
|
8
9
|
* Use during bug investigation to understand what type a variable or expression
|
|
9
|
-
* holds at a specific line/column
|
|
10
|
+
* holds at a specific line/column - especially useful for tracking down
|
|
10
11
|
* null-reference errors or incorrect generic type assumptions.
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
@@ -16,12 +17,6 @@
|
|
|
16
17
|
* // args: { file: '/project/src/app/user.service.ts', line: 42, column: 15, projectRoot: '/project' }
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
20
|
-
import { type ResolvedTypeInfo } from '@angular-modernizer/api';
|
|
21
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
22
|
-
/**
|
|
23
|
-
* MCP tool that resolves the TypeScript type at a given source position.
|
|
24
|
-
*/
|
|
25
20
|
export declare class ResolveTypeTool implements MCPTool {
|
|
26
21
|
private readonly projects;
|
|
27
22
|
readonly name = "resolve-type";
|
|
@@ -29,6 +24,10 @@ export declare class ResolveTypeTool implements MCPTool {
|
|
|
29
24
|
readonly annotations: ToolAnnotations;
|
|
30
25
|
constructor(projects?: ProjectCache);
|
|
31
26
|
readonly description: string;
|
|
27
|
+
/**
|
|
28
|
+
* JSON Schema of the tool arguments.
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
32
31
|
readonly inputSchema: {
|
|
33
32
|
type: string;
|
|
34
33
|
additionalProperties: boolean;
|
|
@@ -52,6 +51,10 @@ export declare class ResolveTypeTool implements MCPTool {
|
|
|
52
51
|
};
|
|
53
52
|
required: string[];
|
|
54
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
55
58
|
readonly outputSchema: {
|
|
56
59
|
type: string;
|
|
57
60
|
properties: {
|
|
@@ -86,8 +89,15 @@ export declare class ResolveTypeTool implements MCPTool {
|
|
|
86
89
|
};
|
|
87
90
|
required: string[];
|
|
88
91
|
};
|
|
89
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Resolves the type at `file`, `line` and `column`.
|
|
94
|
+
* @param args - Tool arguments validated against the input schema
|
|
95
|
+
* @returns The resolved type with a text summary
|
|
96
|
+
*/
|
|
97
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ResolvedTypeInfo & {
|
|
98
|
+
/** Short text summary of the resolved type. */
|
|
90
99
|
summary: string;
|
|
100
|
+
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
91
101
|
warnings?: string[];
|
|
92
102
|
}>;
|
|
93
103
|
private buildSummary;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { TypeResolver } from '@angular-modernizer/api';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
|
+
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
1
6
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Resolve Type Tool
|
|
3
|
-
*
|
|
4
7
|
* MCP tool for resolving the TypeScript type at a given source position.
|
|
5
8
|
* Returns the type string, nullability, async status, and declaration origin.
|
|
6
9
|
*
|
|
7
10
|
* @remarks
|
|
8
11
|
* Use during bug investigation to understand what type a variable or expression
|
|
9
|
-
* holds at a specific line/column
|
|
12
|
+
* holds at a specific line/column - especially useful for tracking down
|
|
10
13
|
* null-reference errors or incorrect generic type assumptions.
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
@@ -16,14 +19,6 @@
|
|
|
16
19
|
* // args: { file: '/project/src/app/user.service.ts', line: 42, column: 15, projectRoot: '/project' }
|
|
17
20
|
* ```
|
|
18
21
|
*/
|
|
19
|
-
import { TypeResolver } from '@angular-modernizer/api';
|
|
20
|
-
import { existsSync } from 'node:fs';
|
|
21
|
-
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
22
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
23
|
-
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
24
|
-
/**
|
|
25
|
-
* MCP tool that resolves the TypeScript type at a given source position.
|
|
26
|
-
*/
|
|
27
22
|
export class ResolveTypeTool {
|
|
28
23
|
projects;
|
|
29
24
|
name = 'resolve-type';
|
|
@@ -41,6 +36,10 @@ export class ResolveTypeTool {
|
|
|
41
36
|
'Returns the full type string, nullability, whether it is async (Promise/Observable), ' +
|
|
42
37
|
'and where the type is declared. Use during bug investigation to trace type mismatches ' +
|
|
43
38
|
'and null-reference errors.';
|
|
39
|
+
/**
|
|
40
|
+
* JSON Schema of the tool arguments.
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
44
43
|
inputSchema = {
|
|
45
44
|
type: 'object',
|
|
46
45
|
additionalProperties: false,
|
|
@@ -64,6 +63,10 @@ export class ResolveTypeTool {
|
|
|
64
63
|
},
|
|
65
64
|
required: ['file', 'line', 'column', 'projectRoot'],
|
|
66
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
68
|
+
* @hidden
|
|
69
|
+
*/
|
|
67
70
|
outputSchema = {
|
|
68
71
|
type: 'object',
|
|
69
72
|
properties: {
|
|
@@ -84,7 +87,12 @@ export class ResolveTypeTool {
|
|
|
84
87
|
'summary',
|
|
85
88
|
],
|
|
86
89
|
};
|
|
87
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Resolves the type at `file`, `line` and `column`.
|
|
92
|
+
* @param args - Tool arguments validated against the input schema
|
|
93
|
+
* @returns The resolved type with a text summary
|
|
94
|
+
*/
|
|
95
|
+
async execute(args, ctx = {}) {
|
|
88
96
|
const params = args;
|
|
89
97
|
if (!params.file) {
|
|
90
98
|
throw new Error('file is required');
|
|
@@ -105,7 +113,7 @@ export class ResolveTypeTool {
|
|
|
105
113
|
if (!tsConfigPath) {
|
|
106
114
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
107
115
|
}
|
|
108
|
-
const project = this.projects
|
|
116
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
109
117
|
const typeResolver = new TypeResolver(project);
|
|
110
118
|
const info = typeResolver.resolveType(params.file, params.line, params.column);
|
|
111
119
|
return withWarnings({
|