@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
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* propagates through the call hierarchy. Useful for determining blast radius
|
|
11
11
|
* before proposing a bug fix.
|
|
12
12
|
*
|
|
13
|
+
* The graph is capped at `maxNodes` (default 200); a capped result carries
|
|
14
|
+
* `truncated: true` and a hint in the summary. Callers are not expanded
|
|
15
|
+
* through lifecycle hooks or interface members of foreign classes unless
|
|
16
|
+
* `includeLifecycleHooks` is set. Projects are cached per tsconfig.
|
|
17
|
+
*
|
|
13
18
|
* @example
|
|
14
19
|
* ```typescript
|
|
15
20
|
* // Via MCP:
|
|
@@ -19,25 +24,56 @@
|
|
|
19
24
|
* // projectRoot: '/project', direction: 'down', depth: 4 }
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
import { Project } from 'ts-morph';
|
|
23
27
|
import { CallGraphBuilder, } from '@angular-modernizer/api';
|
|
24
28
|
import { existsSync } from 'node:fs';
|
|
25
29
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
30
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
31
|
+
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
32
|
+
/** Direct callers and callees spelled out per list in the summary. */
|
|
33
|
+
const SUMMARY_MAX_NODES = 50;
|
|
34
|
+
const CALL_NODE_FIELDS = {
|
|
35
|
+
name: { type: 'string' },
|
|
36
|
+
file: { type: 'string' },
|
|
37
|
+
line: { type: 'integer' },
|
|
38
|
+
kind: { type: 'string' },
|
|
39
|
+
className: { type: 'string' },
|
|
40
|
+
snippet: { type: 'string' },
|
|
41
|
+
inheritedFrom: { type: 'string' },
|
|
42
|
+
};
|
|
26
43
|
/**
|
|
27
44
|
* MCP tool that builds a call graph for a named method or function.
|
|
28
45
|
*/
|
|
29
46
|
export class GetCallGraphTool {
|
|
47
|
+
projects;
|
|
30
48
|
name = 'get-call-graph';
|
|
49
|
+
title = 'Get Call Graph';
|
|
50
|
+
annotations = {
|
|
51
|
+
readOnlyHint: true,
|
|
52
|
+
destructiveHint: false,
|
|
53
|
+
idempotentHint: true,
|
|
54
|
+
openWorldHint: false,
|
|
55
|
+
};
|
|
56
|
+
constructor(projects = new ProjectCache()) {
|
|
57
|
+
this.projects = projects;
|
|
58
|
+
}
|
|
31
59
|
description = 'Build a caller/callee graph for a named method, function, constructor, ' +
|
|
32
60
|
'get/set accessor or arrow-function property. ' +
|
|
33
61
|
'Direction "up" shows who calls it, "down" shows what it calls, ' +
|
|
34
62
|
'"both" returns the full call tree. Configurable depth (default: 2). ' +
|
|
63
|
+
'Prefer "ClassName.method" and the narrowest direction you need. ' +
|
|
64
|
+
'The graph is capped at maxNodes (default 200); a capped result has truncated: true. ' +
|
|
65
|
+
'Callers are not expanded through Angular lifecycle hooks or interface members of foreign classes ' +
|
|
66
|
+
'(set includeLifecycleHooks to override). summaryOnly returns counts and direct neighbours only. ' +
|
|
35
67
|
'Callees are resolved via the type checker and include new X() (constructor incl. field initializers), ' +
|
|
36
68
|
'super(), and property reads that resolve to getters. ' +
|
|
69
|
+
'Callers of component members include calls from the component template as leaf nodes ' +
|
|
70
|
+
'(kind "template", template file and line, snippet), also from templates of subclasses that inherit the member ' +
|
|
71
|
+
'(className of the subclass, inheritedFrom of the declaring class; a subclass overriding it is left out). ' +
|
|
37
72
|
'Use method "ClassName.constructor" to see what runs transitively during construction. ' +
|
|
38
73
|
'Use after parse-stack-trace to trace error propagation through the call hierarchy.';
|
|
39
74
|
inputSchema = {
|
|
40
75
|
type: 'object',
|
|
76
|
+
additionalProperties: false,
|
|
41
77
|
properties: {
|
|
42
78
|
method: {
|
|
43
79
|
type: 'string',
|
|
@@ -63,9 +99,54 @@ export class GetCallGraphTool {
|
|
|
63
99
|
description: 'How many levels deep to traverse. Default: 2.',
|
|
64
100
|
default: 2,
|
|
65
101
|
},
|
|
102
|
+
maxNodes: {
|
|
103
|
+
type: 'number',
|
|
104
|
+
description: 'Maximum number of nodes across callers and callees. Traversal stops at the cap and the ' +
|
|
105
|
+
'result is marked truncated. Default: 200.',
|
|
106
|
+
default: 200,
|
|
107
|
+
},
|
|
108
|
+
includeLifecycleHooks: {
|
|
109
|
+
type: 'boolean',
|
|
110
|
+
description: 'Expand callers through Angular lifecycle hooks and implements-interface members of other ' +
|
|
111
|
+
'classes (e.g. every ngOnInit in the program). Default: false.',
|
|
112
|
+
default: false,
|
|
113
|
+
},
|
|
114
|
+
summaryOnly: {
|
|
115
|
+
type: 'boolean',
|
|
116
|
+
description: 'Return target, counts and the text summary without the callers/callees trees. Default: false.',
|
|
117
|
+
default: false,
|
|
118
|
+
},
|
|
66
119
|
},
|
|
67
120
|
required: ['method', 'file', 'projectRoot'],
|
|
68
121
|
};
|
|
122
|
+
outputSchema = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
$defs: {
|
|
125
|
+
callNode: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
...CALL_NODE_FIELDS,
|
|
129
|
+
children: { type: 'array', items: { $ref: '#/$defs/callNode' } },
|
|
130
|
+
},
|
|
131
|
+
required: ['name', 'file', 'line', 'children'],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
properties: {
|
|
135
|
+
target: {
|
|
136
|
+
type: ['object', 'null'],
|
|
137
|
+
properties: CALL_NODE_FIELDS,
|
|
138
|
+
required: ['name', 'file', 'line'],
|
|
139
|
+
},
|
|
140
|
+
callers: { type: 'array', items: { $ref: '#/$defs/callNode' } },
|
|
141
|
+
callees: { type: 'array', items: { $ref: '#/$defs/callNode' } },
|
|
142
|
+
nodeCount: { type: 'integer' },
|
|
143
|
+
truncated: { type: 'boolean' },
|
|
144
|
+
truncatedAt: { type: 'integer' },
|
|
145
|
+
summary: { type: 'string' },
|
|
146
|
+
...WARNINGS_OUTPUT_SCHEMA,
|
|
147
|
+
},
|
|
148
|
+
required: ['target', 'nodeCount', 'truncated', 'summary'],
|
|
149
|
+
};
|
|
69
150
|
async execute(args) {
|
|
70
151
|
const params = args;
|
|
71
152
|
if (!params.method) {
|
|
@@ -84,17 +165,25 @@ export class GetCallGraphTool {
|
|
|
84
165
|
if (!tsConfigPath) {
|
|
85
166
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
86
167
|
}
|
|
87
|
-
|
|
88
|
-
|
|
168
|
+
if (params.maxNodes !== undefined &&
|
|
169
|
+
(!Number.isInteger(params.maxNodes) || params.maxNodes < 1)) {
|
|
170
|
+
throw new Error('maxNodes must be a positive integer');
|
|
171
|
+
}
|
|
172
|
+
const graphBuilder = new CallGraphBuilder(this.projects.get(tsConfigPath));
|
|
173
|
+
const warnings = this.projects.warnings(tsConfigPath);
|
|
89
174
|
const options = {
|
|
90
175
|
direction: params.direction ?? 'both',
|
|
91
176
|
depth: params.depth ?? 2,
|
|
177
|
+
maxNodes: params.maxNodes ?? 200,
|
|
178
|
+
includeLifecycleHooks: params.includeLifecycleHooks ?? false,
|
|
92
179
|
};
|
|
93
180
|
const result = graphBuilder.buildCallGraph(params.method, params.file, options);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
181
|
+
const summary = this.buildSummary(params.method, result);
|
|
182
|
+
if (params.summaryOnly) {
|
|
183
|
+
const { callers: _callers, callees: _callees, ...rest } = result;
|
|
184
|
+
return withWarnings({ ...rest, summary }, warnings);
|
|
185
|
+
}
|
|
186
|
+
return withWarnings({ ...result, summary }, warnings);
|
|
98
187
|
}
|
|
99
188
|
buildSummary(method, result) {
|
|
100
189
|
if (!result.target) {
|
|
@@ -102,28 +191,49 @@ export class GetCallGraphTool {
|
|
|
102
191
|
}
|
|
103
192
|
const lines = [
|
|
104
193
|
`Call graph for '${method}' at ${result.target.file}:${result.target.line}`,
|
|
194
|
+
`Nodes: ${result.nodeCount}`,
|
|
105
195
|
];
|
|
196
|
+
if (result.truncated) {
|
|
197
|
+
lines.push(`\nTRUNCATED at ${result.truncatedAt ?? result.nodeCount} nodes (maxNodes). The trees are a valid ` +
|
|
198
|
+
'but incomplete prefix. Narrow the query: class-qualified method, direction "up" or "down", ' +
|
|
199
|
+
'lower depth, or raise maxNodes.');
|
|
200
|
+
}
|
|
106
201
|
if (result.callers.length > 0) {
|
|
107
202
|
lines.push(`\nCallers (${result.callers.length}):`);
|
|
108
|
-
|
|
109
|
-
lines.push(` ← ${this.label(c)} (${c.file}:${c.line})`);
|
|
110
|
-
}
|
|
203
|
+
lines.push(...this.listNodes(result.callers, '←', 'callers'));
|
|
111
204
|
}
|
|
112
205
|
else {
|
|
113
206
|
lines.push('\nNo callers found (root method or not traced).');
|
|
114
207
|
}
|
|
115
208
|
if (result.callees.length > 0) {
|
|
116
209
|
lines.push(`\nCallees (${result.callees.length}):`);
|
|
117
|
-
|
|
118
|
-
lines.push(` → ${this.label(c)} (${c.file}:${c.line})`);
|
|
119
|
-
}
|
|
210
|
+
lines.push(...this.listNodes(result.callees, '→', 'callees'));
|
|
120
211
|
}
|
|
121
212
|
else {
|
|
122
213
|
lines.push('\nNo callees found (leaf method or not traced).');
|
|
123
214
|
}
|
|
124
215
|
return lines.join('\n');
|
|
125
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Summary lines for the direct callers or callees, at most
|
|
219
|
+
* {@link SUMMARY_MAX_NODES}: a wide fan-in (500 callers on a large app)
|
|
220
|
+
* made the summary about as large as the tree itself, and the summary is
|
|
221
|
+
* sent as text next to `structuredContent`.
|
|
222
|
+
*/
|
|
223
|
+
listNodes(nodes, arrow, field) {
|
|
224
|
+
const lines = nodes
|
|
225
|
+
.slice(0, SUMMARY_MAX_NODES)
|
|
226
|
+
.map((c) => ` ${arrow} ${this.label(c)} (${c.file}:${c.line})`);
|
|
227
|
+
if (nodes.length > SUMMARY_MAX_NODES) {
|
|
228
|
+
lines.push(` ... and ${nodes.length - SUMMARY_MAX_NODES} more in ${field}`);
|
|
229
|
+
}
|
|
230
|
+
return lines;
|
|
231
|
+
}
|
|
126
232
|
label(node) {
|
|
233
|
+
if (node.kind === 'template') {
|
|
234
|
+
const inherited = node.inheritedFrom === undefined ? '' : ` (inherits ${node.inheritedFrom})`;
|
|
235
|
+
return `template of ${node.className ?? 'component'}${inherited}: ${node.snippet ?? ''}`;
|
|
236
|
+
}
|
|
127
237
|
const qualified = node.className
|
|
128
238
|
? `${node.className}.${node.name}`
|
|
129
239
|
: node.name;
|
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MCP tool for querying progress of streaming operations.
|
|
5
5
|
*/
|
|
6
|
-
import type { MCPTool } from '../types.js';
|
|
6
|
+
import type { MCPTool, ToolAnnotations } from '../types.js';
|
|
7
|
+
import { getOperationProgress } from './get-operation-progress.js';
|
|
8
|
+
type OperationProgress = Awaited<ReturnType<typeof getOperationProgress>>;
|
|
7
9
|
/**
|
|
8
10
|
* MCP tool for getting operation progress.
|
|
9
11
|
*/
|
|
10
12
|
export declare class GetOperationProgressTool implements MCPTool {
|
|
11
13
|
readonly name = "get-operation-progress";
|
|
14
|
+
readonly title = "Get Operation Progress";
|
|
15
|
+
readonly annotations: ToolAnnotations;
|
|
12
16
|
readonly description: string;
|
|
13
17
|
readonly inputSchema: {
|
|
14
18
|
type: string;
|
|
19
|
+
additionalProperties: boolean;
|
|
15
20
|
properties: {
|
|
16
21
|
operationId: {
|
|
17
22
|
type: string;
|
|
@@ -24,6 +29,113 @@ export declare class GetOperationProgressTool implements MCPTool {
|
|
|
24
29
|
};
|
|
25
30
|
required: string[];
|
|
26
31
|
};
|
|
27
|
-
|
|
32
|
+
readonly outputSchema: {
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
operationId: {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
status: {
|
|
39
|
+
type: string;
|
|
40
|
+
enum: string[];
|
|
41
|
+
};
|
|
42
|
+
events: {
|
|
43
|
+
type: string;
|
|
44
|
+
items: {
|
|
45
|
+
type: string;
|
|
46
|
+
properties: {
|
|
47
|
+
phase: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
message: {
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
percentage: {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
timestamp: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
unifiedDiff: {
|
|
60
|
+
type: string;
|
|
61
|
+
properties: {
|
|
62
|
+
filePath: {
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
65
|
+
diff: {
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
linesAdded: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
linesRemoved: {
|
|
72
|
+
type: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
syntaxErrors: {
|
|
77
|
+
type: string;
|
|
78
|
+
items: {
|
|
79
|
+
type: string;
|
|
80
|
+
properties: {
|
|
81
|
+
filePath: {
|
|
82
|
+
type: string;
|
|
83
|
+
};
|
|
84
|
+
line: {
|
|
85
|
+
type: string;
|
|
86
|
+
};
|
|
87
|
+
message: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
memoryUsage: {
|
|
94
|
+
type: string;
|
|
95
|
+
properties: {
|
|
96
|
+
heapUsed: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
heapTotal: {
|
|
100
|
+
type: string;
|
|
101
|
+
};
|
|
102
|
+
external: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
percentage: {
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
totalEvents: {
|
|
115
|
+
type: string;
|
|
116
|
+
};
|
|
117
|
+
elapsedTime: {
|
|
118
|
+
type: string;
|
|
119
|
+
};
|
|
120
|
+
eta: {
|
|
121
|
+
type: string;
|
|
122
|
+
};
|
|
123
|
+
error: {
|
|
124
|
+
type: string;
|
|
125
|
+
};
|
|
126
|
+
result: {
|
|
127
|
+
type: string;
|
|
128
|
+
description: string;
|
|
129
|
+
};
|
|
130
|
+
summary: {
|
|
131
|
+
type: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
required: string[];
|
|
135
|
+
};
|
|
136
|
+
execute(args: Record<string, unknown>): Promise<OperationProgress & {
|
|
137
|
+
summary: string;
|
|
138
|
+
}>;
|
|
28
139
|
}
|
|
140
|
+
export {};
|
|
29
141
|
//# sourceMappingURL=get-operation-progress-tool.d.ts.map
|
|
@@ -4,15 +4,56 @@
|
|
|
4
4
|
* MCP tool for querying progress of streaming operations.
|
|
5
5
|
*/
|
|
6
6
|
import { getOperationProgress, validateInput, } from './get-operation-progress.js';
|
|
7
|
+
/**
|
|
8
|
+
* Text summary: status, time, events, the last event, and the stored result's
|
|
9
|
+
* own summary once the operation is completed.
|
|
10
|
+
*/
|
|
11
|
+
function describeProgress(progress) {
|
|
12
|
+
const last = progress.events.at(-1);
|
|
13
|
+
const lines = [
|
|
14
|
+
`Operation ${progress.operationId} ${progress.status} after ${(progress.elapsedTime / 1000).toFixed(1)} s; ` +
|
|
15
|
+
`${progress.events.length} of ${progress.totalEvents} event(s)` +
|
|
16
|
+
(progress.eta === undefined
|
|
17
|
+
? ''
|
|
18
|
+
: `; eta ${(progress.eta / 1000).toFixed(1)} s`) +
|
|
19
|
+
'.',
|
|
20
|
+
];
|
|
21
|
+
if (last !== undefined) {
|
|
22
|
+
lines.push(`Last event: ${last.phase} ${last.percentage}%: ${last.message}`);
|
|
23
|
+
}
|
|
24
|
+
if (progress.error !== undefined) {
|
|
25
|
+
lines.push(`Error: ${progress.error}`);
|
|
26
|
+
}
|
|
27
|
+
const result = progress.result;
|
|
28
|
+
if (typeof result === 'object' && result !== null && 'summary' in result) {
|
|
29
|
+
const inner = result.summary;
|
|
30
|
+
if (typeof inner === 'string') {
|
|
31
|
+
lines.push(`Result: ${inner}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lines.join('\n');
|
|
35
|
+
}
|
|
7
36
|
/**
|
|
8
37
|
* MCP tool for getting operation progress.
|
|
9
38
|
*/
|
|
10
39
|
export class GetOperationProgressTool {
|
|
11
40
|
name = 'get-operation-progress';
|
|
12
|
-
|
|
13
|
-
|
|
41
|
+
title = 'Get Operation Progress';
|
|
42
|
+
annotations = {
|
|
43
|
+
readOnlyHint: true,
|
|
44
|
+
destructiveHint: false,
|
|
45
|
+
idempotentHint: true,
|
|
46
|
+
openWorldHint: false,
|
|
47
|
+
};
|
|
48
|
+
description = 'Deprecated, kept in 1.x: polls an operation started with streaming: true (transform-code, scan-architecture). ' +
|
|
49
|
+
'Call those tools synchronously instead: they send MCP progress notifications when the request has a progressToken ' +
|
|
50
|
+
'and stop on notifications/cancelled. ' +
|
|
51
|
+
'Get progress for a streaming operation (transformation or analysis). ' +
|
|
52
|
+
'Returns status, events, and operation metadata including diffs and syntax errors. ' +
|
|
53
|
+
'A completed operation carries the tool result in result; summary is a short text with the status, the last event and the result summary.';
|
|
14
54
|
inputSchema = {
|
|
15
55
|
type: 'object',
|
|
56
|
+
additionalProperties: false,
|
|
16
57
|
properties: {
|
|
17
58
|
operationId: {
|
|
18
59
|
type: 'string',
|
|
@@ -25,12 +66,78 @@ export class GetOperationProgressTool {
|
|
|
25
66
|
},
|
|
26
67
|
required: ['operationId'],
|
|
27
68
|
};
|
|
69
|
+
outputSchema = {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
operationId: { type: 'string' },
|
|
73
|
+
status: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
enum: ['running', 'completed', 'failed', 'cancelled'],
|
|
76
|
+
},
|
|
77
|
+
events: {
|
|
78
|
+
type: 'array',
|
|
79
|
+
items: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
phase: { type: 'string' },
|
|
83
|
+
message: { type: 'string' },
|
|
84
|
+
percentage: { type: 'number' },
|
|
85
|
+
timestamp: { type: 'number' },
|
|
86
|
+
unifiedDiff: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
filePath: { type: 'string' },
|
|
90
|
+
diff: { type: 'string' },
|
|
91
|
+
linesAdded: { type: 'integer' },
|
|
92
|
+
linesRemoved: { type: 'integer' },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
syntaxErrors: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
items: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
filePath: { type: 'string' },
|
|
101
|
+
line: { type: 'integer' },
|
|
102
|
+
message: { type: 'string' },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
memoryUsage: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
heapUsed: { type: 'number' },
|
|
110
|
+
heapTotal: { type: 'number' },
|
|
111
|
+
external: { type: 'number' },
|
|
112
|
+
percentage: { type: 'number' },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
required: ['phase', 'message', 'percentage', 'timestamp'],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
totalEvents: { type: 'integer' },
|
|
120
|
+
elapsedTime: { type: 'number' },
|
|
121
|
+
eta: { type: 'number' },
|
|
122
|
+
error: { type: 'string' },
|
|
123
|
+
result: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
description: 'Result of the operation as the tool returns it (scan-architecture, transform-code), only when completed.',
|
|
126
|
+
},
|
|
127
|
+
summary: { type: 'string' },
|
|
128
|
+
},
|
|
129
|
+
required: [
|
|
130
|
+
'operationId',
|
|
131
|
+
'status',
|
|
132
|
+
'events',
|
|
133
|
+
'totalEvents',
|
|
134
|
+
'elapsedTime',
|
|
135
|
+
'summary',
|
|
136
|
+
],
|
|
137
|
+
};
|
|
28
138
|
async execute(args) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Execute the operation
|
|
32
|
-
const result = await getOperationProgress(validatedInput);
|
|
33
|
-
return result;
|
|
139
|
+
const progress = await getOperationProgress(validateInput(args));
|
|
140
|
+
return { ...progress, summary: describeProgress(progress) };
|
|
34
141
|
}
|
|
35
142
|
}
|
|
36
143
|
//# sourceMappingURL=get-operation-progress-tool.js.map
|
|
@@ -59,12 +59,12 @@ export async function getOperationProgress(input) {
|
|
|
59
59
|
message: event.message,
|
|
60
60
|
percentage: event.percentage,
|
|
61
61
|
timestamp: event.timestamp,
|
|
62
|
-
|
|
62
|
+
unifiedDiff: event.unifiedDiff
|
|
63
63
|
? {
|
|
64
|
-
filePath: event.
|
|
65
|
-
diff: event.
|
|
66
|
-
linesAdded: event.
|
|
67
|
-
linesRemoved: event.
|
|
64
|
+
filePath: event.unifiedDiff.filePath,
|
|
65
|
+
diff: event.unifiedDiff.diff,
|
|
66
|
+
linesAdded: event.unifiedDiff.linesAdded,
|
|
67
|
+
linesRemoved: event.unifiedDiff.linesRemoved,
|
|
68
68
|
}
|
|
69
69
|
: undefined,
|
|
70
70
|
syntaxErrors: event.syntaxErrors
|