@angular-modernizer/adapter-mcp 0.2.0 → 0.3.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 +103 -35
- package/dist/cli.js +64 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-watcher.d.ts.map +1 -1
- package/dist/mcp-watcher.js +3 -0
- package/dist/mcp-watcher.js.map +1 -1
- package/dist/server/json-rpc-handler.d.ts +41 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -1
- package/dist/server/json-rpc-handler.js +85 -6
- package/dist/server/json-rpc-handler.js.map +1 -1
- package/dist/server/mcp-server.d.ts +31 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +76 -23
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/stdio-guard.d.ts +20 -0
- package/dist/server/stdio-guard.d.ts.map +1 -0
- package/dist/server/stdio-guard.js +48 -0
- package/dist/server/stdio-guard.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +126 -13
- package/dist/tools/analyze-build-impact.d.ts.map +1 -1
- package/dist/tools/analyze-build-impact.js +172 -30
- package/dist/tools/analyze-build-impact.js.map +1 -1
- package/dist/tools/find-angular-symbol.d.ts +29 -6
- package/dist/tools/find-angular-symbol.d.ts.map +1 -1
- package/dist/tools/find-angular-symbol.js +51 -6
- package/dist/tools/find-angular-symbol.js.map +1 -1
- package/dist/tools/find-component-hosts.d.ts +114 -0
- package/dist/tools/find-component-hosts.d.ts.map +1 -0
- package/dist/tools/find-component-hosts.js +240 -0
- package/dist/tools/find-component-hosts.js.map +1 -0
- package/dist/tools/find-usages.d.ts +20 -3
- package/dist/tools/find-usages.d.ts.map +1 -1
- package/dist/tools/find-usages.js +71 -8
- package/dist/tools/find-usages.js.map +1 -1
- package/dist/tools/get-bootstrap-execution.d.ts +108 -0
- package/dist/tools/get-bootstrap-execution.d.ts.map +1 -0
- package/dist/tools/get-bootstrap-execution.js +243 -0
- package/dist/tools/get-bootstrap-execution.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +28 -3
- package/dist/tools/get-call-graph.d.ts.map +1 -1
- package/dist/tools/get-call-graph.js +55 -7
- package/dist/tools/get-call-graph.js.map +1 -1
- package/dist/tools/helpers/compact-output.d.ts +61 -0
- package/dist/tools/helpers/compact-output.d.ts.map +1 -0
- package/dist/tools/helpers/compact-output.js +83 -0
- package/dist/tools/helpers/compact-output.js.map +1 -0
- package/dist/tools/helpers/project-cache.d.ts +177 -0
- package/dist/tools/helpers/project-cache.d.ts.map +1 -0
- package/dist/tools/helpers/project-cache.js +313 -0
- package/dist/tools/helpers/project-cache.js.map +1 -0
- package/dist/tools/helpers/rule-runner.d.ts +67 -0
- package/dist/tools/helpers/rule-runner.d.ts.map +1 -0
- package/dist/tools/helpers/rule-runner.js +117 -0
- package/dist/tools/helpers/rule-runner.js.map +1 -0
- package/dist/tools/helpers/scan-plan.d.ts +45 -0
- package/dist/tools/helpers/scan-plan.d.ts.map +1 -0
- package/dist/tools/helpers/scan-plan.js +151 -0
- package/dist/tools/helpers/scan-plan.js.map +1 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts.map +1 -0
- package/dist/tools/helpers/stack-frame-file-index.js +71 -0
- package/dist/tools/helpers/stack-frame-file-index.js.map +1 -0
- package/dist/tools/inspect-form-group.d.ts +93 -0
- package/dist/tools/inspect-form-group.d.ts.map +1 -0
- package/dist/tools/inspect-form-group.js +161 -0
- package/dist/tools/inspect-form-group.js.map +1 -0
- package/dist/tools/inspect-i18n.d.ts +85 -0
- package/dist/tools/inspect-i18n.d.ts.map +1 -0
- package/dist/tools/inspect-i18n.js +203 -0
- package/dist/tools/inspect-i18n.js.map +1 -0
- package/dist/tools/inspect-template.d.ts +89 -0
- package/dist/tools/inspect-template.d.ts.map +1 -0
- package/dist/tools/inspect-template.js +166 -0
- package/dist/tools/inspect-template.js.map +1 -0
- package/dist/tools/list-imports.d.ts +17 -1
- package/dist/tools/list-imports.d.ts.map +1 -1
- package/dist/tools/list-imports.js +22 -5
- package/dist/tools/list-imports.js.map +1 -1
- package/dist/tools/orchestrate-migration.d.ts +1 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -1
- package/dist/tools/orchestrate-migration.js +33 -1
- package/dist/tools/orchestrate-migration.js.map +1 -1
- package/dist/tools/parse-stack-trace.d.ts +3 -1
- package/dist/tools/parse-stack-trace.d.ts.map +1 -1
- package/dist/tools/parse-stack-trace.js +18 -4
- package/dist/tools/parse-stack-trace.js.map +1 -1
- package/dist/tools/plan-migration.d.ts +89 -1
- package/dist/tools/plan-migration.d.ts.map +1 -1
- package/dist/tools/plan-migration.js +203 -7
- package/dist/tools/plan-migration.js.map +1 -1
- package/dist/tools/resolve-type.d.ts +3 -0
- package/dist/tools/resolve-type.d.ts.map +1 -1
- package/dist/tools/resolve-type.js +6 -2
- package/dist/tools/resolve-type.js.map +1 -1
- package/dist/tools/scan-all.d.ts +6 -6
- package/dist/tools/scan-all.d.ts.map +1 -1
- package/dist/tools/scan-all.js +7 -7
- package/dist/tools/scan-all.js.map +1 -1
- package/dist/tools/scan-angular.d.ts +1 -1
- package/dist/tools/scan-angular.js +1 -1
- package/dist/tools/scan-architecture.d.ts +25 -4
- package/dist/tools/scan-architecture.d.ts.map +1 -1
- package/dist/tools/scan-architecture.js +115 -134
- package/dist/tools/scan-architecture.js.map +1 -1
- package/dist/tools/scan-solid.d.ts +1 -1
- package/dist/tools/scan-solid.js +1 -1
- package/dist/tools/search-codebase.d.ts +3 -0
- package/dist/tools/search-codebase.d.ts.map +1 -1
- package/dist/tools/search-codebase.js +6 -2
- package/dist/tools/search-codebase.js.map +1 -1
- package/dist/tools/server-status.d.ts +96 -0
- package/dist/tools/server-status.d.ts.map +1 -0
- package/dist/tools/server-status.js +195 -0
- package/dist/tools/server-status.js.map +1 -0
- package/dist/tools/trace-output-flow.d.ts +111 -0
- package/dist/tools/trace-output-flow.d.ts.map +1 -0
- package/dist/tools/trace-output-flow.js +308 -0
- package/dist/tools/trace-output-flow.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-codebase.js","sourceRoot":"","sources":["../../src/tools/search-codebase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"search-codebase.js","sourceRoot":"","sources":["../../src/tools/search-codebase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAqD1D;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAGA;IAFpB,IAAI,GAAG,iBAAiB,CAAC;IAElC,YAA6B,WAAyB,IAAI,YAAY,EAAE;QAA3C,aAAQ,GAAR,QAAQ,CAAmC;IAAG,CAAC;IAEnE,WAAW,GAClB,4DAA4D;QAC5D,8DAA8D;QAC9D,gFAAgF;QAChF,sEAAsE;QACtE,mFAAmF;QACnF,sFAAsF;QACtF,oFAAoF;QACpF,kFAAkF;QAClF,mFAAmF;QACnF,wEAAwE,CAAC;IAElE,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,mEAAmE;aACtE;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,I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AAI,CAAC,IAAI,CAAC;YACb,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CACrE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Server Status Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool that reports on the running server itself: memory, uptime, the
|
|
5
|
+
* ts-morph projects held in the shared cache, response sizes, and whether the
|
|
6
|
+
* build on disk changed after the server started.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* A session keeps the code it started with; after `pnpm run build` it serves
|
|
10
|
+
* stale tools until the client reconnects. `build.rebuiltSinceStart` makes
|
|
11
|
+
* that visible from inside the session. The check compares the newest `.js`
|
|
12
|
+
* mtime per package `dist/` at start and at call time; it walks the
|
|
13
|
+
* directories on every call (a few hundred files, milliseconds).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Via MCP:
|
|
18
|
+
* // tool: server-status
|
|
19
|
+
* // args: {}
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { type MCPTool } from '../types.js';
|
|
23
|
+
import { type ServerRuntimeStats } from '../server/mcp-server.js';
|
|
24
|
+
import { type CachedProjectInfo, type EvictionStats, type ProjectCache } from './helpers/project-cache.js';
|
|
25
|
+
/** A package `dist/` directory to watch for rebuilds. */
|
|
26
|
+
export interface DistDirectory {
|
|
27
|
+
name: string;
|
|
28
|
+
dir: string;
|
|
29
|
+
}
|
|
30
|
+
/** Build state of one package. */
|
|
31
|
+
export interface DistPackageState {
|
|
32
|
+
name: string;
|
|
33
|
+
dir: string;
|
|
34
|
+
/** Newest `.js` mtime when the server started. */
|
|
35
|
+
builtAtStart?: string;
|
|
36
|
+
/** Newest `.js` mtime now. */
|
|
37
|
+
builtNow?: string;
|
|
38
|
+
rebuilt: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Output of the server-status tool. */
|
|
41
|
+
export interface ServerStatusOutput {
|
|
42
|
+
process: {
|
|
43
|
+
pid: number;
|
|
44
|
+
ppid: number;
|
|
45
|
+
nodeVersion: string;
|
|
46
|
+
platform: string;
|
|
47
|
+
cwd: string;
|
|
48
|
+
uptimeSec: number;
|
|
49
|
+
memoryMB: {
|
|
50
|
+
rss: number;
|
|
51
|
+
heapUsed: number;
|
|
52
|
+
heapTotal: number;
|
|
53
|
+
external: number;
|
|
54
|
+
/** V8 heap limit; the process aborts when the heap reaches it. */
|
|
55
|
+
heapLimit: number;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
server: ServerRuntimeStats;
|
|
59
|
+
projects: {
|
|
60
|
+
cached: number;
|
|
61
|
+
capacity: number;
|
|
62
|
+
/** Heap limit checked after each project load; 0 means off. */
|
|
63
|
+
maxHeapMB: number;
|
|
64
|
+
entries: CachedProjectInfo[];
|
|
65
|
+
evictions: EvictionStats;
|
|
66
|
+
};
|
|
67
|
+
build: {
|
|
68
|
+
rebuiltSinceStart: boolean;
|
|
69
|
+
packages: DistPackageState[];
|
|
70
|
+
};
|
|
71
|
+
summary: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* MCP tool that reports server process, cache and build state.
|
|
75
|
+
*/
|
|
76
|
+
export declare class ServerStatusTool implements MCPTool {
|
|
77
|
+
private readonly projects;
|
|
78
|
+
private readonly runtime;
|
|
79
|
+
private readonly distDirectories;
|
|
80
|
+
readonly name = "server-status";
|
|
81
|
+
readonly description: string;
|
|
82
|
+
readonly inputSchema: {
|
|
83
|
+
type: string;
|
|
84
|
+
properties: {};
|
|
85
|
+
};
|
|
86
|
+
private readonly baseline;
|
|
87
|
+
/**
|
|
88
|
+
* @param projects - The project cache shared by the investigation tools.
|
|
89
|
+
* @param runtime - Server start time, tool count and response sizes.
|
|
90
|
+
* @param distDirectories - Package `dist/` directories to watch; missing ones are skipped.
|
|
91
|
+
*/
|
|
92
|
+
constructor(projects: ProjectCache, runtime: () => ServerRuntimeStats, distDirectories?: readonly DistDirectory[]);
|
|
93
|
+
execute(_args: Record<string, unknown>): Promise<ServerStatusOutput>;
|
|
94
|
+
private buildSummary;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=server-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-status.d.ts","sourceRoot":"","sources":["../../src/tools/server-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAEpC,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,kCAAkC;AAClC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE;YACR,GAAG,EAAE,MAAM,CAAC;YAC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memory, uptime, the
|
|
5
|
+
* ts-morph projects held in the shared cache, response sizes, and whether the
|
|
6
|
+
* build on disk changed after the server started.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* A session keeps the code it started with; after `pnpm run build` it serves
|
|
10
|
+
* stale tools until the client reconnects. `build.rebuiltSinceStart` makes
|
|
11
|
+
* that visible from inside the session. The check compares the newest `.js`
|
|
12
|
+
* mtime per package `dist/` at start and at call time; it walks the
|
|
13
|
+
* directories on every call (a few hundred files, milliseconds).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Via MCP:
|
|
18
|
+
* // tool: server-status
|
|
19
|
+
* // args: {}
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import { getHeapStatistics } from 'node:v8';
|
|
25
|
+
import { toMB, } from './helpers/project-cache.js';
|
|
26
|
+
const BYTES_PER_MB = 1024 * 1024;
|
|
27
|
+
function formatBytes(bytes) {
|
|
28
|
+
if (!Number.isFinite(bytes)) {
|
|
29
|
+
return 'too large to serialize';
|
|
30
|
+
}
|
|
31
|
+
return bytes < BYTES_PER_MB
|
|
32
|
+
? `${(bytes / 1024).toFixed(1)} KB`
|
|
33
|
+
: `${toMB(bytes)} MB`;
|
|
34
|
+
}
|
|
35
|
+
/** Newest `.js` mtime under `dir` in ms, or undefined when there is none. */
|
|
36
|
+
function newestJsMtime(dir) {
|
|
37
|
+
let newest;
|
|
38
|
+
const stack = [dir];
|
|
39
|
+
while (stack.length > 0) {
|
|
40
|
+
const current = stack.pop();
|
|
41
|
+
if (current === undefined) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
let entries;
|
|
45
|
+
try {
|
|
46
|
+
entries = readdirSync(current, { withFileTypes: true });
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const full = join(current, entry.name);
|
|
53
|
+
if (entry.isDirectory()) {
|
|
54
|
+
stack.push(full);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (entry.name.endsWith('.js')) {
|
|
58
|
+
const mtime = statSync(full).mtimeMs;
|
|
59
|
+
newest = newest === undefined ? mtime : Math.max(newest, mtime);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return newest;
|
|
64
|
+
}
|
|
65
|
+
function iso(ms) {
|
|
66
|
+
return ms === undefined ? undefined : new Date(ms).toISOString();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* MCP tool that reports server process, cache and build state.
|
|
70
|
+
*/
|
|
71
|
+
export class ServerStatusTool {
|
|
72
|
+
projects;
|
|
73
|
+
runtime;
|
|
74
|
+
distDirectories;
|
|
75
|
+
name = 'server-status';
|
|
76
|
+
description = 'Report on the running MCP server itself: pid, parent pid, uptime, memory (RSS, heap), the ' +
|
|
77
|
+
'ts-morph projects in the shared cache (tsconfig path, source file count, heap taken at load, ' +
|
|
78
|
+
'load and last-use time, source files re-read after a change on disk), the cache limits (projects, heap MB) and evictions (count, last one ' +
|
|
79
|
+
'with reason and heap/RSS before and after), response sizes (count, last, largest, oversized responses replaced by an error), and ' +
|
|
80
|
+
'whether a package dist/ was rebuilt after the server started. When build.rebuiltSinceStart ' +
|
|
81
|
+
'is true this session still runs the old code: reconnect the MCP server to load the new build. ' +
|
|
82
|
+
'Use it when results look stale, before measuring response sizes, or when memory grows.';
|
|
83
|
+
inputSchema = {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {},
|
|
86
|
+
};
|
|
87
|
+
baseline;
|
|
88
|
+
/**
|
|
89
|
+
* @param projects - The project cache shared by the investigation tools.
|
|
90
|
+
* @param runtime - Server start time, tool count and response sizes.
|
|
91
|
+
* @param distDirectories - Package `dist/` directories to watch; missing ones are skipped.
|
|
92
|
+
*/
|
|
93
|
+
constructor(projects, runtime, distDirectories = []) {
|
|
94
|
+
this.projects = projects;
|
|
95
|
+
this.runtime = runtime;
|
|
96
|
+
this.distDirectories = distDirectories;
|
|
97
|
+
this.baseline = new Map(distDirectories
|
|
98
|
+
.filter((d) => existsSync(d.dir))
|
|
99
|
+
.map((d) => [d.dir, newestJsMtime(d.dir)]));
|
|
100
|
+
}
|
|
101
|
+
async execute(_args) {
|
|
102
|
+
const memory = process.memoryUsage();
|
|
103
|
+
const packages = this.distDirectories
|
|
104
|
+
.filter((d) => this.baseline.has(d.dir))
|
|
105
|
+
.map((d) => {
|
|
106
|
+
const atStart = this.baseline.get(d.dir);
|
|
107
|
+
const now = newestJsMtime(d.dir);
|
|
108
|
+
const builtAtStart = iso(atStart);
|
|
109
|
+
const builtNow = iso(now);
|
|
110
|
+
return {
|
|
111
|
+
name: d.name,
|
|
112
|
+
dir: d.dir,
|
|
113
|
+
...(builtAtStart === undefined ? {} : { builtAtStart }),
|
|
114
|
+
...(builtNow === undefined ? {} : { builtNow }),
|
|
115
|
+
rebuilt: now !== undefined && (atStart === undefined || now > atStart),
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
const result = {
|
|
119
|
+
process: {
|
|
120
|
+
pid: process.pid,
|
|
121
|
+
ppid: process.ppid,
|
|
122
|
+
nodeVersion: process.version,
|
|
123
|
+
platform: process.platform,
|
|
124
|
+
cwd: process.cwd(),
|
|
125
|
+
uptimeSec: Math.round(process.uptime()),
|
|
126
|
+
memoryMB: {
|
|
127
|
+
rss: toMB(memory.rss),
|
|
128
|
+
heapUsed: toMB(memory.heapUsed),
|
|
129
|
+
heapTotal: toMB(memory.heapTotal),
|
|
130
|
+
external: toMB(memory.external),
|
|
131
|
+
heapLimit: toMB(getHeapStatistics().heap_size_limit),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
server: this.runtime(),
|
|
135
|
+
projects: {
|
|
136
|
+
cached: this.projects.size,
|
|
137
|
+
capacity: this.projects.capacity,
|
|
138
|
+
maxHeapMB: this.projects.limits.maxHeapMb,
|
|
139
|
+
entries: this.projects.describe(),
|
|
140
|
+
evictions: this.projects.evictions,
|
|
141
|
+
},
|
|
142
|
+
build: {
|
|
143
|
+
rebuiltSinceStart: packages.some((p) => p.rebuilt),
|
|
144
|
+
packages,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
return { ...result, summary: this.buildSummary(result) };
|
|
148
|
+
}
|
|
149
|
+
buildSummary(status) {
|
|
150
|
+
const { process: proc, server, projects, build } = status;
|
|
151
|
+
const lines = [
|
|
152
|
+
`pid ${proc.pid} (parent ${proc.ppid}), up ${proc.uptimeSec} s since ${server.startedAt}, ` +
|
|
153
|
+
`${server.toolCount} tools, Node ${proc.nodeVersion}.`,
|
|
154
|
+
`Memory: RSS ${proc.memoryMB.rss} MB, heap ${proc.memoryMB.heapUsed} of ${proc.memoryMB.heapTotal} MB ` +
|
|
155
|
+
`(V8 limit ${proc.memoryMB.heapLimit} MB).`,
|
|
156
|
+
`Projects cached: ${projects.cached} of ${projects.capacity}, heap limit ` +
|
|
157
|
+
(projects.maxHeapMB === 0 ? 'off' : `${projects.maxHeapMB} MB`) +
|
|
158
|
+
(projects.entries.length === 0
|
|
159
|
+
? '.'
|
|
160
|
+
: `: ${projects.entries.map((p) => `${p.tsConfigPath} (${p.sourceFiles} files, ~${p.loadHeapMB} MB` + (p.refreshedFiles > 0 ? `, ${p.refreshedFiles} refreshed` : '') + ')').join(', ')}.`),
|
|
161
|
+
];
|
|
162
|
+
const { evictions } = projects;
|
|
163
|
+
if (evictions.last !== undefined) {
|
|
164
|
+
const last = evictions.last;
|
|
165
|
+
lines.push(`Evictions: ${evictions.count}; last ${last.tsConfigPath} (${last.reason}) at ${last.at}, ` +
|
|
166
|
+
`heap ${last.heapMB.before} -> ${last.heapMB.after} MB, RSS ${last.rssMB.before} -> ${last.rssMB.after} MB.`);
|
|
167
|
+
}
|
|
168
|
+
const { responses } = server;
|
|
169
|
+
if (responses.count > 0) {
|
|
170
|
+
const last = responses.last;
|
|
171
|
+
const largest = responses.largest;
|
|
172
|
+
lines.push(`Responses: ${responses.count}, ${formatBytes(responses.totalBytes)} total` +
|
|
173
|
+
(last === undefined
|
|
174
|
+
? ''
|
|
175
|
+
: `; last ${formatBytes(last.bytes)}${last.tool ? ` (${last.tool})` : ''}`) +
|
|
176
|
+
(largest === undefined
|
|
177
|
+
? ''
|
|
178
|
+
: `; largest ${formatBytes(largest.bytes)}${largest.tool ? ` (${largest.tool})` : ''}`) +
|
|
179
|
+
(responses.oversized > 0
|
|
180
|
+
? `; ${responses.oversized} over the limit, replaced by an error`
|
|
181
|
+
: '') +
|
|
182
|
+
'.');
|
|
183
|
+
}
|
|
184
|
+
const rebuilt = build.packages.filter((p) => p.rebuilt).map((p) => p.name);
|
|
185
|
+
if (rebuilt.length > 0) {
|
|
186
|
+
lines.push(`Rebuilt since start: ${rebuilt.join(', ')}. This session still runs the old code; ` +
|
|
187
|
+
'reconnect the MCP server to load the new build.');
|
|
188
|
+
}
|
|
189
|
+
else if (build.packages.length > 0) {
|
|
190
|
+
lines.push(`Build unchanged since start (${build.packages.length} packages checked).`);
|
|
191
|
+
}
|
|
192
|
+
return lines.join('\n');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=server-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-status.js","sourceRoot":"","sources":["../../src/tools/server-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACL,IAAI,GAIL,MAAM,4BAA4B,CAAC;AA0DpC,MAAM,YAAY,GAAG,IAAI,GAAG,I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,CAAC,IAAI,CAAC,0CAA0C;gBAClF,iDAAiD,CACpD,CAAC;QACJ,CAAC;aAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CACR,gCAAgC,KAAK,CAAC,QAAQ,CAAC,MAAM,qBAAqB,CAC3E,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Trace Output Flow Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool that follows the payload of a component's outputs across the
|
|
5
|
+
* template boundary: emit sites, the host bindings and handlers that receive
|
|
6
|
+
* the value, and what the handler methods do with `$event`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Logic lives in `OutputFlowTracer` (`@angular-modernizer/api`); this tool
|
|
10
|
+
* resolves the project, validates arguments and applies the compact output
|
|
11
|
+
* contract (`maxResults` caps emit sites, bound hosts and unbound hosts per
|
|
12
|
+
* output).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Via MCP:
|
|
17
|
+
* // tool: trace-output-flow
|
|
18
|
+
* // args: { className: 'ItemComponent', output: 'formError', projectRoot: '/project' }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { type MCPTool } from '../types.js';
|
|
22
|
+
import { type DynamicResultFlow, type OutputFlow, type OutputFlowResult } from '@angular-modernizer/api';
|
|
23
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
24
|
+
/** An output with its lists dropped (summaryOnly) or capped (maxResults). */
|
|
25
|
+
type OutputFlowOutput = Omit<OutputFlow, 'emits' | 'boundIn' | 'unboundIn'> & Partial<Pick<OutputFlow, 'emits' | 'boundIn' | 'unboundIn'>> & {
|
|
26
|
+
truncated: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** The dynamic section with its lists dropped (summaryOnly) or capped (maxResults). */
|
|
29
|
+
type DynamicFlowOutput = Pick<DynamicResultFlow, 'counts'> & Partial<Pick<DynamicResultFlow, 'dataInjections' | 'closeSites' | 'hosts'>> & {
|
|
30
|
+
truncated: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Output of the trace-output-flow tool.
|
|
34
|
+
*/
|
|
35
|
+
interface TraceOutputFlowOutput extends Omit<OutputFlowResult, 'outputs' | 'dynamic'> {
|
|
36
|
+
outputs: OutputFlowOutput[];
|
|
37
|
+
/** Components created in code: data injected, close sites, creation sites with result handlers. */
|
|
38
|
+
dynamic?: DynamicFlowOutput;
|
|
39
|
+
/** `true` when the effect budget or `maxResults` cut a list. */
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
summary: string;
|
|
42
|
+
tsConfigPath: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* MCP tool that traces @Output payloads from emit to host handler.
|
|
46
|
+
*/
|
|
47
|
+
export declare class TraceOutputFlowTool implements MCPTool {
|
|
48
|
+
private readonly projects;
|
|
49
|
+
readonly name = "trace-output-flow";
|
|
50
|
+
constructor(projects?: ProjectCache);
|
|
51
|
+
readonly description: string;
|
|
52
|
+
readonly inputSchema: {
|
|
53
|
+
type: string;
|
|
54
|
+
properties: {
|
|
55
|
+
summaryOnly: {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
readonly description: "Return counts and the text summary only, without the result list. Default: false.";
|
|
58
|
+
readonly default: false;
|
|
59
|
+
};
|
|
60
|
+
maxResults: {
|
|
61
|
+
readonly type: "number";
|
|
62
|
+
readonly description: string;
|
|
63
|
+
};
|
|
64
|
+
className: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
selector: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
file: {
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
output: {
|
|
77
|
+
type: string;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
projectRoot: {
|
|
81
|
+
type: string;
|
|
82
|
+
description: string;
|
|
83
|
+
};
|
|
84
|
+
depth: {
|
|
85
|
+
type: string;
|
|
86
|
+
description: string;
|
|
87
|
+
default: number;
|
|
88
|
+
};
|
|
89
|
+
includeTestHosts: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
includeDynamic: {
|
|
95
|
+
type: string;
|
|
96
|
+
description: string;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
required: string[];
|
|
101
|
+
};
|
|
102
|
+
execute(args: Record<string, unknown>): Promise<TraceOutputFlowOutput>;
|
|
103
|
+
private shapeDynamic;
|
|
104
|
+
private buildSummary;
|
|
105
|
+
private outputLines;
|
|
106
|
+
private dynamicLines;
|
|
107
|
+
private handlerText;
|
|
108
|
+
private effectList;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=trace-output-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-output-flow.d.ts","sourceRoot":"","sources":["../../src/tools/trace-output-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAyC1D,6EAA6E;AAC7E,KAAK,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC,GACzE,OAA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