@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.
- package/CHANGELOG.md +662 -0
- package/README.md +86 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -0
- package/dist/scan-host/scan-host.d.ts +7 -0
- package/dist/scan-host/scan-host.js +73 -10
- package/dist/scan-host/scan-protocol.d.ts +2 -0
- package/dist/scan-host/scan-worker.js +14 -8
- package/dist/server/limited-stdio-transport.d.ts +6 -3
- package/dist/server/limited-stdio-transport.js +26 -9
- package/dist/server/mcp-server.js +1 -1
- package/dist/server/sdk-server.d.ts +14 -3
- package/dist/server/sdk-server.js +54 -6
- package/dist/server/tool-registry.d.ts +3 -1
- package/dist/server/tool-registry.js +8 -3
- package/dist/streaming/progress-store.d.ts +19 -7
- package/dist/streaming/progress-store.js +19 -8
- package/dist/tools/analyze-build-impact.d.ts +9 -6
- package/dist/tools/analyze-build-impact.js +14 -7
- package/dist/tools/analyze-core-to-shared.d.ts +10 -6
- package/dist/tools/analyze-core-to-shared.js +63 -60
- package/dist/tools/analyze-parser-performance.d.ts +57 -13
- package/dist/tools/analyze-parser-performance.js +67 -6
- package/dist/tools/analyze-project.d.ts +35 -6
- package/dist/tools/analyze-project.js +141 -36
- package/dist/tools/check-incremental-compatibility.d.ts +30 -41
- package/dist/tools/check-incremental-compatibility.js +32 -264
- package/dist/tools/collect-feedback.js +15 -2
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.d.ts +2 -2
- package/dist/tools/find-angular-symbol.js +6 -5
- package/dist/tools/find-component-hosts.d.ts +2 -2
- package/dist/tools/find-component-hosts.js +6 -5
- package/dist/tools/find-usages.d.ts +2 -2
- package/dist/tools/find-usages.js +24 -15
- package/dist/tools/get-bootstrap-execution.d.ts +2 -2
- package/dist/tools/get-bootstrap-execution.js +3 -3
- package/dist/tools/get-call-graph.d.ts +2 -2
- package/dist/tools/get-call-graph.js +18 -5
- package/dist/tools/get-operation-progress-tool.d.ts +1 -1
- package/dist/tools/get-operation-progress-tool.js +2 -2
- package/dist/tools/get-operation-progress.d.ts +4 -1
- package/dist/tools/get-operation-progress.js +6 -2
- package/dist/tools/helpers/analysis-output.d.ts +32 -1
- package/dist/tools/helpers/analysis-output.js +22 -1
- package/dist/tools/helpers/build-cache.d.ts +27 -0
- package/dist/tools/helpers/build-cache.js +86 -0
- package/dist/tools/helpers/class-filter.d.ts +18 -0
- package/dist/tools/helpers/class-filter.js +30 -0
- package/dist/tools/helpers/cli-arguments.d.ts +23 -0
- package/dist/tools/helpers/cli-arguments.js +35 -0
- package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
- package/dist/tools/helpers/feedback-catalog.js +196 -0
- package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
- package/dist/tools/helpers/feedback-sidecar.js +381 -0
- package/dist/tools/helpers/file-type-check.d.ts +34 -0
- package/dist/tools/helpers/file-type-check.js +56 -0
- package/dist/tools/helpers/output-contract.d.ts +42 -0
- package/dist/tools/helpers/output-contract.js +54 -0
- package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
- package/dist/tools/helpers/pattern-anonymizer.js +159 -0
- package/dist/tools/helpers/project-cache.d.ts +78 -6
- package/dist/tools/helpers/project-cache.js +205 -15
- package/dist/tools/helpers/project-decorators.d.ts +11 -4
- package/dist/tools/helpers/project-decorators.js +13 -6
- package/dist/tools/helpers/refresh-apply.d.ts +94 -0
- package/dist/tools/helpers/refresh-apply.js +460 -0
- package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
- package/dist/tools/helpers/refresh-inventory.js +610 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +74 -5
- package/dist/tools/helpers/scan-cache.js +134 -6
- package/dist/tools/helpers/scan-engine.d.ts +30 -6
- package/dist/tools/helpers/scan-engine.js +131 -22
- package/dist/tools/helpers/scan-plan.d.ts +1 -1
- package/dist/tools/helpers/scan-plan.js +16 -2
- package/dist/tools/helpers/source-map-loader.d.ts +55 -0
- package/dist/tools/helpers/source-map-loader.js +226 -0
- package/dist/tools/helpers/template-check.d.ts +76 -0
- package/dist/tools/helpers/template-check.js +158 -0
- package/dist/tools/helpers/tool-cache.d.ts +7 -2
- package/dist/tools/helpers/tool-cache.js +9 -3
- package/dist/tools/helpers/tool-context.d.ts +18 -0
- package/dist/tools/helpers/tool-context.js +29 -0
- package/dist/tools/helpers/transform-safety.d.ts +151 -1
- package/dist/tools/helpers/transform-safety.js +357 -4
- package/dist/tools/inspect-form-group.d.ts +2 -2
- package/dist/tools/inspect-form-group.js +8 -3
- package/dist/tools/inspect-i18n.d.ts +2 -2
- package/dist/tools/inspect-i18n.js +3 -3
- package/dist/tools/inspect-template.d.ts +2 -2
- package/dist/tools/inspect-template.js +11 -5
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +2 -2
- package/dist/tools/list-imports.js +3 -3
- package/dist/tools/orchestrate-migration.d.ts +19 -1
- package/dist/tools/orchestrate-migration.js +52 -10
- package/dist/tools/parse-stack-trace.d.ts +48 -1
- package/dist/tools/parse-stack-trace.js +108 -9
- package/dist/tools/plan-migration.d.ts +2 -2
- package/dist/tools/plan-migration.js +25 -12
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.d.ts +2 -2
- package/dist/tools/resolve-type.js +13 -6
- package/dist/tools/review-feedback.d.ts +42 -7
- package/dist/tools/review-feedback.js +24 -17
- package/dist/tools/rollback-changes.d.ts +5 -0
- package/dist/tools/rollback-changes.js +7 -2
- package/dist/tools/run-angular-cli.js +36 -22
- package/dist/tools/run-build.d.ts +33 -28
- package/dist/tools/run-build.js +136 -438
- package/dist/tools/run-schematic.d.ts +8 -2
- package/dist/tools/run-schematic.js +80 -50
- package/dist/tools/scan-all.d.ts +31 -15
- package/dist/tools/scan-all.js +75 -109
- package/dist/tools/scan-angular.d.ts +27 -14
- package/dist/tools/scan-angular.js +70 -92
- package/dist/tools/scan-architecture.d.ts +29 -12
- package/dist/tools/scan-architecture.js +205 -135
- package/dist/tools/scan-solid.d.ts +27 -14
- package/dist/tools/scan-solid.js +73 -89
- package/dist/tools/search-codebase.d.ts +8 -3
- package/dist/tools/search-codebase.js +16 -10
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.d.ts +2 -2
- package/dist/tools/trace-output-flow.js +6 -5
- package/dist/tools/transform-code-batch.d.ts +9 -9
- package/dist/tools/transform-code.d.ts +161 -12
- package/dist/tools/transform-code.js +782 -197
- package/dist/tools/validate-before-transform.js +2 -1
- package/dist/tools/validate-project-compatibility.d.ts +28 -55
- package/dist/tools/validate-project-compatibility.js +33 -225
- package/dist/tools/validate-transformation.d.ts +40 -26
- package/dist/tools/validate-transformation.js +115 -294
- package/dist/tools/verify-citations.js +8 -2
- package/dist/types.d.ts +9 -9
- package/dist/utils/format-tool-response.d.ts +3 -1
- package/dist/utils/format-tool-response.js +8 -3
- package/package.json +14 -13
package/dist/tools/scan-all.js
CHANGED
|
@@ -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 {
|
|
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;
|
|
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-
|
|
19
|
+
const SCAN_ALL_CACHE_VERSION = 'scan-all-5';
|
|
17
20
|
/**
|
|
18
|
-
* MCP tool `scan-all`: one scan with all analysis plugins
|
|
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
|
|
23
|
-
* - AngularPlugin
|
|
24
|
-
* - ArchitecturePlugin
|
|
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
|
|
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: '
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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: ${
|
|
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
|
|
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
|
-
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
let
|
|
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.
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
ctx.progress?.(filesAnalyzed
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
360
|
+
filesFromCache: cacheHits,
|
|
364
361
|
filesToProcess: filesToProcess.length,
|
|
365
362
|
hitRate: finalStats.hitRate,
|
|
366
363
|
hitsBySource: cacheHitsBySource,
|
|
367
364
|
stats: finalStats,
|
|
368
365
|
},
|
|
369
|
-
|
|
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
|
-
/**
|
|
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 (
|
|
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:
|
|
140
|
-
description:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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:
|
|
149
|
-
description:
|
|
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
|
-
*
|
|
168
|
-
*
|
|
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;
|