@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,26 +2,29 @@ import { findTsConfig } from './helpers/find-ts-config.js';
2
2
  import { MultiCacheFallbackManager, RealFileSystemAdapter, createMultiCacheConfig, loadConfig, } from '@angular-modernizer/core';
3
3
  import { glob } from 'glob';
4
4
  import { relative } from 'node:path';
5
- import { statSync } from 'node:fs';
6
5
  import { FindingWindow } from './helpers/finding-window.js';
7
- import { cancelledExecution, fileProgressMessage, } from './helpers/tool-context.js';
6
+ import { cancelledExecution, fileProgressMessage, finalFileProgress, } from './helpers/tool-context.js';
8
7
  import { runScan } from '../scan-host/scan-host.js';
9
- import { describeScan, SCAN_EXECUTION_SCHEMA, scanOutputSchema, } from './helpers/analysis-output.js';
10
- import { dependenciesUnchanged } from './helpers/scan-cache.js';
8
+ import { describeScan, DEPRECATED_SCAN_ORCHESTRATION_SCHEMA, SCAN_EXECUTION_SCHEMA, SCAN_ORCHESTRATION_NOTICE, scanOutputSchema, } from './helpers/analysis-output.js';
9
+ import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, scanCacheVersion, } from './helpers/scan-cache.js';
11
10
  /**
12
11
  * Version of the cache entries scan-all writes. Entries from before the
13
12
  * per-analyzed-file layout (findings filed under their template, files without
14
- * findings missing) would read as complete; the version invalidates them.
13
+ * findings missing) would read as complete; `scan-all-3` also drops entries
14
+ * whose cross-file findings saw only their own batch, `scan-all-4` entries
15
+ * that hold project rule findings of another file, `scan-all-5` entries whose
16
+ * solid:circular-dependency findings have no `cycleId` and carry the path of a
17
+ * long cycle on every file.
15
18
  */
16
- const SCAN_ALL_CACHE_VERSION = 'scan-all-2';
19
+ const SCAN_ALL_CACHE_VERSION = 'scan-all-5';
17
20
  /**
18
- * MCP tool `scan-all`: one scan with all analysis plugins (52 rules total).
21
+ * MCP tool `scan-all`: one scan with the rules of all analysis plugins.
19
22
  *
20
23
  * @remarks
21
24
  * Plugins and rules:
22
- * - SolidPlugin (7 rules): SOLID principles
23
- * - AngularPlugin (28 rules): Angular best practices
24
- * - ArchitecturePlugin (17 rules): architectural issues
25
+ * - SolidPlugin: SOLID principles
26
+ * - AngularPlugin: Angular best practices
27
+ * - ArchitecturePlugin: architectural issues
25
28
  */
26
29
  export class ScanAllTool {
27
30
  name = 'scan-all';
@@ -32,7 +35,7 @@ export class ScanAllTool {
32
35
  idempotentHint: true,
33
36
  openWorldHint: false,
34
37
  };
35
- description = 'Comprehensive code quality scan with all plugins (SOLID 7, Angular 28, Architecture 17: 52 rules total). ' +
38
+ description = 'Comprehensive code quality scan with the rules of all analysis plugins (SOLID, Angular, Architecture). ' +
36
39
  'maxResults (default 1000) and resultOffset page the violations; counts cover all of them, summary is a short text.';
37
40
  /**
38
41
  * JSON Schema of the tool arguments.
@@ -49,7 +52,7 @@ export class ScanAllTool {
49
52
  rules: {
50
53
  type: 'array',
51
54
  items: { type: 'string' },
52
- description: 'Specific rules to run (optional, runs all 52 if not specified)',
55
+ description: 'Rule ids to run (optional, default all rules): only these rules run and are reported in metadata.rulesExecuted; a scan with a selection has a cache of its own, separate from the scan of all rules',
53
56
  },
54
57
  includePatterns: {
55
58
  type: 'array',
@@ -72,6 +75,7 @@ export class ScanAllTool {
72
75
  '**/*.test.ts',
73
76
  ],
74
77
  },
78
+ cache: SCAN_CACHE_MODE_SCHEMA,
75
79
  includeAutoFixes: {
76
80
  type: 'boolean',
77
81
  description: 'Whether to include auto-fix suggestions',
@@ -92,21 +96,7 @@ export class ScanAllTool {
92
96
  description: 'Offset for result pagination',
93
97
  default: 0,
94
98
  },
95
- orchestration: {
96
- type: 'object',
97
- description: 'Advanced orchestration options',
98
- properties: {
99
- parallel: {
100
- type: 'boolean',
101
- description: 'Enable parallel rule execution',
102
- default: false,
103
- },
104
- maxWorkers: {
105
- type: 'number',
106
- description: 'Maximum concurrent workers',
107
- },
108
- },
109
- },
99
+ orchestration: DEPRECATED_SCAN_ORCHESTRATION_SCHEMA,
110
100
  },
111
101
  required: ['rootPath'],
112
102
  };
@@ -122,7 +112,10 @@ export class ScanAllTool {
122
112
  const params = args;
123
113
  const config = this.loadConfig(params.rootPath);
124
114
  const mergedParams = { ...config, ...params };
125
- const orchestration = mergedParams.orchestration ?? {};
115
+ // `rules` selects the rules that run (E-19), not only the reported findings
116
+ const ruleSelection = mergedParams.rules?.length ? mergedParams.rules : undefined;
117
+ // orchestration has no effect: the scan always runs in the scan worker
118
+ const notices = mergedParams.orchestration === undefined ? [] : [SCAN_ORCHESTRATION_NOTICE];
126
119
  if (!mergedParams.rootPath) {
127
120
  throw new Error('rootPath is required');
128
121
  }
@@ -149,6 +142,8 @@ export class ScanAllTool {
149
142
  cwd: mergedParams.rootPath,
150
143
  absolute: true,
151
144
  ignore: excludePatterns,
145
+ // A directory named like a source file (`scaleData.ts/`) is no file
146
+ nodir: true,
152
147
  });
153
148
  allFiles.push(...files);
154
149
  }
@@ -169,23 +164,28 @@ export class ScanAllTool {
169
164
  const fileSystem = new RealFileSystemAdapter();
170
165
  const multiCacheManager = new MultiCacheFallbackManager(fileSystem, ['all'], {
171
166
  ...createMultiCacheConfig(mergedParams.rootPath),
172
- version: SCAN_ALL_CACHE_VERSION,
167
+ version: scanCacheVersion(SCAN_ALL_CACHE_VERSION, mergedParams.rootPath, ruleSelection, {
168
+ includePatterns: mergedParams.includePatterns,
169
+ excludePatterns: mergedParams.excludePatterns,
170
+ }),
173
171
  });
174
172
  await multiCacheManager.initialize();
175
- const cachedResults = []; // eslint-disable-line @typescript-eslint/no-explicit-any
173
+ // Findings per analyzed file, from the cache or the scan
174
+ const findingsByFile = new Map();
175
+ let cachedFindings = 0;
176
176
  const filesToProcess = [];
177
177
  const cacheHitsBySource = {};
178
178
  // The cache holds every rule's findings per analyzed file, so an entry
179
179
  // without findings is a hit as well.
180
180
  const ownCache = multiCacheManager.getAllCaches()[0].manager;
181
+ // refresh analyzes every file; the write below overwrites the entries
182
+ const cacheMode = scanCacheMode(args);
181
183
  for (const filePath of filesToAnalyze) {
182
- const cached = await readCachedFindings(filePath, ownCache);
184
+ const cached = cacheMode === 'refresh' ? null : await readCachedFindings(filePath, ownCache);
183
185
  if (cached !== null) {
184
- // File is cached in one of the cache directories
185
- cachedResults.push(...cached.results);
186
- // Track which cache was used for logging
187
- const source = cached.source;
188
- cacheHitsBySource[source] = (cacheHitsBySource[source] ?? 0) + 1;
186
+ findingsByFile.set(filePath, cached);
187
+ cachedFindings += cached.length;
188
+ cacheHitsBySource['all'] = (cacheHitsBySource['all'] ?? 0) + 1;
189
189
  }
190
190
  else {
191
191
  // File not cached in any directory or has changed
@@ -193,7 +193,7 @@ export class ScanAllTool {
193
193
  }
194
194
  }
195
195
  const stats = multiCacheManager.getStats();
196
- console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${stats.hitRate.toFixed(1)}%)`);
196
+ console.info(`Cache: ${cachedFindings} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${stats.hitRate.toFixed(1)}%)`);
197
197
  // Show cache hit breakdown by source (Phase 3 feature)
198
198
  if (Object.keys(cacheHitsBySource).length > 0) {
199
199
  console.info(`Cache hits by source:`);
@@ -211,32 +211,29 @@ export class ScanAllTool {
211
211
  // - Runs 35 total rules (SOLID + Angular + Architecture combined)
212
212
  // - Highest memory pressure of all scan tools
213
213
  // - Batch size of 100 is critical for stability
214
- // - Longest analysis time but also biggest cache speedup (14.9x)
214
+ // - Longest analysis time of the scan tools
215
215
  // ============================================================================
216
216
  const batchSize = maxFiles;
217
217
  const totalFiles = filesToProcess.length;
218
218
  const totalBatches = Math.ceil(totalFiles / batchSize);
219
219
  console.info(`\nProcessing ${totalFiles} files in ${totalBatches} batch(es) of ${batchSize} files each`);
220
- // Separate arrays for two concerns:
221
220
  // - entriesForCache: per newly-analyzed file its violations (also those on its template) and template files
221
+ // - findingsByFile: the findings of every file, so they enter the window in file order
222
222
  // - window: rule filter, totals and the requested page of cached and new violations
223
- // PERF-1: heap is bounded because the page holds at most maxResults entries.
224
223
  const paginationOffset = mergedParams.resultOffset ?? 0;
225
224
  const paginationLimit = mergedParams.maxResults ?? 1000;
226
225
  const entriesForCache = new Map();
227
- // Cached and newly analyzed findings go through the same window: rule
228
- // filter, summary totals, then the requested page.
229
- const window = new FindingWindow(mergedParams.rules, paginationOffset, paginationLimit);
230
- for (const cached of cachedResults) {
231
- window.add(cached);
232
- }
233
- let filesAnalyzed = cachedResults.length;
234
- const progressTotal = cachedResults.length + totalFiles;
226
+ let newFindings = 0;
227
+ // Files served from the cache plus files the scan reported; a file that
228
+ // failed to load (unreadable, removed meanwhile) is not analyzed.
229
+ const cacheHits = filesToAnalyze.length - totalFiles;
230
+ let filesAnalyzed = cacheHits;
231
+ const progressTotal = filesToAnalyze.length;
232
+ let lastReported;
235
233
  // Kernel, batches and rules run in a scan worker (scan-host), so the
236
- // server keeps reading stdin while the type checker is built. Files that
237
- // failed to load count as analyzed once their batch is done, as before.
238
- let batchFilesAnalyzed = 0;
234
+ // server keeps reading stdin while the type checker is built.
239
235
  if (totalFiles > 0) {
236
+ lastReported = filesAnalyzed;
240
237
  ctx.progress?.(filesAnalyzed, progressTotal, `loading project, ${totalFiles} files to analyze`);
241
238
  }
242
239
  const engine = await runScan({
@@ -245,9 +242,11 @@ export class ScanAllTool {
245
242
  tsConfigPath,
246
243
  rootPath: mergedParams.rootPath,
247
244
  files: filesToProcess,
245
+ contextFiles: filesToAnalyze,
248
246
  mode: 'batches',
249
247
  batchSize,
250
248
  templateDependencies: true,
249
+ ...(ruleSelection === undefined ? {} : { ruleIds: ruleSelection }),
251
250
  }, {
252
251
  file: (event) => {
253
252
  // Always accumulate for cache writes, also files without findings
@@ -255,20 +254,22 @@ export class ScanAllTool {
255
254
  results: event.findings,
256
255
  dependencies: event.dependencies ?? [],
257
256
  });
258
- for (const finding of event.findings) {
259
- window.add(finding);
260
- }
261
- batchFilesAnalyzed++;
262
- ctx.progress?.(filesAnalyzed + batchFilesAnalyzed, progressTotal, fileProgressMessage(filesAnalyzed + batchFilesAnalyzed, progressTotal, window.getTotals().totalViolations));
263
- },
264
- batchDone: (files) => {
265
- filesAnalyzed += files;
266
- batchFilesAnalyzed = 0;
257
+ findingsByFile.set(event.filePath, event.findings);
258
+ newFindings += event.findings.length;
259
+ filesAnalyzed++;
260
+ lastReported = filesAnalyzed;
261
+ ctx.progress?.(filesAnalyzed, progressTotal, fileProgressMessage(filesAnalyzed, progressTotal, cachedFindings + newFindings));
267
262
  },
268
263
  }, { signal: ctx.signal });
269
264
  const cancelled = engine.cancelled;
270
- if (cancelled) {
271
- filesAnalyzed += batchFilesAnalyzed;
265
+ if (!cancelled) {
266
+ finalFileProgress(ctx.progress, progressTotal, filesAnalyzed, cachedFindings + newFindings, lastReported);
267
+ }
268
+ // Cached and newly analyzed findings go through the same window in file
269
+ // order: rule filter, summary totals, then the requested page.
270
+ const window = new FindingWindow(mergedParams.rules, paginationOffset, paginationLimit);
271
+ for (const finding of findingsInFileOrder(findingsByFile)) {
272
+ window.add(finding);
272
273
  }
273
274
  console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${filesAnalyzed} total files analyzed, ${window.getTotals().totalViolations} total violations`);
274
275
  // ============================================================================
@@ -284,26 +285,21 @@ export class ScanAllTool {
284
285
  //
285
286
  // Cache entry format: Same as scan-solid (metadata + results[] + dependencies)
286
287
  //
287
- // Performance impact:
288
- // - First run: Writes cache (adds ~1-2% overhead)
289
- // - Second run: Reads cache (14.9x speedup - best overall improvement!)
290
- //
291
- // Why scan-all benefits most from caching:
292
- // - Runs 35 total rules (SOLID + Angular + Architecture)
293
- // - Each file analyzed with ALL rules = most expensive analysis
294
- // - Cache hit eliminates analysis for ALL 35 rules per file
295
- // - 93.3% time saved on second run (359.8s → 24.2s)
288
+ // A cache hit skips the analysis of the file by the rules of all plugins.
296
289
  // ============================================================================
297
290
  // One entry per analyzed file, also without findings, so a warm run does not
298
291
  // analyze it again in a different batch. Findings on a template stay with the
299
292
  // component file that produced them; the template is a dependency.
300
293
  // Writes go to the PRIMARY cache only (multiCacheManager writes to first cache).
301
- for (const [filePath, entry] of entriesForCache) {
294
+ // A cancelled scan writes nothing: files analyzed before the cancel saw only
295
+ // part of the project, so cross-file and template findings could differ from
296
+ // a full run and a later warm run would serve them as current.
297
+ for (const [filePath, entry] of cancelled ? [] : entriesForCache) {
302
298
  await multiCacheManager.setAnalysisResult(filePath, entry.results, entry.dependencies);
303
299
  }
304
300
  // Log cache effectiveness
305
301
  const writeStats = multiCacheManager.getStats();
306
- console.info(`Cached ${entriesForCache.size} files to primary cache (hit rate: ${writeStats.hitRate.toFixed(1)}%)`);
302
+ console.info(`Cached ${cancelled ? 0 : entriesForCache.size} files to primary cache (hit rate: ${writeStats.hitRate.toFixed(1)}%)`);
307
303
  // The window holds only the requested page of the filtered findings.
308
304
  const paginatedViolations = window
309
305
  .getPage()
@@ -325,7 +321,7 @@ export class ScanAllTool {
325
321
  const totals = window.getTotals();
326
322
  const counts = {
327
323
  ...totals,
328
- analyzedFiles: cancelled ? filesAnalyzed : filesToAnalyze.length,
324
+ analyzedFiles: filesAnalyzed,
329
325
  };
330
326
  const execution = cancelled
331
327
  ? cancelledExecution(filesAnalyzed, filesToAnalyze.length - filesAnalyzed)
@@ -350,7 +346,7 @@ export class ScanAllTool {
350
346
  // Add cache stats to metadata for visibility
351
347
  cacheStats: {
352
348
  totalFilesChecked: filesToAnalyze.length,
353
- filesFromCache: cachedResults.length,
349
+ filesFromCache: cacheHits,
354
350
  filesToProcess: filesToProcess.length,
355
351
  hitRate: finalStats.hitRate,
356
352
  hitsBySource: cacheHitsBySource,
@@ -359,27 +355,18 @@ export class ScanAllTool {
359
355
  // Cache statistics with source breakdown
360
356
  // hitRate and hitsBySource refer to the own cache (/all/) only.
361
357
  cache: {
358
+ mode: cacheMode,
362
359
  totalFilesChecked: filesToAnalyze.length,
363
- filesFromCache: cachedResults.length,
360
+ filesFromCache: cacheHits,
364
361
  filesToProcess: filesToProcess.length,
365
362
  hitRate: finalStats.hitRate,
366
363
  hitsBySource: cacheHitsBySource,
367
364
  stats: finalStats,
368
365
  },
369
- orchestration: orchestration.useWorkerThreads
370
- ? {
371
- parallel: true,
372
- incremental: false,
373
- filesAnalyzed: filesToAnalyze.length,
374
- filesSkipped: 0,
375
- cacheHitRate: finalStats.hitRate,
376
- duration,
377
- throughput: filesToAnalyze.length / (duration / 1000),
378
- }
379
- : undefined,
366
+ ...(notices.length === 0 ? {} : { warnings: notices }),
380
367
  pagination,
381
368
  ...(execution === undefined ? {} : { execution }),
382
- summary: describeScan(counts, paginatedViolations, pagination, execution === undefined ? [] : [execution.note]),
369
+ summary: describeScan(counts, paginatedViolations, pagination, [...notices, ...(execution === undefined ? [] : [execution.note])]),
383
370
  };
384
371
  }
385
372
  /**
@@ -403,25 +390,4 @@ export class ScanAllTool {
403
390
  return {};
404
391
  }
405
392
  }
406
- /**
407
- * Cached findings of one file, or `null` when it must be analyzed. An own
408
- * entry is authoritative even without findings, but stale once one of its
409
- * template dependencies changed.
410
- */
411
- async function readCachedFindings(filePath, ownCache) {
412
- const own = await ownCache.getAnalysisResult(filePath);
413
- if (own === null) {
414
- return null;
415
- }
416
- const fresh = dependenciesUnchanged(own.dependencies, own.metadata.cachedAt, modifiedAt);
417
- return fresh ? { results: own.results, source: 'all' } : null;
418
- }
419
- function modifiedAt(path) {
420
- try {
421
- return statSync(path).mtimeMs;
422
- }
423
- catch {
424
- return undefined;
425
- }
426
- }
427
393
  //# sourceMappingURL=scan-all.js.map
@@ -41,7 +41,12 @@ export interface ScanAngularResult {
41
41
  /** Root path of the scanned project. */
42
42
  projectRoot: string;
43
43
  };
44
- /** Orchestration figures; set only when `orchestration.useWorkerThreads` is set. */
44
+ /** Deprecation notices of the call (`orchestration` has no effect). */
45
+ warnings?: string[];
46
+ /**
47
+ * @deprecated No longer set: the block claimed a parallel run that never
48
+ * happened. The scan always runs in the scan worker.
49
+ */
45
50
  orchestration?: {
46
51
  /** Whether the scan ran in parallel. */
47
52
  parallel: boolean;
@@ -72,7 +77,7 @@ export interface ScanAngularResult {
72
77
  }
73
78
  /**
74
79
  * MCP tool `scan-angular`: scans for Angular-specific best practice
75
- * violations. Runs only the AngularPlugin (28 rules: OnPush, TrackBy,
80
+ * violations. Runs only the rules of the AngularPlugin (OnPush, TrackBy,
76
81
  * performance, RxJS and others).
77
82
  */
78
83
  export declare class ScanAngularTool implements MCPTool {
@@ -115,6 +120,12 @@ export declare class ScanAngularTool implements MCPTool {
115
120
  description: string;
116
121
  default: string[];
117
122
  };
123
+ cache: {
124
+ readonly type: "string";
125
+ readonly enum: readonly ["use", "refresh"];
126
+ readonly default: "use";
127
+ readonly description: "use: serve unchanged files from the scan cache (default); refresh: ignore the existing entries, analyze every file and overwrite them. Read from the call only, never from the tools section of .angular-modernizer.json";
128
+ };
118
129
  includeAutoFixes: {
119
130
  type: string;
120
131
  description: string;
@@ -136,17 +147,19 @@ export declare class ScanAngularTool implements MCPTool {
136
147
  default: number;
137
148
  };
138
149
  orchestration: {
139
- type: string;
140
- description: string;
141
- properties: {
142
- parallel: {
143
- type: string;
144
- description: string;
145
- default: boolean;
150
+ readonly type: "object";
151
+ readonly description: "Deprecated, no effect, kept in 2.x: the scan always runs in the scan worker and answers with a notice in warnings. Leave unset.";
152
+ readonly deprecated: true;
153
+ readonly properties: {
154
+ readonly parallel: {
155
+ readonly type: "boolean";
156
+ readonly description: "Deprecated, no effect.";
157
+ readonly deprecated: true;
146
158
  };
147
- maxWorkers: {
148
- type: string;
149
- description: string;
159
+ readonly maxWorkers: {
160
+ readonly type: "number";
161
+ readonly description: "Deprecated, no effect.";
162
+ readonly deprecated: true;
150
163
  };
151
164
  };
152
165
  };
@@ -164,8 +177,8 @@ export declare class ScanAngularTool implements MCPTool {
164
177
  };
165
178
  execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ScanAngularResult>;
166
179
  /**
167
- * Load configuration from .angular-modernizer.json file.
168
- * Only loads from the provided root path to avoid cache directory issues.
180
+ * The `tools['scan-angular']` section of `.angular-modernizer.json`; arguments of
181
+ * the call override it.
169
182
  */
170
183
  private loadConfig;
171
184
  private calculateSummary;