@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,59 +1,91 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Scan SOLID Principles Tool
3
- *
4
- * MCP tool for scanning Angular codebases for SOLID principle violations.
5
- * Runs only the SolidPlugin (7 rules: DIP, SRP, LSP, OCP, ISP).
6
- */
7
- import type { MCPTool } from '../types.js';
8
- interface ScanSolidResult {
1
+ import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
2
+ import { type ScanCounts } from './helpers/analysis-output.js';
3
+ import { type CancelledExecution } from './helpers/tool-context.js';
4
+ /** Result of the scan-solid tool. */
5
+ export interface ScanSolidResult {
6
+ /** The requested page of violations (`maxResults`, `resultOffset`). */
9
7
  violations: {
8
+ /** Index-based id of the violation (`solid-<index>`). */
10
9
  id: string;
10
+ /** Rule that reported the violation. */
11
11
  ruleId: string;
12
+ /** Severity reported by the rule. */
12
13
  severity: 'error' | 'warning' | 'info';
14
+ /** Rule message. */
13
15
  message: string;
16
+ /** File path relative to `rootPath`. */
14
17
  filePath: string;
18
+ /** 1-based line of the finding, when the rule reports one. */
15
19
  line?: number;
20
+ /** Column of the finding, when the rule reports one. */
16
21
  column?: number;
22
+ /** Rule category; `SOLID` when the rule sets none. */
17
23
  category: string;
24
+ /** Fix suggested by the rule; only with `includeAutoFixes`. */
18
25
  suggestedFix?: string;
26
+ /** Rule-specific details. */
19
27
  metadata?: Record<string, unknown>;
20
28
  }[];
21
- summary: {
22
- totalViolations: number;
23
- analyzedFiles: number;
24
- bySeverity: Record<string, number>;
25
- byCategory: Record<string, number>;
26
- byRule: Record<string, number>;
27
- };
29
+ /** Counts over all violations, independent of the page. */
30
+ counts: ScanCounts;
31
+ /** Human-readable summary for LLM consumption. */
32
+ summary: string;
33
+ /** Set when the client cancelled the scan; counts cover the analyzed files. */
34
+ execution?: CancelledExecution;
35
+ /** Scan metadata. */
28
36
  metadata: {
37
+ /** Ids of the rules that ran. */
29
38
  rulesExecuted: string[];
39
+ /** Duration of the scan in milliseconds. */
30
40
  duration: number;
41
+ /** Root path of the scanned project. */
31
42
  projectRoot: string;
32
43
  };
44
+ /** Orchestration figures; set only when `orchestration.useWorkerThreads` is set. */
33
45
  orchestration?: {
46
+ /** Whether the scan ran in parallel. */
34
47
  parallel: boolean;
48
+ /** Whether only changed files were analyzed (always `false` here). */
35
49
  incremental: boolean;
50
+ /** Files selected for the scan. */
36
51
  filesAnalyzed: number;
52
+ /** Files skipped (always 0 here). */
37
53
  filesSkipped: number;
54
+ /** Cache hit rate (always 0 here). */
38
55
  cacheHitRate: number;
56
+ /** Duration of the scan in milliseconds. */
39
57
  duration: number;
58
+ /** Files per second. */
40
59
  throughput: number;
41
60
  };
61
+ /** What the page covers of all violations. */
42
62
  pagination?: {
63
+ /** Number of all violations. */
43
64
  totalResults: number;
65
+ /** Number of violations in this page. */
44
66
  returnedResults: number;
67
+ /** Offset of the page (`resultOffset`). */
45
68
  offset: number;
69
+ /** Whether violations follow after this page. */
46
70
  hasMore: boolean;
47
71
  };
48
72
  }
49
73
  /**
50
- * Scan for SOLID principle violations using the SolidPlugin.
74
+ * MCP tool `scan-solid`: scans for SOLID principle violations. Runs only the
75
+ * SolidPlugin (7 rules: DIP, SRP, LSP, OCP, ISP).
51
76
  */
52
77
  export declare class ScanSolidTool implements MCPTool {
53
78
  readonly name = "scan-solid";
54
- readonly description = "Scan for SOLID principle violations (DIP, SRP, LSP, OCP, ISP)";
79
+ readonly title = "Scan SOLID Principles";
80
+ readonly annotations: ToolAnnotations;
81
+ readonly description: string;
82
+ /**
83
+ * JSON Schema of the tool arguments.
84
+ * @hidden
85
+ */
55
86
  readonly inputSchema: {
56
87
  type: string;
88
+ additionalProperties: boolean;
57
89
  properties: {
58
90
  rootPath: {
59
91
  type: string;
@@ -120,7 +152,16 @@ export declare class ScanSolidTool implements MCPTool {
120
152
  };
121
153
  required: string[];
122
154
  };
123
- execute(args: Record<string, unknown>): Promise<ScanSolidResult>;
155
+ /**
156
+ * JSON Schema of the tool result (`structuredContent`).
157
+ * @hidden
158
+ */
159
+ readonly outputSchema: {
160
+ type: "object";
161
+ properties: Record<string, unknown>;
162
+ required: string[];
163
+ };
164
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ScanSolidResult>;
124
165
  /**
125
166
  * Load configuration from .angular-modernizer.json file.
126
167
  * Only loads from the provided root path to avoid cache directory issues.
@@ -128,5 +169,4 @@ export declare class ScanSolidTool implements MCPTool {
128
169
  private loadConfig;
129
170
  private calculateSummary;
130
171
  }
131
- export {};
132
172
  //# sourceMappingURL=scan-solid.d.ts.map
@@ -1,25 +1,33 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Scan SOLID Principles Tool
3
- *
4
- * MCP tool for scanning Angular codebases for SOLID principle violations.
5
- * Runs only the SolidPlugin (7 rules: DIP, SRP, LSP, OCP, ISP).
6
- */
7
1
  import { findTsConfig } from './helpers/find-ts-config.js';
8
- import { Kernel, createToolCacheConfig, loadConfig, } from '@angular-modernizer/core';
9
- import { SolidPlugin } from '@angular-modernizer/plugin-solid';
10
- import { ContextFactory } from '@angular-modernizer/plugin-system';
11
- import { createPublicApi } from '@angular-modernizer/api';
12
2
  import { glob } from 'glob';
13
3
  import { resolve, relative } from 'node:path';
14
4
  import { readFileSync, existsSync } from 'node:fs';
5
+ import { describeScan, SCAN_EXECUTION_SCHEMA, scanOutputSchema, } from './helpers/analysis-output.js';
6
+ import { cancelledExecution, fileProgressMessage, } from './helpers/tool-context.js';
7
+ import { runScan } from '../scan-host/scan-host.js';
8
+ import { openToolCache } from './helpers/tool-cache.js';
15
9
  /**
16
- * Scan for SOLID principle violations using the SolidPlugin.
10
+ * MCP tool `scan-solid`: scans for SOLID principle violations. Runs only the
11
+ * SolidPlugin (7 rules: DIP, SRP, LSP, OCP, ISP).
17
12
  */
18
13
  export class ScanSolidTool {
19
14
  name = 'scan-solid';
20
- description = 'Scan for SOLID principle violations (DIP, SRP, LSP, OCP, ISP)';
15
+ title = 'Scan SOLID Principles';
16
+ annotations = {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: true,
20
+ openWorldHint: false,
21
+ };
22
+ description = 'Scan for SOLID principle violations (DIP, SRP, LSP, OCP, ISP). maxResults (default 1000) and resultOffset ' +
23
+ 'page the violations; counts cover all of them, summary is a short text.';
24
+ /**
25
+ * JSON Schema of the tool arguments.
26
+ * @hidden
27
+ */
21
28
  inputSchema = {
22
29
  type: 'object',
30
+ additionalProperties: false,
23
31
  properties: {
24
32
  rootPath: {
25
33
  type: 'string',
@@ -89,7 +97,12 @@ export class ScanSolidTool {
89
97
  },
90
98
  required: ['rootPath'],
91
99
  };
92
- async execute(args) {
100
+ /**
101
+ * JSON Schema of the tool result (`structuredContent`).
102
+ * @hidden
103
+ */
104
+ outputSchema = scanOutputSchema({ execution: SCAN_EXECUTION_SCHEMA });
105
+ async execute(args, ctx = {}) {
93
106
  const params = args;
94
107
  const config = this.loadConfig(params.rootPath);
95
108
  const mergedParams = { ...config, ...params };
@@ -102,16 +115,6 @@ export class ScanSolidTool {
102
115
  if (!tsConfigPath) {
103
116
  throw new Error('Could not find tsconfig.json');
104
117
  }
105
- // Initialize kernel with SolidPlugin and caching
106
- const kernel = new Kernel({
107
- tsConfigPath,
108
- plugins: [new SolidPlugin()],
109
- fileSystem: undefined,
110
- projectOptions: {
111
- skipAddingFilesFromTsConfig: true, // We'll add filtered files manually
112
- },
113
- cacheConfig: createToolCacheConfig(mergedParams.rootPath, 'solid'),
114
- });
115
118
  // Find files to analyze
116
119
  const includePatterns = mergedParams.includePatterns ?? ['**/*.{ts,tsx}'];
117
120
  const excludePatterns = mergedParams.excludePatterns ?? [
@@ -133,19 +136,11 @@ export class ScanSolidTool {
133
136
  });
134
137
  allFiles.push(...files);
135
138
  }
136
- const uniqueFiles = Array.from(new Set(allFiles));
139
+ // Sorted: glob returns files in no fixed order, the result pages depend on it
140
+ const uniqueFiles = Array.from(new Set(allFiles)).sort();
137
141
  const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
138
142
  const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
139
- // Initialize kernel
140
- await kernel.initialize();
141
- // Load rules config from .angular-modernizer.json for per-rule overrides (BUG-3)
142
- const fullConfig = loadConfig(mergedParams.rootPath);
143
- const rulesConfig = fullConfig.rules;
144
- // Get analysis rules from the already-initialized plugin instances so that
145
- // ruleConfigs from .angular-modernizer.json are applied correctly.
146
- const allRules = kernel
147
- .getAllPlugins()
148
- .flatMap((p) => p.getAnalysisRules());
143
+ const cache = await openToolCache(mergedParams.rootPath, 'solid');
149
144
  // ============================================================================
150
145
  // CACHE READ SYSTEM
151
146
  // ============================================================================
@@ -165,27 +160,20 @@ export class ScanSolidTool {
165
160
  // Cache directory: .angular-modernizer-cache/solid/
166
161
  // Cache invalidation: Automatic via mtime/content hash checking
167
162
  // ============================================================================
168
- const cacheManagerForRead = kernel.getCacheManager();
169
163
  const cachedResults = []; // eslint-disable-line @typescript-eslint/no-explicit-any
170
- let filesToProcess = [];
171
- if (cacheManagerForRead) {
172
- for (const filePath of filesToAnalyze) {
173
- const cached = await cacheManagerForRead.getAnalysisResult(filePath);
174
- if (cached?.results && cached.results.length > 0) {
175
- cachedResults.push(...cached.results);
176
- }
177
- else {
178
- // File not cached or has changed
179
- filesToProcess.push(filePath);
180
- }
164
+ const filesToProcess = [];
165
+ for (const filePath of filesToAnalyze) {
166
+ const cached = await cache.getAnalysisResult(filePath);
167
+ if (cached?.results && cached.results.length > 0) {
168
+ // File is cached and hasn't changed
169
+ cachedResults.push(...cached.results);
170
+ }
171
+ else {
172
+ // File not cached or has changed
173
+ filesToProcess.push(filePath);
181
174
  }
182
- const stats = cacheManagerForRead.getStats();
183
- console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${stats.hitRate.toFixed(1)}%)`);
184
- }
185
- else {
186
- // No cache manager, analyze all files
187
- filesToProcess = filesToAnalyze;
188
175
  }
176
+ console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${cache.getStats().hitRate.toFixed(1)}%)`);
189
177
  // ============================================================================
190
178
  // BATCH PROCESSING SYSTEM
191
179
  // ============================================================================
@@ -220,66 +208,33 @@ export class ScanSolidTool {
220
208
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
221
209
  const results = [...cachedResults];
222
210
  let filesAnalyzed = cachedResults.length;
223
- // Process each batch
224
- for (let batchNum = 0; batchNum < totalBatches; batchNum++) {
225
- const batchStart = batchNum * batchSize;
226
- const batchEnd = Math.min(batchStart + batchSize, totalFiles);
227
- const batchFiles = filesToProcess.slice(batchStart, batchEnd);
228
- console.info(`\nBatch ${batchNum + 1}/${totalBatches}: Processing files ${batchStart + 1}-${batchEnd} (${batchFiles.length} files)`);
229
- // Clear project and add batch files
230
- const project = kernel.getProject();
231
- // Remove all source files from previous batch
232
- const existingFiles = project.getSourceFiles();
233
- for (const file of existingFiles) {
234
- project.removeSourceFile(file);
235
- }
236
- // Add current batch files
237
- for (const filePath of batchFiles) {
238
- try {
239
- project.addSourceFileAtPath(filePath);
240
- }
241
- catch (error) {
242
- console.warn(`Failed to add file ${filePath}:`, error);
243
- }
244
- }
245
- console.info(`Batch ${batchNum + 1}: Project now has ${project.getSourceFiles().length} source files`);
246
- // Create PublicApi for this batch
247
- const api = createPublicApi(project); // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
248
- // Analyze files in this batch
249
- let batchViolationCount = 0;
250
- for (const sourceFile of project.getSourceFiles()) {
251
- for (const rule of allRules) {
252
- try {
253
- const ruleResults = await rule.analyze(ContextFactory.createAnalysisContext({
254
- sourceFile,
255
- project,
256
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
257
- api,
258
- config: rulesConfig,
259
- }));
260
- for (const result of ruleResults) {
261
- results.push({
262
- ruleId: result.ruleId,
263
- severity: rule.severity,
264
- message: result.message,
265
- filePath: result.filePath,
266
- line: result.line,
267
- column: result.column,
268
- category: rule.category,
269
- suggestedFix: result.suggestedFix,
270
- metadata: result.metadata,
271
- });
272
- batchViolationCount++;
273
- }
274
- }
275
- catch (error) {
276
- console.warn(`Failed to analyze with rule ${rule.id}:`, error);
277
- }
278
- }
279
- }
280
- filesAnalyzed += batchFiles.length;
281
- console.info(`Batch ${batchNum + 1}: Found ${batchViolationCount} violations in ${batchFiles.length} files`);
211
+ // Kernel, batches and rules run in a scan worker (scan-host), so the
212
+ // server keeps reading stdin while the type checker is built.
213
+ const cachedFiles = filesToAnalyze.length - totalFiles;
214
+ let processedFiles = 0;
215
+ if (totalFiles > 0) {
216
+ ctx.progress?.(cachedFiles, filesToAnalyze.length, `loading project, ${totalFiles} files to analyze`);
282
217
  }
218
+ const engine = await runScan({
219
+ tool: this.name,
220
+ plugins: 'solid',
221
+ tsConfigPath,
222
+ rootPath: mergedParams.rootPath,
223
+ files: filesToProcess,
224
+ mode: 'batches',
225
+ batchSize,
226
+ analyzeProjectFiles: true,
227
+ }, {
228
+ file: (event) => {
229
+ results.push(...event.findings);
230
+ processedFiles++;
231
+ ctx.progress?.(cachedFiles + processedFiles, filesToAnalyze.length, fileProgressMessage(cachedFiles + processedFiles, filesToAnalyze.length, results.length));
232
+ },
233
+ batchDone: (files) => {
234
+ filesAnalyzed += files;
235
+ },
236
+ }, { signal: ctx.signal });
237
+ const cancelled = engine.cancelled;
283
238
  console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${filesAnalyzed} total files analyzed, ${results.length} total violations`);
284
239
  // ============================================================================
285
240
  // CACHE WRITE SYSTEM
@@ -309,26 +264,23 @@ export class ScanSolidTool {
309
264
  // - First run: Writes cache (adds ~1-2% overhead)
310
265
  // - Second run: Reads cache (1.5x-39x speedup depending on scan type)
311
266
  // ============================================================================
312
- const cacheManager = kernel.getCacheManager();
313
- if (cacheManager) {
314
- // Group results by file path
315
- const resultsByFile = new Map();
316
- for (const result of results) {
317
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
318
- const filePath = result.filePath;
319
- if (!resultsByFile.has(filePath)) {
320
- resultsByFile.set(filePath, []);
321
- }
322
- resultsByFile.get(filePath).push(result);
323
- }
324
- // Write each file's results to cache
325
- for (const [filePath, fileResults] of resultsByFile.entries()) {
326
- await cacheManager.setAnalysisResult(filePath, fileResults);
267
+ // Group results by file path
268
+ const resultsByFile = new Map();
269
+ for (const result of results) {
270
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
271
+ const filePath = result.filePath;
272
+ if (!resultsByFile.has(filePath)) {
273
+ resultsByFile.set(filePath, []);
327
274
  }
328
- // Log cache effectiveness
329
- const stats = cacheManager.getStats();
330
- console.info(`Cached ${resultsByFile.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
275
+ resultsByFile.get(filePath).push(result);
331
276
  }
277
+ // Write each file's results to cache
278
+ for (const [filePath, fileResults] of resultsByFile.entries()) {
279
+ await cache.setAnalysisResult(filePath, fileResults);
280
+ }
281
+ // Log cache effectiveness
282
+ const stats = cache.getStats();
283
+ console.info(`Cached ${resultsByFile.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
332
284
  // Filter by specific rules if requested
333
285
  let violations = results
334
286
  .filter((r) => r.ruleId && r.filePath)
@@ -354,13 +306,23 @@ export class ScanSolidTool {
354
306
  const offset = mergedParams.resultOffset ?? 0;
355
307
  const maxResults = mergedParams.maxResults ?? 1000;
356
308
  const paginatedViolations = violations.slice(offset, offset + maxResults);
357
- // Calculate summary
358
- const summary = this.calculateSummary(paginatedViolations, filesToAnalyze.length);
309
+ // Counts cover every violation, not only the page
310
+ const analyzedFiles = cancelled ? cachedFiles + processedFiles : filesToAnalyze.length;
311
+ const counts = this.calculateSummary(violations, analyzedFiles);
312
+ const execution = cancelled
313
+ ? cancelledExecution(analyzedFiles, filesToAnalyze.length - analyzedFiles)
314
+ : undefined;
315
+ const pagination = {
316
+ totalResults: totalViolations,
317
+ returnedResults: paginatedViolations.length,
318
+ offset,
319
+ hasMore: offset + maxResults < totalViolations,
320
+ };
359
321
  const duration = Date.now() - startTime;
360
- const ruleIds = allRules.map((r) => r.id);
322
+ const ruleIds = engine.ruleIds;
361
323
  return {
362
324
  violations: paginatedViolations,
363
- summary,
325
+ counts,
364
326
  metadata: {
365
327
  rulesExecuted: ruleIds,
366
328
  duration,
@@ -377,12 +339,9 @@ export class ScanSolidTool {
377
339
  throughput: filesToAnalyze.length / (duration / 1000),
378
340
  }
379
341
  : undefined,
380
- pagination: {
381
- totalResults: totalViolations,
382
- returnedResults: paginatedViolations.length,
383
- offset,
384
- hasMore: offset + maxResults < totalViolations,
385
- },
342
+ pagination,
343
+ ...(execution === undefined ? {} : { execution }),
344
+ summary: describeScan(counts, paginatedViolations, pagination, execution === undefined ? [] : [execution.note]),
386
345
  };
387
346
  }
388
347
  /**
@@ -1,6 +1,27 @@
1
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
2
+ import { type SearchCoverage, type SearchResult } from '@angular-modernizer/api';
3
+ import { ProjectCache } from './helpers/project-cache.js';
4
+ /**
5
+ * Output of the search-codebase tool.
6
+ */
7
+ export interface SearchCodebaseOutput {
8
+ /** Matches, at most `maxResults` (default 100). */
9
+ results: SearchResult[];
10
+ /** Number of returned matches. */
11
+ totalCount: number;
12
+ /** Short text summary of the matches. */
13
+ summary: string;
14
+ /** Which files the search covered, including the tsconfig used. */
15
+ coverage: SearchCoverage & {
16
+ /** The tsconfig whose program was searched. */
17
+ tsConfigPath: string;
18
+ /** Present when 0 hits were found: why that does not prove absence. */
19
+ hint?: string;
20
+ };
21
+ /** Conditions that can make the result incomplete (unresolved library imports). */
22
+ warnings?: string[];
23
+ }
1
24
  /**
2
- * @angular-modernizer/adapter-mcp - Search Codebase Tool
3
- *
4
25
  * MCP tool for searching across all TypeScript source files in a project.
5
26
  * Supports three modes: literal text, regular expression, and TypeScript
6
27
  * named-declaration (symbol) lookup.
@@ -19,33 +40,20 @@
19
40
  * // args: { query: 'selector:\\s*["\']app-[^"\']+', mode: 'pattern', projectRoot: '/project' }
20
41
  * ```
21
42
  */
22
- import { type MCPTool } from '../types.js';
23
- import { type SearchCoverage, type SearchResult } from '@angular-modernizer/api';
24
- import { ProjectCache } from './helpers/project-cache.js';
25
- /**
26
- * Output of the search-codebase tool.
27
- */
28
- interface SearchCodebaseOutput {
29
- results: SearchResult[];
30
- totalCount: number;
31
- summary: string;
32
- /** Which files the search covered, including the tsconfig used. */
33
- coverage: SearchCoverage & {
34
- tsConfigPath: string;
35
- /** Present when 0 hits were found: why that does not prove absence. */
36
- hint?: string;
37
- };
38
- }
39
- /**
40
- * MCP tool that searches TypeScript source files by text, regex, or symbol.
41
- */
42
43
  export declare class SearchCodebaseTool implements MCPTool {
43
44
  private readonly projects;
44
45
  readonly name = "search-codebase";
46
+ readonly title = "Search Codebase";
47
+ readonly annotations: ToolAnnotations;
45
48
  constructor(projects?: ProjectCache);
46
49
  readonly description: string;
50
+ /**
51
+ * JSON Schema of the tool arguments.
52
+ * @hidden
53
+ */
47
54
  readonly inputSchema: {
48
55
  type: string;
56
+ additionalProperties: boolean;
49
57
  properties: {
50
58
  query: {
51
59
  type: string;
@@ -79,6 +87,86 @@ export declare class SearchCodebaseTool implements MCPTool {
79
87
  };
80
88
  required: string[];
81
89
  };
90
+ /**
91
+ * JSON Schema of the tool result (`structuredContent`).
92
+ * @hidden
93
+ */
94
+ readonly outputSchema: {
95
+ type: string;
96
+ properties: {
97
+ warnings: {
98
+ readonly type: "array";
99
+ readonly items: {
100
+ readonly type: "string";
101
+ };
102
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
103
+ };
104
+ results: {
105
+ type: string;
106
+ items: {
107
+ type: string;
108
+ properties: {
109
+ file: {
110
+ type: string;
111
+ };
112
+ line: {
113
+ type: string;
114
+ };
115
+ col: {
116
+ type: string;
117
+ };
118
+ snippet: {
119
+ type: string;
120
+ };
121
+ symbolKind: {
122
+ type: string;
123
+ };
124
+ source: {
125
+ type: string;
126
+ };
127
+ };
128
+ required: string[];
129
+ };
130
+ };
131
+ totalCount: {
132
+ type: string;
133
+ };
134
+ summary: {
135
+ type: string;
136
+ };
137
+ coverage: {
138
+ type: string;
139
+ properties: {
140
+ programFileCount: {
141
+ type: string;
142
+ };
143
+ extraFileCount: {
144
+ type: string;
145
+ };
146
+ templatesScanned: {
147
+ type: string;
148
+ };
149
+ nonProgramFilesScanned: {
150
+ type: string;
151
+ };
152
+ excludedDirectories: {
153
+ type: string;
154
+ items: {
155
+ type: string;
156
+ };
157
+ };
158
+ tsConfigPath: {
159
+ type: string;
160
+ };
161
+ hint: {
162
+ type: string;
163
+ };
164
+ };
165
+ required: string[];
166
+ };
167
+ };
168
+ required: string[];
169
+ };
82
170
  execute(args: Record<string, unknown>): Promise<SearchCodebaseOutput>;
83
171
  /**
84
172
  * Explains why 0 hits is not proof of absence, naming what was excluded.
@@ -86,5 +174,4 @@ export declare class SearchCodebaseTool implements MCPTool {
86
174
  private buildZeroHitHint;
87
175
  private buildSummary;
88
176
  }
89
- export {};
90
177
  //# sourceMappingURL=search-codebase.d.ts.map