@angular-modernizer/adapter-mcp 0.3.0 → 1.1.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 (298) hide show
  1. package/README.md +181 -282
  2. package/dist/cli.js +21 -13
  3. package/dist/core/project-analyzer.d.ts +3 -12
  4. package/dist/core/project-analyzer.js +3 -12
  5. package/dist/index.d.ts +122 -6
  6. package/dist/index.js +49 -5
  7. package/dist/mcp-watcher.d.ts +32 -7
  8. package/dist/mcp-watcher.js +16 -15
  9. package/dist/scan-host/scan-host.d.ts +119 -0
  10. package/dist/scan-host/scan-host.js +376 -0
  11. package/dist/scan-host/scan-protocol.d.ts +35 -0
  12. package/dist/scan-host/scan-protocol.js +6 -0
  13. package/dist/scan-host/scan-worker.d.ts +14 -0
  14. package/dist/scan-host/scan-worker.js +48 -0
  15. package/dist/server/limited-stdio-transport.d.ts +75 -0
  16. package/dist/server/limited-stdio-transport.js +115 -0
  17. package/dist/server/mcp-server.d.ts +20 -18
  18. package/dist/server/mcp-server.js +42 -79
  19. package/dist/server/package-version.d.ts +16 -0
  20. package/dist/server/package-version.js +37 -0
  21. package/dist/server/sdk-server.d.ts +71 -0
  22. package/dist/server/sdk-server.js +113 -0
  23. package/dist/server/tool-registry.d.ts +6 -9
  24. package/dist/server/tool-registry.js +6 -12
  25. package/dist/streaming/progress-store.d.ts +22 -5
  26. package/dist/streaming/progress-store.js +9 -5
  27. package/dist/tools/analyze-build-impact.d.ts +276 -35
  28. package/dist/tools/analyze-build-impact.js +175 -28
  29. package/dist/tools/analyze-core-to-shared.d.ts +176 -16
  30. package/dist/tools/analyze-core-to-shared.js +124 -19
  31. package/dist/tools/analyze-parser-performance.d.ts +209 -15
  32. package/dist/tools/analyze-parser-performance.js +119 -56
  33. package/dist/tools/analyze-project.d.ts +349 -17
  34. package/dist/tools/analyze-project.js +282 -97
  35. package/dist/tools/check-incremental-compatibility.d.ts +74 -12
  36. package/dist/tools/check-incremental-compatibility.js +69 -10
  37. package/dist/tools/collect-feedback.d.ts +225 -21
  38. package/dist/tools/collect-feedback.js +199 -118
  39. package/dist/tools/compare-health.d.ts +413 -0
  40. package/dist/tools/compare-health.js +479 -0
  41. package/dist/tools/extract-libraries.d.ts +200 -24
  42. package/dist/tools/extract-libraries.js +131 -27
  43. package/dist/tools/find-angular-symbol.d.ts +92 -24
  44. package/dist/tools/find-angular-symbol.js +70 -20
  45. package/dist/tools/find-component-hosts.d.ts +603 -27
  46. package/dist/tools/find-component-hosts.js +223 -19
  47. package/dist/tools/find-usages.d.ts +102 -22
  48. package/dist/tools/find-usages.js +81 -21
  49. package/dist/tools/get-bootstrap-execution.d.ts +183 -25
  50. package/dist/tools/get-bootstrap-execution.js +109 -25
  51. package/dist/tools/get-call-graph.d.ts +127 -12
  52. package/dist/tools/get-call-graph.js +84 -19
  53. package/dist/tools/get-operation-progress-tool.d.ts +126 -8
  54. package/dist/tools/get-operation-progress-tool.js +124 -12
  55. package/dist/tools/get-operation-progress.d.ts +27 -1
  56. package/dist/tools/get-operation-progress.js +5 -5
  57. package/dist/tools/helpers/analysis-output.d.ts +182 -0
  58. package/dist/tools/helpers/analysis-output.js +165 -0
  59. package/dist/tools/helpers/batch-kernel.d.ts +14 -0
  60. package/dist/tools/helpers/batch-kernel.js +12 -0
  61. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  62. package/dist/tools/helpers/build-schemas.js +23 -0
  63. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  64. package/dist/tools/helpers/citation-file-source.js +82 -0
  65. package/dist/tools/helpers/compact-output.d.ts +2 -1
  66. package/dist/tools/helpers/compact-output.js +2 -1
  67. package/dist/tools/helpers/finding-window.d.ts +43 -0
  68. package/dist/tools/helpers/finding-window.js +64 -0
  69. package/dist/tools/helpers/health-delta.d.ts +99 -0
  70. package/dist/tools/helpers/health-delta.js +236 -0
  71. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  72. package/dist/tools/helpers/investigation-schemas.js +48 -0
  73. package/dist/tools/helpers/library-imports.d.ts +57 -0
  74. package/dist/tools/helpers/library-imports.js +151 -0
  75. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  76. package/dist/tools/helpers/load-source-files.js +34 -0
  77. package/dist/tools/helpers/output-contract.d.ts +32 -0
  78. package/dist/tools/helpers/output-contract.js +32 -0
  79. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  80. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  81. package/dist/tools/helpers/process-output.d.ts +19 -0
  82. package/dist/tools/helpers/process-output.js +31 -0
  83. package/dist/tools/helpers/project-cache.d.ts +60 -37
  84. package/dist/tools/helpers/project-cache.js +54 -37
  85. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  86. package/dist/tools/helpers/project-decorators.js +22 -0
  87. package/dist/tools/helpers/rule-matcher.js +5 -0
  88. package/dist/tools/helpers/rule-runner.d.ts +25 -13
  89. package/dist/tools/helpers/rule-runner.js +45 -24
  90. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  91. package/dist/tools/helpers/scan-cache.js +34 -0
  92. package/dist/tools/helpers/scan-engine.d.ts +107 -0
  93. package/dist/tools/helpers/scan-engine.js +197 -0
  94. package/dist/tools/helpers/scan-plan.d.ts +5 -2
  95. package/dist/tools/helpers/scan-plan.js +18 -3
  96. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  97. package/dist/tools/helpers/scope-paths.js +32 -0
  98. package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
  99. package/dist/tools/helpers/suggestion-generator.js +0 -12
  100. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  101. package/dist/tools/helpers/tool-cache.js +15 -0
  102. package/dist/tools/helpers/tool-context.d.ts +63 -0
  103. package/dist/tools/helpers/tool-context.js +79 -0
  104. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  105. package/dist/tools/helpers/transform-safety.js +87 -0
  106. package/dist/tools/helpers/validation-output.d.ts +53 -0
  107. package/dist/tools/helpers/validation-output.js +48 -0
  108. package/dist/tools/inspect-form-group.d.ts +262 -24
  109. package/dist/tools/inspect-form-group.js +134 -13
  110. package/dist/tools/inspect-i18n.d.ts +410 -23
  111. package/dist/tools/inspect-i18n.js +213 -13
  112. package/dist/tools/inspect-template.d.ts +260 -22
  113. package/dist/tools/inspect-template.js +174 -13
  114. package/dist/tools/learn-patterns.d.ts +210 -13
  115. package/dist/tools/learn-patterns.js +113 -12
  116. package/dist/tools/list-imports.d.ts +152 -34
  117. package/dist/tools/list-imports.js +124 -18
  118. package/dist/tools/orchestrate-migration.d.ts +159 -14
  119. package/dist/tools/orchestrate-migration.js +147 -20
  120. package/dist/tools/parse-stack-trace.d.ts +78 -21
  121. package/dist/tools/parse-stack-trace.js +44 -7
  122. package/dist/tools/plan-migration.d.ts +395 -26
  123. package/dist/tools/plan-migration.js +173 -22
  124. package/dist/tools/resolve-type.d.ts +57 -9
  125. package/dist/tools/resolve-type.js +49 -12
  126. package/dist/tools/review-feedback.d.ts +214 -16
  127. package/dist/tools/review-feedback.js +142 -57
  128. package/dist/tools/rollback-changes.d.ts +88 -7
  129. package/dist/tools/rollback-changes.js +74 -19
  130. package/dist/tools/run-angular-cli.d.ts +57 -12
  131. package/dist/tools/run-angular-cli.js +76 -13
  132. package/dist/tools/run-build.d.ts +127 -13
  133. package/dist/tools/run-build.js +128 -16
  134. package/dist/tools/run-schematic.d.ts +82 -12
  135. package/dist/tools/run-schematic.js +115 -18
  136. package/dist/tools/scan-all.d.ts +88 -23
  137. package/dist/tools/scan-all.js +161 -220
  138. package/dist/tools/scan-angular.d.ts +60 -19
  139. package/dist/tools/scan-angular.js +100 -141
  140. package/dist/tools/scan-architecture.d.ts +92 -24
  141. package/dist/tools/scan-architecture.js +268 -211
  142. package/dist/tools/scan-solid.d.ts +59 -19
  143. package/dist/tools/scan-solid.js +98 -139
  144. package/dist/tools/search-codebase.d.ts +110 -23
  145. package/dist/tools/search-codebase.js +67 -11
  146. package/dist/tools/server-status.d.ts +392 -26
  147. package/dist/tools/server-status.js +260 -27
  148. package/dist/tools/suggest-improvements.d.ts +105 -10
  149. package/dist/tools/suggest-improvements.js +91 -51
  150. package/dist/tools/trace-output-flow.d.ts +713 -26
  151. package/dist/tools/trace-output-flow.js +396 -33
  152. package/dist/tools/transform-code-batch.d.ts +3 -0
  153. package/dist/tools/transform-code-batch.js +10 -5
  154. package/dist/tools/transform-code.d.ts +402 -18
  155. package/dist/tools/transform-code.js +708 -649
  156. package/dist/tools/validate-before-transform.d.ts +136 -7
  157. package/dist/tools/validate-before-transform.js +65 -9
  158. package/dist/tools/validate-project-compatibility.d.ts +82 -15
  159. package/dist/tools/validate-project-compatibility.js +84 -15
  160. package/dist/tools/validate-transformation.d.ts +243 -8
  161. package/dist/tools/validate-transformation.js +127 -23
  162. package/dist/tools/verify-citations.d.ts +202 -0
  163. package/dist/tools/verify-citations.js +221 -0
  164. package/dist/types.d.ts +78 -11
  165. package/dist/types.js +0 -5
  166. package/dist/utils/format-tool-response.d.ts +22 -59
  167. package/dist/utils/format-tool-response.js +25 -134
  168. package/package.json +31 -20
  169. package/dist/cli.d.ts.map +0 -1
  170. package/dist/cli.js.map +0 -1
  171. package/dist/core/project-analyzer.d.ts.map +0 -1
  172. package/dist/core/project-analyzer.js.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js.map +0 -1
  175. package/dist/mcp-watcher.d.ts.map +0 -1
  176. package/dist/mcp-watcher.js.map +0 -1
  177. package/dist/server/json-rpc-handler.d.ts +0 -98
  178. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  179. package/dist/server/json-rpc-handler.js +0 -301
  180. package/dist/server/json-rpc-handler.js.map +0 -1
  181. package/dist/server/mcp-server.d.ts.map +0 -1
  182. package/dist/server/mcp-server.js.map +0 -1
  183. package/dist/server/stdio-guard.d.ts.map +0 -1
  184. package/dist/server/stdio-guard.js.map +0 -1
  185. package/dist/server/tool-registry.d.ts.map +0 -1
  186. package/dist/server/tool-registry.js.map +0 -1
  187. package/dist/streaming/progress-store.d.ts.map +0 -1
  188. package/dist/streaming/progress-store.js.map +0 -1
  189. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  190. package/dist/tools/analyze-build-impact.js.map +0 -1
  191. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  192. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  193. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  194. package/dist/tools/analyze-parser-performance.js.map +0 -1
  195. package/dist/tools/analyze-project.d.ts.map +0 -1
  196. package/dist/tools/analyze-project.js.map +0 -1
  197. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  198. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  199. package/dist/tools/collect-feedback.d.ts.map +0 -1
  200. package/dist/tools/collect-feedback.js.map +0 -1
  201. package/dist/tools/extract-libraries.d.ts.map +0 -1
  202. package/dist/tools/extract-libraries.js.map +0 -1
  203. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  204. package/dist/tools/find-angular-symbol.js.map +0 -1
  205. package/dist/tools/find-component-hosts.d.ts.map +0 -1
  206. package/dist/tools/find-component-hosts.js.map +0 -1
  207. package/dist/tools/find-usages.d.ts.map +0 -1
  208. package/dist/tools/find-usages.js.map +0 -1
  209. package/dist/tools/get-bootstrap-execution.d.ts.map +0 -1
  210. package/dist/tools/get-bootstrap-execution.js.map +0 -1
  211. package/dist/tools/get-call-graph.d.ts.map +0 -1
  212. package/dist/tools/get-call-graph.js.map +0 -1
  213. package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
  214. package/dist/tools/get-operation-progress-tool.js.map +0 -1
  215. package/dist/tools/get-operation-progress.d.ts.map +0 -1
  216. package/dist/tools/get-operation-progress.js.map +0 -1
  217. package/dist/tools/helpers/compact-output.d.ts.map +0 -1
  218. package/dist/tools/helpers/compact-output.js.map +0 -1
  219. package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
  220. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  221. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  222. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  223. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  224. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  225. package/dist/tools/helpers/project-cache.d.ts.map +0 -1
  226. package/dist/tools/helpers/project-cache.js.map +0 -1
  227. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  228. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  229. package/dist/tools/helpers/rule-runner.d.ts.map +0 -1
  230. package/dist/tools/helpers/rule-runner.js.map +0 -1
  231. package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
  232. package/dist/tools/helpers/scan-plan.js.map +0 -1
  233. package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
  234. package/dist/tools/helpers/stack-frame-file-index.js.map +0 -1
  235. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  236. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  237. package/dist/tools/inspect-form-group.d.ts.map +0 -1
  238. package/dist/tools/inspect-form-group.js.map +0 -1
  239. package/dist/tools/inspect-i18n.d.ts.map +0 -1
  240. package/dist/tools/inspect-i18n.js.map +0 -1
  241. package/dist/tools/inspect-template.d.ts.map +0 -1
  242. package/dist/tools/inspect-template.js.map +0 -1
  243. package/dist/tools/learn-patterns.d.ts.map +0 -1
  244. package/dist/tools/learn-patterns.js.map +0 -1
  245. package/dist/tools/list-imports.d.ts.map +0 -1
  246. package/dist/tools/list-imports.js.map +0 -1
  247. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  248. package/dist/tools/orchestrate-migration.js.map +0 -1
  249. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  250. package/dist/tools/parse-stack-trace.js.map +0 -1
  251. package/dist/tools/plan-migration.d.ts.map +0 -1
  252. package/dist/tools/plan-migration.js.map +0 -1
  253. package/dist/tools/resolve-type.d.ts.map +0 -1
  254. package/dist/tools/resolve-type.js.map +0 -1
  255. package/dist/tools/review-feedback.d.ts.map +0 -1
  256. package/dist/tools/review-feedback.js.map +0 -1
  257. package/dist/tools/rollback-changes.d.ts.map +0 -1
  258. package/dist/tools/rollback-changes.js.map +0 -1
  259. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  260. package/dist/tools/run-angular-cli.js.map +0 -1
  261. package/dist/tools/run-build.d.ts.map +0 -1
  262. package/dist/tools/run-build.js.map +0 -1
  263. package/dist/tools/run-schematic.d.ts.map +0 -1
  264. package/dist/tools/run-schematic.js.map +0 -1
  265. package/dist/tools/scan-all.d.ts.map +0 -1
  266. package/dist/tools/scan-all.js.map +0 -1
  267. package/dist/tools/scan-angular.d.ts.map +0 -1
  268. package/dist/tools/scan-angular.js.map +0 -1
  269. package/dist/tools/scan-architecture.d.ts.map +0 -1
  270. package/dist/tools/scan-architecture.js.map +0 -1
  271. package/dist/tools/scan-solid.d.ts.map +0 -1
  272. package/dist/tools/scan-solid.js.map +0 -1
  273. package/dist/tools/search-codebase.d.ts.map +0 -1
  274. package/dist/tools/search-codebase.js.map +0 -1
  275. package/dist/tools/server-status.d.ts.map +0 -1
  276. package/dist/tools/server-status.js.map +0 -1
  277. package/dist/tools/shared/scan-types.d.ts +0 -200
  278. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  279. package/dist/tools/shared/scan-types.js +0 -7
  280. package/dist/tools/shared/scan-types.js.map +0 -1
  281. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  282. package/dist/tools/suggest-improvements.js.map +0 -1
  283. package/dist/tools/trace-output-flow.d.ts.map +0 -1
  284. package/dist/tools/trace-output-flow.js.map +0 -1
  285. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  286. package/dist/tools/transform-code-batch.js.map +0 -1
  287. package/dist/tools/transform-code.d.ts.map +0 -1
  288. package/dist/tools/transform-code.js.map +0 -1
  289. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  290. package/dist/tools/validate-before-transform.js.map +0 -1
  291. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  292. package/dist/tools/validate-project-compatibility.js.map +0 -1
  293. package/dist/tools/validate-transformation.d.ts.map +0 -1
  294. package/dist/tools/validate-transformation.js.map +0 -1
  295. package/dist/types.d.ts.map +0 -1
  296. package/dist/types.js.map +0 -1
  297. package/dist/utils/format-tool-response.d.ts.map +0 -1
  298. package/dist/utils/format-tool-response.js.map +0 -1
@@ -1,80 +1,106 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Extract Libraries Tool
3
- *
4
- * MCP tool for detecting Angular artifacts that qualify for extraction into
5
- * dedicated Angular libraries with secondary entry points.
6
- *
7
- * Two-phase usage:
8
- * 1. Detection: scan shared/common/core folders → returns LibraryExtractionOpportunity[]
9
- * 2. Extraction: pass an opportunity's artifacts to transform-code with
10
- * transformation: 'library-extraction' to execute the actual migration
11
- */
12
- import type { MCPTool } from '../types.js';
1
+ import type { MCPTool, ToolAnnotations } from '../types.js';
13
2
  /**
14
3
  * A single library extraction opportunity.
15
4
  */
16
- interface ExtractionOpportunity {
5
+ export interface ExtractionOpportunity {
6
+ /** Always `architecture:library-extraction-opportunity`. */
17
7
  ruleId: string;
8
+ /** Rule message. */
18
9
  message: string;
10
+ /** File the opportunity was reported on. */
19
11
  filePath: string;
12
+ /** Suggested library name (e.g. `ui`, `forms`, `utils`). */
20
13
  suggestedLibraryName: string;
14
+ /** Artifact category. */
21
15
  category: string;
16
+ /** File paths of the artifacts belonging to this library. */
22
17
  artifacts: string[];
18
+ /** Suggested secondary entry point names. */
23
19
  secondaryEntryPoints: string[];
20
+ /** Cohesion score of the artifact cluster (0-1). */
24
21
  cohesionScore: number;
22
+ /** Reusability score (0-100). */
25
23
  reusabilityScore: number;
24
+ /** Migration complexity estimate. */
26
25
  migrationComplexity: 'low' | 'medium' | 'high';
26
+ /** Estimated effort. */
27
27
  estimatedEffort: {
28
+ /** Effort amount in `unit`. */
28
29
  value: number;
30
+ /** Unit of `value`. */
29
31
  unit: 'minutes' | 'hours' | 'days';
30
32
  };
33
+ /** External dependencies of this library. */
31
34
  dependencies: string[];
35
+ /** Circular dependency blockers. */
32
36
  circularDependencies: string[];
33
37
  /** 'data-only': interfaces / types / enums / consts foundation. */
34
38
  candidateKind?: 'standard' | 'data-only';
39
+ /** Rule-specific details. */
35
40
  metadata?: Record<string, unknown>;
36
41
  }
37
42
  /**
38
43
  * Result returned by extract-libraries.
39
44
  */
40
- interface ExtractLibrariesResult {
45
+ export interface ExtractLibrariesResult {
41
46
  /** Detected extraction opportunities. */
42
47
  opportunities: ExtractionOpportunity[];
43
- /** Summary statistics. */
44
- summary: {
48
+ /** Counts over all opportunities, independent of the page. */
49
+ counts: {
50
+ /** Number of all opportunities. */
45
51
  totalOpportunities: number;
52
+ /** Number of source files in the project. */
46
53
  analyzedFiles: number;
54
+ /** Opportunities per category. */
47
55
  byCategory: Record<string, number>;
56
+ /** Opportunities per migration complexity. */
48
57
  byComplexity: Record<string, number>;
49
58
  /** Opportunities per candidate kind ('standard' / 'data-only'). */
50
59
  byKind: Record<string, number>;
60
+ /** Artifacts over all opportunities. */
51
61
  totalArtifacts: number;
52
62
  };
63
+ /** Human-readable summary for LLM consumption. */
64
+ summary: string;
53
65
  /** Suggested next step instructions for the LLM. */
54
66
  nextSteps: string[];
55
67
  /** Analysis metadata. */
56
68
  metadata: {
69
+ /** Duration of the analysis in milliseconds. */
57
70
  duration: number;
71
+ /** Root path of the analyzed project. */
58
72
  projectRoot: string;
73
+ /** Folders scanned for candidates. */
59
74
  targetFolders: string[];
75
+ /** Minimum reusability score that was applied (0-100). */
60
76
  minReusabilityScore: number;
77
+ /** Minimum cohesion score that was applied (0-1). */
61
78
  minCohesionScore: number;
62
79
  };
63
80
  }
64
81
  /**
65
- * Extract Libraries Tool
82
+ * MCP tool `extract-libraries`: detects cohesive groups of Angular artifacts
83
+ * (in shared, common, core and similar folders) that qualify for extraction
84
+ * into dedicated Angular libraries with secondary entry points.
66
85
  *
67
- * Scans Angular codebases for cohesive artifact groups in shared/common/core
68
- * folders that qualify for extraction into dedicated Angular libraries.
69
- *
70
- * After detecting opportunities, use the `transform-code` tool with
71
- * `transformation: 'library-extraction'` to execute the actual migration.
86
+ * @remarks
87
+ * Two-step usage:
88
+ * 1. Detection: this tool returns the extraction opportunities.
89
+ * 2. Extraction: pass an opportunity's artifacts to the `transform-code` tool
90
+ * with `transformation: 'library-extraction'` to run the migration.
72
91
  */
73
92
  export declare class ExtractLibrariesTool implements MCPTool {
74
93
  readonly name = "extract-libraries";
75
- readonly 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.";
94
+ readonly title = "Detect Library Candidates";
95
+ readonly annotations: ToolAnnotations;
96
+ readonly 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.";
97
+ /**
98
+ * JSON Schema of the tool arguments.
99
+ * @hidden
100
+ */
76
101
  readonly inputSchema: {
77
102
  type: string;
103
+ additionalProperties: boolean;
78
104
  properties: {
79
105
  rootPath: {
80
106
  type: string;
@@ -117,9 +143,159 @@ export declare class ExtractLibrariesTool implements MCPTool {
117
143
  };
118
144
  required: string[];
119
145
  };
146
+ /**
147
+ * JSON Schema of the tool result (`structuredContent`).
148
+ * @hidden
149
+ */
150
+ readonly outputSchema: {
151
+ type: string;
152
+ properties: {
153
+ opportunities: {
154
+ type: string;
155
+ items: {
156
+ type: string;
157
+ properties: {
158
+ ruleId: {
159
+ type: string;
160
+ };
161
+ message: {
162
+ type: string;
163
+ };
164
+ filePath: {
165
+ type: string;
166
+ };
167
+ suggestedLibraryName: {
168
+ type: string;
169
+ };
170
+ category: {
171
+ type: string;
172
+ };
173
+ artifacts: {
174
+ readonly type: "array";
175
+ readonly items: {
176
+ readonly type: "string";
177
+ };
178
+ };
179
+ secondaryEntryPoints: {
180
+ readonly type: "array";
181
+ readonly items: {
182
+ readonly type: "string";
183
+ };
184
+ };
185
+ cohesionScore: {
186
+ type: string;
187
+ };
188
+ reusabilityScore: {
189
+ type: string;
190
+ };
191
+ migrationComplexity: {
192
+ type: string;
193
+ };
194
+ estimatedEffort: {
195
+ type: string;
196
+ properties: {
197
+ value: {
198
+ type: string;
199
+ };
200
+ unit: {
201
+ type: string;
202
+ };
203
+ };
204
+ required: string[];
205
+ };
206
+ dependencies: {
207
+ readonly type: "array";
208
+ readonly items: {
209
+ readonly type: "string";
210
+ };
211
+ };
212
+ circularDependencies: {
213
+ readonly type: "array";
214
+ readonly items: {
215
+ readonly type: "string";
216
+ };
217
+ };
218
+ candidateKind: {
219
+ type: string;
220
+ };
221
+ metadata: {
222
+ type: string;
223
+ };
224
+ };
225
+ required: string[];
226
+ };
227
+ };
228
+ counts: {
229
+ type: string;
230
+ properties: {
231
+ totalOpportunities: {
232
+ type: string;
233
+ };
234
+ analyzedFiles: {
235
+ type: string;
236
+ };
237
+ byCategory: {
238
+ readonly type: "object";
239
+ readonly additionalProperties: {
240
+ readonly type: "integer";
241
+ };
242
+ };
243
+ byComplexity: {
244
+ readonly type: "object";
245
+ readonly additionalProperties: {
246
+ readonly type: "integer";
247
+ };
248
+ };
249
+ byKind: {
250
+ readonly type: "object";
251
+ readonly additionalProperties: {
252
+ readonly type: "integer";
253
+ };
254
+ };
255
+ totalArtifacts: {
256
+ type: string;
257
+ };
258
+ };
259
+ required: string[];
260
+ };
261
+ summary: {
262
+ type: string;
263
+ };
264
+ nextSteps: {
265
+ readonly type: "array";
266
+ readonly items: {
267
+ readonly type: "string";
268
+ };
269
+ };
270
+ metadata: {
271
+ type: string;
272
+ properties: {
273
+ duration: {
274
+ type: string;
275
+ };
276
+ projectRoot: {
277
+ type: string;
278
+ };
279
+ targetFolders: {
280
+ readonly type: "array";
281
+ readonly items: {
282
+ readonly type: "string";
283
+ };
284
+ };
285
+ minReusabilityScore: {
286
+ type: string;
287
+ };
288
+ minCohesionScore: {
289
+ type: string;
290
+ };
291
+ };
292
+ required: string[];
293
+ };
294
+ };
295
+ required: string[];
296
+ };
120
297
  execute(args: Record<string, unknown>): Promise<ExtractLibrariesResult>;
121
298
  private emptyResult;
122
299
  private buildNextSteps;
123
300
  }
124
- export {};
125
301
  //# sourceMappingURL=extract-libraries.d.ts.map
@@ -1,14 +1,3 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Extract Libraries Tool
3
- *
4
- * MCP tool for detecting Angular artifacts that qualify for extraction into
5
- * dedicated Angular libraries with secondary entry points.
6
- *
7
- * Two-phase usage:
8
- * 1. Detection: scan shared/common/core folders → returns LibraryExtractionOpportunity[]
9
- * 2. Extraction: pass an opportunity's artifacts to transform-code with
10
- * transformation: 'library-extraction' to execute the actual migration
11
- */
12
1
  import { findTsConfig } from './helpers/find-ts-config.js';
13
2
  import { Kernel, loadConfig } from '@angular-modernizer/core';
14
3
  import { LibraryExtractionAnalysisRule } from '@angular-modernizer/plugin-architecture';
@@ -16,6 +5,8 @@ import { ContextFactory } from '@angular-modernizer/plugin-system';
16
5
  import { createPublicApi } from '@angular-modernizer/api';
17
6
  import { glob } from 'glob';
18
7
  import { resolve, extname } from 'node:path';
8
+ import { countList, pageNote } from './helpers/analysis-output.js';
9
+ import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
19
10
  /**
20
11
  * Default folders scanned for candidates. `libs` / `projects` cover Nx and
21
12
  * Angular CLI library workspaces; `models` / `interfaces` cover data-only
@@ -43,20 +34,66 @@ const DEFAULT_MIN_REUSABILITY = 40;
43
34
  * cluster spread over more than one sub-folder. The scanner itself uses 0.3.
44
35
  */
45
36
  const DEFAULT_MIN_COHESION = 0.5;
37
+ /** Candidates spelled out in the summary; the rest is in `opportunities`. */
38
+ const SUMMARY_CANDIDATES = 5;
46
39
  /**
47
- * Extract Libraries Tool
48
- *
49
- * Scans Angular codebases for cohesive artifact groups in shared/common/core
50
- * folders that qualify for extraction into dedicated Angular libraries.
40
+ * Text summary: totals per complexity and kind, the first candidates of the
41
+ * page and the page itself.
42
+ */
43
+ function describeOpportunities(counts, page, offset) {
44
+ const complexity = countList(counts.byComplexity, SUMMARY_CANDIDATES);
45
+ const kinds = countList(counts.byKind, SUMMARY_CANDIDATES);
46
+ const lines = [
47
+ `${counts.totalOpportunities} library candidate(s) with ${counts.totalArtifacts} artifact(s) in ` +
48
+ `${counts.analyzedFiles} analyzed file(s)` +
49
+ (complexity === undefined ? '.' : ` (complexity ${complexity}; kind ${kinds ?? 'none'}).`),
50
+ ];
51
+ for (const o of page.slice(0, SUMMARY_CANDIDATES)) {
52
+ lines.push(`- ${o.suggestedLibraryName} (${o.category}): ${o.artifacts.length} artifact(s), cohesion ` +
53
+ `${o.cohesionScore}, reusability ${o.reusabilityScore}, complexity ${o.migrationComplexity}` +
54
+ (o.circularDependencies.length > 0
55
+ ? `, ${o.circularDependencies.length} circular dependency(ies)`
56
+ : ''));
57
+ }
58
+ const note = pageNote({
59
+ totalResults: counts.totalOpportunities,
60
+ returnedResults: page.length,
61
+ offset,
62
+ hasMore: offset + page.length < counts.totalOpportunities,
63
+ }, 'candidates');
64
+ if (note !== undefined) {
65
+ lines.push(note);
66
+ }
67
+ return lines.join('\n');
68
+ }
69
+ /**
70
+ * MCP tool `extract-libraries`: detects cohesive groups of Angular artifacts
71
+ * (in shared, common, core and similar folders) that qualify for extraction
72
+ * into dedicated Angular libraries with secondary entry points.
51
73
  *
52
- * After detecting opportunities, use the `transform-code` tool with
53
- * `transformation: 'library-extraction'` to execute the actual migration.
74
+ * @remarks
75
+ * Two-step usage:
76
+ * 1. Detection: this tool returns the extraction opportunities.
77
+ * 2. Extraction: pass an opportunity's artifacts to the `transform-code` tool
78
+ * with `transformation: 'library-extraction'` to run the migration.
54
79
  */
55
80
  export class ExtractLibrariesTool {
56
81
  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.';
82
+ title = 'Detect Library Candidates';
83
+ annotations = {
84
+ readOnlyHint: true,
85
+ destructiveHint: false,
86
+ idempotentHint: true,
87
+ openWorldHint: false,
88
+ };
89
+ 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.';
90
+ /**
91
+ * JSON Schema of the tool arguments.
92
+ * @hidden
93
+ */
58
94
  inputSchema = {
59
95
  type: 'object',
96
+ additionalProperties: false,
60
97
  properties: {
61
98
  rootPath: {
62
99
  type: 'string',
@@ -95,6 +132,69 @@ export class ExtractLibrariesTool {
95
132
  },
96
133
  required: ['rootPath'],
97
134
  };
135
+ /**
136
+ * JSON Schema of the tool result (`structuredContent`).
137
+ * @hidden
138
+ */
139
+ outputSchema = {
140
+ type: 'object',
141
+ properties: {
142
+ opportunities: {
143
+ type: 'array',
144
+ items: {
145
+ type: 'object',
146
+ properties: {
147
+ ruleId: { type: 'string' },
148
+ message: { type: 'string' },
149
+ filePath: { type: 'string' },
150
+ suggestedLibraryName: { type: 'string' },
151
+ category: { type: 'string' },
152
+ artifacts: STRING_ARRAY,
153
+ secondaryEntryPoints: STRING_ARRAY,
154
+ cohesionScore: { type: 'number' },
155
+ reusabilityScore: { type: 'number' },
156
+ migrationComplexity: { type: 'string' },
157
+ estimatedEffort: {
158
+ type: 'object',
159
+ properties: { value: { type: 'number' }, unit: { type: 'string' } },
160
+ required: ['value', 'unit'],
161
+ },
162
+ dependencies: STRING_ARRAY,
163
+ circularDependencies: STRING_ARRAY,
164
+ candidateKind: { type: 'string' },
165
+ metadata: { type: 'object' },
166
+ },
167
+ required: ['suggestedLibraryName', 'category', 'artifacts', 'migrationComplexity'],
168
+ },
169
+ },
170
+ counts: {
171
+ type: 'object',
172
+ properties: {
173
+ totalOpportunities: { type: 'integer' },
174
+ analyzedFiles: { type: 'integer' },
175
+ byCategory: COUNT_OBJECT,
176
+ byComplexity: COUNT_OBJECT,
177
+ byKind: COUNT_OBJECT,
178
+ totalArtifacts: { type: 'integer' },
179
+ },
180
+ required: ['totalOpportunities', 'analyzedFiles', 'byCategory', 'byComplexity', 'byKind', 'totalArtifacts'],
181
+ },
182
+ summary: { type: 'string' },
183
+ nextSteps: STRING_ARRAY,
184
+ metadata: {
185
+ type: 'object',
186
+ properties: {
187
+ duration: { type: 'number' },
188
+ projectRoot: { type: 'string' },
189
+ targetFolders: STRING_ARRAY,
190
+ minReusabilityScore: { type: 'number' },
191
+ minCohesionScore: { type: 'number' },
192
+ },
193
+ required: ['duration', 'projectRoot', 'targetFolders', 'minReusabilityScore', 'minCohesionScore'],
194
+ },
195
+ },
196
+ required: ['opportunities', 'counts', 'summary', 'nextSteps', 'metadata'],
197
+ };
98
198
  async execute(args) {
99
199
  const params = args;
100
200
  if (!params.rootPath || typeof params.rootPath !== 'string') {
@@ -182,16 +282,18 @@ export class ExtractLibrariesTool {
182
282
  totalArtifacts += opp.artifacts.length;
183
283
  }
184
284
  const nextSteps = this.buildNextSteps(allOpportunities);
285
+ const counts = {
286
+ totalOpportunities: allOpportunities.length,
287
+ analyzedFiles,
288
+ byCategory,
289
+ byComplexity,
290
+ byKind,
291
+ totalArtifacts,
292
+ };
185
293
  return {
186
294
  opportunities: paginated,
187
- summary: {
188
- totalOpportunities: allOpportunities.length,
189
- analyzedFiles,
190
- byCategory,
191
- byComplexity,
192
- byKind,
193
- totalArtifacts,
194
- },
295
+ counts,
296
+ summary: describeOpportunities(counts, paginated, resultOffset),
195
297
  nextSteps,
196
298
  metadata: {
197
299
  duration: Date.now() - startTime,
@@ -208,7 +310,7 @@ export class ExtractLibrariesTool {
208
310
  emptyResult(projectRoot, targetFolders, minReusabilityScore, minCohesionScore, analyzedFiles, startTime) {
209
311
  return {
210
312
  opportunities: [],
211
- summary: {
313
+ counts: {
212
314
  totalOpportunities: 0,
213
315
  analyzedFiles,
214
316
  byCategory: {},
@@ -216,6 +318,8 @@ export class ExtractLibrariesTool {
216
318
  byKind: {},
217
319
  totalArtifacts: 0,
218
320
  },
321
+ summary: `No library candidates in ${analyzedFiles} analyzed file(s); lower minReusabilityScore ` +
322
+ 'or minCohesionScore to broaden the search.',
219
323
  nextSteps: [
220
324
  'No library extraction opportunities detected. Lower minReusabilityScore or minCohesionScore to broaden the search.',
221
325
  ],
@@ -1,28 +1,8 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Find Angular Symbol Tool
3
- *
4
- * MCP tool for locating Angular symbols (components, directives, pipes,
5
- * services, guards, interceptors, resolvers, modules, tokens) in a project.
6
- * Accepts selectors, pipe names, class names, or partial selector substrings.
7
- *
8
- * @remarks
9
- * Supports both standard Angular decorators (@Component, @Directive, @Pipe,
10
- * @Injectable, @NgModule) and ngUWI-specific external decorators
11
- * (@ExportComponent, @ExportFunction).
12
- *
13
- * @example
14
- * ```typescript
15
- * // Via MCP:
16
- * // tool: find-angular-symbol
17
- * // args: { query: 'app-user', projectRoot: '/project' }
18
- * // args: { query: 'UserService', type: 'service', projectRoot: '/project' }
19
- * ```
20
- */
21
- import { type MCPTool } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
22
2
  import { type AngularSymbolResult, type AngularSymbolType } from '@angular-modernizer/api';
23
3
  import { ProjectCache } from './helpers/project-cache.js';
24
4
  /** Output of the find-angular-symbol tool. */
25
- interface FindAngularSymbolOutput {
5
+ export interface FindAngularSymbolOutput {
26
6
  /** Matching symbols, cut to `maxResults`; omitted with `summaryOnly`. */
27
7
  results?: AngularSymbolResult[];
28
8
  /** Total number of matches (before `maxResults`). */
@@ -33,17 +13,41 @@ interface FindAngularSymbolOutput {
33
13
  countsByType: Partial<Record<AngularSymbolType, number>>;
34
14
  /** Human-readable summary for LLM consumption. */
35
15
  summary: string;
16
+ /** Conditions that can make the result incomplete (unresolved library imports). */
17
+ warnings?: string[];
36
18
  }
37
19
  /**
38
- * MCP tool that finds Angular symbols by selector, pipe name, or class name.
20
+ * MCP tool for locating Angular symbols (components, directives, pipes,
21
+ * services, guards, interceptors, resolvers, modules, tokens) in a project.
22
+ * Accepts selectors, pipe names, class names, or partial selector substrings.
23
+ *
24
+ * @remarks
25
+ * Supports both standard Angular decorators (@Component, @Directive, @Pipe,
26
+ * @Injectable, @NgModule) and the project's own component decorators
27
+ * (`parser.componentDecorators` in `.angular-modernizer.json`).
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Via MCP:
32
+ * // tool: find-angular-symbol
33
+ * // args: { query: 'app-user', projectRoot: '/project' }
34
+ * // args: { query: 'UserService', type: 'service', projectRoot: '/project' }
35
+ * ```
39
36
  */
40
37
  export declare class FindAngularSymbolTool implements MCPTool {
41
38
  private readonly projects;
42
39
  readonly name = "find-angular-symbol";
40
+ readonly title = "Find Angular Symbol";
41
+ readonly annotations: ToolAnnotations;
43
42
  constructor(projects?: ProjectCache);
44
43
  readonly description: string;
44
+ /**
45
+ * JSON Schema of the tool arguments.
46
+ * @hidden
47
+ */
45
48
  readonly inputSchema: {
46
49
  type: string;
50
+ additionalProperties: boolean;
47
51
  properties: {
48
52
  summaryOnly: {
49
53
  readonly type: "boolean";
@@ -70,9 +74,73 @@ export declare class FindAngularSymbolTool implements MCPTool {
70
74
  };
71
75
  required: string[];
72
76
  };
77
+ /**
78
+ * JSON Schema of the tool result (`structuredContent`).
79
+ * @hidden
80
+ */
81
+ readonly outputSchema: {
82
+ type: string;
83
+ properties: {
84
+ warnings: {
85
+ readonly type: "array";
86
+ readonly items: {
87
+ readonly type: "string";
88
+ };
89
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
90
+ };
91
+ results: {
92
+ type: string;
93
+ items: {
94
+ type: string;
95
+ properties: {
96
+ file: {
97
+ type: string;
98
+ };
99
+ className: {
100
+ type: string;
101
+ };
102
+ angularType: {
103
+ type: string;
104
+ };
105
+ selector: {
106
+ type: string;
107
+ };
108
+ pipeName: {
109
+ type: string;
110
+ };
111
+ metadata: {
112
+ type: string;
113
+ additionalProperties: {
114
+ type: string;
115
+ };
116
+ };
117
+ source: {
118
+ type: string;
119
+ };
120
+ };
121
+ required: string[];
122
+ };
123
+ };
124
+ totalCount: {
125
+ type: string;
126
+ };
127
+ truncated: {
128
+ type: string;
129
+ };
130
+ countsByType: {
131
+ type: string;
132
+ additionalProperties: {
133
+ type: string;
134
+ };
135
+ };
136
+ summary: {
137
+ type: string;
138
+ };
139
+ };
140
+ required: string[];
141
+ };
73
142
  execute(args: Record<string, unknown>): Promise<FindAngularSymbolOutput>;
74
143
  private buildCompactSummary;
75
144
  private buildSummary;
76
145
  }
77
- export {};
78
146
  //# sourceMappingURL=find-angular-symbol.d.ts.map