@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
@@ -11,15 +11,62 @@ import { findTsConfig } from './helpers/find-ts-config.js';
11
11
  import { Project, SyntaxKind } from 'ts-morph';
12
12
  import { writeFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
13
13
  import { resolve, dirname } from 'node:path';
14
+ import { countList } from './helpers/analysis-output.js';
15
+ import { COUNT_OBJECT } from './helpers/investigation-schemas.js';
14
16
  import { PatternKnowledgeBase, StyleConventionDetector, ContextAwareScorer, ContextAwareRuleGenerator, RealFileSystemAdapter, } from '@angular-modernizer/core';
17
+ /** Categories and patterns named in the summary. */
18
+ const SUMMARY_PATTERNS = 5;
19
+ /**
20
+ * Text summary: totals per category and complexity, the most frequent
21
+ * patterns, the style profile and what was written.
22
+ */
23
+ function describePatterns(result) {
24
+ const { statistics } = result;
25
+ const categories = countList(statistics.byCategory, SUMMARY_PATTERNS);
26
+ const complexity = countList(statistics.byComplexity, SUMMARY_PATTERNS);
27
+ const lines = [
28
+ `${statistics.totalPatternsFound} pattern(s) in ${statistics.filesAnalyzed} analyzed file(s)` +
29
+ (categories === undefined ? '.' : ` (category ${categories}; complexity ${complexity ?? 'none'}).`),
30
+ ];
31
+ const top = [...result.patterns]
32
+ .sort((a, b) => b.occurrences - a.occurrences || a.name.localeCompare(b.name))
33
+ .slice(0, SUMMARY_PATTERNS);
34
+ for (const p of top) {
35
+ const confidence = p.confidence === undefined ? '' : `, confidence ${p.confidence.toFixed(2)}`;
36
+ lines.push(`- ${p.name} (${p.category}): ${p.occurrences} occurrence(s), ${p.complexity}${confidence}`);
37
+ }
38
+ const style = result.styleProfile;
39
+ if (style !== undefined) {
40
+ lines.push(`Style: DI ${style.diPreference}, RxJS ${style.rxjsPreference}, change detection ` +
41
+ `${style.changeDetectionPreference}, modules ${style.moduleStyle}, state ${style.stateManagement}, ` +
42
+ `architecture ${style.architectureStyle} (confidence ${style.confidence.toFixed(2)}).`);
43
+ }
44
+ if (result.generatedRules !== undefined) {
45
+ lines.push(`${result.generatedRules.length} rule(s) generated.`);
46
+ }
47
+ const fixtures = result.artifacts?.fixtures?.length ?? 0;
48
+ const rules = result.artifacts?.rules?.length ?? 0;
49
+ if (fixtures + rules > 0) {
50
+ lines.push(`Written: ${fixtures} fixture file(s), ${rules} rule file(s).`);
51
+ }
52
+ return lines.join('\n');
53
+ }
15
54
  /**
16
55
  * MCP tool for learning patterns from codebases.
17
56
  */
18
57
  export class LearnPatternsTool {
19
58
  name = 'learn-patterns';
20
- description = 'Discover and learn patterns from codebases using ML-based pattern recognition with self-learning capabilities. Identifies recurring architectural patterns, anti-patterns, and transformation opportunities while respecting codebase style conventions.';
59
+ title = 'Learn Patterns';
60
+ annotations = {
61
+ readOnlyHint: false,
62
+ destructiveHint: false,
63
+ idempotentHint: true,
64
+ openWorldHint: false,
65
+ };
66
+ description = 'Discover and learn patterns from codebases using ML-based pattern recognition with self-learning capabilities. Identifies recurring architectural patterns, anti-patterns, and transformation opportunities while respecting codebase style conventions. summary is a short text of patterns and style profile.';
21
67
  inputSchema = {
22
68
  type: 'object',
69
+ additionalProperties: false,
23
70
  properties: {
24
71
  targetPath: {
25
72
  type: 'string',
@@ -157,6 +204,54 @@ export class LearnPatternsTool {
157
204
  },
158
205
  required: ['targetPath'],
159
206
  };
207
+ outputSchema = {
208
+ type: 'object',
209
+ properties: {
210
+ patterns: {
211
+ type: 'array',
212
+ items: {
213
+ type: 'object',
214
+ properties: {
215
+ id: { type: 'string' },
216
+ name: { type: 'string' },
217
+ category: { type: 'string' },
218
+ description: { type: 'string' },
219
+ occurrences: { type: 'integer' },
220
+ complexity: { type: 'string' },
221
+ examples: { type: 'array', items: { type: 'object' } },
222
+ suggestedRule: { type: 'object' },
223
+ confidence: { type: 'number' },
224
+ confidenceExplanation: { type: 'string' },
225
+ alignsWithStyle: { type: 'boolean' },
226
+ styleAlignment: { type: 'number' },
227
+ dominancePercentage: { type: 'number' },
228
+ trending: { type: 'string' },
229
+ scanCount: { type: 'integer' },
230
+ },
231
+ required: ['id', 'name', 'category', 'occurrences', 'complexity'],
232
+ },
233
+ },
234
+ statistics: {
235
+ type: 'object',
236
+ properties: {
237
+ totalPatternsFound: { type: 'integer' },
238
+ byCategory: COUNT_OBJECT,
239
+ byComplexity: COUNT_OBJECT,
240
+ filesAnalyzed: { type: 'integer' },
241
+ duration: { type: 'number' },
242
+ },
243
+ required: ['totalPatternsFound', 'byCategory', 'byComplexity', 'filesAnalyzed', 'duration'],
244
+ },
245
+ artifacts: { type: 'object' },
246
+ validation: { type: 'object' },
247
+ styleProfile: { type: 'object' },
248
+ learningEvolution: { type: 'object' },
249
+ confidenceAnalysis: { type: 'object' },
250
+ generatedRules: { type: 'array', items: { type: 'object' } },
251
+ summary: { type: 'string' },
252
+ },
253
+ required: ['patterns', 'statistics', 'summary'],
254
+ };
160
255
  async execute(args) {
161
256
  const params = args;
162
257
  const targetPath = params.targetPath;
@@ -458,7 +553,7 @@ export class LearnPatternsTool {
458
553
  if (generatedRulesResult) {
459
554
  result.generatedRules = generatedRulesResult;
460
555
  }
461
- return result;
556
+ return { ...result, summary: describePatterns(result) };
462
557
  }
463
558
  /**
464
559
  * Discover patterns from the project.
@@ -17,7 +17,7 @@
17
17
  * // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
18
18
  * ```
19
19
  */
20
- import { type MCPTool } from '../types.js';
20
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
21
21
  import { type ModuleSpecifierKind } from '@angular-modernizer/core';
22
22
  import { ProjectCache } from './helpers/project-cache.js';
23
23
  /**
@@ -63,15 +63,21 @@ interface ListImportsOutput {
63
63
  /** `true` when `maxResults` cut the import list. */
64
64
  truncated: boolean;
65
65
  /** Counts over all imports, independent of `maxResults`. */
66
- summary: {
67
- total: number;
68
- aliased: number;
69
- relative: number;
70
- external: number;
71
- unresolved: number;
72
- reExports: number;
73
- typeOnly: number;
74
- };
66
+ counts: ImportCounts;
67
+ /** Human-readable summary for LLM consumption. */
68
+ summary: string;
69
+ /** Conditions that can make the result incomplete (unresolved library imports). */
70
+ warnings?: string[];
71
+ }
72
+ /** Counts over all imports of the file. */
73
+ interface ImportCounts {
74
+ total: number;
75
+ aliased: number;
76
+ relative: number;
77
+ external: number;
78
+ unresolved: number;
79
+ reExports: number;
80
+ typeOnly: number;
75
81
  }
76
82
  /**
77
83
  * MCP tool that lists the resolved imports of a file.
@@ -79,10 +85,13 @@ interface ListImportsOutput {
79
85
  export declare class ListImportsTool implements MCPTool {
80
86
  private readonly projects;
81
87
  readonly name = "list-imports";
88
+ readonly title = "List Imports";
89
+ readonly annotations: ToolAnnotations;
82
90
  constructor(projects?: ProjectCache);
83
91
  readonly description: string;
84
92
  readonly inputSchema: {
85
93
  type: string;
94
+ additionalProperties: boolean;
86
95
  properties: {
87
96
  summaryOnly: {
88
97
  readonly type: "boolean";
@@ -109,11 +118,103 @@ export declare class ListImportsTool implements MCPTool {
109
118
  };
110
119
  required: string[];
111
120
  };
121
+ readonly outputSchema: {
122
+ type: string;
123
+ properties: {
124
+ warnings: {
125
+ readonly type: "array";
126
+ readonly items: {
127
+ readonly type: "string";
128
+ };
129
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
130
+ };
131
+ file: {
132
+ type: string;
133
+ };
134
+ projectRoot: {
135
+ type: string;
136
+ };
137
+ tsConfigPath: {
138
+ type: string;
139
+ };
140
+ imports: {
141
+ type: string;
142
+ items: {
143
+ type: string;
144
+ properties: {
145
+ moduleSpecifier: {
146
+ type: string;
147
+ };
148
+ kind: {
149
+ type: string;
150
+ };
151
+ resolvedPath: {
152
+ type: string[];
153
+ };
154
+ namedImports: {
155
+ type: string;
156
+ items: {
157
+ type: string;
158
+ properties: {
159
+ name: {
160
+ type: string;
161
+ };
162
+ alias: {
163
+ type: string[];
164
+ };
165
+ typeOnly: {
166
+ type: string;
167
+ };
168
+ };
169
+ required: string[];
170
+ };
171
+ };
172
+ defaultImport: {
173
+ type: string[];
174
+ };
175
+ namespaceImport: {
176
+ type: string[];
177
+ };
178
+ typeOnly: {
179
+ type: string;
180
+ };
181
+ isReExport: {
182
+ type: string;
183
+ };
184
+ isStarReExport: {
185
+ type: string;
186
+ };
187
+ line: {
188
+ type: string;
189
+ };
190
+ };
191
+ required: string[];
192
+ };
193
+ };
194
+ truncated: {
195
+ type: string;
196
+ };
197
+ counts: {
198
+ type: string;
199
+ properties: {
200
+ [k: string]: {
201
+ type: string;
202
+ };
203
+ };
204
+ required: ("total" | "external" | "unresolved" | "aliased" | "relative" | "reExports" | "typeOnly")[];
205
+ };
206
+ summary: {
207
+ type: string;
208
+ };
209
+ };
210
+ required: string[];
211
+ };
112
212
  execute(args: Record<string, unknown>): Promise<ListImportsOutput>;
113
213
  private resolveFilePath;
114
214
  private findProjectRoot;
115
215
  private toEntry;
116
216
  private buildSummary;
217
+ private countImports;
117
218
  }
118
219
  export {};
119
220
  //# sourceMappingURL=list-imports.d.ts.map
@@ -23,13 +23,32 @@ import { existsSync } from 'node:fs';
23
23
  import { dirname, isAbsolute, relative, resolve } from 'node:path';
24
24
  import { findTsConfig } from './helpers/find-ts-config.js';
25
25
  import { ProjectCache } from './helpers/project-cache.js';
26
- import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
26
+ import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
27
+ import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
28
+ /** Unresolved specifiers named in the summary. */
29
+ const SUMMARY_UNRESOLVED = 10;
30
+ const COUNT_KEYS = [
31
+ 'total',
32
+ 'aliased',
33
+ 'relative',
34
+ 'external',
35
+ 'unresolved',
36
+ 'reExports',
37
+ 'typeOnly',
38
+ ];
27
39
  /**
28
40
  * MCP tool that lists the resolved imports of a file.
29
41
  */
30
42
  export class ListImportsTool {
31
43
  projects;
32
44
  name = 'list-imports';
45
+ title = 'List Imports';
46
+ annotations = {
47
+ readOnlyHint: true,
48
+ destructiveHint: false,
49
+ idempotentHint: true,
50
+ openWorldHint: false,
51
+ };
33
52
  constructor(projects = new ProjectCache()) {
34
53
  this.projects = projects;
35
54
  }
@@ -37,9 +56,10 @@ export class ListImportsTool {
37
56
  'For each import: moduleSpecifier, kind (aliased | relative | external), ' +
38
57
  'project-relative resolvedPath (tsconfig paths aware), named/default/namespace imports, ' +
39
58
  'type-only flags and whether it is a re-export. Use instead of grepping import lines. ' +
40
- 'summary counts always cover all imports; summaryOnly returns only the counts.';
59
+ 'counts always cover all imports; summaryOnly returns only the counts and the summary.';
41
60
  inputSchema = {
42
61
  type: 'object',
62
+ additionalProperties: false,
43
63
  properties: {
44
64
  file: {
45
65
  type: 'string',
@@ -58,6 +78,64 @@ export class ListImportsTool {
58
78
  },
59
79
  required: ['file'],
60
80
  };
81
+ outputSchema = {
82
+ type: 'object',
83
+ properties: {
84
+ file: { type: 'string' },
85
+ projectRoot: { type: 'string' },
86
+ tsConfigPath: { type: 'string' },
87
+ imports: {
88
+ type: 'array',
89
+ items: {
90
+ type: 'object',
91
+ properties: {
92
+ moduleSpecifier: { type: 'string' },
93
+ kind: { type: 'string' },
94
+ resolvedPath: { type: ['string', 'null'] },
95
+ namedImports: {
96
+ type: 'array',
97
+ items: {
98
+ type: 'object',
99
+ properties: {
100
+ name: { type: 'string' },
101
+ alias: { type: ['string', 'null'] },
102
+ typeOnly: { type: 'boolean' },
103
+ },
104
+ required: ['name', 'alias', 'typeOnly'],
105
+ },
106
+ },
107
+ defaultImport: { type: ['string', 'null'] },
108
+ namespaceImport: { type: ['string', 'null'] },
109
+ typeOnly: { type: 'boolean' },
110
+ isReExport: { type: 'boolean' },
111
+ isStarReExport: { type: 'boolean' },
112
+ line: { type: 'integer' },
113
+ },
114
+ required: [
115
+ 'moduleSpecifier',
116
+ 'kind',
117
+ 'resolvedPath',
118
+ 'namedImports',
119
+ 'defaultImport',
120
+ 'namespaceImport',
121
+ 'typeOnly',
122
+ 'isReExport',
123
+ 'isStarReExport',
124
+ 'line',
125
+ ],
126
+ },
127
+ },
128
+ truncated: { type: 'boolean' },
129
+ counts: {
130
+ type: 'object',
131
+ properties: Object.fromEntries(COUNT_KEYS.map((k) => [k, { type: 'integer' }])),
132
+ required: [...COUNT_KEYS],
133
+ },
134
+ summary: { type: 'string' },
135
+ ...WARNINGS_OUTPUT_SCHEMA,
136
+ },
137
+ required: ['file', 'projectRoot', 'tsConfigPath', 'truncated', 'counts', 'summary'],
138
+ };
61
139
  async execute(args) {
62
140
  const params = args;
63
141
  if (!params.file || typeof params.file !== 'string') {
@@ -84,19 +162,24 @@ export class ListImportsTool {
84
162
  new Project({ tsConfigFilePath: tsConfigPath }).addSourceFileAtPath(filePath);
85
163
  const includeReExports = params.includeReExports !== false;
86
164
  const imports = collectModuleEdges(sourceFile, includeReExports).map((edge) => this.toEntry(sourceFile, edge, projectRoot));
87
- const summary = this.buildSummary(imports);
165
+ const counts = this.countImports(imports);
166
+ const warnings = this.projects.warnings(tsConfigPath);
167
+ const label = relative(projectRoot, filePath) || filePath;
88
168
  if (compact.summaryOnly) {
89
- return { file: filePath, projectRoot, tsConfigPath, truncated: false, summary };
169
+ const summary = this.buildSummary(label, imports, counts, imports.length);
170
+ return withWarnings({ file: filePath, projectRoot, tsConfigPath, truncated: false, counts, summary }, warnings);
90
171
  }
91
172
  const shown = limitList(imports, compact.maxResults);
92
- return {
173
+ const summary = this.buildSummary(label, imports, counts, shown.items.length);
174
+ return withWarnings({
93
175
  file: filePath,
94
176
  projectRoot,
95
177
  tsConfigPath,
96
178
  imports: shown.items,
97
179
  truncated: shown.truncated,
180
+ counts,
98
181
  summary,
99
- };
182
+ }, warnings);
100
183
  }
101
184
  resolveFilePath(file, projectRoot) {
102
185
  if (isAbsolute(file)) {
@@ -155,7 +238,27 @@ export class ListImportsTool {
155
238
  line: edge.declaration.getStartLineNumber(),
156
239
  };
157
240
  }
158
- buildSummary(imports) {
241
+ buildSummary(file, imports, counts, shown) {
242
+ const lines = [
243
+ `${file}: ${counts.total} import(s) (${counts.aliased} aliased, ${counts.relative} relative, ` +
244
+ `${counts.external} external), ${counts.reExports} re-export(s), ${counts.typeOnly} type-only.`,
245
+ ];
246
+ const unresolved = imports
247
+ .filter((e) => e.kind !== 'external' && e.resolvedPath === null)
248
+ .map((e) => `${e.moduleSpecifier} (line ${e.line})`);
249
+ if (unresolved.length > 0) {
250
+ const more = unresolved.length > SUMMARY_UNRESOLVED
251
+ ? ` and ${unresolved.length - SUMMARY_UNRESOLVED} more`
252
+ : '';
253
+ lines.push(`${unresolved.length} unresolved: ${unresolved.slice(0, SUMMARY_UNRESOLVED).join(', ')}${more}.`);
254
+ }
255
+ const note = truncationNote(shown, counts.total, 'imports');
256
+ if (note !== undefined) {
257
+ lines.push(note);
258
+ }
259
+ return lines.join('\n');
260
+ }
261
+ countImports(imports) {
159
262
  const count = (predicate) => imports.filter(predicate).length;
160
263
  return {
161
264
  total: imports.length,
@@ -4,7 +4,7 @@
4
4
  * MCP tool for executing multi-step migration workflows with
5
5
  * dependency management, checkpoint/resume, and rollback support.
6
6
  */
7
- import { type MCPTool } from '../types.js';
7
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
8
8
  /**
9
9
  * Result from orchestrate-migration tool
10
10
  */
@@ -14,10 +14,13 @@ interface OrchestrateMigrationResult {
14
14
  */
15
15
  status: 'completed' | 'failed' | 'partial';
16
16
  /**
17
- * Execution summary
17
+ * Workflow that ran
18
18
  */
19
- summary: {
20
- workflowId: string;
19
+ workflowId: string;
20
+ /**
21
+ * Step counts and total duration
22
+ */
23
+ counts: {
21
24
  totalSteps: number;
22
25
  successfulSteps: number;
23
26
  failedSteps: number;
@@ -61,15 +64,22 @@ interface OrchestrateMigrationResult {
61
64
  * Message for the user
62
65
  */
63
66
  message: string;
67
+ /**
68
+ * Short text: status, step counts, duration, message and the first errors.
69
+ */
70
+ summary: string;
64
71
  }
65
72
  /**
66
73
  * Orchestrate Migration MCP Tool
67
74
  */
68
75
  export declare class OrchestrateMigrationTool implements MCPTool {
69
76
  name: string;
77
+ title: string;
78
+ annotations: ToolAnnotations;
70
79
  description: string;
71
80
  inputSchema: {
72
81
  type: string;
82
+ additionalProperties: boolean;
73
83
  properties: {
74
84
  workflow: {
75
85
  type: string;
@@ -170,6 +180,118 @@ export declare class OrchestrateMigrationTool implements MCPTool {
170
180
  };
171
181
  required: string[];
172
182
  };
183
+ outputSchema: {
184
+ type: string;
185
+ properties: {
186
+ status: {
187
+ type: string;
188
+ enum: string[];
189
+ };
190
+ workflowId: {
191
+ type: string;
192
+ };
193
+ counts: {
194
+ type: string;
195
+ properties: {
196
+ totalSteps: {
197
+ type: string;
198
+ };
199
+ successfulSteps: {
200
+ type: string;
201
+ };
202
+ failedSteps: {
203
+ type: string;
204
+ };
205
+ skippedSteps: {
206
+ type: string;
207
+ };
208
+ totalDurationMs: {
209
+ type: string;
210
+ };
211
+ };
212
+ required: string[];
213
+ };
214
+ stepResults: {
215
+ type: string;
216
+ items: {
217
+ type: string;
218
+ properties: {
219
+ stepId: {
220
+ type: string;
221
+ };
222
+ name: {
223
+ type: string;
224
+ };
225
+ status: {
226
+ type: string;
227
+ };
228
+ durationMs: {
229
+ type: string;
230
+ };
231
+ error: {
232
+ type: string;
233
+ };
234
+ };
235
+ required: string[];
236
+ };
237
+ };
238
+ checkpoints: {
239
+ type: string;
240
+ items: {
241
+ type: string;
242
+ properties: {
243
+ id: {
244
+ type: string;
245
+ };
246
+ stepId: {
247
+ type: string;
248
+ };
249
+ timestamp: {
250
+ type: string;
251
+ };
252
+ };
253
+ required: string[];
254
+ };
255
+ };
256
+ errors: {
257
+ type: string;
258
+ items: {
259
+ type: string;
260
+ properties: {
261
+ stepId: {
262
+ type: string;
263
+ };
264
+ message: {
265
+ type: string;
266
+ };
267
+ stack: {
268
+ type: string;
269
+ };
270
+ };
271
+ required: string[];
272
+ };
273
+ };
274
+ finalCheckpoint: {
275
+ type: string;
276
+ properties: {
277
+ id: {
278
+ type: string;
279
+ };
280
+ canResume: {
281
+ type: string;
282
+ };
283
+ };
284
+ required: string[];
285
+ };
286
+ message: {
287
+ type: string;
288
+ };
289
+ summary: {
290
+ type: string;
291
+ };
292
+ };
293
+ required: string[];
294
+ };
173
295
  private availableTools;
174
296
  private readonly checkpointManager;
175
297
  constructor();
@@ -177,7 +299,8 @@ export declare class OrchestrateMigrationTool implements MCPTool {
177
299
  * Set the available tools for workflow execution
178
300
  */
179
301
  setAvailableTools(tools: Map<string, MCPTool>): void;
180
- execute(args: Record<string, unknown>): Promise<OrchestrateMigrationResult>;
302
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<OrchestrateMigrationResult>;
303
+ private runWorkflow;
181
304
  private unknownToolsResult;
182
305
  /**
183
306
  * Build result from workflow execution