@angular-modernizer/adapter-mcp 1.2.0 → 2.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 (138) hide show
  1. package/CHANGELOG.md +688 -0
  2. package/README.md +84 -445
  3. package/dist/cli.js +9 -1
  4. package/dist/core/project-analyzer.js +2 -2
  5. package/dist/index.d.ts +10 -0
  6. package/dist/index.js +1 -0
  7. package/dist/scan-host/scan-host.d.ts +7 -0
  8. package/dist/scan-host/scan-host.js +73 -10
  9. package/dist/scan-host/scan-protocol.d.ts +2 -0
  10. package/dist/scan-host/scan-worker.js +14 -8
  11. package/dist/server/limited-stdio-transport.d.ts +6 -3
  12. package/dist/server/limited-stdio-transport.js +26 -9
  13. package/dist/server/mcp-server.js +1 -1
  14. package/dist/server/sdk-server.d.ts +14 -3
  15. package/dist/server/sdk-server.js +54 -6
  16. package/dist/server/tool-registry.d.ts +3 -1
  17. package/dist/server/tool-registry.js +8 -3
  18. package/dist/streaming/progress-store.d.ts +19 -7
  19. package/dist/streaming/progress-store.js +19 -8
  20. package/dist/tools/analyze-build-impact.d.ts +7 -4
  21. package/dist/tools/analyze-build-impact.js +8 -3
  22. package/dist/tools/analyze-core-to-shared.d.ts +10 -6
  23. package/dist/tools/analyze-core-to-shared.js +63 -60
  24. package/dist/tools/analyze-parser-performance.d.ts +57 -13
  25. package/dist/tools/analyze-parser-performance.js +67 -6
  26. package/dist/tools/analyze-project.d.ts +55 -4
  27. package/dist/tools/analyze-project.js +104 -15
  28. package/dist/tools/check-incremental-compatibility.d.ts +30 -41
  29. package/dist/tools/check-incremental-compatibility.js +32 -264
  30. package/dist/tools/collect-feedback.js +15 -2
  31. package/dist/tools/compare-health.d.ts +40 -4
  32. package/dist/tools/compare-health.js +22 -5
  33. package/dist/tools/extract-libraries.js +42 -27
  34. package/dist/tools/find-angular-symbol.js +3 -2
  35. package/dist/tools/find-component-hosts.js +3 -2
  36. package/dist/tools/find-usages.js +21 -12
  37. package/dist/tools/get-call-graph.js +15 -2
  38. package/dist/tools/get-operation-progress-tool.d.ts +1 -1
  39. package/dist/tools/get-operation-progress-tool.js +2 -2
  40. package/dist/tools/get-operation-progress.d.ts +4 -1
  41. package/dist/tools/get-operation-progress.js +6 -2
  42. package/dist/tools/helpers/analysis-output.d.ts +32 -1
  43. package/dist/tools/helpers/analysis-output.js +25 -1
  44. package/dist/tools/helpers/build-cache.d.ts +27 -0
  45. package/dist/tools/helpers/build-cache.js +86 -0
  46. package/dist/tools/helpers/class-filter.d.ts +18 -0
  47. package/dist/tools/helpers/class-filter.js +30 -0
  48. package/dist/tools/helpers/cli-arguments.d.ts +23 -0
  49. package/dist/tools/helpers/cli-arguments.js +35 -0
  50. package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
  51. package/dist/tools/helpers/feedback-catalog.js +196 -0
  52. package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
  53. package/dist/tools/helpers/feedback-sidecar.js +381 -0
  54. package/dist/tools/helpers/file-type-check.d.ts +34 -0
  55. package/dist/tools/helpers/file-type-check.js +56 -0
  56. package/dist/tools/helpers/health-delta.d.ts +6 -0
  57. package/dist/tools/helpers/health-delta.js +4 -1
  58. package/dist/tools/helpers/library-import-warning.d.ts +33 -0
  59. package/dist/tools/helpers/library-import-warning.js +38 -0
  60. package/dist/tools/helpers/library-imports.d.ts +38 -14
  61. package/dist/tools/helpers/library-imports.js +128 -23
  62. package/dist/tools/helpers/output-contract.d.ts +64 -0
  63. package/dist/tools/helpers/output-contract.js +67 -0
  64. package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
  65. package/dist/tools/helpers/pattern-anonymizer.js +159 -0
  66. package/dist/tools/helpers/project-cache.d.ts +5 -4
  67. package/dist/tools/helpers/project-cache.js +21 -16
  68. package/dist/tools/helpers/project-decorators.d.ts +11 -4
  69. package/dist/tools/helpers/project-decorators.js +13 -6
  70. package/dist/tools/helpers/refresh-apply.d.ts +94 -0
  71. package/dist/tools/helpers/refresh-apply.js +460 -0
  72. package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
  73. package/dist/tools/helpers/refresh-inventory.js +631 -0
  74. package/dist/tools/helpers/rule-runner.js +3 -1
  75. package/dist/tools/helpers/scan-cache.d.ts +117 -5
  76. package/dist/tools/helpers/scan-cache.js +179 -6
  77. package/dist/tools/helpers/scan-engine.d.ts +43 -6
  78. package/dist/tools/helpers/scan-engine.js +141 -22
  79. package/dist/tools/helpers/scan-plan.js +16 -2
  80. package/dist/tools/helpers/source-map-loader.d.ts +55 -0
  81. package/dist/tools/helpers/source-map-loader.js +226 -0
  82. package/dist/tools/helpers/template-check.d.ts +76 -0
  83. package/dist/tools/helpers/template-check.js +158 -0
  84. package/dist/tools/helpers/tool-cache.d.ts +7 -2
  85. package/dist/tools/helpers/tool-cache.js +9 -3
  86. package/dist/tools/helpers/tool-context.d.ts +18 -0
  87. package/dist/tools/helpers/tool-context.js +29 -0
  88. package/dist/tools/helpers/transform-safety.d.ts +151 -1
  89. package/dist/tools/helpers/transform-safety.js +357 -4
  90. package/dist/tools/inspect-form-group.js +5 -0
  91. package/dist/tools/inspect-i18n.d.ts +1 -1
  92. package/dist/tools/inspect-template.js +8 -2
  93. package/dist/tools/learn-patterns.d.ts +43 -28
  94. package/dist/tools/learn-patterns.js +83 -161
  95. package/dist/tools/list-imports.d.ts +1 -1
  96. package/dist/tools/orchestrate-migration.d.ts +19 -1
  97. package/dist/tools/orchestrate-migration.js +52 -10
  98. package/dist/tools/parse-stack-trace.d.ts +48 -1
  99. package/dist/tools/parse-stack-trace.js +108 -9
  100. package/dist/tools/plan-migration.js +22 -10
  101. package/dist/tools/refresh-state.d.ts +378 -0
  102. package/dist/tools/refresh-state.js +370 -0
  103. package/dist/tools/resolve-type.js +10 -3
  104. package/dist/tools/review-feedback.d.ts +42 -7
  105. package/dist/tools/review-feedback.js +24 -17
  106. package/dist/tools/rollback-changes.d.ts +5 -0
  107. package/dist/tools/rollback-changes.js +7 -2
  108. package/dist/tools/run-angular-cli.js +36 -22
  109. package/dist/tools/run-build.d.ts +33 -28
  110. package/dist/tools/run-build.js +136 -438
  111. package/dist/tools/run-schematic.d.ts +8 -2
  112. package/dist/tools/run-schematic.js +80 -50
  113. package/dist/tools/scan-all.d.ts +37 -15
  114. package/dist/tools/scan-all.js +76 -115
  115. package/dist/tools/scan-angular.d.ts +33 -14
  116. package/dist/tools/scan-angular.js +77 -94
  117. package/dist/tools/scan-architecture.d.ts +37 -12
  118. package/dist/tools/scan-architecture.js +220 -139
  119. package/dist/tools/scan-solid.d.ts +33 -14
  120. package/dist/tools/scan-solid.js +80 -91
  121. package/dist/tools/search-codebase.d.ts +6 -1
  122. package/dist/tools/search-codebase.js +13 -7
  123. package/dist/tools/suggest-improvements.d.ts +34 -3
  124. package/dist/tools/suggest-improvements.js +34 -9
  125. package/dist/tools/trace-output-flow.js +3 -2
  126. package/dist/tools/transform-code-batch.d.ts +9 -9
  127. package/dist/tools/transform-code.d.ts +161 -12
  128. package/dist/tools/transform-code.js +715 -206
  129. package/dist/tools/validate-before-transform.js +2 -1
  130. package/dist/tools/validate-project-compatibility.d.ts +28 -55
  131. package/dist/tools/validate-project-compatibility.js +33 -225
  132. package/dist/tools/validate-transformation.d.ts +40 -26
  133. package/dist/tools/validate-transformation.js +115 -294
  134. package/dist/tools/verify-citations.js +8 -2
  135. package/dist/types.d.ts +9 -9
  136. package/dist/utils/format-tool-response.d.ts +3 -1
  137. package/dist/utils/format-tool-response.js +8 -3
  138. package/package.json +14 -13
@@ -460,8 +460,9 @@ export class TraceOutputFlowTool {
460
460
  const file = params.file === undefined || isAbsolute(params.file)
461
461
  ? params.file
462
462
  : resolve(params.projectRoot, params.file);
463
+ const decorators = configuredComponentDecorators(params.projectRoot);
463
464
  const tracer = new OutputFlowTracer((await acquireProject(this.projects, tsConfigPath, ctx)), {
464
- componentDecorators: configuredComponentDecorators(params.projectRoot),
465
+ componentDecorators: decorators.componentDecorators,
465
466
  includeTestHosts: params.includeTestHosts === true,
466
467
  includeDynamic: params.includeDynamic !== false,
467
468
  depth,
@@ -473,7 +474,7 @@ export class TraceOutputFlowTool {
473
474
  ...(params.output ? { output: params.output } : {}),
474
475
  });
475
476
  const summary = this.buildSummary(params, result);
476
- const warnings = this.projects.warnings(tsConfigPath);
477
+ const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
477
478
  const { outputs, dynamic, ...rest } = result;
478
479
  if (compact.summaryOnly) {
479
480
  return withWarnings({
@@ -22,13 +22,16 @@ export interface BatchTransformOptions {
22
22
  timeout?: number;
23
23
  pluginIds?: string[];
24
24
  }
25
- export interface BatchTransformResult {
25
+ /** Outcome of one batch file as the transform callback returns it. */
26
+ export interface BatchFileOutcome {
26
27
  success: boolean;
27
- files: {
28
+ error?: string;
29
+ }
30
+ export interface BatchTransformResult<R extends BatchFileOutcome = BatchFileOutcome> {
31
+ success: boolean;
32
+ files: (R & {
28
33
  path: string;
29
- success: boolean;
30
- error?: string;
31
- }[];
34
+ })[];
32
35
  orchestration: {
33
36
  parallel: boolean;
34
37
  batchMode: boolean;
@@ -53,8 +56,5 @@ export interface BatchTransformResult {
53
56
  /**
54
57
  * Execute batch transformation with optional parallel processing.
55
58
  */
56
- export declare function executeBatchTransformation(options: BatchTransformOptions, transformSingleFile: (filePath: string) => Promise<{
57
- success: boolean;
58
- error?: string;
59
- }>): Promise<BatchTransformResult>;
59
+ export declare function executeBatchTransformation<R extends BatchFileOutcome>(options: BatchTransformOptions, transformSingleFile: (filePath: string) => Promise<R>): Promise<BatchTransformResult<R>>;
60
60
  //# sourceMappingURL=transform-code-batch.d.ts.map
@@ -1,9 +1,17 @@
1
1
  import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
2
+ import { type Project } from 'ts-morph';
3
+ import { type TemplateChecker } from './helpers/template-check.js';
2
4
  /**
3
5
  * Plugin config of a transformation: the plugins read `transformationType`
4
6
  * and the transformation options under their own package name.
5
7
  */
6
8
  export declare function pluginConfigFor(transformation: string | undefined, options: Record<string, unknown> | undefined): Record<string, Record<string, unknown>>;
9
+ /**
10
+ * The transformation options with the options of its analysis rule from the
11
+ * `rules` section as defaults: the rule and the transform then use the same
12
+ * thresholds. The call `options` win, key by key.
13
+ */
14
+ export declare function withRuleOptionDefaults(transformation: string, rules: Readonly<Record<string, unknown>> | undefined, options: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
7
15
  /**
8
16
  * Transformation result.
9
17
  */
@@ -13,9 +21,34 @@ export interface TransformationResult {
13
21
  */
14
22
  operationId?: string;
15
23
  /**
16
- * Whether the transformation was successful.
24
+ * `'running'` only in the immediate answer of a streaming call: the
25
+ * transformation has not run yet, so `success`, `modified`,
26
+ * `validation.syntaxValid` and `validation.typeCheckPassed` are `false`
27
+ * and mean "not yet"; get-operation-progress returns the real result.
28
+ * Unset in every other result.
29
+ */
30
+ status?: 'running';
31
+ /**
32
+ * Whether the transformation was successful (`false` in the immediate
33
+ * answer of a streaming call, see `status`).
17
34
  */
18
35
  success: boolean;
36
+ /**
37
+ * Whether the call left a file changed on disk (`false` for a run that had
38
+ * nothing to do, or whose changes were rolled back).
39
+ */
40
+ modified?: boolean;
41
+ /**
42
+ * Messages of the rules that handled the requested transformation, e.g.
43
+ * why nothing changed.
44
+ */
45
+ ruleMessages?: string[];
46
+ /**
47
+ * Every file the call left changed or created, the requested one first;
48
+ * all of them were backed up, saved and checked. Files a rollback restored
49
+ * are not listed (they are in `rollback.files`).
50
+ */
51
+ changedFiles?: string[];
19
52
  /**
20
53
  * The transformed file path (single file mode).
21
54
  */
@@ -30,16 +63,21 @@ export interface TransformationResult {
30
63
  success: boolean;
31
64
  /** Error message of a failed file. */
32
65
  error?: string;
66
+ /** Lines the transformation left changed in this file. */
67
+ changes?: TransformationResult['changes'];
68
+ /** Whether the file was left changed on disk. */
69
+ modified?: boolean;
33
70
  }[];
34
71
  /**
35
72
  * Type of transformation applied.
36
73
  */
37
74
  transformation: string;
38
75
  /**
39
- * Summary of changes made.
76
+ * Lines the call left changed on disk, counted like `git diff --numstat`
77
+ * (a batch sums its files; a restored file counts 0).
40
78
  */
41
79
  changes: {
42
- /** Changed lines. */
80
+ /** Added plus removed lines. */
43
81
  linesChanged: number;
44
82
  /** Added lines. */
45
83
  additions: number;
@@ -74,14 +112,33 @@ export interface TransformationResult {
74
112
  validation: {
75
113
  /** `true` when the transformation introduced no syntax error. */
76
114
  syntaxValid: boolean;
77
- /** `true` when the transformation introduced no type error. */
115
+ /**
116
+ * `true` when the type check ran and found no new error; `false` when it
117
+ * failed or was skipped (`typeCheck` says which).
118
+ */
78
119
  typeCheckPassed: boolean;
120
+ /** Outcome of the type check; `skipped` with `validateTransformation: false`. */
121
+ typeCheck?: 'passed' | 'failed' | 'skipped';
79
122
  /** Test outcome, when tests ran. */
80
123
  testsPass?: boolean;
81
124
  /**
82
125
  * Type errors the transformation introduced into the file.
83
126
  */
84
127
  introducedTypeErrors?: string[];
128
+ /**
129
+ * Type errors it caused in test files that import a changed file (`<file>: <error>`);
130
+ * they fail the transformation only with `failOnTestErrors`.
131
+ */
132
+ testTypeErrors?: string[];
133
+ /**
134
+ * Outcome of the Angular template check, set when the call changed a
135
+ * template (a `templateUrl` file or an inline `template` text);
136
+ * `skipped` without `@angular/compiler-cli` in the project or with
137
+ * `validateTransformation: false`.
138
+ */
139
+ templateCheck?: 'passed' | 'failed' | 'skipped';
140
+ /** Template errors the call introduced (`<file>: NG<code>: <message>`). */
141
+ introducedTemplateErrors?: string[];
85
142
  };
86
143
  /**
87
144
  * Backup information (if backup was created).
@@ -108,6 +165,8 @@ export interface TransformationResult {
108
165
  reason?: string;
109
166
  /** `true` when the restore succeeded. */
110
167
  success?: boolean;
168
+ /** Files the rollback restored (or removed, when the call created them). */
169
+ files?: string[];
111
170
  };
112
171
  /**
113
172
  * Any warnings or issues.
@@ -207,6 +266,17 @@ export interface TransformationResult {
207
266
  */
208
267
  summary: string;
209
268
  }
269
+ /**
270
+ * Context file for a library-extraction whose `filePath` no longer exists
271
+ * (an earlier run moved it into the library): the first source file of the
272
+ * project, by path, in the workspace of that path (nearest folder above it
273
+ * with angular.json): a .ts or .tsx file, not a declaration file (ts-morph
274
+ * also keeps imported JSON files as source files). The rule only needs a file of
275
+ * the workspace and checks `options.artifacts`, so a second run with the
276
+ * same arguments reports what is already in the library. `undefined` in
277
+ * every other case, so the file load fails as before.
278
+ */
279
+ export declare function movedFileContext(project: Project, filePath: string, transformation: string, options: Record<string, unknown>): string | undefined;
210
280
  /**
211
281
  * MCP tool `transform-code`: applies one of the transformation types to a
212
282
  * file (or, with `files`, to a batch) to fix architectural issues, including
@@ -221,6 +291,15 @@ export interface TransformationResult {
221
291
  */
222
292
  export declare class TransformCodeTool implements MCPTool {
223
293
  name: string;
294
+ /** Compiles changed templates before and after a call. */
295
+ private readonly templateChecker;
296
+ /**
297
+ * @param options - `templateChecker` replaces the Angular compiler of the
298
+ * target project in the template check (tests).
299
+ */
300
+ constructor(options?: {
301
+ templateChecker?: TemplateChecker;
302
+ });
224
303
  title: string;
225
304
  annotations: ToolAnnotations;
226
305
  description: string;
@@ -246,7 +325,7 @@ export declare class TransformCodeTool implements MCPTool {
246
325
  transformation: {
247
326
  type: string;
248
327
  description: string;
249
- enum: string[];
328
+ enum: ("constructor-to-inject" | "interface-extraction" | "standalone-migration" | "dependency-injection-migration" | "facade-pattern" | "form-modernization" | "constructor-injection-transform" | "component-inputs-interface-extraction" | "service-injection-cleanup" | "container-presentational" | "core-shared-modules" | "inheritance-to-composition" | "promise-service-to-observable" | "promise-component-to-reactive" | "promise-cleanup" | "sequential-await-to-forkjoin" | "missing-output-transform" | "subscription-transform" | "library-extraction" | "service-bag-transform" | "any-to-interface" | "dto-object-literal" | "interface-duplication" | "static-class-to-functions" | "extract-static-from-stateful" | "type-safety")[];
250
329
  };
251
330
  options: {
252
331
  type: string;
@@ -368,6 +447,11 @@ export declare class TransformCodeTool implements MCPTool {
368
447
  description: string;
369
448
  default: boolean;
370
449
  };
450
+ failOnTestErrors: {
451
+ type: string;
452
+ description: string;
453
+ default: boolean;
454
+ };
371
455
  rollbackOnBuildFailure: {
372
456
  type: string;
373
457
  description: string;
@@ -395,9 +479,29 @@ export declare class TransformCodeTool implements MCPTool {
395
479
  operationId: {
396
480
  type: string;
397
481
  };
482
+ status: {
483
+ type: string;
484
+ enum: string[];
485
+ description: string;
486
+ };
398
487
  success: {
399
488
  type: string;
400
489
  };
490
+ modified: {
491
+ type: string;
492
+ };
493
+ ruleMessages: {
494
+ readonly type: "array";
495
+ readonly items: {
496
+ readonly type: "string";
497
+ };
498
+ };
499
+ changedFiles: {
500
+ readonly type: "array";
501
+ readonly items: {
502
+ readonly type: "string";
503
+ };
504
+ };
401
505
  filePath: {
402
506
  type: string;
403
507
  };
@@ -415,6 +519,23 @@ export declare class TransformCodeTool implements MCPTool {
415
519
  error: {
416
520
  type: string;
417
521
  };
522
+ modified: {
523
+ type: string;
524
+ };
525
+ changes: {
526
+ type: string;
527
+ properties: {
528
+ linesChanged: {
529
+ type: string;
530
+ };
531
+ additions: {
532
+ type: string;
533
+ };
534
+ deletions: {
535
+ type: string;
536
+ };
537
+ };
538
+ };
418
539
  };
419
540
  required: string[];
420
541
  };
@@ -482,6 +603,10 @@ export declare class TransformCodeTool implements MCPTool {
482
603
  typeCheckPassed: {
483
604
  type: string;
484
605
  };
606
+ typeCheck: {
607
+ type: string;
608
+ enum: string[];
609
+ };
485
610
  testsPass: {
486
611
  type: string;
487
612
  };
@@ -491,6 +616,22 @@ export declare class TransformCodeTool implements MCPTool {
491
616
  readonly type: "string";
492
617
  };
493
618
  };
619
+ testTypeErrors: {
620
+ readonly type: "array";
621
+ readonly items: {
622
+ readonly type: "string";
623
+ };
624
+ };
625
+ templateCheck: {
626
+ type: string;
627
+ enum: string[];
628
+ };
629
+ introducedTemplateErrors: {
630
+ readonly type: "array";
631
+ readonly items: {
632
+ readonly type: "string";
633
+ };
634
+ };
494
635
  };
495
636
  required: string[];
496
637
  };
@@ -525,6 +666,12 @@ export declare class TransformCodeTool implements MCPTool {
525
666
  success: {
526
667
  type: string;
527
668
  };
669
+ files: {
670
+ readonly type: "array";
671
+ readonly items: {
672
+ readonly type: "string";
673
+ };
674
+ };
528
675
  };
529
676
  required: string[];
530
677
  };
@@ -697,11 +844,17 @@ export declare class TransformCodeTool implements MCPTool {
697
844
  * when a build ran.
698
845
  */
699
846
  private validateTransformedFile;
847
+ /**
848
+ * Template check of the changed files with the tool's checker;
849
+ * `undefined` when they changed no template.
850
+ */
851
+ private checkTemplates;
700
852
  /**
701
853
  * Streaming mode: runs the synchronous path (same safety envelope, batch
702
- * included) in the background and returns the operationId at once. The
703
- * result is stored with setResult before markComplete, so
704
- * get-operation-progress returns it.
854
+ * included) in the background and returns the operationId at once with
855
+ * `status: 'running'` and no success or passed check claimed. The result
856
+ * is stored with setResult before markComplete, so get-operation-progress
857
+ * returns it.
705
858
  */
706
859
  private executeStreaming;
707
860
  /**
@@ -716,10 +869,6 @@ export declare class TransformCodeTool implements MCPTool {
716
869
  * Find the project root from a file path.
717
870
  */
718
871
  private findProjectRoot;
719
- /**
720
- * Validate the transformation.
721
- */
722
- private validateTransformation;
723
872
  /**
724
873
  * Get validation schema for a specific transformation type.
725
874
  */