@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,31 +1,93 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Analyze Project Tool
3
- *
4
- * MCP tool for analyzing Angular projects to detect framework,
5
- * architecture, layers, and technologies.
6
- */
7
1
  import { findTsConfig } from './helpers/find-ts-config.js';
8
2
  import { toParallelOptions } from '../types.js';
9
- import { Kernel, loadConfig } from '@angular-modernizer/core';
3
+ import { Kernel } from '@angular-modernizer/core';
10
4
  import { AnalyzerPlugin } from '@angular-modernizer/plugin-analyzer';
11
- import { ContextFactory } from '@angular-modernizer/plugin-system';
12
- import { createPublicApi } from '@angular-modernizer/api';
13
5
  import { getWorkerScriptPath } from '@angular-modernizer/worker';
14
6
  import { getMCPWatcher } from '../mcp-watcher.js';
15
7
  import { glob } from 'glob';
16
8
  import { resolve, extname } from 'node:path';
17
9
  import { readFileSync, existsSync } from 'node:fs';
10
+ import { PAGINATION_SCHEMA, SCAN_EXECUTION_SCHEMA, nameList, pageNote, } from './helpers/analysis-output.js';
11
+ import { cancelledExecution, fileProgressMessage, forwardKernelProgress, } from './helpers/tool-context.js';
12
+ import { runScan } from '../scan-host/scan-host.js';
13
+ import { STRING_ARRAY } from './helpers/investigation-schemas.js';
14
+ /** Application or library entry of `framework.projects`. */
15
+ const NAMED_PROJECT_SCHEMA = {
16
+ type: 'object',
17
+ properties: {
18
+ name: { type: 'string' },
19
+ root: { type: 'string' },
20
+ sourceRoot: { type: 'string' },
21
+ },
22
+ required: ['name', 'root'],
23
+ };
24
+ /** Layers, projects and stack entries named in the summary. */
25
+ const SUMMARY_NAMES = 10;
26
+ /**
27
+ * Text summary of an analysis: framework, architecture, projects, stack,
28
+ * counts and the returned page of rule findings.
29
+ */
30
+ function describeAnalysis(analysis, totalResults) {
31
+ const { framework, architecture, technologyStack, counts } = analysis;
32
+ const lines = [
33
+ `Framework: ${framework.detected ? framework.type : 'not detected'} ` +
34
+ `(confidence ${framework.confidence}). Architecture: ${architecture.pattern} ` +
35
+ `(confidence ${architecture.confidence}).`,
36
+ ];
37
+ const layers = nameList(architecture.layers.map((l) => `${l.name} (${l.path})`), SUMMARY_NAMES);
38
+ if (layers !== undefined) {
39
+ lines.push(`Layers: ${layers}.`);
40
+ }
41
+ const projects = framework.projects;
42
+ if (projects !== undefined) {
43
+ const apps = nameList(projects.applications.map((a) => a.name), SUMMARY_NAMES);
44
+ const libs = nameList(projects.libraries.map((l) => l.name), SUMMARY_NAMES);
45
+ lines.push(`Applications: ${apps ?? 'none'}. Libraries: ${libs ?? 'none'}.` +
46
+ (framework.offlineApp?.detected === true ? ' Offline app detected.' : ''));
47
+ }
48
+ const stack = nameList([...technologyStack.languages, ...technologyStack.frameworks, ...technologyStack.buildTools], SUMMARY_NAMES);
49
+ lines.push(`Stack: ${stack ?? 'unknown'}; package manager ${technologyStack.packageManager}.`, `${counts.analyzedFiles} of ${counts.totalFiles} file(s) analyzed with ${counts.rulesExecuted} rule(s) ` +
50
+ `in ${counts.duration} ms, ${totalResults} finding(s)` +
51
+ (analysis.pagination === undefined && totalResults > 0
52
+ ? '; includeDetails returns them.'
53
+ : '.'));
54
+ const page = pageNote(analysis.pagination, 'findings');
55
+ if (page !== undefined) {
56
+ lines.push(page);
57
+ }
58
+ if (analysis.execution !== undefined) {
59
+ lines.push(analysis.execution.note);
60
+ }
61
+ return lines.join('\n');
62
+ }
18
63
  /**
19
- * Analyze Project Tool
64
+ * MCP tool `analyze-project`: detects the framework (Angular CLI, Nx),
65
+ * architecture pattern, layers, workspace projects and technology stack of
66
+ * an Angular project.
20
67
  *
21
- * Provides comprehensive project analysis capabilities through MCP.
22
- * Uses the Analyzer plugin to detect framework, architecture, and technologies.
68
+ * @remarks
69
+ * Uses the Analyzer plugin. Rule findings are returned only with
70
+ * `includeDetails`, paged by `maxResults` and `resultOffset`.
23
71
  */
24
72
  export class AnalyzeProjectTool {
25
73
  name = 'analyze-project';
26
- description = 'Analyze Angular projects to detect framework, architecture, layers, and technologies';
74
+ title = 'Analyze Project';
75
+ annotations = {
76
+ readOnlyHint: true,
77
+ destructiveHint: false,
78
+ idempotentHint: true,
79
+ openWorldHint: false,
80
+ };
81
+ description = 'Analyze Angular projects to detect framework, architecture, layers, and technologies. ' +
82
+ 'counts holds the file and rule numbers, summary a short text; includeDetails returns the rule findings ' +
83
+ '(maxResults and resultOffset page them).';
84
+ /**
85
+ * JSON Schema of the tool arguments.
86
+ * @hidden
87
+ */
27
88
  inputSchema = {
28
89
  type: 'object',
90
+ additionalProperties: false,
29
91
  properties: {
30
92
  rootPath: {
31
93
  type: 'string',
@@ -53,16 +115,16 @@ export class AnalyzeProjectTool {
53
115
  },
54
116
  orchestration: {
55
117
  type: 'object',
56
- description: 'Advanced orchestration options for analysis',
118
+ description: 'Deprecated, kept in 1.x: parallel and incremental run the old WorkerPool path on the main thread. On a large app it was no faster than the default path, blocked the server for seconds and took about four times the memory. Leave unset; the default path runs in the scan worker and answers cancellation at once.',
57
119
  properties: {
58
120
  parallel: {
59
121
  type: 'boolean',
60
- description: 'Enable parallel execution for faster analysis',
122
+ description: 'Deprecated: runs the old WorkerPool path over the whole program instead of 50 files. Leave unset.',
61
123
  default: false,
62
124
  },
63
125
  incremental: {
64
126
  type: 'boolean',
65
- description: 'Only analyze changed files (requires git)',
127
+ description: 'Deprecated: analyzes files changed against baseBranch (requires git, else every file) on the main thread. Leave unset.',
66
128
  default: false,
67
129
  },
68
130
  baseBranch: {
@@ -122,7 +184,119 @@ export class AnalyzeProjectTool {
122
184
  },
123
185
  required: [],
124
186
  };
125
- async execute(args) {
187
+ /**
188
+ * JSON Schema of the tool result (`structuredContent`).
189
+ * @hidden
190
+ */
191
+ outputSchema = {
192
+ type: 'object',
193
+ properties: {
194
+ framework: {
195
+ type: 'object',
196
+ properties: {
197
+ detected: { type: 'boolean' },
198
+ type: { type: 'string' },
199
+ confidence: { type: 'number' },
200
+ indicators: STRING_ARRAY,
201
+ projects: {
202
+ type: 'object',
203
+ properties: {
204
+ applications: { type: 'array', items: NAMED_PROJECT_SCHEMA },
205
+ libraries: { type: 'array', items: NAMED_PROJECT_SCHEMA },
206
+ },
207
+ required: ['applications', 'libraries'],
208
+ },
209
+ offlineApp: {
210
+ type: 'object',
211
+ properties: {
212
+ detected: { type: 'boolean' },
213
+ indicators: STRING_ARRAY,
214
+ },
215
+ required: ['detected', 'indicators'],
216
+ },
217
+ },
218
+ required: ['detected', 'type', 'confidence', 'indicators'],
219
+ },
220
+ architecture: {
221
+ type: 'object',
222
+ properties: {
223
+ pattern: { type: 'string' },
224
+ confidence: { type: 'number' },
225
+ layers: {
226
+ type: 'array',
227
+ items: {
228
+ type: 'object',
229
+ properties: {
230
+ name: { type: 'string' },
231
+ path: { type: 'string' },
232
+ purpose: { type: 'string' },
233
+ },
234
+ required: ['name', 'path', 'purpose'],
235
+ },
236
+ },
237
+ },
238
+ required: ['pattern', 'confidence', 'layers'],
239
+ },
240
+ technologyStack: {
241
+ type: 'object',
242
+ properties: {
243
+ languages: STRING_ARRAY,
244
+ frameworks: STRING_ARRAY,
245
+ buildTools: STRING_ARRAY,
246
+ packageManager: { type: 'string' },
247
+ },
248
+ required: ['languages', 'frameworks', 'buildTools', 'packageManager'],
249
+ },
250
+ results: {
251
+ type: 'array',
252
+ items: {
253
+ type: 'object',
254
+ properties: {
255
+ ruleId: { type: 'string' },
256
+ message: { type: 'string' },
257
+ filePath: { type: 'string' },
258
+ metadata: { type: 'object' },
259
+ },
260
+ required: ['ruleId', 'message'],
261
+ },
262
+ },
263
+ counts: {
264
+ type: 'object',
265
+ properties: {
266
+ totalFiles: { type: 'integer' },
267
+ analyzedFiles: { type: 'integer' },
268
+ rulesExecuted: { type: 'integer' },
269
+ duration: { type: 'number' },
270
+ },
271
+ required: ['totalFiles', 'analyzedFiles', 'rulesExecuted', 'duration'],
272
+ },
273
+ metadata: {
274
+ type: 'object',
275
+ properties: {
276
+ projectRoot: { type: 'string' },
277
+ tsconfigPath: { type: 'string' },
278
+ packageJsonPath: { type: 'string' },
279
+ angularJsonPath: { type: 'string' },
280
+ },
281
+ required: ['projectRoot', 'tsconfigPath'],
282
+ },
283
+ pagination: PAGINATION_SCHEMA,
284
+ orchestration: { type: 'object' },
285
+ execution: SCAN_EXECUTION_SCHEMA,
286
+ progress: { type: 'object' },
287
+ summary: { type: 'string' },
288
+ },
289
+ required: [
290
+ 'framework',
291
+ 'architecture',
292
+ 'technologyStack',
293
+ 'results',
294
+ 'counts',
295
+ 'metadata',
296
+ 'summary',
297
+ ],
298
+ };
299
+ async execute(args, ctx = {}) {
126
300
  const params = args;
127
301
  // Register operation with watcher for debugging
128
302
  const watcher = getMCPWatcher();
@@ -155,28 +329,6 @@ export class AnalyzeProjectTool {
155
329
  if (!tsConfigPath) {
156
330
  throw new Error('Could not find tsconfig.json in the project root');
157
331
  }
158
- if (opId) {
159
- watcher?.updateOperation(opId, 'initializing-kernel', 'Creating Kernel with AnalyzerPlugin');
160
- }
161
- // Initialize kernel with full Phase 6d/7b orchestration support + caching
162
- const kernel = new Kernel({
163
- tsConfigPath,
164
- plugins: [new AnalyzerPlugin()],
165
- cacheConfig: {
166
- enabled: true,
167
- cacheDir: resolve(mergedParams.rootPath, '.angular-modernizer-cache'),
168
- maxSize: 100 * 1024 * 1024, // 100MB
169
- maxAge: 24 * 60 * 60 * 1000, // 24 hours
170
- compression: true,
171
- },
172
- });
173
- await kernel.initialize();
174
- // Load rules config from .angular-modernizer.json for per-rule overrides (BUG-3)
175
- const fullAnalyzeConfig = loadConfig(mergedParams.rootPath ?? process.cwd());
176
- const analyzeRulesConfig = (fullAnalyzeConfig.rules ?? {});
177
- if (opId) {
178
- watcher?.updateOperation(opId, 'kernel-ready', 'Kernel initialized successfully');
179
- }
180
332
  // Analyze project structure
181
333
  if (opId) {
182
334
  watcher?.updateOperation(opId, 'analyzing-structure', 'Scanning project structure');
@@ -186,26 +338,55 @@ export class AnalyzeProjectTool {
186
338
  if (opId) {
187
339
  watcher?.updateOperation(opId, 'structure-complete', `Found ${projectStructure.totalFiles} files`);
188
340
  }
189
- // Setup progress tracking if requested
190
- let lastProgress;
191
- if (orchestration.enableProgress) {
192
- const progressReporter = kernel.getProgressReporter();
193
- if (progressReporter) {
194
- progressReporter.on('progress', (progress) => {
195
- lastProgress = {
196
- current: progress.current,
197
- total: progress.total,
198
- percentage: progress.percentage,
199
- eta: progress.eta,
200
- phase: progress.type,
201
- };
202
- });
203
- }
204
- }
205
341
  // Run analysis using full Phase 6d/7b orchestration
206
342
  let results = [];
207
343
  let filesAnalyzed = 0;
344
+ let execution;
345
+ let lastProgress;
346
+ // The parallel and incremental paths run the kernel here (it starts its
347
+ // own analysis workers); the sequential path runs in a scan worker.
348
+ let parallelKernel;
349
+ let rulesExecuted = 0;
208
350
  if (orchestration.parallel || orchestration.incremental) {
351
+ if (opId) {
352
+ watcher?.updateOperation(opId, 'initializing-kernel', 'Creating Kernel with AnalyzerPlugin');
353
+ }
354
+ // Initialize kernel with full Phase 6d/7b orchestration support + caching
355
+ const kernel = new Kernel({
356
+ tsConfigPath,
357
+ plugins: [new AnalyzerPlugin()],
358
+ cacheConfig: {
359
+ enabled: true,
360
+ cacheDir: resolve(mergedParams.rootPath, '.angular-modernizer-cache'),
361
+ maxSize: 100 * 1024 * 1024, // 100MB
362
+ maxAge: 24 * 60 * 60 * 1000, // 24 hours
363
+ compression: true,
364
+ },
365
+ });
366
+ await kernel.initialize();
367
+ if (opId) {
368
+ watcher?.updateOperation(opId, 'kernel-ready', 'Kernel initialized successfully');
369
+ }
370
+ // Setup progress tracking if requested
371
+ if (ctx.progress !== undefined) {
372
+ forwardKernelProgress(kernel.getProgressReporter(), ctx.progress);
373
+ }
374
+ if (orchestration.enableProgress) {
375
+ const progressReporter = kernel.getProgressReporter();
376
+ if (progressReporter) {
377
+ progressReporter.on('progress', (progress) => {
378
+ lastProgress = {
379
+ current: progress.current,
380
+ total: progress.total,
381
+ percentage: progress.percentage,
382
+ eta: progress.eta,
383
+ phase: progress.type,
384
+ };
385
+ });
386
+ }
387
+ }
388
+ parallelKernel = kernel;
389
+ rulesExecuted = kernel.getPlugin('analyzer').getAnalysisRules().length;
209
390
  if (opId) {
210
391
  const mode = orchestration.incremental ? 'incremental' : 'parallel';
211
392
  watcher?.updateOperation(opId, `starting-${mode}`, `Running ${mode} analysis`);
@@ -260,48 +441,46 @@ export class AnalyzeProjectTool {
260
441
  if (opId) {
261
442
  watcher?.updateOperation(opId, 'starting-sequential', 'Running sequential analysis');
262
443
  }
263
- const project = kernel.getProject();
264
- const api = createPublicApi(project); // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
265
- const plugin = kernel.getPlugin('analyzer');
266
- const rules = plugin.getAnalysisRules();
267
444
  const tsFiles = await this.findTypeScriptFiles(mergedParams.rootPath, mergedParams.maxDepth ?? 3);
268
445
  if (opId) {
269
446
  watcher?.updateOperation(opId, 'scanning-files', `Found ${tsFiles.length} files to analyze`);
270
447
  }
271
- for (let i = 0; i < tsFiles.slice(0, 50).length; i++) {
272
- const filePath = tsFiles[i];
273
- if (!filePath) {
274
- continue;
275
- }
276
- // Update progress every 10 files
277
- if (opId && i > 0 && i % 10 === 0) {
278
- watcher?.updateOperation(opId, 'analyzing-files', `${i}/${tsFiles.slice(0, 50).length} files processed`);
279
- }
280
- try {
281
- const sourceFile = project.addSourceFileAtPath(filePath);
282
- for (const rule of rules) {
283
- const ruleResults = await rule.analyze(ContextFactory.createAnalysisContext({
284
- sourceFile,
285
- project,
286
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
287
- api,
288
- config: analyzeRulesConfig,
289
- }));
290
- for (const result of ruleResults) {
291
- results.push({
292
- ruleId: result.ruleId,
293
- message: result.message,
294
- filePath: result.filePath,
295
- metadata: result.metadata,
296
- });
297
- }
448
+ // Kernel (the whole tsconfig program) and rules run in a scan worker,
449
+ // so the server keeps reading stdin while the program is built
450
+ const sequentialFiles = tsFiles.slice(0, 50);
451
+ let done = 0;
452
+ ctx.progress?.(0, sequentialFiles.length, fileProgressMessage(0, sequentialFiles.length, 0));
453
+ const engine = await runScan({
454
+ tool: this.name,
455
+ plugins: 'analyzer',
456
+ tsConfigPath,
457
+ rootPath: mergedParams.rootPath,
458
+ files: sequentialFiles,
459
+ mode: 'sequential',
460
+ }, {
461
+ file: (event) => {
462
+ for (const finding of event.findings) {
463
+ results.push({
464
+ ruleId: finding.ruleId,
465
+ message: finding.message,
466
+ filePath: finding.filePath,
467
+ metadata: finding.metadata,
468
+ });
298
469
  }
299
- }
300
- catch (error) {
301
- console.warn(`Error analyzing ${filePath}:`, error);
302
- }
470
+ done++;
471
+ ctx.progress?.(done, sequentialFiles.length, fileProgressMessage(done, sequentialFiles.length, results.length));
472
+ // Update progress every 10 files
473
+ if (opId && done % 10 === 0) {
474
+ watcher?.updateOperation(opId, 'analyzing-files', `${done}/${sequentialFiles.length} files processed`);
475
+ }
476
+ },
477
+ }, { signal: ctx.signal });
478
+ rulesExecuted = engine.ruleIds.length;
479
+ if (engine.cancelled) {
480
+ execution = cancelledExecution(done, sequentialFiles.length - done);
303
481
  }
304
- filesAnalyzed = tsFiles.slice(0, 50).length;
482
+ filesAnalyzed =
483
+ sequentialFiles.length - (execution?.skippedFiles ?? 0);
305
484
  if (opId) {
306
485
  watcher?.updateOperation(opId, 'sequential-complete', `Analyzed ${filesAnalyzed} files sequentially`);
307
486
  }
@@ -313,8 +492,8 @@ export class AnalyzeProjectTool {
313
492
  const duration = Date.now() - startTime;
314
493
  // Gather orchestration stats
315
494
  let orchestrationMetrics;
316
- if (orchestration.parallel || orchestration.incremental) {
317
- const stats = kernel.getOrchestrationStats();
495
+ if (parallelKernel !== undefined) {
496
+ const stats = parallelKernel.getOrchestrationStats();
318
497
  orchestrationMetrics = {
319
498
  parallel: orchestration.parallel ?? false,
320
499
  incremental: orchestration.incremental ?? false,
@@ -354,15 +533,15 @@ export class AnalyzeProjectTool {
354
533
  hasMore: resultOffset + maxResults < totalResults,
355
534
  };
356
535
  }
357
- const result = {
536
+ const analysis = {
358
537
  framework,
359
538
  architecture,
360
539
  technologyStack,
361
540
  results: params.includeDetails ? paginatedResults : [],
362
- summary: {
541
+ counts: {
363
542
  totalFiles: projectStructure.totalFiles,
364
543
  analyzedFiles: filesAnalyzed,
365
- rulesExecuted: kernel.getPlugin('analyzer').getAnalysisRules().length,
544
+ rulesExecuted,
366
545
  duration,
367
546
  },
368
547
  metadata: {
@@ -374,6 +553,11 @@ export class AnalyzeProjectTool {
374
553
  pagination: paginationMetadata,
375
554
  orchestration: orchestrationMetrics,
376
555
  progress: lastProgress,
556
+ ...(execution === undefined ? {} : { execution }),
557
+ };
558
+ const result = {
559
+ ...analysis,
560
+ summary: describeAnalysis(analysis, totalResults),
377
561
  };
378
562
  // Mark operation as completed successfully
379
563
  if (opId) {
@@ -625,7 +809,8 @@ export class AnalyzeProjectTool {
625
809
  });
626
810
  files.push(...found);
627
811
  }
628
- return [...new Set(files)].filter((file) => ['.ts', '.tsx'].includes(extname(file)));
812
+ // Sorted: glob returns files in no fixed order
813
+ return [...new Set(files)].sort().filter((file) => ['.ts', '.tsx'].includes(extname(file)));
629
814
  }
630
815
  /**
631
816
  * Determine framework from analysis results and structure.
@@ -1,20 +1,13 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Check Incremental Compatibility Tool
3
- *
4
- * MCP tool for checking project compatibility with incremental build validation.
5
- * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
6
- * and complex monorepo structures. Provides clear recommendations and speedup estimates.
7
- */
8
- import { type MCPTool } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
9
2
  import { type IncompatibilityCheck } from '@angular-modernizer/core';
10
3
  /**
11
4
  * Recommendation type for incremental build usage.
12
5
  */
13
- type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
6
+ export type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
14
7
  /**
15
8
  * Output result of compatibility check.
16
9
  */
17
- interface CompatibilityCheckOutput {
10
+ export interface CompatibilityCheckOutput {
18
11
  /**
19
12
  * Whether incremental build is compatible (no blockers).
20
13
  */
@@ -40,15 +33,28 @@ interface CompatibilityCheckOutput {
40
33
  * User-facing formatted message.
41
34
  */
42
35
  message: string;
36
+ /**
37
+ * Short text: verdict, recommendation, detected blockers and warnings, speedup.
38
+ */
39
+ summary: string;
43
40
  }
44
41
  /**
45
- * MCP tool for checking incremental build compatibility.
42
+ * MCP tool for checking project compatibility with incremental build validation.
43
+ * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
44
+ * and complex monorepo structures. Provides clear recommendations and speedup estimates.
46
45
  */
47
46
  export declare class CheckIncrementalCompatibilityTool implements MCPTool {
48
47
  name: string;
48
+ title: string;
49
+ annotations: ToolAnnotations;
49
50
  description: string;
51
+ /**
52
+ * JSON Schema of the tool arguments.
53
+ * @hidden
54
+ */
50
55
  inputSchema: {
51
56
  type: string;
57
+ additionalProperties: boolean;
52
58
  properties: {
53
59
  projectPath: {
54
60
  type: string;
@@ -72,6 +78,63 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
72
78
  };
73
79
  required: string[];
74
80
  };
81
+ /**
82
+ * JSON Schema of the tool result (`structuredContent`).
83
+ * @hidden
84
+ */
85
+ outputSchema: {
86
+ type: string;
87
+ properties: {
88
+ compatible: {
89
+ type: string;
90
+ };
91
+ angularVersion: {
92
+ type: string[];
93
+ };
94
+ issues: {
95
+ readonly type: "array";
96
+ readonly items: {
97
+ readonly type: "object";
98
+ readonly properties: {
99
+ readonly type: {
100
+ readonly type: "string";
101
+ };
102
+ readonly detected: {
103
+ readonly type: "boolean";
104
+ };
105
+ readonly severity: {
106
+ readonly type: "string";
107
+ readonly enum: readonly ["blocker", "warning"];
108
+ };
109
+ readonly message: {
110
+ readonly type: "string";
111
+ };
112
+ readonly recommendation: {
113
+ readonly type: "string";
114
+ };
115
+ readonly details: {
116
+ readonly type: "object";
117
+ };
118
+ };
119
+ readonly required: readonly ["type", "detected", "severity", "message", "recommendation"];
120
+ };
121
+ };
122
+ recommendation: {
123
+ type: string;
124
+ enum: string[];
125
+ };
126
+ estimatedSpeedup: {
127
+ type: string[];
128
+ };
129
+ message: {
130
+ type: string;
131
+ };
132
+ summary: {
133
+ type: string;
134
+ };
135
+ };
136
+ required: string[];
137
+ };
75
138
  execute(args: Record<string, unknown>): Promise<CompatibilityCheckOutput>;
76
139
  /**
77
140
  * Extracts Angular version from package.json
@@ -105,5 +168,4 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
105
168
  */
106
169
  private formatDetails;
107
170
  }
108
- export {};
109
171
  //# sourceMappingURL=check-incremental-compatibility.d.ts.map