@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.
Files changed (126) hide show
  1. package/README.md +103 -35
  2. package/dist/cli.js +64 -14
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +7 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp-watcher.d.ts.map +1 -1
  9. package/dist/mcp-watcher.js +3 -0
  10. package/dist/mcp-watcher.js.map +1 -1
  11. package/dist/server/json-rpc-handler.d.ts +41 -0
  12. package/dist/server/json-rpc-handler.d.ts.map +1 -1
  13. package/dist/server/json-rpc-handler.js +85 -6
  14. package/dist/server/json-rpc-handler.js.map +1 -1
  15. package/dist/server/mcp-server.d.ts +31 -0
  16. package/dist/server/mcp-server.d.ts.map +1 -1
  17. package/dist/server/mcp-server.js +76 -23
  18. package/dist/server/mcp-server.js.map +1 -1
  19. package/dist/server/stdio-guard.d.ts +20 -0
  20. package/dist/server/stdio-guard.d.ts.map +1 -0
  21. package/dist/server/stdio-guard.js +48 -0
  22. package/dist/server/stdio-guard.js.map +1 -0
  23. package/dist/tools/analyze-build-impact.d.ts +126 -13
  24. package/dist/tools/analyze-build-impact.d.ts.map +1 -1
  25. package/dist/tools/analyze-build-impact.js +172 -30
  26. package/dist/tools/analyze-build-impact.js.map +1 -1
  27. package/dist/tools/find-angular-symbol.d.ts +29 -6
  28. package/dist/tools/find-angular-symbol.d.ts.map +1 -1
  29. package/dist/tools/find-angular-symbol.js +51 -6
  30. package/dist/tools/find-angular-symbol.js.map +1 -1
  31. package/dist/tools/find-component-hosts.d.ts +114 -0
  32. package/dist/tools/find-component-hosts.d.ts.map +1 -0
  33. package/dist/tools/find-component-hosts.js +240 -0
  34. package/dist/tools/find-component-hosts.js.map +1 -0
  35. package/dist/tools/find-usages.d.ts +20 -3
  36. package/dist/tools/find-usages.d.ts.map +1 -1
  37. package/dist/tools/find-usages.js +71 -8
  38. package/dist/tools/find-usages.js.map +1 -1
  39. package/dist/tools/get-bootstrap-execution.d.ts +108 -0
  40. package/dist/tools/get-bootstrap-execution.d.ts.map +1 -0
  41. package/dist/tools/get-bootstrap-execution.js +243 -0
  42. package/dist/tools/get-bootstrap-execution.js.map +1 -0
  43. package/dist/tools/get-call-graph.d.ts +28 -3
  44. package/dist/tools/get-call-graph.d.ts.map +1 -1
  45. package/dist/tools/get-call-graph.js +55 -7
  46. package/dist/tools/get-call-graph.js.map +1 -1
  47. package/dist/tools/helpers/compact-output.d.ts +61 -0
  48. package/dist/tools/helpers/compact-output.d.ts.map +1 -0
  49. package/dist/tools/helpers/compact-output.js +83 -0
  50. package/dist/tools/helpers/compact-output.js.map +1 -0
  51. package/dist/tools/helpers/project-cache.d.ts +177 -0
  52. package/dist/tools/helpers/project-cache.d.ts.map +1 -0
  53. package/dist/tools/helpers/project-cache.js +313 -0
  54. package/dist/tools/helpers/project-cache.js.map +1 -0
  55. package/dist/tools/helpers/rule-runner.d.ts +67 -0
  56. package/dist/tools/helpers/rule-runner.d.ts.map +1 -0
  57. package/dist/tools/helpers/rule-runner.js +117 -0
  58. package/dist/tools/helpers/rule-runner.js.map +1 -0
  59. package/dist/tools/helpers/scan-plan.d.ts +45 -0
  60. package/dist/tools/helpers/scan-plan.d.ts.map +1 -0
  61. package/dist/tools/helpers/scan-plan.js +151 -0
  62. package/dist/tools/helpers/scan-plan.js.map +1 -0
  63. package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
  64. package/dist/tools/helpers/stack-frame-file-index.d.ts.map +1 -0
  65. package/dist/tools/helpers/stack-frame-file-index.js +71 -0
  66. package/dist/tools/helpers/stack-frame-file-index.js.map +1 -0
  67. package/dist/tools/inspect-form-group.d.ts +93 -0
  68. package/dist/tools/inspect-form-group.d.ts.map +1 -0
  69. package/dist/tools/inspect-form-group.js +161 -0
  70. package/dist/tools/inspect-form-group.js.map +1 -0
  71. package/dist/tools/inspect-i18n.d.ts +85 -0
  72. package/dist/tools/inspect-i18n.d.ts.map +1 -0
  73. package/dist/tools/inspect-i18n.js +203 -0
  74. package/dist/tools/inspect-i18n.js.map +1 -0
  75. package/dist/tools/inspect-template.d.ts +89 -0
  76. package/dist/tools/inspect-template.d.ts.map +1 -0
  77. package/dist/tools/inspect-template.js +166 -0
  78. package/dist/tools/inspect-template.js.map +1 -0
  79. package/dist/tools/list-imports.d.ts +17 -1
  80. package/dist/tools/list-imports.d.ts.map +1 -1
  81. package/dist/tools/list-imports.js +22 -5
  82. package/dist/tools/list-imports.js.map +1 -1
  83. package/dist/tools/orchestrate-migration.d.ts +1 -0
  84. package/dist/tools/orchestrate-migration.d.ts.map +1 -1
  85. package/dist/tools/orchestrate-migration.js +33 -1
  86. package/dist/tools/orchestrate-migration.js.map +1 -1
  87. package/dist/tools/parse-stack-trace.d.ts +3 -1
  88. package/dist/tools/parse-stack-trace.d.ts.map +1 -1
  89. package/dist/tools/parse-stack-trace.js +18 -4
  90. package/dist/tools/parse-stack-trace.js.map +1 -1
  91. package/dist/tools/plan-migration.d.ts +89 -1
  92. package/dist/tools/plan-migration.d.ts.map +1 -1
  93. package/dist/tools/plan-migration.js +203 -7
  94. package/dist/tools/plan-migration.js.map +1 -1
  95. package/dist/tools/resolve-type.d.ts +3 -0
  96. package/dist/tools/resolve-type.d.ts.map +1 -1
  97. package/dist/tools/resolve-type.js +6 -2
  98. package/dist/tools/resolve-type.js.map +1 -1
  99. package/dist/tools/scan-all.d.ts +6 -6
  100. package/dist/tools/scan-all.d.ts.map +1 -1
  101. package/dist/tools/scan-all.js +7 -7
  102. package/dist/tools/scan-all.js.map +1 -1
  103. package/dist/tools/scan-angular.d.ts +1 -1
  104. package/dist/tools/scan-angular.js +1 -1
  105. package/dist/tools/scan-architecture.d.ts +25 -4
  106. package/dist/tools/scan-architecture.d.ts.map +1 -1
  107. package/dist/tools/scan-architecture.js +115 -134
  108. package/dist/tools/scan-architecture.js.map +1 -1
  109. package/dist/tools/scan-solid.d.ts +1 -1
  110. package/dist/tools/scan-solid.js +1 -1
  111. package/dist/tools/search-codebase.d.ts +3 -0
  112. package/dist/tools/search-codebase.d.ts.map +1 -1
  113. package/dist/tools/search-codebase.js +6 -2
  114. package/dist/tools/search-codebase.js.map +1 -1
  115. package/dist/tools/server-status.d.ts +96 -0
  116. package/dist/tools/server-status.d.ts.map +1 -0
  117. package/dist/tools/server-status.js +195 -0
  118. package/dist/tools/server-status.js.map +1 -0
  119. package/dist/tools/trace-output-flow.d.ts +111 -0
  120. package/dist/tools/trace-output-flow.d.ts.map +1 -0
  121. package/dist/tools/trace-output-flow.js +308 -0
  122. package/dist/tools/trace-output-flow.js.map +1 -0
  123. package/dist/types.d.ts +7 -0
  124. package/dist/types.d.ts.map +1 -1
  125. package/dist/types.js.map +1 -1
  126. package/package.json +11 -11
@@ -16,25 +16,37 @@
16
16
  * // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
17
17
  * ```
18
18
  */
19
- import { Project } from 'ts-morph';
20
19
  import { UsageFinder, } from '@angular-modernizer/api';
21
20
  import { existsSync } from 'node:fs';
22
21
  import { findTsConfig } from './helpers/find-ts-config.js';
22
+ import { ProjectCache } from './helpers/project-cache.js';
23
+ import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
24
+ /** Directory depth (relative to projectRoot) used for `countsByDirectory`. */
25
+ const DIRECTORY_DEPTH = 3;
26
+ /** Directories listed in the summaryOnly text. */
27
+ const SUMMARY_TOP_DIRECTORIES = 10;
23
28
  /**
24
29
  * MCP tool that finds all references to a named symbol across a TypeScript project.
25
30
  */
26
31
  export class FindUsagesTool {
32
+ projects;
27
33
  name = 'find-usages';
34
+ constructor(projects = new ProjectCache()) {
35
+ this.projects = projects;
36
+ }
28
37
  description = 'Find all references to a symbol (class, method, function, variable, or constant) ' +
29
38
  'across a TypeScript project. Returns file paths, line numbers, source snippets, ' +
30
- 'and usage type: read/write/call (resolved references), template (Angular template ' +
39
+ 'and usage type: read/write/call/argument/decorator-argument (resolved references), ' +
40
+ 'declaration (the name of the declaring class, method, property or interface member), ' +
41
+ 'template (Angular template ' +
31
42
  'usage: component/directive selector, pipe name, member read/call/write, input/output ' +
32
43
  'binding; external templateUrl and inline templates; templateMatch is "verified" or ' +
33
44
  '"template-unverified" for same-name matches that could not be tied to the symbol), ' +
34
45
  'and unresolved (same-name identifiers whose symbol does not resolve, e.g. a class ' +
35
46
  'still used after its import was removed). The file option filters reported usages only. ' +
36
47
  'Use after parse-stack-trace to trace call paths and determine blast radius before ' +
37
- 'proposing a bug fix.';
48
+ 'proposing a bug fix. countsByType and countsByDirectory always cover all usages; ' +
49
+ 'use summaryOnly for a quick overview of widely used symbols, maxResults to cap the list.';
38
50
  inputSchema = {
39
51
  type: 'object',
40
52
  properties: {
@@ -53,8 +65,18 @@ export class FindUsagesTool {
53
65
  },
54
66
  usageType: {
55
67
  type: 'string',
56
- enum: ['read', 'write', 'call', 'template', 'unresolved'],
57
- description: 'Restrict results to this usage type. Optional.',
68
+ enum: [
69
+ 'declaration',
70
+ 'read',
71
+ 'write',
72
+ 'call',
73
+ 'argument',
74
+ 'decorator-argument',
75
+ 'template',
76
+ 'unresolved',
77
+ ],
78
+ description: 'Restrict results to this usage type. `call` is only the callee; ' +
79
+ '`inject(Foo)` is `argument`, `@ViewChild(Foo)` is `decorator-argument`. Optional.',
58
80
  },
59
81
  includeTemplates: {
60
82
  type: 'boolean',
@@ -64,6 +86,7 @@ export class FindUsagesTool {
64
86
  type: 'boolean',
65
87
  description: 'Include same-name identifiers that do not resolve to any symbol (e.g. missing import, TS2304). Defaults to true.',
66
88
  },
89
+ ...COMPACT_OUTPUT_SCHEMA,
67
90
  },
68
91
  required: ['symbol', 'projectRoot'],
69
92
  };
@@ -75,6 +98,7 @@ export class FindUsagesTool {
75
98
  if (!params.projectRoot) {
76
99
  throw new Error('projectRoot is required');
77
100
  }
101
+ const compact = parseCompactOptions(args);
78
102
  if (!existsSync(params.projectRoot)) {
79
103
  throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
80
104
  }
@@ -82,7 +106,9 @@ export class FindUsagesTool {
82
106
  if (!tsConfigPath) {
83
107
  throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
84
108
  }
85
- const project = new Project({ tsConfigFilePath: tsConfigPath });
109
+ // The shared ProjectCache: a fresh Project cost 4 to 6 s per call on
110
+ // ngUWI and sat next to the cached one while the search ran.
111
+ const project = this.projects.get(tsConfigPath);
86
112
  const finder = new UsageFinder(project);
87
113
  const usages = finder.findUsages(params.symbol, {
88
114
  file: params.file,
@@ -94,14 +120,51 @@ export class FindUsagesTool {
94
120
  for (const u of usages) {
95
121
  countsByType[u.usageType] = (countsByType[u.usageType] ?? 0) + 1;
96
122
  }
123
+ const countsByDirectory = countByDirectory(usages.map((u) => u.file), params.projectRoot, DIRECTORY_DEPTH);
124
+ const shown = limitList(usages, compact.maxResults);
125
+ if (compact.summaryOnly) {
126
+ return {
127
+ totalCount: usages.length,
128
+ truncated: false,
129
+ summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, params.file),
130
+ countsByType,
131
+ countsByDirectory,
132
+ tsConfigPath,
133
+ };
134
+ }
135
+ const note = truncationNote(shown.items.length, usages.length, 'usages');
136
+ const summary = this.buildSummary(params.symbol, shown.items, params.file);
97
137
  return {
98
- usages,
138
+ usages: shown.items,
99
139
  totalCount: usages.length,
100
- summary: this.buildSummary(params.symbol, usages, params.file),
140
+ truncated: shown.truncated,
141
+ summary: note ? `${note}\n${summary}` : summary,
101
142
  countsByType,
143
+ countsByDirectory,
102
144
  tsConfigPath,
103
145
  };
104
146
  }
147
+ buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file) {
148
+ if (usages.length === 0) {
149
+ return this.buildSummary(symbol, usages, file);
150
+ }
151
+ const fileCount = new Set(usages.map((u) => u.file)).size;
152
+ const types = Object.entries(countsByType)
153
+ .map(([type, count]) => `${type} ${count}`)
154
+ .join(', ');
155
+ const directories = Object.entries(countsByDirectory);
156
+ const lines = [
157
+ `Found ${usages.length} usage(s) of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
158
+ 'Top directories:',
159
+ ...directories
160
+ .slice(0, SUMMARY_TOP_DIRECTORIES)
161
+ .map(([dir, count]) => ` ${dir} (${count})`),
162
+ ];
163
+ if (directories.length > SUMMARY_TOP_DIRECTORIES) {
164
+ lines.push(` ... ${directories.length - SUMMARY_TOP_DIRECTORIES} more directories in countsByDirectory`);
165
+ }
166
+ return lines.join('\n');
167
+ }
105
168
  buildSummary(symbol, usages, file) {
106
169
  if (usages.length === 0) {
107
170
  const scope = file ? `in ${file}` : 'across the project';
@@ -1 +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;AAoD3D;;GAEG;AACH,MAAM,OAAO,cAAc;IAChB,IAAI,GAAG,aAAa,CAAC;IAErB,WAAW,GAClB,mFAAmF;QACnF,kFAAkF;QAClF,oFAAoF;QACpF,uFAAuF;QACvF,qFAAqF;QACrF,qFAAqF;QACrF,oFAAoF;QACpF,0FAA0F;QAC1F,oFAAoF;QACpF,sBAAsB,CAAC;IAEhB,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,0EAA0E;aAC7E;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAC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,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACtD,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,108 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Get Bootstrap Execution Tool
3
+ *
4
+ * MCP tool that lists what an Angular app runs at startup (initializers,
5
+ * bootstrap component/module), on the first HTTP request (interceptors) and
6
+ * on first injection (provider factories), including everything reached
7
+ * through calls and dependency injection, and where a watched expression
8
+ * such as `AppConfig.settings` is read or written on the way.
9
+ *
10
+ * @remarks
11
+ * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
12
+ * this tool resolves the project, validates arguments and applies the
13
+ * compact output contract.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Via MCP:
18
+ * // tool: get-bootstrap-execution
19
+ * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
20
+ * ```
21
+ */
22
+ import { type MCPTool } from '../types.js';
23
+ import { type BootstrapExecutionResult, type BootstrapRoot, type BootstrapTiming, type BootstrapWatchHit } from '@angular-modernizer/api';
24
+ import { ProjectCache } from './helpers/project-cache.js';
25
+ /** A root with its reached list optionally dropped or capped. */
26
+ type RootOutput = Omit<BootstrapRoot, 'reached'> & Partial<Pick<BootstrapRoot, 'reached'>> & {
27
+ reachedCount: number;
28
+ };
29
+ /**
30
+ * Output of the get-bootstrap-execution tool.
31
+ */
32
+ interface GetBootstrapExecutionOutput {
33
+ roots?: RootOutput[];
34
+ watchHits?: BootstrapWatchHit[];
35
+ counts: BootstrapExecutionResult['counts'];
36
+ /** `true` when `maxResults` cut a reached list or the watch hits. */
37
+ truncated: boolean;
38
+ summary: string;
39
+ tsConfigPath: string;
40
+ }
41
+ /**
42
+ * MCP tool that reports what runs at application startup.
43
+ */
44
+ export declare class GetBootstrapExecutionTool implements MCPTool {
45
+ private readonly projects;
46
+ readonly name = "get-bootstrap-execution";
47
+ constructor(projects?: ProjectCache);
48
+ readonly description: string;
49
+ readonly inputSchema: {
50
+ type: string;
51
+ properties: {
52
+ summaryOnly: {
53
+ readonly type: "boolean";
54
+ readonly description: "Return counts and the text summary only, without the result list. Default: false.";
55
+ readonly default: false;
56
+ };
57
+ maxResults: {
58
+ readonly type: "number";
59
+ readonly description: string;
60
+ };
61
+ projectRoot: {
62
+ type: string;
63
+ description: string;
64
+ };
65
+ watch: {
66
+ type: string;
67
+ items: {
68
+ type: string;
69
+ };
70
+ description: string;
71
+ };
72
+ timings: {
73
+ type: string;
74
+ items: {
75
+ type: string;
76
+ enum: BootstrapTiming[];
77
+ };
78
+ description: string;
79
+ };
80
+ file: {
81
+ type: string;
82
+ description: string;
83
+ };
84
+ method: {
85
+ type: string;
86
+ description: string;
87
+ };
88
+ depth: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ maxNodes: {
93
+ type: string;
94
+ description: string;
95
+ };
96
+ includeReached: {
97
+ type: string;
98
+ description: string;
99
+ default: boolean;
100
+ };
101
+ };
102
+ required: string[];
103
+ };
104
+ execute(args: Record<string, unknown>): Promise<GetBootstrapExecutionOutput>;
105
+ private buildSummary;
106
+ }
107
+ export {};
108
+ //# sourceMappingURL=get-bootstrap-execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bootstrap-execution.d.ts","sourceRoot":"","sources":["../../src/tools/get-bootstrap-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAkD1D,iEAAiE;AACjE,KAAK,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;GAEG;AACH,UAAU,2BAA2B;IACnC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAE3C,qEAAqE;IACrE,SAAS,EAAE,OAAO,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAuBD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,OAAO;IAG3C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,IAAI,6BAA6B;gBAEb,QAAQ,GAAE,YAAiC;IAExE,QAAQ,CAAC,WAAW,SAY8C;IAElE,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4ClB;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAmElF,OAAO,CAAC,YAAY;CAwDrB"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Get Bootstrap Execution Tool
3
+ *
4
+ * MCP tool that lists what an Angular app runs at startup (initializers,
5
+ * bootstrap component/module), on the first HTTP request (interceptors) and
6
+ * on first injection (provider factories), including everything reached
7
+ * through calls and dependency injection, and where a watched expression
8
+ * such as `AppConfig.settings` is read or written on the way.
9
+ *
10
+ * @remarks
11
+ * Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
12
+ * this tool resolves the project, validates arguments and applies the
13
+ * compact output contract.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Via MCP:
18
+ * // tool: get-bootstrap-execution
19
+ * // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
20
+ * ```
21
+ */
22
+ import { BootstrapExecutionAnalyzer, normalizeWatchExpression, } from '@angular-modernizer/api';
23
+ import { existsSync } from 'node:fs';
24
+ import { isAbsolute, relative, resolve } from 'node:path';
25
+ import { findTsConfig } from './helpers/find-ts-config.js';
26
+ import { ProjectCache } from './helpers/project-cache.js';
27
+ import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
28
+ const TIMINGS = [
29
+ 'initializer',
30
+ 'bootstrap',
31
+ 'first-http-request',
32
+ 'first-injection',
33
+ 'custom',
34
+ ];
35
+ /** Watched access sites listed in the text summary. */
36
+ const SUMMARY_MAX_SITES = 10;
37
+ /**
38
+ * Summary order: accesses that can run before the app is fully initialized
39
+ * first (initializers, and interceptors an initializer may construct).
40
+ */
41
+ const TIMING_RANK = {
42
+ initializer: 0,
43
+ 'first-http-request': 1,
44
+ custom: 2,
45
+ 'first-injection': 3,
46
+ bootstrap: 4,
47
+ };
48
+ function earliestFirst(a, b) {
49
+ return TIMING_RANK[a.timing] - TIMING_RANK[b.timing] || a.path.length - b.path.length;
50
+ }
51
+ function positiveInteger(value, name) {
52
+ if (value === undefined) {
53
+ return undefined;
54
+ }
55
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {
56
+ throw new Error(`${name} must be a positive integer`);
57
+ }
58
+ return value;
59
+ }
60
+ function stringList(value, name) {
61
+ if (value === undefined) {
62
+ return undefined;
63
+ }
64
+ const valid = Array.isArray(value) && value.every((v) => typeof v === 'string');
65
+ if (!valid) {
66
+ throw new Error(`${name} must be an array of strings`);
67
+ }
68
+ return value;
69
+ }
70
+ /**
71
+ * MCP tool that reports what runs at application startup.
72
+ */
73
+ export class GetBootstrapExecutionTool {
74
+ projects;
75
+ name = 'get-bootstrap-execution';
76
+ constructor(projects = new ProjectCache()) {
77
+ this.projects = projects;
78
+ }
79
+ description = 'List what an Angular app executes at startup and whether it touches a given expression. Roots: ' +
80
+ 'provideAppInitializer/provideEnvironmentInitializer/providePlatformInitializer and APP_INITIALIZER-style ' +
81
+ 'provider literals (timing "initializer", finish before "bootstrap"), bootstrapApplication/bootstrapModule ' +
82
+ '("bootstrap"), HTTP_INTERCEPTORS classes and withInterceptors functions ("first-http-request", can happen ' +
83
+ 'inside an initializer that uses HttpClient), other useFactory providers ("first-injection"). From each root ' +
84
+ 'it walks calls (incl. constructors, field initializers, getters) and DI: inject(X), constructor parameters, ' +
85
+ '@Inject(TOKEN) and factory deps, with tokens resolved to the providers registered in the project. watch ' +
86
+ '(e.g. ["AppConfig.settings"]) reports every reachable read/write with the call path from the root, which ' +
87
+ 'catches reads hidden behind constructors and getters that search-codebase cannot see. method + file start ' +
88
+ 'from one callable instead (e.g. "AuthInterceptor.constructor"). Roots are found by scanning source files, ' +
89
+ 'not by evaluating which providers are registered; spec files are skipped. Start with summaryOnly; ' +
90
+ 'maxResults caps the reached list per root and the watch hits.';
91
+ inputSchema = {
92
+ type: 'object',
93
+ properties: {
94
+ projectRoot: {
95
+ type: 'string',
96
+ description: 'Absolute path to the project root. Must contain a tsconfig.json.',
97
+ },
98
+ watch: {
99
+ type: 'array',
100
+ items: { type: 'string' },
101
+ description: 'Expressions whose reads and writes to report, matched by text (optional chaining ignored), e.g. ["AppConfig.settings"].',
102
+ },
103
+ timings: {
104
+ type: 'array',
105
+ items: { type: 'string', enum: [...TIMINGS] },
106
+ description: 'Only roots with these timings. Default: all.',
107
+ },
108
+ file: {
109
+ type: 'string',
110
+ description: 'Only roots registered in this file; with method, the file declaring it (absolute, or relative to projectRoot).',
111
+ },
112
+ method: {
113
+ type: 'string',
114
+ description: 'Start from this callable instead of the discovered roots: "Class.constructor", "Class.member" or a function name. Needs file.',
115
+ },
116
+ depth: {
117
+ type: 'number',
118
+ description: 'Maximum call/injection distance from a root. Default: 8.',
119
+ },
120
+ maxNodes: {
121
+ type: 'number',
122
+ description: 'Maximum callables walked per root; a capped root is marked truncated. Default: 300.',
123
+ },
124
+ includeReached: {
125
+ type: 'boolean',
126
+ description: 'Include the reached callables per root. Default: true.',
127
+ default: true,
128
+ },
129
+ ...COMPACT_OUTPUT_SCHEMA,
130
+ },
131
+ required: ['projectRoot'],
132
+ };
133
+ async execute(args) {
134
+ const params = args;
135
+ if (!params.projectRoot) {
136
+ throw new Error('projectRoot is required');
137
+ }
138
+ const compact = parseCompactOptions(args);
139
+ const watch = stringList(params.watch, 'watch');
140
+ const timings = stringList(params.timings, 'timings');
141
+ const unknownTiming = timings?.find((t) => !TIMINGS.includes(t));
142
+ if (unknownTiming !== undefined) {
143
+ throw new Error(`unknown timing: ${unknownTiming}`);
144
+ }
145
+ const depth = positiveInteger(params.depth, 'depth');
146
+ const maxNodes = positiveInteger(params.maxNodes, 'maxNodes');
147
+ if (params.method !== undefined && params.file === undefined) {
148
+ throw new Error('method needs file');
149
+ }
150
+ if (!existsSync(params.projectRoot)) {
151
+ throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
152
+ }
153
+ const tsConfigPath = findTsConfig(params.projectRoot);
154
+ if (!tsConfigPath) {
155
+ throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
156
+ }
157
+ const file = params.file === undefined || isAbsolute(params.file)
158
+ ? params.file
159
+ : resolve(params.projectRoot, params.file);
160
+ const result = new BootstrapExecutionAnalyzer(this.projects.get(tsConfigPath)).analyze({
161
+ ...(watch === undefined ? {} : { watch }),
162
+ ...(timings === undefined ? {} : { timings: timings }),
163
+ ...(file === undefined ? {} : { file }),
164
+ ...(params.method === undefined ? {} : { method: params.method }),
165
+ ...(depth === undefined ? {} : { depth }),
166
+ ...(maxNodes === undefined ? {} : { maxNodes }),
167
+ });
168
+ const summary = this.buildSummary(result, params.projectRoot, watch ?? [], params.method);
169
+ if (compact.summaryOnly) {
170
+ return { counts: result.counts, truncated: false, summary, tsConfigPath };
171
+ }
172
+ const includeReached = params.includeReached !== false;
173
+ let truncated = false;
174
+ const roots = result.roots.map((root) => {
175
+ const { reached, ...rest } = root;
176
+ if (!includeReached) {
177
+ return { ...rest, reachedCount: reached.length };
178
+ }
179
+ const shown = limitList(reached, compact.maxResults);
180
+ truncated ||= shown.truncated;
181
+ return { ...rest, reached: shown.items, reachedCount: reached.length };
182
+ });
183
+ const hits = limitList(result.watchHits, compact.maxResults);
184
+ truncated ||= hits.truncated;
185
+ return {
186
+ roots,
187
+ watchHits: hits.items,
188
+ counts: result.counts,
189
+ truncated,
190
+ summary,
191
+ tsConfigPath,
192
+ };
193
+ }
194
+ buildSummary(result, projectRoot, watch, method) {
195
+ if (result.roots.length === 0) {
196
+ return method !== undefined
197
+ ? `Callable '${method}' not found in the given file.`
198
+ : 'No bootstrap roots found (no initializers, bootstrapApplication/bootstrapModule, interceptors or factory providers in the tsconfig program).';
199
+ }
200
+ const rel = (f) => relative(projectRoot, f);
201
+ const timings = Object.entries(result.counts.rootsByTiming)
202
+ .map(([t, n]) => `${t} ${n}`)
203
+ .join(', ');
204
+ const lines = [
205
+ `${result.counts.roots} root(s) (${timings}), ${result.counts.reached} callables reached` +
206
+ (result.counts.truncatedRoots > 0 ? `, ${result.counts.truncatedRoots} root(s) truncated by maxNodes` : '') +
207
+ '.',
208
+ ];
209
+ for (const expression of watch) {
210
+ const hits = result.watchHits.filter((h) => h.watch === normalizeWatchExpression(expression));
211
+ if (hits.length === 0) {
212
+ lines.push(`${expression}: not accessed from any root.`);
213
+ continue;
214
+ }
215
+ const sites = new Map();
216
+ for (const h of [...hits].sort(earliestFirst)) {
217
+ const key = `${rel(h.file)}:${h.line}`;
218
+ sites.set(key, [...(sites.get(key) ?? []), h]);
219
+ }
220
+ const early = hits.filter((h) => h.timing === 'initializer' || h.timing === 'first-http-request');
221
+ lines.push(`${expression}: ${sites.size} access site(s) reachable, ${early.length} path(s) from initializer or interceptor roots.`);
222
+ const ordered = [...sites].sort(([, a], [, b]) => {
223
+ const [firstA] = a;
224
+ const [firstB] = b;
225
+ return firstA === undefined || firstB === undefined ? 0 : earliestFirst(firstA, firstB);
226
+ });
227
+ for (const [site, siteHits] of ordered.slice(0, SUMMARY_MAX_SITES)) {
228
+ const first = siteHits[0];
229
+ if (first === undefined) {
230
+ continue;
231
+ }
232
+ const roots = [...new Set(siteHits.map((h) => h.timing))].join('/');
233
+ // siteHits is sorted earliest first, so this is the path that runs soonest.
234
+ lines.push(` ${first.access} ${site} [${roots}] via ${first.path.join(' > ')}`);
235
+ }
236
+ if (sites.size > SUMMARY_MAX_SITES) {
237
+ lines.push(` ... ${sites.size - SUMMARY_MAX_SITES} more site(s) in watchHits`);
238
+ }
239
+ }
240
+ return lines.join('\n');
241
+ }
242
+ }
243
+ //# sourceMappingURL=get-bootstrap-execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bootstrap-execution.js","sourceRoot":"","sources":["../../src/tools/get-bootstrap-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GAKzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,MAAM,OAAO,GAA+B;IAC1C,aAAa;IACb,WAAW;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AAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACpE,4EAA4E;gBAC5E,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,KAAK,KAAK,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACnF,CAAC;YACD,IAAI,KAAK,CAAC,IAAI,GAAG,iBAAiB,EAAE,CAAC;gBACnC,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,GAAG,iBAAiB,4BAA4B,CAAC,CAAC;YAClF,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -10,6 +10,11 @@
10
10
  * propagates through the call hierarchy. Useful for determining blast radius
11
11
  * before proposing a bug fix.
12
12
  *
13
+ * The graph is capped at `maxNodes` (default 200); a capped result carries
14
+ * `truncated: true` and a hint in the summary. Callers are not expanded
15
+ * through lifecycle hooks or interface members of foreign classes unless
16
+ * `includeLifecycleHooks` is set. Projects are cached per tsconfig.
17
+ *
13
18
  * @example
14
19
  * ```typescript
15
20
  * // Via MCP:
@@ -21,11 +26,18 @@
21
26
  */
22
27
  import { type MCPTool } from '../types.js';
23
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
+ };
24
34
  /**
25
35
  * MCP tool that builds a call graph for a named method or function.
26
36
  */
27
37
  export declare class GetCallGraphTool implements MCPTool {
38
+ private readonly projects;
28
39
  readonly name = "get-call-graph";
40
+ constructor(projects?: ProjectCache);
29
41
  readonly description: string;
30
42
  readonly inputSchema: {
31
43
  type: string;
@@ -53,12 +65,25 @@ export declare class GetCallGraphTool implements MCPTool {
53
65
  description: string;
54
66
  default: number;
55
67
  };
68
+ maxNodes: {
69
+ type: string;
70
+ description: string;
71
+ default: number;
72
+ };
73
+ includeLifecycleHooks: {
74
+ type: string;
75
+ description: string;
76
+ default: boolean;
77
+ };
78
+ summaryOnly: {
79
+ type: string;
80
+ description: string;
81
+ default: boolean;
82
+ };
56
83
  };
57
84
  required: string[];
58
85
  };
59
- execute(args: Record<string, unknown>): Promise<CallGraphResult & {
60
- summary: string;
61
- }>;
86
+ execute(args: Record<string, unknown>): Promise<GetCallGraphOutput>;
62
87
  private buildSummary;
63
88
  private label;
64
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-call-graph.d.ts","sourceRoot":"","sources":["../../src/tools/get-call-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAkCjC;;GAEG;AACH,qBAAa,gBAAiB,YAAW,OAAO;IAC9C,QAAQ,CAAC,IAAI,oBAAoB;IAEjC,QAAQ,CAAC,WAAW,SAQmE;IAEvF,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+BlB;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;IA8BpB,OAAO,CAAC,KAAK;CAOd"}
1
+ {"version":3,"file":"get-call-graph.d.ts","sourceRoot":"","sources":["../../src/tools/get-call-graph.ts"],"names":[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