@angular-modernizer/adapter-mcp 2.0.0 → 2.1.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 (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/tools/analyze-project.d.ts +26 -1
  4. package/dist/tools/analyze-project.js +8 -3
  5. package/dist/tools/compare-health.d.ts +40 -4
  6. package/dist/tools/compare-health.js +22 -5
  7. package/dist/tools/helpers/analysis-output.js +3 -0
  8. package/dist/tools/helpers/health-delta.d.ts +6 -0
  9. package/dist/tools/helpers/health-delta.js +4 -1
  10. package/dist/tools/helpers/library-import-warning.d.ts +33 -0
  11. package/dist/tools/helpers/library-import-warning.js +38 -0
  12. package/dist/tools/helpers/library-imports.d.ts +38 -14
  13. package/dist/tools/helpers/library-imports.js +128 -23
  14. package/dist/tools/helpers/output-contract.d.ts +22 -0
  15. package/dist/tools/helpers/output-contract.js +13 -0
  16. package/dist/tools/helpers/refresh-apply.js +1 -1
  17. package/dist/tools/helpers/refresh-inventory.d.ts +1 -1
  18. package/dist/tools/helpers/refresh-inventory.js +24 -3
  19. package/dist/tools/helpers/scan-cache.d.ts +45 -2
  20. package/dist/tools/helpers/scan-cache.js +47 -2
  21. package/dist/tools/helpers/scan-engine.d.ts +13 -0
  22. package/dist/tools/helpers/scan-engine.js +10 -0
  23. package/dist/tools/list-imports.d.ts +1 -1
  24. package/dist/tools/refresh-state.js +1 -1
  25. package/dist/tools/scan-all.d.ts +7 -1
  26. package/dist/tools/scan-all.js +8 -13
  27. package/dist/tools/scan-angular.d.ts +7 -1
  28. package/dist/tools/scan-angular.js +7 -2
  29. package/dist/tools/scan-architecture.d.ts +8 -0
  30. package/dist/tools/scan-architecture.js +25 -14
  31. package/dist/tools/scan-solid.d.ts +7 -1
  32. package/dist/tools/scan-solid.js +7 -2
  33. package/package.json +11 -11
@@ -7,6 +7,7 @@ import { cancelledExecution, fileProgressMessage, finalFileProgress, } from './h
7
7
  import { runScan } from '../scan-host/scan-host.js';
8
8
  import { openToolCache } from './helpers/tool-cache.js';
9
9
  import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, SCAN_TOOL_CACHE_VERSION, scanCacheVersion, } from './helpers/scan-cache.js';
10
+ import { withLibraryImportWarning, } from './helpers/library-import-warning.js';
10
11
  /**
11
12
  * MCP tool `scan-angular`: scans for Angular-specific best practice
12
13
  * violations. Runs only the rules of the AngularPlugin (OnPush, TrackBy,
@@ -134,9 +135,13 @@ export class ScanAngularTool {
134
135
  const uniqueFiles = Array.from(new Set(allFiles)).sort();
135
136
  const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
136
137
  const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
138
+ // Library resolution state before the cache read: it is part of the
139
+ // cache version, so entries of another node_modules state are not served
140
+ const libraryCheck = await (await import('./helpers/library-imports.js')).checkScanScope(tsConfigPath, filesToAnalyze);
137
141
  const cache = await openToolCache(mergedParams.rootPath, 'angular', scanCacheVersion(SCAN_TOOL_CACHE_VERSION, mergedParams.rootPath, ruleSelection, {
138
142
  includePatterns: mergedParams.includePatterns,
139
143
  excludePatterns: mergedParams.excludePatterns,
144
+ unresolvedPackages: libraryCheck.packages,
140
145
  }));
141
146
  // ============================================================================
142
147
  // CACHE READ SYSTEM
@@ -292,7 +297,7 @@ export class ScanAngularTool {
292
297
  };
293
298
  const duration = Date.now() - startTime;
294
299
  const ruleIds = engine.ruleIds;
295
- return {
300
+ return withLibraryImportWarning({
296
301
  violations: paginatedViolations,
297
302
  counts,
298
303
  metadata: {
@@ -304,7 +309,7 @@ export class ScanAngularTool {
304
309
  pagination,
305
310
  ...(execution === undefined ? {} : { execution }),
306
311
  summary: describeScan(counts, paginatedViolations, pagination, [...notices, ...(execution === undefined ? [] : [execution.note])]),
307
- };
312
+ }, libraryCheck.unresolved);
308
313
  }
309
314
  /**
310
315
  * The `tools['scan-angular']` section of `.angular-modernizer.json`; arguments of
@@ -1,4 +1,5 @@
1
1
  import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
2
+ import { type UnresolvedLibraryImports } from './helpers/library-import-warning.js';
2
3
  import { type ScanCounts } from './helpers/analysis-output.js';
3
4
  import { type RuleTiming } from './helpers/rule-runner.js';
4
5
  /**
@@ -70,6 +71,13 @@ export interface ScanArchitectureResult {
70
71
  * Operation ID for streaming mode (when streaming=true).
71
72
  */
72
73
  operationId?: string;
74
+ /** The warning about library imports that do not resolve. */
75
+ warnings?: string[];
76
+ /**
77
+ * Library imports of the scope that do not resolve (sequential and fluent
78
+ * path); absent when all resolve.
79
+ */
80
+ unresolvedLibraryImports?: UnresolvedLibraryImports;
73
81
  /**
74
82
  * All violations found.
75
83
  */
@@ -2,7 +2,8 @@ import { findTsConfig } from './helpers/find-ts-config.js';
2
2
  import { cancelledExecution, fileProgressMessage, finalFileProgress, yieldIfCancellable, } from './helpers/tool-context.js';
3
3
  import { runScan } from '../scan-host/scan-host.js';
4
4
  import { openToolCache } from './helpers/tool-cache.js';
5
- import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, scanCacheVersion, templateDependencies, } from './helpers/scan-cache.js';
5
+ import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, scanCacheVersion, ARCHITECTURE_CACHE_VERSION, templateDependencies, } from './helpers/scan-cache.js';
6
+ import { withLibraryImportWarning, } from './helpers/library-import-warning.js';
6
7
  import { loadSourceFiles } from './helpers/load-source-files.js';
7
8
  import { filterFilesByScopePaths } from './helpers/scope-paths.js';
8
9
  import { toParallelOptions } from '../types.js';
@@ -42,10 +43,10 @@ function paginateViolations(violations, params) {
42
43
  */
43
44
  function withScanSummary(result) {
44
45
  const notes = result.execution?.note === undefined ? [] : [result.execution.note];
45
- return {
46
+ return withLibraryImportWarning({
46
47
  ...result,
47
48
  summary: describeScan(result.counts, result.violations, result.pagination, notes),
48
- };
49
+ }, result.unresolvedLibraryImports);
49
50
  }
50
51
  /**
51
52
  * MCP tool `scan-architecture`: scans for architectural issues. Runs only the
@@ -364,6 +365,7 @@ export class ScanArchitectureTool {
364
365
  // own analysis workers); the sequential path runs in a scan worker.
365
366
  let parallelKernel;
366
367
  let rulesExecuted = [];
368
+ let unresolvedLibraryImports;
367
369
  let lastProgress;
368
370
  if (orchestration.parallel || orchestration.incremental) {
369
371
  // Initialize kernel with ArchitecturePlugin only + caching
@@ -592,7 +594,14 @@ export class ScanArchitectureTool {
592
594
  // once more at another file (70 -> 74 -> 78 findings on a large app).
593
595
  // The cache version carries the rule configuration (scanCacheVersion).
594
596
  // ============================================================================
595
- const cache = await openToolCache(mergedParams.rootPath, 'architecture', scanCacheVersion(ARCHITECTURE_CACHE_VERSION, mergedParams.rootPath));
597
+ // Library resolution state before the cache read: it is part of the
598
+ // cache version, so entries of another node_modules state are not served
599
+ const libraryCheck = await (await import('./helpers/library-imports.js')).checkScanScope(tsConfigPath, filesToAnalyze);
600
+ unresolvedLibraryImports =
601
+ libraryCheck.unresolved.imports > 0 ? libraryCheck.unresolved : undefined;
602
+ const cache = await openToolCache(mergedParams.rootPath, 'architecture', scanCacheVersion(ARCHITECTURE_CACHE_VERSION, mergedParams.rootPath, undefined, {
603
+ unresolvedPackages: libraryCheck.packages,
604
+ }));
596
605
  // A run limited by rules holds only those rules' findings per file:
597
606
  // it neither reads the cache nor writes entries a full run would
598
607
  // take for complete
@@ -702,6 +711,7 @@ export class ScanArchitectureTool {
702
711
  ...summary,
703
712
  analyzedFiles: filesAnalyzed,
704
713
  },
714
+ ...(unresolvedLibraryImports === undefined ? {} : { unresolvedLibraryImports }),
705
715
  metadata: {
706
716
  rulesExecuted,
707
717
  duration,
@@ -752,7 +762,14 @@ export class ScanArchitectureTool {
752
762
  ruleTimings: [],
753
763
  durationMs: Date.now() - (spec.startTime ?? Date.now()),
754
764
  };
755
- return { run, ruleIds: engine.ruleIds };
765
+ return {
766
+ run,
767
+ ruleIds: engine.ruleIds,
768
+ // Only when some do not resolve, like the other scans
769
+ ...((engine.unresolvedLibraryImports?.imports ?? 0) > 0
770
+ ? { unresolvedLibraryImports: engine.unresolvedLibraryImports }
771
+ : {}),
772
+ };
756
773
  }
757
774
  /**
758
775
  * Execute analysis using fluent API.
@@ -806,13 +823,14 @@ export class ScanArchitectureTool {
806
823
  // rules such as layer-boundary-violation returned 0 violations, Bug 1/3),
807
824
  // in a scan worker when enabled.
808
825
  const violations = [];
809
- const { run, ruleIds } = await this.runRules({
826
+ const { run, ruleIds, unresolvedLibraryImports } = await this.runRules({
810
827
  tool: this.name,
811
828
  plugins: 'architecture',
812
829
  tsConfigPath,
813
830
  rootPath: params.rootPath,
814
831
  files: filesToAnalyze,
815
832
  mode: 'runner',
833
+ libraryImports: true,
816
834
  ...(params.rules === undefined ? {} : { ruleIds: params.rules }),
817
835
  maxDurationMs: parseMaxDurationMs(params.maxDurationMs),
818
836
  startTime,
@@ -828,6 +846,7 @@ export class ScanArchitectureTool {
828
846
  ...summary,
829
847
  analyzedFiles: filesAnalyzed,
830
848
  },
849
+ ...(unresolvedLibraryImports === undefined ? {} : { unresolvedLibraryImports }),
831
850
  metadata: {
832
851
  rulesExecuted: ruleIds,
833
852
  duration,
@@ -1358,14 +1377,6 @@ function withFileCap(execution, scopeFiles, selectedFiles, maxFiles) {
1358
1377
  function relativeToRoot(violations, rootPath) {
1359
1378
  return violations.map((v) => ({ ...v, filePath: relative(rootPath, v.filePath) }));
1360
1379
  }
1361
- /**
1362
- * Version of the imperative path's cache entries: one entry per analyzed file
1363
- * with the findings of the file-scope rules. Entries of the earlier layout
1364
- * were filed under each finding's file and held project-wide findings;
1365
- * `scan-architecture-3` drops solid:circular-dependency findings without
1366
- * `cycleId` that carry the path of a long cycle on every file.
1367
- */
1368
- const ARCHITECTURE_CACHE_VERSION = 'scan-architecture-3';
1369
1380
  /** Files a cache entry depends on besides the analyzed file itself. */
1370
1381
  function cacheDependencies(filePath, findings) {
1371
1382
  let text = '';
@@ -1,6 +1,7 @@
1
1
  import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
2
2
  import { type ScanCounts } from './helpers/analysis-output.js';
3
3
  import { type CancelledExecution } from './helpers/tool-context.js';
4
+ import { type UnresolvedLibraryImports } from './helpers/library-import-warning.js';
4
5
  /** Result of the scan-solid tool. */
5
6
  export interface ScanSolidResult {
6
7
  /** The requested page of violations (`maxResults`, `resultOffset`). */
@@ -41,8 +42,13 @@ export interface ScanSolidResult {
41
42
  /** Root path of the scanned project. */
42
43
  projectRoot: string;
43
44
  };
44
- /** Deprecation notices of the call (`orchestration` has no effect). */
45
+ /**
46
+ * Deprecation notices of the call (`orchestration` has no effect) and the
47
+ * warning about library imports that do not resolve.
48
+ */
45
49
  warnings?: string[];
50
+ /** Library imports of the scope that do not resolve; absent when all resolve. */
51
+ unresolvedLibraryImports?: UnresolvedLibraryImports;
46
52
  /**
47
53
  * @deprecated No longer set: the block claimed a parallel run that never
48
54
  * happened. The scan always runs in the scan worker.
@@ -7,6 +7,7 @@ import { cancelledExecution, fileProgressMessage, finalFileProgress, } from './h
7
7
  import { runScan } from '../scan-host/scan-host.js';
8
8
  import { openToolCache } from './helpers/tool-cache.js';
9
9
  import { findingsInFileOrder, readCachedFindings, SCAN_CACHE_MODE_SCHEMA, scanCacheMode, SCAN_TOOL_CACHE_VERSION, scanCacheVersion, } from './helpers/scan-cache.js';
10
+ import { withLibraryImportWarning, } from './helpers/library-import-warning.js';
10
11
  /**
11
12
  * MCP tool `scan-solid`: scans for SOLID principle violations. Runs only the
12
13
  * rules of the SolidPlugin (DIP, SRP, LSP, OCP, ISP).
@@ -133,9 +134,13 @@ export class ScanSolidTool {
133
134
  const uniqueFiles = Array.from(new Set(allFiles)).sort();
134
135
  const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
135
136
  const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
137
+ // Library resolution state before the cache read: it is part of the
138
+ // cache version, so entries of another node_modules state are not served
139
+ const libraryCheck = await (await import('./helpers/library-imports.js')).checkScanScope(tsConfigPath, filesToAnalyze);
136
140
  const cache = await openToolCache(mergedParams.rootPath, 'solid', scanCacheVersion(SCAN_TOOL_CACHE_VERSION, mergedParams.rootPath, ruleSelection, {
137
141
  includePatterns: mergedParams.includePatterns,
138
142
  excludePatterns: mergedParams.excludePatterns,
143
+ unresolvedPackages: libraryCheck.packages,
139
144
  }));
140
145
  // ============================================================================
141
146
  // CACHE READ SYSTEM
@@ -322,7 +327,7 @@ export class ScanSolidTool {
322
327
  };
323
328
  const duration = Date.now() - startTime;
324
329
  const ruleIds = engine.ruleIds;
325
- return {
330
+ return withLibraryImportWarning({
326
331
  violations: paginatedViolations,
327
332
  counts,
328
333
  metadata: {
@@ -334,7 +339,7 @@ export class ScanSolidTool {
334
339
  pagination,
335
340
  ...(execution === undefined ? {} : { execution }),
336
341
  summary: describeScan(counts, paginatedViolations, pagination, [...notices, ...(execution === undefined ? [] : [execution.note])]),
337
- };
342
+ }, libraryCheck.unresolved);
338
343
  }
339
344
  /**
340
345
  * The `tools['scan-solid']` section of `.angular-modernizer.json`; arguments of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-modernizer/adapter-mcp",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "MCP Server to expose Angular Modernizer tools to an AI assistant.",
5
5
  "keywords": [
6
6
  "angular",
@@ -32,16 +32,16 @@
32
32
  "glob": "^11.0.3",
33
33
  "ts-morph": "^27.0.2",
34
34
  "zod": "^4.6.5",
35
- "@angular-modernizer/api": "2.0.0",
36
- "@angular-modernizer/orchestration": "2.0.0",
37
- "@angular-modernizer/plugin-architecture": "2.0.0",
38
- "@angular-modernizer/core": "2.0.0",
39
- "@angular-modernizer/plugin-solid": "2.0.0",
40
- "@angular-modernizer/plugin-standalone": "2.0.0",
41
- "@angular-modernizer/plugin-system": "2.0.0",
42
- "@angular-modernizer/plugin-angular": "2.0.0",
43
- "@angular-modernizer/worker": "2.0.0",
44
- "@angular-modernizer/plugin-analyzer": "2.0.0"
35
+ "@angular-modernizer/plugin-analyzer": "2.1.0",
36
+ "@angular-modernizer/api": "2.1.0",
37
+ "@angular-modernizer/plugin-angular": "2.1.0",
38
+ "@angular-modernizer/orchestration": "2.1.0",
39
+ "@angular-modernizer/core": "2.1.0",
40
+ "@angular-modernizer/plugin-architecture": "2.1.0",
41
+ "@angular-modernizer/plugin-standalone": "2.1.0",
42
+ "@angular-modernizer/plugin-solid": "2.1.0",
43
+ "@angular-modernizer/plugin-system": "2.1.0",
44
+ "@angular-modernizer/worker": "2.1.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/express": "^4.17.13",