@angular-modernizer/adapter-mcp 1.0.0 → 1.2.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 (131) hide show
  1. package/README.md +81 -65
  2. package/dist/cli.js +8 -0
  3. package/dist/core/project-analyzer.d.ts +3 -12
  4. package/dist/core/project-analyzer.js +3 -12
  5. package/dist/index.d.ts +118 -3
  6. package/dist/index.js +46 -3
  7. package/dist/mcp-watcher.d.ts +28 -8
  8. package/dist/mcp-watcher.js +7 -7
  9. package/dist/scan-host/scan-host.d.ts +119 -0
  10. package/dist/scan-host/scan-host.js +376 -0
  11. package/dist/scan-host/scan-protocol.d.ts +35 -0
  12. package/dist/scan-host/scan-protocol.js +6 -0
  13. package/dist/scan-host/scan-worker.d.ts +14 -0
  14. package/dist/scan-host/scan-worker.js +48 -0
  15. package/dist/server/limited-stdio-transport.d.ts +7 -0
  16. package/dist/server/mcp-server.d.ts +11 -7
  17. package/dist/server/mcp-server.js +4 -7
  18. package/dist/server/sdk-server.d.ts +1 -0
  19. package/dist/server/tool-registry.d.ts +3 -7
  20. package/dist/server/tool-registry.js +1 -7
  21. package/dist/streaming/progress-store.d.ts +22 -5
  22. package/dist/streaming/progress-store.js +9 -5
  23. package/dist/tools/analyze-build-impact.d.ts +58 -36
  24. package/dist/tools/analyze-build-impact.js +36 -29
  25. package/dist/tools/analyze-core-to-shared.d.ts +42 -12
  26. package/dist/tools/analyze-core-to-shared.js +11 -10
  27. package/dist/tools/analyze-parser-performance.d.ts +23 -22
  28. package/dist/tools/analyze-parser-performance.js +20 -18
  29. package/dist/tools/analyze-project.d.ts +87 -14
  30. package/dist/tools/analyze-project.js +140 -122
  31. package/dist/tools/check-incremental-compatibility.d.ts +13 -11
  32. package/dist/tools/check-incremental-compatibility.js +11 -8
  33. package/dist/tools/collect-feedback.d.ts +41 -26
  34. package/dist/tools/collect-feedback.js +32 -23
  35. package/dist/tools/compare-health.d.ts +76 -19
  36. package/dist/tools/compare-health.js +26 -19
  37. package/dist/tools/extract-libraries.d.ts +44 -20
  38. package/dist/tools/extract-libraries.js +16 -17
  39. package/dist/tools/find-angular-symbol.d.ts +27 -25
  40. package/dist/tools/find-angular-symbol.js +19 -16
  41. package/dist/tools/find-component-hosts.d.ts +33 -27
  42. package/dist/tools/find-component-hosts.js +27 -24
  43. package/dist/tools/find-usages.d.ts +25 -23
  44. package/dist/tools/find-usages.js +21 -18
  45. package/dist/tools/get-bootstrap-execution.d.ts +35 -27
  46. package/dist/tools/get-bootstrap-execution.js +28 -25
  47. package/dist/tools/get-call-graph.d.ts +19 -14
  48. package/dist/tools/get-call-graph.js +26 -23
  49. package/dist/tools/get-operation-progress-tool.d.ts +12 -6
  50. package/dist/tools/get-operation-progress-tool.js +11 -6
  51. package/dist/tools/get-operation-progress.d.ts +26 -0
  52. package/dist/tools/helpers/analysis-output.d.ts +5 -0
  53. package/dist/tools/helpers/batch-kernel.d.ts +14 -0
  54. package/dist/tools/helpers/batch-kernel.js +12 -0
  55. package/dist/tools/helpers/compact-output.d.ts +2 -1
  56. package/dist/tools/helpers/compact-output.js +2 -1
  57. package/dist/tools/helpers/health-delta.d.ts +27 -14
  58. package/dist/tools/helpers/health-delta.js +11 -14
  59. package/dist/tools/helpers/project-cache.d.ts +123 -36
  60. package/dist/tools/helpers/project-cache.js +227 -43
  61. package/dist/tools/helpers/rule-runner.d.ts +23 -16
  62. package/dist/tools/helpers/rule-runner.js +24 -17
  63. package/dist/tools/helpers/scan-engine.d.ts +107 -0
  64. package/dist/tools/helpers/scan-engine.js +197 -0
  65. package/dist/tools/helpers/scan-plan.d.ts +1 -1
  66. package/dist/tools/helpers/scan-plan.js +1 -1
  67. package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
  68. package/dist/tools/helpers/suggestion-generator.js +0 -12
  69. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  70. package/dist/tools/helpers/tool-cache.js +15 -0
  71. package/dist/tools/helpers/tool-context.d.ts +11 -8
  72. package/dist/tools/helpers/tool-context.js +5 -8
  73. package/dist/tools/inspect-form-group.d.ts +34 -27
  74. package/dist/tools/inspect-form-group.js +27 -24
  75. package/dist/tools/inspect-i18n.d.ts +31 -25
  76. package/dist/tools/inspect-i18n.js +23 -20
  77. package/dist/tools/inspect-template.d.ts +32 -25
  78. package/dist/tools/inspect-template.js +26 -23
  79. package/dist/tools/learn-patterns.d.ts +88 -12
  80. package/dist/tools/learn-patterns.js +17 -11
  81. package/dist/tools/list-imports.d.ts +45 -28
  82. package/dist/tools/list-imports.js +26 -23
  83. package/dist/tools/orchestrate-migration.d.ts +31 -9
  84. package/dist/tools/orchestrate-migration.js +12 -7
  85. package/dist/tools/parse-stack-trace.d.ts +23 -21
  86. package/dist/tools/parse-stack-trace.js +10 -7
  87. package/dist/tools/plan-migration.d.ts +67 -27
  88. package/dist/tools/plan-migration.js +22 -21
  89. package/dist/tools/resolve-type.d.ts +20 -10
  90. package/dist/tools/resolve-type.js +21 -13
  91. package/dist/tools/review-feedback.d.ts +27 -24
  92. package/dist/tools/review-feedback.js +24 -20
  93. package/dist/tools/rollback-changes.d.ts +13 -9
  94. package/dist/tools/rollback-changes.js +10 -7
  95. package/dist/tools/run-angular-cli.d.ts +12 -10
  96. package/dist/tools/run-angular-cli.js +11 -8
  97. package/dist/tools/run-build.d.ts +13 -11
  98. package/dist/tools/run-build.js +11 -8
  99. package/dist/tools/run-schematic.d.ts +12 -10
  100. package/dist/tools/run-schematic.js +11 -8
  101. package/dist/tools/scan-all.d.ts +69 -12
  102. package/dist/tools/scan-all.js +55 -122
  103. package/dist/tools/scan-angular.d.ts +41 -9
  104. package/dist/tools/scan-angular.js +66 -135
  105. package/dist/tools/scan-architecture.d.ts +75 -14
  106. package/dist/tools/scan-architecture.js +180 -185
  107. package/dist/tools/scan-solid.d.ts +40 -9
  108. package/dist/tools/scan-solid.js +64 -133
  109. package/dist/tools/search-codebase.d.ts +32 -26
  110. package/dist/tools/search-codebase.js +15 -12
  111. package/dist/tools/server-status.d.ts +116 -24
  112. package/dist/tools/server-status.js +85 -26
  113. package/dist/tools/suggest-improvements.d.ts +22 -19
  114. package/dist/tools/suggest-improvements.js +21 -17
  115. package/dist/tools/trace-output-flow.d.ts +34 -27
  116. package/dist/tools/trace-output-flow.js +27 -24
  117. package/dist/tools/transform-code.d.ts +71 -10
  118. package/dist/tools/transform-code.js +148 -54
  119. package/dist/tools/validate-before-transform.d.ts +24 -9
  120. package/dist/tools/validate-before-transform.js +10 -7
  121. package/dist/tools/validate-project-compatibility.d.ts +18 -13
  122. package/dist/tools/validate-project-compatibility.js +17 -11
  123. package/dist/tools/validate-transformation.d.ts +28 -11
  124. package/dist/tools/validate-transformation.js +14 -8
  125. package/dist/tools/verify-citations.d.ts +37 -16
  126. package/dist/tools/verify-citations.js +19 -16
  127. package/dist/types.d.ts +40 -10
  128. package/dist/types.js +0 -5
  129. package/package.json +12 -18
  130. package/dist/tools/shared/scan-types.d.ts +0 -200
  131. package/dist/tools/shared/scan-types.js +0 -7
@@ -1,22 +1,15 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Scan Angular Best Practices Tool
3
- *
4
- * MCP tool for scanning Angular codebases for Angular-specific best practice violations.
5
- * Runs only the AngularPlugin (28 rules: OnPush, TrackBy, Performance, RxJS, etc.).
6
- */
7
1
  import { findTsConfig } from './helpers/find-ts-config.js';
8
- import { Kernel, createToolCacheConfig, loadConfig, } from '@angular-modernizer/core';
9
- import { AngularPlugin } from '@angular-modernizer/plugin-angular';
10
- import { ContextFactory } from '@angular-modernizer/plugin-system';
11
- import { createPublicApi } from '@angular-modernizer/api';
12
2
  import { glob } from 'glob';
13
3
  import { resolve, relative } from 'node:path';
14
4
  import { readFileSync, existsSync } from 'node:fs';
15
5
  import { describeScan, SCAN_EXECUTION_SCHEMA, scanOutputSchema, } from './helpers/analysis-output.js';
16
- import { cancelledExecution, fileProgressMessage, yieldIfCancellable, } from './helpers/tool-context.js';
17
- import { loadSourceFiles } from './helpers/load-source-files.js';
6
+ import { cancelledExecution, fileProgressMessage, } from './helpers/tool-context.js';
7
+ import { runScan } from '../scan-host/scan-host.js';
8
+ import { openToolCache } from './helpers/tool-cache.js';
18
9
  /**
19
- * Scan for Angular best practice violations using the AngularPlugin.
10
+ * MCP tool `scan-angular`: scans for Angular-specific best practice
11
+ * violations. Runs only the AngularPlugin (28 rules: OnPush, TrackBy,
12
+ * performance, RxJS and others).
20
13
  */
21
14
  export class ScanAngularTool {
22
15
  name = 'scan-angular';
@@ -29,6 +22,10 @@ export class ScanAngularTool {
29
22
  };
30
23
  description = 'Scan for Angular best practice violations (OnPush, TrackBy, Performance, RxJS, etc.). maxResults (default 1000) ' +
31
24
  'and resultOffset page the violations; counts cover all of them, summary is a short text.';
25
+ /**
26
+ * JSON Schema of the tool arguments.
27
+ * @hidden
28
+ */
32
29
  inputSchema = {
33
30
  type: 'object',
34
31
  additionalProperties: false,
@@ -101,6 +98,10 @@ export class ScanAngularTool {
101
98
  },
102
99
  required: ['rootPath'],
103
100
  };
101
+ /**
102
+ * JSON Schema of the tool result (`structuredContent`).
103
+ * @hidden
104
+ */
104
105
  outputSchema = scanOutputSchema({ execution: SCAN_EXECUTION_SCHEMA });
105
106
  async execute(args, ctx = {}) {
106
107
  const params = args;
@@ -115,16 +116,6 @@ export class ScanAngularTool {
115
116
  if (!tsConfigPath) {
116
117
  throw new Error('Could not find tsconfig.json');
117
118
  }
118
- // Initialize kernel with AngularPlugin and caching
119
- const kernel = new Kernel({
120
- tsConfigPath,
121
- plugins: [new AngularPlugin()],
122
- fileSystem: undefined,
123
- projectOptions: {
124
- skipAddingFilesFromTsConfig: true, // We'll add filtered files manually
125
- },
126
- cacheConfig: createToolCacheConfig(mergedParams.rootPath, 'angular'),
127
- });
128
119
  // Find files to analyze
129
120
  const includePatterns = mergedParams.includePatterns ?? ['**/*.{ts,tsx}'];
130
121
  const excludePatterns = mergedParams.excludePatterns ?? [
@@ -150,16 +141,7 @@ export class ScanAngularTool {
150
141
  const uniqueFiles = Array.from(new Set(allFiles)).sort();
151
142
  const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
152
143
  const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
153
- // Initialize kernel
154
- await kernel.initialize();
155
- // Load rules config from .angular-modernizer.json for per-rule overrides (BUG-3)
156
- const fullConfig = loadConfig(mergedParams.rootPath);
157
- const rulesConfig = fullConfig.rules;
158
- // Get analysis rules from the already-initialized plugin instances so that
159
- // ruleConfigs from .angular-modernizer.json are applied correctly.
160
- const allRules = kernel
161
- .getAllPlugins()
162
- .flatMap((p) => p.getAnalysisRules());
144
+ const cache = await openToolCache(mergedParams.rootPath, 'angular');
163
145
  // ============================================================================
164
146
  // CACHE READ SYSTEM
165
147
  // ============================================================================
@@ -179,28 +161,20 @@ export class ScanAngularTool {
179
161
  // Cache directory: .angular-modernizer-cache/angular/
180
162
  // Cache invalidation: Automatic via mtime/content hash checking
181
163
  // ============================================================================
182
- const cacheManagerForRead = kernel.getCacheManager();
183
164
  const cachedResults = []; // eslint-disable-line @typescript-eslint/no-explicit-any
184
- let filesToProcess = [];
185
- if (cacheManagerForRead) {
186
- for (const filePath of filesToAnalyze) {
187
- const cached = await cacheManagerForRead.getAnalysisResult(filePath);
188
- if (cached?.results && cached.results.length > 0) {
189
- // File is cached and hasn't changed
190
- cachedResults.push(...cached.results);
191
- }
192
- else {
193
- // File not cached or has changed
194
- filesToProcess.push(filePath);
195
- }
165
+ const filesToProcess = [];
166
+ for (const filePath of filesToAnalyze) {
167
+ const cached = await cache.getAnalysisResult(filePath);
168
+ if (cached?.results && cached.results.length > 0) {
169
+ // File is cached and hasn't changed
170
+ cachedResults.push(...cached.results);
171
+ }
172
+ else {
173
+ // File not cached or has changed
174
+ filesToProcess.push(filePath);
196
175
  }
197
- const stats = cacheManagerForRead.getStats();
198
- console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${stats.hitRate.toFixed(1)}%)`);
199
- }
200
- else {
201
- // No cache manager, analyze all files
202
- filesToProcess = filesToAnalyze;
203
176
  }
177
+ console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${cache.getStats().hitRate.toFixed(1)}%)`);
204
178
  // ============================================================================
205
179
  // BATCH PROCESSING SYSTEM
206
180
  // ============================================================================
@@ -220,73 +194,33 @@ export class ScanAngularTool {
220
194
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
221
195
  const results = [...cachedResults];
222
196
  let filesAnalyzed = cachedResults.length;
223
- // Process each batch; cancellation is checked between files
197
+ // Kernel, batches and rules run in a scan worker (scan-host), so the
198
+ // server keeps reading stdin while the type checker is built.
224
199
  const cachedFiles = filesToAnalyze.length - totalFiles;
225
200
  let processedFiles = 0;
226
- let cancelled = false;
227
- for (let batchNum = 0; batchNum < totalBatches && !cancelled; batchNum++) {
228
- const batchStart = batchNum * batchSize;
229
- const batchEnd = Math.min(batchStart + batchSize, totalFiles);
230
- const batchFiles = filesToProcess.slice(batchStart, batchEnd);
231
- console.info(`\nBatch ${batchNum + 1}/${totalBatches}: Processing files ${batchStart + 1}-${batchEnd} (${batchFiles.length} files)`);
232
- // Clear project and add batch files
233
- const project = kernel.getProject();
234
- // Remove all source files from previous batch
235
- const existingFiles = project.getSourceFiles();
236
- for (const file of existingFiles) {
237
- project.removeSourceFile(file);
238
- }
239
- // Add current batch files; a cancel during the load stops the scan
240
- const loaded = await loadSourceFiles(project, batchFiles, { signal: ctx.signal });
241
- if (loaded.cancelled) {
242
- cancelled = true;
243
- break;
244
- }
245
- console.info(`Batch ${batchNum + 1}: Project now has ${project.getSourceFiles().length} source files`);
246
- // Create PublicApi for this batch
247
- const api = createPublicApi(project); // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
248
- // Analyze files in this batch
249
- let batchViolationCount = 0;
250
- for (const sourceFile of project.getSourceFiles()) {
251
- await yieldIfCancellable(ctx.signal);
252
- if (ctx.signal?.aborted === true) {
253
- cancelled = true;
254
- break;
255
- }
256
- for (const rule of allRules) {
257
- try {
258
- const ruleResults = await rule.analyze(ContextFactory.createAnalysisContext({
259
- sourceFile,
260
- project,
261
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
262
- api,
263
- config: rulesConfig,
264
- }));
265
- for (const result of ruleResults) {
266
- results.push({
267
- ruleId: result.ruleId,
268
- severity: result.severity ?? rule.severity,
269
- message: result.message,
270
- filePath: result.filePath,
271
- line: result.line,
272
- column: result.column,
273
- category: rule.category,
274
- suggestedFix: result.suggestedFix,
275
- metadata: result.metadata,
276
- });
277
- batchViolationCount++;
278
- }
279
- }
280
- catch (error) {
281
- console.warn(`Failed to analyze with rule ${rule.id}:`, error);
282
- }
283
- }
201
+ if (totalFiles > 0) {
202
+ ctx.progress?.(cachedFiles, filesToAnalyze.length, `loading project, ${totalFiles} files to analyze`);
203
+ }
204
+ const engine = await runScan({
205
+ tool: this.name,
206
+ plugins: 'angular',
207
+ tsConfigPath,
208
+ rootPath: mergedParams.rootPath,
209
+ files: filesToProcess,
210
+ mode: 'batches',
211
+ batchSize,
212
+ analyzeProjectFiles: true,
213
+ }, {
214
+ file: (event) => {
215
+ results.push(...event.findings);
284
216
  processedFiles++;
285
217
  ctx.progress?.(cachedFiles + processedFiles, filesToAnalyze.length, fileProgressMessage(cachedFiles + processedFiles, filesToAnalyze.length, results.length));
286
- }
287
- filesAnalyzed += batchFiles.length;
288
- console.info(`Batch ${batchNum + 1}: Found ${batchViolationCount} violations in ${batchFiles.length} files`);
289
- }
218
+ },
219
+ batchDone: (files) => {
220
+ filesAnalyzed += files;
221
+ },
222
+ }, { signal: ctx.signal });
223
+ const cancelled = engine.cancelled;
290
224
  console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${filesAnalyzed} total files analyzed, ${results.length} total violations`);
291
225
  // ============================================================================
292
226
  // CACHE WRITE SYSTEM
@@ -306,26 +240,23 @@ export class ScanAngularTool {
306
240
  // - Parsing Angular templates and metadata takes significant time
307
241
  // - Cache hit eliminates all AST parsing and decorator analysis overhead
308
242
  // ============================================================================
309
- const cacheManager = kernel.getCacheManager();
310
- if (cacheManager) {
311
- // Group results by file path
312
- const resultsByFile = new Map();
313
- for (const result of results) {
314
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
315
- const filePath = result.filePath;
316
- if (!resultsByFile.has(filePath)) {
317
- resultsByFile.set(filePath, []);
318
- }
319
- resultsByFile.get(filePath).push(result);
320
- }
321
- // Write each file's results to cache
322
- for (const [filePath, fileResults] of resultsByFile.entries()) {
323
- await cacheManager.setAnalysisResult(filePath, fileResults);
243
+ // Group results by file path
244
+ const resultsByFile = new Map();
245
+ for (const result of results) {
246
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
247
+ const filePath = result.filePath;
248
+ if (!resultsByFile.has(filePath)) {
249
+ resultsByFile.set(filePath, []);
324
250
  }
325
- // Log cache effectiveness
326
- const stats = cacheManager.getStats();
327
- console.info(`Cached ${resultsByFile.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
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);
328
256
  }
257
+ // Log cache effectiveness
258
+ const stats = cache.getStats();
259
+ console.info(`Cached ${resultsByFile.size} files (hit rate: ${stats.hitRate.toFixed(1)}%)`);
329
260
  // Filter by specific rules if requested
330
261
  let violations = results
331
262
  .filter((r) => r.ruleId && r.filePath)
@@ -364,12 +295,12 @@ export class ScanAngularTool {
364
295
  hasMore: offset + maxResults < totalViolations,
365
296
  };
366
297
  const duration = Date.now() - startTime;
367
- const angularRules = allRules.map((r) => r.id);
298
+ const ruleIds = engine.ruleIds;
368
299
  return {
369
300
  violations: paginatedViolations,
370
301
  counts,
371
302
  metadata: {
372
- rulesExecuted: angularRules,
303
+ rulesExecuted: ruleIds,
373
304
  duration,
374
305
  projectRoot: mergedParams.rootPath,
375
306
  },
@@ -1,9 +1,3 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Scan Architecture Tool
3
- *
4
- * MCP tool for scanning Angular codebases for architectural issues.
5
- * Runs only the ArchitecturePlugin (17 rules: import cycles, layer violations, god objects, etc.).
6
- */
7
1
  import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
8
2
  import { type ScanCounts } from './helpers/analysis-output.js';
9
3
  import { type RuleTiming } from './helpers/rule-runner.js';
@@ -34,28 +28,39 @@ interface ScanScope {
34
28
  /**
35
29
  * Resolved scope information returned in results.
36
30
  */
37
- interface ResolvedScope {
31
+ export interface ResolvedScope {
32
+ /** Scope type that was scanned. */
38
33
  type: ScanScope['type'];
34
+ /** Project or feature names from the requested scope. */
39
35
  names?: string[];
36
+ /** Folder paths from the requested scope. */
40
37
  paths?: string[];
38
+ /** Paths the scope resolved to; files below them are scanned. */
41
39
  resolvedPaths: string[];
40
+ /** Number of files in scope that were selected for the scan. */
42
41
  matchedFiles: number;
43
42
  }
44
43
  /**
45
44
  * Run details of a scan.
46
45
  */
47
- interface ScanExecution {
46
+ export interface ScanExecution {
47
+ /** Time budget of the scan in milliseconds; `0` means no budget. */
48
48
  maxDurationMs: number;
49
+ /** `true` when the time budget or a cancellation stopped the scan early. */
49
50
  incomplete: boolean;
51
+ /** Why the scan stopped early. */
50
52
  stopReason?: 'time-budget' | 'cancelled';
53
+ /** Files that were not analyzed because the scan stopped early. */
51
54
  skippedFiles: number;
55
+ /** Time per rule, slowest first. */
52
56
  ruleTimings: RuleTiming[];
57
+ /** Human-readable note on an incomplete scan. */
53
58
  note?: string;
54
59
  }
55
60
  /**
56
61
  * Result from the scan-architecture tool.
57
62
  */
58
- interface ScanArchitectureResult {
63
+ export interface ScanArchitectureResult {
59
64
  /**
60
65
  * Operation ID for streaming mode (when streaming=true).
61
66
  */
@@ -64,15 +69,25 @@ interface ScanArchitectureResult {
64
69
  * All violations found.
65
70
  */
66
71
  violations: {
72
+ /** Violation id built from rule id, file, line and column. */
67
73
  id: string;
74
+ /** Rule that reported the violation, e.g. `solid:circular-dependency`. */
68
75
  ruleId: string;
76
+ /** Severity reported by the rule, else the rule's default severity. */
69
77
  severity: 'error' | 'warning' | 'info';
78
+ /** Rule message. */
70
79
  message: string;
80
+ /** File the violation was reported on. */
71
81
  filePath: string;
82
+ /** 1-based line of the finding, when the rule reports one. */
72
83
  line?: number;
84
+ /** Column of the finding, when the rule reports one. */
73
85
  column?: number;
86
+ /** Category of the rule. */
74
87
  category: string;
88
+ /** Fix suggested by the rule. */
75
89
  suggestedFix?: string;
90
+ /** Rule-specific details. */
76
91
  metadata?: Record<string, unknown>;
77
92
  }[];
78
93
  /**
@@ -87,8 +102,11 @@ interface ScanArchitectureResult {
87
102
  * Analysis metadata.
88
103
  */
89
104
  metadata: {
105
+ /** Ids of the rules that ran. */
90
106
  rulesExecuted: string[];
107
+ /** Duration of the scan in milliseconds. */
91
108
  duration: number;
109
+ /** Root path of the scanned project. */
92
110
  projectRoot: string;
93
111
  };
94
112
  /**
@@ -100,25 +118,42 @@ interface ScanArchitectureResult {
100
118
  */
101
119
  scope?: ResolvedScope;
102
120
  /**
103
- * Orchestration metrics (Phase 5b/6d/7b).
121
+ * Orchestration metrics; set when `orchestration.parallel` or
122
+ * `orchestration.incremental` is set.
104
123
  */
105
124
  orchestration?: {
125
+ /** Value of `orchestration.parallel`. */
106
126
  parallel: boolean;
127
+ /** Value of `orchestration.incremental`. */
107
128
  incremental: boolean;
129
+ /** Value of `orchestration.useWorkerThreads`. */
108
130
  useWorkerThreads?: boolean;
131
+ /** Value of `orchestration.autoSelectMode`. */
109
132
  autoSelectMode?: boolean;
133
+ /** Files analyzed. */
110
134
  filesAnalyzed: number;
135
+ /** Files skipped by incremental analysis. */
111
136
  filesSkipped: number;
137
+ /** Cache hit rate of incremental analysis. */
112
138
  cacheHitRate: number;
139
+ /** Duration of the scan in milliseconds. */
113
140
  duration: number;
141
+ /** Files per second. */
114
142
  throughput: number;
143
+ /** Parallel execution figures of the kernel. */
115
144
  workerStats?: {
145
+ /** Completed tasks. */
116
146
  completedTasks: number;
147
+ /** Average task duration in milliseconds. */
117
148
  averageTaskDuration: number;
149
+ /** Summed CPU time of all tasks. */
118
150
  totalCpuTime: number;
119
151
  };
152
+ /** Resource limits from `orchestration.resourceLimits`. */
120
153
  resourceUsage?: {
154
+ /** Maximum number of workers. */
121
155
  maxWorkers?: number;
156
+ /** Memory limit. */
122
157
  maxMemory?: number;
123
158
  };
124
159
  };
@@ -126,19 +161,28 @@ interface ScanArchitectureResult {
126
161
  * Pagination metadata (when pagination is used).
127
162
  */
128
163
  pagination?: {
164
+ /** Number of all violations. */
129
165
  totalResults: number;
166
+ /** Number of violations in this page. */
130
167
  returnedResults: number;
168
+ /** Offset of the page (`resultOffset`). */
131
169
  offset: number;
170
+ /** Whether violations follow after this page. */
132
171
  hasMore: boolean;
133
172
  };
134
173
  /**
135
174
  * Progress state (if enableProgress was true).
136
175
  */
137
176
  progress?: {
177
+ /** Processed items. */
138
178
  current: number;
179
+ /** Items in total. */
139
180
  total: number;
181
+ /** Progress in percent. */
140
182
  percentage: number;
183
+ /** Estimated remaining time; 0 when unknown. */
141
184
  eta: number;
185
+ /** Progress event type of the kernel's progress reporter. */
142
186
  phase: string;
143
187
  };
144
188
  /**
@@ -150,23 +194,30 @@ interface ScanArchitectureResult {
150
194
  * Intermediate results from each pipeline stage (fluent API only).
151
195
  */
152
196
  intermediateResults?: Record<string, {
197
+ /** Whether the stage succeeded. */
153
198
  success: boolean;
199
+ /** Violations found by the stage. */
154
200
  violations?: number;
201
+ /** Files processed by the stage. */
155
202
  filesProcessed?: number;
203
+ /** Stage message. */
156
204
  message?: string;
157
205
  }>;
158
206
  }
159
207
  /**
160
- * Scan Architecture Tool
161
- *
162
- * Provides architectural analysis capabilities through MCP with the rules of
163
- * the ArchitecturePlugin.
208
+ * MCP tool `scan-architecture`: scans for architectural issues. Runs only the
209
+ * ArchitecturePlugin (17 rules: import cycles, layer violations, god objects
210
+ * and others).
164
211
  */
165
212
  export declare class ScanArchitectureTool implements MCPTool {
166
213
  readonly name = "scan-architecture";
167
214
  readonly title = "Scan Architecture";
168
215
  readonly annotations: ToolAnnotations;
169
216
  readonly description: string;
217
+ /**
218
+ * JSON Schema of the tool arguments.
219
+ * @hidden
220
+ */
170
221
  readonly inputSchema: {
171
222
  type: string;
172
223
  additionalProperties: boolean;
@@ -333,12 +384,22 @@ export declare class ScanArchitectureTool implements MCPTool {
333
384
  };
334
385
  required: string[];
335
386
  };
387
+ /**
388
+ * JSON Schema of the tool result (`structuredContent`).
389
+ * @hidden
390
+ */
336
391
  readonly outputSchema: {
337
392
  type: "object";
338
393
  properties: Record<string, unknown>;
339
394
  required: string[];
340
395
  };
341
396
  execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ScanArchitectureResult>;
397
+ /**
398
+ * Runs the rules through the scan engine (in a scan worker when enabled)
399
+ * and appends each file's findings to `violations`. A worker terminated by
400
+ * a cancel leaves no run summary; it is rebuilt from the files received.
401
+ */
402
+ private runRules;
342
403
  /**
343
404
  * Execute analysis using fluent API.
344
405
  */