@angular-modernizer/adapter-mcp 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/README.md +103 -218
  2. package/dist/cli.js +13 -13
  3. package/dist/index.d.ts +4 -3
  4. package/dist/index.js +3 -2
  5. package/dist/mcp-watcher.d.ts +6 -1
  6. package/dist/mcp-watcher.js +11 -10
  7. package/dist/server/limited-stdio-transport.d.ts +68 -0
  8. package/dist/server/limited-stdio-transport.js +115 -0
  9. package/dist/server/mcp-server.d.ts +12 -14
  10. package/dist/server/mcp-server.js +41 -75
  11. package/dist/server/package-version.d.ts +16 -0
  12. package/dist/server/package-version.js +37 -0
  13. package/dist/server/sdk-server.d.ts +70 -0
  14. package/dist/server/sdk-server.js +113 -0
  15. package/dist/server/tool-registry.d.ts +3 -2
  16. package/dist/server/tool-registry.js +5 -5
  17. package/dist/tools/analyze-build-impact.d.ts +220 -1
  18. package/dist/tools/analyze-build-impact.js +145 -3
  19. package/dist/tools/analyze-core-to-shared.d.ts +134 -4
  20. package/dist/tools/analyze-core-to-shared.js +113 -9
  21. package/dist/tools/analyze-parser-performance.d.ts +200 -7
  22. package/dist/tools/analyze-parser-performance.js +108 -47
  23. package/dist/tools/analyze-project.d.ts +267 -5
  24. package/dist/tools/analyze-project.js +196 -8
  25. package/dist/tools/check-incremental-compatibility.d.ts +61 -1
  26. package/dist/tools/check-incremental-compatibility.js +58 -2
  27. package/dist/tools/collect-feedback.d.ts +199 -10
  28. package/dist/tools/collect-feedback.js +171 -99
  29. package/dist/tools/compare-health.d.ts +356 -0
  30. package/dist/tools/compare-health.js +472 -0
  31. package/dist/tools/extract-libraries.d.ts +156 -4
  32. package/dist/tools/extract-libraries.js +115 -10
  33. package/dist/tools/find-angular-symbol.d.ts +69 -3
  34. package/dist/tools/find-angular-symbol.js +55 -8
  35. package/dist/tools/find-component-hosts.d.ts +572 -2
  36. package/dist/tools/find-component-hosts.js +207 -6
  37. package/dist/tools/find-usages.d.ts +79 -1
  38. package/dist/tools/find-usages.js +64 -7
  39. package/dist/tools/get-bootstrap-execution.d.ts +151 -1
  40. package/dist/tools/get-bootstrap-execution.js +84 -3
  41. package/dist/tools/get-call-graph.d.ts +111 -1
  42. package/dist/tools/get-call-graph.js +72 -10
  43. package/dist/tools/get-operation-progress-tool.d.ts +114 -2
  44. package/dist/tools/get-operation-progress-tool.js +114 -7
  45. package/dist/tools/get-operation-progress.d.ts +1 -1
  46. package/dist/tools/get-operation-progress.js +5 -5
  47. package/dist/tools/helpers/analysis-output.d.ts +177 -0
  48. package/dist/tools/helpers/analysis-output.js +165 -0
  49. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  50. package/dist/tools/helpers/build-schemas.js +23 -0
  51. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  52. package/dist/tools/helpers/citation-file-source.js +82 -0
  53. package/dist/tools/helpers/finding-window.d.ts +43 -0
  54. package/dist/tools/helpers/finding-window.js +64 -0
  55. package/dist/tools/helpers/health-delta.d.ts +86 -0
  56. package/dist/tools/helpers/health-delta.js +239 -0
  57. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  58. package/dist/tools/helpers/investigation-schemas.js +48 -0
  59. package/dist/tools/helpers/library-imports.d.ts +57 -0
  60. package/dist/tools/helpers/library-imports.js +151 -0
  61. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  62. package/dist/tools/helpers/load-source-files.js +34 -0
  63. package/dist/tools/helpers/output-contract.d.ts +32 -0
  64. package/dist/tools/helpers/output-contract.js +32 -0
  65. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  66. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  67. package/dist/tools/helpers/process-output.d.ts +19 -0
  68. package/dist/tools/helpers/process-output.js +31 -0
  69. package/dist/tools/helpers/project-cache.d.ts +11 -4
  70. package/dist/tools/helpers/project-cache.js +22 -4
  71. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  72. package/dist/tools/helpers/project-decorators.js +22 -0
  73. package/dist/tools/helpers/rule-matcher.js +5 -0
  74. package/dist/tools/helpers/rule-runner.d.ts +9 -4
  75. package/dist/tools/helpers/rule-runner.js +28 -14
  76. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  77. package/dist/tools/helpers/scan-cache.js +34 -0
  78. package/dist/tools/helpers/scan-plan.d.ts +5 -2
  79. package/dist/tools/helpers/scan-plan.js +18 -3
  80. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  81. package/dist/tools/helpers/scope-paths.js +32 -0
  82. package/dist/tools/helpers/tool-context.d.ts +60 -0
  83. package/dist/tools/helpers/tool-context.js +82 -0
  84. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  85. package/dist/tools/helpers/transform-safety.js +87 -0
  86. package/dist/tools/helpers/validation-output.d.ts +53 -0
  87. package/dist/tools/helpers/validation-output.js +48 -0
  88. package/dist/tools/inspect-form-group.d.ts +232 -1
  89. package/dist/tools/inspect-form-group.js +120 -2
  90. package/dist/tools/inspect-i18n.d.ts +382 -1
  91. package/dist/tools/inspect-i18n.js +199 -2
  92. package/dist/tools/inspect-template.d.ts +232 -1
  93. package/dist/tools/inspect-template.js +160 -2
  94. package/dist/tools/learn-patterns.d.ts +122 -1
  95. package/dist/tools/learn-patterns.js +97 -2
  96. package/dist/tools/list-imports.d.ts +111 -10
  97. package/dist/tools/list-imports.js +110 -7
  98. package/dist/tools/orchestrate-migration.d.ts +128 -5
  99. package/dist/tools/orchestrate-migration.js +135 -13
  100. package/dist/tools/parse-stack-trace.d.ts +56 -1
  101. package/dist/tools/parse-stack-trace.js +34 -0
  102. package/dist/tools/plan-migration.d.ts +330 -1
  103. package/dist/tools/plan-migration.js +154 -3
  104. package/dist/tools/resolve-type.d.ts +39 -1
  105. package/dist/tools/resolve-type.js +31 -2
  106. package/dist/tools/review-feedback.d.ts +206 -11
  107. package/dist/tools/review-feedback.js +132 -51
  108. package/dist/tools/rollback-changes.d.ts +79 -2
  109. package/dist/tools/rollback-changes.js +66 -14
  110. package/dist/tools/run-angular-cli.d.ts +45 -2
  111. package/dist/tools/run-angular-cli.js +67 -7
  112. package/dist/tools/run-build.d.ts +114 -2
  113. package/dist/tools/run-build.js +117 -8
  114. package/dist/tools/run-schematic.d.ts +70 -2
  115. package/dist/tools/run-schematic.js +104 -10
  116. package/dist/tools/scan-all.d.ts +19 -11
  117. package/dist/tools/scan-all.js +139 -131
  118. package/dist/tools/scan-angular.d.ts +19 -10
  119. package/dist/tools/scan-angular.js +51 -23
  120. package/dist/tools/scan-architecture.d.ts +17 -10
  121. package/dist/tools/scan-architecture.js +93 -31
  122. package/dist/tools/scan-solid.d.ts +19 -10
  123. package/dist/tools/scan-solid.js +51 -23
  124. package/dist/tools/search-codebase.d.ts +82 -1
  125. package/dist/tools/search-codebase.js +55 -2
  126. package/dist/tools/server-status.d.ts +279 -5
  127. package/dist/tools/server-status.js +179 -5
  128. package/dist/tools/suggest-improvements.d.ts +97 -5
  129. package/dist/tools/suggest-improvements.js +80 -44
  130. package/dist/tools/trace-output-flow.d.ts +682 -2
  131. package/dist/tools/trace-output-flow.js +375 -15
  132. package/dist/tools/transform-code-batch.d.ts +3 -0
  133. package/dist/tools/transform-code-batch.js +10 -5
  134. package/dist/tools/transform-code.d.ts +335 -12
  135. package/dist/tools/transform-code.js +649 -608
  136. package/dist/tools/validate-before-transform.d.ts +116 -2
  137. package/dist/tools/validate-before-transform.js +55 -2
  138. package/dist/tools/validate-project-compatibility.d.ts +64 -2
  139. package/dist/tools/validate-project-compatibility.js +67 -4
  140. package/dist/tools/validate-transformation.d.ts +220 -2
  141. package/dist/tools/validate-transformation.js +113 -15
  142. package/dist/tools/verify-citations.d.ts +181 -0
  143. package/dist/tools/verify-citations.js +218 -0
  144. package/dist/types.d.ts +38 -1
  145. package/dist/utils/format-tool-response.d.ts +22 -59
  146. package/dist/utils/format-tool-response.js +25 -134
  147. package/package.json +30 -13
  148. package/dist/cli.d.ts.map +0 -1
  149. package/dist/cli.js.map +0 -1
  150. package/dist/core/project-analyzer.d.ts.map +0 -1
  151. package/dist/core/project-analyzer.js.map +0 -1
  152. package/dist/index.d.ts.map +0 -1
  153. package/dist/index.js.map +0 -1
  154. package/dist/mcp-watcher.d.ts.map +0 -1
  155. package/dist/mcp-watcher.js.map +0 -1
  156. package/dist/server/json-rpc-handler.d.ts +0 -98
  157. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  158. package/dist/server/json-rpc-handler.js +0 -301
  159. package/dist/server/json-rpc-handler.js.map +0 -1
  160. package/dist/server/mcp-server.d.ts.map +0 -1
  161. package/dist/server/mcp-server.js.map +0 -1
  162. package/dist/server/stdio-guard.d.ts.map +0 -1
  163. package/dist/server/stdio-guard.js.map +0 -1
  164. package/dist/server/tool-registry.d.ts.map +0 -1
  165. package/dist/server/tool-registry.js.map +0 -1
  166. package/dist/streaming/progress-store.d.ts.map +0 -1
  167. package/dist/streaming/progress-store.js.map +0 -1
  168. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  169. package/dist/tools/analyze-build-impact.js.map +0 -1
  170. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  171. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  172. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  173. package/dist/tools/analyze-parser-performance.js.map +0 -1
  174. package/dist/tools/analyze-project.d.ts.map +0 -1
  175. package/dist/tools/analyze-project.js.map +0 -1
  176. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  177. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  178. package/dist/tools/collect-feedback.d.ts.map +0 -1
  179. package/dist/tools/collect-feedback.js.map +0 -1
  180. package/dist/tools/extract-libraries.d.ts.map +0 -1
  181. package/dist/tools/extract-libraries.js.map +0 -1
  182. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  183. package/dist/tools/find-angular-symbol.js.map +0 -1
  184. package/dist/tools/find-component-hosts.d.ts.map +0 -1
  185. package/dist/tools/find-component-hosts.js.map +0 -1
  186. package/dist/tools/find-usages.d.ts.map +0 -1
  187. package/dist/tools/find-usages.js.map +0 -1
  188. package/dist/tools/get-bootstrap-execution.d.ts.map +0 -1
  189. package/dist/tools/get-bootstrap-execution.js.map +0 -1
  190. package/dist/tools/get-call-graph.d.ts.map +0 -1
  191. package/dist/tools/get-call-graph.js.map +0 -1
  192. package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
  193. package/dist/tools/get-operation-progress-tool.js.map +0 -1
  194. package/dist/tools/get-operation-progress.d.ts.map +0 -1
  195. package/dist/tools/get-operation-progress.js.map +0 -1
  196. package/dist/tools/helpers/compact-output.d.ts.map +0 -1
  197. package/dist/tools/helpers/compact-output.js.map +0 -1
  198. package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
  199. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  200. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  201. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  202. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  203. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  204. package/dist/tools/helpers/project-cache.d.ts.map +0 -1
  205. package/dist/tools/helpers/project-cache.js.map +0 -1
  206. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  207. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  208. package/dist/tools/helpers/rule-runner.d.ts.map +0 -1
  209. package/dist/tools/helpers/rule-runner.js.map +0 -1
  210. package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
  211. package/dist/tools/helpers/scan-plan.js.map +0 -1
  212. package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
  213. package/dist/tools/helpers/stack-frame-file-index.js.map +0 -1
  214. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  215. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  216. package/dist/tools/inspect-form-group.d.ts.map +0 -1
  217. package/dist/tools/inspect-form-group.js.map +0 -1
  218. package/dist/tools/inspect-i18n.d.ts.map +0 -1
  219. package/dist/tools/inspect-i18n.js.map +0 -1
  220. package/dist/tools/inspect-template.d.ts.map +0 -1
  221. package/dist/tools/inspect-template.js.map +0 -1
  222. package/dist/tools/learn-patterns.d.ts.map +0 -1
  223. package/dist/tools/learn-patterns.js.map +0 -1
  224. package/dist/tools/list-imports.d.ts.map +0 -1
  225. package/dist/tools/list-imports.js.map +0 -1
  226. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  227. package/dist/tools/orchestrate-migration.js.map +0 -1
  228. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  229. package/dist/tools/parse-stack-trace.js.map +0 -1
  230. package/dist/tools/plan-migration.d.ts.map +0 -1
  231. package/dist/tools/plan-migration.js.map +0 -1
  232. package/dist/tools/resolve-type.d.ts.map +0 -1
  233. package/dist/tools/resolve-type.js.map +0 -1
  234. package/dist/tools/review-feedback.d.ts.map +0 -1
  235. package/dist/tools/review-feedback.js.map +0 -1
  236. package/dist/tools/rollback-changes.d.ts.map +0 -1
  237. package/dist/tools/rollback-changes.js.map +0 -1
  238. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  239. package/dist/tools/run-angular-cli.js.map +0 -1
  240. package/dist/tools/run-build.d.ts.map +0 -1
  241. package/dist/tools/run-build.js.map +0 -1
  242. package/dist/tools/run-schematic.d.ts.map +0 -1
  243. package/dist/tools/run-schematic.js.map +0 -1
  244. package/dist/tools/scan-all.d.ts.map +0 -1
  245. package/dist/tools/scan-all.js.map +0 -1
  246. package/dist/tools/scan-angular.d.ts.map +0 -1
  247. package/dist/tools/scan-angular.js.map +0 -1
  248. package/dist/tools/scan-architecture.d.ts.map +0 -1
  249. package/dist/tools/scan-architecture.js.map +0 -1
  250. package/dist/tools/scan-solid.d.ts.map +0 -1
  251. package/dist/tools/scan-solid.js.map +0 -1
  252. package/dist/tools/search-codebase.d.ts.map +0 -1
  253. package/dist/tools/search-codebase.js.map +0 -1
  254. package/dist/tools/server-status.d.ts.map +0 -1
  255. package/dist/tools/server-status.js.map +0 -1
  256. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  257. package/dist/tools/shared/scan-types.js.map +0 -1
  258. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  259. package/dist/tools/suggest-improvements.js.map +0 -1
  260. package/dist/tools/trace-output-flow.d.ts.map +0 -1
  261. package/dist/tools/trace-output-flow.js.map +0 -1
  262. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  263. package/dist/tools/transform-code-batch.js.map +0 -1
  264. package/dist/tools/transform-code.d.ts.map +0 -1
  265. package/dist/tools/transform-code.js.map +0 -1
  266. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  267. package/dist/tools/validate-before-transform.js.map +0 -1
  268. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  269. package/dist/tools/validate-project-compatibility.js.map +0 -1
  270. package/dist/tools/validate-transformation.d.ts.map +0 -1
  271. package/dist/tools/validate-transformation.js.map +0 -1
  272. package/dist/types.d.ts.map +0 -1
  273. package/dist/types.js.map +0 -1
  274. package/dist/utils/format-tool-response.d.ts.map +0 -1
  275. package/dist/utils/format-tool-response.js.map +0 -1
@@ -8,15 +8,61 @@
8
8
  import { spawn, execSync } from 'node:child_process';
9
9
  import { existsSync, readFileSync } from 'node:fs';
10
10
  import { join } from 'node:path';
11
- import { loadConfig, } from '@angular-modernizer/core';
11
+ import { loadConfig, processGroupOptions, terminateOnAbort, terminateProcessTree, } from '@angular-modernizer/core';
12
+ import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
13
+ import { STRING_ARRAY } from './helpers/investigation-schemas.js';
14
+ import { outputTail, seconds } from './helpers/process-output.js';
15
+ /** Build warnings spelled out in the summary; the rest is in `warnings`. */
16
+ const SUMMARY_BUILD_WARNINGS = 5;
17
+ /** Text summary: outcome, build mode, warnings, blockers and the tail of the output on failure. */
18
+ function describeBuild(result) {
19
+ const ending = result.timedOut === true
20
+ ? `timed out after ${seconds(result.executionTime)}`
21
+ : `exited ${result.exitCode} after ${seconds(result.executionTime)}`;
22
+ const lines = [
23
+ `Build ${result.success ? 'passed' : 'failed'} (${result.buildSystem}): \`${result.fullCommand}\` ${ending}.`,
24
+ ];
25
+ const inc = result.incremental;
26
+ if (inc !== undefined) {
27
+ lines.push(inc.enabled
28
+ ? `Incremental (${inc.scope ?? 'unknown scope'}): ${inc.filesBuilt ?? 0} file(s) built, ` +
29
+ `${inc.filesSkipped ?? 0} skipped${inc.speedup === undefined ? '' : `; ${inc.speedup}`}.`
30
+ : `Full build${inc.fallbackReason === undefined ? '' : `: ${inc.fallbackReason}`}.`);
31
+ }
32
+ const blockers = (result.incompatibilityIssues ?? []).filter((i) => i.detected && i.severity === 'blocker');
33
+ if (blockers.length > 0) {
34
+ lines.push(`Blockers for incremental builds: ${blockers.map((b) => b.type).join(', ')}.`);
35
+ }
36
+ const warnings = result.warnings ?? [];
37
+ if (warnings.length > 0) {
38
+ lines.push(`${warnings.length} build warning(s):`);
39
+ lines.push(...warnings.slice(0, SUMMARY_BUILD_WARNINGS).map((w) => `- ${w}`));
40
+ }
41
+ if (!result.success) {
42
+ const tail = outputTail(result.errors) ?? outputTail(result.output);
43
+ if (tail !== undefined) {
44
+ lines.push(`Last output:\n${tail}`);
45
+ }
46
+ }
47
+ return lines.join('\n');
48
+ }
12
49
  /**
13
50
  * MCP tool for executing build systems.
14
51
  */
15
52
  export class RunBuildTool {
16
53
  name = 'run-build';
17
- description = 'Execute build systems to validate code transformations. Supports incremental mode for 2-4x faster builds by validating only changed files and their dependencies. Automatically detects incompatibilities and falls back to full build when needed.';
54
+ title = 'Run Build';
55
+ annotations = {
56
+ readOnlyHint: false,
57
+ destructiveHint: true,
58
+ idempotentHint: true,
59
+ openWorldHint: false,
60
+ };
61
+ description = 'Execute build systems to validate code transformations. Supports incremental mode for 2-4x faster builds by validating only changed files and their dependencies. Automatically detects incompatibilities and falls back to full build when needed. ' +
62
+ 'The result has the full build output; summary is a short text with the outcome, the build mode and, on failure, the last output lines.';
18
63
  inputSchema = {
19
64
  type: 'object',
65
+ additionalProperties: false,
20
66
  properties: {
21
67
  rootPath: {
22
68
  type: 'string',
@@ -75,7 +121,57 @@ export class RunBuildTool {
75
121
  },
76
122
  required: ['rootPath'],
77
123
  };
78
- async execute(args) {
124
+ outputSchema = {
125
+ type: 'object',
126
+ properties: {
127
+ success: { type: 'boolean' },
128
+ buildSystem: { type: 'string' },
129
+ command: { type: 'string' },
130
+ fullCommand: { type: 'string' },
131
+ exitCode: { type: 'integer' },
132
+ output: { type: 'string' },
133
+ errors: { type: 'string' },
134
+ executionTime: { type: 'number' },
135
+ timedOut: { type: 'boolean' },
136
+ artifacts: STRING_ARRAY,
137
+ warnings: {
138
+ type: 'array',
139
+ items: { type: 'string' },
140
+ description: 'Warnings the build printed.',
141
+ },
142
+ incremental: {
143
+ type: 'object',
144
+ properties: {
145
+ enabled: { type: 'boolean' },
146
+ scope: { type: 'string' },
147
+ filesBuilt: { type: 'integer' },
148
+ filesSkipped: { type: 'integer' },
149
+ cacheHit: { type: 'boolean' },
150
+ speedup: { type: 'string' },
151
+ fallbackReason: { type: 'string' },
152
+ },
153
+ required: ['enabled'],
154
+ },
155
+ incompatibilityIssues: INCOMPATIBILITY_ISSUES_SCHEMA,
156
+ summary: { type: 'string' },
157
+ },
158
+ required: [
159
+ 'success',
160
+ 'buildSystem',
161
+ 'command',
162
+ 'fullCommand',
163
+ 'exitCode',
164
+ 'output',
165
+ 'errors',
166
+ 'executionTime',
167
+ 'summary',
168
+ ],
169
+ };
170
+ async execute(args, ctx = {}) {
171
+ const result = await this.runBuild(args, ctx.signal);
172
+ return { ...result, summary: describeBuild(result) };
173
+ }
174
+ async runBuild(args, signal) {
79
175
  const params = args;
80
176
  if (!params.rootPath) {
81
177
  throw new Error('rootPath is required');
@@ -117,10 +213,13 @@ export class RunBuildTool {
117
213
  // Attempt incremental build if enabled
118
214
  if (attemptIncremental) {
119
215
  try {
120
- return await this.executeIncrementalBuild(rootPath, params, systemInfo, options, timeout);
216
+ return await this.executeIncrementalBuild(rootPath, params, systemInfo, options, timeout, signal);
121
217
  }
122
218
  catch (error) {
123
- // Fallback to full build on any error
219
+ // A cancelled build stops; any other error falls back to a full build
220
+ if (signal?.aborted === true) {
221
+ throw error;
222
+ }
124
223
  incrementalMetadata = {
125
224
  enabled: false,
126
225
  fallbackReason: error instanceof Error
@@ -135,6 +234,7 @@ export class RunBuildTool {
135
234
  const result = await this.executeBuildCommand(buildArgs, {
136
235
  cwd: rootPath,
137
236
  timeout,
237
+ signal,
138
238
  });
139
239
  const executionTime = Date.now() - startTime;
140
240
  const { warnings, artifacts } = this.parseBuildOutput(result.stdout);
@@ -215,7 +315,7 @@ export class RunBuildTool {
215
315
  /**
216
316
  * Executes an incremental build using IncompatibilityDetector and IncrementalBuildValidator
217
317
  */
218
- async executeIncrementalBuild(rootPath, params, systemInfo, options, timeout) {
318
+ async executeIncrementalBuild(rootPath, params, systemInfo, options, timeout, signal) {
219
319
  // Dynamic import to avoid circular dependencies
220
320
  const { Project } = await import('ts-morph');
221
321
  const { IncompatibilityDetector, IncrementalBuildValidator, IncrementalAnalyzer, } = await import('@angular-modernizer/core');
@@ -237,6 +337,7 @@ export class RunBuildTool {
237
337
  const result = await this.executeBuildCommand(buildArgs, {
238
338
  cwd: rootPath,
239
339
  timeout,
340
+ signal,
240
341
  });
241
342
  const executionTime = Date.now() - startTime;
242
343
  const { warnings, artifacts } = this.parseBuildOutput(result.stdout);
@@ -313,6 +414,7 @@ export class RunBuildTool {
313
414
  baseBranch: 'HEAD',
314
415
  forceFiles: params.changedFiles,
315
416
  includeDependents: true,
417
+ signal,
316
418
  });
317
419
  // Calculate speedup with better messaging
318
420
  const fullBuildEstimate = validationResult.scope.estimatedBuildTime * 1000;
@@ -494,16 +596,19 @@ export class RunBuildTool {
494
596
  stdio: ['pipe', 'pipe', 'pipe'],
495
597
  shell: true,
496
598
  env: { ...process.env, CI: 'true' },
599
+ ...processGroupOptions(),
497
600
  });
498
601
  let stdout = '';
499
602
  let stderr = '';
500
- // Set up timeout
603
+ // Set up timeout; the build runs under a shell, so the whole process tree goes
501
604
  const timeoutId = setTimeout(() => {
502
- buildProcess.kill('SIGTERM');
605
+ terminateProcessTree(buildProcess);
503
606
  reject(new Error(`Build command timed out after ${options.timeout}ms`));
504
607
  }, options.timeout);
608
+ const stopOnAbort = terminateOnAbort(buildProcess, options.signal);
505
609
  const cleanup = () => {
506
610
  clearTimeout(timeoutId);
611
+ stopOnAbort();
507
612
  };
508
613
  buildProcess.stdout.on('data', (data) => {
509
614
  stdout += data.toString();
@@ -513,6 +618,10 @@ export class RunBuildTool {
513
618
  });
514
619
  buildProcess.on('close', (code) => {
515
620
  cleanup();
621
+ if (options.signal?.aborted === true) {
622
+ reject(new Error('Build cancelled'));
623
+ return;
624
+ }
516
625
  resolve({
517
626
  exitCode: code ?? 0,
518
627
  stdout,
@@ -5,7 +5,7 @@
5
5
  * Enables AI assistants to run code generation and migration schematics
6
6
  * from built-in Angular collections or custom schematic libraries.
7
7
  */
8
- import { type MCPTool } from '../types.js';
8
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
9
9
  /**
10
10
  * Result of schematic execution.
11
11
  */
@@ -66,15 +66,22 @@ interface SchematicResult {
66
66
  * Warnings or informational messages.
67
67
  */
68
68
  warnings: string[];
69
+ /**
70
+ * Short text: command, exit code, generated files, conflicts, and the last output lines on failure.
71
+ */
72
+ summary: string;
69
73
  }
70
74
  /**
71
75
  * MCP tool for executing Angular schematics.
72
76
  */
73
77
  export declare class RunSchematicTool implements MCPTool {
74
78
  name: string;
79
+ title: string;
80
+ annotations: ToolAnnotations;
75
81
  description: string;
76
82
  inputSchema: {
77
83
  type: string;
84
+ additionalProperties: boolean;
78
85
  properties: {
79
86
  schematic: {
80
87
  type: string;
@@ -131,7 +138,68 @@ export declare class RunSchematicTool implements MCPTool {
131
138
  };
132
139
  required: string[];
133
140
  };
134
- execute(args: Record<string, unknown>): Promise<SchematicResult>;
141
+ outputSchema: {
142
+ type: string;
143
+ properties: {
144
+ success: {
145
+ type: string;
146
+ };
147
+ schematic: {
148
+ type: string;
149
+ };
150
+ collection: {
151
+ type: string;
152
+ };
153
+ target: {
154
+ type: string;
155
+ };
156
+ fullCommand: {
157
+ type: string;
158
+ };
159
+ exitCode: {
160
+ type: string;
161
+ };
162
+ stdout: {
163
+ type: string;
164
+ };
165
+ stderr: {
166
+ type: string;
167
+ };
168
+ filesGenerated: {
169
+ readonly type: "array";
170
+ readonly items: {
171
+ readonly type: "string";
172
+ };
173
+ };
174
+ conflicts: {
175
+ readonly type: "array";
176
+ readonly items: {
177
+ readonly type: "string";
178
+ };
179
+ };
180
+ executionTime: {
181
+ type: string;
182
+ };
183
+ timedOut: {
184
+ type: string;
185
+ };
186
+ cwd: {
187
+ type: string;
188
+ };
189
+ warnings: {
190
+ type: string;
191
+ items: {
192
+ type: string;
193
+ };
194
+ description: string;
195
+ };
196
+ summary: {
197
+ type: string;
198
+ };
199
+ };
200
+ required: string[];
201
+ };
202
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<SchematicResult>;
135
203
  /**
136
204
  * Validate schematic name format.
137
205
  */
@@ -6,8 +6,43 @@
6
6
  * from built-in Angular collections or custom schematic libraries.
7
7
  */
8
8
  import { spawn } from 'node:child_process';
9
+ import { processGroupOptions, terminateOnAbort, terminateProcessTree, } from '@angular-modernizer/core';
9
10
  import { existsSync } from 'node:fs';
10
11
  import { resolve, dirname } from 'node:path';
12
+ import { STRING_ARRAY } from './helpers/investigation-schemas.js';
13
+ import { outputTail, seconds } from './helpers/process-output.js';
14
+ /** Generated files spelled out in the summary; the rest is in `filesGenerated`. */
15
+ const SUMMARY_FILES = 10;
16
+ /** Text summary: outcome, files, conflicts, warnings and the tail of the output on failure. */
17
+ function describeSchematic(result) {
18
+ const ending = result.timedOut === true
19
+ ? `timed out after ${seconds(result.executionTime)}`
20
+ : `exited ${result.exitCode} after ${seconds(result.executionTime)}`;
21
+ const lines = [
22
+ `Schematic ${result.collection}:${result.schematic} ${result.success ? 'passed' : 'failed'}: ` +
23
+ `\`${result.fullCommand}\` ${ending} in ${result.cwd}.`,
24
+ ];
25
+ if (result.filesGenerated.length > 0) {
26
+ lines.push(`${result.filesGenerated.length} file(s) generated or updated:`);
27
+ lines.push(...result.filesGenerated.slice(0, SUMMARY_FILES).map((f) => `- ${f}`));
28
+ }
29
+ if (result.conflicts.length > 0) {
30
+ lines.push(`${result.conflicts.length} conflict(s): ${result.conflicts.join('; ')}`);
31
+ }
32
+ if (result.warnings.length > 0) {
33
+ lines.push(`${result.warnings.length} warning(s).`);
34
+ }
35
+ if (!result.success) {
36
+ const tail = outputTail(result.stderr) ?? outputTail(result.stdout);
37
+ if (tail !== undefined) {
38
+ lines.push(`Last output:\n${tail}`);
39
+ }
40
+ }
41
+ return lines.join('\n');
42
+ }
43
+ function withSummary(result) {
44
+ return { ...result, summary: describeSchematic(result) };
45
+ }
11
46
  /**
12
47
  * Safe schematic options whitelist.
13
48
  * Only these options are allowed to prevent security issues and ensure compatibility.
@@ -44,7 +79,7 @@ const SAFE_SCHEMATIC_OPTIONS = new Set([
44
79
  // Additional safe options
45
80
  'dry-run',
46
81
  'force',
47
- 'skip-confirmation',
82
+ 'interactive',
48
83
  'defaults',
49
84
  ]);
50
85
  /**
@@ -52,9 +87,18 @@ const SAFE_SCHEMATIC_OPTIONS = new Set([
52
87
  */
53
88
  export class RunSchematicTool {
54
89
  name = 'run-schematic';
55
- description = 'Execute Angular schematics for code generation and automated migrations';
90
+ title = 'Run Schematic';
91
+ annotations = {
92
+ readOnlyHint: false,
93
+ destructiveHint: true,
94
+ idempotentHint: false,
95
+ openWorldHint: true,
96
+ };
97
+ description = 'Execute Angular schematics for code generation and automated migrations. ' +
98
+ 'The result has the full stdout and stderr; summary is a short text with the outcome, the generated files and, on failure, the last output lines.';
56
99
  inputSchema = {
57
100
  type: 'object',
101
+ additionalProperties: false,
58
102
  properties: {
59
103
  schematic: {
60
104
  type: 'string',
@@ -87,7 +131,7 @@ export class RunSchematicTool {
87
131
  },
88
132
  skipPrompts: {
89
133
  type: 'boolean',
90
- description: 'Skip interactive prompts',
134
+ description: 'Skip interactive prompts (passes --interactive=false to ng generate)',
91
135
  default: true,
92
136
  },
93
137
  dryRun: {
@@ -111,7 +155,47 @@ export class RunSchematicTool {
111
155
  },
112
156
  required: ['schematic', 'target'],
113
157
  };
114
- async execute(args) {
158
+ outputSchema = {
159
+ type: 'object',
160
+ properties: {
161
+ success: { type: 'boolean' },
162
+ schematic: { type: 'string' },
163
+ collection: { type: 'string' },
164
+ target: { type: 'string' },
165
+ fullCommand: { type: 'string' },
166
+ exitCode: { type: 'integer' },
167
+ stdout: { type: 'string' },
168
+ stderr: { type: 'string' },
169
+ filesGenerated: STRING_ARRAY,
170
+ conflicts: STRING_ARRAY,
171
+ executionTime: { type: 'number' },
172
+ timedOut: { type: 'boolean' },
173
+ cwd: { type: 'string' },
174
+ warnings: {
175
+ type: 'array',
176
+ items: { type: 'string' },
177
+ description: 'Warnings the schematic printed.',
178
+ },
179
+ summary: { type: 'string' },
180
+ },
181
+ required: [
182
+ 'success',
183
+ 'schematic',
184
+ 'collection',
185
+ 'target',
186
+ 'fullCommand',
187
+ 'exitCode',
188
+ 'stdout',
189
+ 'stderr',
190
+ 'filesGenerated',
191
+ 'conflicts',
192
+ 'executionTime',
193
+ 'cwd',
194
+ 'warnings',
195
+ 'summary',
196
+ ],
197
+ };
198
+ async execute(args, ctx = {}) {
115
199
  const params = args;
116
200
  // Validate required parameters
117
201
  if (!params.schematic || typeof params.schematic !== 'string') {
@@ -150,13 +234,14 @@ export class RunSchematicTool {
150
234
  const result = await this.executeSchematic(commandArgs, {
151
235
  cwd: projectRoot,
152
236
  timeout: executionOptions.timeout ?? 300000,
237
+ signal: ctx.signal,
153
238
  });
154
239
  const executionTime = Date.now() - startTime;
155
240
  // Parse output for generated files and conflicts
156
241
  const filesGenerated = this.extractGeneratedFiles(result.stdout);
157
242
  const conflicts = this.extractConflicts(result.stderr);
158
243
  const warnings = this.extractWarnings(result.stdout, result.stderr);
159
- return {
244
+ return withSummary({
160
245
  success: result.exitCode === 0,
161
246
  schematic,
162
247
  collection,
@@ -170,11 +255,11 @@ export class RunSchematicTool {
170
255
  executionTime,
171
256
  cwd: projectRoot,
172
257
  warnings,
173
- };
258
+ });
174
259
  }
175
260
  catch (error) {
176
261
  if (error instanceof Error && error.message.includes('timed out')) {
177
- return {
262
+ return withSummary({
178
263
  success: false,
179
264
  schematic,
180
265
  collection,
@@ -189,7 +274,7 @@ export class RunSchematicTool {
189
274
  timedOut: true,
190
275
  cwd: projectRoot,
191
276
  warnings: [],
192
- };
277
+ });
193
278
  }
194
279
  throw new Error(`Schematic execution failed: ${error instanceof Error ? error.message : String(error)}`);
195
280
  }
@@ -311,8 +396,10 @@ export class RunSchematicTool {
311
396
  if (executionOptions.force) {
312
397
  args.push('--force');
313
398
  }
399
+ // ng generate has no --skip-confirmation (only ng add and ng update do);
400
+ // --interactive=false turns the prompts off.
314
401
  if (executionOptions.skipPrompts ?? true) {
315
- args.push('--skip-confirmation');
402
+ args.push('--interactive=false');
316
403
  }
317
404
  return args;
318
405
  }
@@ -326,16 +413,19 @@ export class RunSchematicTool {
326
413
  env: process.env,
327
414
  stdio: ['pipe', 'pipe', 'pipe'],
328
415
  shell: true,
416
+ ...processGroupOptions(),
329
417
  });
330
418
  let stdout = '';
331
419
  let stderr = '';
332
420
  // Set up timeout
333
421
  const timeoutId = setTimeout(() => {
334
- ngProcess.kill('SIGTERM');
422
+ terminateProcessTree(ngProcess);
335
423
  reject(new Error(`Schematic execution timed out after ${options.timeout}ms`));
336
424
  }, options.timeout);
425
+ const stopOnAbort = terminateOnAbort(ngProcess, options.signal);
337
426
  const cleanup = () => {
338
427
  clearTimeout(timeoutId);
428
+ stopOnAbort();
339
429
  };
340
430
  ngProcess.stdout.on('data', (data) => {
341
431
  stdout += data.toString();
@@ -345,6 +435,10 @@ export class RunSchematicTool {
345
435
  });
346
436
  ngProcess.on('close', (code) => {
347
437
  cleanup();
438
+ if (options.signal?.aborted === true) {
439
+ reject(new Error('Command cancelled'));
440
+ return;
441
+ }
348
442
  resolve({
349
443
  exitCode: code ?? 0,
350
444
  stdout,
@@ -7,7 +7,9 @@
7
7
  * - ArchitecturePlugin (17 rules): Architectural issues
8
8
  * Total: 52 rules
9
9
  */
10
- import type { MCPTool } from '../types.js';
10
+ import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
11
+ import { type CancelledExecution } from './helpers/tool-context.js';
12
+ import { type ScanCounts } from './helpers/analysis-output.js';
11
13
  interface ScanAllResult {
12
14
  violations: {
13
15
  id: string;
@@ -21,13 +23,12 @@ interface ScanAllResult {
21
23
  suggestedFix?: string;
22
24
  metadata?: Record<string, unknown>;
23
25
  }[];
24
- summary: {
25
- totalViolations: number;
26
- analyzedFiles: number;
27
- bySeverity: Record<string, number>;
28
- byCategory: Record<string, number>;
29
- byRule: Record<string, number>;
30
- };
26
+ /** Counts over all violations, independent of the page. */
27
+ counts: ScanCounts;
28
+ /** Human-readable summary for LLM consumption. */
29
+ summary: string;
30
+ /** Set when the client cancelled the scan; counts cover the analyzed files. */
31
+ execution?: CancelledExecution;
31
32
  metadata: {
32
33
  rulesExecuted: string[];
33
34
  duration: number;
@@ -79,9 +80,12 @@ interface ScanAllResult {
79
80
  */
80
81
  export declare class ScanAllTool implements MCPTool {
81
82
  readonly name = "scan-all";
82
- readonly description = "Comprehensive code quality scan with all plugins (SOLID 7, Angular 28, Architecture 17: 52 rules total)";
83
+ readonly title = "Scan All Rules";
84
+ readonly annotations: ToolAnnotations;
85
+ readonly description: string;
83
86
  readonly inputSchema: {
84
87
  type: string;
88
+ additionalProperties: boolean;
85
89
  properties: {
86
90
  rootPath: {
87
91
  type: string;
@@ -148,13 +152,17 @@ export declare class ScanAllTool implements MCPTool {
148
152
  };
149
153
  required: string[];
150
154
  };
151
- execute(args: Record<string, unknown>): Promise<ScanAllResult>;
155
+ readonly outputSchema: {
156
+ type: "object";
157
+ properties: Record<string, unknown>;
158
+ required: string[];
159
+ };
160
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ScanAllResult>;
152
161
  /**
153
162
  * Load scan-all tool configuration from .angular-modernizer.json file.
154
163
  * Only loads from the provided root path to avoid cache directory issues.
155
164
  */
156
165
  private loadConfig;
157
- private calculateSummary;
158
166
  }
159
167
  export {};
160
168
  //# sourceMappingURL=scan-all.d.ts.map