@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,43 +1,95 @@
1
+ import { RollbackStrategy } from '@angular-modernizer/core';
2
+ import { createProjectRollbackManager, findProjectRootOf, } from './helpers/transform-safety.js';
3
+ import { STRING_ARRAY } from './helpers/investigation-schemas.js';
4
+ /** Restored files spelled out in the summary; the rest is in `files`. */
5
+ const SUMMARY_FILES = 10;
6
+ /** Text summary: outcome, strategy and the restored files, or the error. */
7
+ function describeRollback(result) {
8
+ const lines = [
9
+ `Rollback ${result.success ? 'done' : 'failed'} (${result.strategy}): ` +
10
+ `${result.files.length} file(s) restored` +
11
+ (result.error === undefined ? '.' : `; ${result.error}`),
12
+ ];
13
+ lines.push(...result.files.slice(0, SUMMARY_FILES).map((f) => `- ${f}`));
14
+ if (result.files.length > SUMMARY_FILES) {
15
+ lines.push(`... ${result.files.length - SUMMARY_FILES} more in files.`);
16
+ }
17
+ return lines.join('\n');
18
+ }
1
19
  /**
2
- * @angular-modernizer/adapter-mcp - Rollback Changes Tool
3
- *
4
20
  * MCP tool for rolling back transformations if validation fails or
5
21
  * changes are unsatisfactory. Uses either git stash or file-level backups.
6
22
  */
7
- import { RollbackManager, RollbackStrategy, } from '@angular-modernizer/core';
8
- /**
9
- * MCP tool for rollback operations.
10
- */
11
23
  export class RollbackChangesTool {
12
24
  name = 'rollback-changes';
13
- description = 'Rollback transformations if validation fails or changes are unsatisfactory. Uses git stash or file-level backups.';
25
+ title = 'Roll Back Changes';
26
+ annotations = {
27
+ readOnlyHint: false,
28
+ destructiveHint: true,
29
+ idempotentHint: false,
30
+ openWorldHint: false,
31
+ };
32
+ description = 'Rollback transformations if validation fails or changes are unsatisfactory. Restores the backups transform-code wrote into <projectRoot>/.angular-modernizer-backups (file copies, plus a git snapshot inside a git repository); without files it restores the files of the last transform-code call. ' +
33
+ 'summary is a short text with the outcome and the restored files.';
34
+ /**
35
+ * JSON Schema of the tool arguments.
36
+ * @hidden
37
+ */
14
38
  inputSchema = {
15
39
  type: 'object',
40
+ additionalProperties: false,
16
41
  properties: {
17
42
  files: {
18
43
  type: 'array',
19
44
  items: { type: 'string' },
20
- description: 'Specific files to rollback (optional - rolls back all if not specified)',
45
+ description: 'Specific files to rollback (optional - restores the files of the last transform-code call if not specified)',
21
46
  },
22
47
  strategy: {
23
48
  type: 'string',
24
49
  enum: ['auto', 'git-stash', 'file-backup'],
25
- description: 'Rollback strategy: "auto" (try git first, fallback to file), "git-stash", or "file-backup"',
50
+ description: 'Rollback strategy: "auto" (file backup first, then the git snapshot), "git-stash" (git snapshot recorded by transform-code; never applies a stash from the stash list), or "file-backup"',
26
51
  default: 'auto',
27
52
  },
28
53
  backupDir: {
29
54
  type: 'string',
30
- description: 'Custom backup directory for file backups (optional)',
55
+ description: 'Custom backup directory for file backups (optional - defaults to <projectRoot>/.angular-modernizer-backups)',
56
+ },
57
+ projectRoot: {
58
+ type: 'string',
59
+ description: 'Project root (optional - defaults to gitRoot, else the nearest folder with tsconfig.json, package.json or .angular-modernizer.json above the first file)',
31
60
  },
32
61
  gitRoot: {
33
62
  type: 'string',
34
- description: 'Git project root (optional - auto-detects if not specified)',
63
+ description: 'Git project root (optional - used as project root when projectRoot is not given)',
35
64
  },
36
65
  },
37
66
  };
67
+ /**
68
+ * JSON Schema of the tool result (`structuredContent`).
69
+ * @hidden
70
+ */
71
+ outputSchema = {
72
+ type: 'object',
73
+ properties: {
74
+ success: { type: 'boolean' },
75
+ strategy: { type: 'string', enum: ['git-stash', 'file-backup'] },
76
+ files: STRING_ARRAY,
77
+ error: { type: 'string' },
78
+ metadata: {
79
+ type: 'object',
80
+ properties: {
81
+ totalFiles: { type: 'integer' },
82
+ duration: { type: 'number' },
83
+ },
84
+ required: ['totalFiles'],
85
+ },
86
+ summary: { type: 'string' },
87
+ },
88
+ required: ['success', 'strategy', 'files', 'summary'],
89
+ };
38
90
  async execute(args) {
39
91
  const typedArgs = args;
40
- const { files, strategy = 'auto', backupDir, gitRoot } = typedArgs;
92
+ const { files, strategy = 'auto', backupDir, projectRoot, gitRoot, } = typedArgs;
41
93
  const startTime = Date.now();
42
94
  // Convert strategy string to RollbackStrategy enum
43
95
  let rollbackStrategy;
@@ -53,12 +105,15 @@ export class RollbackChangesTool {
53
105
  rollbackStrategy = RollbackStrategy.AUTO;
54
106
  break;
55
107
  }
56
- const config = {
57
- strategy: rollbackStrategy,
108
+ const firstFile = files?.[0];
109
+ const root = projectRoot ??
110
+ gitRoot ??
111
+ (firstFile ? findProjectRootOf(firstFile) : undefined) ??
112
+ process.cwd();
113
+ const rollbackManager = createProjectRollbackManager(root, {
58
114
  backupDir,
59
- gitRoot,
60
- };
61
- const rollbackManager = new RollbackManager(config);
115
+ strategy: rollbackStrategy,
116
+ });
62
117
  try {
63
118
  const result = await rollbackManager.rollback(files);
64
119
  const duration = Date.now() - startTime;
@@ -74,7 +129,7 @@ export class RollbackChangesTool {
74
129
  duration,
75
130
  },
76
131
  };
77
- return response;
132
+ return { ...response, summary: describeRollback(response) };
78
133
  }
79
134
  catch (error) {
80
135
  const duration = Date.now() - startTime;
@@ -88,7 +143,7 @@ export class RollbackChangesTool {
88
143
  duration,
89
144
  },
90
145
  };
91
- return errorResponse;
146
+ return { ...errorResponse, summary: describeRollback(errorResponse) };
92
147
  }
93
148
  }
94
149
  }
@@ -1,15 +1,8 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Run Angular CLI Tool
3
- *
4
- * MCP tool for executing Angular CLI commands programmatically.
5
- * Enables AI assistants to run ng commands for project management,
6
- * code generation, and build operations.
7
- */
8
- import { type MCPTool } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
9
2
  /**
10
3
  * Result of Angular CLI command execution.
11
4
  */
12
- interface AngularCliResult {
5
+ export interface AngularCliResult {
13
6
  /**
14
7
  * Whether the command executed successfully.
15
8
  */
@@ -46,15 +39,28 @@ interface AngularCliResult {
46
39
  * Working directory where command was executed.
47
40
  */
48
41
  cwd: string;
42
+ /**
43
+ * Short text: command, exit code, time, and the last output lines on failure.
44
+ */
45
+ summary: string;
49
46
  }
50
47
  /**
51
- * MCP tool for executing Angular CLI commands.
48
+ * MCP tool for executing Angular CLI commands programmatically.
49
+ * Enables AI assistants to run ng commands for project management,
50
+ * code generation, and build operations.
52
51
  */
53
52
  export declare class RunAngularCliTool implements MCPTool {
54
53
  name: string;
54
+ title: string;
55
+ annotations: ToolAnnotations;
55
56
  description: string;
57
+ /**
58
+ * JSON Schema of the tool arguments.
59
+ * @hidden
60
+ */
56
61
  inputSchema: {
57
62
  type: string;
63
+ additionalProperties: boolean;
58
64
  properties: {
59
65
  command: {
60
66
  type: string;
@@ -92,11 +98,50 @@ export declare class RunAngularCliTool implements MCPTool {
92
98
  };
93
99
  required: string[];
94
100
  };
95
- execute(args: Record<string, unknown>): Promise<AngularCliResult>;
101
+ /**
102
+ * JSON Schema of the tool result (`structuredContent`).
103
+ * @hidden
104
+ */
105
+ outputSchema: {
106
+ type: string;
107
+ properties: {
108
+ success: {
109
+ type: string;
110
+ };
111
+ command: {
112
+ type: string;
113
+ };
114
+ fullCommand: {
115
+ type: string;
116
+ };
117
+ exitCode: {
118
+ type: string;
119
+ };
120
+ stdout: {
121
+ type: string;
122
+ };
123
+ stderr: {
124
+ type: string;
125
+ };
126
+ executionTime: {
127
+ type: string;
128
+ };
129
+ timedOut: {
130
+ type: string;
131
+ };
132
+ cwd: {
133
+ type: string;
134
+ };
135
+ summary: {
136
+ type: string;
137
+ };
138
+ };
139
+ required: string[];
140
+ };
141
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<AngularCliResult>;
96
142
  /**
97
143
  * Execute an Angular CLI command.
98
144
  */
99
145
  private executeCommand;
100
146
  }
101
- export {};
102
147
  //# sourceMappingURL=run-angular-cli.d.ts.map
@@ -1,19 +1,44 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { processGroupOptions, terminateOnAbort, terminateProcessTree, } from '@angular-modernizer/core';
3
+ import { outputTail, seconds } from './helpers/process-output.js';
4
+ /** Text summary: what ran, how it ended, and the tail of stderr (or stdout) on failure. */
5
+ function describeCliRun(result) {
6
+ const ending = result.timedOut === true
7
+ ? `timed out after ${seconds(result.executionTime)}`
8
+ : `exited ${result.exitCode} after ${seconds(result.executionTime)}`;
9
+ const head = `\`${result.fullCommand}\` ${ending} in ${result.cwd}.`;
10
+ if (result.success) {
11
+ return head;
12
+ }
13
+ const tail = outputTail(result.stderr) ?? outputTail(result.stdout);
14
+ return tail === undefined ? head : `${head}\nLast output:\n${tail}`;
15
+ }
16
+ function withSummary(result) {
17
+ return { ...result, summary: describeCliRun(result) };
18
+ }
1
19
  /**
2
- * @angular-modernizer/adapter-mcp - Run Angular CLI Tool
3
- *
4
20
  * MCP tool for executing Angular CLI commands programmatically.
5
21
  * Enables AI assistants to run ng commands for project management,
6
22
  * code generation, and build operations.
7
23
  */
8
- import { spawn } from 'node:child_process';
9
- /**
10
- * MCP tool for executing Angular CLI commands.
11
- */
12
24
  export class RunAngularCliTool {
13
25
  name = 'run-angular-cli';
14
- description = 'Execute Angular CLI commands for project management and code generation';
26
+ title = 'Run Angular CLI';
27
+ annotations = {
28
+ readOnlyHint: false,
29
+ destructiveHint: true,
30
+ idempotentHint: false,
31
+ openWorldHint: true,
32
+ };
33
+ description = 'Execute Angular CLI commands for project management and code generation. ' +
34
+ 'The result has the full stdout and stderr; summary is a short text with the exit code and, on failure, the last output lines.';
35
+ /**
36
+ * JSON Schema of the tool arguments.
37
+ * @hidden
38
+ */
15
39
  inputSchema = {
16
40
  type: 'object',
41
+ additionalProperties: false,
17
42
  properties: {
18
43
  command: {
19
44
  type: 'string',
@@ -57,7 +82,37 @@ export class RunAngularCliTool {
57
82
  },
58
83
  required: ['command'],
59
84
  };
60
- async execute(args) {
85
+ /**
86
+ * JSON Schema of the tool result (`structuredContent`).
87
+ * @hidden
88
+ */
89
+ outputSchema = {
90
+ type: 'object',
91
+ properties: {
92
+ success: { type: 'boolean' },
93
+ command: { type: 'string' },
94
+ fullCommand: { type: 'string' },
95
+ exitCode: { type: 'integer' },
96
+ stdout: { type: 'string' },
97
+ stderr: { type: 'string' },
98
+ executionTime: { type: 'number' },
99
+ timedOut: { type: 'boolean' },
100
+ cwd: { type: 'string' },
101
+ summary: { type: 'string' },
102
+ },
103
+ required: [
104
+ 'success',
105
+ 'command',
106
+ 'fullCommand',
107
+ 'exitCode',
108
+ 'stdout',
109
+ 'stderr',
110
+ 'executionTime',
111
+ 'cwd',
112
+ 'summary',
113
+ ],
114
+ };
115
+ async execute(args, ctx = {}) {
61
116
  const params = args;
62
117
  if (!params.command) {
63
118
  throw new Error('command is required');
@@ -77,9 +132,10 @@ export class RunAngularCliTool {
77
132
  cwd,
78
133
  env,
79
134
  timeout,
135
+ signal: ctx.signal,
80
136
  });
81
137
  const executionTime = Date.now() - startTime;
82
- return {
138
+ return withSummary({
83
139
  success: result.exitCode === 0,
84
140
  command,
85
141
  fullCommand,
@@ -88,11 +144,11 @@ export class RunAngularCliTool {
88
144
  stderr: result.stderr,
89
145
  executionTime,
90
146
  cwd,
91
- };
147
+ });
92
148
  }
93
149
  catch (error) {
94
150
  if (error instanceof Error && error.message.includes('timed out')) {
95
- return {
151
+ return withSummary({
96
152
  success: false,
97
153
  command,
98
154
  fullCommand,
@@ -102,7 +158,7 @@ export class RunAngularCliTool {
102
158
  executionTime: timeout,
103
159
  timedOut: true,
104
160
  cwd,
105
- };
161
+ });
106
162
  }
107
163
  throw new Error(`Angular CLI command failed: ${error instanceof Error ? error.message : String(error)}`);
108
164
  }
@@ -117,16 +173,19 @@ export class RunAngularCliTool {
117
173
  env: options.env,
118
174
  stdio: ['pipe', 'pipe', 'pipe'],
119
175
  shell: true,
176
+ ...processGroupOptions(),
120
177
  });
121
178
  let stdout = '';
122
179
  let stderr = '';
123
180
  // Set up timeout
124
181
  const timeoutId = setTimeout(() => {
125
- ngProcess.kill('SIGTERM');
182
+ terminateProcessTree(ngProcess);
126
183
  reject(new Error(`Command timed out after ${options.timeout}ms`));
127
184
  }, options.timeout);
185
+ const stopOnAbort = terminateOnAbort(ngProcess, options.signal);
128
186
  const cleanup = () => {
129
187
  clearTimeout(timeoutId);
188
+ stopOnAbort();
130
189
  };
131
190
  ngProcess.stdout.on('data', (data) => {
132
191
  stdout += data.toString();
@@ -136,6 +195,10 @@ export class RunAngularCliTool {
136
195
  });
137
196
  ngProcess.on('close', (code) => {
138
197
  cleanup();
198
+ if (options.signal?.aborted === true) {
199
+ reject(new Error('Command cancelled'));
200
+ return;
201
+ }
139
202
  resolve({
140
203
  exitCode: code ?? 0,
141
204
  stdout,
@@ -1,16 +1,9 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Run Build Tool
3
- *
4
- * MCP tool for executing build systems and validating code transformations.
5
- * Supports Angular CLI, Nx, Webpack, Vite, and auto-detection.
6
- * Includes incremental build mode for efficient validation.
7
- */
8
- import { type MCPTool } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
9
2
  import { type IncompatibilityCheck } from '@angular-modernizer/core';
10
3
  /**
11
4
  * Incremental build metadata
12
5
  */
13
- interface IncrementalMetadata {
6
+ export interface IncrementalMetadata {
14
7
  /**
15
8
  * Whether incremental mode was enabled
16
9
  */
@@ -43,7 +36,7 @@ interface IncrementalMetadata {
43
36
  /**
44
37
  * Build execution result.
45
38
  */
46
- interface BuildResult {
39
+ export interface BuildResult {
47
40
  /**
48
41
  * Whether the build was successful.
49
42
  */
@@ -96,15 +89,28 @@ interface BuildResult {
96
89
  * Incompatibility issues detected (if incremental mode was blocked)
97
90
  */
98
91
  incompatibilityIssues?: IncompatibilityCheck[];
92
+ /**
93
+ * Short text: command, exit code, time, build mode, and the last output lines on failure.
94
+ */
95
+ summary: string;
99
96
  }
100
97
  /**
101
- * MCP tool for executing build systems.
98
+ * MCP tool for executing build systems and validating code transformations.
99
+ * Supports Angular CLI, Nx, Webpack, Vite, and auto-detection.
100
+ * Includes incremental build mode for efficient validation.
102
101
  */
103
102
  export declare class RunBuildTool implements MCPTool {
104
103
  name: string;
104
+ title: string;
105
+ annotations: ToolAnnotations;
105
106
  description: string;
107
+ /**
108
+ * JSON Schema of the tool arguments.
109
+ * @hidden
110
+ */
106
111
  inputSchema: {
107
112
  type: string;
113
+ additionalProperties: boolean;
108
114
  properties: {
109
115
  rootPath: {
110
116
  type: string;
@@ -167,7 +173,116 @@ export declare class RunBuildTool implements MCPTool {
167
173
  };
168
174
  required: string[];
169
175
  };
170
- execute(args: Record<string, unknown>): Promise<BuildResult>;
176
+ /**
177
+ * JSON Schema of the tool result (`structuredContent`).
178
+ * @hidden
179
+ */
180
+ outputSchema: {
181
+ type: string;
182
+ properties: {
183
+ success: {
184
+ type: string;
185
+ };
186
+ buildSystem: {
187
+ type: string;
188
+ };
189
+ command: {
190
+ type: string;
191
+ };
192
+ fullCommand: {
193
+ type: string;
194
+ };
195
+ exitCode: {
196
+ type: string;
197
+ };
198
+ output: {
199
+ type: string;
200
+ };
201
+ errors: {
202
+ type: string;
203
+ };
204
+ executionTime: {
205
+ type: string;
206
+ };
207
+ timedOut: {
208
+ type: string;
209
+ };
210
+ artifacts: {
211
+ readonly type: "array";
212
+ readonly items: {
213
+ readonly type: "string";
214
+ };
215
+ };
216
+ warnings: {
217
+ type: string;
218
+ items: {
219
+ type: string;
220
+ };
221
+ description: string;
222
+ };
223
+ incremental: {
224
+ type: string;
225
+ properties: {
226
+ enabled: {
227
+ type: string;
228
+ };
229
+ scope: {
230
+ type: string;
231
+ };
232
+ filesBuilt: {
233
+ type: string;
234
+ };
235
+ filesSkipped: {
236
+ type: string;
237
+ };
238
+ cacheHit: {
239
+ type: string;
240
+ };
241
+ speedup: {
242
+ type: string;
243
+ };
244
+ fallbackReason: {
245
+ type: string;
246
+ };
247
+ };
248
+ required: string[];
249
+ };
250
+ incompatibilityIssues: {
251
+ readonly type: "array";
252
+ readonly items: {
253
+ readonly type: "object";
254
+ readonly properties: {
255
+ readonly type: {
256
+ readonly type: "string";
257
+ };
258
+ readonly detected: {
259
+ readonly type: "boolean";
260
+ };
261
+ readonly severity: {
262
+ readonly type: "string";
263
+ readonly enum: readonly ["blocker", "warning"];
264
+ };
265
+ readonly message: {
266
+ readonly type: "string";
267
+ };
268
+ readonly recommendation: {
269
+ readonly type: "string";
270
+ };
271
+ readonly details: {
272
+ readonly type: "object";
273
+ };
274
+ };
275
+ readonly required: readonly ["type", "detected", "severity", "message", "recommendation"];
276
+ };
277
+ };
278
+ summary: {
279
+ type: string;
280
+ };
281
+ };
282
+ required: string[];
283
+ };
284
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<BuildResult>;
285
+ private runBuild;
171
286
  /**
172
287
  * Detects changed files using git status
173
288
  */
@@ -197,5 +312,4 @@ export declare class RunBuildTool implements MCPTool {
197
312
  */
198
313
  private parseBuildOutput;
199
314
  }
200
- export {};
201
315
  //# sourceMappingURL=run-build.d.ts.map