@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,19 +1,121 @@
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
2
+ import { type IncompatibilityCheck } from '@angular-modernizer/core';
1
3
  /**
2
- * @angular-modernizer/adapter-mcp - Validate Transformation Tool
3
- *
4
- * MCP tool for validating code after transformation to ensure changes
5
- * didn't break anything. Supports both legacy validation (PostTransformValidator)
6
- * and modern incremental build validation (IncrementalBuildValidator) for 2-4x speedup.
4
+ * Incremental build metadata
7
5
  */
8
- import { type MCPTool } from '../types.js';
6
+ export interface IncrementalMetadata {
7
+ /**
8
+ * Whether incremental mode was enabled
9
+ */
10
+ enabled: boolean;
11
+ /**
12
+ * Build scope strategy used
13
+ */
14
+ scope?: 'affected-only' | 'partial' | 'full';
15
+ /**
16
+ * Number of files validated
17
+ */
18
+ filesValidated?: number;
19
+ /**
20
+ * Number of files skipped
21
+ */
22
+ filesSkipped?: number;
23
+ /**
24
+ * Whether cache was used
25
+ */
26
+ cacheHit?: boolean;
27
+ /**
28
+ * Speedup estimation compared to full validation
29
+ */
30
+ speedup?: string;
31
+ /**
32
+ * Reason for fallback to full validation (if incremental was disabled)
33
+ */
34
+ fallbackReason?: string;
35
+ /**
36
+ * Incompatibility issues detected (if any)
37
+ */
38
+ incompatibilityIssues?: IncompatibilityCheck[];
39
+ }
40
+ /**
41
+ * Validation result.
42
+ */
43
+ export interface ValidationResult {
44
+ /**
45
+ * Whether validation passed (no errors).
46
+ */
47
+ valid: boolean;
48
+ /**
49
+ * Validation issues found.
50
+ */
51
+ issues: {
52
+ /** Check that reported the issue. */
53
+ type: 'syntax' | 'build' | 'test' | 'lint';
54
+ /** Severity; only errors make the file not valid. */
55
+ severity: 'error' | 'warning' | 'info';
56
+ /** Issue description. */
57
+ message: string;
58
+ /** File the issue was found in. */
59
+ filePath?: string;
60
+ /** Line of the issue (1-based). */
61
+ line?: number;
62
+ /** Column of the issue. */
63
+ column?: number;
64
+ /** Additional details of the issue. */
65
+ details?: string;
66
+ }[];
67
+ /**
68
+ * Validation duration in milliseconds.
69
+ */
70
+ duration: number;
71
+ /**
72
+ * Metadata about validation.
73
+ */
74
+ metadata: {
75
+ /** Validated file. */
76
+ filePath: string;
77
+ /** Whether build validation was requested. */
78
+ buildValidation: boolean;
79
+ /** Whether test validation was requested. */
80
+ testValidation: boolean;
81
+ /** Whether lint validation was requested. */
82
+ lintValidation: boolean;
83
+ /** Project root the validation ran in. */
84
+ cwd?: string;
85
+ /** Build command that ran (legacy validation). */
86
+ buildCommand?: string;
87
+ /** Where it came from: config, angular-cli, nx, vite, package-script or custom. */
88
+ buildCommandSource?: string;
89
+ };
90
+ /**
91
+ * Incremental build metadata (if incremental mode was used)
92
+ */
93
+ incremental?: IncrementalMetadata;
94
+ /**
95
+ * Short text: verdict, checks, validation mode, issue counts and the first issues.
96
+ */
97
+ summary: string;
98
+ }
9
99
  /**
10
- * MCP tool for post-transformation validation with incremental build support.
100
+ * MCP tool for validating code after a transformation to make sure the
101
+ * changes did not break anything, with incremental build support.
102
+ *
103
+ * @remarks
104
+ * Supports legacy validation (`PostTransformValidator`) and incremental build
105
+ * validation (`IncrementalBuildValidator`), which is 2-4x faster.
11
106
  */
12
107
  export declare class ValidateTransformationTool implements MCPTool {
13
108
  name: string;
109
+ title: string;
110
+ annotations: ToolAnnotations;
14
111
  description: string;
112
+ /**
113
+ * JSON Schema of the tool arguments.
114
+ * @hidden
115
+ */
15
116
  inputSchema: {
16
117
  type: string;
118
+ additionalProperties: boolean;
17
119
  properties: {
18
120
  filePath: {
19
121
  type: string;
@@ -84,7 +186,140 @@ export declare class ValidateTransformationTool implements MCPTool {
84
186
  };
85
187
  required: string[];
86
188
  };
87
- execute(args: Record<string, unknown>): Promise<unknown>;
189
+ /**
190
+ * JSON Schema of the tool result (`structuredContent`).
191
+ * @hidden
192
+ */
193
+ outputSchema: {
194
+ type: string;
195
+ properties: {
196
+ valid: {
197
+ type: string;
198
+ };
199
+ issues: {
200
+ readonly type: "array";
201
+ readonly items: {
202
+ readonly type: "object";
203
+ readonly properties: {
204
+ readonly type: {
205
+ readonly type: "string";
206
+ };
207
+ readonly severity: {
208
+ readonly type: "string";
209
+ readonly enum: readonly ["error", "warning", "info"];
210
+ };
211
+ readonly message: {
212
+ readonly type: "string";
213
+ };
214
+ readonly filePath: {
215
+ readonly type: "string";
216
+ };
217
+ readonly line: {
218
+ readonly type: "integer";
219
+ };
220
+ readonly column: {
221
+ readonly type: "integer";
222
+ };
223
+ readonly details: {
224
+ readonly type: "string";
225
+ };
226
+ };
227
+ readonly required: readonly ["type", "severity", "message"];
228
+ };
229
+ };
230
+ duration: {
231
+ type: string;
232
+ };
233
+ metadata: {
234
+ type: string;
235
+ properties: {
236
+ filePath: {
237
+ type: string;
238
+ };
239
+ buildValidation: {
240
+ type: string;
241
+ };
242
+ testValidation: {
243
+ type: string;
244
+ };
245
+ lintValidation: {
246
+ type: string;
247
+ };
248
+ cwd: {
249
+ type: string;
250
+ };
251
+ buildCommand: {
252
+ type: string;
253
+ };
254
+ buildCommandSource: {
255
+ type: string;
256
+ };
257
+ };
258
+ required: string[];
259
+ };
260
+ incremental: {
261
+ type: string;
262
+ properties: {
263
+ enabled: {
264
+ type: string;
265
+ };
266
+ scope: {
267
+ type: string;
268
+ };
269
+ filesValidated: {
270
+ type: string;
271
+ };
272
+ filesSkipped: {
273
+ type: string;
274
+ };
275
+ cacheHit: {
276
+ type: string;
277
+ };
278
+ speedup: {
279
+ type: string;
280
+ };
281
+ fallbackReason: {
282
+ type: string;
283
+ };
284
+ incompatibilityIssues: {
285
+ readonly type: "array";
286
+ readonly items: {
287
+ readonly type: "object";
288
+ readonly properties: {
289
+ readonly type: {
290
+ readonly type: "string";
291
+ };
292
+ readonly detected: {
293
+ readonly type: "boolean";
294
+ };
295
+ readonly severity: {
296
+ readonly type: "string";
297
+ readonly enum: readonly ["blocker", "warning"];
298
+ };
299
+ readonly message: {
300
+ readonly type: "string";
301
+ };
302
+ readonly recommendation: {
303
+ readonly type: "string";
304
+ };
305
+ readonly details: {
306
+ readonly type: "object";
307
+ };
308
+ };
309
+ readonly required: readonly ["type", "detected", "severity", "message", "recommendation"];
310
+ };
311
+ };
312
+ };
313
+ required: string[];
314
+ };
315
+ summary: {
316
+ type: string;
317
+ };
318
+ };
319
+ required: string[];
320
+ };
321
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ValidationResult>;
322
+ private runValidation;
88
323
  /**
89
324
  * Executes incremental build validation using IncrementalBuildValidator
90
325
  */
@@ -1,23 +1,61 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Validate Transformation Tool
3
- *
4
- * MCP tool for validating code after transformation to ensure changes
5
- * didn't break anything. Supports both legacy validation (PostTransformValidator)
6
- * and modern incremental build validation (IncrementalBuildValidator) for 2-4x speedup.
7
- */
8
1
  import { PostTransformValidator, loadConfig, } from '@angular-modernizer/core';
9
2
  import { Project } from 'ts-morph';
10
3
  import { existsSync } from 'node:fs';
11
4
  import { join, dirname } from 'node:path';
12
5
  import { execSync } from 'node:child_process';
6
+ import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
7
+ import { VALIDATION_ISSUES_SCHEMA, issueCount, issueLines, } from './helpers/validation-output.js';
8
+ /** Text summary: verdict, checks, validation mode, counts per severity and the first issues. */
9
+ function describeTransformationValidation(result) {
10
+ const checks = [
11
+ result.metadata.buildValidation ? 'build' : undefined,
12
+ result.metadata.testValidation ? 'tests' : undefined,
13
+ result.metadata.lintValidation ? 'lint' : undefined,
14
+ ].filter((c) => c !== undefined);
15
+ const lines = [
16
+ `${result.valid ? 'Valid' : 'Not valid'}: ${result.metadata.filePath} ` +
17
+ `(${checks.length > 0 ? checks.join(', ') : 'no checks'}; ${result.duration} ms); ` +
18
+ `${issueCount(result.issues)}.`,
19
+ ];
20
+ const inc = result.incremental;
21
+ if (inc !== undefined) {
22
+ lines.push(inc.enabled
23
+ ? `Incremental (${inc.scope ?? 'unknown scope'}): ${inc.filesValidated ?? 0} file(s) validated, ` +
24
+ `${inc.filesSkipped ?? 0} skipped${inc.speedup === undefined ? '' : `; ${inc.speedup}`}.`
25
+ : `Full validation${inc.fallbackReason === undefined ? '' : `: ${inc.fallbackReason}`}.`);
26
+ }
27
+ if (result.metadata.buildCommand !== undefined) {
28
+ lines.push(`Build command: ${result.metadata.buildCommand} (${result.metadata.buildCommandSource ?? 'unknown source'}).`);
29
+ }
30
+ lines.push(...issueLines(result.issues));
31
+ return lines.join('\n');
32
+ }
13
33
  /**
14
- * MCP tool for post-transformation validation with incremental build support.
34
+ * MCP tool for validating code after a transformation to make sure the
35
+ * changes did not break anything, with incremental build support.
36
+ *
37
+ * @remarks
38
+ * Supports legacy validation (`PostTransformValidator`) and incremental build
39
+ * validation (`IncrementalBuildValidator`), which is 2-4x faster.
15
40
  */
16
41
  export class ValidateTransformationTool {
17
42
  name = 'validate-transformation';
18
- description = 'Validate code after transformation to ensure changes did not break anything. Supports incremental build mode for 2-4x faster validation by checking only transformed files and their dependencies. Automatically detects project compatibility and falls back to full validation when needed.';
43
+ title = 'Validate Transformation';
44
+ annotations = {
45
+ readOnlyHint: false,
46
+ destructiveHint: true,
47
+ idempotentHint: true,
48
+ openWorldHint: false,
49
+ };
50
+ description = 'Validate code after transformation to ensure changes did not break anything. Supports incremental build mode for 2-4x faster validation by checking only transformed files and their dependencies. Automatically detects project compatibility and falls back to full validation when needed. ' +
51
+ 'summary is a short text with the verdict, the validation mode, the issue counts and the first issues.';
52
+ /**
53
+ * JSON Schema of the tool arguments.
54
+ * @hidden
55
+ */
19
56
  inputSchema = {
20
57
  type: 'object',
58
+ additionalProperties: false,
21
59
  properties: {
22
60
  filePath: {
23
61
  type: 'string',
@@ -86,7 +124,57 @@ export class ValidateTransformationTool {
86
124
  },
87
125
  required: ['filePath'],
88
126
  };
89
- async execute(args) {
127
+ /**
128
+ * JSON Schema of the tool result (`structuredContent`).
129
+ * @hidden
130
+ */
131
+ outputSchema = {
132
+ type: 'object',
133
+ properties: {
134
+ valid: { type: 'boolean' },
135
+ issues: VALIDATION_ISSUES_SCHEMA,
136
+ duration: { type: 'number' },
137
+ metadata: {
138
+ type: 'object',
139
+ properties: {
140
+ filePath: { type: 'string' },
141
+ buildValidation: { type: 'boolean' },
142
+ testValidation: { type: 'boolean' },
143
+ lintValidation: { type: 'boolean' },
144
+ cwd: { type: 'string' },
145
+ buildCommand: { type: 'string' },
146
+ buildCommandSource: { type: 'string' },
147
+ },
148
+ required: [
149
+ 'filePath',
150
+ 'buildValidation',
151
+ 'testValidation',
152
+ 'lintValidation',
153
+ ],
154
+ },
155
+ incremental: {
156
+ type: 'object',
157
+ properties: {
158
+ enabled: { type: 'boolean' },
159
+ scope: { type: 'string' },
160
+ filesValidated: { type: 'integer' },
161
+ filesSkipped: { type: 'integer' },
162
+ cacheHit: { type: 'boolean' },
163
+ speedup: { type: 'string' },
164
+ fallbackReason: { type: 'string' },
165
+ incompatibilityIssues: INCOMPATIBILITY_ISSUES_SCHEMA,
166
+ },
167
+ required: ['enabled'],
168
+ },
169
+ summary: { type: 'string' },
170
+ },
171
+ required: ['valid', 'issues', 'duration', 'metadata', 'summary'],
172
+ };
173
+ async execute(args, ctx = {}) {
174
+ const result = await this.runValidation(args, ctx.signal);
175
+ return { ...result, summary: describeTransformationValidation(result) };
176
+ }
177
+ async runValidation(args, signal) {
90
178
  const typedArgs = args;
91
179
  // Determine project root
92
180
  const projectRoot = typedArgs.cwd ?? this.detectProjectRoot(typedArgs.filePath);
@@ -105,22 +193,30 @@ export class ValidateTransformationTool {
105
193
  mergedArgs.validateBuild !== false &&
106
194
  mergedArgs.incrementalMode !== false &&
107
195
  !typedArgs.forceFullBuild;
196
+ let fallbackReason = typedArgs.forceFullBuild
197
+ ? 'Full validation forced by user'
198
+ : `No angular.json in ${projectRoot}: incremental validation needs an Angular CLI project`;
108
199
  if (shouldUseIncremental) {
109
200
  try {
110
- return await this.executeIncrementalValidation(typedArgs.filePath, projectRoot, typedArgs);
201
+ return await this.executeIncrementalValidation(typedArgs.filePath, projectRoot, typedArgs, signal);
111
202
  }
112
203
  catch (error) {
113
- // Fallback to legacy validation on any error
114
- console.warn('Incremental validation failed, falling back to legacy validation:', error instanceof Error ? error.message : String(error));
204
+ // A cancelled build stops; any other error falls back to legacy validation
205
+ if (signal?.aborted === true) {
206
+ throw error;
207
+ }
208
+ const message = error instanceof Error ? error.message : String(error);
209
+ console.warn('Incremental validation failed, falling back to legacy validation:', message);
210
+ fallbackReason = `Incremental validation failed: ${message}`;
115
211
  }
116
212
  }
117
213
  // Use legacy PostTransformValidator
118
- return this.executeLegacyValidation(typedArgs.filePath, typedArgs);
214
+ return this.executeLegacyValidation(typedArgs.filePath, typedArgs, fallbackReason, signal);
119
215
  }
120
216
  /**
121
217
  * Executes incremental build validation using IncrementalBuildValidator
122
218
  */
123
- async executeIncrementalValidation(filePath, projectRoot, args) {
219
+ async executeIncrementalValidation(filePath, projectRoot, args, signal) {
124
220
  // Dynamic imports to avoid circular dependencies
125
221
  const { IncompatibilityDetector, IncrementalBuildValidator, IncrementalAnalyzer, CacheManager, RealFileSystemAdapter, } = await import('@angular-modernizer/core');
126
222
  const startTime = Date.now();
@@ -215,6 +311,7 @@ export class ValidateTransformationTool {
215
311
  baseBranch: 'HEAD',
216
312
  forceFiles: filesToValidate,
217
313
  includeDependents: true,
314
+ signal,
218
315
  });
219
316
  // Calculate speedup
220
317
  const fullBuildEstimate = validationResult.scope.estimatedBuildTime * 1000;
@@ -293,7 +390,7 @@ export class ValidateTransformationTool {
293
390
  /**
294
391
  * Executes legacy validation using PostTransformValidator
295
392
  */
296
- async executeLegacyValidation(filePath, args) {
393
+ async executeLegacyValidation(filePath, args, fallbackReason, signal) {
297
394
  const validator = new PostTransformValidator();
298
395
  const config = {
299
396
  validateBuild: args.validateBuild ?? true,
@@ -303,6 +400,7 @@ export class ValidateTransformationTool {
303
400
  testTimeout: args.testTimeout ?? 600000,
304
401
  lintTimeout: args.lintTimeout ?? 120000,
305
402
  cwd: args.cwd,
403
+ signal,
306
404
  };
307
405
  const result = await validator.validate(filePath, config);
308
406
  // Transform ValidationResult from core to MCP format
@@ -324,15 +422,12 @@ export class ValidateTransformationTool {
324
422
  testValidation: args.validateTests ?? false,
325
423
  lintValidation: args.validateLint ?? true,
326
424
  cwd: args.cwd,
425
+ ...buildCommandOf(result.metadata),
327
426
  },
328
- incremental: args.incrementalMode === false
427
+ // Only a build has an incremental mode to fall back from
428
+ incremental: args.incrementalMode === false || args.validateBuild === false
329
429
  ? undefined
330
- : {
331
- enabled: false,
332
- fallbackReason: args.forceFullBuild
333
- ? 'Full validation forced by user'
334
- : 'Incremental mode not available or compatible',
335
- },
430
+ : { enabled: false, fallbackReason },
336
431
  };
337
432
  return response;
338
433
  }
@@ -388,4 +483,13 @@ export class ValidateTransformationTool {
388
483
  }
389
484
  }
390
485
  }
486
+ /** Build command and its source from the validator's metadata. */
487
+ function buildCommandOf(metadata) {
488
+ const command = metadata?.['buildCommand'];
489
+ const source = metadata?.['buildCommandSource'];
490
+ return {
491
+ ...(typeof command === 'string' ? { buildCommand: command } : {}),
492
+ ...(typeof source === 'string' ? { buildCommandSource: source } : {}),
493
+ };
494
+ }
391
495
  //# sourceMappingURL=validate-transformation.js.map
@@ -0,0 +1,202 @@
1
+ import { type CitationFileSource, type CitationStatus } from '@angular-modernizer/api';
2
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
3
+ /** One checked citation in the tool output. */
4
+ export interface VerifiedCitation {
5
+ /** Plan file relative to `projectRoot`. */
6
+ plan: string;
7
+ /** Line of the citation in the plan. */
8
+ planLine: number;
9
+ /** Citation as written, e.g. `x.ts:12-20`. */
10
+ text: string;
11
+ /** Result of the check. */
12
+ status: CitationStatus;
13
+ /** Resolved file relative to the root, when exactly one file matched. */
14
+ file?: string;
15
+ /** Anchor that decided the status (`prefix` anchors end in `*`). */
16
+ matched?: string;
17
+ /** For `moved`: lines where the anchor is now, nearest first, at most 5. */
18
+ foundAt?: number[];
19
+ /** Current text of the first cited line, whitespace collapsed, at most 100 characters. */
20
+ current?: string;
21
+ /** For `out-of-range`: number of lines of the file. */
22
+ fileLength?: number;
23
+ /** For `missing-file`: files with the same name or stem; for `ambiguous`: the matches. */
24
+ candidates?: string[];
25
+ }
26
+ /** Output of the verify-citations tool. */
27
+ export interface VerifyCitationsOutput {
28
+ /** Absolute repository root the citations resolve from. */
29
+ projectRoot: string;
30
+ /** Citation counts per plan. */
31
+ plans: {
32
+ /** Plan file relative to `projectRoot`. */
33
+ plan: string;
34
+ /** Number of citations in the plan. */
35
+ citations: number;
36
+ /** Citations of the plan that need attention. */
37
+ needsAttention: number;
38
+ }[];
39
+ /** Number of citations in all plans. */
40
+ total: number;
41
+ /** Citations with status moved, anchor-missing, out-of-range, missing-file or ambiguous. */
42
+ needsAttention: number;
43
+ /** Number of citations per status. */
44
+ counts: Record<CitationStatus, number>;
45
+ /** Citations that need attention first, then the others, each in plan order. */
46
+ citations?: VerifiedCitation[];
47
+ /** `true` when `maxResults` cut the citation list. */
48
+ truncated: boolean;
49
+ /** Short text with the counts and the citations that need attention. */
50
+ summary: string;
51
+ }
52
+ /**
53
+ * MCP tool that checks the `path:line` citations of Markdown plans against the
54
+ * current code: does the cited file exist, is the line range still in the
55
+ * file, and does the symbol named next to the citation still sit in the range?
56
+ *
57
+ * @remarks
58
+ * Run it before executing a bug-fix or feature plan (stale line numbers make
59
+ * edits land in the wrong place) and after writing one. Logic lives in the api
60
+ * `CitationVerifier`; the claude-plugin script `verify-citations.mjs` is the
61
+ * same check for sessions without this server.
62
+ */
63
+ export declare class VerifyCitationsTool implements MCPTool {
64
+ private readonly createSource;
65
+ readonly name = "verify-citations";
66
+ readonly title = "Verify Plan Citations";
67
+ readonly description: string;
68
+ readonly annotations: ToolAnnotations;
69
+ /**
70
+ * JSON Schema of the tool arguments.
71
+ * @hidden
72
+ */
73
+ readonly inputSchema: {
74
+ type: string;
75
+ additionalProperties: boolean;
76
+ properties: {
77
+ summaryOnly: {
78
+ readonly type: "boolean";
79
+ readonly description: "Return counts and the text summary only, without the result list. Default: false.";
80
+ readonly default: false;
81
+ };
82
+ maxResults: {
83
+ readonly type: "number";
84
+ readonly description: string;
85
+ };
86
+ planPaths: {
87
+ type: string;
88
+ items: {
89
+ type: string;
90
+ };
91
+ minItems: number;
92
+ description: string;
93
+ };
94
+ projectRoot: {
95
+ type: string;
96
+ description: string;
97
+ };
98
+ };
99
+ required: string[];
100
+ };
101
+ /**
102
+ * JSON Schema of the tool result (`structuredContent`).
103
+ * @hidden
104
+ */
105
+ readonly outputSchema: {
106
+ type: string;
107
+ properties: {
108
+ projectRoot: {
109
+ type: string;
110
+ };
111
+ plans: {
112
+ type: string;
113
+ items: {
114
+ type: string;
115
+ properties: {
116
+ plan: {
117
+ type: string;
118
+ };
119
+ citations: {
120
+ type: string;
121
+ };
122
+ needsAttention: {
123
+ type: string;
124
+ };
125
+ };
126
+ required: string[];
127
+ };
128
+ };
129
+ total: {
130
+ type: string;
131
+ };
132
+ needsAttention: {
133
+ type: string;
134
+ };
135
+ counts: {
136
+ type: string;
137
+ properties: {
138
+ [k: string]: {
139
+ type: string;
140
+ };
141
+ };
142
+ required: CitationStatus[];
143
+ };
144
+ citations: {
145
+ type: string;
146
+ items: {
147
+ readonly type: "object";
148
+ readonly properties: {
149
+ readonly plan: {
150
+ readonly type: "string";
151
+ };
152
+ readonly planLine: {
153
+ readonly type: "integer";
154
+ };
155
+ readonly text: {
156
+ readonly type: "string";
157
+ };
158
+ readonly status: {
159
+ readonly type: "string";
160
+ readonly enum: readonly CitationStatus[];
161
+ };
162
+ readonly file: {
163
+ readonly type: "string";
164
+ };
165
+ readonly matched: {
166
+ readonly type: "string";
167
+ };
168
+ readonly foundAt: {
169
+ readonly type: "array";
170
+ readonly items: {
171
+ readonly type: "integer";
172
+ };
173
+ };
174
+ readonly current: {
175
+ readonly type: "string";
176
+ };
177
+ readonly fileLength: {
178
+ readonly type: "integer";
179
+ };
180
+ readonly candidates: {
181
+ readonly type: "array";
182
+ readonly items: {
183
+ readonly type: "string";
184
+ };
185
+ };
186
+ };
187
+ readonly required: readonly ["plan", "planLine", "text", "status"];
188
+ };
189
+ };
190
+ truncated: {
191
+ type: string;
192
+ };
193
+ summary: {
194
+ type: string;
195
+ };
196
+ };
197
+ required: string[];
198
+ };
199
+ constructor(createSource?: (projectRoot: string) => CitationFileSource);
200
+ execute(args: Record<string, unknown>): Promise<VerifyCitationsOutput>;
201
+ }
202
+ //# sourceMappingURL=verify-citations.d.ts.map