@angular-modernizer/adapter-mcp 0.2.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 (255) hide show
  1. package/README.md +188 -235
  2. package/dist/cli.js +77 -27
  3. package/dist/index.d.ts +11 -3
  4. package/dist/index.js +10 -2
  5. package/dist/mcp-watcher.d.ts +6 -1
  6. package/dist/mcp-watcher.js +14 -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 +41 -12
  10. package/dist/server/mcp-server.js +113 -94
  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/stdio-guard.d.ts +20 -0
  16. package/dist/server/stdio-guard.js +48 -0
  17. package/dist/server/tool-registry.d.ts +3 -2
  18. package/dist/server/tool-registry.js +5 -5
  19. package/dist/tools/analyze-build-impact.d.ts +346 -14
  20. package/dist/tools/analyze-build-impact.js +315 -31
  21. package/dist/tools/analyze-core-to-shared.d.ts +134 -4
  22. package/dist/tools/analyze-core-to-shared.js +113 -9
  23. package/dist/tools/analyze-parser-performance.d.ts +200 -7
  24. package/dist/tools/analyze-parser-performance.js +108 -47
  25. package/dist/tools/analyze-project.d.ts +267 -5
  26. package/dist/tools/analyze-project.js +196 -8
  27. package/dist/tools/check-incremental-compatibility.d.ts +61 -1
  28. package/dist/tools/check-incremental-compatibility.js +58 -2
  29. package/dist/tools/collect-feedback.d.ts +199 -10
  30. package/dist/tools/collect-feedback.js +171 -99
  31. package/dist/tools/compare-health.d.ts +356 -0
  32. package/dist/tools/compare-health.js +472 -0
  33. package/dist/tools/extract-libraries.d.ts +156 -4
  34. package/dist/tools/extract-libraries.js +115 -10
  35. package/dist/tools/find-angular-symbol.d.ts +98 -9
  36. package/dist/tools/find-angular-symbol.js +104 -12
  37. package/dist/tools/find-component-hosts.d.ts +684 -0
  38. package/dist/tools/find-component-hosts.js +441 -0
  39. package/dist/tools/find-usages.d.ts +99 -4
  40. package/dist/tools/find-usages.js +131 -11
  41. package/dist/tools/get-bootstrap-execution.d.ts +258 -0
  42. package/dist/tools/get-bootstrap-execution.js +324 -0
  43. package/dist/tools/get-call-graph.d.ts +139 -4
  44. package/dist/tools/get-call-graph.js +123 -13
  45. package/dist/tools/get-operation-progress-tool.d.ts +114 -2
  46. package/dist/tools/get-operation-progress-tool.js +114 -7
  47. package/dist/tools/get-operation-progress.d.ts +1 -1
  48. package/dist/tools/get-operation-progress.js +5 -5
  49. package/dist/tools/helpers/analysis-output.d.ts +177 -0
  50. package/dist/tools/helpers/analysis-output.js +165 -0
  51. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  52. package/dist/tools/helpers/build-schemas.js +23 -0
  53. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  54. package/dist/tools/helpers/citation-file-source.js +82 -0
  55. package/dist/tools/helpers/compact-output.d.ts +61 -0
  56. package/dist/tools/helpers/compact-output.js +83 -0
  57. package/dist/tools/helpers/finding-window.d.ts +43 -0
  58. package/dist/tools/helpers/finding-window.js +64 -0
  59. package/dist/tools/helpers/health-delta.d.ts +86 -0
  60. package/dist/tools/helpers/health-delta.js +239 -0
  61. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  62. package/dist/tools/helpers/investigation-schemas.js +48 -0
  63. package/dist/tools/helpers/library-imports.d.ts +57 -0
  64. package/dist/tools/helpers/library-imports.js +151 -0
  65. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  66. package/dist/tools/helpers/load-source-files.js +34 -0
  67. package/dist/tools/helpers/output-contract.d.ts +32 -0
  68. package/dist/tools/helpers/output-contract.js +32 -0
  69. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  70. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  71. package/dist/tools/helpers/process-output.d.ts +19 -0
  72. package/dist/tools/helpers/process-output.js +31 -0
  73. package/dist/tools/helpers/project-cache.d.ts +184 -0
  74. package/dist/tools/helpers/project-cache.js +331 -0
  75. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  76. package/dist/tools/helpers/project-decorators.js +22 -0
  77. package/dist/tools/helpers/rule-matcher.js +5 -0
  78. package/dist/tools/helpers/rule-runner.d.ts +72 -0
  79. package/dist/tools/helpers/rule-runner.js +131 -0
  80. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  81. package/dist/tools/helpers/scan-cache.js +34 -0
  82. package/dist/tools/helpers/scan-plan.d.ts +48 -0
  83. package/dist/tools/helpers/scan-plan.js +166 -0
  84. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  85. package/dist/tools/helpers/scope-paths.js +32 -0
  86. package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
  87. package/dist/tools/helpers/stack-frame-file-index.js +71 -0
  88. package/dist/tools/helpers/tool-context.d.ts +60 -0
  89. package/dist/tools/helpers/tool-context.js +82 -0
  90. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  91. package/dist/tools/helpers/transform-safety.js +87 -0
  92. package/dist/tools/helpers/validation-output.d.ts +53 -0
  93. package/dist/tools/helpers/validation-output.js +48 -0
  94. package/dist/tools/inspect-form-group.d.ts +324 -0
  95. package/dist/tools/inspect-form-group.js +279 -0
  96. package/dist/tools/inspect-i18n.d.ts +466 -0
  97. package/dist/tools/inspect-i18n.js +400 -0
  98. package/dist/tools/inspect-template.d.ts +320 -0
  99. package/dist/tools/inspect-template.js +324 -0
  100. package/dist/tools/learn-patterns.d.ts +122 -1
  101. package/dist/tools/learn-patterns.js +97 -2
  102. package/dist/tools/list-imports.d.ts +128 -11
  103. package/dist/tools/list-imports.js +128 -8
  104. package/dist/tools/orchestrate-migration.d.ts +129 -5
  105. package/dist/tools/orchestrate-migration.js +166 -12
  106. package/dist/tools/parse-stack-trace.d.ts +59 -2
  107. package/dist/tools/parse-stack-trace.js +52 -4
  108. package/dist/tools/plan-migration.d.ts +418 -1
  109. package/dist/tools/plan-migration.js +355 -8
  110. package/dist/tools/resolve-type.d.ts +42 -1
  111. package/dist/tools/resolve-type.js +37 -4
  112. package/dist/tools/review-feedback.d.ts +206 -11
  113. package/dist/tools/review-feedback.js +132 -51
  114. package/dist/tools/rollback-changes.d.ts +79 -2
  115. package/dist/tools/rollback-changes.js +66 -14
  116. package/dist/tools/run-angular-cli.d.ts +45 -2
  117. package/dist/tools/run-angular-cli.js +67 -7
  118. package/dist/tools/run-build.d.ts +114 -2
  119. package/dist/tools/run-build.js +117 -8
  120. package/dist/tools/run-schematic.d.ts +70 -2
  121. package/dist/tools/run-schematic.js +104 -10
  122. package/dist/tools/scan-all.d.ts +24 -16
  123. package/dist/tools/scan-all.js +145 -137
  124. package/dist/tools/scan-angular.d.ts +20 -11
  125. package/dist/tools/scan-angular.js +52 -24
  126. package/dist/tools/scan-architecture.d.ts +42 -14
  127. package/dist/tools/scan-architecture.js +206 -163
  128. package/dist/tools/scan-solid.d.ts +20 -11
  129. package/dist/tools/scan-solid.js +52 -24
  130. package/dist/tools/search-codebase.d.ts +85 -1
  131. package/dist/tools/search-codebase.js +61 -4
  132. package/dist/tools/server-status.d.ts +370 -0
  133. package/dist/tools/server-status.js +369 -0
  134. package/dist/tools/suggest-improvements.d.ts +97 -5
  135. package/dist/tools/suggest-improvements.js +80 -44
  136. package/dist/tools/trace-output-flow.d.ts +791 -0
  137. package/dist/tools/trace-output-flow.js +668 -0
  138. package/dist/tools/transform-code-batch.d.ts +3 -0
  139. package/dist/tools/transform-code-batch.js +10 -5
  140. package/dist/tools/transform-code.d.ts +335 -12
  141. package/dist/tools/transform-code.js +649 -608
  142. package/dist/tools/validate-before-transform.d.ts +116 -2
  143. package/dist/tools/validate-before-transform.js +55 -2
  144. package/dist/tools/validate-project-compatibility.d.ts +64 -2
  145. package/dist/tools/validate-project-compatibility.js +67 -4
  146. package/dist/tools/validate-transformation.d.ts +220 -2
  147. package/dist/tools/validate-transformation.js +113 -15
  148. package/dist/tools/verify-citations.d.ts +181 -0
  149. package/dist/tools/verify-citations.js +218 -0
  150. package/dist/types.d.ts +45 -1
  151. package/dist/utils/format-tool-response.d.ts +22 -59
  152. package/dist/utils/format-tool-response.js +25 -134
  153. package/package.json +30 -13
  154. package/dist/cli.d.ts.map +0 -1
  155. package/dist/cli.js.map +0 -1
  156. package/dist/core/project-analyzer.d.ts.map +0 -1
  157. package/dist/core/project-analyzer.js.map +0 -1
  158. package/dist/index.d.ts.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/mcp-watcher.d.ts.map +0 -1
  161. package/dist/mcp-watcher.js.map +0 -1
  162. package/dist/server/json-rpc-handler.d.ts +0 -57
  163. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  164. package/dist/server/json-rpc-handler.js +0 -222
  165. package/dist/server/json-rpc-handler.js.map +0 -1
  166. package/dist/server/mcp-server.d.ts.map +0 -1
  167. package/dist/server/mcp-server.js.map +0 -1
  168. package/dist/server/tool-registry.d.ts.map +0 -1
  169. package/dist/server/tool-registry.js.map +0 -1
  170. package/dist/streaming/progress-store.d.ts.map +0 -1
  171. package/dist/streaming/progress-store.js.map +0 -1
  172. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  173. package/dist/tools/analyze-build-impact.js.map +0 -1
  174. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  175. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  176. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  177. package/dist/tools/analyze-parser-performance.js.map +0 -1
  178. package/dist/tools/analyze-project.d.ts.map +0 -1
  179. package/dist/tools/analyze-project.js.map +0 -1
  180. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  181. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  182. package/dist/tools/collect-feedback.d.ts.map +0 -1
  183. package/dist/tools/collect-feedback.js.map +0 -1
  184. package/dist/tools/extract-libraries.d.ts.map +0 -1
  185. package/dist/tools/extract-libraries.js.map +0 -1
  186. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  187. package/dist/tools/find-angular-symbol.js.map +0 -1
  188. package/dist/tools/find-usages.d.ts.map +0 -1
  189. package/dist/tools/find-usages.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/feedback-analyzer.d.ts.map +0 -1
  197. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  198. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  199. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  200. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  201. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  202. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  203. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  204. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  205. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  206. package/dist/tools/learn-patterns.d.ts.map +0 -1
  207. package/dist/tools/learn-patterns.js.map +0 -1
  208. package/dist/tools/list-imports.d.ts.map +0 -1
  209. package/dist/tools/list-imports.js.map +0 -1
  210. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  211. package/dist/tools/orchestrate-migration.js.map +0 -1
  212. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  213. package/dist/tools/parse-stack-trace.js.map +0 -1
  214. package/dist/tools/plan-migration.d.ts.map +0 -1
  215. package/dist/tools/plan-migration.js.map +0 -1
  216. package/dist/tools/resolve-type.d.ts.map +0 -1
  217. package/dist/tools/resolve-type.js.map +0 -1
  218. package/dist/tools/review-feedback.d.ts.map +0 -1
  219. package/dist/tools/review-feedback.js.map +0 -1
  220. package/dist/tools/rollback-changes.d.ts.map +0 -1
  221. package/dist/tools/rollback-changes.js.map +0 -1
  222. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  223. package/dist/tools/run-angular-cli.js.map +0 -1
  224. package/dist/tools/run-build.d.ts.map +0 -1
  225. package/dist/tools/run-build.js.map +0 -1
  226. package/dist/tools/run-schematic.d.ts.map +0 -1
  227. package/dist/tools/run-schematic.js.map +0 -1
  228. package/dist/tools/scan-all.d.ts.map +0 -1
  229. package/dist/tools/scan-all.js.map +0 -1
  230. package/dist/tools/scan-angular.d.ts.map +0 -1
  231. package/dist/tools/scan-angular.js.map +0 -1
  232. package/dist/tools/scan-architecture.d.ts.map +0 -1
  233. package/dist/tools/scan-architecture.js.map +0 -1
  234. package/dist/tools/scan-solid.d.ts.map +0 -1
  235. package/dist/tools/scan-solid.js.map +0 -1
  236. package/dist/tools/search-codebase.d.ts.map +0 -1
  237. package/dist/tools/search-codebase.js.map +0 -1
  238. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  239. package/dist/tools/shared/scan-types.js.map +0 -1
  240. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  241. package/dist/tools/suggest-improvements.js.map +0 -1
  242. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  243. package/dist/tools/transform-code-batch.js.map +0 -1
  244. package/dist/tools/transform-code.d.ts.map +0 -1
  245. package/dist/tools/transform-code.js.map +0 -1
  246. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  247. package/dist/tools/validate-before-transform.js.map +0 -1
  248. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  249. package/dist/tools/validate-project-compatibility.js.map +0 -1
  250. package/dist/tools/validate-transformation.d.ts.map +0 -1
  251. package/dist/tools/validate-transformation.js.map +0 -1
  252. package/dist/types.d.ts.map +0 -1
  253. package/dist/types.js.map +0 -1
  254. package/dist/utils/format-tool-response.d.ts.map +0 -1
  255. package/dist/utils/format-tool-response.js.map +0 -1
@@ -16,6 +16,8 @@ import { ContextFactory } from '@angular-modernizer/plugin-system';
16
16
  import { createPublicApi } from '@angular-modernizer/api';
17
17
  import { glob } from 'glob';
18
18
  import { resolve, extname } from 'node:path';
19
+ import { countList, pageNote } from './helpers/analysis-output.js';
20
+ import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
19
21
  /**
20
22
  * Default folders scanned for candidates. `libs` / `projects` cover Nx and
21
23
  * Angular CLI library workspaces; `models` / `interfaces` cover data-only
@@ -43,6 +45,38 @@ const DEFAULT_MIN_REUSABILITY = 40;
43
45
  * cluster spread over more than one sub-folder. The scanner itself uses 0.3.
44
46
  */
45
47
  const DEFAULT_MIN_COHESION = 0.5;
48
+ /** Candidates spelled out in the summary; the rest is in `opportunities`. */
49
+ const SUMMARY_CANDIDATES = 5;
50
+ /**
51
+ * Text summary: totals per complexity and kind, the first candidates of the
52
+ * page and the page itself.
53
+ */
54
+ function describeOpportunities(counts, page, offset) {
55
+ const complexity = countList(counts.byComplexity, SUMMARY_CANDIDATES);
56
+ const kinds = countList(counts.byKind, SUMMARY_CANDIDATES);
57
+ const lines = [
58
+ `${counts.totalOpportunities} library candidate(s) with ${counts.totalArtifacts} artifact(s) in ` +
59
+ `${counts.analyzedFiles} analyzed file(s)` +
60
+ (complexity === undefined ? '.' : ` (complexity ${complexity}; kind ${kinds ?? 'none'}).`),
61
+ ];
62
+ for (const o of page.slice(0, SUMMARY_CANDIDATES)) {
63
+ lines.push(`- ${o.suggestedLibraryName} (${o.category}): ${o.artifacts.length} artifact(s), cohesion ` +
64
+ `${o.cohesionScore}, reusability ${o.reusabilityScore}, complexity ${o.migrationComplexity}` +
65
+ (o.circularDependencies.length > 0
66
+ ? `, ${o.circularDependencies.length} circular dependency(ies)`
67
+ : ''));
68
+ }
69
+ const note = pageNote({
70
+ totalResults: counts.totalOpportunities,
71
+ returnedResults: page.length,
72
+ offset,
73
+ hasMore: offset + page.length < counts.totalOpportunities,
74
+ }, 'candidates');
75
+ if (note !== undefined) {
76
+ lines.push(note);
77
+ }
78
+ return lines.join('\n');
79
+ }
46
80
  /**
47
81
  * Extract Libraries Tool
48
82
  *
@@ -54,9 +88,17 @@ const DEFAULT_MIN_COHESION = 0.5;
54
88
  */
55
89
  export class ExtractLibrariesTool {
56
90
  name = 'extract-libraries';
57
- description = 'Detect Angular artifacts in shared folders that qualify for extraction into dedicated libraries with secondary entry points. Returns opportunities with cohesion/reusability scores and suggested library names.';
91
+ title = 'Detect Library Candidates';
92
+ annotations = {
93
+ readOnlyHint: true,
94
+ destructiveHint: false,
95
+ idempotentHint: true,
96
+ openWorldHint: false,
97
+ };
98
+ description = 'Detect Angular artifacts in shared folders that qualify for extraction into dedicated libraries with secondary entry points. Returns opportunities with cohesion/reusability scores and suggested library names; counts cover all of them, summary is a short text.';
58
99
  inputSchema = {
59
100
  type: 'object',
101
+ additionalProperties: false,
60
102
  properties: {
61
103
  rootPath: {
62
104
  type: 'string',
@@ -95,6 +137,65 @@ export class ExtractLibrariesTool {
95
137
  },
96
138
  required: ['rootPath'],
97
139
  };
140
+ outputSchema = {
141
+ type: 'object',
142
+ properties: {
143
+ opportunities: {
144
+ type: 'array',
145
+ items: {
146
+ type: 'object',
147
+ properties: {
148
+ ruleId: { type: 'string' },
149
+ message: { type: 'string' },
150
+ filePath: { type: 'string' },
151
+ suggestedLibraryName: { type: 'string' },
152
+ category: { type: 'string' },
153
+ artifacts: STRING_ARRAY,
154
+ secondaryEntryPoints: STRING_ARRAY,
155
+ cohesionScore: { type: 'number' },
156
+ reusabilityScore: { type: 'number' },
157
+ migrationComplexity: { type: 'string' },
158
+ estimatedEffort: {
159
+ type: 'object',
160
+ properties: { value: { type: 'number' }, unit: { type: 'string' } },
161
+ required: ['value', 'unit'],
162
+ },
163
+ dependencies: STRING_ARRAY,
164
+ circularDependencies: STRING_ARRAY,
165
+ candidateKind: { type: 'string' },
166
+ metadata: { type: 'object' },
167
+ },
168
+ required: ['suggestedLibraryName', 'category', 'artifacts', 'migrationComplexity'],
169
+ },
170
+ },
171
+ counts: {
172
+ type: 'object',
173
+ properties: {
174
+ totalOpportunities: { type: 'integer' },
175
+ analyzedFiles: { type: 'integer' },
176
+ byCategory: COUNT_OBJECT,
177
+ byComplexity: COUNT_OBJECT,
178
+ byKind: COUNT_OBJECT,
179
+ totalArtifacts: { type: 'integer' },
180
+ },
181
+ required: ['totalOpportunities', 'analyzedFiles', 'byCategory', 'byComplexity', 'byKind', 'totalArtifacts'],
182
+ },
183
+ summary: { type: 'string' },
184
+ nextSteps: STRING_ARRAY,
185
+ metadata: {
186
+ type: 'object',
187
+ properties: {
188
+ duration: { type: 'number' },
189
+ projectRoot: { type: 'string' },
190
+ targetFolders: STRING_ARRAY,
191
+ minReusabilityScore: { type: 'number' },
192
+ minCohesionScore: { type: 'number' },
193
+ },
194
+ required: ['duration', 'projectRoot', 'targetFolders', 'minReusabilityScore', 'minCohesionScore'],
195
+ },
196
+ },
197
+ required: ['opportunities', 'counts', 'summary', 'nextSteps', 'metadata'],
198
+ };
98
199
  async execute(args) {
99
200
  const params = args;
100
201
  if (!params.rootPath || typeof params.rootPath !== 'string') {
@@ -182,16 +283,18 @@ export class ExtractLibrariesTool {
182
283
  totalArtifacts += opp.artifacts.length;
183
284
  }
184
285
  const nextSteps = this.buildNextSteps(allOpportunities);
286
+ const counts = {
287
+ totalOpportunities: allOpportunities.length,
288
+ analyzedFiles,
289
+ byCategory,
290
+ byComplexity,
291
+ byKind,
292
+ totalArtifacts,
293
+ };
185
294
  return {
186
295
  opportunities: paginated,
187
- summary: {
188
- totalOpportunities: allOpportunities.length,
189
- analyzedFiles,
190
- byCategory,
191
- byComplexity,
192
- byKind,
193
- totalArtifacts,
194
- },
296
+ counts,
297
+ summary: describeOpportunities(counts, paginated, resultOffset),
195
298
  nextSteps,
196
299
  metadata: {
197
300
  duration: Date.now() - startTime,
@@ -208,7 +311,7 @@ export class ExtractLibrariesTool {
208
311
  emptyResult(projectRoot, targetFolders, minReusabilityScore, minCohesionScore, analyzedFiles, startTime) {
209
312
  return {
210
313
  opportunities: [],
211
- summary: {
314
+ counts: {
212
315
  totalOpportunities: 0,
213
316
  analyzedFiles,
214
317
  byCategory: {},
@@ -216,6 +319,8 @@ export class ExtractLibrariesTool {
216
319
  byKind: {},
217
320
  totalArtifacts: 0,
218
321
  },
322
+ summary: `No library candidates in ${analyzedFiles} analyzed file(s); lower minReusabilityScore ` +
323
+ 'or minCohesionScore to broaden the search.',
219
324
  nextSteps: [
220
325
  'No library extraction opportunities detected. Lower minReusabilityScore or minCohesionScore to broaden the search.',
221
326
  ],
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * @remarks
9
9
  * Supports both standard Angular decorators (@Component, @Directive, @Pipe,
10
- * @Injectable, @NgModule) and ngUWI-specific external decorators
11
- * (@ExportComponent, @ExportFunction).
10
+ * @Injectable, @NgModule) and the project's own component decorators
11
+ * (`parser.componentDecorators` in `.angular-modernizer.json`).
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -18,17 +18,47 @@
18
18
  * // args: { query: 'UserService', type: 'service', projectRoot: '/project' }
19
19
  * ```
20
20
  */
21
- import { type MCPTool } from '../types.js';
22
- import { type AngularSymbolResult } from '@angular-modernizer/api';
21
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
22
+ import { type AngularSymbolResult, type AngularSymbolType } from '@angular-modernizer/api';
23
+ import { ProjectCache } from './helpers/project-cache.js';
24
+ /** Output of the find-angular-symbol tool. */
25
+ interface FindAngularSymbolOutput {
26
+ /** Matching symbols, cut to `maxResults`; omitted with `summaryOnly`. */
27
+ results?: AngularSymbolResult[];
28
+ /** Total number of matches (before `maxResults`). */
29
+ totalCount: number;
30
+ /** `true` when `maxResults` cut the result list. */
31
+ truncated: boolean;
32
+ /** Match counts per Angular symbol type. */
33
+ countsByType: Partial<Record<AngularSymbolType, number>>;
34
+ /** Human-readable summary for LLM consumption. */
35
+ summary: string;
36
+ /** Conditions that can make the result incomplete (unresolved library imports). */
37
+ warnings?: string[];
38
+ }
23
39
  /**
24
40
  * MCP tool that finds Angular symbols by selector, pipe name, or class name.
25
41
  */
26
42
  export declare class FindAngularSymbolTool implements MCPTool {
43
+ private readonly projects;
27
44
  readonly name = "find-angular-symbol";
45
+ readonly title = "Find Angular Symbol";
46
+ readonly annotations: ToolAnnotations;
47
+ constructor(projects?: ProjectCache);
28
48
  readonly description: string;
29
49
  readonly inputSchema: {
30
50
  type: string;
51
+ additionalProperties: boolean;
31
52
  properties: {
53
+ summaryOnly: {
54
+ readonly type: "boolean";
55
+ readonly description: "Return counts and the text summary only, without the result list. Default: false.";
56
+ readonly default: false;
57
+ };
58
+ maxResults: {
59
+ readonly type: "number";
60
+ readonly description: string;
61
+ };
32
62
  query: {
33
63
  type: string;
34
64
  description: string;
@@ -45,11 +75,70 @@ export declare class FindAngularSymbolTool implements MCPTool {
45
75
  };
46
76
  required: string[];
47
77
  };
48
- execute(args: Record<string, unknown>): Promise<{
49
- results: AngularSymbolResult[];
50
- totalCount: number;
51
- summary: string;
52
- }>;
78
+ readonly outputSchema: {
79
+ type: string;
80
+ properties: {
81
+ warnings: {
82
+ readonly type: "array";
83
+ readonly items: {
84
+ readonly type: "string";
85
+ };
86
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
87
+ };
88
+ results: {
89
+ type: string;
90
+ items: {
91
+ type: string;
92
+ properties: {
93
+ file: {
94
+ type: string;
95
+ };
96
+ className: {
97
+ type: string;
98
+ };
99
+ angularType: {
100
+ type: string;
101
+ };
102
+ selector: {
103
+ type: string;
104
+ };
105
+ pipeName: {
106
+ type: string;
107
+ };
108
+ metadata: {
109
+ type: string;
110
+ additionalProperties: {
111
+ type: string;
112
+ };
113
+ };
114
+ source: {
115
+ type: string;
116
+ };
117
+ };
118
+ required: string[];
119
+ };
120
+ };
121
+ totalCount: {
122
+ type: string;
123
+ };
124
+ truncated: {
125
+ type: string;
126
+ };
127
+ countsByType: {
128
+ type: string;
129
+ additionalProperties: {
130
+ type: string;
131
+ };
132
+ };
133
+ summary: {
134
+ type: string;
135
+ };
136
+ };
137
+ required: string[];
138
+ };
139
+ execute(args: Record<string, unknown>): Promise<FindAngularSymbolOutput>;
140
+ private buildCompactSummary;
53
141
  private buildSummary;
54
142
  }
143
+ export {};
55
144
  //# sourceMappingURL=find-angular-symbol.d.ts.map
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * @remarks
9
9
  * Supports both standard Angular decorators (@Component, @Directive, @Pipe,
10
- * @Injectable, @NgModule) and ngUWI-specific external decorators
11
- * (@ExportComponent, @ExportFunction).
10
+ * @Injectable, @NgModule) and the project's own component decorators
11
+ * (`parser.componentDecorators` in `.angular-modernizer.json`).
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -18,23 +18,45 @@
18
18
  * // args: { query: 'UserService', type: 'service', projectRoot: '/project' }
19
19
  * ```
20
20
  */
21
- import { Project } from 'ts-morph';
22
21
  import { AngularSymbolFinder, } from '@angular-modernizer/api';
23
22
  import { existsSync } from 'node:fs';
24
23
  import { findTsConfig } from './helpers/find-ts-config.js';
24
+ import { ProjectCache } from './helpers/project-cache.js';
25
+ import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
26
+ import { configuredComponentDecorators } from './helpers/project-decorators.js';
27
+ import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
28
+ /** Symbols named in the summaryOnly text. */
29
+ const SUMMARY_NAMES = 10;
25
30
  /**
26
31
  * MCP tool that finds Angular symbols by selector, pipe name, or class name.
27
32
  */
28
33
  export class FindAngularSymbolTool {
34
+ projects;
29
35
  name = 'find-angular-symbol';
36
+ title = 'Find Angular Symbol';
37
+ annotations = {
38
+ readOnlyHint: true,
39
+ destructiveHint: false,
40
+ idempotentHint: true,
41
+ openWorldHint: false,
42
+ };
43
+ constructor(projects = new ProjectCache()) {
44
+ this.projects = projects;
45
+ }
30
46
  description = 'Find Angular symbols (components, directives, pipes, services, guards, ' +
31
47
  'interceptors, resolvers, modules, tokens) by selector, pipe name, or class name. ' +
32
48
  'Accepts CSS selectors (e.g. app-user), attribute selectors (e.g. appHighlight), ' +
33
49
  'pipe template names (e.g. dateFormat), or TypeScript class names. ' +
34
- 'Supports standard Angular decorators and ngUWI @ExportComponent/@ExportFunction. ' +
35
- 'Use during bug investigation to locate which class owns a given selector or pipe.';
50
+ 'Supports standard Angular decorators and the project component decorators listed in ' +
51
+ 'parser.componentDecorators of .angular-modernizer.json. ' +
52
+ 'Library components, directives and pipes (e.g. the ngx-translate translate pipe) come from ' +
53
+ 'compiled .d.ts metadata with source "library", after project symbols; they match exactly (class name, ' +
54
+ 'pipe name or one selector of the list), not by substring. *.spec.ts files are skipped. ' +
55
+ 'Use during bug investigation to locate which class owns a given selector or pipe. ' +
56
+ 'Selector and pipe queries match substrings; use summaryOnly or maxResults for short queries.';
36
57
  inputSchema = {
37
58
  type: 'object',
59
+ additionalProperties: false,
38
60
  properties: {
39
61
  query: {
40
62
  type: 'string',
@@ -61,9 +83,43 @@ export class FindAngularSymbolTool {
61
83
  type: 'string',
62
84
  description: 'Absolute path to the project root. Must contain a tsconfig.json.',
63
85
  },
86
+ ...COMPACT_OUTPUT_SCHEMA,
64
87
  },
65
88
  required: ['query', 'projectRoot'],
66
89
  };
90
+ outputSchema = {
91
+ type: 'object',
92
+ properties: {
93
+ results: {
94
+ type: 'array',
95
+ items: {
96
+ type: 'object',
97
+ properties: {
98
+ file: { type: 'string' },
99
+ className: { type: 'string' },
100
+ angularType: { type: 'string' },
101
+ selector: { type: 'string' },
102
+ pipeName: { type: 'string' },
103
+ metadata: {
104
+ type: 'object',
105
+ additionalProperties: { type: 'string' },
106
+ },
107
+ source: { type: 'string' },
108
+ },
109
+ required: ['file', 'className', 'angularType', 'metadata'],
110
+ },
111
+ },
112
+ totalCount: { type: 'integer' },
113
+ truncated: { type: 'boolean' },
114
+ countsByType: {
115
+ type: 'object',
116
+ additionalProperties: { type: 'integer' },
117
+ },
118
+ summary: { type: 'string' },
119
+ ...WARNINGS_OUTPUT_SCHEMA,
120
+ },
121
+ required: ['totalCount', 'truncated', 'countsByType', 'summary'],
122
+ };
67
123
  async execute(args) {
68
124
  const params = args;
69
125
  if (!params.query) {
@@ -72,6 +128,7 @@ export class FindAngularSymbolTool {
72
128
  if (!params.projectRoot) {
73
129
  throw new Error('projectRoot is required');
74
130
  }
131
+ const compact = parseCompactOptions(args);
75
132
  if (!existsSync(params.projectRoot)) {
76
133
  throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
77
134
  }
@@ -79,14 +136,48 @@ export class FindAngularSymbolTool {
79
136
  if (!tsConfigPath) {
80
137
  throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
81
138
  }
82
- const project = new Project({ tsConfigFilePath: tsConfigPath });
83
- const finder = new AngularSymbolFinder(project);
139
+ const project = this.projects.get(tsConfigPath);
140
+ const finder = new AngularSymbolFinder(project, {
141
+ componentDecorators: configuredComponentDecorators(params.projectRoot),
142
+ });
84
143
  const results = finder.findSymbol(params.query, params.type);
85
- return {
86
- results,
144
+ const warnings = this.projects.warnings(tsConfigPath);
145
+ const countsByType = {};
146
+ for (const r of results) {
147
+ countsByType[r.angularType] = (countsByType[r.angularType] ?? 0) + 1;
148
+ }
149
+ if (compact.summaryOnly) {
150
+ return withWarnings({
151
+ totalCount: results.length,
152
+ truncated: false,
153
+ countsByType,
154
+ summary: this.buildCompactSummary(params.query, results, countsByType),
155
+ }, warnings);
156
+ }
157
+ const shown = limitList(results, compact.maxResults);
158
+ const note = truncationNote(shown.items.length, results.length, 'symbols');
159
+ const summary = this.buildSummary(params.query, params.type, shown.items);
160
+ return withWarnings({
161
+ results: shown.items,
87
162
  totalCount: results.length,
88
- summary: this.buildSummary(params.query, params.type, results),
89
- };
163
+ truncated: shown.truncated,
164
+ countsByType,
165
+ summary: note ? `${note}\n${summary}` : summary,
166
+ }, warnings);
167
+ }
168
+ buildCompactSummary(query, results, countsByType) {
169
+ if (results.length === 0) {
170
+ return `No Angular symbol found matching '${query}'.`;
171
+ }
172
+ const types = Object.entries(countsByType)
173
+ .map(([type, count]) => `${type} ${count}`)
174
+ .join(', ');
175
+ const names = results.slice(0, SUMMARY_NAMES).map((r) => r.className);
176
+ const more = results.length > SUMMARY_NAMES
177
+ ? ` and ${results.length - SUMMARY_NAMES} more`
178
+ : '';
179
+ return (`Found ${results.length} symbol(s) matching '${query}' (${types}): ` +
180
+ `${names.join(', ')}${more}.`);
90
181
  }
91
182
  buildSummary(query, type, results) {
92
183
  if (results.length === 0) {
@@ -96,7 +187,8 @@ export class FindAngularSymbolTool {
96
187
  const typeStr = type ? ` ${type}` : '';
97
188
  const lines = results.map((r) => `${r.className} (${r.angularType}) in ${r.file}` +
98
189
  (r.selector ? ` [selector: ${r.selector}]` : '') +
99
- (r.pipeName ? ` [pipe: ${r.pipeName}]` : ''));
190
+ (r.pipeName ? ` [pipe: ${r.pipeName}]` : '') +
191
+ (r.source === 'library' ? ' [library]' : ''));
100
192
  return (`Found ${results.length}${typeStr} symbol${results.length === 1 ? '' : 's'} matching '${query}':\n` +
101
193
  lines.join('\n'));
102
194
  }