@angular-modernizer/adapter-mcp 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -64
- package/dist/cli.js +8 -0
- package/dist/core/project-analyzer.d.ts +3 -12
- package/dist/core/project-analyzer.js +3 -12
- package/dist/index.d.ts +118 -3
- package/dist/index.js +46 -3
- package/dist/mcp-watcher.d.ts +28 -8
- package/dist/mcp-watcher.js +7 -7
- package/dist/scan-host/scan-host.d.ts +119 -0
- package/dist/scan-host/scan-host.js +376 -0
- package/dist/scan-host/scan-protocol.d.ts +35 -0
- package/dist/scan-host/scan-protocol.js +6 -0
- package/dist/scan-host/scan-worker.d.ts +14 -0
- package/dist/scan-host/scan-worker.js +48 -0
- package/dist/server/limited-stdio-transport.d.ts +7 -0
- package/dist/server/mcp-server.d.ts +11 -7
- package/dist/server/mcp-server.js +4 -7
- package/dist/server/sdk-server.d.ts +1 -0
- package/dist/server/tool-registry.d.ts +3 -7
- package/dist/server/tool-registry.js +1 -7
- package/dist/streaming/progress-store.d.ts +22 -5
- package/dist/streaming/progress-store.js +9 -5
- package/dist/tools/analyze-build-impact.d.ts +56 -34
- package/dist/tools/analyze-build-impact.js +30 -25
- package/dist/tools/analyze-core-to-shared.d.ts +42 -12
- package/dist/tools/analyze-core-to-shared.js +11 -10
- package/dist/tools/analyze-parser-performance.d.ts +23 -22
- package/dist/tools/analyze-parser-performance.js +20 -18
- package/dist/tools/analyze-project.d.ts +82 -12
- package/dist/tools/analyze-project.js +98 -101
- package/dist/tools/check-incremental-compatibility.d.ts +13 -11
- package/dist/tools/check-incremental-compatibility.js +11 -8
- package/dist/tools/collect-feedback.d.ts +41 -26
- package/dist/tools/collect-feedback.js +32 -23
- package/dist/tools/compare-health.d.ts +76 -19
- package/dist/tools/compare-health.js +26 -19
- package/dist/tools/extract-libraries.d.ts +44 -20
- package/dist/tools/extract-libraries.js +16 -17
- package/dist/tools/find-angular-symbol.d.ts +25 -23
- package/dist/tools/find-angular-symbol.js +17 -14
- package/dist/tools/find-component-hosts.d.ts +31 -25
- package/dist/tools/find-component-hosts.js +24 -21
- package/dist/tools/find-usages.d.ts +23 -21
- package/dist/tools/find-usages.js +19 -16
- package/dist/tools/get-bootstrap-execution.d.ts +33 -25
- package/dist/tools/get-bootstrap-execution.js +25 -22
- package/dist/tools/get-call-graph.d.ts +18 -13
- package/dist/tools/get-call-graph.js +24 -21
- package/dist/tools/get-operation-progress-tool.d.ts +12 -6
- package/dist/tools/get-operation-progress-tool.js +11 -6
- package/dist/tools/get-operation-progress.d.ts +26 -0
- package/dist/tools/helpers/analysis-output.d.ts +5 -0
- package/dist/tools/helpers/batch-kernel.d.ts +14 -0
- package/dist/tools/helpers/batch-kernel.js +12 -0
- package/dist/tools/helpers/compact-output.d.ts +2 -1
- package/dist/tools/helpers/compact-output.js +2 -1
- package/dist/tools/helpers/health-delta.d.ts +27 -14
- package/dist/tools/helpers/health-delta.js +11 -14
- package/dist/tools/helpers/project-cache.d.ts +50 -34
- package/dist/tools/helpers/project-cache.js +33 -34
- package/dist/tools/helpers/rule-runner.d.ts +23 -16
- package/dist/tools/helpers/rule-runner.js +24 -17
- package/dist/tools/helpers/scan-engine.d.ts +107 -0
- package/dist/tools/helpers/scan-engine.js +197 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
- package/dist/tools/helpers/suggestion-generator.js +0 -12
- package/dist/tools/helpers/tool-cache.d.ts +11 -0
- package/dist/tools/helpers/tool-cache.js +15 -0
- package/dist/tools/helpers/tool-context.d.ts +11 -8
- package/dist/tools/helpers/tool-context.js +5 -8
- package/dist/tools/inspect-form-group.d.ts +32 -25
- package/dist/tools/inspect-form-group.js +24 -21
- package/dist/tools/inspect-i18n.d.ts +28 -22
- package/dist/tools/inspect-i18n.js +20 -17
- package/dist/tools/inspect-template.d.ts +31 -24
- package/dist/tools/inspect-template.js +23 -20
- package/dist/tools/learn-patterns.d.ts +88 -12
- package/dist/tools/learn-patterns.js +17 -11
- package/dist/tools/list-imports.d.ts +42 -25
- package/dist/tools/list-imports.js +23 -20
- package/dist/tools/orchestrate-migration.d.ts +31 -9
- package/dist/tools/orchestrate-migration.js +12 -7
- package/dist/tools/parse-stack-trace.d.ts +23 -21
- package/dist/tools/parse-stack-trace.js +10 -7
- package/dist/tools/plan-migration.d.ts +65 -25
- package/dist/tools/plan-migration.js +19 -19
- package/dist/tools/resolve-type.d.ts +19 -9
- package/dist/tools/resolve-type.js +19 -11
- package/dist/tools/review-feedback.d.ts +27 -24
- package/dist/tools/review-feedback.js +24 -20
- package/dist/tools/rollback-changes.d.ts +13 -9
- package/dist/tools/rollback-changes.js +10 -7
- package/dist/tools/run-angular-cli.d.ts +12 -10
- package/dist/tools/run-angular-cli.js +11 -8
- package/dist/tools/run-build.d.ts +13 -11
- package/dist/tools/run-build.js +11 -8
- package/dist/tools/run-schematic.d.ts +12 -10
- package/dist/tools/run-schematic.js +11 -8
- package/dist/tools/scan-all.d.ts +69 -12
- package/dist/tools/scan-all.js +55 -122
- package/dist/tools/scan-angular.d.ts +41 -9
- package/dist/tools/scan-angular.js +66 -135
- package/dist/tools/scan-architecture.d.ts +75 -14
- package/dist/tools/scan-architecture.js +180 -185
- package/dist/tools/scan-solid.d.ts +40 -9
- package/dist/tools/scan-solid.js +64 -133
- package/dist/tools/search-codebase.d.ts +30 -24
- package/dist/tools/search-codebase.js +13 -10
- package/dist/tools/server-status.d.ts +116 -24
- package/dist/tools/server-status.js +85 -26
- package/dist/tools/suggest-improvements.d.ts +22 -19
- package/dist/tools/suggest-improvements.js +21 -17
- package/dist/tools/trace-output-flow.d.ts +32 -25
- package/dist/tools/trace-output-flow.js +24 -21
- package/dist/tools/transform-code.d.ts +71 -10
- package/dist/tools/transform-code.js +60 -42
- package/dist/tools/validate-before-transform.d.ts +24 -9
- package/dist/tools/validate-before-transform.js +10 -7
- package/dist/tools/validate-project-compatibility.d.ts +18 -13
- package/dist/tools/validate-project-compatibility.js +17 -11
- package/dist/tools/validate-transformation.d.ts +28 -11
- package/dist/tools/validate-transformation.js +14 -8
- package/dist/tools/verify-citations.d.ts +37 -16
- package/dist/tools/verify-citations.js +19 -16
- package/dist/types.d.ts +40 -10
- package/dist/types.js +0 -5
- package/package.json +12 -18
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.js +0 -7
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
2
|
+
import { type CallGraphResult } from '@angular-modernizer/api';
|
|
3
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
|
+
/** Tool output: the call graph (trees omitted with `summaryOnly`) plus a text summary. */
|
|
5
|
+
export type GetCallGraphOutput = Omit<CallGraphResult, 'callers' | 'callees'> & Partial<Pick<CallGraphResult, 'callers' | 'callees'>> & {
|
|
6
|
+
/** Short text summary with the direct callers and callees. */
|
|
7
|
+
summary: string;
|
|
8
|
+
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
9
|
+
warnings?: string[];
|
|
10
|
+
};
|
|
1
11
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Get Call Graph Tool
|
|
3
|
-
*
|
|
4
12
|
* MCP tool for building a caller/callee graph for a named method, function,
|
|
5
13
|
* constructor, get/set accessor or arrow-function property.
|
|
6
14
|
* Supports configurable traversal direction and depth.
|
|
@@ -24,17 +32,6 @@
|
|
|
24
32
|
* // projectRoot: '/project', direction: 'down', depth: 4 }
|
|
25
33
|
* ```
|
|
26
34
|
*/
|
|
27
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
28
|
-
import { type CallGraphResult } from '@angular-modernizer/api';
|
|
29
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
30
|
-
/** Tool output: the call graph (trees omitted with `summaryOnly`) plus a text summary. */
|
|
31
|
-
export type GetCallGraphOutput = Omit<CallGraphResult, 'callers' | 'callees'> & Partial<Pick<CallGraphResult, 'callers' | 'callees'>> & {
|
|
32
|
-
summary: string;
|
|
33
|
-
warnings?: string[];
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* MCP tool that builds a call graph for a named method or function.
|
|
37
|
-
*/
|
|
38
35
|
export declare class GetCallGraphTool implements MCPTool {
|
|
39
36
|
private readonly projects;
|
|
40
37
|
readonly name = "get-call-graph";
|
|
@@ -42,6 +39,10 @@ export declare class GetCallGraphTool implements MCPTool {
|
|
|
42
39
|
readonly annotations: ToolAnnotations;
|
|
43
40
|
constructor(projects?: ProjectCache);
|
|
44
41
|
readonly description: string;
|
|
42
|
+
/**
|
|
43
|
+
* JSON Schema of the tool arguments.
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
45
46
|
readonly inputSchema: {
|
|
46
47
|
type: string;
|
|
47
48
|
additionalProperties: boolean;
|
|
@@ -87,6 +88,10 @@ export declare class GetCallGraphTool implements MCPTool {
|
|
|
87
88
|
};
|
|
88
89
|
required: string[];
|
|
89
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
93
|
+
* @hidden
|
|
94
|
+
*/
|
|
90
95
|
readonly outputSchema: {
|
|
91
96
|
type: string;
|
|
92
97
|
$defs: {
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
import { CallGraphBuilder, } from '@angular-modernizer/api';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
6
|
+
/** Direct callers and callees spelled out per list in the summary. */
|
|
7
|
+
const SUMMARY_MAX_NODES = 50;
|
|
8
|
+
const CALL_NODE_FIELDS = {
|
|
9
|
+
name: { type: 'string' },
|
|
10
|
+
file: { type: 'string' },
|
|
11
|
+
line: { type: 'integer' },
|
|
12
|
+
kind: { type: 'string' },
|
|
13
|
+
className: { type: 'string' },
|
|
14
|
+
snippet: { type: 'string' },
|
|
15
|
+
inheritedFrom: { type: 'string' },
|
|
16
|
+
};
|
|
1
17
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Get Call Graph Tool
|
|
3
|
-
*
|
|
4
18
|
* MCP tool for building a caller/callee graph for a named method, function,
|
|
5
19
|
* constructor, get/set accessor or arrow-function property.
|
|
6
20
|
* Supports configurable traversal direction and depth.
|
|
@@ -24,25 +38,6 @@
|
|
|
24
38
|
* // projectRoot: '/project', direction: 'down', depth: 4 }
|
|
25
39
|
* ```
|
|
26
40
|
*/
|
|
27
|
-
import { CallGraphBuilder, } from '@angular-modernizer/api';
|
|
28
|
-
import { existsSync } from 'node:fs';
|
|
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
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* MCP tool that builds a call graph for a named method or function.
|
|
45
|
-
*/
|
|
46
41
|
export class GetCallGraphTool {
|
|
47
42
|
projects;
|
|
48
43
|
name = 'get-call-graph';
|
|
@@ -71,6 +66,10 @@ export class GetCallGraphTool {
|
|
|
71
66
|
'(className of the subclass, inheritedFrom of the declaring class; a subclass overriding it is left out). ' +
|
|
72
67
|
'Use method "ClassName.constructor" to see what runs transitively during construction. ' +
|
|
73
68
|
'Use after parse-stack-trace to trace error propagation through the call hierarchy.';
|
|
69
|
+
/**
|
|
70
|
+
* JSON Schema of the tool arguments.
|
|
71
|
+
* @hidden
|
|
72
|
+
*/
|
|
74
73
|
inputSchema = {
|
|
75
74
|
type: 'object',
|
|
76
75
|
additionalProperties: false,
|
|
@@ -119,6 +118,10 @@ export class GetCallGraphTool {
|
|
|
119
118
|
},
|
|
120
119
|
required: ['method', 'file', 'projectRoot'],
|
|
121
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
123
|
+
* @hidden
|
|
124
|
+
*/
|
|
122
125
|
outputSchema = {
|
|
123
126
|
type: 'object',
|
|
124
127
|
$defs: {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for querying progress of streaming operations.
|
|
5
|
-
*/
|
|
6
1
|
import type { MCPTool, ToolAnnotations } from '../types.js';
|
|
7
2
|
import { getOperationProgress } from './get-operation-progress.js';
|
|
8
3
|
type OperationProgress = Awaited<ReturnType<typeof getOperationProgress>>;
|
|
9
4
|
/**
|
|
10
|
-
* MCP tool for
|
|
5
|
+
* MCP tool for querying the progress of streaming operations (deprecated, kept
|
|
6
|
+
* in 1.x): polls an operation started with `streaming: true` by transform-code
|
|
7
|
+
* or scan-architecture.
|
|
11
8
|
*/
|
|
12
9
|
export declare class GetOperationProgressTool implements MCPTool {
|
|
13
10
|
readonly name = "get-operation-progress";
|
|
14
11
|
readonly title = "Get Operation Progress";
|
|
15
12
|
readonly annotations: ToolAnnotations;
|
|
16
13
|
readonly description: string;
|
|
14
|
+
/**
|
|
15
|
+
* JSON Schema of the tool arguments.
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
17
18
|
readonly inputSchema: {
|
|
18
19
|
type: string;
|
|
19
20
|
additionalProperties: boolean;
|
|
@@ -29,6 +30,10 @@ export declare class GetOperationProgressTool implements MCPTool {
|
|
|
29
30
|
};
|
|
30
31
|
required: string[];
|
|
31
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
32
37
|
readonly outputSchema: {
|
|
33
38
|
type: string;
|
|
34
39
|
properties: {
|
|
@@ -134,6 +139,7 @@ export declare class GetOperationProgressTool implements MCPTool {
|
|
|
134
139
|
required: string[];
|
|
135
140
|
};
|
|
136
141
|
execute(args: Record<string, unknown>): Promise<OperationProgress & {
|
|
142
|
+
/** Short text with the status, the last event and the result summary. */
|
|
137
143
|
summary: string;
|
|
138
144
|
}>;
|
|
139
145
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Get Operation Progress Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for querying progress of streaming operations.
|
|
5
|
-
*/
|
|
6
1
|
import { getOperationProgress, validateInput, } from './get-operation-progress.js';
|
|
7
2
|
/**
|
|
8
3
|
* Text summary: status, time, events, the last event, and the stored result's
|
|
@@ -34,7 +29,9 @@ function describeProgress(progress) {
|
|
|
34
29
|
return lines.join('\n');
|
|
35
30
|
}
|
|
36
31
|
/**
|
|
37
|
-
* MCP tool for
|
|
32
|
+
* MCP tool for querying the progress of streaming operations (deprecated, kept
|
|
33
|
+
* in 1.x): polls an operation started with `streaming: true` by transform-code
|
|
34
|
+
* or scan-architecture.
|
|
38
35
|
*/
|
|
39
36
|
export class GetOperationProgressTool {
|
|
40
37
|
name = 'get-operation-progress';
|
|
@@ -51,6 +48,10 @@ export class GetOperationProgressTool {
|
|
|
51
48
|
'Get progress for a streaming operation (transformation or analysis). ' +
|
|
52
49
|
'Returns status, events, and operation metadata including diffs and syntax errors. ' +
|
|
53
50
|
'A completed operation carries the tool result in result; summary is a short text with the status, the last event and the result summary.';
|
|
51
|
+
/**
|
|
52
|
+
* JSON Schema of the tool arguments.
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
54
55
|
inputSchema = {
|
|
55
56
|
type: 'object',
|
|
56
57
|
additionalProperties: false,
|
|
@@ -66,6 +67,10 @@ export class GetOperationProgressTool {
|
|
|
66
67
|
},
|
|
67
68
|
required: ['operationId'],
|
|
68
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
69
74
|
outputSchema = {
|
|
70
75
|
type: 'object',
|
|
71
76
|
properties: {
|
|
@@ -17,35 +17,61 @@ export declare function validateInput(input: unknown): GetOperationProgressInput
|
|
|
17
17
|
* Returns status, events, and operation metadata
|
|
18
18
|
*/
|
|
19
19
|
export declare function getOperationProgress(input: GetOperationProgressInput): Promise<{
|
|
20
|
+
/** Operation id. */
|
|
20
21
|
operationId: string;
|
|
22
|
+
/** Lifecycle status of the operation. */
|
|
21
23
|
status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
24
|
+
/** Progress events, only those after `sinceTimestamp` when given. */
|
|
22
25
|
events: {
|
|
26
|
+
/** Phase of the operation. */
|
|
23
27
|
phase: string;
|
|
28
|
+
/** Progress message. */
|
|
24
29
|
message: string;
|
|
30
|
+
/** Progress in percent (0 to 100). */
|
|
25
31
|
percentage: number;
|
|
32
|
+
/** Time of the event in milliseconds since the epoch. */
|
|
26
33
|
timestamp: number;
|
|
34
|
+
/** Unified diff of a transformed file. */
|
|
27
35
|
unifiedDiff?: {
|
|
36
|
+
/** Path of the changed file. */
|
|
28
37
|
filePath: string;
|
|
38
|
+
/** Diff text in unified format. */
|
|
29
39
|
diff: string;
|
|
40
|
+
/** Number of added lines. */
|
|
30
41
|
linesAdded: number;
|
|
42
|
+
/** Number of removed lines. */
|
|
31
43
|
linesRemoved: number;
|
|
32
44
|
};
|
|
45
|
+
/** Syntax errors found in transformed code. */
|
|
33
46
|
syntaxErrors?: {
|
|
47
|
+
/** File with the error. */
|
|
34
48
|
filePath: string;
|
|
49
|
+
/** Line of the error. */
|
|
35
50
|
line: number;
|
|
51
|
+
/** Error message. */
|
|
36
52
|
message: string;
|
|
37
53
|
}[];
|
|
54
|
+
/** Memory usage of the process at the event. */
|
|
38
55
|
memoryUsage?: {
|
|
56
|
+
/** V8 heap in use, bytes. */
|
|
39
57
|
heapUsed: number;
|
|
58
|
+
/** V8 heap allocated, bytes. */
|
|
40
59
|
heapTotal: number;
|
|
60
|
+
/** Memory of C++ objects bound to JavaScript objects, bytes. */
|
|
41
61
|
external: number;
|
|
62
|
+
/** Heap in use as percent of the heap allocated. */
|
|
42
63
|
percentage: number;
|
|
43
64
|
};
|
|
44
65
|
}[];
|
|
66
|
+
/** Number of all events of the operation, regardless of `sinceTimestamp`. */
|
|
45
67
|
totalEvents: number;
|
|
68
|
+
/** Milliseconds since the operation started. */
|
|
46
69
|
elapsedTime: number;
|
|
70
|
+
/** Estimated milliseconds until completion; only for running operations with progress. */
|
|
47
71
|
eta?: number;
|
|
72
|
+
/** Error message of a failed operation. */
|
|
48
73
|
error?: string;
|
|
74
|
+
/** Stored result of a completed operation. */
|
|
49
75
|
result?: unknown;
|
|
50
76
|
}>;
|
|
51
77
|
//# sourceMappingURL=get-operation-progress.d.ts.map
|
|
@@ -47,10 +47,15 @@ export declare function countList(counts: Record<string, number>, max: number):
|
|
|
47
47
|
export declare function pageNote(pagination: Pagination | undefined, noun: string): string | undefined;
|
|
48
48
|
/** Counts of a scan over all violations, independent of the page. */
|
|
49
49
|
export interface ScanCounts {
|
|
50
|
+
/** Number of all violations. */
|
|
50
51
|
totalViolations: number;
|
|
52
|
+
/** Number of analyzed files. */
|
|
51
53
|
analyzedFiles: number;
|
|
54
|
+
/** Violations per severity. */
|
|
52
55
|
bySeverity: Record<string, number>;
|
|
56
|
+
/** Violations per category. */
|
|
53
57
|
byCategory: Record<string, number>;
|
|
58
|
+
/** Violations per rule id. */
|
|
54
59
|
byRule: Record<string, number>;
|
|
55
60
|
}
|
|
56
61
|
/** Fields of a scan violation the summary names. */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One kernel for all files of a transform-code batch. The batch used to build
|
|
3
|
+
* a kernel per file, and each kernel loads the whole tsconfig program: about
|
|
4
|
+
* 3 s per file on a 330-file package, about 8 s on a large app.
|
|
5
|
+
*
|
|
6
|
+
* The kernel loads on the first task. Tasks run one after another even when
|
|
7
|
+
* the batch runs files in parallel, because they share one ts-morph project.
|
|
8
|
+
* A failed load fails every task with the same error.
|
|
9
|
+
*/
|
|
10
|
+
export interface BatchKernel<K> {
|
|
11
|
+
run<T>(task: (kernel: K) => Promise<T>): Promise<T>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createBatchKernel<K>(load: () => Promise<K>): BatchKernel<K>;
|
|
14
|
+
//# sourceMappingURL=batch-kernel.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function createBatchKernel(load) {
|
|
2
|
+
let kernel;
|
|
3
|
+
let queue = Promise.resolve();
|
|
4
|
+
return {
|
|
5
|
+
run(task) {
|
|
6
|
+
const next = queue.then(async () => task(await (kernel ??= load())));
|
|
7
|
+
queue = next.catch(() => undefined);
|
|
8
|
+
return next;
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=batch-kernel.js.map
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* `truncated: true` when anything was cut. Counts always describe the full
|
|
13
13
|
* result, never the shortened list.
|
|
14
14
|
* Both are opt-in; without them the tools return everything, as before. The
|
|
15
|
-
*
|
|
15
|
+
* 4 MB response limit of the stdio transport (`server/limited-stdio-transport.ts`)
|
|
16
|
+
* stays the last line of defence.
|
|
16
17
|
*/
|
|
17
18
|
/** JSON schema entries for the two shared parameters. */
|
|
18
19
|
export declare const COMPACT_OUTPUT_SCHEMA: {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* `truncated: true` when anything was cut. Counts always describe the full
|
|
13
13
|
* result, never the shortened list.
|
|
14
14
|
* Both are opt-in; without them the tools return everything, as before. The
|
|
15
|
-
*
|
|
15
|
+
* 4 MB response limit of the stdio transport (`server/limited-stdio-transport.ts`)
|
|
16
|
+
* stays the last line of defence.
|
|
16
17
|
*/
|
|
17
18
|
import { relative, sep } from 'node:path';
|
|
18
19
|
/** JSON schema entries for the two shared parameters. */
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Health delta
|
|
3
|
-
*
|
|
4
|
-
* Snapshot format and comparison behind the compare-health tool: which
|
|
5
|
-
* violations are new, fixed or unchanged since the last scan.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Line numbers shift with every edit above a finding, so they are not part of
|
|
9
|
-
* the key. Within one rule and file, violations are matched first by their
|
|
10
|
-
* message with digits removed (counts inside messages change too), the rest
|
|
11
|
-
* by number: three findings before and two now means one fixed. Which of the
|
|
12
|
-
* unmatched ones is reported as fixed or new follows the line order.
|
|
13
|
-
*/
|
|
14
1
|
/** One violation as stored in a snapshot and reported in a delta. */
|
|
15
2
|
export interface HealthViolation {
|
|
3
|
+
/** Rule that reported the violation. */
|
|
16
4
|
ruleId: string;
|
|
17
5
|
/** Relative to the project root. */
|
|
18
6
|
filePath: string;
|
|
7
|
+
/** Rule message. */
|
|
19
8
|
message: string;
|
|
9
|
+
/** Severity of the violation. */
|
|
20
10
|
severity: string;
|
|
11
|
+
/** Rule category. */
|
|
21
12
|
category: string;
|
|
13
|
+
/** 1-based line, when the rule reports one. */
|
|
22
14
|
line?: number;
|
|
23
15
|
}
|
|
24
16
|
/** Scan arguments that change which violations a run can find. */
|
|
@@ -38,19 +30,30 @@ export interface HealthSnapshot {
|
|
|
38
30
|
}
|
|
39
31
|
/** Counts of one rule in the previous and the current run. */
|
|
40
32
|
export interface RuleDelta {
|
|
33
|
+
/** Rule id. */
|
|
41
34
|
ruleId: string;
|
|
35
|
+
/** Violations of the rule in the previous run. */
|
|
42
36
|
previous: number;
|
|
37
|
+
/** Violations of the rule in the current run. */
|
|
43
38
|
current: number;
|
|
39
|
+
/** Violations only in the current run. */
|
|
44
40
|
new: number;
|
|
41
|
+
/** Violations only in the previous run. */
|
|
45
42
|
fixed: number;
|
|
43
|
+
/** Violations in both runs. */
|
|
46
44
|
unchanged: number;
|
|
47
45
|
}
|
|
48
46
|
/** Counts of one file whose violations changed. */
|
|
49
47
|
export interface FileDelta {
|
|
48
|
+
/** Relative to the project root. */
|
|
50
49
|
filePath: string;
|
|
50
|
+
/** Violations in the file in the previous run. */
|
|
51
51
|
previous: number;
|
|
52
|
+
/** Violations in the file in the current run. */
|
|
52
53
|
current: number;
|
|
54
|
+
/** Violations only in the current run. */
|
|
53
55
|
new: number;
|
|
56
|
+
/** Violations only in the previous run. */
|
|
54
57
|
fixed: number;
|
|
55
58
|
}
|
|
56
59
|
/** Result of comparing two runs. */
|
|
@@ -81,6 +84,16 @@ export declare function serializeHealthSnapshot(snapshot: HealthSnapshot): strin
|
|
|
81
84
|
export declare function parseHealthSnapshot(text: string): HealthSnapshot | undefined;
|
|
82
85
|
/** Readable differences between two scopes; empty when they match. */
|
|
83
86
|
export declare function scopeDifferences(previous: HealthScope, current: HealthScope): string[];
|
|
84
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Compares the violations of the previous run with the current one: which
|
|
89
|
+
* violations are new, fixed or unchanged.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Line numbers shift with every edit above a finding, so they are not part of
|
|
93
|
+
* the key. Within one rule and file, violations are matched first by their
|
|
94
|
+
* message with digits removed (counts inside messages change too), the rest
|
|
95
|
+
* by number: three findings before and two now means one fixed. Which of the
|
|
96
|
+
* unmatched ones is reported as fixed or new follows the line order.
|
|
97
|
+
*/
|
|
85
98
|
export declare function compareHealth(previous: readonly HealthViolation[], current: readonly HealthViolation[]): HealthDelta;
|
|
86
99
|
//# sourceMappingURL=health-delta.d.ts.map
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Health delta
|
|
3
|
-
*
|
|
4
|
-
* Snapshot format and comparison behind the compare-health tool: which
|
|
5
|
-
* violations are new, fixed or unchanged since the last scan.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Line numbers shift with every edit above a finding, so they are not part of
|
|
9
|
-
* the key. Within one rule and file, violations are matched first by their
|
|
10
|
-
* message with digits removed (counts inside messages change too), the rest
|
|
11
|
-
* by number: three findings before and two now means one fixed. Which of the
|
|
12
|
-
* unmatched ones is reported as fixed or new follows the line order.
|
|
13
|
-
*/
|
|
14
1
|
export const HEALTH_SNAPSHOT_VERSION = 1;
|
|
15
2
|
/** Snapshot location relative to the project root, next to the scan cache. */
|
|
16
3
|
export const DEFAULT_HEALTH_SNAPSHOT_PATH = '.angular-modernizer-cache/health/last-run.json';
|
|
@@ -106,7 +93,17 @@ export function scopeDifferences(previous, current) {
|
|
|
106
93
|
.filter((key) => !sameList(previous[key], current[key]))
|
|
107
94
|
.map((key) => `${key}: ${describeList(previous[key])} -> ${describeList(current[key])}`);
|
|
108
95
|
}
|
|
109
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Compares the violations of the previous run with the current one: which
|
|
98
|
+
* violations are new, fixed or unchanged.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* Line numbers shift with every edit above a finding, so they are not part of
|
|
102
|
+
* the key. Within one rule and file, violations are matched first by their
|
|
103
|
+
* message with digits removed (counts inside messages change too), the rest
|
|
104
|
+
* by number: three findings before and two now means one fixed. Which of the
|
|
105
|
+
* unmatched ones is reported as fixed or new follows the line order.
|
|
106
|
+
*/
|
|
110
107
|
export function compareHealth(previous, current) {
|
|
111
108
|
const previousGroups = groupByRuleAndFile(previous);
|
|
112
109
|
const currentGroups = groupByRuleAndFile(current);
|
|
@@ -1,69 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Project Cache
|
|
3
|
-
*
|
|
4
|
-
* Keeps ts-morph `Project` instances alive across tool calls, keyed by the
|
|
5
|
-
* tsconfig path, so repeated investigation calls on the same workspace do not
|
|
6
|
-
* re-parse the whole program each time (seconds on a large Angular app).
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Same idea as `SharedProjectManager` in core (one long-lived Project instead
|
|
10
|
-
* of one per call), but keyed per tsconfig because the MCP server can serve
|
|
11
|
-
* several workspaces in one session. An entry is rebuilt when the tsconfig
|
|
12
|
-
* mtime changes. Source files are kept current file by file: the mtime of
|
|
13
|
-
* every program file is recorded at load and compared on each `get()` (about
|
|
14
|
-
* 6 ms for 3939 files); changed files are re-read, deleted ones
|
|
15
|
-
* removed. The type checker then rebuilds lazily on the next query. Files
|
|
16
|
-
* that were not in the program at load (new files) need a tsconfig touch or a
|
|
17
|
-
* server restart.
|
|
18
|
-
*
|
|
19
|
-
* Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
|
|
20
|
-
* heap, checked on every `get()` because a project keeps growing after the
|
|
21
|
-
* load as the type checker resolves more of it, and on a miss also before
|
|
22
|
-
* the load. Over either limit the least recently used project is evicted;
|
|
23
|
-
* the project being requested never is.
|
|
24
|
-
* The heap is the signal, not the RSS: dropping a Project frees its heap
|
|
25
|
-
* (the TypeScript program, checker and ts-morph wrappers hang off it and
|
|
26
|
-
* nothing else keeps them), but V8 does not reliably unmap the pages, so the
|
|
27
|
-
* RSS can stay at its peak after an eviction and an RSS limit would then
|
|
28
|
-
* evict everything on every call. Freed pages are reused by the next load.
|
|
29
|
-
* When node runs with `--expose-gc` the cache collects once the raw heap
|
|
30
|
-
* reading passes the limit and after each eviction, so garbage does not count
|
|
31
|
-
* against the cache; otherwise it subtracts the heap growth recorded when the
|
|
32
|
-
* evicted project was loaded, and garbage makes it evict earlier.
|
|
33
|
-
*/
|
|
34
1
|
import { Project } from 'ts-morph';
|
|
35
2
|
/** A cached project as reported by `server-status`. */
|
|
36
3
|
export interface CachedProjectInfo {
|
|
4
|
+
/** tsconfig the project was loaded from. */
|
|
37
5
|
tsConfigPath: string;
|
|
6
|
+
/** Number of source files in the project. */
|
|
38
7
|
sourceFiles: number;
|
|
8
|
+
/** Load time (ISO 8601). */
|
|
39
9
|
loadedAt: string;
|
|
10
|
+
/** Time of the last `get()` (ISO 8601). */
|
|
40
11
|
lastUsedAt: string;
|
|
41
12
|
/** Heap growth while the project was loaded, an estimate of its size. */
|
|
42
13
|
loadHeapMB: number;
|
|
43
14
|
/** Source files re-read or removed because they changed on disk. */
|
|
44
15
|
refreshedFiles: number;
|
|
16
|
+
/** Time of the last refresh of changed files (ISO 8601). */
|
|
45
17
|
lastRefreshAt?: string;
|
|
46
18
|
}
|
|
47
19
|
/** Why a project left the cache. */
|
|
48
20
|
export type EvictionReason = 'max-entries' | 'max-heap';
|
|
49
21
|
/** One eviction with the memory around it. */
|
|
50
22
|
export interface ProjectEviction {
|
|
23
|
+
/** tsconfig of the evicted project. */
|
|
51
24
|
tsConfigPath: string;
|
|
25
|
+
/** Limit that caused the eviction. */
|
|
52
26
|
reason: EvictionReason;
|
|
27
|
+
/** Time of the eviction (ISO 8601). */
|
|
53
28
|
at: string;
|
|
29
|
+
/** Number of source files of the evicted project. */
|
|
54
30
|
sourceFiles: number;
|
|
31
|
+
/** V8 heap in use, MB. */
|
|
55
32
|
heapMB: {
|
|
33
|
+
/** Before the eviction. */
|
|
56
34
|
before: number;
|
|
35
|
+
/** After the eviction. */
|
|
57
36
|
after: number;
|
|
58
37
|
};
|
|
38
|
+
/** Resident set size, MB. */
|
|
59
39
|
rssMB: {
|
|
40
|
+
/** Before the eviction. */
|
|
60
41
|
before: number;
|
|
42
|
+
/** After the eviction. */
|
|
61
43
|
after: number;
|
|
62
44
|
};
|
|
63
45
|
}
|
|
64
46
|
/** Evictions since the server started. */
|
|
65
47
|
export interface EvictionStats {
|
|
48
|
+
/** Number of evictions. */
|
|
66
49
|
count: number;
|
|
50
|
+
/** The most recent eviction. */
|
|
67
51
|
last?: ProjectEviction;
|
|
68
52
|
}
|
|
69
53
|
/** Heap and RSS reader, plus a full collection when node exposes one. */
|
|
@@ -98,7 +82,39 @@ export declare const DEFAULT_MAX_ENTRIES = 3;
|
|
|
98
82
|
export declare const DEFAULT_MAX_HEAP_MB = 2048;
|
|
99
83
|
/** Bytes to MB, one decimal. */
|
|
100
84
|
export declare function toMB(bytes: number): number;
|
|
101
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* LRU cache of ts-morph Projects keyed by tsconfig path. Keeps `Project`
|
|
87
|
+
* instances alive across tool calls, so repeated investigation calls on the
|
|
88
|
+
* same workspace do not re-parse the whole program each time (seconds on a
|
|
89
|
+
* large Angular app).
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Same idea as `SharedProjectManager` in core (one long-lived Project instead
|
|
93
|
+
* of one per call), but keyed per tsconfig because the MCP server can serve
|
|
94
|
+
* several workspaces in one session. An entry is rebuilt when the tsconfig
|
|
95
|
+
* mtime changes. Source files are kept current file by file: the mtime of
|
|
96
|
+
* every program file is recorded at load and compared on each `get()` (about
|
|
97
|
+
* 6 ms for 3939 files); changed files are re-read, deleted ones
|
|
98
|
+
* removed. The type checker then rebuilds lazily on the next query. Files
|
|
99
|
+
* that were not in the program at load (new files) need a tsconfig touch or a
|
|
100
|
+
* server restart.
|
|
101
|
+
*
|
|
102
|
+
* Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
|
|
103
|
+
* heap, checked on every `get()` because a project keeps growing after the
|
|
104
|
+
* load as the type checker resolves more of it, and on a miss also before
|
|
105
|
+
* the load. Over either limit the least recently used project is evicted;
|
|
106
|
+
* the project being requested never is.
|
|
107
|
+
*
|
|
108
|
+
* The heap is the signal, not the RSS: dropping a Project frees its heap
|
|
109
|
+
* (the TypeScript program, checker and ts-morph wrappers hang off it and
|
|
110
|
+
* nothing else keeps them), but V8 does not reliably unmap the pages, so the
|
|
111
|
+
* RSS can stay at its peak after an eviction and an RSS limit would then
|
|
112
|
+
* evict everything on every call. Freed pages are reused by the next load.
|
|
113
|
+
* When node runs with `--expose-gc` the cache collects once the raw heap
|
|
114
|
+
* reading passes the limit and after each eviction, so garbage does not count
|
|
115
|
+
* against the cache; otherwise it subtracts the heap growth recorded when the
|
|
116
|
+
* evicted project was loaded, and garbage makes it evict earlier.
|
|
117
|
+
*/
|
|
102
118
|
export declare class ProjectCache {
|
|
103
119
|
private readonly entries;
|
|
104
120
|
private readonly maxEntries;
|
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Project Cache
|
|
3
|
-
*
|
|
4
|
-
* Keeps ts-morph `Project` instances alive across tool calls, keyed by the
|
|
5
|
-
* tsconfig path, so repeated investigation calls on the same workspace do not
|
|
6
|
-
* re-parse the whole program each time (seconds on a large Angular app).
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Same idea as `SharedProjectManager` in core (one long-lived Project instead
|
|
10
|
-
* of one per call), but keyed per tsconfig because the MCP server can serve
|
|
11
|
-
* several workspaces in one session. An entry is rebuilt when the tsconfig
|
|
12
|
-
* mtime changes. Source files are kept current file by file: the mtime of
|
|
13
|
-
* every program file is recorded at load and compared on each `get()` (about
|
|
14
|
-
* 6 ms for 3939 files); changed files are re-read, deleted ones
|
|
15
|
-
* removed. The type checker then rebuilds lazily on the next query. Files
|
|
16
|
-
* that were not in the program at load (new files) need a tsconfig touch or a
|
|
17
|
-
* server restart.
|
|
18
|
-
*
|
|
19
|
-
* Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
|
|
20
|
-
* heap, checked on every `get()` because a project keeps growing after the
|
|
21
|
-
* load as the type checker resolves more of it, and on a miss also before
|
|
22
|
-
* the load. Over either limit the least recently used project is evicted;
|
|
23
|
-
* the project being requested never is.
|
|
24
|
-
* The heap is the signal, not the RSS: dropping a Project frees its heap
|
|
25
|
-
* (the TypeScript program, checker and ts-morph wrappers hang off it and
|
|
26
|
-
* nothing else keeps them), but V8 does not reliably unmap the pages, so the
|
|
27
|
-
* RSS can stay at its peak after an eviction and an RSS limit would then
|
|
28
|
-
* evict everything on every call. Freed pages are reused by the next load.
|
|
29
|
-
* When node runs with `--expose-gc` the cache collects once the raw heap
|
|
30
|
-
* reading passes the limit and after each eviction, so garbage does not count
|
|
31
|
-
* against the cache; otherwise it subtracts the heap growth recorded when the
|
|
32
|
-
* evicted project was loaded, and garbage makes it evict earlier.
|
|
33
|
-
*/
|
|
34
1
|
import { statSync } from 'node:fs';
|
|
35
2
|
import { Project } from 'ts-morph';
|
|
36
3
|
import { findUnresolvedLibraryImports, libraryImportWarning, } from './library-imports.js';
|
|
@@ -62,7 +29,39 @@ const processMemory = {
|
|
|
62
29
|
? { collect: globalThis.gc.bind(globalThis) }
|
|
63
30
|
: {}),
|
|
64
31
|
};
|
|
65
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* LRU cache of ts-morph Projects keyed by tsconfig path. Keeps `Project`
|
|
34
|
+
* instances alive across tool calls, so repeated investigation calls on the
|
|
35
|
+
* same workspace do not re-parse the whole program each time (seconds on a
|
|
36
|
+
* large Angular app).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Same idea as `SharedProjectManager` in core (one long-lived Project instead
|
|
40
|
+
* of one per call), but keyed per tsconfig because the MCP server can serve
|
|
41
|
+
* several workspaces in one session. An entry is rebuilt when the tsconfig
|
|
42
|
+
* mtime changes. Source files are kept current file by file: the mtime of
|
|
43
|
+
* every program file is recorded at load and compared on each `get()` (about
|
|
44
|
+
* 6 ms for 3939 files); changed files are re-read, deleted ones
|
|
45
|
+
* removed. The type checker then rebuilds lazily on the next query. Files
|
|
46
|
+
* that were not in the program at load (new files) need a tsconfig touch or a
|
|
47
|
+
* server restart.
|
|
48
|
+
*
|
|
49
|
+
* Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
|
|
50
|
+
* heap, checked on every `get()` because a project keeps growing after the
|
|
51
|
+
* load as the type checker resolves more of it, and on a miss also before
|
|
52
|
+
* the load. Over either limit the least recently used project is evicted;
|
|
53
|
+
* the project being requested never is.
|
|
54
|
+
*
|
|
55
|
+
* The heap is the signal, not the RSS: dropping a Project frees its heap
|
|
56
|
+
* (the TypeScript program, checker and ts-morph wrappers hang off it and
|
|
57
|
+
* nothing else keeps them), but V8 does not reliably unmap the pages, so the
|
|
58
|
+
* RSS can stay at its peak after an eviction and an RSS limit would then
|
|
59
|
+
* evict everything on every call. Freed pages are reused by the next load.
|
|
60
|
+
* When node runs with `--expose-gc` the cache collects once the raw heap
|
|
61
|
+
* reading passes the limit and after each eviction, so garbage does not count
|
|
62
|
+
* against the cache; otherwise it subtracts the heap growth recorded when the
|
|
63
|
+
* evicted project was loaded, and garbage makes it evict earlier.
|
|
64
|
+
*/
|
|
66
65
|
export class ProjectCache {
|
|
67
66
|
entries = new Map();
|
|
68
67
|
maxEntries;
|