@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
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Safety envelope shared by transform-code and rollback-changes: backups in
3
+ * the project (not in the server's working directory), one RollbackManager
4
+ * configuration for both tools, and the type check of a transformed file.
5
+ */
6
+ import { type SourceFile } from 'ts-morph';
7
+ import { RollbackManager, RollbackStrategy } from '@angular-modernizer/core';
8
+ /**
9
+ * Backup directory name inside the project root.
10
+ */
11
+ export declare const BACKUP_DIR_NAME = ".angular-modernizer-backups";
12
+ /**
13
+ * Backup directory of a project: the explicit one, else inside the project.
14
+ */
15
+ export declare function projectBackupDir(projectRoot: string, backupDir?: string): string;
16
+ /**
17
+ * RollbackManager writing to and reading from the project's backup
18
+ * directory; git snapshots run in the project root.
19
+ */
20
+ export declare function createProjectRollbackManager(projectRoot: string, options?: {
21
+ backupDir?: string;
22
+ strategy?: RollbackStrategy;
23
+ }): RollbackManager;
24
+ /**
25
+ * Nearest directory above a file that holds a tsconfig.json, package.json or
26
+ * .angular-modernizer.json; undefined when none exists up to the file system
27
+ * root.
28
+ */
29
+ export declare function findProjectRootOf(filePath: string): string | undefined;
30
+ /**
31
+ * Type errors of one file, as `TS<code>: <message>` without positions so the
32
+ * lists before and after a transformation can be compared.
33
+ */
34
+ export declare function fileTypeErrors(sourceFile: SourceFile): string[];
35
+ /**
36
+ * Errors in `after` that `before` did not have (multiset difference): errors
37
+ * the file already had do not fail the transformation.
38
+ */
39
+ export declare function introducedTypeErrors(before: readonly string[], after: readonly string[]): string[];
40
+ //# sourceMappingURL=transform-safety.d.ts.map
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Safety envelope shared by transform-code and rollback-changes: backups in
3
+ * the project (not in the server's working directory), one RollbackManager
4
+ * configuration for both tools, and the type check of a transformed file.
5
+ */
6
+ import { existsSync } from 'node:fs';
7
+ import { dirname, join, resolve } from 'node:path';
8
+ import { DiagnosticCategory } from 'ts-morph';
9
+ import { RollbackManager, RollbackStrategy } from '@angular-modernizer/core';
10
+ /**
11
+ * Backup directory name inside the project root.
12
+ */
13
+ export const BACKUP_DIR_NAME = '.angular-modernizer-backups';
14
+ /**
15
+ * Backup directory of a project: the explicit one, else inside the project.
16
+ */
17
+ export function projectBackupDir(projectRoot, backupDir) {
18
+ return backupDir ?? join(projectRoot, BACKUP_DIR_NAME);
19
+ }
20
+ /**
21
+ * RollbackManager writing to and reading from the project's backup
22
+ * directory; git snapshots run in the project root.
23
+ */
24
+ export function createProjectRollbackManager(projectRoot, options = {}) {
25
+ return new RollbackManager({
26
+ backupDir: projectBackupDir(projectRoot, options.backupDir),
27
+ gitRoot: projectRoot,
28
+ strategy: options.strategy ?? RollbackStrategy.AUTO,
29
+ });
30
+ }
31
+ /**
32
+ * Nearest directory above a file that holds a tsconfig.json, package.json or
33
+ * .angular-modernizer.json; undefined when none exists up to the file system
34
+ * root.
35
+ */
36
+ export function findProjectRootOf(filePath) {
37
+ let dir = dirname(resolve(filePath));
38
+ for (;;) {
39
+ const marker = ['tsconfig.json', 'package.json', '.angular-modernizer.json']
40
+ .map((name) => join(dir, name))
41
+ .some((path) => existsSync(path));
42
+ if (marker) {
43
+ return dir;
44
+ }
45
+ const parent = dirname(dir);
46
+ if (parent === dir) {
47
+ return undefined;
48
+ }
49
+ dir = parent;
50
+ }
51
+ }
52
+ /**
53
+ * Type errors of one file, as `TS<code>: <message>` without positions so the
54
+ * lists before and after a transformation can be compared.
55
+ */
56
+ export function fileTypeErrors(sourceFile) {
57
+ return sourceFile
58
+ .getPreEmitDiagnostics()
59
+ .filter((d) => d.getCategory() === DiagnosticCategory.Error)
60
+ .map((d) => {
61
+ const message = d.getMessageText();
62
+ const text = typeof message === 'string' ? message : message.getMessageText();
63
+ return `TS${d.getCode()}: ${text}`;
64
+ });
65
+ }
66
+ /**
67
+ * Errors in `after` that `before` did not have (multiset difference): errors
68
+ * the file already had do not fail the transformation.
69
+ */
70
+ export function introducedTypeErrors(before, after) {
71
+ const remaining = new Map();
72
+ for (const error of before) {
73
+ remaining.set(error, (remaining.get(error) ?? 0) + 1);
74
+ }
75
+ const introduced = [];
76
+ for (const error of after) {
77
+ const count = remaining.get(error) ?? 0;
78
+ if (count > 0) {
79
+ remaining.set(error, count - 1);
80
+ }
81
+ else {
82
+ introduced.push(error);
83
+ }
84
+ }
85
+ return introduced;
86
+ }
87
+ //# sourceMappingURL=transform-safety.js.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Validation issues in summaries
3
+ *
4
+ * validate-before-transform and validate-transformation return an `issues`
5
+ * list with a severity each; their summaries count the issues per severity
6
+ * and spell out the first ones, errors first.
7
+ */
8
+ /** Issues spelled out in a summary; the rest is in `issues`. */
9
+ export declare const SUMMARY_ISSUES = 10;
10
+ /** The part of a validation issue a summary shows. */
11
+ export interface SummaryIssue {
12
+ type: string;
13
+ severity: 'error' | 'warning' | 'info';
14
+ message: string;
15
+ line?: number;
16
+ }
17
+ /** `N issue(s) (error 2, warning 1)` */
18
+ export declare function issueCount(issues: readonly SummaryIssue[]): string;
19
+ /** One `- severity type line N: message` line per issue, errors first, at most `max`. */
20
+ export declare function issueLines(issues: readonly SummaryIssue[], max?: number): string[];
21
+ /** Output schema of a validation issue list. */
22
+ export declare const VALIDATION_ISSUES_SCHEMA: {
23
+ readonly type: "array";
24
+ readonly items: {
25
+ readonly type: "object";
26
+ readonly properties: {
27
+ readonly type: {
28
+ readonly type: "string";
29
+ };
30
+ readonly severity: {
31
+ readonly type: "string";
32
+ readonly enum: readonly ["error", "warning", "info"];
33
+ };
34
+ readonly message: {
35
+ readonly type: "string";
36
+ };
37
+ readonly filePath: {
38
+ readonly type: "string";
39
+ };
40
+ readonly line: {
41
+ readonly type: "integer";
42
+ };
43
+ readonly column: {
44
+ readonly type: "integer";
45
+ };
46
+ readonly details: {
47
+ readonly type: "string";
48
+ };
49
+ };
50
+ readonly required: readonly ["type", "severity", "message"];
51
+ };
52
+ };
53
+ //# sourceMappingURL=validation-output.d.ts.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Validation issues in summaries
3
+ *
4
+ * validate-before-transform and validate-transformation return an `issues`
5
+ * list with a severity each; their summaries count the issues per severity
6
+ * and spell out the first ones, errors first.
7
+ */
8
+ import { countList } from './analysis-output.js';
9
+ /** Issues spelled out in a summary; the rest is in `issues`. */
10
+ export const SUMMARY_ISSUES = 10;
11
+ const SEVERITY_RANK = { error: 0, warning: 1, info: 2 };
12
+ /** `N issue(s) (error 2, warning 1)` */
13
+ export function issueCount(issues) {
14
+ const bySeverity = {};
15
+ for (const issue of issues) {
16
+ bySeverity[issue.severity] = (bySeverity[issue.severity] ?? 0) + 1;
17
+ }
18
+ const counts = countList(bySeverity, 3);
19
+ return `${issues.length} issue(s)${counts === undefined ? '' : ` (${counts})`}`;
20
+ }
21
+ /** One `- severity type line N: message` line per issue, errors first, at most `max`. */
22
+ export function issueLines(issues, max = SUMMARY_ISSUES) {
23
+ return [...issues]
24
+ .sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity])
25
+ .slice(0, max)
26
+ .map((issue) => {
27
+ const where = issue.line === undefined ? '' : ` line ${issue.line}`;
28
+ return `- ${issue.severity} ${issue.type}${where}: ${issue.message}`;
29
+ });
30
+ }
31
+ /** Output schema of a validation issue list. */
32
+ export const VALIDATION_ISSUES_SCHEMA = {
33
+ type: 'array',
34
+ items: {
35
+ type: 'object',
36
+ properties: {
37
+ type: { type: 'string' },
38
+ severity: { type: 'string', enum: ['error', 'warning', 'info'] },
39
+ message: { type: 'string' },
40
+ filePath: { type: 'string' },
41
+ line: { type: 'integer' },
42
+ column: { type: 'integer' },
43
+ details: { type: 'string' },
44
+ },
45
+ required: ['type', 'severity', 'message'],
46
+ },
47
+ };
48
+ //# sourceMappingURL=validation-output.js.map
@@ -0,0 +1,324 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Inspect Form Group Tool
3
+ *
4
+ * MCP tool that returns the Reactive Forms of a component or service file
5
+ * as structure: controls with validators and initial state, and every
6
+ * enable/disable/validator change per control, including what an ancestor
7
+ * group's enable()/disable() switches with it.
8
+ *
9
+ * @remarks
10
+ * Logic lives in `FormGroupInspector` (`@angular-modernizer/api`); this tool
11
+ * resolves the project, validates arguments and applies the compact output
12
+ * contract (`maxResults` caps the control list per form).
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Via MCP:
17
+ * // tool: inspect-form-group
18
+ * // args: { file: 'src/app/edit/edit.component.ts', projectRoot: '/project' }
19
+ * ```
20
+ */
21
+ import { type MCPTool, type ToolAnnotations } from '../types.js';
22
+ import { type InspectedForm, type InspectedFormControl } from '@angular-modernizer/api';
23
+ import { ProjectCache } from './helpers/project-cache.js';
24
+ /** A control with the cascade optionally dropped. */
25
+ type ControlOutput = Omit<InspectedFormControl, 'cascade'> & Partial<Pick<InspectedFormControl, 'cascade'>>;
26
+ /** A form shaped by the compact options. */
27
+ type FormOutput = Omit<InspectedForm, 'controls'> & {
28
+ controls?: ControlOutput[];
29
+ truncated: boolean;
30
+ };
31
+ /**
32
+ * Output of the inspect-form-group tool.
33
+ */
34
+ interface InspectFormGroupOutput {
35
+ forms: FormOutput[];
36
+ summary: string;
37
+ tsConfigPath: string;
38
+ /** Conditions that can make the result incomplete (unresolved library imports). */
39
+ warnings?: string[];
40
+ }
41
+ /**
42
+ * MCP tool that inspects Reactive Forms in a file.
43
+ */
44
+ export declare class InspectFormGroupTool implements MCPTool {
45
+ private readonly projects;
46
+ readonly name = "inspect-form-group";
47
+ readonly title = "Inspect Form Group";
48
+ readonly annotations: ToolAnnotations;
49
+ constructor(projects?: ProjectCache);
50
+ readonly description: string;
51
+ readonly inputSchema: {
52
+ type: string;
53
+ additionalProperties: boolean;
54
+ properties: {
55
+ summaryOnly: {
56
+ readonly type: "boolean";
57
+ readonly description: "Return counts and the text summary only, without the result list. Default: false.";
58
+ readonly default: false;
59
+ };
60
+ maxResults: {
61
+ readonly type: "number";
62
+ readonly description: string;
63
+ };
64
+ file: {
65
+ type: string;
66
+ description: string;
67
+ };
68
+ projectRoot: {
69
+ type: string;
70
+ description: string;
71
+ };
72
+ className: {
73
+ type: string;
74
+ description: string;
75
+ };
76
+ form: {
77
+ type: string;
78
+ description: string;
79
+ };
80
+ includeValueOperations: {
81
+ type: string;
82
+ description: string;
83
+ default: boolean;
84
+ };
85
+ includeCascade: {
86
+ type: string;
87
+ description: string;
88
+ default: boolean;
89
+ };
90
+ };
91
+ required: string[];
92
+ };
93
+ readonly outputSchema: {
94
+ type: string;
95
+ properties: {
96
+ warnings: {
97
+ readonly type: "array";
98
+ readonly items: {
99
+ readonly type: "string";
100
+ };
101
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
102
+ };
103
+ forms: {
104
+ type: string;
105
+ items: {
106
+ readonly type: "object";
107
+ readonly properties: {
108
+ readonly className: {
109
+ readonly type: "string";
110
+ };
111
+ readonly property: {
112
+ readonly type: "string";
113
+ };
114
+ readonly file: {
115
+ readonly type: "string";
116
+ };
117
+ readonly definedAt: {
118
+ readonly type: "array";
119
+ readonly items: {
120
+ readonly type: "integer";
121
+ };
122
+ };
123
+ readonly kind: {
124
+ readonly type: "string";
125
+ };
126
+ readonly validators: {
127
+ readonly type: "array";
128
+ readonly items: {
129
+ readonly type: "string";
130
+ };
131
+ };
132
+ readonly controls: {
133
+ readonly type: "array";
134
+ readonly items: {
135
+ readonly type: "object";
136
+ readonly properties: {
137
+ readonly path: {
138
+ readonly type: "string";
139
+ };
140
+ readonly kind: {
141
+ readonly type: "string";
142
+ };
143
+ readonly line: {
144
+ readonly type: "integer";
145
+ };
146
+ readonly disabledInitially: {
147
+ readonly type: "boolean";
148
+ };
149
+ readonly validators: {
150
+ readonly type: "array";
151
+ readonly items: {
152
+ readonly type: "string";
153
+ };
154
+ };
155
+ readonly asyncValidators: {
156
+ readonly type: "array";
157
+ readonly items: {
158
+ readonly type: "string";
159
+ };
160
+ };
161
+ readonly addedAt: {
162
+ readonly type: "integer";
163
+ };
164
+ readonly operations: {
165
+ readonly type: "array";
166
+ readonly items: {
167
+ readonly type: "object";
168
+ readonly properties: {
169
+ readonly op: {
170
+ readonly type: "string";
171
+ };
172
+ readonly line: {
173
+ readonly type: "integer";
174
+ };
175
+ readonly args: {
176
+ readonly type: "string";
177
+ };
178
+ readonly in: {
179
+ readonly type: "string";
180
+ };
181
+ };
182
+ readonly required: readonly ["op", "line", "in"];
183
+ };
184
+ };
185
+ readonly cascade: {
186
+ readonly type: "array";
187
+ readonly items: {
188
+ readonly type: "object";
189
+ readonly properties: {
190
+ readonly op: {
191
+ readonly type: "string";
192
+ };
193
+ readonly from: {
194
+ readonly type: "string";
195
+ };
196
+ readonly line: {
197
+ readonly type: "integer";
198
+ };
199
+ readonly in: {
200
+ readonly type: "string";
201
+ };
202
+ };
203
+ readonly required: readonly ["op", "from", "line", "in"];
204
+ };
205
+ };
206
+ readonly reEnabledBy: {
207
+ readonly type: "array";
208
+ readonly items: {
209
+ readonly type: "object";
210
+ readonly properties: {
211
+ readonly op: {
212
+ readonly type: "string";
213
+ };
214
+ readonly from: {
215
+ readonly type: "string";
216
+ };
217
+ readonly line: {
218
+ readonly type: "integer";
219
+ };
220
+ readonly in: {
221
+ readonly type: "string";
222
+ };
223
+ };
224
+ readonly required: readonly ["op", "from", "line", "in"];
225
+ };
226
+ };
227
+ };
228
+ readonly required: readonly ["path", "kind", "line", "disabledInitially", "validators", "asyncValidators", "operations"];
229
+ };
230
+ };
231
+ readonly operations: {
232
+ readonly type: "array";
233
+ readonly items: {
234
+ readonly type: "object";
235
+ readonly properties: {
236
+ readonly op: {
237
+ readonly type: "string";
238
+ };
239
+ readonly line: {
240
+ readonly type: "integer";
241
+ };
242
+ readonly args: {
243
+ readonly type: "string";
244
+ };
245
+ readonly in: {
246
+ readonly type: "string";
247
+ };
248
+ };
249
+ readonly required: readonly ["op", "line", "in"];
250
+ };
251
+ };
252
+ readonly unknownPaths: {
253
+ readonly type: "array";
254
+ readonly items: {
255
+ readonly type: "object";
256
+ readonly properties: {
257
+ readonly path: {
258
+ readonly type: "string";
259
+ };
260
+ readonly op: {
261
+ readonly type: "string";
262
+ };
263
+ readonly line: {
264
+ readonly type: "integer";
265
+ };
266
+ };
267
+ readonly required: readonly ["path", "op", "line"];
268
+ };
269
+ };
270
+ readonly dynamicOperations: {
271
+ readonly type: "array";
272
+ readonly items: {
273
+ readonly type: "object";
274
+ readonly properties: {
275
+ readonly path: {
276
+ readonly type: "string";
277
+ };
278
+ readonly op: {
279
+ readonly type: "string";
280
+ };
281
+ readonly line: {
282
+ readonly type: "integer";
283
+ };
284
+ readonly args: {
285
+ readonly type: "string";
286
+ };
287
+ readonly in: {
288
+ readonly type: "string";
289
+ };
290
+ };
291
+ readonly required: readonly ["op", "line", "in", "path"];
292
+ };
293
+ };
294
+ readonly counts: {
295
+ readonly type: "object";
296
+ readonly properties: {
297
+ [k: string]: {
298
+ type: string;
299
+ };
300
+ };
301
+ readonly required: readonly ["controls", "validated", "disabledInitially", "operations", "unknownPaths", "dynamicOperations", "reEnabledByAncestor"];
302
+ };
303
+ readonly truncated: {
304
+ readonly type: "boolean";
305
+ };
306
+ };
307
+ readonly required: readonly ["className", "property", "file", "definedAt", "kind", "validators", "operations", "unknownPaths", "dynamicOperations", "counts", "truncated"];
308
+ };
309
+ };
310
+ summary: {
311
+ type: string;
312
+ };
313
+ tsConfigPath: {
314
+ type: string;
315
+ };
316
+ };
317
+ required: string[];
318
+ };
319
+ execute(args: Record<string, unknown>): Promise<InspectFormGroupOutput>;
320
+ private shape;
321
+ private buildSummary;
322
+ }
323
+ export {};
324
+ //# sourceMappingURL=inspect-form-group.d.ts.map