@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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
2
|
+
import { loadConfig } from '@angular-modernizer/core';
|
|
2
3
|
import { glob } from 'glob';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { cancelledExecution, fileProgressMessage, } from './helpers/tool-context.js';
|
|
4
|
+
import { relative } from 'node:path';
|
|
5
|
+
import { describeScan, DEPRECATED_SCAN_ORCHESTRATION_SCHEMA, SCAN_EXECUTION_SCHEMA, SCAN_ORCHESTRATION_NOTICE, scanOutputSchema, } from './helpers/analysis-output.js';
|
|
6
|
+
import { cancelledExecution, fileProgressMessage, finalFileProgress, } from './helpers/tool-context.js';
|
|
7
7
|
import { runScan } from '../scan-host/scan-host.js';
|
|
8
8
|
import { openToolCache } from './helpers/tool-cache.js';
|
|
9
|
+
import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, SCAN_TOOL_CACHE_VERSION, scanCacheVersion, } from './helpers/scan-cache.js';
|
|
9
10
|
/**
|
|
10
11
|
* MCP tool `scan-angular`: scans for Angular-specific best practice
|
|
11
|
-
* violations. Runs only the AngularPlugin (
|
|
12
|
+
* violations. Runs only the rules of the AngularPlugin (OnPush, TrackBy,
|
|
12
13
|
* performance, RxJS and others).
|
|
13
14
|
*/
|
|
14
15
|
export class ScanAngularTool {
|
|
@@ -37,7 +38,7 @@ export class ScanAngularTool {
|
|
|
37
38
|
rules: {
|
|
38
39
|
type: 'array',
|
|
39
40
|
items: { type: 'string' },
|
|
40
|
-
description: '
|
|
41
|
+
description: 'Rule ids to run (optional, default all rules of the plugin): 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',
|
|
41
42
|
},
|
|
42
43
|
includePatterns: {
|
|
43
44
|
type: 'array',
|
|
@@ -60,6 +61,7 @@ export class ScanAngularTool {
|
|
|
60
61
|
'**/*.test.ts',
|
|
61
62
|
],
|
|
62
63
|
},
|
|
64
|
+
cache: SCAN_CACHE_MODE_SCHEMA,
|
|
63
65
|
includeAutoFixes: {
|
|
64
66
|
type: 'boolean',
|
|
65
67
|
description: 'Whether to include auto-fix suggestions',
|
|
@@ -80,21 +82,7 @@ export class ScanAngularTool {
|
|
|
80
82
|
description: 'Offset for result pagination',
|
|
81
83
|
default: 0,
|
|
82
84
|
},
|
|
83
|
-
orchestration:
|
|
84
|
-
type: 'object',
|
|
85
|
-
description: 'Advanced orchestration options',
|
|
86
|
-
properties: {
|
|
87
|
-
parallel: {
|
|
88
|
-
type: 'boolean',
|
|
89
|
-
description: 'Enable parallel rule execution',
|
|
90
|
-
default: false,
|
|
91
|
-
},
|
|
92
|
-
maxWorkers: {
|
|
93
|
-
type: 'number',
|
|
94
|
-
description: 'Maximum concurrent workers',
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
85
|
+
orchestration: DEPRECATED_SCAN_ORCHESTRATION_SCHEMA,
|
|
98
86
|
},
|
|
99
87
|
required: ['rootPath'],
|
|
100
88
|
};
|
|
@@ -107,7 +95,10 @@ export class ScanAngularTool {
|
|
|
107
95
|
const params = args;
|
|
108
96
|
const config = this.loadConfig(params.rootPath);
|
|
109
97
|
const mergedParams = { ...config, ...params };
|
|
110
|
-
|
|
98
|
+
// `rules` selects the rules that run (E-19), not only the reported findings
|
|
99
|
+
const ruleSelection = mergedParams.rules?.length ? mergedParams.rules : undefined;
|
|
100
|
+
// orchestration has no effect: the scan always runs in the scan worker
|
|
101
|
+
const notices = mergedParams.orchestration === undefined ? [] : [SCAN_ORCHESTRATION_NOTICE];
|
|
111
102
|
if (!mergedParams.rootPath) {
|
|
112
103
|
throw new Error('rootPath is required');
|
|
113
104
|
}
|
|
@@ -134,6 +125,8 @@ export class ScanAngularTool {
|
|
|
134
125
|
cwd: mergedParams.rootPath,
|
|
135
126
|
absolute: true,
|
|
136
127
|
ignore: excludePatterns,
|
|
128
|
+
// A directory named like a source file (`scaleData.ts/`) is no file
|
|
129
|
+
nodir: true,
|
|
137
130
|
});
|
|
138
131
|
allFiles.push(...files);
|
|
139
132
|
}
|
|
@@ -141,12 +134,15 @@ export class ScanAngularTool {
|
|
|
141
134
|
const uniqueFiles = Array.from(new Set(allFiles)).sort();
|
|
142
135
|
const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
|
|
143
136
|
const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
|
|
144
|
-
const cache = await openToolCache(mergedParams.rootPath, 'angular'
|
|
137
|
+
const cache = await openToolCache(mergedParams.rootPath, 'angular', scanCacheVersion(SCAN_TOOL_CACHE_VERSION, mergedParams.rootPath, ruleSelection, {
|
|
138
|
+
includePatterns: mergedParams.includePatterns,
|
|
139
|
+
excludePatterns: mergedParams.excludePatterns,
|
|
140
|
+
}));
|
|
145
141
|
// ============================================================================
|
|
146
142
|
// CACHE READ SYSTEM
|
|
147
143
|
// ============================================================================
|
|
148
144
|
// Before analyzing files, check if cached results exist for unchanged files.
|
|
149
|
-
//
|
|
145
|
+
// A warm run analyzes only new and changed files.
|
|
150
146
|
//
|
|
151
147
|
// How it works:
|
|
152
148
|
// 1. For each file, check if cache entry exists via CacheManager.getAnalysisResult()
|
|
@@ -154,27 +150,29 @@ export class ScanAngularTool {
|
|
|
154
150
|
// 3. If cached AND unchanged → reuse cached results
|
|
155
151
|
// 4. If not cached OR changed → add to filesToProcess for analysis
|
|
156
152
|
//
|
|
157
|
-
// Performance results (real-world validation on 2,758 files):
|
|
158
|
-
// - First run: 161.4s (analyzes all files, writes cache)
|
|
159
|
-
// - Second run: 14.1s (11.4x speedup, 91.2% faster, reads from cache)
|
|
160
|
-
//
|
|
161
153
|
// Cache directory: .angular-modernizer-cache/angular/
|
|
162
154
|
// Cache invalidation: Automatic via mtime/content hash checking
|
|
163
155
|
// ============================================================================
|
|
164
|
-
|
|
156
|
+
// Findings per analyzed file, from the cache or the scan
|
|
157
|
+
const findingsByFile = new Map();
|
|
158
|
+
let cachedFindings = 0;
|
|
165
159
|
const filesToProcess = [];
|
|
160
|
+
// One entry per analyzed file, also without findings: findings on its
|
|
161
|
+
// template stay with the component file, the template is a dependency.
|
|
162
|
+
// refresh analyzes every file; the write below overwrites the entries
|
|
163
|
+
const cacheMode = scanCacheMode(args);
|
|
166
164
|
for (const filePath of filesToAnalyze) {
|
|
167
|
-
const cached = await
|
|
168
|
-
if (cached
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
const cached = cacheMode === 'refresh' ? null : await readCachedFindings(filePath, cache);
|
|
166
|
+
if (cached !== null) {
|
|
167
|
+
findingsByFile.set(filePath, cached);
|
|
168
|
+
cachedFindings += cached.length;
|
|
171
169
|
}
|
|
172
170
|
else {
|
|
173
171
|
// File not cached or has changed
|
|
174
172
|
filesToProcess.push(filePath);
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
|
-
console.info(`Cache: ${
|
|
175
|
+
console.info(`Cache: ${cachedFindings} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${cache.getStats().hitRate.toFixed(1)}%)`);
|
|
178
176
|
// ============================================================================
|
|
179
177
|
// BATCH PROCESSING SYSTEM
|
|
180
178
|
// ============================================================================
|
|
@@ -191,14 +189,16 @@ export class ScanAngularTool {
|
|
|
191
189
|
const totalFiles = filesToProcess.length;
|
|
192
190
|
const totalBatches = Math.ceil(totalFiles / batchSize);
|
|
193
191
|
console.info(`\nProcessing ${totalFiles} files in ${totalBatches} batch(es) of ${batchSize} files each`);
|
|
194
|
-
//
|
|
195
|
-
const
|
|
196
|
-
let
|
|
192
|
+
// Per newly analyzed file its findings (also those on its template) and template files
|
|
193
|
+
const entriesForCache = new Map();
|
|
194
|
+
let newFindings = 0;
|
|
197
195
|
// Kernel, batches and rules run in a scan worker (scan-host), so the
|
|
198
196
|
// server keeps reading stdin while the type checker is built.
|
|
199
197
|
const cachedFiles = filesToAnalyze.length - totalFiles;
|
|
200
198
|
let processedFiles = 0;
|
|
199
|
+
let lastReported;
|
|
201
200
|
if (totalFiles > 0) {
|
|
201
|
+
lastReported = cachedFiles;
|
|
202
202
|
ctx.progress?.(cachedFiles, filesToAnalyze.length, `loading project, ${totalFiles} files to analyze`);
|
|
203
203
|
}
|
|
204
204
|
const engine = await runScan({
|
|
@@ -209,19 +209,28 @@ export class ScanAngularTool {
|
|
|
209
209
|
files: filesToProcess,
|
|
210
210
|
mode: 'batches',
|
|
211
211
|
batchSize,
|
|
212
|
-
|
|
212
|
+
templateDependencies: true,
|
|
213
|
+
contextFiles: filesToAnalyze,
|
|
214
|
+
...(ruleSelection === undefined ? {} : { ruleIds: ruleSelection }),
|
|
213
215
|
}, {
|
|
214
216
|
file: (event) => {
|
|
215
|
-
|
|
217
|
+
entriesForCache.set(event.filePath, {
|
|
218
|
+
results: event.findings,
|
|
219
|
+
dependencies: event.dependencies ?? [],
|
|
220
|
+
});
|
|
221
|
+
findingsByFile.set(event.filePath, event.findings);
|
|
222
|
+
newFindings += event.findings.length;
|
|
216
223
|
processedFiles++;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
batchDone: (files) => {
|
|
220
|
-
filesAnalyzed += files;
|
|
224
|
+
lastReported = cachedFiles + processedFiles;
|
|
225
|
+
ctx.progress?.(cachedFiles + processedFiles, filesToAnalyze.length, fileProgressMessage(cachedFiles + processedFiles, filesToAnalyze.length, cachedFindings + newFindings));
|
|
221
226
|
},
|
|
222
227
|
}, { signal: ctx.signal });
|
|
223
228
|
const cancelled = engine.cancelled;
|
|
224
|
-
|
|
229
|
+
if (!cancelled) {
|
|
230
|
+
finalFileProgress(ctx.progress, filesToAnalyze.length, cachedFiles + processedFiles, cachedFindings + newFindings, lastReported);
|
|
231
|
+
}
|
|
232
|
+
const results = findingsInFileOrder(findingsByFile);
|
|
233
|
+
console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${cachedFiles + processedFiles} total files analyzed, ${results.length} total violations`);
|
|
225
234
|
// ============================================================================
|
|
226
235
|
// CACHE WRITE SYSTEM
|
|
227
236
|
// ============================================================================
|
|
@@ -231,32 +240,18 @@ export class ScanAngularTool {
|
|
|
231
240
|
// Cache directory: .angular-modernizer-cache/angular/
|
|
232
241
|
// Cache entry format: Same as scan-solid (metadata + results[] + dependencies)
|
|
233
242
|
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
// - Second run: Reads cache (11.4x speedup - one of the best improvements!)
|
|
237
|
-
//
|
|
238
|
-
// Why Angular benefits more from caching than SOLID:
|
|
239
|
-
// - Angular rules are more computationally expensive (template parsing, decorators)
|
|
240
|
-
// - Parsing Angular templates and metadata takes significant time
|
|
241
|
-
// - Cache hit eliminates all AST parsing and decorator analysis overhead
|
|
243
|
+
// A cache hit skips the analysis of the file by every rule (template
|
|
244
|
+
// parsing, decorators).
|
|
242
245
|
// ============================================================================
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (!resultsByFile.has(filePath)) {
|
|
249
|
-
resultsByFile.set(filePath, []);
|
|
250
|
-
}
|
|
251
|
-
resultsByFile.get(filePath).push(result);
|
|
252
|
-
}
|
|
253
|
-
// Write each file's results to cache
|
|
254
|
-
for (const [filePath, fileResults] of resultsByFile.entries()) {
|
|
255
|
-
await cache.setAnalysisResult(filePath, fileResults);
|
|
246
|
+
// A cancelled scan writes nothing: files analyzed before the cancel saw only
|
|
247
|
+
// part of the project, so cross-file and template findings could differ from
|
|
248
|
+
// a full run and a later warm run would serve them as current.
|
|
249
|
+
for (const [filePath, entry] of cancelled ? [] : entriesForCache) {
|
|
250
|
+
await cache.setAnalysisResult(filePath, entry.results, entry.dependencies);
|
|
256
251
|
}
|
|
257
252
|
// Log cache effectiveness
|
|
258
253
|
const stats = cache.getStats();
|
|
259
|
-
console.info(`Cached ${
|
|
254
|
+
console.info(`Cached ${cancelled ? 0 : entriesForCache.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
|
|
260
255
|
// Filter by specific rules if requested
|
|
261
256
|
let violations = results
|
|
262
257
|
.filter((r) => r.ruleId && r.filePath)
|
|
@@ -283,7 +278,8 @@ export class ScanAngularTool {
|
|
|
283
278
|
const maxResults = mergedParams.maxResults ?? 1000;
|
|
284
279
|
const paginatedViolations = violations.slice(offset, offset + maxResults);
|
|
285
280
|
// Counts cover every violation, not only the page
|
|
286
|
-
|
|
281
|
+
// A file that failed to load sends no result and is not analyzed
|
|
282
|
+
const analyzedFiles = cachedFiles + processedFiles;
|
|
287
283
|
const counts = this.calculateSummary(violations, analyzedFiles);
|
|
288
284
|
const execution = cancelled
|
|
289
285
|
? cancelledExecution(analyzedFiles, filesToAnalyze.length - analyzedFiles)
|
|
@@ -304,42 +300,24 @@ export class ScanAngularTool {
|
|
|
304
300
|
duration,
|
|
305
301
|
projectRoot: mergedParams.rootPath,
|
|
306
302
|
},
|
|
307
|
-
|
|
308
|
-
? {
|
|
309
|
-
parallel: true,
|
|
310
|
-
incremental: false,
|
|
311
|
-
filesAnalyzed: filesToAnalyze.length,
|
|
312
|
-
filesSkipped: 0,
|
|
313
|
-
cacheHitRate: 0,
|
|
314
|
-
duration,
|
|
315
|
-
throughput: filesToAnalyze.length / (duration / 1000),
|
|
316
|
-
}
|
|
317
|
-
: undefined,
|
|
303
|
+
...(notices.length === 0 ? {} : { warnings: notices }),
|
|
318
304
|
pagination,
|
|
319
305
|
...(execution === undefined ? {} : { execution }),
|
|
320
|
-
summary: describeScan(counts, paginatedViolations, pagination, execution === undefined ? [] : [execution.note]),
|
|
306
|
+
summary: describeScan(counts, paginatedViolations, pagination, [...notices, ...(execution === undefined ? [] : [execution.note])]),
|
|
321
307
|
};
|
|
322
308
|
}
|
|
323
309
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
310
|
+
* The `tools['scan-angular']` section of `.angular-modernizer.json`; arguments of
|
|
311
|
+
* the call override it.
|
|
326
312
|
*/
|
|
327
313
|
loadConfig(rootPath) {
|
|
328
|
-
// Ensure rootPath is provided before loading config
|
|
329
314
|
if (!rootPath) {
|
|
330
315
|
return {};
|
|
331
316
|
}
|
|
332
|
-
const configPath = resolve(rootPath, '.angular-modernizer.json');
|
|
333
|
-
if (!existsSync(configPath)) {
|
|
334
|
-
return {};
|
|
335
|
-
}
|
|
336
317
|
try {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const scanAngularConfig = config['scan-angular'];
|
|
341
|
-
if (scanAngularConfig && typeof scanAngularConfig === 'object') {
|
|
342
|
-
return scanAngularConfig;
|
|
318
|
+
const toolConfig = loadConfig(rootPath).tools?.['scan-angular'];
|
|
319
|
+
if (toolConfig && typeof toolConfig === 'object') {
|
|
320
|
+
return toolConfig;
|
|
343
321
|
}
|
|
344
322
|
}
|
|
345
323
|
catch (error) {
|
|
@@ -46,12 +46,17 @@ export interface ResolvedScope {
|
|
|
46
46
|
export interface ScanExecution {
|
|
47
47
|
/** Time budget of the scan in milliseconds; `0` means no budget. */
|
|
48
48
|
maxDurationMs: number;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* `true` when the time budget or a cancellation stopped the scan early, or
|
|
51
|
+
* `maxFiles` left files of the scope out.
|
|
52
|
+
*/
|
|
50
53
|
incomplete: boolean;
|
|
51
|
-
/** Why the scan stopped early. */
|
|
52
|
-
stopReason?: 'time-budget' | 'cancelled';
|
|
53
|
-
/** Files that were not analyzed
|
|
54
|
+
/** Why the scan stopped early or left files out. */
|
|
55
|
+
stopReason?: 'time-budget' | 'cancelled' | 'max-files';
|
|
56
|
+
/** Files of the scope that were not analyzed. */
|
|
54
57
|
skippedFiles: number;
|
|
58
|
+
/** Files in the scope before the `maxFiles` cap; set when the cap cut files. */
|
|
59
|
+
scopeFiles?: number;
|
|
55
60
|
/** Time per rule, slowest first. */
|
|
56
61
|
ruleTimings: RuleTiming[];
|
|
57
62
|
/** Human-readable note on an incomplete scan. */
|
|
@@ -77,7 +82,7 @@ export interface ScanArchitectureResult {
|
|
|
77
82
|
severity: 'error' | 'warning' | 'info';
|
|
78
83
|
/** Rule message. */
|
|
79
84
|
message: string;
|
|
80
|
-
/** File the violation was reported on
|
|
85
|
+
/** File the violation was reported on, relative to `rootPath`. */
|
|
81
86
|
filePath: string;
|
|
82
87
|
/** 1-based line of the finding, when the rule reports one. */
|
|
83
88
|
line?: number;
|
|
@@ -206,8 +211,8 @@ export interface ScanArchitectureResult {
|
|
|
206
211
|
}
|
|
207
212
|
/**
|
|
208
213
|
* MCP tool `scan-architecture`: scans for architectural issues. Runs only the
|
|
209
|
-
* ArchitecturePlugin (
|
|
210
|
-
* and others).
|
|
214
|
+
* rules of the ArchitecturePlugin (import cycles, layer violations, god
|
|
215
|
+
* objects and others).
|
|
211
216
|
*/
|
|
212
217
|
export declare class ScanArchitectureTool implements MCPTool {
|
|
213
218
|
readonly name = "scan-architecture";
|
|
@@ -275,10 +280,16 @@ export declare class ScanArchitectureTool implements MCPTool {
|
|
|
275
280
|
description: string;
|
|
276
281
|
default: string[];
|
|
277
282
|
};
|
|
283
|
+
cache: {
|
|
284
|
+
description: string;
|
|
285
|
+
type: "string";
|
|
286
|
+
enum: readonly ["use", "refresh"];
|
|
287
|
+
default: "use";
|
|
288
|
+
};
|
|
278
289
|
includeAutoFixes: {
|
|
279
290
|
type: string;
|
|
280
291
|
description: string;
|
|
281
|
-
|
|
292
|
+
deprecated: boolean;
|
|
282
293
|
};
|
|
283
294
|
maxFiles: {
|
|
284
295
|
type: string;
|
|
@@ -422,15 +433,21 @@ export declare class ScanArchitectureTool implements MCPTool {
|
|
|
422
433
|
*/
|
|
423
434
|
private calculateSummary;
|
|
424
435
|
/**
|
|
425
|
-
*
|
|
426
|
-
* Only loads from the provided root path
|
|
436
|
+
* The `tools['scan-architecture']` section of `.angular-modernizer.json`.
|
|
437
|
+
* Only loads from the provided root path, never from the server's cwd.
|
|
427
438
|
*/
|
|
428
439
|
private loadConfig;
|
|
429
440
|
/**
|
|
430
|
-
* Resolve scope configuration to actual file paths.
|
|
431
|
-
*
|
|
441
|
+
* Resolve scope configuration to actual file paths. A scope other than
|
|
442
|
+
* `all` that resolves to no path is an error: the file filter treats an
|
|
443
|
+
* empty path list as "everything", so such a scope used to scan the whole
|
|
444
|
+
* project (its first `maxFiles` files) instead of nothing.
|
|
432
445
|
*/
|
|
433
446
|
private resolveScope;
|
|
447
|
+
/**
|
|
448
|
+
* Paths a scope stands for. Reads angular.json to find project paths.
|
|
449
|
+
*/
|
|
450
|
+
private resolveScopePaths;
|
|
434
451
|
/**
|
|
435
452
|
* Filter files based on resolved scope paths.
|
|
436
453
|
*/
|