@angular-modernizer/adapter-mcp 0.1.1
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/LICENSE +21 -0
- package/README.md +917 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/project-analyzer.d.ts +59 -0
- package/dist/core/project-analyzer.d.ts.map +1 -0
- package/dist/core/project-analyzer.js +116 -0
- package/dist/core/project-analyzer.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-watcher.d.ts +119 -0
- package/dist/mcp-watcher.d.ts.map +1 -0
- package/dist/mcp-watcher.js +380 -0
- package/dist/mcp-watcher.js.map +1 -0
- package/dist/server/json-rpc-handler.d.ts +57 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -0
- package/dist/server/json-rpc-handler.js +222 -0
- package/dist/server/json-rpc-handler.js.map +1 -0
- package/dist/server/mcp-server.d.ts +62 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +184 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/server/tool-registry.d.ts +73 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +102 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/streaming/progress-store.d.ts +120 -0
- package/dist/streaming/progress-store.d.ts.map +1 -0
- package/dist/streaming/progress-store.js +238 -0
- package/dist/streaming/progress-store.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +127 -0
- package/dist/tools/analyze-build-impact.d.ts.map +1 -0
- package/dist/tools/analyze-build-impact.js +194 -0
- package/dist/tools/analyze-build-impact.js.map +1 -0
- package/dist/tools/analyze-core-to-shared.d.ts +163 -0
- package/dist/tools/analyze-core-to-shared.d.ts.map +1 -0
- package/dist/tools/analyze-core-to-shared.js +436 -0
- package/dist/tools/analyze-core-to-shared.js.map +1 -0
- package/dist/tools/analyze-parser-performance.d.ts +105 -0
- package/dist/tools/analyze-parser-performance.d.ts.map +1 -0
- package/dist/tools/analyze-parser-performance.js +313 -0
- package/dist/tools/analyze-parser-performance.js.map +1 -0
- package/dist/tools/analyze-project.d.ts +277 -0
- package/dist/tools/analyze-project.d.ts.map +1 -0
- package/dist/tools/analyze-project.js +946 -0
- package/dist/tools/analyze-project.js.map +1 -0
- package/dist/tools/check-incremental-compatibility.d.ts +109 -0
- package/dist/tools/check-incremental-compatibility.d.ts.map +1 -0
- package/dist/tools/check-incremental-compatibility.js +302 -0
- package/dist/tools/check-incremental-compatibility.js.map +1 -0
- package/dist/tools/collect-feedback.d.ts +117 -0
- package/dist/tools/collect-feedback.d.ts.map +1 -0
- package/dist/tools/collect-feedback.js +773 -0
- package/dist/tools/collect-feedback.js.map +1 -0
- package/dist/tools/extract-libraries.d.ts +121 -0
- package/dist/tools/extract-libraries.d.ts.map +1 -0
- package/dist/tools/extract-libraries.js +223 -0
- package/dist/tools/extract-libraries.js.map +1 -0
- package/dist/tools/find-angular-symbol.d.ts +55 -0
- package/dist/tools/find-angular-symbol.d.ts.map +1 -0
- package/dist/tools/find-angular-symbol.js +104 -0
- package/dist/tools/find-angular-symbol.js.map +1 -0
- package/dist/tools/find-usages.d.ts +65 -0
- package/dist/tools/find-usages.d.ts.map +1 -0
- package/dist/tools/find-usages.js +108 -0
- package/dist/tools/find-usages.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +61 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +119 -0
- package/dist/tools/get-call-graph.js.map +1 -0
- package/dist/tools/get-operation-progress-tool.d.ts +29 -0
- package/dist/tools/get-operation-progress-tool.d.ts.map +1 -0
- package/dist/tools/get-operation-progress-tool.js +36 -0
- package/dist/tools/get-operation-progress-tool.js.map +1 -0
- package/dist/tools/get-operation-progress.d.ts +51 -0
- package/dist/tools/get-operation-progress.d.ts.map +1 -0
- package/dist/tools/get-operation-progress.js +93 -0
- package/dist/tools/get-operation-progress.js.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts +43 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.js +196 -0
- package/dist/tools/helpers/feedback-analyzer.js.map +1 -0
- package/dist/tools/helpers/find-ts-config.d.ts +10 -0
- package/dist/tools/helpers/find-ts-config.d.ts.map +1 -0
- package/dist/tools/helpers/find-ts-config.js +32 -0
- package/dist/tools/helpers/find-ts-config.js.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +33 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.js +60 -0
- package/dist/tools/helpers/platform-root-resolver.js.map +1 -0
- package/dist/tools/helpers/rule-matcher.d.ts +84 -0
- package/dist/tools/helpers/rule-matcher.d.ts.map +1 -0
- package/dist/tools/helpers/rule-matcher.js +212 -0
- package/dist/tools/helpers/rule-matcher.js.map +1 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +66 -0
- package/dist/tools/helpers/suggestion-generator.d.ts.map +1 -0
- package/dist/tools/helpers/suggestion-generator.js +248 -0
- package/dist/tools/helpers/suggestion-generator.js.map +1 -0
- package/dist/tools/learn-patterns.d.ts +368 -0
- package/dist/tools/learn-patterns.d.ts.map +1 -0
- package/dist/tools/learn-patterns.js +1089 -0
- package/dist/tools/learn-patterns.js.map +1 -0
- package/dist/tools/orchestrate-migration.d.ts +187 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -0
- package/dist/tools/orchestrate-migration.js +235 -0
- package/dist/tools/orchestrate-migration.js.map +1 -0
- package/dist/tools/parse-stack-trace.d.ts +63 -0
- package/dist/tools/parse-stack-trace.d.ts.map +1 -0
- package/dist/tools/parse-stack-trace.js +92 -0
- package/dist/tools/parse-stack-trace.js.map +1 -0
- package/dist/tools/plan-migration.d.ts +388 -0
- package/dist/tools/plan-migration.d.ts.map +1 -0
- package/dist/tools/plan-migration.js +826 -0
- package/dist/tools/plan-migration.js.map +1 -0
- package/dist/tools/resolve-type.d.ts +54 -0
- package/dist/tools/resolve-type.d.ts.map +1 -0
- package/dist/tools/resolve-type.js +101 -0
- package/dist/tools/resolve-type.js.map +1 -0
- package/dist/tools/review-feedback.d.ts +124 -0
- package/dist/tools/review-feedback.d.ts.map +1 -0
- package/dist/tools/review-feedback.js +276 -0
- package/dist/tools/review-feedback.js.map +1 -0
- package/dist/tools/rollback-changes.d.ts +42 -0
- package/dist/tools/rollback-changes.d.ts.map +1 -0
- package/dist/tools/rollback-changes.js +95 -0
- package/dist/tools/rollback-changes.js.map +1 -0
- package/dist/tools/run-angular-cli.d.ts +102 -0
- package/dist/tools/run-angular-cli.d.ts.map +1 -0
- package/dist/tools/run-angular-cli.js +152 -0
- package/dist/tools/run-angular-cli.js.map +1 -0
- package/dist/tools/run-build.d.ts +201 -0
- package/dist/tools/run-build.d.ts.map +1 -0
- package/dist/tools/run-build.js +554 -0
- package/dist/tools/run-build.js.map +1 -0
- package/dist/tools/run-schematic.d.ts +173 -0
- package/dist/tools/run-schematic.d.ts.map +1 -0
- package/dist/tools/run-schematic.js +410 -0
- package/dist/tools/run-schematic.js.map +1 -0
- package/dist/tools/scan-all.d.ts +160 -0
- package/dist/tools/scan-all.d.ts.map +1 -0
- package/dist/tools/scan-all.js +486 -0
- package/dist/tools/scan-all.js.map +1 -0
- package/dist/tools/scan-angular.d.ts +132 -0
- package/dist/tools/scan-angular.d.ts.map +1 -0
- package/dist/tools/scan-angular.js +411 -0
- package/dist/tools/scan-angular.js.map +1 -0
- package/dist/tools/scan-architecture.d.ts +351 -0
- package/dist/tools/scan-architecture.d.ts.map +1 -0
- package/dist/tools/scan-architecture.js +1290 -0
- package/dist/tools/scan-architecture.js.map +1 -0
- package/dist/tools/scan-solid.d.ts +132 -0
- package/dist/tools/scan-solid.d.ts.map +1 -0
- package/dist/tools/scan-solid.js +435 -0
- package/dist/tools/scan-solid.js.map +1 -0
- package/dist/tools/search-codebase.d.ts +64 -0
- package/dist/tools/search-codebase.d.ts.map +1 -0
- package/dist/tools/search-codebase.js +109 -0
- package/dist/tools/search-codebase.js.map +1 -0
- package/dist/tools/shared/scan-types.d.ts +200 -0
- package/dist/tools/shared/scan-types.d.ts.map +1 -0
- package/dist/tools/shared/scan-types.js +7 -0
- package/dist/tools/shared/scan-types.js.map +1 -0
- package/dist/tools/suggest-improvements.d.ts +96 -0
- package/dist/tools/suggest-improvements.d.ts.map +1 -0
- package/dist/tools/suggest-improvements.js +182 -0
- package/dist/tools/suggest-improvements.js.map +1 -0
- package/dist/tools/transform-code-batch.d.ts +57 -0
- package/dist/tools/transform-code-batch.d.ts.map +1 -0
- package/dist/tools/transform-code-batch.js +107 -0
- package/dist/tools/transform-code-batch.js.map +1 -0
- package/dist/tools/transform-code.d.ts +352 -0
- package/dist/tools/transform-code.d.ts.map +1 -0
- package/dist/tools/transform-code.js +1171 -0
- package/dist/tools/transform-code.js.map +1 -0
- package/dist/tools/validate-before-transform.d.ts +54 -0
- package/dist/tools/validate-before-transform.d.ts.map +1 -0
- package/dist/tools/validate-before-transform.js +141 -0
- package/dist/tools/validate-before-transform.js.map +1 -0
- package/dist/tools/validate-project-compatibility.d.ts +119 -0
- package/dist/tools/validate-project-compatibility.d.ts.map +1 -0
- package/dist/tools/validate-project-compatibility.js +243 -0
- package/dist/tools/validate-project-compatibility.js.map +1 -0
- package/dist/tools/validate-transformation.d.ts +105 -0
- package/dist/tools/validate-transformation.d.ts.map +1 -0
- package/dist/tools/validate-transformation.js +391 -0
- package/dist/tools/validate-transformation.js.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +38 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format-tool-response.d.ts +72 -0
- package/dist/utils/format-tool-response.d.ts.map +1 -0
- package/dist/utils/format-tool-response.js +149 -0
- package/dist/utils/format-tool-response.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Find Usages Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for finding all references to a symbol (class, method, function,
|
|
5
|
+
* variable, constant) across a TypeScript project.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Uses ts-morph `findReferences()` via `UsageFinder` from `@angular-modernizer/api`.
|
|
9
|
+
* Ideal as a second step in bug investigation after `parse-stack-trace` has
|
|
10
|
+
* identified the affected files and symbols.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Via MCP:
|
|
15
|
+
* // tool: find-usages
|
|
16
|
+
* // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { Project } from 'ts-morph';
|
|
20
|
+
import { UsageFinder, } from '@angular-modernizer/api';
|
|
21
|
+
import { existsSync } from 'node:fs';
|
|
22
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
23
|
+
/**
|
|
24
|
+
* MCP tool that finds all references to a named symbol across a TypeScript project.
|
|
25
|
+
*/
|
|
26
|
+
export class FindUsagesTool {
|
|
27
|
+
name = 'find-usages';
|
|
28
|
+
description = 'Find all references to a symbol (class, method, function, variable, or constant) ' +
|
|
29
|
+
'across a TypeScript project. Returns file paths, line numbers, source snippets, ' +
|
|
30
|
+
'and usage type (read/write/call). Use after parse-stack-trace to trace call paths ' +
|
|
31
|
+
'and determine blast radius before proposing a bug fix.';
|
|
32
|
+
inputSchema = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
symbol: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Symbol name to search for (class, method, function, variable, constant).',
|
|
38
|
+
},
|
|
39
|
+
projectRoot: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Absolute path to the project root. Must contain a tsconfig.json.',
|
|
42
|
+
},
|
|
43
|
+
file: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Restrict results to this source file (absolute path). Optional.',
|
|
46
|
+
},
|
|
47
|
+
usageType: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: ['read', 'write', 'call'],
|
|
50
|
+
description: 'Restrict results to this usage type. Optional.',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ['symbol', 'projectRoot'],
|
|
54
|
+
};
|
|
55
|
+
async execute(args) {
|
|
56
|
+
const params = args;
|
|
57
|
+
if (!params.symbol) {
|
|
58
|
+
throw new Error('symbol is required');
|
|
59
|
+
}
|
|
60
|
+
if (!params.projectRoot) {
|
|
61
|
+
throw new Error('projectRoot is required');
|
|
62
|
+
}
|
|
63
|
+
if (!existsSync(params.projectRoot)) {
|
|
64
|
+
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
65
|
+
}
|
|
66
|
+
const tsConfigPath = findTsConfig(params.projectRoot);
|
|
67
|
+
if (!tsConfigPath) {
|
|
68
|
+
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
69
|
+
}
|
|
70
|
+
const project = new Project({ tsConfigFilePath: tsConfigPath });
|
|
71
|
+
const finder = new UsageFinder(project);
|
|
72
|
+
const usages = finder.findUsages(params.symbol, {
|
|
73
|
+
file: params.file,
|
|
74
|
+
usageType: params.usageType,
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
usages,
|
|
78
|
+
totalCount: usages.length,
|
|
79
|
+
summary: this.buildSummary(params.symbol, usages, params.file),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
buildSummary(symbol, usages, file) {
|
|
83
|
+
if (usages.length === 0) {
|
|
84
|
+
const scope = file ? `in ${file}` : 'across the project';
|
|
85
|
+
return `No usages of '${symbol}' found ${scope}.`;
|
|
86
|
+
}
|
|
87
|
+
const byFile = new Map();
|
|
88
|
+
for (const u of usages) {
|
|
89
|
+
const list = byFile.get(u.file) ?? [];
|
|
90
|
+
list.push(u);
|
|
91
|
+
byFile.set(u.file, list);
|
|
92
|
+
}
|
|
93
|
+
const lines = [
|
|
94
|
+
`Found ${usages.length} usage(s) of '${symbol}' across ${byFile.size} file(s):`,
|
|
95
|
+
];
|
|
96
|
+
for (const [filePath, fileUsages] of byFile) {
|
|
97
|
+
lines.push(` ${filePath} (${fileUsages.length})`);
|
|
98
|
+
for (const u of fileUsages.slice(0, 3)) {
|
|
99
|
+
lines.push(` L${u.line}: [${u.usageType}] ${u.snippet}`);
|
|
100
|
+
}
|
|
101
|
+
if (fileUsages.length > 3) {
|
|
102
|
+
lines.push(` ... and ${fileUsages.length - 3} more`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=find-usages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-usages.js","sourceRoot":"","sources":["../../src/tools/find-usages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,WAAW,GAGZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAuC3D;;GAEG;AACH,MAAM,OAAO,cAAc;IAChB,IAAI,GAAG,aAAa,CAAC;IAErB,WAAW,GAClB,mFAAmF;QACnF,kFAAkF;QAClF,oFAAoF;QACpF,wDAAwD,CAAC;IAElD,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,0EAA0E;aAC7E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,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9D,CAAC;YACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,KAAK,CAAC,IAAI,CAAC,eAAe,UAAU,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Call Graph Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for building a caller/callee graph for a named method or function.
|
|
5
|
+
* Supports configurable traversal direction and depth.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Use this after `parse-stack-trace` or `find-usages` to understand how an error
|
|
9
|
+
* propagates through the call hierarchy. Useful for determining blast radius
|
|
10
|
+
* before proposing a bug fix.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Via MCP:
|
|
15
|
+
* // tool: get-call-graph
|
|
16
|
+
* // args: { method: 'getUser', file: '/project/src/app/user.service.ts', projectRoot: '/project' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { type MCPTool } from '../types.js';
|
|
20
|
+
import { type CallGraphResult } from '@angular-modernizer/api';
|
|
21
|
+
/**
|
|
22
|
+
* MCP tool that builds a call graph for a named method or function.
|
|
23
|
+
*/
|
|
24
|
+
export declare class GetCallGraphTool implements MCPTool {
|
|
25
|
+
readonly name = "get-call-graph";
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly inputSchema: {
|
|
28
|
+
type: string;
|
|
29
|
+
properties: {
|
|
30
|
+
method: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
file: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
projectRoot: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
direction: {
|
|
43
|
+
type: string;
|
|
44
|
+
enum: string[];
|
|
45
|
+
description: string;
|
|
46
|
+
default: string;
|
|
47
|
+
};
|
|
48
|
+
depth: {
|
|
49
|
+
type: string;
|
|
50
|
+
description: string;
|
|
51
|
+
default: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
required: string[];
|
|
55
|
+
};
|
|
56
|
+
execute(args: Record<string, unknown>): Promise<CallGraphResult & {
|
|
57
|
+
summary: string;
|
|
58
|
+
}>;
|
|
59
|
+
private buildSummary;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=get-call-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-call-graph.d.ts","sourceRoot":"","sources":["../../src/tools/get-call-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AA8BjC;;GAEG;AACH,qBAAa,gBAAiB,YAAW,OAAO;IAC9C,QAAQ,CAAC,IAAI,oBAAoB;IAEjC,QAAQ,CAAC,WAAW,SAImE;IAEvF,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BlB;IAEI,OAAO,CACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,eAAe,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IA4CjD,OAAO,CAAC,YAAY;CA6BrB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Call Graph Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for building a caller/callee graph for a named method or function.
|
|
5
|
+
* Supports configurable traversal direction and depth.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Use this after `parse-stack-trace` or `find-usages` to understand how an error
|
|
9
|
+
* propagates through the call hierarchy. Useful for determining blast radius
|
|
10
|
+
* before proposing a bug fix.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Via MCP:
|
|
15
|
+
* // tool: get-call-graph
|
|
16
|
+
* // args: { method: 'getUser', file: '/project/src/app/user.service.ts', projectRoot: '/project' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { Project } from 'ts-morph';
|
|
20
|
+
import { CallGraphBuilder, } from '@angular-modernizer/api';
|
|
21
|
+
import { existsSync } from 'node:fs';
|
|
22
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
23
|
+
/**
|
|
24
|
+
* MCP tool that builds a call graph for a named method or function.
|
|
25
|
+
*/
|
|
26
|
+
export class GetCallGraphTool {
|
|
27
|
+
name = 'get-call-graph';
|
|
28
|
+
description = 'Build a caller/callee graph for a named method or function. ' +
|
|
29
|
+
'Direction "up" shows who calls the method, "down" shows what it calls, ' +
|
|
30
|
+
'"both" returns the full call tree. Configurable depth (default: 2). ' +
|
|
31
|
+
'Use after parse-stack-trace to trace error propagation through the call hierarchy.';
|
|
32
|
+
inputSchema = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
method: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Name of the method or function to analyse.',
|
|
38
|
+
},
|
|
39
|
+
file: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Absolute path of the source file containing the method.',
|
|
42
|
+
},
|
|
43
|
+
projectRoot: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Absolute path to the project root. Must contain a tsconfig.json.',
|
|
46
|
+
},
|
|
47
|
+
direction: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: ['up', 'down', 'both'],
|
|
50
|
+
description: 'Traversal direction. Default: "both".',
|
|
51
|
+
default: 'both',
|
|
52
|
+
},
|
|
53
|
+
depth: {
|
|
54
|
+
type: 'number',
|
|
55
|
+
description: 'How many levels deep to traverse. Default: 2.',
|
|
56
|
+
default: 2,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['method', 'file', 'projectRoot'],
|
|
60
|
+
};
|
|
61
|
+
async execute(args) {
|
|
62
|
+
const params = args;
|
|
63
|
+
if (!params.method) {
|
|
64
|
+
throw new Error('method is required');
|
|
65
|
+
}
|
|
66
|
+
if (!params.file) {
|
|
67
|
+
throw new Error('file is required');
|
|
68
|
+
}
|
|
69
|
+
if (!params.projectRoot) {
|
|
70
|
+
throw new Error('projectRoot is required');
|
|
71
|
+
}
|
|
72
|
+
if (!existsSync(params.projectRoot)) {
|
|
73
|
+
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
74
|
+
}
|
|
75
|
+
const tsConfigPath = findTsConfig(params.projectRoot);
|
|
76
|
+
if (!tsConfigPath) {
|
|
77
|
+
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
78
|
+
}
|
|
79
|
+
const project = new Project({ tsConfigFilePath: tsConfigPath });
|
|
80
|
+
const graphBuilder = new CallGraphBuilder(project);
|
|
81
|
+
const options = {
|
|
82
|
+
direction: params.direction ?? 'both',
|
|
83
|
+
depth: params.depth ?? 2,
|
|
84
|
+
};
|
|
85
|
+
const result = graphBuilder.buildCallGraph(params.method, params.file, options);
|
|
86
|
+
return {
|
|
87
|
+
...result,
|
|
88
|
+
summary: this.buildSummary(params.method, result),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
buildSummary(method, result) {
|
|
92
|
+
if (!result.target) {
|
|
93
|
+
return `Method '${method}' not found in the specified file.`;
|
|
94
|
+
}
|
|
95
|
+
const lines = [
|
|
96
|
+
`Call graph for '${method}' at ${result.target.file}:${result.target.line}`,
|
|
97
|
+
];
|
|
98
|
+
if (result.callers.length > 0) {
|
|
99
|
+
lines.push(`\nCallers (${result.callers.length}):`);
|
|
100
|
+
for (const c of result.callers) {
|
|
101
|
+
lines.push(` ← ${c.name} (${c.file}:${c.line})`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
lines.push('\nNo callers found (root method or not traced).');
|
|
106
|
+
}
|
|
107
|
+
if (result.callees.length > 0) {
|
|
108
|
+
lines.push(`\nCallees (${result.callees.length}):`);
|
|
109
|
+
for (const c of result.callees) {
|
|
110
|
+
lines.push(` → ${c.name} (${c.file}:${c.line})`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
lines.push('\nNo callees found (leaf method or not traced).');
|
|
115
|
+
}
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=get-call-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-call-graph.js","sourceRoot":"","sources":["../../src/tools/get-call-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA4B3D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAClB,IAAI,GAAG,gBAAgB,CAAC;IAExB,WAAW,GAClB,8DAA8D;QAC9D,yEAAyE;QACzE,sEAAsE;QACtE,oFAAoF,CAAC;IAE9E,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW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AC,CAAC;QAChE,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,cAAc,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;YACpD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBAC/B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for querying progress of streaming operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPTool } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* MCP tool for getting operation progress.
|
|
9
|
+
*/
|
|
10
|
+
export declare class GetOperationProgressTool implements MCPTool {
|
|
11
|
+
readonly name = "get-operation-progress";
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly inputSchema: {
|
|
14
|
+
type: string;
|
|
15
|
+
properties: {
|
|
16
|
+
operationId: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
sinceTimestamp: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
execute(args: Record<string, unknown>): Promise<unknown>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=get-operation-progress-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-operation-progress-tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-operation-progress-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAM3C;;GAEG;AACH,qBAAa,wBAAyB,YAAW,OAAO;IACtD,QAAQ,CAAC,IAAI,4BAA4B;IACzC,QAAQ,CAAC,WAAW,SAEkE;IAEtF,QAAQ,CAAC,WAAW;;;;;;;;;;;;;MAelB;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAS/D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for querying progress of streaming operations.
|
|
5
|
+
*/
|
|
6
|
+
import { getOperationProgress, validateInput, } from './get-operation-progress.js';
|
|
7
|
+
/**
|
|
8
|
+
* MCP tool for getting operation progress.
|
|
9
|
+
*/
|
|
10
|
+
export class GetOperationProgressTool {
|
|
11
|
+
name = 'get-operation-progress';
|
|
12
|
+
description = 'Get progress for a streaming operation (transformation or analysis). ' +
|
|
13
|
+
'Returns status, events, and operation metadata including diffs and syntax errors.';
|
|
14
|
+
inputSchema = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
operationId: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'Unique operation identifier from streaming transformation/analysis',
|
|
20
|
+
},
|
|
21
|
+
sinceTimestamp: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
description: 'Only return events after this timestamp (milliseconds since epoch)',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ['operationId'],
|
|
27
|
+
};
|
|
28
|
+
async execute(args) {
|
|
29
|
+
// Validate input
|
|
30
|
+
const validatedInput = validateInput(args);
|
|
31
|
+
// Execute the operation
|
|
32
|
+
const result = await getOperationProgress(validatedInput);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=get-operation-progress-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-operation-progress-tool.js","sourceRoot":"","sources":["../../src/tools/get-operation-progress-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAC1B,IAAI,GAAG,wBAAwB,CAAC;IAChC,WAAW,GAClB,uEAAuE;QACvE,mFAAmF,CAAC;IAE7E,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,oEAAoE;aACvE;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,oEAAoE;aACvE;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,CAAC;KAC1B,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,IAA6B;QACzC,iBAAiB;QACjB,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAE3C,wBAAwB;QACxB,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAE1D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Input for get-operation-progress tool
|
|
6
|
+
*/
|
|
7
|
+
export interface GetOperationProgressInput {
|
|
8
|
+
operationId: string;
|
|
9
|
+
sinceTimestamp?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate get-operation-progress input
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateInput(input: unknown): GetOperationProgressInput;
|
|
15
|
+
/**
|
|
16
|
+
* Get progress for a streaming operation
|
|
17
|
+
* Returns status, events, and operation metadata
|
|
18
|
+
*/
|
|
19
|
+
export declare function getOperationProgress(input: GetOperationProgressInput): Promise<{
|
|
20
|
+
operationId: string;
|
|
21
|
+
status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
22
|
+
events: {
|
|
23
|
+
phase: string;
|
|
24
|
+
message: string;
|
|
25
|
+
percentage: number;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
diff?: {
|
|
28
|
+
filePath: string;
|
|
29
|
+
diff: string;
|
|
30
|
+
linesAdded: number;
|
|
31
|
+
linesRemoved: number;
|
|
32
|
+
};
|
|
33
|
+
syntaxErrors?: {
|
|
34
|
+
filePath: string;
|
|
35
|
+
line: number;
|
|
36
|
+
message: string;
|
|
37
|
+
}[];
|
|
38
|
+
memoryUsage?: {
|
|
39
|
+
heapUsed: number;
|
|
40
|
+
heapTotal: number;
|
|
41
|
+
external: number;
|
|
42
|
+
percentage: number;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
totalEvents: number;
|
|
46
|
+
elapsedTime: number;
|
|
47
|
+
eta?: number;
|
|
48
|
+
error?: string;
|
|
49
|
+
result?: unknown;
|
|
50
|
+
}>;
|
|
51
|
+
//# sourceMappingURL=get-operation-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-operation-progress.d.ts","sourceRoot":"","sources":["../../src/tools/get-operation-progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CAsBvE;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IACzD,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,YAAY,CAAC,EAAE;YACb,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,EAAE,CAAC;QACJ,WAAW,CAAC,EAAE;YACZ,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;KACH,EAAE,CAAC;IACJ,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,CAuED"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
+
*/
|
|
4
|
+
import { ProgressStore } from '../streaming/progress-store.js';
|
|
5
|
+
/**
|
|
6
|
+
* Validate get-operation-progress input
|
|
7
|
+
*/
|
|
8
|
+
export function validateInput(input) {
|
|
9
|
+
if (!input || typeof input !== 'object') {
|
|
10
|
+
throw new Error('Input must be an object');
|
|
11
|
+
}
|
|
12
|
+
const obj = input;
|
|
13
|
+
if (!obj['operationId'] || typeof obj['operationId'] !== 'string') {
|
|
14
|
+
throw new Error('operationId is required and must be a string');
|
|
15
|
+
}
|
|
16
|
+
if (obj['sinceTimestamp'] !== undefined &&
|
|
17
|
+
typeof obj['sinceTimestamp'] !== 'number') {
|
|
18
|
+
throw new Error('sinceTimestamp must be a number');
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
operationId: obj['operationId'],
|
|
22
|
+
sinceTimestamp: obj['sinceTimestamp'],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get progress for a streaming operation
|
|
27
|
+
* Returns status, events, and operation metadata
|
|
28
|
+
*/
|
|
29
|
+
export async function getOperationProgress(input) {
|
|
30
|
+
const store = ProgressStore.getInstance();
|
|
31
|
+
const { operationId, sinceTimestamp } = input;
|
|
32
|
+
// Verify operation exists
|
|
33
|
+
if (!store.hasOperation(operationId)) {
|
|
34
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
35
|
+
}
|
|
36
|
+
// Get metadata
|
|
37
|
+
const metadata = store.getMetadata(operationId);
|
|
38
|
+
const events = store.getEvents(operationId, sinceTimestamp);
|
|
39
|
+
// Calculate elapsed time
|
|
40
|
+
const elapsedTime = Date.now() - metadata.startTime;
|
|
41
|
+
// Estimate ETA based on progress (only for running operations)
|
|
42
|
+
let eta;
|
|
43
|
+
if (metadata.status === 'running' && events.length > 0) {
|
|
44
|
+
const lastEvent = events.at(-1);
|
|
45
|
+
if (lastEvent && lastEvent.percentage > 0 && lastEvent.percentage < 100) {
|
|
46
|
+
const estimatedTotal = (elapsedTime / lastEvent.percentage) * 100;
|
|
47
|
+
eta = Math.round(estimatedTotal - elapsedTime);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Get total event count (not filtered)
|
|
51
|
+
const allEvents = store.getEvents(operationId);
|
|
52
|
+
// Retrieve stored result (set by tools like scan-architecture after completion)
|
|
53
|
+
const result = metadata.status === 'completed' ? store.getResult(operationId) : undefined;
|
|
54
|
+
return {
|
|
55
|
+
operationId,
|
|
56
|
+
status: metadata.status,
|
|
57
|
+
events: events.map((event) => ({
|
|
58
|
+
phase: event.phase,
|
|
59
|
+
message: event.message,
|
|
60
|
+
percentage: event.percentage,
|
|
61
|
+
timestamp: event.timestamp,
|
|
62
|
+
diff: event.diff
|
|
63
|
+
? {
|
|
64
|
+
filePath: event.diff.filePath,
|
|
65
|
+
diff: event.diff.diff,
|
|
66
|
+
linesAdded: event.diff.linesAdded,
|
|
67
|
+
linesRemoved: event.diff.linesRemoved,
|
|
68
|
+
}
|
|
69
|
+
: undefined,
|
|
70
|
+
syntaxErrors: event.syntaxErrors
|
|
71
|
+
? event.syntaxErrors.map((err) => ({
|
|
72
|
+
filePath: err.file,
|
|
73
|
+
line: err.line,
|
|
74
|
+
message: err.message,
|
|
75
|
+
}))
|
|
76
|
+
: undefined,
|
|
77
|
+
memoryUsage: event.memoryUsage
|
|
78
|
+
? {
|
|
79
|
+
heapUsed: event.memoryUsage.heapUsed,
|
|
80
|
+
heapTotal: event.memoryUsage.heapTotal,
|
|
81
|
+
external: event.memoryUsage.external,
|
|
82
|
+
percentage: event.memoryUsage.percentage,
|
|
83
|
+
}
|
|
84
|
+
: undefined,
|
|
85
|
+
})),
|
|
86
|
+
totalEvents: allEvents.length,
|
|
87
|
+
elapsedTime,
|
|
88
|
+
eta,
|
|
89
|
+
error: metadata.error,
|
|
90
|
+
result,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=get-operation-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-operation-progress.js","sourceRoot":"","sources":["../../src/tools/get-operation-progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAU/D;;GAEG;AACH,MA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C,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY;iBACtC;gBACH,CAAC,CAAC,SAAS;YACb,YAAY,EAAE,KAAK,CAAC,YAAY;gBAC9B,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAC/B,QAAQ,EAAE,GAAG,CAAC,IAAI;oBAClB,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,OAAO,EAAE,GAAG,CAAC,OAAO;iBACrB,CAAC,CAAC;gBACL,CAAC,CAAC,SAAS;YACb,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC5B,CAAC,CAAC;oBACE,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ;oBACpC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS;oBACtC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ;oBACpC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU;iBACzC;gBACH,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;QACH,WAAW,EAAE,SAAS,CAAC,MAAM;QAC7B,WAAW;QACX,GAAG;QACH,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Feedback Analyzer Helper
|
|
3
|
+
*
|
|
4
|
+
* Pattern analysis utilities for transformation feedback.
|
|
5
|
+
* Detects success patterns, failure patterns, and quality trends.
|
|
6
|
+
*
|
|
7
|
+
* Analysis Criteria:
|
|
8
|
+
* - Success patterns: ≥3 occurrences, ≥80% success rate, high confidence
|
|
9
|
+
* - Failure patterns: ≥2 occurrences, recommend avoiding
|
|
10
|
+
* - Quality trends: Identify degraded quality, suggest review
|
|
11
|
+
*/
|
|
12
|
+
import type { TransformationFeedback } from '@angular-modernizer/core';
|
|
13
|
+
/**
|
|
14
|
+
* Extracted feedback insight for AI learning
|
|
15
|
+
*/
|
|
16
|
+
export interface FeedbackInsight {
|
|
17
|
+
/** Type of insight */
|
|
18
|
+
type: 'success-pattern' | 'failure-pattern' | 'quality-trend' | 'anti-pattern';
|
|
19
|
+
/** Pattern description */
|
|
20
|
+
pattern: string;
|
|
21
|
+
/** Number of occurrences */
|
|
22
|
+
occurrences: number;
|
|
23
|
+
/** Success rate for this pattern (0.0-1.0) */
|
|
24
|
+
successRate: number;
|
|
25
|
+
/** Confidence in this insight (0.0-1.0) */
|
|
26
|
+
confidence: number;
|
|
27
|
+
/** Detailed description */
|
|
28
|
+
description: string;
|
|
29
|
+
/** Actionable recommendation for AI */
|
|
30
|
+
recommendation: string;
|
|
31
|
+
/** Example transformation IDs */
|
|
32
|
+
examples: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Analyze patterns in transformation feedback
|
|
36
|
+
*
|
|
37
|
+
* @param feedback - Array of transformation feedback to analyze
|
|
38
|
+
* @param analysisType - Type of analysis to perform
|
|
39
|
+
* @param minConfidence - Minimum confidence threshold (0.0-1.0)
|
|
40
|
+
* @returns Array of feedback insights sorted by confidence
|
|
41
|
+
*/
|
|
42
|
+
export declare function analyzePatterns(feedback: TransformationFeedback[], analysisType: 'success-patterns' | 'failure-patterns' | 'quality-trends' | 'all', minConfidence: number): FeedbackInsight[];
|
|
43
|
+
//# sourceMappingURL=feedback-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-analyzer.d.ts","sourceRoot":"","sources":["../../../src/tools/helpers/feedback-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,IAAI,EACA,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,cAAc,CAAC;IACnB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAsBD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,sBAAsB,EAAE,EAClC,YAAY,EACR,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,KAAK,EACT,aAAa,EAAE,MAAM,GACpB,eAAe,EAAE,CA2BnB"}
|