@angular-modernizer/adapter-mcp 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/README.md +103 -218
  2. package/dist/cli.js +13 -13
  3. package/dist/index.d.ts +4 -3
  4. package/dist/index.js +3 -2
  5. package/dist/mcp-watcher.d.ts +6 -1
  6. package/dist/mcp-watcher.js +11 -10
  7. package/dist/server/limited-stdio-transport.d.ts +68 -0
  8. package/dist/server/limited-stdio-transport.js +115 -0
  9. package/dist/server/mcp-server.d.ts +12 -14
  10. package/dist/server/mcp-server.js +41 -75
  11. package/dist/server/package-version.d.ts +16 -0
  12. package/dist/server/package-version.js +37 -0
  13. package/dist/server/sdk-server.d.ts +70 -0
  14. package/dist/server/sdk-server.js +113 -0
  15. package/dist/server/tool-registry.d.ts +3 -2
  16. package/dist/server/tool-registry.js +5 -5
  17. package/dist/tools/analyze-build-impact.d.ts +220 -1
  18. package/dist/tools/analyze-build-impact.js +145 -3
  19. package/dist/tools/analyze-core-to-shared.d.ts +134 -4
  20. package/dist/tools/analyze-core-to-shared.js +113 -9
  21. package/dist/tools/analyze-parser-performance.d.ts +200 -7
  22. package/dist/tools/analyze-parser-performance.js +108 -47
  23. package/dist/tools/analyze-project.d.ts +267 -5
  24. package/dist/tools/analyze-project.js +196 -8
  25. package/dist/tools/check-incremental-compatibility.d.ts +61 -1
  26. package/dist/tools/check-incremental-compatibility.js +58 -2
  27. package/dist/tools/collect-feedback.d.ts +199 -10
  28. package/dist/tools/collect-feedback.js +171 -99
  29. package/dist/tools/compare-health.d.ts +356 -0
  30. package/dist/tools/compare-health.js +472 -0
  31. package/dist/tools/extract-libraries.d.ts +156 -4
  32. package/dist/tools/extract-libraries.js +115 -10
  33. package/dist/tools/find-angular-symbol.d.ts +69 -3
  34. package/dist/tools/find-angular-symbol.js +55 -8
  35. package/dist/tools/find-component-hosts.d.ts +572 -2
  36. package/dist/tools/find-component-hosts.js +207 -6
  37. package/dist/tools/find-usages.d.ts +79 -1
  38. package/dist/tools/find-usages.js +64 -7
  39. package/dist/tools/get-bootstrap-execution.d.ts +151 -1
  40. package/dist/tools/get-bootstrap-execution.js +84 -3
  41. package/dist/tools/get-call-graph.d.ts +111 -1
  42. package/dist/tools/get-call-graph.js +72 -10
  43. package/dist/tools/get-operation-progress-tool.d.ts +114 -2
  44. package/dist/tools/get-operation-progress-tool.js +114 -7
  45. package/dist/tools/get-operation-progress.d.ts +1 -1
  46. package/dist/tools/get-operation-progress.js +5 -5
  47. package/dist/tools/helpers/analysis-output.d.ts +177 -0
  48. package/dist/tools/helpers/analysis-output.js +165 -0
  49. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  50. package/dist/tools/helpers/build-schemas.js +23 -0
  51. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  52. package/dist/tools/helpers/citation-file-source.js +82 -0
  53. package/dist/tools/helpers/finding-window.d.ts +43 -0
  54. package/dist/tools/helpers/finding-window.js +64 -0
  55. package/dist/tools/helpers/health-delta.d.ts +86 -0
  56. package/dist/tools/helpers/health-delta.js +239 -0
  57. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  58. package/dist/tools/helpers/investigation-schemas.js +48 -0
  59. package/dist/tools/helpers/library-imports.d.ts +57 -0
  60. package/dist/tools/helpers/library-imports.js +151 -0
  61. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  62. package/dist/tools/helpers/load-source-files.js +34 -0
  63. package/dist/tools/helpers/output-contract.d.ts +32 -0
  64. package/dist/tools/helpers/output-contract.js +32 -0
  65. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  66. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  67. package/dist/tools/helpers/process-output.d.ts +19 -0
  68. package/dist/tools/helpers/process-output.js +31 -0
  69. package/dist/tools/helpers/project-cache.d.ts +11 -4
  70. package/dist/tools/helpers/project-cache.js +22 -4
  71. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  72. package/dist/tools/helpers/project-decorators.js +22 -0
  73. package/dist/tools/helpers/rule-matcher.js +5 -0
  74. package/dist/tools/helpers/rule-runner.d.ts +9 -4
  75. package/dist/tools/helpers/rule-runner.js +28 -14
  76. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  77. package/dist/tools/helpers/scan-cache.js +34 -0
  78. package/dist/tools/helpers/scan-plan.d.ts +5 -2
  79. package/dist/tools/helpers/scan-plan.js +18 -3
  80. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  81. package/dist/tools/helpers/scope-paths.js +32 -0
  82. package/dist/tools/helpers/tool-context.d.ts +60 -0
  83. package/dist/tools/helpers/tool-context.js +82 -0
  84. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  85. package/dist/tools/helpers/transform-safety.js +87 -0
  86. package/dist/tools/helpers/validation-output.d.ts +53 -0
  87. package/dist/tools/helpers/validation-output.js +48 -0
  88. package/dist/tools/inspect-form-group.d.ts +232 -1
  89. package/dist/tools/inspect-form-group.js +120 -2
  90. package/dist/tools/inspect-i18n.d.ts +382 -1
  91. package/dist/tools/inspect-i18n.js +199 -2
  92. package/dist/tools/inspect-template.d.ts +232 -1
  93. package/dist/tools/inspect-template.js +160 -2
  94. package/dist/tools/learn-patterns.d.ts +122 -1
  95. package/dist/tools/learn-patterns.js +97 -2
  96. package/dist/tools/list-imports.d.ts +111 -10
  97. package/dist/tools/list-imports.js +110 -7
  98. package/dist/tools/orchestrate-migration.d.ts +128 -5
  99. package/dist/tools/orchestrate-migration.js +135 -13
  100. package/dist/tools/parse-stack-trace.d.ts +56 -1
  101. package/dist/tools/parse-stack-trace.js +34 -0
  102. package/dist/tools/plan-migration.d.ts +330 -1
  103. package/dist/tools/plan-migration.js +154 -3
  104. package/dist/tools/resolve-type.d.ts +39 -1
  105. package/dist/tools/resolve-type.js +31 -2
  106. package/dist/tools/review-feedback.d.ts +206 -11
  107. package/dist/tools/review-feedback.js +132 -51
  108. package/dist/tools/rollback-changes.d.ts +79 -2
  109. package/dist/tools/rollback-changes.js +66 -14
  110. package/dist/tools/run-angular-cli.d.ts +45 -2
  111. package/dist/tools/run-angular-cli.js +67 -7
  112. package/dist/tools/run-build.d.ts +114 -2
  113. package/dist/tools/run-build.js +117 -8
  114. package/dist/tools/run-schematic.d.ts +70 -2
  115. package/dist/tools/run-schematic.js +104 -10
  116. package/dist/tools/scan-all.d.ts +19 -11
  117. package/dist/tools/scan-all.js +139 -131
  118. package/dist/tools/scan-angular.d.ts +19 -10
  119. package/dist/tools/scan-angular.js +51 -23
  120. package/dist/tools/scan-architecture.d.ts +17 -10
  121. package/dist/tools/scan-architecture.js +93 -31
  122. package/dist/tools/scan-solid.d.ts +19 -10
  123. package/dist/tools/scan-solid.js +51 -23
  124. package/dist/tools/search-codebase.d.ts +82 -1
  125. package/dist/tools/search-codebase.js +55 -2
  126. package/dist/tools/server-status.d.ts +279 -5
  127. package/dist/tools/server-status.js +179 -5
  128. package/dist/tools/suggest-improvements.d.ts +97 -5
  129. package/dist/tools/suggest-improvements.js +80 -44
  130. package/dist/tools/trace-output-flow.d.ts +682 -2
  131. package/dist/tools/trace-output-flow.js +375 -15
  132. package/dist/tools/transform-code-batch.d.ts +3 -0
  133. package/dist/tools/transform-code-batch.js +10 -5
  134. package/dist/tools/transform-code.d.ts +335 -12
  135. package/dist/tools/transform-code.js +649 -608
  136. package/dist/tools/validate-before-transform.d.ts +116 -2
  137. package/dist/tools/validate-before-transform.js +55 -2
  138. package/dist/tools/validate-project-compatibility.d.ts +64 -2
  139. package/dist/tools/validate-project-compatibility.js +67 -4
  140. package/dist/tools/validate-transformation.d.ts +220 -2
  141. package/dist/tools/validate-transformation.js +113 -15
  142. package/dist/tools/verify-citations.d.ts +181 -0
  143. package/dist/tools/verify-citations.js +218 -0
  144. package/dist/types.d.ts +38 -1
  145. package/dist/utils/format-tool-response.d.ts +22 -59
  146. package/dist/utils/format-tool-response.js +25 -134
  147. package/package.json +30 -13
  148. package/dist/cli.d.ts.map +0 -1
  149. package/dist/cli.js.map +0 -1
  150. package/dist/core/project-analyzer.d.ts.map +0 -1
  151. package/dist/core/project-analyzer.js.map +0 -1
  152. package/dist/index.d.ts.map +0 -1
  153. package/dist/index.js.map +0 -1
  154. package/dist/mcp-watcher.d.ts.map +0 -1
  155. package/dist/mcp-watcher.js.map +0 -1
  156. package/dist/server/json-rpc-handler.d.ts +0 -98
  157. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  158. package/dist/server/json-rpc-handler.js +0 -301
  159. package/dist/server/json-rpc-handler.js.map +0 -1
  160. package/dist/server/mcp-server.d.ts.map +0 -1
  161. package/dist/server/mcp-server.js.map +0 -1
  162. package/dist/server/stdio-guard.d.ts.map +0 -1
  163. package/dist/server/stdio-guard.js.map +0 -1
  164. package/dist/server/tool-registry.d.ts.map +0 -1
  165. package/dist/server/tool-registry.js.map +0 -1
  166. package/dist/streaming/progress-store.d.ts.map +0 -1
  167. package/dist/streaming/progress-store.js.map +0 -1
  168. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  169. package/dist/tools/analyze-build-impact.js.map +0 -1
  170. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  171. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  172. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  173. package/dist/tools/analyze-parser-performance.js.map +0 -1
  174. package/dist/tools/analyze-project.d.ts.map +0 -1
  175. package/dist/tools/analyze-project.js.map +0 -1
  176. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  177. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  178. package/dist/tools/collect-feedback.d.ts.map +0 -1
  179. package/dist/tools/collect-feedback.js.map +0 -1
  180. package/dist/tools/extract-libraries.d.ts.map +0 -1
  181. package/dist/tools/extract-libraries.js.map +0 -1
  182. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  183. package/dist/tools/find-angular-symbol.js.map +0 -1
  184. package/dist/tools/find-component-hosts.d.ts.map +0 -1
  185. package/dist/tools/find-component-hosts.js.map +0 -1
  186. package/dist/tools/find-usages.d.ts.map +0 -1
  187. package/dist/tools/find-usages.js.map +0 -1
  188. package/dist/tools/get-bootstrap-execution.d.ts.map +0 -1
  189. package/dist/tools/get-bootstrap-execution.js.map +0 -1
  190. package/dist/tools/get-call-graph.d.ts.map +0 -1
  191. package/dist/tools/get-call-graph.js.map +0 -1
  192. package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
  193. package/dist/tools/get-operation-progress-tool.js.map +0 -1
  194. package/dist/tools/get-operation-progress.d.ts.map +0 -1
  195. package/dist/tools/get-operation-progress.js.map +0 -1
  196. package/dist/tools/helpers/compact-output.d.ts.map +0 -1
  197. package/dist/tools/helpers/compact-output.js.map +0 -1
  198. package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
  199. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  200. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  201. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  202. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  203. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  204. package/dist/tools/helpers/project-cache.d.ts.map +0 -1
  205. package/dist/tools/helpers/project-cache.js.map +0 -1
  206. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  207. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  208. package/dist/tools/helpers/rule-runner.d.ts.map +0 -1
  209. package/dist/tools/helpers/rule-runner.js.map +0 -1
  210. package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
  211. package/dist/tools/helpers/scan-plan.js.map +0 -1
  212. package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
  213. package/dist/tools/helpers/stack-frame-file-index.js.map +0 -1
  214. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  215. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  216. package/dist/tools/inspect-form-group.d.ts.map +0 -1
  217. package/dist/tools/inspect-form-group.js.map +0 -1
  218. package/dist/tools/inspect-i18n.d.ts.map +0 -1
  219. package/dist/tools/inspect-i18n.js.map +0 -1
  220. package/dist/tools/inspect-template.d.ts.map +0 -1
  221. package/dist/tools/inspect-template.js.map +0 -1
  222. package/dist/tools/learn-patterns.d.ts.map +0 -1
  223. package/dist/tools/learn-patterns.js.map +0 -1
  224. package/dist/tools/list-imports.d.ts.map +0 -1
  225. package/dist/tools/list-imports.js.map +0 -1
  226. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  227. package/dist/tools/orchestrate-migration.js.map +0 -1
  228. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  229. package/dist/tools/parse-stack-trace.js.map +0 -1
  230. package/dist/tools/plan-migration.d.ts.map +0 -1
  231. package/dist/tools/plan-migration.js.map +0 -1
  232. package/dist/tools/resolve-type.d.ts.map +0 -1
  233. package/dist/tools/resolve-type.js.map +0 -1
  234. package/dist/tools/review-feedback.d.ts.map +0 -1
  235. package/dist/tools/review-feedback.js.map +0 -1
  236. package/dist/tools/rollback-changes.d.ts.map +0 -1
  237. package/dist/tools/rollback-changes.js.map +0 -1
  238. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  239. package/dist/tools/run-angular-cli.js.map +0 -1
  240. package/dist/tools/run-build.d.ts.map +0 -1
  241. package/dist/tools/run-build.js.map +0 -1
  242. package/dist/tools/run-schematic.d.ts.map +0 -1
  243. package/dist/tools/run-schematic.js.map +0 -1
  244. package/dist/tools/scan-all.d.ts.map +0 -1
  245. package/dist/tools/scan-all.js.map +0 -1
  246. package/dist/tools/scan-angular.d.ts.map +0 -1
  247. package/dist/tools/scan-angular.js.map +0 -1
  248. package/dist/tools/scan-architecture.d.ts.map +0 -1
  249. package/dist/tools/scan-architecture.js.map +0 -1
  250. package/dist/tools/scan-solid.d.ts.map +0 -1
  251. package/dist/tools/scan-solid.js.map +0 -1
  252. package/dist/tools/search-codebase.d.ts.map +0 -1
  253. package/dist/tools/search-codebase.js.map +0 -1
  254. package/dist/tools/server-status.d.ts.map +0 -1
  255. package/dist/tools/server-status.js.map +0 -1
  256. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  257. package/dist/tools/shared/scan-types.js.map +0 -1
  258. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  259. package/dist/tools/suggest-improvements.js.map +0 -1
  260. package/dist/tools/trace-output-flow.d.ts.map +0 -1
  261. package/dist/tools/trace-output-flow.js.map +0 -1
  262. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  263. package/dist/tools/transform-code-batch.js.map +0 -1
  264. package/dist/tools/transform-code.d.ts.map +0 -1
  265. package/dist/tools/transform-code.js.map +0 -1
  266. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  267. package/dist/tools/validate-before-transform.js.map +0 -1
  268. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  269. package/dist/tools/validate-project-compatibility.js.map +0 -1
  270. package/dist/tools/validate-transformation.d.ts.map +0 -1
  271. package/dist/tools/validate-transformation.js.map +0 -1
  272. package/dist/types.d.ts.map +0 -1
  273. package/dist/types.js.map +0 -1
  274. package/dist/utils/format-tool-response.d.ts.map +0 -1
  275. package/dist/utils/format-tool-response.js.map +0 -1
@@ -4,7 +4,7 @@
4
4
  * MCP tool for analyzing core-to-shared dependency violations with impact assessment.
5
5
  * Detects when core layer imports from shared layer and provides detailed refactoring guidance.
6
6
  */
7
- import type { MCPTool } from '../types.js';
7
+ import type { MCPTool, ToolAnnotations } from '../types.js';
8
8
  /**
9
9
  * Result from the analyze-core-to-shared tool.
10
10
  */
@@ -33,15 +33,19 @@ interface AnalyzeCoreToSharedResult {
33
33
  metadata?: Record<string, unknown>;
34
34
  }[];
35
35
  /**
36
- * Summary statistics.
36
+ * Counts over all violations.
37
37
  */
38
- summary: {
38
+ counts: {
39
39
  totalViolations: number;
40
40
  analyzedFiles: number;
41
41
  bySeverity: Record<string, number>;
42
42
  affectedCoreFiles: number;
43
43
  uniqueSharedModules: number;
44
44
  };
45
+ /**
46
+ * Human-readable summary for LLM consumption.
47
+ */
48
+ summary: string;
45
49
  /**
46
50
  * Analysis metadata.
47
51
  */
@@ -59,9 +63,12 @@ interface AnalyzeCoreToSharedResult {
59
63
  */
60
64
  export declare class AnalyzeCoreToSharedTool implements MCPTool {
61
65
  readonly name = "analyze-core-to-shared";
62
- readonly description = "Analyze core-to-shared dependency violations with impact assessment";
66
+ readonly title = "Analyze Core-to-Shared Candidates";
67
+ readonly annotations: ToolAnnotations;
68
+ readonly description: string;
63
69
  readonly inputSchema: {
64
70
  type: string;
71
+ additionalProperties: boolean;
65
72
  properties: {
66
73
  rootPath: {
67
74
  type: string;
@@ -109,6 +116,129 @@ export declare class AnalyzeCoreToSharedTool implements MCPTool {
109
116
  };
110
117
  required: string[];
111
118
  };
119
+ readonly outputSchema: {
120
+ type: string;
121
+ properties: {
122
+ violations: {
123
+ type: string;
124
+ items: {
125
+ type: string;
126
+ properties: {
127
+ id: {
128
+ type: string;
129
+ };
130
+ filePath: {
131
+ type: string;
132
+ };
133
+ line: {
134
+ type: string;
135
+ };
136
+ importedModule: {
137
+ type: string;
138
+ };
139
+ importedItem: {
140
+ type: string;
141
+ };
142
+ severity: {
143
+ type: string;
144
+ };
145
+ message: {
146
+ type: string;
147
+ };
148
+ impactAssessment: {
149
+ type: string;
150
+ properties: {
151
+ breakingChangeRisk: {
152
+ type: string;
153
+ };
154
+ riskFactors: {
155
+ readonly type: "array";
156
+ readonly items: {
157
+ readonly type: "string";
158
+ };
159
+ };
160
+ reverseDependencies: {
161
+ type: string;
162
+ items: {
163
+ type: string;
164
+ properties: {
165
+ file: {
166
+ type: string;
167
+ };
168
+ imports: {
169
+ readonly type: "array";
170
+ readonly items: {
171
+ readonly type: "string";
172
+ };
173
+ };
174
+ };
175
+ required: string[];
176
+ };
177
+ };
178
+ transitiveDependencies: {
179
+ readonly type: "array";
180
+ readonly items: {
181
+ readonly type: "string";
182
+ };
183
+ };
184
+ };
185
+ required: string[];
186
+ };
187
+ suggestedFix: {
188
+ type: string;
189
+ };
190
+ metadata: {
191
+ type: string;
192
+ };
193
+ };
194
+ required: string[];
195
+ };
196
+ };
197
+ counts: {
198
+ type: string;
199
+ properties: {
200
+ totalViolations: {
201
+ type: string;
202
+ };
203
+ analyzedFiles: {
204
+ type: string;
205
+ };
206
+ bySeverity: {
207
+ readonly type: "object";
208
+ readonly additionalProperties: {
209
+ readonly type: "integer";
210
+ };
211
+ };
212
+ affectedCoreFiles: {
213
+ type: string;
214
+ };
215
+ uniqueSharedModules: {
216
+ type: string;
217
+ };
218
+ };
219
+ required: string[];
220
+ };
221
+ metadata: {
222
+ type: string;
223
+ properties: {
224
+ duration: {
225
+ type: string;
226
+ };
227
+ projectRoot: {
228
+ type: string;
229
+ };
230
+ impactAssessmentEnabled: {
231
+ type: string;
232
+ };
233
+ };
234
+ required: string[];
235
+ };
236
+ summary: {
237
+ type: string;
238
+ };
239
+ };
240
+ required: string[];
241
+ };
112
242
  execute(args: Record<string, unknown>): Promise<AnalyzeCoreToSharedResult>;
113
243
  /**
114
244
  * Find files to analyze based on patterns.
@@ -9,6 +9,40 @@ import { Kernel } from '@angular-modernizer/core';
9
9
  import { glob } from 'glob';
10
10
  import { resolve, extname, relative, dirname } from 'node:path';
11
11
  import { readFileSync, statSync } from 'node:fs';
12
+ import { countList } from './helpers/analysis-output.js';
13
+ import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
14
+ /** Shared modules named in the summary. */
15
+ const SUMMARY_MODULES = 10;
16
+ /** Violations spelled out in the summary; the rest is in `violations`. */
17
+ const SUMMARY_VIOLATIONS = 5;
18
+ /**
19
+ * Text summary: totals, the most imported shared modules, the first
20
+ * violations and a note when `maxFiles` cut the file list.
21
+ */
22
+ function describeCoreToShared(violations, counts, maxFilesReached) {
23
+ const severity = countList(counts.bySeverity, SUMMARY_MODULES);
24
+ const lines = [
25
+ `${counts.totalViolations} core-to-shared import(s) in ${counts.analyzedFiles} analyzed core file(s)` +
26
+ (severity === undefined ? '' : ` (${severity})`) +
27
+ `: ${counts.affectedCoreFiles} core file(s) import from ${counts.uniqueSharedModules} shared module(s).`,
28
+ ];
29
+ const byModule = {};
30
+ for (const v of violations) {
31
+ byModule[v.importedModule] = (byModule[v.importedModule] ?? 0) + 1;
32
+ }
33
+ const modules = countList(byModule, SUMMARY_MODULES);
34
+ if (modules !== undefined) {
35
+ lines.push(`Shared modules: ${modules}.`);
36
+ }
37
+ for (const v of violations.slice(0, SUMMARY_VIOLATIONS)) {
38
+ const risk = v.impactAssessment ? `, risk ${v.impactAssessment.breakingChangeRisk}` : '';
39
+ lines.push(`- ${v.filePath}:${v.line} imports ${v.importedItem} from ${v.importedModule}${risk}`);
40
+ }
41
+ if (maxFilesReached !== undefined) {
42
+ lines.push(`maxFiles (${maxFilesReached}) reached; raise it to analyze the remaining core files.`);
43
+ }
44
+ return lines.join('\n');
45
+ }
12
46
  /**
13
47
  * Analyze Core-to-Shared Tool
14
48
  *
@@ -17,9 +51,18 @@ import { readFileSync, statSync } from 'node:fs';
17
51
  */
18
52
  export class AnalyzeCoreToSharedTool {
19
53
  name = 'analyze-core-to-shared';
20
- description = 'Analyze core-to-shared dependency violations with impact assessment';
54
+ title = 'Analyze Core-to-Shared Candidates';
55
+ annotations = {
56
+ readOnlyHint: true,
57
+ destructiveHint: false,
58
+ idempotentHint: true,
59
+ openWorldHint: false,
60
+ };
61
+ description = 'Analyze core-to-shared dependency violations with impact assessment. counts cover all violations, ' +
62
+ 'summary is a short text with the most imported shared modules and the first violations.';
21
63
  inputSchema = {
22
64
  type: 'object',
65
+ additionalProperties: false,
23
66
  properties: {
24
67
  rootPath: {
25
68
  type: 'string',
@@ -67,6 +110,68 @@ export class AnalyzeCoreToSharedTool {
67
110
  },
68
111
  required: ['rootPath'],
69
112
  };
113
+ outputSchema = {
114
+ type: 'object',
115
+ properties: {
116
+ violations: {
117
+ type: 'array',
118
+ items: {
119
+ type: 'object',
120
+ properties: {
121
+ id: { type: 'string' },
122
+ filePath: { type: 'string' },
123
+ line: { type: 'integer' },
124
+ importedModule: { type: 'string' },
125
+ importedItem: { type: 'string' },
126
+ severity: { type: 'string' },
127
+ message: { type: 'string' },
128
+ impactAssessment: {
129
+ type: 'object',
130
+ properties: {
131
+ breakingChangeRisk: { type: 'string' },
132
+ riskFactors: STRING_ARRAY,
133
+ reverseDependencies: {
134
+ type: 'array',
135
+ items: {
136
+ type: 'object',
137
+ properties: { file: { type: 'string' }, imports: STRING_ARRAY },
138
+ required: ['file', 'imports'],
139
+ },
140
+ },
141
+ transitiveDependencies: STRING_ARRAY,
142
+ },
143
+ required: ['breakingChangeRisk', 'riskFactors', 'reverseDependencies', 'transitiveDependencies'],
144
+ },
145
+ suggestedFix: { type: 'string' },
146
+ metadata: { type: 'object' },
147
+ },
148
+ required: ['filePath', 'line', 'importedModule', 'importedItem', 'severity', 'message'],
149
+ },
150
+ },
151
+ counts: {
152
+ type: 'object',
153
+ properties: {
154
+ totalViolations: { type: 'integer' },
155
+ analyzedFiles: { type: 'integer' },
156
+ bySeverity: COUNT_OBJECT,
157
+ affectedCoreFiles: { type: 'integer' },
158
+ uniqueSharedModules: { type: 'integer' },
159
+ },
160
+ required: ['totalViolations', 'analyzedFiles', 'bySeverity', 'affectedCoreFiles', 'uniqueSharedModules'],
161
+ },
162
+ metadata: {
163
+ type: 'object',
164
+ properties: {
165
+ duration: { type: 'number' },
166
+ projectRoot: { type: 'string' },
167
+ impactAssessmentEnabled: { type: 'boolean' },
168
+ },
169
+ required: ['duration', 'projectRoot', 'impactAssessmentEnabled'],
170
+ },
171
+ summary: { type: 'string' },
172
+ },
173
+ required: ['violations', 'counts', 'metadata', 'summary'],
174
+ };
70
175
  async execute(args) {
71
176
  const params = args;
72
177
  // Validate input
@@ -113,19 +218,17 @@ export class AnalyzeCoreToSharedTool {
113
218
  // Calculate summary
114
219
  const summary = this.calculateSummary(violations);
115
220
  const duration = Date.now() - startTime;
116
- const result = {
221
+ const counts = { ...summary, analyzedFiles: filesToAnalyze.length };
222
+ return {
117
223
  violations,
118
- summary: {
119
- ...summary,
120
- analyzedFiles: filesToAnalyze.length,
121
- },
224
+ counts,
122
225
  metadata: {
123
226
  duration,
124
227
  projectRoot: params.rootPath,
125
228
  impactAssessmentEnabled: includeImpactAssessment,
126
229
  },
230
+ summary: describeCoreToShared(violations, counts, filesToAnalyze.length >= maxFiles ? maxFiles : undefined),
127
231
  };
128
- return result;
129
232
  }
130
233
  catch (error) {
131
234
  throw new Error(`Core-to-shared analysis failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -150,8 +253,9 @@ export class AnalyzeCoreToSharedTool {
150
253
  });
151
254
  allFiles.push(...files);
152
255
  }
153
- // Remove duplicates and limit
154
- const uniqueFiles = [...new Set(allFiles)].slice(0, maxFiles);
256
+ // Sorted before the limit: glob returns files in no fixed order, and both
257
+ // the chosen files and the result pages depend on it
258
+ const uniqueFiles = [...new Set(allFiles)].sort().slice(0, maxFiles);
155
259
  // Filter to only TypeScript files and ensure they are actual files
156
260
  return uniqueFiles.filter((file) => {
157
261
  const isTsFile = ['.ts', '.tsx'].includes(extname(file));
@@ -9,23 +9,86 @@
9
9
  * - Calculates average performance statistics
10
10
  * - Identifies common improvement opportunities
11
11
  *
12
- * Dual-Location Support:
13
- * - DEFAULT: Read from BOTH project and platform locations
14
- * - Configurable: 'project', 'platform', or 'both'
12
+ * Location Support:
13
+ * - 'both' (default): the project, plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set
15
14
  * - Automatic session deduplication by sessionId
16
15
  *
17
16
  * Parser Configuration & Feedback
18
17
  */
19
- import { type MCPTool } from '../types.js';
18
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
19
+ import { type ParserImprovementSuggestion } from '@angular-modernizer/core';
20
+ /**
21
+ * Output from analyze-parser-performance tool
22
+ */
23
+ interface AnalyzeParserPerformanceOutput {
24
+ /** Number of sessions analyzed */
25
+ sessionsAnalyzed: number;
26
+ /** Total transformations across all sessions */
27
+ totalTransformations: number;
28
+ /** Locations where sessions were read from */
29
+ sourcesRead: string[];
30
+ /** Aggregated metrics across all sessions */
31
+ aggregatedMetrics: AggregatedParserMetrics;
32
+ /** Improvement suggestions sorted by priority */
33
+ suggestions: ParserImprovementSuggestion[];
34
+ /** Per-session detailed metrics */
35
+ sessionMetrics: SessionMetricsDetail[];
36
+ /** Human-readable summary for LLM consumption */
37
+ summary: string;
38
+ }
39
+ /**
40
+ * Aggregated parser metrics across multiple sessions
41
+ */
42
+ interface AggregatedParserMetrics {
43
+ /** Overall strategy distribution */
44
+ strategyDistribution: Record<string, number>;
45
+ /** Average parse time across all sessions */
46
+ avgParseTime: number;
47
+ /** Min parse time observed */
48
+ minParseTime: number;
49
+ /** Max parse time observed */
50
+ maxParseTime: number;
51
+ /** Total false positives filtered across all sessions */
52
+ totalFalsePositivesFiltered: number;
53
+ /** Average false positives per transformation */
54
+ avgFalsePositivesPerTransformation: number;
55
+ /** Total path aliases resolved across all sessions */
56
+ totalPathAliasesResolved: number;
57
+ /** Average path aliases per transformation */
58
+ avgPathAliasesPerTransformation: number;
59
+ /** All unique custom decorators found */
60
+ customDecoratorsFound: string[];
61
+ /** Overall success rate by parser strategy */
62
+ successRateByStrategy: Record<string, number>;
63
+ /** Average parse time by parser strategy */
64
+ parseTimeByStrategy: Record<string, number>;
65
+ }
66
+ /**
67
+ * Per-session detailed metrics
68
+ */
69
+ interface SessionMetricsDetail {
70
+ /** Session identifier */
71
+ sessionId: string;
72
+ /** Number of transformations in this session */
73
+ transformations: number;
74
+ /** Average parse time for this session */
75
+ avgParseTime: number;
76
+ /** Parser strategy used most in this session */
77
+ primaryStrategy: string;
78
+ /** Success rate for this session */
79
+ successRate: number;
80
+ }
20
81
  /**
21
82
  * Analyze parser performance from transformation feedback sessions
22
83
  */
23
84
  export declare class AnalyzeParserPerformanceTool implements MCPTool {
24
85
  name: string;
86
+ title: string;
87
+ annotations: ToolAnnotations;
25
88
  description: string;
26
- private platformRoot;
27
89
  inputSchema: {
28
90
  readonly type: "object";
91
+ readonly additionalProperties: false;
29
92
  readonly properties: {
30
93
  readonly projectRoot: {
31
94
  readonly type: "string";
@@ -41,11 +104,140 @@ export declare class AnalyzeParserPerformanceTool implements MCPTool {
41
104
  readonly source: {
42
105
  readonly type: "string";
43
106
  readonly enum: readonly ["project", "platform", "both"];
44
- readonly description: "Source location strategy (default: 'both')";
107
+ readonly description: string;
45
108
  };
46
109
  };
47
110
  readonly required: readonly [];
48
111
  };
112
+ outputSchema: {
113
+ type: string;
114
+ properties: {
115
+ sessionsAnalyzed: {
116
+ type: string;
117
+ };
118
+ totalTransformations: {
119
+ type: string;
120
+ };
121
+ sourcesRead: {
122
+ readonly type: "array";
123
+ readonly items: {
124
+ readonly type: "string";
125
+ };
126
+ };
127
+ aggregatedMetrics: {
128
+ type: string;
129
+ properties: {
130
+ strategyDistribution: {
131
+ readonly type: "object";
132
+ readonly additionalProperties: {
133
+ readonly type: "number";
134
+ };
135
+ };
136
+ avgParseTime: {
137
+ type: string;
138
+ };
139
+ minParseTime: {
140
+ type: string;
141
+ };
142
+ maxParseTime: {
143
+ type: string;
144
+ };
145
+ totalFalsePositivesFiltered: {
146
+ type: string;
147
+ };
148
+ avgFalsePositivesPerTransformation: {
149
+ type: string;
150
+ };
151
+ totalPathAliasesResolved: {
152
+ type: string;
153
+ };
154
+ avgPathAliasesPerTransformation: {
155
+ type: string;
156
+ };
157
+ customDecoratorsFound: {
158
+ readonly type: "array";
159
+ readonly items: {
160
+ readonly type: "string";
161
+ };
162
+ };
163
+ successRateByStrategy: {
164
+ readonly type: "object";
165
+ readonly additionalProperties: {
166
+ readonly type: "number";
167
+ };
168
+ };
169
+ parseTimeByStrategy: {
170
+ readonly type: "object";
171
+ readonly additionalProperties: {
172
+ readonly type: "number";
173
+ };
174
+ };
175
+ };
176
+ required: string[];
177
+ };
178
+ suggestions: {
179
+ type: string;
180
+ items: {
181
+ type: string;
182
+ properties: {
183
+ category: {
184
+ type: string;
185
+ };
186
+ priority: {
187
+ type: string;
188
+ };
189
+ confidence: {
190
+ type: string;
191
+ };
192
+ description: {
193
+ type: string;
194
+ };
195
+ recommendation: {
196
+ type: string;
197
+ };
198
+ evidence: {
199
+ readonly type: "array";
200
+ readonly items: {
201
+ readonly type: "string";
202
+ };
203
+ };
204
+ impact: {
205
+ type: string;
206
+ };
207
+ };
208
+ required: string[];
209
+ };
210
+ };
211
+ sessionMetrics: {
212
+ type: string;
213
+ items: {
214
+ type: string;
215
+ properties: {
216
+ sessionId: {
217
+ type: string;
218
+ };
219
+ transformations: {
220
+ type: string;
221
+ };
222
+ avgParseTime: {
223
+ type: string;
224
+ };
225
+ primaryStrategy: {
226
+ type: string;
227
+ };
228
+ successRate: {
229
+ type: string;
230
+ };
231
+ };
232
+ required: string[];
233
+ };
234
+ };
235
+ summary: {
236
+ type: string;
237
+ };
238
+ };
239
+ required: string[];
240
+ };
49
241
  /**
50
242
  * Execute analyze-parser-performance tool to analyze parser metrics from feedback sessions
51
243
  *
@@ -90,7 +282,7 @@ export declare class AnalyzeParserPerformanceTool implements MCPTool {
90
282
  * - Platform root can be overridden via ANGULAR_MODERNIZER_PLATFORM_ROOT environment variable
91
283
  * - Suggestions are sorted by priority (high → medium → low)
92
284
  */
93
- execute(args: Record<string, unknown>): Promise<unknown>;
285
+ execute(args: Record<string, unknown>): Promise<AnalyzeParserPerformanceOutput>;
94
286
  /**
95
287
  * Aggregate metrics from multiple sessions
96
288
  * @private
@@ -102,4 +294,5 @@ export declare class AnalyzeParserPerformanceTool implements MCPTool {
102
294
  */
103
295
  private getEmptyAggregatedMetrics;
104
296
  }
297
+ export {};
105
298
  //# sourceMappingURL=analyze-parser-performance.d.ts.map