@angular-modernizer/adapter-mcp 1.1.0 → 2.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 (144) hide show
  1. package/CHANGELOG.md +662 -0
  2. package/README.md +86 -445
  3. package/dist/cli.js +9 -1
  4. package/dist/core/project-analyzer.js +2 -2
  5. package/dist/index.d.ts +10 -1
  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 +9 -6
  21. package/dist/tools/analyze-build-impact.js +14 -7
  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 +35 -6
  27. package/dist/tools/analyze-project.js +141 -36
  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/extract-libraries.js +42 -27
  32. package/dist/tools/find-angular-symbol.d.ts +2 -2
  33. package/dist/tools/find-angular-symbol.js +6 -5
  34. package/dist/tools/find-component-hosts.d.ts +2 -2
  35. package/dist/tools/find-component-hosts.js +6 -5
  36. package/dist/tools/find-usages.d.ts +2 -2
  37. package/dist/tools/find-usages.js +24 -15
  38. package/dist/tools/get-bootstrap-execution.d.ts +2 -2
  39. package/dist/tools/get-bootstrap-execution.js +3 -3
  40. package/dist/tools/get-call-graph.d.ts +2 -2
  41. package/dist/tools/get-call-graph.js +18 -5
  42. package/dist/tools/get-operation-progress-tool.d.ts +1 -1
  43. package/dist/tools/get-operation-progress-tool.js +2 -2
  44. package/dist/tools/get-operation-progress.d.ts +4 -1
  45. package/dist/tools/get-operation-progress.js +6 -2
  46. package/dist/tools/helpers/analysis-output.d.ts +32 -1
  47. package/dist/tools/helpers/analysis-output.js +22 -1
  48. package/dist/tools/helpers/build-cache.d.ts +27 -0
  49. package/dist/tools/helpers/build-cache.js +86 -0
  50. package/dist/tools/helpers/class-filter.d.ts +18 -0
  51. package/dist/tools/helpers/class-filter.js +30 -0
  52. package/dist/tools/helpers/cli-arguments.d.ts +23 -0
  53. package/dist/tools/helpers/cli-arguments.js +35 -0
  54. package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
  55. package/dist/tools/helpers/feedback-catalog.js +196 -0
  56. package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
  57. package/dist/tools/helpers/feedback-sidecar.js +381 -0
  58. package/dist/tools/helpers/file-type-check.d.ts +34 -0
  59. package/dist/tools/helpers/file-type-check.js +56 -0
  60. package/dist/tools/helpers/output-contract.d.ts +42 -0
  61. package/dist/tools/helpers/output-contract.js +54 -0
  62. package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
  63. package/dist/tools/helpers/pattern-anonymizer.js +159 -0
  64. package/dist/tools/helpers/project-cache.d.ts +78 -6
  65. package/dist/tools/helpers/project-cache.js +205 -15
  66. package/dist/tools/helpers/project-decorators.d.ts +11 -4
  67. package/dist/tools/helpers/project-decorators.js +13 -6
  68. package/dist/tools/helpers/refresh-apply.d.ts +94 -0
  69. package/dist/tools/helpers/refresh-apply.js +460 -0
  70. package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
  71. package/dist/tools/helpers/refresh-inventory.js +610 -0
  72. package/dist/tools/helpers/rule-runner.js +3 -1
  73. package/dist/tools/helpers/scan-cache.d.ts +74 -5
  74. package/dist/tools/helpers/scan-cache.js +134 -6
  75. package/dist/tools/helpers/scan-engine.d.ts +30 -6
  76. package/dist/tools/helpers/scan-engine.js +131 -22
  77. package/dist/tools/helpers/scan-plan.d.ts +1 -1
  78. package/dist/tools/helpers/scan-plan.js +16 -2
  79. package/dist/tools/helpers/source-map-loader.d.ts +55 -0
  80. package/dist/tools/helpers/source-map-loader.js +226 -0
  81. package/dist/tools/helpers/template-check.d.ts +76 -0
  82. package/dist/tools/helpers/template-check.js +158 -0
  83. package/dist/tools/helpers/tool-cache.d.ts +7 -2
  84. package/dist/tools/helpers/tool-cache.js +9 -3
  85. package/dist/tools/helpers/tool-context.d.ts +18 -0
  86. package/dist/tools/helpers/tool-context.js +29 -0
  87. package/dist/tools/helpers/transform-safety.d.ts +151 -1
  88. package/dist/tools/helpers/transform-safety.js +357 -4
  89. package/dist/tools/inspect-form-group.d.ts +2 -2
  90. package/dist/tools/inspect-form-group.js +8 -3
  91. package/dist/tools/inspect-i18n.d.ts +2 -2
  92. package/dist/tools/inspect-i18n.js +3 -3
  93. package/dist/tools/inspect-template.d.ts +2 -2
  94. package/dist/tools/inspect-template.js +11 -5
  95. package/dist/tools/learn-patterns.d.ts +43 -28
  96. package/dist/tools/learn-patterns.js +83 -161
  97. package/dist/tools/list-imports.d.ts +2 -2
  98. package/dist/tools/list-imports.js +3 -3
  99. package/dist/tools/orchestrate-migration.d.ts +19 -1
  100. package/dist/tools/orchestrate-migration.js +52 -10
  101. package/dist/tools/parse-stack-trace.d.ts +48 -1
  102. package/dist/tools/parse-stack-trace.js +108 -9
  103. package/dist/tools/plan-migration.d.ts +2 -2
  104. package/dist/tools/plan-migration.js +25 -12
  105. package/dist/tools/refresh-state.d.ts +378 -0
  106. package/dist/tools/refresh-state.js +370 -0
  107. package/dist/tools/resolve-type.d.ts +2 -2
  108. package/dist/tools/resolve-type.js +13 -6
  109. package/dist/tools/review-feedback.d.ts +42 -7
  110. package/dist/tools/review-feedback.js +24 -17
  111. package/dist/tools/rollback-changes.d.ts +5 -0
  112. package/dist/tools/rollback-changes.js +7 -2
  113. package/dist/tools/run-angular-cli.js +36 -22
  114. package/dist/tools/run-build.d.ts +33 -28
  115. package/dist/tools/run-build.js +136 -438
  116. package/dist/tools/run-schematic.d.ts +8 -2
  117. package/dist/tools/run-schematic.js +80 -50
  118. package/dist/tools/scan-all.d.ts +31 -15
  119. package/dist/tools/scan-all.js +75 -109
  120. package/dist/tools/scan-angular.d.ts +27 -14
  121. package/dist/tools/scan-angular.js +70 -92
  122. package/dist/tools/scan-architecture.d.ts +29 -12
  123. package/dist/tools/scan-architecture.js +205 -135
  124. package/dist/tools/scan-solid.d.ts +27 -14
  125. package/dist/tools/scan-solid.js +73 -89
  126. package/dist/tools/search-codebase.d.ts +8 -3
  127. package/dist/tools/search-codebase.js +16 -10
  128. package/dist/tools/suggest-improvements.d.ts +34 -3
  129. package/dist/tools/suggest-improvements.js +34 -9
  130. package/dist/tools/trace-output-flow.d.ts +2 -2
  131. package/dist/tools/trace-output-flow.js +6 -5
  132. package/dist/tools/transform-code-batch.d.ts +9 -9
  133. package/dist/tools/transform-code.d.ts +161 -12
  134. package/dist/tools/transform-code.js +782 -197
  135. package/dist/tools/validate-before-transform.js +2 -1
  136. package/dist/tools/validate-project-compatibility.d.ts +28 -55
  137. package/dist/tools/validate-project-compatibility.js +33 -225
  138. package/dist/tools/validate-transformation.d.ts +40 -26
  139. package/dist/tools/validate-transformation.js +115 -294
  140. package/dist/tools/verify-citations.js +8 -2
  141. package/dist/types.d.ts +9 -9
  142. package/dist/utils/format-tool-response.d.ts +3 -1
  143. package/dist/utils/format-tool-response.js +8 -3
  144. package/package.json +14 -13
@@ -2,46 +2,59 @@ import { type MCPTool, type ToolAnnotations } from '../types.js';
2
2
  import { type IncompatibilityCheck } from '@angular-modernizer/core';
3
3
  /**
4
4
  * Recommendation type for incremental build usage.
5
+ *
6
+ * @deprecated check-incremental-compatibility always answers `use-full`:
7
+ * run-build and validate-transformation have no incremental mode.
5
8
  */
6
9
  export type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
7
10
  /**
8
11
  * Output result of compatibility check.
12
+ *
13
+ * @deprecated check-incremental-compatibility is deprecated: its fields keep
14
+ * their 1.x shape, `compatible` is always `false`, `issues` empty and
15
+ * `estimatedSpeedup` `null`.
9
16
  */
10
17
  export interface CompatibilityCheckOutput {
11
18
  /**
12
- * Whether incremental build is compatible (no blockers).
19
+ * Always `false`: there is no incremental build to be compatible with.
13
20
  */
14
21
  compatible: boolean;
15
22
  /**
16
- * Detected Angular version.
23
+ * Angular version from package.json.
17
24
  */
18
25
  angularVersion: string | null;
19
26
  /**
20
- * Array of detected incompatibility issues.
27
+ * Always empty.
21
28
  */
22
29
  issues: IncompatibilityCheck[];
23
30
  /**
24
- * Recommendation for build strategy.
31
+ * Always `use-full`.
25
32
  */
26
33
  recommendation: RecommendationType;
27
34
  /**
28
- * Estimated speedup ratio (e.g., 5.2 = 5.2x faster).
29
- * Null if incremental mode is not compatible.
35
+ * Always `null`.
30
36
  */
31
37
  estimatedSpeedup: number | null;
32
38
  /**
33
- * User-facing formatted message.
39
+ * Always `true`.
40
+ */
41
+ deprecated: boolean;
42
+ /**
43
+ * The deprecation notice and where to go instead.
34
44
  */
35
45
  message: string;
36
46
  /**
37
- * Short text: verdict, recommendation, detected blockers and warnings, speedup.
47
+ * Short text: the deprecation notice.
38
48
  */
39
49
  summary: string;
40
50
  }
41
51
  /**
42
- * MCP tool for checking project compatibility with incremental build validation.
43
- * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
44
- * and complex monorepo structures. Provides clear recommendations and speedup estimates.
52
+ * Deprecated MCP tool that used to check a project for incremental build
53
+ * validation. run-build and validate-transformation have one build path, so
54
+ * there is nothing to check; the tool stays registered in 2.x and answers at
55
+ * once with a deprecation notice, without loading the project.
56
+ *
57
+ * @deprecated Use analyze-build-impact for the affected files; removal planned for 3.0.
45
58
  */
46
59
  export declare class CheckIncrementalCompatibilityTool implements MCPTool {
47
60
  name: string;
@@ -63,17 +76,17 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
63
76
  maxCircularDeps: {
64
77
  type: string;
65
78
  description: string;
66
- default: number;
79
+ deprecated: boolean;
67
80
  };
68
81
  minAngularVersion: {
69
82
  type: string;
70
83
  description: string;
71
- default: string;
84
+ deprecated: boolean;
72
85
  };
73
86
  maxInterProjectDeps: {
74
87
  type: string;
75
88
  description: string;
76
- default: number;
89
+ deprecated: boolean;
77
90
  };
78
91
  };
79
92
  required: string[];
@@ -126,6 +139,9 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
126
139
  estimatedSpeedup: {
127
140
  type: string[];
128
141
  };
142
+ deprecated: {
143
+ type: string;
144
+ };
129
145
  message: {
130
146
  type: string;
131
147
  };
@@ -140,32 +156,5 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
140
156
  * Extracts Angular version from package.json
141
157
  */
142
158
  private extractAngularVersion;
143
- /**
144
- * Determines recommendation based on blockers and warnings
145
- */
146
- private determineRecommendation;
147
- /**
148
- * Calculates estimated speedup for incremental builds
149
- *
150
- * Estimates based on:
151
- * - Project size (number of files)
152
- * - Typical change patterns (10-20% of files modified)
153
- * - Build time heuristics
154
- *
155
- * Returns speedup factor (e.g., 5.2 = 5.2x faster)
156
- */
157
- private calculateSpeedup;
158
- /**
159
- * Formats user-facing message with compatibility status, issues, and recommendations
160
- */
161
- private formatMessage;
162
- /**
163
- * Gets version status indicator (supported/too old)
164
- */
165
- private getVersionStatus;
166
- /**
167
- * Formats issue details for display
168
- */
169
- private formatDetails;
170
159
  }
171
160
  //# sourceMappingURL=check-incremental-compatibility.d.ts.map
@@ -1,45 +1,28 @@
1
- import { Project } from 'ts-morph';
2
- import { IncompatibilityDetector, } from '@angular-modernizer/core';
3
1
  import { existsSync, readFileSync } from 'node:fs';
4
2
  import { join } from 'node:path';
5
3
  import { INCOMPATIBILITY_ISSUES_SCHEMA } from './helpers/build-schemas.js';
6
- /** Text summary: verdict, Angular version, recommendation and one line per detected issue. */
7
- function describeCompatibility(output) {
8
- const detected = output.issues.filter((i) => i.detected);
9
- const blockers = detected.filter((i) => i.severity === 'blocker');
10
- const verdict = !output.compatible
11
- ? 'Not compatible with incremental builds'
12
- : output.recommendation === 'use-with-caution'
13
- ? 'Compatible with incremental builds, with caution'
14
- : 'Compatible with incremental builds';
15
- const lines = [
16
- `${verdict} (Angular ${output.angularVersion ?? 'not detected'}); recommendation ${output.recommendation}; ` +
17
- `${blockers.length} blocker(s), ${detected.length - blockers.length} warning(s)` +
18
- (output.estimatedSpeedup === null
19
- ? '.'
20
- : `; estimated speedup ${output.estimatedSpeedup}x.`),
21
- ];
22
- for (const issue of detected) {
23
- lines.push(`- ${issue.severity} ${issue.type}: ${issue.message} ${issue.recommendation}`);
24
- }
25
- return lines.join('\n');
26
- }
4
+ /** What the tool answers on every call. */
5
+ const DEPRECATION_MESSAGE = 'check-incremental-compatibility is deprecated and checks nothing: run-build and validate-transformation always run the full build command of the project (the Angular CLI has no file-scoped build). ' +
6
+ 'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
27
7
  /**
28
- * MCP tool for checking project compatibility with incremental build validation.
29
- * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
30
- * and complex monorepo structures. Provides clear recommendations and speedup estimates.
8
+ * Deprecated MCP tool that used to check a project for incremental build
9
+ * validation. run-build and validate-transformation have one build path, so
10
+ * there is nothing to check; the tool stays registered in 2.x and answers at
11
+ * once with a deprecation notice, without loading the project.
12
+ *
13
+ * @deprecated Use analyze-build-impact for the affected files; removal planned for 3.0.
31
14
  */
32
15
  export class CheckIncrementalCompatibilityTool {
33
16
  name = 'check-incremental-compatibility';
34
- title = 'Check Incremental Build Compatibility';
17
+ title = 'Check Incremental Build Compatibility (deprecated)';
35
18
  annotations = {
36
19
  readOnlyHint: true,
37
20
  destructiveHint: false,
38
21
  idempotentHint: true,
39
22
  openWorldHint: false,
40
23
  };
41
- description = 'Check if a project is compatible with incremental build validation. Detects blockers like circular dependencies, old Angular versions, custom build configs, and complex monorepos. Returns compatibility status, issues, recommendations, and estimated speedup. ' +
42
- 'summary is a short text with the verdict, the recommendation and the detected issues.';
24
+ description = 'Deprecated, checks nothing: run-build and validate-transformation always run the full build command of the project. Answers compatible false, recommendation use-full and no issues. ' +
25
+ 'Use analyze-build-impact for the files a change affects and scan-architecture for import cycles.';
43
26
  /**
44
27
  * JSON Schema of the tool arguments.
45
28
  * @hidden
@@ -50,22 +33,22 @@ export class CheckIncrementalCompatibilityTool {
50
33
  properties: {
51
34
  projectPath: {
52
35
  type: 'string',
53
- description: 'Project root path to check for incremental build compatibility',
36
+ description: 'Project root path',
54
37
  },
55
38
  maxCircularDeps: {
56
39
  type: 'number',
57
- description: 'Maximum circular dependency chains before blocking (default: 10)',
58
- default: 10,
40
+ description: 'Deprecated, no effect',
41
+ deprecated: true,
59
42
  },
60
43
  minAngularVersion: {
61
44
  type: 'string',
62
- description: 'Minimum supported Angular version (default: "12.0.0")',
63
- default: '12.0.0',
45
+ description: 'Deprecated, no effect',
46
+ deprecated: true,
64
47
  },
65
48
  maxInterProjectDeps: {
66
49
  type: 'number',
67
- description: 'Maximum inter-project dependencies in monorepo before warning (default: 20)',
68
- default: 20,
50
+ description: 'Deprecated, no effect',
51
+ deprecated: true,
69
52
  },
70
53
  },
71
54
  required: ['projectPath'],
@@ -85,6 +68,7 @@ export class CheckIncrementalCompatibilityTool {
85
68
  enum: ['use-incremental', 'use-full', 'use-with-caution'],
86
69
  },
87
70
  estimatedSpeedup: { type: ['number', 'null'] },
71
+ deprecated: { type: 'boolean' },
88
72
  message: { type: 'string' },
89
73
  summary: { type: 'string' },
90
74
  },
@@ -103,49 +87,19 @@ export class CheckIncrementalCompatibilityTool {
103
87
  if (!params.projectPath) {
104
88
  throw new Error('projectPath is required');
105
89
  }
106
- const projectPath = params.projectPath;
107
- // Validate project path
108
- if (!existsSync(projectPath)) {
109
- throw new Error(`Project path does not exist: ${projectPath}`);
110
- }
111
- const tsConfigPath = join(projectPath, 'tsconfig.json');
112
- if (!existsSync(tsConfigPath)) {
113
- throw new Error(`tsconfig.json not found in project: ${projectPath}`);
114
- }
115
- // Initialize ts-morph project
116
- const project = new Project({
117
- tsConfigFilePath: tsConfigPath,
118
- skipAddingFilesFromTsConfig: false,
119
- });
120
- // Create IncompatibilityDetector with optional config
121
- const detector = new IncompatibilityDetector(project, projectPath, {
122
- maxCircularDeps: params.maxCircularDeps,
123
- minAngularVersion: params.minAngularVersion,
124
- maxInterProjectDeps: params.maxInterProjectDeps,
125
- });
126
- // Run compatibility checks
127
- const issues = await detector.checkProjectCompatibility();
128
- // Extract Angular version
129
- const angularVersion = this.extractAngularVersion(projectPath);
130
- // Determine compatibility (no blockers detected)
131
- const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
132
- const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
133
- const compatible = blockers.length === 0;
134
- // Determine recommendation
135
- const recommendation = this.determineRecommendation(blockers, warnings);
136
- // Calculate estimated speedup
137
- const estimatedSpeedup = compatible ? this.calculateSpeedup(project) : null;
138
- // Format user-facing message
139
- const message = this.formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup);
140
- const output = {
141
- compatible,
142
- angularVersion,
143
- issues,
144
- recommendation,
145
- estimatedSpeedup,
146
- message,
90
+ if (!existsSync(params.projectPath)) {
91
+ throw new Error(`Project path does not exist: ${params.projectPath}`);
92
+ }
93
+ return {
94
+ compatible: false,
95
+ angularVersion: this.extractAngularVersion(params.projectPath),
96
+ issues: [],
97
+ recommendation: 'use-full',
98
+ estimatedSpeedup: null,
99
+ deprecated: true,
100
+ message: DEPRECATION_MESSAGE,
101
+ summary: DEPRECATION_MESSAGE,
147
102
  };
148
- return { ...output, summary: describeCompatibility(output) };
149
103
  }
150
104
  /**
151
105
  * Extracts Angular version from package.json
@@ -171,191 +125,5 @@ export class CheckIncrementalCompatibilityTool {
171
125
  return null;
172
126
  }
173
127
  }
174
- /**
175
- * Determines recommendation based on blockers and warnings
176
- */
177
- determineRecommendation(blockers, warnings) {
178
- if (blockers.length > 0) {
179
- return 'use-full';
180
- }
181
- if (warnings.length > 0) {
182
- return 'use-with-caution';
183
- }
184
- return 'use-incremental';
185
- }
186
- /**
187
- * Calculates estimated speedup for incremental builds
188
- *
189
- * Estimates based on:
190
- * - Project size (number of files)
191
- * - Typical change patterns (10-20% of files modified)
192
- * - Build time heuristics
193
- *
194
- * Returns speedup factor (e.g., 5.2 = 5.2x faster)
195
- */
196
- calculateSpeedup(project) {
197
- const sourceFiles = project.getSourceFiles();
198
- const fileCount = sourceFiles.length;
199
- // Estimate full build time based on file count
200
- // Heuristic: 50 files = 30s, 500 files = 4min (240s)
201
- // Linear interpolation with some diminishing returns at scale
202
- let fullBuildTimeSeconds;
203
- if (fileCount <= 50) {
204
- fullBuildTimeSeconds = 30;
205
- }
206
- else if (fileCount <= 500) {
207
- // Linear interpolation: 30s to 240s
208
- const ratio = (fileCount - 50) / (500 - 50);
209
- fullBuildTimeSeconds = 30 + ratio * (240 - 30);
210
- }
211
- else {
212
- // Large projects: 240s + additional time
213
- const extraFiles = fileCount - 500;
214
- fullBuildTimeSeconds = 240 + extraFiles * 0.3; // 0.3s per extra file
215
- }
216
- // Estimate incremental build time
217
- // Typically validates 10-20% of files for small changes
218
- // Heuristic: 10-15% of full build time + 5s overhead
219
- const incrementalBuildTimeSeconds = fullBuildTimeSeconds * 0.12 + 5;
220
- // Calculate speedup ratio
221
- const speedup = fullBuildTimeSeconds / incrementalBuildTimeSeconds;
222
- // Round to 1 decimal place
223
- return Math.round(speedup * 10) / 10;
224
- }
225
- /**
226
- * Formats user-facing message with compatibility status, issues, and recommendations
227
- */
228
- formatMessage(compatible, angularVersion, issues, recommendation, estimatedSpeedup) {
229
- const lines = [];
230
- // Status header
231
- if (compatible && recommendation === 'use-incremental') {
232
- lines.push('✅ Incremental build compatible with this project');
233
- }
234
- else if (compatible && recommendation === 'use-with-caution') {
235
- lines.push('⚠️ Incremental build compatible with caution');
236
- }
237
- else {
238
- lines.push('❌ Incremental build not compatible with this project');
239
- }
240
- lines.push('');
241
- // Angular version
242
- if (angularVersion) {
243
- const versionStatus = this.getVersionStatus(angularVersion);
244
- lines.push(`Angular version: ${angularVersion} ${versionStatus}`);
245
- }
246
- else {
247
- lines.push('Angular version: Not detected');
248
- }
249
- lines.push('');
250
- // Issues section
251
- const blockers = issues.filter((issue) => issue.severity === 'blocker' && issue.detected);
252
- const warnings = issues.filter((issue) => issue.severity === 'warning' && issue.detected);
253
- if (blockers.length > 0 || warnings.length > 0) {
254
- lines.push('Issues:');
255
- blockers.forEach((issue) => {
256
- lines.push(` [BLOCKER] ${issue.message}`);
257
- lines.push(` → ${issue.recommendation}`);
258
- if (issue.details) {
259
- const detailsStr = this.formatDetails(issue.details);
260
- if (detailsStr) {
261
- lines.push(` ${detailsStr}`);
262
- }
263
- }
264
- lines.push('');
265
- });
266
- warnings.forEach((issue) => {
267
- lines.push(` [WARNING] ${issue.message}`);
268
- lines.push(` → ${issue.recommendation}`);
269
- if (issue.details) {
270
- const detailsStr = this.formatDetails(issue.details);
271
- if (detailsStr) {
272
- lines.push(` ${detailsStr}`);
273
- }
274
- }
275
- lines.push('');
276
- });
277
- }
278
- else {
279
- lines.push('No compatibility issues detected');
280
- lines.push('');
281
- }
282
- // Recommendation
283
- lines.push('Recommendation:');
284
- switch (recommendation) {
285
- case 'use-incremental':
286
- lines.push(' Use incremental build mode for faster validation');
287
- if (estimatedSpeedup) {
288
- lines.push(` Estimated speedup: ${estimatedSpeedup}x faster on incremental changes`);
289
- }
290
- break;
291
- case 'use-with-caution':
292
- lines.push(' Incremental build may work, but test thoroughly');
293
- lines.push(' Consider using full build if issues occur');
294
- if (estimatedSpeedup) {
295
- lines.push(` Potential speedup: ${estimatedSpeedup}x faster (if warnings resolved)`);
296
- }
297
- break;
298
- case 'use-full':
299
- lines.push(' Use full build mode for this project');
300
- lines.push(' Address blockers above to enable incremental builds');
301
- break;
302
- }
303
- return lines.join('\n');
304
- }
305
- /**
306
- * Gets version status indicator (supported/too old)
307
- */
308
- getVersionStatus(version) {
309
- const majorVersion = Number.parseInt(version.split('.')[0] ?? '0', 10);
310
- if (majorVersion >= 12) {
311
- return '(supported)';
312
- }
313
- else if (majorVersion >= 10) {
314
- return '(old, upgrade recommended)';
315
- }
316
- else {
317
- return '(too old, upgrade required)';
318
- }
319
- }
320
- /**
321
- * Formats issue details for display
322
- */
323
- formatDetails(details) {
324
- const parts = [];
325
- const count = details['count'];
326
- if (count !== undefined &&
327
- (typeof count === 'number' || typeof count === 'string')) {
328
- parts.push(`Count: ${count}`);
329
- }
330
- if (details['examples'] && Array.isArray(details['examples'])) {
331
- const examples = details['examples'].slice(0, 2);
332
- if (examples.length > 0) {
333
- parts.push(`Examples: ${examples.join('; ')}`);
334
- }
335
- }
336
- const currentVersion = details['currentVersion'];
337
- if (currentVersion !== undefined && typeof currentVersion === 'string') {
338
- parts.push(`Current: ${currentVersion}`);
339
- }
340
- const minVersion = details['minVersion'];
341
- if (minVersion !== undefined && typeof minVersion === 'string') {
342
- parts.push(`Required: ${minVersion}`);
343
- }
344
- const projectCount = details['projectCount'];
345
- if (projectCount !== undefined &&
346
- (typeof projectCount === 'number' || typeof projectCount === 'string')) {
347
- parts.push(`Projects: ${projectCount}`);
348
- }
349
- const interProjectDeps = details['interProjectDeps'];
350
- if (interProjectDeps !== undefined &&
351
- (typeof interProjectDeps === 'number' ||
352
- typeof interProjectDeps === 'string')) {
353
- parts.push(`Inter-project deps: ${interProjectDeps}`);
354
- }
355
- if (details['configs'] && Array.isArray(details['configs'])) {
356
- parts.push(`Configs: ${details['configs'].join(', ')}`);
357
- }
358
- return parts.length > 0 ? parts.join(', ') : '';
359
- }
360
128
  }
361
129
  //# sourceMappingURL=check-incremental-compatibility.js.map
@@ -632,8 +632,7 @@ export class CollectFeedbackTool {
632
632
  storageLocations,
633
633
  learnings,
634
634
  validationResult: {
635
- valid: validationResult.issues.filter((i) => i.severity === 'error')
636
- .length === 0,
635
+ valid: isValidFeedback(validationResult, config),
637
636
  score: validationResult.score,
638
637
  issues: validationResult.issues.map((issue) => ({
639
638
  type: ValidationType.SCHEMA, // Use ValidationType enum for validation module
@@ -798,6 +797,20 @@ async function estimateComplexity(filePath) {
798
797
  return { linesOfCode: 100, complexity: 5 };
799
798
  }
800
799
  }
800
+ /**
801
+ * Whether collected feedback counts as valid: no errors, and the
802
+ * `tools['collect-feedback']` checks that are set (`strictMode`: no warnings
803
+ * either, `minCompletenessScore`: at least that score). Unset, only errors
804
+ * count, as before the fields were read.
805
+ */
806
+ function isValidFeedback(result, config) {
807
+ const hasErrors = result.issues.some((issue) => issue.severity === 'error');
808
+ const hasStrictWarnings = config.strictMode === true &&
809
+ result.issues.some((issue) => issue.severity === 'warning');
810
+ const belowMinimum = config.minCompletenessScore !== undefined &&
811
+ result.score < config.minCompletenessScore;
812
+ return !hasErrors && !hasStrictWarnings && !belowMinimum;
813
+ }
801
814
  /**
802
815
  * Type guard to validate if a parsed value matches the StructuredDiff interface.
803
816
  *
@@ -1,6 +1,6 @@
1
1
  import { findTsConfig } from './helpers/find-ts-config.js';
2
- import { Kernel, loadConfig } from '@angular-modernizer/core';
3
- import { LibraryExtractionAnalysisRule } from '@angular-modernizer/plugin-architecture';
2
+ import { Kernel, applySuppressionComments, loadConfig } from '@angular-modernizer/core';
3
+ import { LIBRARY_EXTRACTION_DEFAULTS, LibraryExtractionAnalysisRule } from '@angular-modernizer/plugin-architecture';
4
4
  import { ContextFactory } from '@angular-modernizer/plugin-system';
5
5
  import { createPublicApi } from '@angular-modernizer/api';
6
6
  import { glob } from 'glob';
@@ -8,32 +8,45 @@ import { resolve, extname } from 'node:path';
8
8
  import { countList, pageNote } from './helpers/analysis-output.js';
9
9
  import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
10
10
  /**
11
- * Default folders scanned for candidates. `libs` / `projects` cover Nx and
12
- * Angular CLI library workspaces; `models` / `interfaces` cover data-only
13
- * foundations (interfaces, types, enums, consts).
11
+ * Default folders scanned for candidates, shared with the
12
+ * `architecture:library-extraction-opportunity` rule
13
+ * (['shared', 'common', 'core', 'libs']). Data-only foundations in `models` or
14
+ * `interfaces` are found when those folders are passed as `targetFolders`.
14
15
  */
15
- const DEFAULT_TARGET_FOLDERS = [
16
- 'shared',
17
- 'common',
18
- 'core',
19
- 'libs',
20
- 'models',
21
- 'interfaces',
22
- 'projects',
23
- ];
16
+ const DEFAULT_TARGET_FOLDERS = LIBRARY_EXTRACTION_DEFAULTS.targetFolders;
17
+ /**
18
+ * Default minimum reusability (0-100), shared with the
19
+ * `architecture:library-extraction-opportunity` rule (40).
20
+ */
21
+ const DEFAULT_MIN_REUSABILITY = LIBRARY_EXTRACTION_DEFAULTS.minReusabilityScore;
24
22
  /**
25
- * Default minimum reusability (0-100). Every file in a target folder starts
26
- * at 30 (location bonus), so 40 still requires real signals (few external
27
- * dependencies, barrel export or importers) without demanding 2+ importers
28
- * AND a barrel export like the former 60 did. The scanner itself uses 20.
23
+ * Default minimum cohesion (0-1), shared with the
24
+ * `architecture:library-extraction-opportunity` rule (0.5).
29
25
  */
30
- const DEFAULT_MIN_REUSABILITY = 40;
26
+ const DEFAULT_MIN_COHESION = LIBRARY_EXTRACTION_DEFAULTS.minCohesionScore;
27
+ /**
28
+ * Files that never become library artifacts: tests, e2e code, tool configs and
29
+ * declaration files, matched against the path relative to the project root.
30
+ * The scanner's `**\/` also matches no folder; the root-level forms stay for
31
+ * readability.
32
+ */
33
+ const NON_LIBRARY_PATTERNS = [
34
+ '*.spec.ts',
35
+ '**/*.spec.ts',
36
+ '*.test.ts',
37
+ '**/*.test.ts',
38
+ 'e2e/**',
39
+ '**/e2e/**',
40
+ '*.config.ts',
41
+ '**/*.config.ts',
42
+ '*.d.ts',
43
+ '**/*.d.ts',
44
+ ];
31
45
  /**
32
- * Default minimum cohesion (0-1). 0.5 means at least half of the weighted
33
- * location / naming / import signals agree; the former 0.7 rejected any
34
- * cluster spread over more than one sub-folder. The scanner itself uses 0.3.
46
+ * Files not loaded into the project at all. Spec and test files stay loaded:
47
+ * the scanner counts an artifact's spec file as test evidence.
35
48
  */
36
- const DEFAULT_MIN_COHESION = 0.5;
49
+ const NOT_LOADED_PATTERNS = ['**/e2e/**', '**/*.config.ts'];
37
50
  /** Candidates spelled out in the summary; the rest is in `opportunities`. */
38
51
  const SUMMARY_CANDIDATES = 5;
39
52
  /**
@@ -102,7 +115,7 @@ export class ExtractLibrariesTool {
102
115
  targetFolders: {
103
116
  type: 'array',
104
117
  items: { type: 'string' },
105
- description: "Folders to scan for extraction candidates. Default: ['shared', 'common', 'core', 'libs', 'models', 'interfaces', 'projects']",
118
+ description: "Folders to scan for extraction candidates (whole path segments). Default: ['shared', 'common', 'core', 'libs'], the default of the architecture:library-extraction-opportunity rule; pass models, interfaces or other folders here to scan them.",
106
119
  },
107
120
  minReusabilityScore: {
108
121
  type: 'number',
@@ -202,7 +215,7 @@ export class ExtractLibrariesTool {
202
215
  }
203
216
  const startTime = Date.now();
204
217
  const projectRoot = resolve(params.rootPath);
205
- const targetFolders = params.targetFolders ?? DEFAULT_TARGET_FOLDERS;
218
+ const targetFolders = params.targetFolders ?? [...DEFAULT_TARGET_FOLDERS];
206
219
  const minReusabilityScore = params.minReusabilityScore ?? DEFAULT_MIN_REUSABILITY;
207
220
  const minCohesionScore = params.minCohesionScore ?? DEFAULT_MIN_COHESION;
208
221
  const maxResults = params.maxResults ?? 1000;
@@ -228,9 +241,11 @@ export class ExtractLibrariesTool {
228
241
  '**/dist/**',
229
242
  '**/build/**',
230
243
  '**/.git/**',
244
+ ...NOT_LOADED_PATTERNS,
231
245
  ...(params.excludePatterns ?? []),
232
246
  ],
233
247
  absolute: true,
248
+ nodir: true,
234
249
  });
235
250
  const tsFiles = allFiles.filter((f) => extname(f) === '.ts');
236
251
  for (const filePath of tsFiles) {
@@ -256,7 +271,7 @@ export class ExtractLibrariesTool {
256
271
  targetFolders,
257
272
  minReusabilityScore,
258
273
  minCohesionScore,
259
- excludePatterns: params.excludePatterns ?? [],
274
+ excludePatterns: [...NON_LIBRARY_PATTERNS, ...(params.excludePatterns ?? [])],
260
275
  });
261
276
  const context = ContextFactory.createAnalysisContext({
262
277
  sourceFile: entrySourceFile,
@@ -264,7 +279,7 @@ export class ExtractLibrariesTool {
264
279
  api,
265
280
  config: extractRulesConfig,
266
281
  });
267
- const rawResults = await extractionRule.analyze(context);
282
+ const rawResults = applySuppressionComments(await extractionRule.analyze(context), extractionRule.id, extractRulesConfig, project);
268
283
  // Cast and paginate results
269
284
  const allOpportunities = rawResults;
270
285
  const paginated = allOpportunities.slice(resultOffset, resultOffset + maxResults);
@@ -1,4 +1,4 @@
1
- import { type MCPTool, type ToolAnnotations } from '../types.js';
1
+ import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
2
2
  import { type AngularSymbolResult, type AngularSymbolType } from '@angular-modernizer/api';
3
3
  import { ProjectCache } from './helpers/project-cache.js';
4
4
  /** Output of the find-angular-symbol tool. */
@@ -139,7 +139,7 @@ export declare class FindAngularSymbolTool implements MCPTool {
139
139
  };
140
140
  required: string[];
141
141
  };
142
- execute(args: Record<string, unknown>): Promise<FindAngularSymbolOutput>;
142
+ execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<FindAngularSymbolOutput>;
143
143
  private buildCompactSummary;
144
144
  private buildSummary;
145
145
  }