@angular-modernizer/adapter-mcp 1.2.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 +84 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +9 -0
- 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 +7 -4
- package/dist/tools/analyze-build-impact.js +8 -3
- 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 +30 -4
- package/dist/tools/analyze-project.js +99 -15
- 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.js +3 -2
- package/dist/tools/find-component-hosts.js +3 -2
- package/dist/tools/find-usages.js +21 -12
- package/dist/tools/get-call-graph.js +15 -2
- 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 +5 -4
- package/dist/tools/helpers/project-cache.js +21 -16
- 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.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.js +5 -0
- package/dist/tools/inspect-i18n.d.ts +1 -1
- package/dist/tools/inspect-template.js +8 -2
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +1 -1
- 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.js +22 -10
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.js +10 -3
- 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 +6 -1
- package/dist/tools/search-codebase.js +13 -7
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.js +3 -2
- 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 +715 -206
- 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-solid.js
CHANGED
|
@@ -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-solid`: scans for SOLID principle violations. Runs only the
|
|
11
|
-
* SolidPlugin (
|
|
12
|
+
* rules of the SolidPlugin (DIP, SRP, LSP, OCP, ISP).
|
|
12
13
|
*/
|
|
13
14
|
export class ScanSolidTool {
|
|
14
15
|
name = 'scan-solid';
|
|
@@ -36,7 +37,7 @@ export class ScanSolidTool {
|
|
|
36
37
|
rules: {
|
|
37
38
|
type: 'array',
|
|
38
39
|
items: { type: 'string' },
|
|
39
|
-
description: '
|
|
40
|
+
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',
|
|
40
41
|
},
|
|
41
42
|
includePatterns: {
|
|
42
43
|
type: 'array',
|
|
@@ -59,6 +60,7 @@ export class ScanSolidTool {
|
|
|
59
60
|
'**/*.test.ts',
|
|
60
61
|
],
|
|
61
62
|
},
|
|
63
|
+
cache: SCAN_CACHE_MODE_SCHEMA,
|
|
62
64
|
includeAutoFixes: {
|
|
63
65
|
type: 'boolean',
|
|
64
66
|
description: 'Whether to include auto-fix suggestions',
|
|
@@ -79,21 +81,7 @@ export class ScanSolidTool {
|
|
|
79
81
|
description: 'Offset for result pagination',
|
|
80
82
|
default: 0,
|
|
81
83
|
},
|
|
82
|
-
orchestration:
|
|
83
|
-
type: 'object',
|
|
84
|
-
description: 'Advanced orchestration options',
|
|
85
|
-
properties: {
|
|
86
|
-
parallel: {
|
|
87
|
-
type: 'boolean',
|
|
88
|
-
description: 'Enable parallel rule execution',
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
maxWorkers: {
|
|
92
|
-
type: 'number',
|
|
93
|
-
description: 'Maximum concurrent workers',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
84
|
+
orchestration: DEPRECATED_SCAN_ORCHESTRATION_SCHEMA,
|
|
97
85
|
},
|
|
98
86
|
required: ['rootPath'],
|
|
99
87
|
};
|
|
@@ -106,7 +94,10 @@ export class ScanSolidTool {
|
|
|
106
94
|
const params = args;
|
|
107
95
|
const config = this.loadConfig(params.rootPath);
|
|
108
96
|
const mergedParams = { ...config, ...params };
|
|
109
|
-
|
|
97
|
+
// `rules` selects the rules that run (E-19), not only the reported findings
|
|
98
|
+
const ruleSelection = mergedParams.rules?.length ? mergedParams.rules : undefined;
|
|
99
|
+
// orchestration has no effect: the scan always runs in the scan worker
|
|
100
|
+
const notices = mergedParams.orchestration === undefined ? [] : [SCAN_ORCHESTRATION_NOTICE];
|
|
110
101
|
if (!mergedParams.rootPath) {
|
|
111
102
|
throw new Error('rootPath is required');
|
|
112
103
|
}
|
|
@@ -133,6 +124,8 @@ export class ScanSolidTool {
|
|
|
133
124
|
cwd: mergedParams.rootPath,
|
|
134
125
|
absolute: true,
|
|
135
126
|
ignore: excludePatterns,
|
|
127
|
+
// A directory named like a source file (`scaleData.ts/`) is no file
|
|
128
|
+
nodir: true,
|
|
136
129
|
});
|
|
137
130
|
allFiles.push(...files);
|
|
138
131
|
}
|
|
@@ -140,12 +133,15 @@ export class ScanSolidTool {
|
|
|
140
133
|
const uniqueFiles = Array.from(new Set(allFiles)).sort();
|
|
141
134
|
const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
|
|
142
135
|
const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
|
|
143
|
-
const cache = await openToolCache(mergedParams.rootPath, 'solid'
|
|
136
|
+
const cache = await openToolCache(mergedParams.rootPath, 'solid', scanCacheVersion(SCAN_TOOL_CACHE_VERSION, mergedParams.rootPath, ruleSelection, {
|
|
137
|
+
includePatterns: mergedParams.includePatterns,
|
|
138
|
+
excludePatterns: mergedParams.excludePatterns,
|
|
139
|
+
}));
|
|
144
140
|
// ============================================================================
|
|
145
141
|
// CACHE READ SYSTEM
|
|
146
142
|
// ============================================================================
|
|
147
143
|
// Before analyzing files, check if cached results exist for unchanged files.
|
|
148
|
-
//
|
|
144
|
+
// A warm run analyzes only new and changed files.
|
|
149
145
|
//
|
|
150
146
|
// How it works:
|
|
151
147
|
// 1. For each file, check if cache entry exists via CacheManager.getAnalysisResult()
|
|
@@ -153,27 +149,29 @@ export class ScanSolidTool {
|
|
|
153
149
|
// 3. If cached AND unchanged → reuse cached results
|
|
154
150
|
// 4. If not cached OR changed → add to filesToProcess for analysis
|
|
155
151
|
//
|
|
156
|
-
// Performance results (real-world validation on 2,758 files):
|
|
157
|
-
// - First run: 62.7s (analyzes all files, writes cache)
|
|
158
|
-
// - Second run: 42.4s (1.5x speedup, 32% faster, reads from cache)
|
|
159
|
-
//
|
|
160
152
|
// Cache directory: .angular-modernizer-cache/solid/
|
|
161
153
|
// Cache invalidation: Automatic via mtime/content hash checking
|
|
162
154
|
// ============================================================================
|
|
163
|
-
|
|
155
|
+
// Findings per analyzed file, from the cache or the scan
|
|
156
|
+
const findingsByFile = new Map();
|
|
157
|
+
let cachedFindings = 0;
|
|
164
158
|
const filesToProcess = [];
|
|
159
|
+
// One entry per analyzed file, also without findings: findings on its
|
|
160
|
+
// template stay with the component file, the template is a dependency.
|
|
161
|
+
// refresh analyzes every file; the write below overwrites the entries
|
|
162
|
+
const cacheMode = scanCacheMode(args);
|
|
165
163
|
for (const filePath of filesToAnalyze) {
|
|
166
|
-
const cached = await
|
|
167
|
-
if (cached
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
const cached = cacheMode === 'refresh' ? null : await readCachedFindings(filePath, cache);
|
|
165
|
+
if (cached !== null) {
|
|
166
|
+
findingsByFile.set(filePath, cached);
|
|
167
|
+
cachedFindings += cached.length;
|
|
170
168
|
}
|
|
171
169
|
else {
|
|
172
170
|
// File not cached or has changed
|
|
173
171
|
filesToProcess.push(filePath);
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
|
-
console.info(`Cache: ${
|
|
174
|
+
console.info(`Cache: ${cachedFindings} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${cache.getStats().hitRate.toFixed(1)}%)`);
|
|
177
175
|
// ============================================================================
|
|
178
176
|
// BATCH PROCESSING SYSTEM
|
|
179
177
|
// ============================================================================
|
|
@@ -205,14 +203,16 @@ export class ScanSolidTool {
|
|
|
205
203
|
const totalFiles = filesToProcess.length;
|
|
206
204
|
const totalBatches = Math.ceil(totalFiles / batchSize);
|
|
207
205
|
console.info(`\nProcessing ${totalFiles} files in ${totalBatches} batch(es) of ${batchSize} files each`);
|
|
208
|
-
//
|
|
209
|
-
const
|
|
210
|
-
let
|
|
206
|
+
// Per newly analyzed file its findings (also those on its template) and template files
|
|
207
|
+
const entriesForCache = new Map();
|
|
208
|
+
let newFindings = 0;
|
|
211
209
|
// Kernel, batches and rules run in a scan worker (scan-host), so the
|
|
212
210
|
// server keeps reading stdin while the type checker is built.
|
|
213
211
|
const cachedFiles = filesToAnalyze.length - totalFiles;
|
|
214
212
|
let processedFiles = 0;
|
|
213
|
+
let lastReported;
|
|
215
214
|
if (totalFiles > 0) {
|
|
215
|
+
lastReported = cachedFiles;
|
|
216
216
|
ctx.progress?.(cachedFiles, filesToAnalyze.length, `loading project, ${totalFiles} files to analyze`);
|
|
217
217
|
}
|
|
218
218
|
const engine = await runScan({
|
|
@@ -223,19 +223,28 @@ export class ScanSolidTool {
|
|
|
223
223
|
files: filesToProcess,
|
|
224
224
|
mode: 'batches',
|
|
225
225
|
batchSize,
|
|
226
|
-
|
|
226
|
+
templateDependencies: true,
|
|
227
|
+
contextFiles: filesToAnalyze,
|
|
228
|
+
...(ruleSelection === undefined ? {} : { ruleIds: ruleSelection }),
|
|
227
229
|
}, {
|
|
228
230
|
file: (event) => {
|
|
229
|
-
|
|
231
|
+
entriesForCache.set(event.filePath, {
|
|
232
|
+
results: event.findings,
|
|
233
|
+
dependencies: event.dependencies ?? [],
|
|
234
|
+
});
|
|
235
|
+
findingsByFile.set(event.filePath, event.findings);
|
|
236
|
+
newFindings += event.findings.length;
|
|
230
237
|
processedFiles++;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
batchDone: (files) => {
|
|
234
|
-
filesAnalyzed += files;
|
|
238
|
+
lastReported = cachedFiles + processedFiles;
|
|
239
|
+
ctx.progress?.(cachedFiles + processedFiles, filesToAnalyze.length, fileProgressMessage(cachedFiles + processedFiles, filesToAnalyze.length, cachedFindings + newFindings));
|
|
235
240
|
},
|
|
236
241
|
}, { signal: ctx.signal });
|
|
237
242
|
const cancelled = engine.cancelled;
|
|
238
|
-
|
|
243
|
+
if (!cancelled) {
|
|
244
|
+
finalFileProgress(ctx.progress, filesToAnalyze.length, cachedFiles + processedFiles, cachedFindings + newFindings, lastReported);
|
|
245
|
+
}
|
|
246
|
+
const results = findingsInFileOrder(findingsByFile);
|
|
247
|
+
console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${cachedFiles + processedFiles} total files analyzed, ${results.length} total violations`);
|
|
239
248
|
// ============================================================================
|
|
240
249
|
// CACHE WRITE SYSTEM
|
|
241
250
|
// ============================================================================
|
|
@@ -243,9 +252,11 @@ export class ScanSolidTool {
|
|
|
243
252
|
// This enables cache reads to skip unchanged files on subsequent runs.
|
|
244
253
|
//
|
|
245
254
|
// How it works:
|
|
246
|
-
// 1.
|
|
247
|
-
//
|
|
255
|
+
// 1. One cache entry per analyzed file, also without findings, holding all
|
|
256
|
+
// of its findings (also those reported on its template)
|
|
257
|
+
// 2. Write each entry via CacheManager.setAnalysisResult()
|
|
248
258
|
// 3. CacheManager stores: results[], metadata (mtime, hash, size), dependencies
|
|
259
|
+
// (the template files)
|
|
249
260
|
//
|
|
250
261
|
// Why plugin-specific cache directories?
|
|
251
262
|
// - Each scan tool (scan-solid, scan-angular, scan-architecture, scan-all) uses
|
|
@@ -260,27 +271,17 @@ export class ScanSolidTool {
|
|
|
260
271
|
// dependencies: []
|
|
261
272
|
// }
|
|
262
273
|
//
|
|
263
|
-
//
|
|
264
|
-
// - First run: Writes cache (adds ~1-2% overhead)
|
|
265
|
-
// - Second run: Reads cache (1.5x-39x speedup depending on scan type)
|
|
274
|
+
// A cache hit skips the analysis of the file by every rule.
|
|
266
275
|
// ============================================================================
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (!resultsByFile.has(filePath)) {
|
|
273
|
-
resultsByFile.set(filePath, []);
|
|
274
|
-
}
|
|
275
|
-
resultsByFile.get(filePath).push(result);
|
|
276
|
-
}
|
|
277
|
-
// Write each file's results to cache
|
|
278
|
-
for (const [filePath, fileResults] of resultsByFile.entries()) {
|
|
279
|
-
await cache.setAnalysisResult(filePath, fileResults);
|
|
276
|
+
// A cancelled scan writes nothing: files analyzed before the cancel saw only
|
|
277
|
+
// part of the project, so cross-file and template findings could differ from
|
|
278
|
+
// a full run and a later warm run would serve them as current.
|
|
279
|
+
for (const [filePath, entry] of cancelled ? [] : entriesForCache) {
|
|
280
|
+
await cache.setAnalysisResult(filePath, entry.results, entry.dependencies);
|
|
280
281
|
}
|
|
281
282
|
// Log cache effectiveness
|
|
282
283
|
const stats = cache.getStats();
|
|
283
|
-
console.info(`Cached ${
|
|
284
|
+
console.info(`Cached ${cancelled ? 0 : entriesForCache.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
|
|
284
285
|
// Filter by specific rules if requested
|
|
285
286
|
let violations = results
|
|
286
287
|
.filter((r) => r.ruleId && r.filePath)
|
|
@@ -307,7 +308,8 @@ export class ScanSolidTool {
|
|
|
307
308
|
const maxResults = mergedParams.maxResults ?? 1000;
|
|
308
309
|
const paginatedViolations = violations.slice(offset, offset + maxResults);
|
|
309
310
|
// Counts cover every violation, not only the page
|
|
310
|
-
|
|
311
|
+
// A file that failed to load sends no result and is not analyzed
|
|
312
|
+
const analyzedFiles = cachedFiles + processedFiles;
|
|
311
313
|
const counts = this.calculateSummary(violations, analyzedFiles);
|
|
312
314
|
const execution = cancelled
|
|
313
315
|
? cancelledExecution(analyzedFiles, filesToAnalyze.length - analyzedFiles)
|
|
@@ -328,42 +330,24 @@ export class ScanSolidTool {
|
|
|
328
330
|
duration,
|
|
329
331
|
projectRoot: mergedParams.rootPath,
|
|
330
332
|
},
|
|
331
|
-
|
|
332
|
-
? {
|
|
333
|
-
parallel: true,
|
|
334
|
-
incremental: false,
|
|
335
|
-
filesAnalyzed: filesToAnalyze.length,
|
|
336
|
-
filesSkipped: 0,
|
|
337
|
-
cacheHitRate: 0,
|
|
338
|
-
duration,
|
|
339
|
-
throughput: filesToAnalyze.length / (duration / 1000),
|
|
340
|
-
}
|
|
341
|
-
: undefined,
|
|
333
|
+
...(notices.length === 0 ? {} : { warnings: notices }),
|
|
342
334
|
pagination,
|
|
343
335
|
...(execution === undefined ? {} : { execution }),
|
|
344
|
-
summary: describeScan(counts, paginatedViolations, pagination, execution === undefined ? [] : [execution.note]),
|
|
336
|
+
summary: describeScan(counts, paginatedViolations, pagination, [...notices, ...(execution === undefined ? [] : [execution.note])]),
|
|
345
337
|
};
|
|
346
338
|
}
|
|
347
339
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
340
|
+
* The `tools['scan-solid']` section of `.angular-modernizer.json`; arguments of
|
|
341
|
+
* the call override it.
|
|
350
342
|
*/
|
|
351
343
|
loadConfig(rootPath) {
|
|
352
|
-
// Ensure rootPath is provided before loading config
|
|
353
344
|
if (!rootPath) {
|
|
354
345
|
return {};
|
|
355
346
|
}
|
|
356
|
-
const configPath = resolve(rootPath, '.angular-modernizer.json');
|
|
357
|
-
if (!existsSync(configPath)) {
|
|
358
|
-
return {};
|
|
359
|
-
}
|
|
360
347
|
try {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const scanSolidConfig = config['scan-solid'];
|
|
365
|
-
if (scanSolidConfig && typeof scanSolidConfig === 'object') {
|
|
366
|
-
return scanSolidConfig;
|
|
348
|
+
const toolConfig = loadConfig(rootPath).tools?.['scan-solid'];
|
|
349
|
+
if (toolConfig && typeof toolConfig === 'object') {
|
|
350
|
+
return toolConfig;
|
|
367
351
|
}
|
|
368
352
|
}
|
|
369
353
|
catch (error) {
|
|
@@ -7,8 +7,10 @@ import { ProjectCache } from './helpers/project-cache.js';
|
|
|
7
7
|
export interface SearchCodebaseOutput {
|
|
8
8
|
/** Matches, at most `maxResults` (default 100). */
|
|
9
9
|
results: SearchResult[];
|
|
10
|
-
/** Number of
|
|
10
|
+
/** Number of all matches, also those `maxResults` left out of `results`. */
|
|
11
11
|
totalCount: number;
|
|
12
|
+
/** True when `maxResults` cut matches from `results`. */
|
|
13
|
+
truncated: boolean;
|
|
12
14
|
/** Short text summary of the matches. */
|
|
13
15
|
summary: string;
|
|
14
16
|
/** Which files the search covered, including the tsconfig used. */
|
|
@@ -131,6 +133,9 @@ export declare class SearchCodebaseTool implements MCPTool {
|
|
|
131
133
|
totalCount: {
|
|
132
134
|
type: string;
|
|
133
135
|
};
|
|
136
|
+
truncated: {
|
|
137
|
+
type: string;
|
|
138
|
+
};
|
|
134
139
|
summary: {
|
|
135
140
|
type: string;
|
|
136
141
|
};
|
|
@@ -74,7 +74,8 @@ export class SearchCodebaseTool {
|
|
|
74
74
|
},
|
|
75
75
|
maxResults: {
|
|
76
76
|
type: 'number',
|
|
77
|
-
description: 'Maximum number of results to return. Defaults to 100.'
|
|
77
|
+
description: 'Maximum number of results to return. Defaults to 100. totalCount still counts every match and ' +
|
|
78
|
+
'truncated is true when the list was cut.',
|
|
78
79
|
},
|
|
79
80
|
includeTemplates: {
|
|
80
81
|
type: 'boolean',
|
|
@@ -111,6 +112,7 @@ export class SearchCodebaseTool {
|
|
|
111
112
|
},
|
|
112
113
|
},
|
|
113
114
|
totalCount: { type: 'integer' },
|
|
115
|
+
truncated: { type: 'boolean' },
|
|
114
116
|
summary: { type: 'string' },
|
|
115
117
|
coverage: {
|
|
116
118
|
type: 'object',
|
|
@@ -134,7 +136,7 @@ export class SearchCodebaseTool {
|
|
|
134
136
|
},
|
|
135
137
|
...WARNINGS_OUTPUT_SCHEMA,
|
|
136
138
|
},
|
|
137
|
-
required: ['results', 'totalCount', 'summary', 'coverage'],
|
|
139
|
+
required: ['results', 'totalCount', 'truncated', 'summary', 'coverage'],
|
|
138
140
|
};
|
|
139
141
|
async execute(args, ctx = {}) {
|
|
140
142
|
const params = args;
|
|
@@ -156,7 +158,7 @@ export class SearchCodebaseTool {
|
|
|
156
158
|
}
|
|
157
159
|
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
158
160
|
const searcher = new CodebaseSearcher(project);
|
|
159
|
-
const { results, coverage } = searcher.searchWithCoverage(params.query, {
|
|
161
|
+
const { results, totalCount, coverage } = searcher.searchWithCoverage(params.query, {
|
|
160
162
|
mode: params.mode,
|
|
161
163
|
include: params.include,
|
|
162
164
|
maxResults: params.maxResults ?? 100,
|
|
@@ -167,8 +169,9 @@ export class SearchCodebaseTool {
|
|
|
167
169
|
const hint = results.length === 0 ? this.buildZeroHitHint(params.mode, coverage) : undefined;
|
|
168
170
|
return withWarnings({
|
|
169
171
|
results,
|
|
170
|
-
totalCount
|
|
171
|
-
|
|
172
|
+
totalCount,
|
|
173
|
+
truncated: totalCount > results.length,
|
|
174
|
+
summary: this.buildSummary(params.query, params.mode, results, totalCount, hint),
|
|
172
175
|
coverage: {
|
|
173
176
|
...coverage,
|
|
174
177
|
tsConfigPath,
|
|
@@ -196,11 +199,14 @@ export class SearchCodebaseTool {
|
|
|
196
199
|
`and ${coverage.extraFileCount} non-program file(s); excluded ${excluded.join('; ')}. ` +
|
|
197
200
|
'Verify with a raw grep if the result matters.');
|
|
198
201
|
}
|
|
199
|
-
buildSummary(query, mode, results, hint) {
|
|
202
|
+
buildSummary(query, mode, results, totalCount, hint) {
|
|
200
203
|
if (results.length === 0) {
|
|
201
204
|
return `No ${mode} matches found for '${query}'. ${hint ?? ''}`.trim();
|
|
202
205
|
}
|
|
203
|
-
|
|
206
|
+
const shown = totalCount > results.length
|
|
207
|
+
? `${results.length} of ${totalCount} ${mode} matches (cut by maxResults)`
|
|
208
|
+
: `${results.length} ${mode} match${results.length === 1 ? '' : 'es'}`;
|
|
209
|
+
return (`Found ${shown} for '${query}':\n` +
|
|
204
210
|
results
|
|
205
211
|
.slice(0, 5)
|
|
206
212
|
.map((r) => ` ${r.file}:${r.line}:${r.col} - ${r.snippet}`)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
2
2
|
import { type Performance, type Suggestion } from './helpers/suggestion-generator.js';
|
|
3
|
+
import { type SkippedRecords } from './helpers/feedback-sidecar.js';
|
|
3
4
|
/**
|
|
4
5
|
* Output from suggest-improvements tool
|
|
5
6
|
*/
|
|
@@ -16,6 +17,10 @@ export interface SuggestImprovementsOutput {
|
|
|
16
17
|
analysisFeedbackCount: number;
|
|
17
18
|
/** Locations where feedback was read from */
|
|
18
19
|
sourcesRead: string[];
|
|
20
|
+
/** Records of this rule or tool skipped because the feedback sidecar marks them (0 with `includeOutdated`) */
|
|
21
|
+
skippedRecords: SkippedRecords;
|
|
22
|
+
/** Unusable sidecar, or session files changed since refresh-state marked them */
|
|
23
|
+
sidecarWarnings?: string[];
|
|
19
24
|
/** Short text: data points, current performance and the top suggestions */
|
|
20
25
|
summary: string;
|
|
21
26
|
}
|
|
@@ -47,6 +52,11 @@ export declare class SuggestImprovementsTool implements MCPTool {
|
|
|
47
52
|
readonly type: "object";
|
|
48
53
|
readonly additionalProperties: false;
|
|
49
54
|
readonly properties: {
|
|
55
|
+
readonly includeOutdated: {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
readonly default: false;
|
|
58
|
+
readonly description: "Also read the records that .claude-feedback/index/consolidated.json marks as duplicate or outdated (written by refresh-state apply, part 'feedback'); default false skips them and counts them in skippedRecords";
|
|
59
|
+
};
|
|
50
60
|
readonly projectRoot: {
|
|
51
61
|
readonly type: "string";
|
|
52
62
|
readonly description: "Project root path (defaults to process.cwd() if not provided)";
|
|
@@ -77,6 +87,30 @@ export declare class SuggestImprovementsTool implements MCPTool {
|
|
|
77
87
|
outputSchema: {
|
|
78
88
|
type: string;
|
|
79
89
|
properties: {
|
|
90
|
+
summary: {
|
|
91
|
+
type: string;
|
|
92
|
+
};
|
|
93
|
+
skippedRecords: {
|
|
94
|
+
readonly type: "object";
|
|
95
|
+
readonly properties: {
|
|
96
|
+
readonly total: {
|
|
97
|
+
readonly type: "integer";
|
|
98
|
+
};
|
|
99
|
+
readonly byReason: {
|
|
100
|
+
readonly type: "object";
|
|
101
|
+
readonly additionalProperties: {
|
|
102
|
+
readonly type: "integer";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly required: readonly ["total", "byReason"];
|
|
107
|
+
};
|
|
108
|
+
sidecarWarnings: {
|
|
109
|
+
readonly type: "array";
|
|
110
|
+
readonly items: {
|
|
111
|
+
readonly type: "string";
|
|
112
|
+
};
|
|
113
|
+
};
|
|
80
114
|
ruleId: {
|
|
81
115
|
type: string;
|
|
82
116
|
};
|
|
@@ -137,9 +171,6 @@ export declare class SuggestImprovementsTool implements MCPTool {
|
|
|
137
171
|
readonly type: "string";
|
|
138
172
|
};
|
|
139
173
|
};
|
|
140
|
-
summary: {
|
|
141
|
-
type: string;
|
|
142
|
-
};
|
|
143
174
|
};
|
|
144
175
|
required: string[];
|
|
145
176
|
};
|
|
@@ -2,6 +2,7 @@ import { FeedbackStorage, loadConfig, findRepeatedToolMisses, fromLegacyAnalysis
|
|
|
2
2
|
import { calculatePerformance, generateSuggestions, } from './helpers/suggestion-generator.js';
|
|
3
3
|
import { feedbackSessionDirs, feedbackStorageConfig, resolveFeedbackRoots, } from './helpers/platform-root-resolver.js';
|
|
4
4
|
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
5
|
+
import { INCLUDE_OUTDATED_SCHEMA, SKIPPED_RECORDS_OUTPUT_SCHEMA, describeSkipped, skipMarkedRecords, } from './helpers/feedback-sidecar.js';
|
|
5
6
|
/** Suggestions spelled out in the summary; the rest is in `suggestions`. */
|
|
6
7
|
const SUMMARY_SUGGESTIONS = 5;
|
|
7
8
|
/** Text summary: data points, current performance and the top suggestions. */
|
|
@@ -15,6 +16,7 @@ function describeSuggestions(output) {
|
|
|
15
16
|
for (const suggestion of output.suggestions.slice(0, SUMMARY_SUGGESTIONS)) {
|
|
16
17
|
lines.push(`- ${suggestion.type} (confidence ${suggestion.confidence.toFixed(2)}): ${suggestion.description}`);
|
|
17
18
|
}
|
|
19
|
+
lines.push(...describeSkipped(output.skippedRecords, output.sidecarWarnings ?? []));
|
|
18
20
|
return lines.join('\n');
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
@@ -76,6 +78,7 @@ export class SuggestImprovementsTool {
|
|
|
76
78
|
"plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set; " +
|
|
77
79
|
"'platform' requires that variable.",
|
|
78
80
|
},
|
|
81
|
+
...INCLUDE_OUTDATED_SCHEMA,
|
|
79
82
|
},
|
|
80
83
|
required: ['ruleId'],
|
|
81
84
|
};
|
|
@@ -115,6 +118,7 @@ export class SuggestImprovementsTool {
|
|
|
115
118
|
feedbackCount: { type: 'integer' },
|
|
116
119
|
analysisFeedbackCount: { type: 'integer' },
|
|
117
120
|
sourcesRead: STRING_ARRAY,
|
|
121
|
+
...SKIPPED_RECORDS_OUTPUT_SCHEMA,
|
|
118
122
|
summary: { type: 'string' },
|
|
119
123
|
},
|
|
120
124
|
required: [
|
|
@@ -196,23 +200,42 @@ export class SuggestImprovementsTool {
|
|
|
196
200
|
const sessionIds = await feedbackStorage.listSessions();
|
|
197
201
|
// Track which locations we read from
|
|
198
202
|
const sourcesRead = feedbackSessionDirs(roots);
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
const
|
|
203
|
+
// Records of this rule (or analysis tool); old analysis records keep their transformation record
|
|
204
|
+
// until the sidecar marks are applied, so their stored id decides
|
|
205
|
+
const matching = new Map();
|
|
202
206
|
for (const sessionId of sessionIds) {
|
|
203
207
|
try {
|
|
204
208
|
const session = await feedbackStorage.loadSession(sessionId);
|
|
205
|
-
|
|
206
|
-
.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
matching.set(sessionId, {
|
|
210
|
+
transformations: session.transformations.filter((f) => {
|
|
211
|
+
const legacy = fromLegacyAnalysisRecord(f);
|
|
212
|
+
return legacy === null
|
|
213
|
+
? f.rule.ruleId === input.ruleId
|
|
214
|
+
: legacy.tool === input.ruleId;
|
|
215
|
+
}),
|
|
216
|
+
analyses: (session.analyses ?? []).filter((a) => a.tool === input.ruleId),
|
|
217
|
+
});
|
|
211
218
|
}
|
|
212
219
|
catch {
|
|
213
220
|
// Session not found or load error, skip
|
|
214
221
|
}
|
|
215
222
|
}
|
|
223
|
+
// Records the sidecar marks (duplicates, outdated) stay out unless includeOutdated
|
|
224
|
+
const marked = skipMarkedRecords(projectRoot, matching, input.includeOutdated === true);
|
|
225
|
+
const ruleFeedback = [];
|
|
226
|
+
const toolAnalyses = [];
|
|
227
|
+
for (const session of marked.sessions) {
|
|
228
|
+
for (const record of session.transformations) {
|
|
229
|
+
const legacy = fromLegacyAnalysisRecord(record);
|
|
230
|
+
if (legacy === null) {
|
|
231
|
+
ruleFeedback.push(record);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
toolAnalyses.push(legacy);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
toolAnalyses.push(...session.analyses);
|
|
238
|
+
}
|
|
216
239
|
// Calculate current performance
|
|
217
240
|
const currentPerformance = calculatePerformance(ruleFeedback);
|
|
218
241
|
// Generate suggestions (transformation outcomes + repeated tool misses)
|
|
@@ -228,6 +251,8 @@ export class SuggestImprovementsTool {
|
|
|
228
251
|
feedbackCount: ruleFeedback.length,
|
|
229
252
|
analysisFeedbackCount: toolAnalyses.length,
|
|
230
253
|
sourcesRead,
|
|
254
|
+
skippedRecords: marked.skipped,
|
|
255
|
+
...(marked.warnings.length === 0 ? {} : { sidecarWarnings: marked.warnings }),
|
|
231
256
|
};
|
|
232
257
|
return { ...output, summary: describeSuggestions(output) };
|
|
233
258
|
}
|
|
@@ -460,8 +460,9 @@ export class TraceOutputFlowTool {
|
|
|
460
460
|
const file = params.file === undefined || isAbsolute(params.file)
|
|
461
461
|
? params.file
|
|
462
462
|
: resolve(params.projectRoot, params.file);
|
|
463
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
463
464
|
const tracer = new OutputFlowTracer((await acquireProject(this.projects, tsConfigPath, ctx)), {
|
|
464
|
-
componentDecorators:
|
|
465
|
+
componentDecorators: decorators.componentDecorators,
|
|
465
466
|
includeTestHosts: params.includeTestHosts === true,
|
|
466
467
|
includeDynamic: params.includeDynamic !== false,
|
|
467
468
|
depth,
|
|
@@ -473,7 +474,7 @@ export class TraceOutputFlowTool {
|
|
|
473
474
|
...(params.output ? { output: params.output } : {}),
|
|
474
475
|
});
|
|
475
476
|
const summary = this.buildSummary(params, result);
|
|
476
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
477
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
477
478
|
const { outputs, dynamic, ...rest } = result;
|
|
478
479
|
if (compact.summaryOnly) {
|
|
479
480
|
return withWarnings({
|
|
@@ -22,13 +22,16 @@ export interface BatchTransformOptions {
|
|
|
22
22
|
timeout?: number;
|
|
23
23
|
pluginIds?: string[];
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
/** Outcome of one batch file as the transform callback returns it. */
|
|
26
|
+
export interface BatchFileOutcome {
|
|
26
27
|
success: boolean;
|
|
27
|
-
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface BatchTransformResult<R extends BatchFileOutcome = BatchFileOutcome> {
|
|
31
|
+
success: boolean;
|
|
32
|
+
files: (R & {
|
|
28
33
|
path: string;
|
|
29
|
-
|
|
30
|
-
error?: string;
|
|
31
|
-
}[];
|
|
34
|
+
})[];
|
|
32
35
|
orchestration: {
|
|
33
36
|
parallel: boolean;
|
|
34
37
|
batchMode: boolean;
|
|
@@ -53,8 +56,5 @@ export interface BatchTransformResult {
|
|
|
53
56
|
/**
|
|
54
57
|
* Execute batch transformation with optional parallel processing.
|
|
55
58
|
*/
|
|
56
|
-
export declare function executeBatchTransformation(options: BatchTransformOptions, transformSingleFile: (filePath: string) => Promise<
|
|
57
|
-
success: boolean;
|
|
58
|
-
error?: string;
|
|
59
|
-
}>): Promise<BatchTransformResult>;
|
|
59
|
+
export declare function executeBatchTransformation<R extends BatchFileOutcome>(options: BatchTransformOptions, transformSingleFile: (filePath: string) => Promise<R>): Promise<BatchTransformResult<R>>;
|
|
60
60
|
//# sourceMappingURL=transform-code-batch.d.ts.map
|