@angular-modernizer/adapter-mcp 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -235
- package/dist/cli.js +77 -27
- package/dist/index.d.ts +11 -3
- package/dist/index.js +10 -2
- package/dist/mcp-watcher.d.ts +6 -1
- package/dist/mcp-watcher.js +14 -10
- package/dist/server/limited-stdio-transport.d.ts +68 -0
- package/dist/server/limited-stdio-transport.js +115 -0
- package/dist/server/mcp-server.d.ts +41 -12
- package/dist/server/mcp-server.js +113 -94
- package/dist/server/package-version.d.ts +16 -0
- package/dist/server/package-version.js +37 -0
- package/dist/server/sdk-server.d.ts +70 -0
- package/dist/server/sdk-server.js +113 -0
- package/dist/server/stdio-guard.d.ts +20 -0
- package/dist/server/stdio-guard.js +48 -0
- package/dist/server/tool-registry.d.ts +3 -2
- package/dist/server/tool-registry.js +5 -5
- package/dist/tools/analyze-build-impact.d.ts +346 -14
- package/dist/tools/analyze-build-impact.js +315 -31
- package/dist/tools/analyze-core-to-shared.d.ts +134 -4
- package/dist/tools/analyze-core-to-shared.js +113 -9
- package/dist/tools/analyze-parser-performance.d.ts +200 -7
- package/dist/tools/analyze-parser-performance.js +108 -47
- package/dist/tools/analyze-project.d.ts +267 -5
- package/dist/tools/analyze-project.js +196 -8
- package/dist/tools/check-incremental-compatibility.d.ts +61 -1
- package/dist/tools/check-incremental-compatibility.js +58 -2
- package/dist/tools/collect-feedback.d.ts +199 -10
- package/dist/tools/collect-feedback.js +171 -99
- package/dist/tools/compare-health.d.ts +356 -0
- package/dist/tools/compare-health.js +472 -0
- package/dist/tools/extract-libraries.d.ts +156 -4
- package/dist/tools/extract-libraries.js +115 -10
- package/dist/tools/find-angular-symbol.d.ts +98 -9
- package/dist/tools/find-angular-symbol.js +104 -12
- package/dist/tools/find-component-hosts.d.ts +684 -0
- package/dist/tools/find-component-hosts.js +441 -0
- package/dist/tools/find-usages.d.ts +99 -4
- package/dist/tools/find-usages.js +131 -11
- package/dist/tools/get-bootstrap-execution.d.ts +258 -0
- package/dist/tools/get-bootstrap-execution.js +324 -0
- package/dist/tools/get-call-graph.d.ts +139 -4
- package/dist/tools/get-call-graph.js +123 -13
- package/dist/tools/get-operation-progress-tool.d.ts +114 -2
- package/dist/tools/get-operation-progress-tool.js +114 -7
- package/dist/tools/get-operation-progress.d.ts +1 -1
- package/dist/tools/get-operation-progress.js +5 -5
- package/dist/tools/helpers/analysis-output.d.ts +177 -0
- package/dist/tools/helpers/analysis-output.js +165 -0
- package/dist/tools/helpers/build-schemas.d.ts +36 -0
- package/dist/tools/helpers/build-schemas.js +23 -0
- package/dist/tools/helpers/citation-file-source.d.ts +10 -0
- package/dist/tools/helpers/citation-file-source.js +82 -0
- package/dist/tools/helpers/compact-output.d.ts +61 -0
- package/dist/tools/helpers/compact-output.js +83 -0
- package/dist/tools/helpers/finding-window.d.ts +43 -0
- package/dist/tools/helpers/finding-window.js +64 -0
- package/dist/tools/helpers/health-delta.d.ts +86 -0
- package/dist/tools/helpers/health-delta.js +239 -0
- package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
- package/dist/tools/helpers/investigation-schemas.js +48 -0
- package/dist/tools/helpers/library-imports.d.ts +57 -0
- package/dist/tools/helpers/library-imports.js +151 -0
- package/dist/tools/helpers/load-source-files.d.ts +30 -0
- package/dist/tools/helpers/load-source-files.js +34 -0
- package/dist/tools/helpers/output-contract.d.ts +32 -0
- package/dist/tools/helpers/output-contract.js +32 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
- package/dist/tools/helpers/platform-root-resolver.js +75 -48
- package/dist/tools/helpers/process-output.d.ts +19 -0
- package/dist/tools/helpers/process-output.js +31 -0
- package/dist/tools/helpers/project-cache.d.ts +184 -0
- package/dist/tools/helpers/project-cache.js +331 -0
- package/dist/tools/helpers/project-decorators.d.ts +14 -0
- package/dist/tools/helpers/project-decorators.js +22 -0
- package/dist/tools/helpers/rule-matcher.js +5 -0
- package/dist/tools/helpers/rule-runner.d.ts +72 -0
- package/dist/tools/helpers/rule-runner.js +131 -0
- package/dist/tools/helpers/scan-cache.d.ts +22 -0
- package/dist/tools/helpers/scan-cache.js +34 -0
- package/dist/tools/helpers/scan-plan.d.ts +48 -0
- package/dist/tools/helpers/scan-plan.js +166 -0
- package/dist/tools/helpers/scope-paths.d.ts +17 -0
- package/dist/tools/helpers/scope-paths.js +32 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
- package/dist/tools/helpers/stack-frame-file-index.js +71 -0
- package/dist/tools/helpers/tool-context.d.ts +60 -0
- package/dist/tools/helpers/tool-context.js +82 -0
- package/dist/tools/helpers/transform-safety.d.ts +40 -0
- package/dist/tools/helpers/transform-safety.js +87 -0
- package/dist/tools/helpers/validation-output.d.ts +53 -0
- package/dist/tools/helpers/validation-output.js +48 -0
- package/dist/tools/inspect-form-group.d.ts +324 -0
- package/dist/tools/inspect-form-group.js +279 -0
- package/dist/tools/inspect-i18n.d.ts +466 -0
- package/dist/tools/inspect-i18n.js +400 -0
- package/dist/tools/inspect-template.d.ts +320 -0
- package/dist/tools/inspect-template.js +324 -0
- package/dist/tools/learn-patterns.d.ts +122 -1
- package/dist/tools/learn-patterns.js +97 -2
- package/dist/tools/list-imports.d.ts +128 -11
- package/dist/tools/list-imports.js +128 -8
- package/dist/tools/orchestrate-migration.d.ts +129 -5
- package/dist/tools/orchestrate-migration.js +166 -12
- package/dist/tools/parse-stack-trace.d.ts +59 -2
- package/dist/tools/parse-stack-trace.js +52 -4
- package/dist/tools/plan-migration.d.ts +418 -1
- package/dist/tools/plan-migration.js +355 -8
- package/dist/tools/resolve-type.d.ts +42 -1
- package/dist/tools/resolve-type.js +37 -4
- package/dist/tools/review-feedback.d.ts +206 -11
- package/dist/tools/review-feedback.js +132 -51
- package/dist/tools/rollback-changes.d.ts +79 -2
- package/dist/tools/rollback-changes.js +66 -14
- package/dist/tools/run-angular-cli.d.ts +45 -2
- package/dist/tools/run-angular-cli.js +67 -7
- package/dist/tools/run-build.d.ts +114 -2
- package/dist/tools/run-build.js +117 -8
- package/dist/tools/run-schematic.d.ts +70 -2
- package/dist/tools/run-schematic.js +104 -10
- package/dist/tools/scan-all.d.ts +24 -16
- package/dist/tools/scan-all.js +145 -137
- package/dist/tools/scan-angular.d.ts +20 -11
- package/dist/tools/scan-angular.js +52 -24
- package/dist/tools/scan-architecture.d.ts +42 -14
- package/dist/tools/scan-architecture.js +206 -163
- package/dist/tools/scan-solid.d.ts +20 -11
- package/dist/tools/scan-solid.js +52 -24
- package/dist/tools/search-codebase.d.ts +85 -1
- package/dist/tools/search-codebase.js +61 -4
- package/dist/tools/server-status.d.ts +370 -0
- package/dist/tools/server-status.js +369 -0
- package/dist/tools/suggest-improvements.d.ts +97 -5
- package/dist/tools/suggest-improvements.js +80 -44
- package/dist/tools/trace-output-flow.d.ts +791 -0
- package/dist/tools/trace-output-flow.js +668 -0
- package/dist/tools/transform-code-batch.d.ts +3 -0
- package/dist/tools/transform-code-batch.js +10 -5
- package/dist/tools/transform-code.d.ts +335 -12
- package/dist/tools/transform-code.js +649 -608
- package/dist/tools/validate-before-transform.d.ts +116 -2
- package/dist/tools/validate-before-transform.js +55 -2
- package/dist/tools/validate-project-compatibility.d.ts +64 -2
- package/dist/tools/validate-project-compatibility.js +67 -4
- package/dist/tools/validate-transformation.d.ts +220 -2
- package/dist/tools/validate-transformation.js +113 -15
- package/dist/tools/verify-citations.d.ts +181 -0
- package/dist/tools/verify-citations.js +218 -0
- package/dist/types.d.ts +45 -1
- package/dist/utils/format-tool-response.d.ts +22 -59
- package/dist/utils/format-tool-response.js +25 -134
- package/package.json +30 -13
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/project-analyzer.d.ts.map +0 -1
- package/dist/core/project-analyzer.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp-watcher.d.ts.map +0 -1
- package/dist/mcp-watcher.js.map +0 -1
- package/dist/server/json-rpc-handler.d.ts +0 -57
- package/dist/server/json-rpc-handler.d.ts.map +0 -1
- package/dist/server/json-rpc-handler.js +0 -222
- package/dist/server/json-rpc-handler.js.map +0 -1
- package/dist/server/mcp-server.d.ts.map +0 -1
- package/dist/server/mcp-server.js.map +0 -1
- package/dist/server/tool-registry.d.ts.map +0 -1
- package/dist/server/tool-registry.js.map +0 -1
- package/dist/streaming/progress-store.d.ts.map +0 -1
- package/dist/streaming/progress-store.js.map +0 -1
- package/dist/tools/analyze-build-impact.d.ts.map +0 -1
- package/dist/tools/analyze-build-impact.js.map +0 -1
- package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
- package/dist/tools/analyze-core-to-shared.js.map +0 -1
- package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
- package/dist/tools/analyze-parser-performance.js.map +0 -1
- package/dist/tools/analyze-project.d.ts.map +0 -1
- package/dist/tools/analyze-project.js.map +0 -1
- package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
- package/dist/tools/check-incremental-compatibility.js.map +0 -1
- package/dist/tools/collect-feedback.d.ts.map +0 -1
- package/dist/tools/collect-feedback.js.map +0 -1
- package/dist/tools/extract-libraries.d.ts.map +0 -1
- package/dist/tools/extract-libraries.js.map +0 -1
- package/dist/tools/find-angular-symbol.d.ts.map +0 -1
- package/dist/tools/find-angular-symbol.js.map +0 -1
- package/dist/tools/find-usages.d.ts.map +0 -1
- package/dist/tools/find-usages.js.map +0 -1
- package/dist/tools/get-call-graph.d.ts.map +0 -1
- package/dist/tools/get-call-graph.js.map +0 -1
- package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
- package/dist/tools/get-operation-progress-tool.js.map +0 -1
- package/dist/tools/get-operation-progress.d.ts.map +0 -1
- package/dist/tools/get-operation-progress.js.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
- package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
- package/dist/tools/helpers/find-ts-config.js.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
- package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
- package/dist/tools/helpers/rule-matcher.js.map +0 -1
- package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
- package/dist/tools/helpers/suggestion-generator.js.map +0 -1
- package/dist/tools/learn-patterns.d.ts.map +0 -1
- package/dist/tools/learn-patterns.js.map +0 -1
- package/dist/tools/list-imports.d.ts.map +0 -1
- package/dist/tools/list-imports.js.map +0 -1
- package/dist/tools/orchestrate-migration.d.ts.map +0 -1
- package/dist/tools/orchestrate-migration.js.map +0 -1
- package/dist/tools/parse-stack-trace.d.ts.map +0 -1
- package/dist/tools/parse-stack-trace.js.map +0 -1
- package/dist/tools/plan-migration.d.ts.map +0 -1
- package/dist/tools/plan-migration.js.map +0 -1
- package/dist/tools/resolve-type.d.ts.map +0 -1
- package/dist/tools/resolve-type.js.map +0 -1
- package/dist/tools/review-feedback.d.ts.map +0 -1
- package/dist/tools/review-feedback.js.map +0 -1
- package/dist/tools/rollback-changes.d.ts.map +0 -1
- package/dist/tools/rollback-changes.js.map +0 -1
- package/dist/tools/run-angular-cli.d.ts.map +0 -1
- package/dist/tools/run-angular-cli.js.map +0 -1
- package/dist/tools/run-build.d.ts.map +0 -1
- package/dist/tools/run-build.js.map +0 -1
- package/dist/tools/run-schematic.d.ts.map +0 -1
- package/dist/tools/run-schematic.js.map +0 -1
- package/dist/tools/scan-all.d.ts.map +0 -1
- package/dist/tools/scan-all.js.map +0 -1
- package/dist/tools/scan-angular.d.ts.map +0 -1
- package/dist/tools/scan-angular.js.map +0 -1
- package/dist/tools/scan-architecture.d.ts.map +0 -1
- package/dist/tools/scan-architecture.js.map +0 -1
- package/dist/tools/scan-solid.d.ts.map +0 -1
- package/dist/tools/scan-solid.js.map +0 -1
- package/dist/tools/search-codebase.d.ts.map +0 -1
- package/dist/tools/search-codebase.js.map +0 -1
- package/dist/tools/shared/scan-types.d.ts.map +0 -1
- package/dist/tools/shared/scan-types.js.map +0 -1
- package/dist/tools/suggest-improvements.d.ts.map +0 -1
- package/dist/tools/suggest-improvements.js.map +0 -1
- package/dist/tools/transform-code-batch.d.ts.map +0 -1
- package/dist/tools/transform-code-batch.js.map +0 -1
- package/dist/tools/transform-code.d.ts.map +0 -1
- package/dist/tools/transform-code.js.map +0 -1
- package/dist/tools/validate-before-transform.d.ts.map +0 -1
- package/dist/tools/validate-before-transform.js.map +0 -1
- package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
- package/dist/tools/validate-project-compatibility.js.map +0 -1
- package/dist/tools/validate-transformation.d.ts.map +0 -1
- package/dist/tools/validate-transformation.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/format-tool-response.d.ts.map +0 -1
- package/dist/utils/format-tool-response.js.map +0 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* MCP tool for executing multi-step migration workflows with
|
|
5
5
|
* dependency management, checkpoint/resume, and rollback support.
|
|
6
6
|
*/
|
|
7
|
-
import { type MCPTool } from '../types.js';
|
|
7
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Result from orchestrate-migration tool
|
|
10
10
|
*/
|
|
@@ -14,10 +14,13 @@ interface OrchestrateMigrationResult {
|
|
|
14
14
|
*/
|
|
15
15
|
status: 'completed' | 'failed' | 'partial';
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Workflow that ran
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
workflowId: string;
|
|
20
|
+
/**
|
|
21
|
+
* Step counts and total duration
|
|
22
|
+
*/
|
|
23
|
+
counts: {
|
|
21
24
|
totalSteps: number;
|
|
22
25
|
successfulSteps: number;
|
|
23
26
|
failedSteps: number;
|
|
@@ -61,15 +64,22 @@ interface OrchestrateMigrationResult {
|
|
|
61
64
|
* Message for the user
|
|
62
65
|
*/
|
|
63
66
|
message: string;
|
|
67
|
+
/**
|
|
68
|
+
* Short text: status, step counts, duration, message and the first errors.
|
|
69
|
+
*/
|
|
70
|
+
summary: string;
|
|
64
71
|
}
|
|
65
72
|
/**
|
|
66
73
|
* Orchestrate Migration MCP Tool
|
|
67
74
|
*/
|
|
68
75
|
export declare class OrchestrateMigrationTool implements MCPTool {
|
|
69
76
|
name: string;
|
|
77
|
+
title: string;
|
|
78
|
+
annotations: ToolAnnotations;
|
|
70
79
|
description: string;
|
|
71
80
|
inputSchema: {
|
|
72
81
|
type: string;
|
|
82
|
+
additionalProperties: boolean;
|
|
73
83
|
properties: {
|
|
74
84
|
workflow: {
|
|
75
85
|
type: string;
|
|
@@ -170,6 +180,118 @@ export declare class OrchestrateMigrationTool implements MCPTool {
|
|
|
170
180
|
};
|
|
171
181
|
required: string[];
|
|
172
182
|
};
|
|
183
|
+
outputSchema: {
|
|
184
|
+
type: string;
|
|
185
|
+
properties: {
|
|
186
|
+
status: {
|
|
187
|
+
type: string;
|
|
188
|
+
enum: string[];
|
|
189
|
+
};
|
|
190
|
+
workflowId: {
|
|
191
|
+
type: string;
|
|
192
|
+
};
|
|
193
|
+
counts: {
|
|
194
|
+
type: string;
|
|
195
|
+
properties: {
|
|
196
|
+
totalSteps: {
|
|
197
|
+
type: string;
|
|
198
|
+
};
|
|
199
|
+
successfulSteps: {
|
|
200
|
+
type: string;
|
|
201
|
+
};
|
|
202
|
+
failedSteps: {
|
|
203
|
+
type: string;
|
|
204
|
+
};
|
|
205
|
+
skippedSteps: {
|
|
206
|
+
type: string;
|
|
207
|
+
};
|
|
208
|
+
totalDurationMs: {
|
|
209
|
+
type: string;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
required: string[];
|
|
213
|
+
};
|
|
214
|
+
stepResults: {
|
|
215
|
+
type: string;
|
|
216
|
+
items: {
|
|
217
|
+
type: string;
|
|
218
|
+
properties: {
|
|
219
|
+
stepId: {
|
|
220
|
+
type: string;
|
|
221
|
+
};
|
|
222
|
+
name: {
|
|
223
|
+
type: string;
|
|
224
|
+
};
|
|
225
|
+
status: {
|
|
226
|
+
type: string;
|
|
227
|
+
};
|
|
228
|
+
durationMs: {
|
|
229
|
+
type: string;
|
|
230
|
+
};
|
|
231
|
+
error: {
|
|
232
|
+
type: string;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
required: string[];
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
checkpoints: {
|
|
239
|
+
type: string;
|
|
240
|
+
items: {
|
|
241
|
+
type: string;
|
|
242
|
+
properties: {
|
|
243
|
+
id: {
|
|
244
|
+
type: string;
|
|
245
|
+
};
|
|
246
|
+
stepId: {
|
|
247
|
+
type: string;
|
|
248
|
+
};
|
|
249
|
+
timestamp: {
|
|
250
|
+
type: string;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
required: string[];
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
errors: {
|
|
257
|
+
type: string;
|
|
258
|
+
items: {
|
|
259
|
+
type: string;
|
|
260
|
+
properties: {
|
|
261
|
+
stepId: {
|
|
262
|
+
type: string;
|
|
263
|
+
};
|
|
264
|
+
message: {
|
|
265
|
+
type: string;
|
|
266
|
+
};
|
|
267
|
+
stack: {
|
|
268
|
+
type: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
required: string[];
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
finalCheckpoint: {
|
|
275
|
+
type: string;
|
|
276
|
+
properties: {
|
|
277
|
+
id: {
|
|
278
|
+
type: string;
|
|
279
|
+
};
|
|
280
|
+
canResume: {
|
|
281
|
+
type: string;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
required: string[];
|
|
285
|
+
};
|
|
286
|
+
message: {
|
|
287
|
+
type: string;
|
|
288
|
+
};
|
|
289
|
+
summary: {
|
|
290
|
+
type: string;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
required: string[];
|
|
294
|
+
};
|
|
173
295
|
private availableTools;
|
|
174
296
|
private readonly checkpointManager;
|
|
175
297
|
constructor();
|
|
@@ -177,7 +299,9 @@ export declare class OrchestrateMigrationTool implements MCPTool {
|
|
|
177
299
|
* Set the available tools for workflow execution
|
|
178
300
|
*/
|
|
179
301
|
setAvailableTools(tools: Map<string, MCPTool>): void;
|
|
180
|
-
execute(args: Record<string, unknown
|
|
302
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<OrchestrateMigrationResult>;
|
|
303
|
+
private runWorkflow;
|
|
304
|
+
private unknownToolsResult;
|
|
181
305
|
/**
|
|
182
306
|
* Build result from workflow execution
|
|
183
307
|
*/
|
|
@@ -4,7 +4,23 @@
|
|
|
4
4
|
* MCP tool for executing multi-step migration workflows with
|
|
5
5
|
* dependency management, checkpoint/resume, and rollback support.
|
|
6
6
|
*/
|
|
7
|
+
import { yieldIfCancellable } from './helpers/tool-context.js';
|
|
7
8
|
import { WorkflowEngine, } from '@angular-modernizer/orchestration';
|
|
9
|
+
/** Errors spelled out in the summary; the rest is in `errors`. */
|
|
10
|
+
const SUMMARY_ERRORS = 5;
|
|
11
|
+
/** Text summary: status and step counts, the message, the first errors. */
|
|
12
|
+
function describeWorkflow(result) {
|
|
13
|
+
const c = result.counts;
|
|
14
|
+
const lines = [
|
|
15
|
+
`Workflow ${result.workflowId} ${result.status}: ${c.successfulSteps}/${c.totalSteps} step(s) succeeded, ` +
|
|
16
|
+
`${c.failedSteps} failed, ${c.skippedSteps} skipped in ${(c.totalDurationMs / 1000).toFixed(1)} s.`,
|
|
17
|
+
result.message,
|
|
18
|
+
];
|
|
19
|
+
lines.push(...result.errors
|
|
20
|
+
.slice(0, SUMMARY_ERRORS)
|
|
21
|
+
.map((e) => `- ${e.stepId}: ${e.message}`));
|
|
22
|
+
return lines.join('\n');
|
|
23
|
+
}
|
|
8
24
|
/**
|
|
9
25
|
* Simple in-memory checkpoint manager
|
|
10
26
|
*/
|
|
@@ -24,8 +40,14 @@ class InMemoryCheckpointManager {
|
|
|
24
40
|
* Tool executor that delegates to other MCP tools
|
|
25
41
|
*/
|
|
26
42
|
class MCPToolExecutor {
|
|
43
|
+
signal;
|
|
27
44
|
tools;
|
|
28
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @param signal - Cancellation of the workflow call: passed to every step,
|
|
47
|
+
* so a running build ends; steps after a cancellation fail at once
|
|
48
|
+
*/
|
|
49
|
+
constructor(tools, signal) {
|
|
50
|
+
this.signal = signal;
|
|
29
51
|
this.tools = tools;
|
|
30
52
|
}
|
|
31
53
|
async executeTool(toolName, args) {
|
|
@@ -33,7 +55,11 @@ class MCPToolExecutor {
|
|
|
33
55
|
if (!tool) {
|
|
34
56
|
throw new Error(`Tool not found: ${toolName}`);
|
|
35
57
|
}
|
|
36
|
-
|
|
58
|
+
await yieldIfCancellable(this.signal);
|
|
59
|
+
if (this.signal?.aborted === true) {
|
|
60
|
+
throw new Error('Workflow cancelled by the client');
|
|
61
|
+
}
|
|
62
|
+
return tool.execute(args, this.signal === undefined ? {} : { signal: this.signal });
|
|
37
63
|
}
|
|
38
64
|
}
|
|
39
65
|
/**
|
|
@@ -41,9 +67,18 @@ class MCPToolExecutor {
|
|
|
41
67
|
*/
|
|
42
68
|
export class OrchestrateMigrationTool {
|
|
43
69
|
name = 'orchestrate-migration';
|
|
44
|
-
|
|
70
|
+
title = 'Orchestrate Migration';
|
|
71
|
+
annotations = {
|
|
72
|
+
readOnlyHint: false,
|
|
73
|
+
destructiveHint: true,
|
|
74
|
+
idempotentHint: false,
|
|
75
|
+
openWorldHint: false,
|
|
76
|
+
};
|
|
77
|
+
description = 'Execute multi-step migration workflows with dependency management and checkpoint/resume. ' +
|
|
78
|
+
'counts has the step counts and the duration; summary is a short text with the status, the counts and the first errors.';
|
|
45
79
|
inputSchema = {
|
|
46
80
|
type: 'object',
|
|
81
|
+
additionalProperties: false,
|
|
47
82
|
properties: {
|
|
48
83
|
workflow: {
|
|
49
84
|
type: 'object',
|
|
@@ -110,6 +145,88 @@ export class OrchestrateMigrationTool {
|
|
|
110
145
|
},
|
|
111
146
|
required: ['workflow'],
|
|
112
147
|
};
|
|
148
|
+
outputSchema = {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
status: { type: 'string', enum: ['completed', 'failed', 'partial'] },
|
|
152
|
+
workflowId: { type: 'string' },
|
|
153
|
+
counts: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
totalSteps: { type: 'integer' },
|
|
157
|
+
successfulSteps: { type: 'integer' },
|
|
158
|
+
failedSteps: { type: 'integer' },
|
|
159
|
+
skippedSteps: { type: 'integer' },
|
|
160
|
+
totalDurationMs: { type: 'number' },
|
|
161
|
+
},
|
|
162
|
+
required: [
|
|
163
|
+
'totalSteps',
|
|
164
|
+
'successfulSteps',
|
|
165
|
+
'failedSteps',
|
|
166
|
+
'skippedSteps',
|
|
167
|
+
'totalDurationMs',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
stepResults: {
|
|
171
|
+
type: 'array',
|
|
172
|
+
items: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
stepId: { type: 'string' },
|
|
176
|
+
name: { type: 'string' },
|
|
177
|
+
status: { type: 'string' },
|
|
178
|
+
durationMs: { type: 'number' },
|
|
179
|
+
error: { type: 'string' },
|
|
180
|
+
},
|
|
181
|
+
required: ['stepId', 'name', 'status', 'durationMs'],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
checkpoints: {
|
|
185
|
+
type: 'array',
|
|
186
|
+
items: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
id: { type: 'string' },
|
|
190
|
+
stepId: { type: 'string' },
|
|
191
|
+
timestamp: { type: 'number' },
|
|
192
|
+
},
|
|
193
|
+
required: ['id', 'stepId', 'timestamp'],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
errors: {
|
|
197
|
+
type: 'array',
|
|
198
|
+
items: {
|
|
199
|
+
type: 'object',
|
|
200
|
+
properties: {
|
|
201
|
+
stepId: { type: 'string' },
|
|
202
|
+
message: { type: 'string' },
|
|
203
|
+
stack: { type: 'string' },
|
|
204
|
+
},
|
|
205
|
+
required: ['stepId', 'message'],
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
finalCheckpoint: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
properties: {
|
|
211
|
+
id: { type: 'string' },
|
|
212
|
+
canResume: { type: 'boolean' },
|
|
213
|
+
},
|
|
214
|
+
required: ['id', 'canResume'],
|
|
215
|
+
},
|
|
216
|
+
message: { type: 'string' },
|
|
217
|
+
summary: { type: 'string' },
|
|
218
|
+
},
|
|
219
|
+
required: [
|
|
220
|
+
'status',
|
|
221
|
+
'workflowId',
|
|
222
|
+
'counts',
|
|
223
|
+
'stepResults',
|
|
224
|
+
'checkpoints',
|
|
225
|
+
'errors',
|
|
226
|
+
'message',
|
|
227
|
+
'summary',
|
|
228
|
+
],
|
|
229
|
+
};
|
|
113
230
|
availableTools;
|
|
114
231
|
checkpointManager;
|
|
115
232
|
constructor() {
|
|
@@ -122,12 +239,22 @@ export class OrchestrateMigrationTool {
|
|
|
122
239
|
setAvailableTools(tools) {
|
|
123
240
|
this.availableTools = tools;
|
|
124
241
|
}
|
|
125
|
-
async execute(args) {
|
|
242
|
+
async execute(args, ctx = {}) {
|
|
243
|
+
const result = await this.runWorkflow(args, ctx);
|
|
244
|
+
return { ...result, summary: describeWorkflow(result) };
|
|
245
|
+
}
|
|
246
|
+
async runWorkflow(args, ctx) {
|
|
126
247
|
const typedArgs = args;
|
|
127
248
|
const { workflow, resumeFromCheckpoint, dryRun = false } = typedArgs;
|
|
249
|
+
// Unknown tool names fail every run; report them before any step runs,
|
|
250
|
+
// also in dry-run mode, which never calls the tools.
|
|
251
|
+
const unknownSteps = (Array.isArray(workflow.steps) ? workflow.steps : []).filter((step) => !this.availableTools.has(step.tool));
|
|
252
|
+
if (unknownSteps.length > 0) {
|
|
253
|
+
return this.unknownToolsResult(workflow, unknownSteps);
|
|
254
|
+
}
|
|
128
255
|
try {
|
|
129
256
|
// Create tool executor
|
|
130
|
-
const toolExecutor = new MCPToolExecutor(this.availableTools);
|
|
257
|
+
const toolExecutor = new MCPToolExecutor(this.availableTools, ctx.signal);
|
|
131
258
|
// Create workflow engine
|
|
132
259
|
const engine = new WorkflowEngine(toolExecutor, this.checkpointManager);
|
|
133
260
|
// Execute workflow
|
|
@@ -135,8 +262,9 @@ export class OrchestrateMigrationTool {
|
|
|
135
262
|
resumeFromCheckpoint,
|
|
136
263
|
dryRun,
|
|
137
264
|
onProgress: (state) => {
|
|
138
|
-
|
|
139
|
-
console.info(`Progress: ${
|
|
265
|
+
const { completedSteps, totalSteps } = state.progress;
|
|
266
|
+
console.info(`Progress: ${completedSteps}/${totalSteps} (${state.progress.percentage.toFixed(1)}%)`);
|
|
267
|
+
ctx.progress?.(completedSteps, totalSteps, `${completedSteps}/${totalSteps} steps`);
|
|
140
268
|
},
|
|
141
269
|
onStepComplete: (stepResult) => {
|
|
142
270
|
console.info(`✓ Step completed: ${stepResult.stepId} (${stepResult.status})`);
|
|
@@ -151,8 +279,8 @@ export class OrchestrateMigrationTool {
|
|
|
151
279
|
catch (error) {
|
|
152
280
|
return {
|
|
153
281
|
status: 'failed',
|
|
154
|
-
|
|
155
|
-
|
|
282
|
+
workflowId: workflow.id,
|
|
283
|
+
counts: {
|
|
156
284
|
// steps may be malformed (that can be exactly why we ended up here)
|
|
157
285
|
totalSteps: workflow.steps?.length ?? 0,
|
|
158
286
|
successfulSteps: 0,
|
|
@@ -173,6 +301,28 @@ export class OrchestrateMigrationTool {
|
|
|
173
301
|
};
|
|
174
302
|
}
|
|
175
303
|
}
|
|
304
|
+
unknownToolsResult(workflow, unknownSteps) {
|
|
305
|
+
const names = [...new Set(unknownSteps.map((step) => step.tool))];
|
|
306
|
+
return {
|
|
307
|
+
status: 'failed',
|
|
308
|
+
workflowId: workflow.id,
|
|
309
|
+
counts: {
|
|
310
|
+
totalSteps: workflow.steps.length,
|
|
311
|
+
successfulSteps: 0,
|
|
312
|
+
failedSteps: 0,
|
|
313
|
+
skippedSteps: workflow.steps.length,
|
|
314
|
+
totalDurationMs: 0,
|
|
315
|
+
},
|
|
316
|
+
stepResults: [],
|
|
317
|
+
checkpoints: [],
|
|
318
|
+
errors: unknownSteps.map((step) => ({
|
|
319
|
+
stepId: step.id,
|
|
320
|
+
message: `Tool not found: ${step.tool}`,
|
|
321
|
+
})),
|
|
322
|
+
message: `Workflow not started: unknown tool(s) ${names.join(', ')}. ` +
|
|
323
|
+
'Use the names from tools/list; batch transformations are transform-code with files.',
|
|
324
|
+
};
|
|
325
|
+
}
|
|
176
326
|
/**
|
|
177
327
|
* Build result from workflow execution
|
|
178
328
|
*/
|
|
@@ -207,12 +357,16 @@ export class OrchestrateMigrationTool {
|
|
|
207
357
|
message = `Workflow partially completed. ${result.metrics.successfulSteps}/${result.metrics.totalSteps} steps succeeded, ${result.metrics.failedSteps} failed. Use finalCheckpoint to resume.`;
|
|
208
358
|
}
|
|
209
359
|
else {
|
|
210
|
-
|
|
360
|
+
const workflowError = result.errors.find((e) => e.stepId === 'workflow');
|
|
361
|
+
message =
|
|
362
|
+
workflowError === undefined
|
|
363
|
+
? `Workflow failed. ${result.metrics.failedSteps} steps failed.`
|
|
364
|
+
: `Workflow failed: ${workflowError.error.message}`;
|
|
211
365
|
}
|
|
212
366
|
return {
|
|
213
367
|
status: result.status,
|
|
214
|
-
|
|
215
|
-
|
|
368
|
+
workflowId: result.workflowId,
|
|
369
|
+
counts: {
|
|
216
370
|
totalSteps: result.metrics.totalSteps,
|
|
217
371
|
successfulSteps: result.metrics.successfulSteps,
|
|
218
372
|
failedSteps: result.metrics.failedSteps,
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* // args: { stackTrace: error.stack, projectRoot: '/my/project/src' }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { type MCPTool } from '../types.js';
|
|
20
|
-
import { type StackFrame } from '@angular-modernizer/api';
|
|
19
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
20
|
+
import { type StackFrame, type StackFrameFileIndex } from '@angular-modernizer/api';
|
|
21
21
|
/**
|
|
22
22
|
* Output of the parse-stack-trace tool.
|
|
23
23
|
*/
|
|
@@ -35,10 +35,15 @@ interface ParseStackTraceOutput {
|
|
|
35
35
|
* MCP tool that parses stack traces into structured, LLM-consumable frames.
|
|
36
36
|
*/
|
|
37
37
|
export declare class ParseStackTraceTool implements MCPTool {
|
|
38
|
+
private readonly createFileIndex;
|
|
38
39
|
readonly name = "parse-stack-trace";
|
|
40
|
+
readonly title = "Parse Stack Trace";
|
|
41
|
+
readonly annotations: ToolAnnotations;
|
|
42
|
+
constructor(createFileIndex?: (projectRoot: string) => StackFrameFileIndex);
|
|
39
43
|
readonly description: string;
|
|
40
44
|
readonly inputSchema: {
|
|
41
45
|
type: string;
|
|
46
|
+
additionalProperties: boolean;
|
|
42
47
|
properties: {
|
|
43
48
|
stackTrace: {
|
|
44
49
|
type: string;
|
|
@@ -56,6 +61,58 @@ export declare class ParseStackTraceTool implements MCPTool {
|
|
|
56
61
|
};
|
|
57
62
|
required: string[];
|
|
58
63
|
};
|
|
64
|
+
readonly outputSchema: {
|
|
65
|
+
type: string;
|
|
66
|
+
properties: {
|
|
67
|
+
frames: {
|
|
68
|
+
type: string;
|
|
69
|
+
items: {
|
|
70
|
+
type: string;
|
|
71
|
+
properties: {
|
|
72
|
+
file: {
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
line: {
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
col: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
functionName: {
|
|
82
|
+
type: string;
|
|
83
|
+
};
|
|
84
|
+
isProjectFile: {
|
|
85
|
+
type: string;
|
|
86
|
+
};
|
|
87
|
+
resolvedFile: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
resolvedFrom: {
|
|
91
|
+
type: string;
|
|
92
|
+
enum: string[];
|
|
93
|
+
};
|
|
94
|
+
candidates: {
|
|
95
|
+
type: string;
|
|
96
|
+
items: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
required: string[];
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
projectFrameCount: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
totalFrameCount: {
|
|
108
|
+
type: string;
|
|
109
|
+
};
|
|
110
|
+
summary: {
|
|
111
|
+
type: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
required: string[];
|
|
115
|
+
};
|
|
59
116
|
execute(args: Record<string, unknown>): Promise<ParseStackTraceOutput>;
|
|
60
117
|
private buildSummary;
|
|
61
118
|
}
|
|
@@ -16,18 +16,33 @@
|
|
|
16
16
|
* // args: { stackTrace: error.stack, projectRoot: '/my/project/src' }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { StackTraceParser } from '@angular-modernizer/api';
|
|
19
|
+
import { StackTraceParser, } from '@angular-modernizer/api';
|
|
20
|
+
import { createNodeStackFrameFileIndex } from './helpers/stack-frame-file-index.js';
|
|
20
21
|
/**
|
|
21
22
|
* MCP tool that parses stack traces into structured, LLM-consumable frames.
|
|
22
23
|
*/
|
|
23
24
|
export class ParseStackTraceTool {
|
|
25
|
+
createFileIndex;
|
|
24
26
|
name = 'parse-stack-trace';
|
|
27
|
+
title = 'Parse Stack Trace';
|
|
28
|
+
annotations = {
|
|
29
|
+
readOnlyHint: true,
|
|
30
|
+
destructiveHint: false,
|
|
31
|
+
idempotentHint: true,
|
|
32
|
+
openWorldHint: false,
|
|
33
|
+
};
|
|
34
|
+
constructor(createFileIndex = createNodeStackFrameFileIndex) {
|
|
35
|
+
this.createFileIndex = createFileIndex;
|
|
36
|
+
}
|
|
25
37
|
description = 'Parse a Node.js/Angular/Zone.js/browser stack trace into structured frames. ' +
|
|
26
38
|
'Maps each frame to its source file, line, column, and function name. ' +
|
|
27
|
-
'Classifies frames as project files or external dependencies (node_modules
|
|
39
|
+
'Classifies frames as project files or external dependencies (node_modules). ' +
|
|
40
|
+
'Browser frames (http://host/src/..., webpack:///, ng:///, bare file names) are mapped ' +
|
|
41
|
+
'onto project files via resolvedFile; an ambiguous file name lists candidates. ' +
|
|
28
42
|
'Use as the first step in bug investigation when a stack trace is available.';
|
|
29
43
|
inputSchema = {
|
|
30
44
|
type: 'object',
|
|
45
|
+
additionalProperties: false,
|
|
31
46
|
properties: {
|
|
32
47
|
stackTrace: {
|
|
33
48
|
type: 'string',
|
|
@@ -45,6 +60,32 @@ export class ParseStackTraceTool {
|
|
|
45
60
|
},
|
|
46
61
|
required: ['stackTrace', 'projectRoot'],
|
|
47
62
|
};
|
|
63
|
+
outputSchema = {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
frames: {
|
|
67
|
+
type: 'array',
|
|
68
|
+
items: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
file: { type: 'string' },
|
|
72
|
+
line: { type: 'integer' },
|
|
73
|
+
col: { type: 'integer' },
|
|
74
|
+
functionName: { type: 'string' },
|
|
75
|
+
isProjectFile: { type: 'boolean' },
|
|
76
|
+
resolvedFile: { type: 'string' },
|
|
77
|
+
resolvedFrom: { type: 'string', enum: ['url', 'basename'] },
|
|
78
|
+
candidates: { type: 'array', items: { type: 'string' } },
|
|
79
|
+
},
|
|
80
|
+
required: ['file', 'line', 'col', 'functionName', 'isProjectFile'],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
projectFrameCount: { type: 'integer' },
|
|
84
|
+
totalFrameCount: { type: 'integer' },
|
|
85
|
+
summary: { type: 'string' },
|
|
86
|
+
},
|
|
87
|
+
required: ['frames', 'projectFrameCount', 'totalFrameCount', 'summary'],
|
|
88
|
+
};
|
|
48
89
|
async execute(args) {
|
|
49
90
|
const params = args;
|
|
50
91
|
if (!params.stackTrace) {
|
|
@@ -53,7 +94,7 @@ export class ParseStackTraceTool {
|
|
|
53
94
|
if (!params.projectRoot) {
|
|
54
95
|
throw new Error('projectRoot is required');
|
|
55
96
|
}
|
|
56
|
-
const parser = new StackTraceParser(params.projectRoot);
|
|
97
|
+
const parser = new StackTraceParser(params.projectRoot, this.createFileIndex(params.projectRoot));
|
|
57
98
|
const allFrames = parser.parse(params.stackTrace);
|
|
58
99
|
const projectFrameCount = allFrames.filter((f) => f.isProjectFile).length;
|
|
59
100
|
const frames = params.projectFramesOnly === true
|
|
@@ -80,12 +121,19 @@ export class ParseStackTraceTool {
|
|
|
80
121
|
lines.push(`Project root: ${projectRoot}`);
|
|
81
122
|
lines.push('Project frames (investigate these):');
|
|
82
123
|
for (const frame of projectFrames) {
|
|
83
|
-
lines.push(` ${frame.functionName} → ${frame.file}:${frame.line}:${frame.col}`);
|
|
124
|
+
lines.push(` ${frame.functionName} → ${frame.resolvedFile ?? frame.file}:${frame.line}:${frame.col}`);
|
|
84
125
|
}
|
|
85
126
|
}
|
|
86
127
|
else {
|
|
87
128
|
lines.push('No project frames found. The error originates entirely in external dependencies.');
|
|
88
129
|
}
|
|
130
|
+
const ambiguous = frames.filter((f) => f.candidates !== undefined);
|
|
131
|
+
if (ambiguous.length > 0) {
|
|
132
|
+
lines.push('Ambiguous file names (not counted as project frames):');
|
|
133
|
+
for (const frame of ambiguous) {
|
|
134
|
+
lines.push(` ${frame.functionName} → ${frame.file}:${frame.line}:${frame.col} could be ${(frame.candidates ?? []).join(', ')}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
89
137
|
return lines.join('\n');
|
|
90
138
|
}
|
|
91
139
|
}
|