@angular-modernizer/adapter-mcp 0.2.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 (255) hide show
  1. package/README.md +188 -235
  2. package/dist/cli.js +77 -27
  3. package/dist/index.d.ts +11 -3
  4. package/dist/index.js +10 -2
  5. package/dist/mcp-watcher.d.ts +6 -1
  6. package/dist/mcp-watcher.js +14 -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 +41 -12
  10. package/dist/server/mcp-server.js +113 -94
  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/stdio-guard.d.ts +20 -0
  16. package/dist/server/stdio-guard.js +48 -0
  17. package/dist/server/tool-registry.d.ts +3 -2
  18. package/dist/server/tool-registry.js +5 -5
  19. package/dist/tools/analyze-build-impact.d.ts +346 -14
  20. package/dist/tools/analyze-build-impact.js +315 -31
  21. package/dist/tools/analyze-core-to-shared.d.ts +134 -4
  22. package/dist/tools/analyze-core-to-shared.js +113 -9
  23. package/dist/tools/analyze-parser-performance.d.ts +200 -7
  24. package/dist/tools/analyze-parser-performance.js +108 -47
  25. package/dist/tools/analyze-project.d.ts +267 -5
  26. package/dist/tools/analyze-project.js +196 -8
  27. package/dist/tools/check-incremental-compatibility.d.ts +61 -1
  28. package/dist/tools/check-incremental-compatibility.js +58 -2
  29. package/dist/tools/collect-feedback.d.ts +199 -10
  30. package/dist/tools/collect-feedback.js +171 -99
  31. package/dist/tools/compare-health.d.ts +356 -0
  32. package/dist/tools/compare-health.js +472 -0
  33. package/dist/tools/extract-libraries.d.ts +156 -4
  34. package/dist/tools/extract-libraries.js +115 -10
  35. package/dist/tools/find-angular-symbol.d.ts +98 -9
  36. package/dist/tools/find-angular-symbol.js +104 -12
  37. package/dist/tools/find-component-hosts.d.ts +684 -0
  38. package/dist/tools/find-component-hosts.js +441 -0
  39. package/dist/tools/find-usages.d.ts +99 -4
  40. package/dist/tools/find-usages.js +131 -11
  41. package/dist/tools/get-bootstrap-execution.d.ts +258 -0
  42. package/dist/tools/get-bootstrap-execution.js +324 -0
  43. package/dist/tools/get-call-graph.d.ts +139 -4
  44. package/dist/tools/get-call-graph.js +123 -13
  45. package/dist/tools/get-operation-progress-tool.d.ts +114 -2
  46. package/dist/tools/get-operation-progress-tool.js +114 -7
  47. package/dist/tools/get-operation-progress.d.ts +1 -1
  48. package/dist/tools/get-operation-progress.js +5 -5
  49. package/dist/tools/helpers/analysis-output.d.ts +177 -0
  50. package/dist/tools/helpers/analysis-output.js +165 -0
  51. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  52. package/dist/tools/helpers/build-schemas.js +23 -0
  53. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  54. package/dist/tools/helpers/citation-file-source.js +82 -0
  55. package/dist/tools/helpers/compact-output.d.ts +61 -0
  56. package/dist/tools/helpers/compact-output.js +83 -0
  57. package/dist/tools/helpers/finding-window.d.ts +43 -0
  58. package/dist/tools/helpers/finding-window.js +64 -0
  59. package/dist/tools/helpers/health-delta.d.ts +86 -0
  60. package/dist/tools/helpers/health-delta.js +239 -0
  61. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  62. package/dist/tools/helpers/investigation-schemas.js +48 -0
  63. package/dist/tools/helpers/library-imports.d.ts +57 -0
  64. package/dist/tools/helpers/library-imports.js +151 -0
  65. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  66. package/dist/tools/helpers/load-source-files.js +34 -0
  67. package/dist/tools/helpers/output-contract.d.ts +32 -0
  68. package/dist/tools/helpers/output-contract.js +32 -0
  69. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  70. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  71. package/dist/tools/helpers/process-output.d.ts +19 -0
  72. package/dist/tools/helpers/process-output.js +31 -0
  73. package/dist/tools/helpers/project-cache.d.ts +184 -0
  74. package/dist/tools/helpers/project-cache.js +331 -0
  75. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  76. package/dist/tools/helpers/project-decorators.js +22 -0
  77. package/dist/tools/helpers/rule-matcher.js +5 -0
  78. package/dist/tools/helpers/rule-runner.d.ts +72 -0
  79. package/dist/tools/helpers/rule-runner.js +131 -0
  80. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  81. package/dist/tools/helpers/scan-cache.js +34 -0
  82. package/dist/tools/helpers/scan-plan.d.ts +48 -0
  83. package/dist/tools/helpers/scan-plan.js +166 -0
  84. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  85. package/dist/tools/helpers/scope-paths.js +32 -0
  86. package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
  87. package/dist/tools/helpers/stack-frame-file-index.js +71 -0
  88. package/dist/tools/helpers/tool-context.d.ts +60 -0
  89. package/dist/tools/helpers/tool-context.js +82 -0
  90. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  91. package/dist/tools/helpers/transform-safety.js +87 -0
  92. package/dist/tools/helpers/validation-output.d.ts +53 -0
  93. package/dist/tools/helpers/validation-output.js +48 -0
  94. package/dist/tools/inspect-form-group.d.ts +324 -0
  95. package/dist/tools/inspect-form-group.js +279 -0
  96. package/dist/tools/inspect-i18n.d.ts +466 -0
  97. package/dist/tools/inspect-i18n.js +400 -0
  98. package/dist/tools/inspect-template.d.ts +320 -0
  99. package/dist/tools/inspect-template.js +324 -0
  100. package/dist/tools/learn-patterns.d.ts +122 -1
  101. package/dist/tools/learn-patterns.js +97 -2
  102. package/dist/tools/list-imports.d.ts +128 -11
  103. package/dist/tools/list-imports.js +128 -8
  104. package/dist/tools/orchestrate-migration.d.ts +129 -5
  105. package/dist/tools/orchestrate-migration.js +166 -12
  106. package/dist/tools/parse-stack-trace.d.ts +59 -2
  107. package/dist/tools/parse-stack-trace.js +52 -4
  108. package/dist/tools/plan-migration.d.ts +418 -1
  109. package/dist/tools/plan-migration.js +355 -8
  110. package/dist/tools/resolve-type.d.ts +42 -1
  111. package/dist/tools/resolve-type.js +37 -4
  112. package/dist/tools/review-feedback.d.ts +206 -11
  113. package/dist/tools/review-feedback.js +132 -51
  114. package/dist/tools/rollback-changes.d.ts +79 -2
  115. package/dist/tools/rollback-changes.js +66 -14
  116. package/dist/tools/run-angular-cli.d.ts +45 -2
  117. package/dist/tools/run-angular-cli.js +67 -7
  118. package/dist/tools/run-build.d.ts +114 -2
  119. package/dist/tools/run-build.js +117 -8
  120. package/dist/tools/run-schematic.d.ts +70 -2
  121. package/dist/tools/run-schematic.js +104 -10
  122. package/dist/tools/scan-all.d.ts +24 -16
  123. package/dist/tools/scan-all.js +145 -137
  124. package/dist/tools/scan-angular.d.ts +20 -11
  125. package/dist/tools/scan-angular.js +52 -24
  126. package/dist/tools/scan-architecture.d.ts +42 -14
  127. package/dist/tools/scan-architecture.js +206 -163
  128. package/dist/tools/scan-solid.d.ts +20 -11
  129. package/dist/tools/scan-solid.js +52 -24
  130. package/dist/tools/search-codebase.d.ts +85 -1
  131. package/dist/tools/search-codebase.js +61 -4
  132. package/dist/tools/server-status.d.ts +370 -0
  133. package/dist/tools/server-status.js +369 -0
  134. package/dist/tools/suggest-improvements.d.ts +97 -5
  135. package/dist/tools/suggest-improvements.js +80 -44
  136. package/dist/tools/trace-output-flow.d.ts +791 -0
  137. package/dist/tools/trace-output-flow.js +668 -0
  138. package/dist/tools/transform-code-batch.d.ts +3 -0
  139. package/dist/tools/transform-code-batch.js +10 -5
  140. package/dist/tools/transform-code.d.ts +335 -12
  141. package/dist/tools/transform-code.js +649 -608
  142. package/dist/tools/validate-before-transform.d.ts +116 -2
  143. package/dist/tools/validate-before-transform.js +55 -2
  144. package/dist/tools/validate-project-compatibility.d.ts +64 -2
  145. package/dist/tools/validate-project-compatibility.js +67 -4
  146. package/dist/tools/validate-transformation.d.ts +220 -2
  147. package/dist/tools/validate-transformation.js +113 -15
  148. package/dist/tools/verify-citations.d.ts +181 -0
  149. package/dist/tools/verify-citations.js +218 -0
  150. package/dist/types.d.ts +45 -1
  151. package/dist/utils/format-tool-response.d.ts +22 -59
  152. package/dist/utils/format-tool-response.js +25 -134
  153. package/package.json +30 -13
  154. package/dist/cli.d.ts.map +0 -1
  155. package/dist/cli.js.map +0 -1
  156. package/dist/core/project-analyzer.d.ts.map +0 -1
  157. package/dist/core/project-analyzer.js.map +0 -1
  158. package/dist/index.d.ts.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/mcp-watcher.d.ts.map +0 -1
  161. package/dist/mcp-watcher.js.map +0 -1
  162. package/dist/server/json-rpc-handler.d.ts +0 -57
  163. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  164. package/dist/server/json-rpc-handler.js +0 -222
  165. package/dist/server/json-rpc-handler.js.map +0 -1
  166. package/dist/server/mcp-server.d.ts.map +0 -1
  167. package/dist/server/mcp-server.js.map +0 -1
  168. package/dist/server/tool-registry.d.ts.map +0 -1
  169. package/dist/server/tool-registry.js.map +0 -1
  170. package/dist/streaming/progress-store.d.ts.map +0 -1
  171. package/dist/streaming/progress-store.js.map +0 -1
  172. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  173. package/dist/tools/analyze-build-impact.js.map +0 -1
  174. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  175. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  176. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  177. package/dist/tools/analyze-parser-performance.js.map +0 -1
  178. package/dist/tools/analyze-project.d.ts.map +0 -1
  179. package/dist/tools/analyze-project.js.map +0 -1
  180. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  181. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  182. package/dist/tools/collect-feedback.d.ts.map +0 -1
  183. package/dist/tools/collect-feedback.js.map +0 -1
  184. package/dist/tools/extract-libraries.d.ts.map +0 -1
  185. package/dist/tools/extract-libraries.js.map +0 -1
  186. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  187. package/dist/tools/find-angular-symbol.js.map +0 -1
  188. package/dist/tools/find-usages.d.ts.map +0 -1
  189. package/dist/tools/find-usages.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/feedback-analyzer.d.ts.map +0 -1
  197. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  198. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  199. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  200. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  201. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  202. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  203. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  204. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  205. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  206. package/dist/tools/learn-patterns.d.ts.map +0 -1
  207. package/dist/tools/learn-patterns.js.map +0 -1
  208. package/dist/tools/list-imports.d.ts.map +0 -1
  209. package/dist/tools/list-imports.js.map +0 -1
  210. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  211. package/dist/tools/orchestrate-migration.js.map +0 -1
  212. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  213. package/dist/tools/parse-stack-trace.js.map +0 -1
  214. package/dist/tools/plan-migration.d.ts.map +0 -1
  215. package/dist/tools/plan-migration.js.map +0 -1
  216. package/dist/tools/resolve-type.d.ts.map +0 -1
  217. package/dist/tools/resolve-type.js.map +0 -1
  218. package/dist/tools/review-feedback.d.ts.map +0 -1
  219. package/dist/tools/review-feedback.js.map +0 -1
  220. package/dist/tools/rollback-changes.d.ts.map +0 -1
  221. package/dist/tools/rollback-changes.js.map +0 -1
  222. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  223. package/dist/tools/run-angular-cli.js.map +0 -1
  224. package/dist/tools/run-build.d.ts.map +0 -1
  225. package/dist/tools/run-build.js.map +0 -1
  226. package/dist/tools/run-schematic.d.ts.map +0 -1
  227. package/dist/tools/run-schematic.js.map +0 -1
  228. package/dist/tools/scan-all.d.ts.map +0 -1
  229. package/dist/tools/scan-all.js.map +0 -1
  230. package/dist/tools/scan-angular.d.ts.map +0 -1
  231. package/dist/tools/scan-angular.js.map +0 -1
  232. package/dist/tools/scan-architecture.d.ts.map +0 -1
  233. package/dist/tools/scan-architecture.js.map +0 -1
  234. package/dist/tools/scan-solid.d.ts.map +0 -1
  235. package/dist/tools/scan-solid.js.map +0 -1
  236. package/dist/tools/search-codebase.d.ts.map +0 -1
  237. package/dist/tools/search-codebase.js.map +0 -1
  238. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  239. package/dist/tools/shared/scan-types.js.map +0 -1
  240. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  241. package/dist/tools/suggest-improvements.js.map +0 -1
  242. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  243. package/dist/tools/transform-code-batch.js.map +0 -1
  244. package/dist/tools/transform-code.d.ts.map +0 -1
  245. package/dist/tools/transform-code.js.map +0 -1
  246. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  247. package/dist/tools/validate-before-transform.js.map +0 -1
  248. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  249. package/dist/tools/validate-project-compatibility.js.map +0 -1
  250. package/dist/tools/validate-transformation.d.ts.map +0 -1
  251. package/dist/tools/validate-transformation.js.map +0 -1
  252. package/dist/types.d.ts.map +0 -1
  253. package/dist/types.js.map +0 -1
  254. package/dist/utils/format-tool-response.d.ts.map +0 -1
  255. package/dist/utils/format-tool-response.js.map +0 -1
@@ -4,40 +4,89 @@
4
4
  * MCP tool for rolling back transformations if validation fails or
5
5
  * changes are unsatisfactory. Uses either git stash or file-level backups.
6
6
  */
7
- import { RollbackManager, RollbackStrategy, } from '@angular-modernizer/core';
7
+ import { RollbackStrategy } from '@angular-modernizer/core';
8
+ import { createProjectRollbackManager, findProjectRootOf, } from './helpers/transform-safety.js';
9
+ import { STRING_ARRAY } from './helpers/investigation-schemas.js';
10
+ /** Restored files spelled out in the summary; the rest is in `files`. */
11
+ const SUMMARY_FILES = 10;
12
+ /** Text summary: outcome, strategy and the restored files, or the error. */
13
+ function describeRollback(result) {
14
+ const lines = [
15
+ `Rollback ${result.success ? 'done' : 'failed'} (${result.strategy}): ` +
16
+ `${result.files.length} file(s) restored` +
17
+ (result.error === undefined ? '.' : `; ${result.error}`),
18
+ ];
19
+ lines.push(...result.files.slice(0, SUMMARY_FILES).map((f) => `- ${f}`));
20
+ if (result.files.length > SUMMARY_FILES) {
21
+ lines.push(`... ${result.files.length - SUMMARY_FILES} more in files.`);
22
+ }
23
+ return lines.join('\n');
24
+ }
8
25
  /**
9
26
  * MCP tool for rollback operations.
10
27
  */
11
28
  export class RollbackChangesTool {
12
29
  name = 'rollback-changes';
13
- description = 'Rollback transformations if validation fails or changes are unsatisfactory. Uses git stash or file-level backups.';
30
+ title = 'Roll Back Changes';
31
+ annotations = {
32
+ readOnlyHint: false,
33
+ destructiveHint: true,
34
+ idempotentHint: false,
35
+ openWorldHint: false,
36
+ };
37
+ 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. ' +
38
+ 'summary is a short text with the outcome and the restored files.';
14
39
  inputSchema = {
15
40
  type: 'object',
41
+ additionalProperties: false,
16
42
  properties: {
17
43
  files: {
18
44
  type: 'array',
19
45
  items: { type: 'string' },
20
- description: 'Specific files to rollback (optional - rolls back all if not specified)',
46
+ description: 'Specific files to rollback (optional - restores the files of the last transform-code call if not specified)',
21
47
  },
22
48
  strategy: {
23
49
  type: 'string',
24
50
  enum: ['auto', 'git-stash', 'file-backup'],
25
- description: 'Rollback strategy: "auto" (try git first, fallback to file), "git-stash", or "file-backup"',
51
+ 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
52
  default: 'auto',
27
53
  },
28
54
  backupDir: {
29
55
  type: 'string',
30
- description: 'Custom backup directory for file backups (optional)',
56
+ description: 'Custom backup directory for file backups (optional - defaults to <projectRoot>/.angular-modernizer-backups)',
57
+ },
58
+ projectRoot: {
59
+ type: 'string',
60
+ 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
61
  },
32
62
  gitRoot: {
33
63
  type: 'string',
34
- description: 'Git project root (optional - auto-detects if not specified)',
64
+ description: 'Git project root (optional - used as project root when projectRoot is not given)',
35
65
  },
36
66
  },
37
67
  };
68
+ outputSchema = {
69
+ type: 'object',
70
+ properties: {
71
+ success: { type: 'boolean' },
72
+ strategy: { type: 'string', enum: ['git-stash', 'file-backup'] },
73
+ files: STRING_ARRAY,
74
+ error: { type: 'string' },
75
+ metadata: {
76
+ type: 'object',
77
+ properties: {
78
+ totalFiles: { type: 'integer' },
79
+ duration: { type: 'number' },
80
+ },
81
+ required: ['totalFiles'],
82
+ },
83
+ summary: { type: 'string' },
84
+ },
85
+ required: ['success', 'strategy', 'files', 'summary'],
86
+ };
38
87
  async execute(args) {
39
88
  const typedArgs = args;
40
- const { files, strategy = 'auto', backupDir, gitRoot } = typedArgs;
89
+ const { files, strategy = 'auto', backupDir, projectRoot, gitRoot, } = typedArgs;
41
90
  const startTime = Date.now();
42
91
  // Convert strategy string to RollbackStrategy enum
43
92
  let rollbackStrategy;
@@ -53,12 +102,15 @@ export class RollbackChangesTool {
53
102
  rollbackStrategy = RollbackStrategy.AUTO;
54
103
  break;
55
104
  }
56
- const config = {
57
- strategy: rollbackStrategy,
105
+ const firstFile = files?.[0];
106
+ const root = projectRoot ??
107
+ gitRoot ??
108
+ (firstFile ? findProjectRootOf(firstFile) : undefined) ??
109
+ process.cwd();
110
+ const rollbackManager = createProjectRollbackManager(root, {
58
111
  backupDir,
59
- gitRoot,
60
- };
61
- const rollbackManager = new RollbackManager(config);
112
+ strategy: rollbackStrategy,
113
+ });
62
114
  try {
63
115
  const result = await rollbackManager.rollback(files);
64
116
  const duration = Date.now() - startTime;
@@ -74,7 +126,7 @@ export class RollbackChangesTool {
74
126
  duration,
75
127
  },
76
128
  };
77
- return response;
129
+ return { ...response, summary: describeRollback(response) };
78
130
  }
79
131
  catch (error) {
80
132
  const duration = Date.now() - startTime;
@@ -88,7 +140,7 @@ export class RollbackChangesTool {
88
140
  duration,
89
141
  },
90
142
  };
91
- return errorResponse;
143
+ return { ...errorResponse, summary: describeRollback(errorResponse) };
92
144
  }
93
145
  }
94
146
  }
@@ -5,7 +5,7 @@
5
5
  * Enables AI assistants to run ng commands for project management,
6
6
  * code generation, and build operations.
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 Angular CLI command execution.
11
11
  */
@@ -46,15 +46,22 @@ interface AngularCliResult {
46
46
  * Working directory where command was executed.
47
47
  */
48
48
  cwd: string;
49
+ /**
50
+ * Short text: command, exit code, time, and the last output lines on failure.
51
+ */
52
+ summary: string;
49
53
  }
50
54
  /**
51
55
  * MCP tool for executing Angular CLI commands.
52
56
  */
53
57
  export declare class RunAngularCliTool implements MCPTool {
54
58
  name: string;
59
+ title: string;
60
+ annotations: ToolAnnotations;
55
61
  description: string;
56
62
  inputSchema: {
57
63
  type: string;
64
+ additionalProperties: boolean;
58
65
  properties: {
59
66
  command: {
60
67
  type: string;
@@ -92,7 +99,43 @@ export declare class RunAngularCliTool implements MCPTool {
92
99
  };
93
100
  required: string[];
94
101
  };
95
- execute(args: Record<string, unknown>): Promise<AngularCliResult>;
102
+ outputSchema: {
103
+ type: string;
104
+ properties: {
105
+ success: {
106
+ type: string;
107
+ };
108
+ command: {
109
+ type: string;
110
+ };
111
+ fullCommand: {
112
+ type: string;
113
+ };
114
+ exitCode: {
115
+ type: string;
116
+ };
117
+ stdout: {
118
+ type: string;
119
+ };
120
+ stderr: {
121
+ type: string;
122
+ };
123
+ executionTime: {
124
+ type: string;
125
+ };
126
+ timedOut: {
127
+ type: string;
128
+ };
129
+ cwd: {
130
+ type: string;
131
+ };
132
+ summary: {
133
+ type: string;
134
+ };
135
+ };
136
+ required: string[];
137
+ };
138
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<AngularCliResult>;
96
139
  /**
97
140
  * Execute an Angular CLI command.
98
141
  */
@@ -6,14 +6,40 @@
6
6
  * code generation, and build operations.
7
7
  */
8
8
  import { spawn } from 'node:child_process';
9
+ import { processGroupOptions, terminateOnAbort, terminateProcessTree, } from '@angular-modernizer/core';
10
+ import { outputTail, seconds } from './helpers/process-output.js';
11
+ /** Text summary: what ran, how it ended, and the tail of stderr (or stdout) on failure. */
12
+ function describeCliRun(result) {
13
+ const ending = result.timedOut === true
14
+ ? `timed out after ${seconds(result.executionTime)}`
15
+ : `exited ${result.exitCode} after ${seconds(result.executionTime)}`;
16
+ const head = `\`${result.fullCommand}\` ${ending} in ${result.cwd}.`;
17
+ if (result.success) {
18
+ return head;
19
+ }
20
+ const tail = outputTail(result.stderr) ?? outputTail(result.stdout);
21
+ return tail === undefined ? head : `${head}\nLast output:\n${tail}`;
22
+ }
23
+ function withSummary(result) {
24
+ return { ...result, summary: describeCliRun(result) };
25
+ }
9
26
  /**
10
27
  * MCP tool for executing Angular CLI commands.
11
28
  */
12
29
  export class RunAngularCliTool {
13
30
  name = 'run-angular-cli';
14
- description = 'Execute Angular CLI commands for project management and code generation';
31
+ title = 'Run Angular CLI';
32
+ annotations = {
33
+ readOnlyHint: false,
34
+ destructiveHint: true,
35
+ idempotentHint: false,
36
+ openWorldHint: true,
37
+ };
38
+ description = 'Execute Angular CLI commands for project management and code generation. ' +
39
+ 'The result has the full stdout and stderr; summary is a short text with the exit code and, on failure, the last output lines.';
15
40
  inputSchema = {
16
41
  type: 'object',
42
+ additionalProperties: false,
17
43
  properties: {
18
44
  command: {
19
45
  type: 'string',
@@ -57,7 +83,33 @@ export class RunAngularCliTool {
57
83
  },
58
84
  required: ['command'],
59
85
  };
60
- async execute(args) {
86
+ outputSchema = {
87
+ type: 'object',
88
+ properties: {
89
+ success: { type: 'boolean' },
90
+ command: { type: 'string' },
91
+ fullCommand: { type: 'string' },
92
+ exitCode: { type: 'integer' },
93
+ stdout: { type: 'string' },
94
+ stderr: { type: 'string' },
95
+ executionTime: { type: 'number' },
96
+ timedOut: { type: 'boolean' },
97
+ cwd: { type: 'string' },
98
+ summary: { type: 'string' },
99
+ },
100
+ required: [
101
+ 'success',
102
+ 'command',
103
+ 'fullCommand',
104
+ 'exitCode',
105
+ 'stdout',
106
+ 'stderr',
107
+ 'executionTime',
108
+ 'cwd',
109
+ 'summary',
110
+ ],
111
+ };
112
+ async execute(args, ctx = {}) {
61
113
  const params = args;
62
114
  if (!params.command) {
63
115
  throw new Error('command is required');
@@ -77,9 +129,10 @@ export class RunAngularCliTool {
77
129
  cwd,
78
130
  env,
79
131
  timeout,
132
+ signal: ctx.signal,
80
133
  });
81
134
  const executionTime = Date.now() - startTime;
82
- return {
135
+ return withSummary({
83
136
  success: result.exitCode === 0,
84
137
  command,
85
138
  fullCommand,
@@ -88,11 +141,11 @@ export class RunAngularCliTool {
88
141
  stderr: result.stderr,
89
142
  executionTime,
90
143
  cwd,
91
- };
144
+ });
92
145
  }
93
146
  catch (error) {
94
147
  if (error instanceof Error && error.message.includes('timed out')) {
95
- return {
148
+ return withSummary({
96
149
  success: false,
97
150
  command,
98
151
  fullCommand,
@@ -102,7 +155,7 @@ export class RunAngularCliTool {
102
155
  executionTime: timeout,
103
156
  timedOut: true,
104
157
  cwd,
105
- };
158
+ });
106
159
  }
107
160
  throw new Error(`Angular CLI command failed: ${error instanceof Error ? error.message : String(error)}`);
108
161
  }
@@ -117,16 +170,19 @@ export class RunAngularCliTool {
117
170
  env: options.env,
118
171
  stdio: ['pipe', 'pipe', 'pipe'],
119
172
  shell: true,
173
+ ...processGroupOptions(),
120
174
  });
121
175
  let stdout = '';
122
176
  let stderr = '';
123
177
  // Set up timeout
124
178
  const timeoutId = setTimeout(() => {
125
- ngProcess.kill('SIGTERM');
179
+ terminateProcessTree(ngProcess);
126
180
  reject(new Error(`Command timed out after ${options.timeout}ms`));
127
181
  }, options.timeout);
182
+ const stopOnAbort = terminateOnAbort(ngProcess, options.signal);
128
183
  const cleanup = () => {
129
184
  clearTimeout(timeoutId);
185
+ stopOnAbort();
130
186
  };
131
187
  ngProcess.stdout.on('data', (data) => {
132
188
  stdout += data.toString();
@@ -136,6 +192,10 @@ export class RunAngularCliTool {
136
192
  });
137
193
  ngProcess.on('close', (code) => {
138
194
  cleanup();
195
+ if (options.signal?.aborted === true) {
196
+ reject(new Error('Command cancelled'));
197
+ return;
198
+ }
139
199
  resolve({
140
200
  exitCode: code ?? 0,
141
201
  stdout,
@@ -5,7 +5,7 @@
5
5
  * Supports Angular CLI, Nx, Webpack, Vite, and auto-detection.
6
6
  * Includes incremental build mode for efficient validation.
7
7
  */
8
- import { type MCPTool } from '../types.js';
8
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
9
9
  import { type IncompatibilityCheck } from '@angular-modernizer/core';
10
10
  /**
11
11
  * Incremental build metadata
@@ -96,15 +96,22 @@ interface BuildResult {
96
96
  * Incompatibility issues detected (if incremental mode was blocked)
97
97
  */
98
98
  incompatibilityIssues?: IncompatibilityCheck[];
99
+ /**
100
+ * Short text: command, exit code, time, build mode, and the last output lines on failure.
101
+ */
102
+ summary: string;
99
103
  }
100
104
  /**
101
105
  * MCP tool for executing build systems.
102
106
  */
103
107
  export declare class RunBuildTool implements MCPTool {
104
108
  name: string;
109
+ title: string;
110
+ annotations: ToolAnnotations;
105
111
  description: string;
106
112
  inputSchema: {
107
113
  type: string;
114
+ additionalProperties: boolean;
108
115
  properties: {
109
116
  rootPath: {
110
117
  type: string;
@@ -167,7 +174,112 @@ export declare class RunBuildTool implements MCPTool {
167
174
  };
168
175
  required: string[];
169
176
  };
170
- execute(args: Record<string, unknown>): Promise<BuildResult>;
177
+ outputSchema: {
178
+ type: string;
179
+ properties: {
180
+ success: {
181
+ type: string;
182
+ };
183
+ buildSystem: {
184
+ type: string;
185
+ };
186
+ command: {
187
+ type: string;
188
+ };
189
+ fullCommand: {
190
+ type: string;
191
+ };
192
+ exitCode: {
193
+ type: string;
194
+ };
195
+ output: {
196
+ type: string;
197
+ };
198
+ errors: {
199
+ type: string;
200
+ };
201
+ executionTime: {
202
+ type: string;
203
+ };
204
+ timedOut: {
205
+ type: string;
206
+ };
207
+ artifacts: {
208
+ readonly type: "array";
209
+ readonly items: {
210
+ readonly type: "string";
211
+ };
212
+ };
213
+ warnings: {
214
+ type: string;
215
+ items: {
216
+ type: string;
217
+ };
218
+ description: string;
219
+ };
220
+ incremental: {
221
+ type: string;
222
+ properties: {
223
+ enabled: {
224
+ type: string;
225
+ };
226
+ scope: {
227
+ type: string;
228
+ };
229
+ filesBuilt: {
230
+ type: string;
231
+ };
232
+ filesSkipped: {
233
+ type: string;
234
+ };
235
+ cacheHit: {
236
+ type: string;
237
+ };
238
+ speedup: {
239
+ type: string;
240
+ };
241
+ fallbackReason: {
242
+ type: string;
243
+ };
244
+ };
245
+ required: string[];
246
+ };
247
+ incompatibilityIssues: {
248
+ readonly type: "array";
249
+ readonly items: {
250
+ readonly type: "object";
251
+ readonly properties: {
252
+ readonly type: {
253
+ readonly type: "string";
254
+ };
255
+ readonly detected: {
256
+ readonly type: "boolean";
257
+ };
258
+ readonly severity: {
259
+ readonly type: "string";
260
+ readonly enum: readonly ["blocker", "warning"];
261
+ };
262
+ readonly message: {
263
+ readonly type: "string";
264
+ };
265
+ readonly recommendation: {
266
+ readonly type: "string";
267
+ };
268
+ readonly details: {
269
+ readonly type: "object";
270
+ };
271
+ };
272
+ readonly required: readonly ["type", "detected", "severity", "message", "recommendation"];
273
+ };
274
+ };
275
+ summary: {
276
+ type: string;
277
+ };
278
+ };
279
+ required: string[];
280
+ };
281
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<BuildResult>;
282
+ private runBuild;
171
283
  /**
172
284
  * Detects changed files using git status
173
285
  */