@angular-modernizer/adapter-mcp 1.0.0 → 1.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 (129) hide show
  1. package/README.md +78 -64
  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 +56 -34
  24. package/dist/tools/analyze-build-impact.js +30 -25
  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 +82 -12
  30. package/dist/tools/analyze-project.js +98 -101
  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 +25 -23
  40. package/dist/tools/find-angular-symbol.js +17 -14
  41. package/dist/tools/find-component-hosts.d.ts +31 -25
  42. package/dist/tools/find-component-hosts.js +24 -21
  43. package/dist/tools/find-usages.d.ts +23 -21
  44. package/dist/tools/find-usages.js +19 -16
  45. package/dist/tools/get-bootstrap-execution.d.ts +33 -25
  46. package/dist/tools/get-bootstrap-execution.js +25 -22
  47. package/dist/tools/get-call-graph.d.ts +18 -13
  48. package/dist/tools/get-call-graph.js +24 -21
  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 +50 -34
  60. package/dist/tools/helpers/project-cache.js +33 -34
  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/suggestion-generator.d.ts +9 -13
  66. package/dist/tools/helpers/suggestion-generator.js +0 -12
  67. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  68. package/dist/tools/helpers/tool-cache.js +15 -0
  69. package/dist/tools/helpers/tool-context.d.ts +11 -8
  70. package/dist/tools/helpers/tool-context.js +5 -8
  71. package/dist/tools/inspect-form-group.d.ts +32 -25
  72. package/dist/tools/inspect-form-group.js +24 -21
  73. package/dist/tools/inspect-i18n.d.ts +28 -22
  74. package/dist/tools/inspect-i18n.js +20 -17
  75. package/dist/tools/inspect-template.d.ts +31 -24
  76. package/dist/tools/inspect-template.js +23 -20
  77. package/dist/tools/learn-patterns.d.ts +88 -12
  78. package/dist/tools/learn-patterns.js +17 -11
  79. package/dist/tools/list-imports.d.ts +42 -25
  80. package/dist/tools/list-imports.js +23 -20
  81. package/dist/tools/orchestrate-migration.d.ts +31 -9
  82. package/dist/tools/orchestrate-migration.js +12 -7
  83. package/dist/tools/parse-stack-trace.d.ts +23 -21
  84. package/dist/tools/parse-stack-trace.js +10 -7
  85. package/dist/tools/plan-migration.d.ts +65 -25
  86. package/dist/tools/plan-migration.js +19 -19
  87. package/dist/tools/resolve-type.d.ts +19 -9
  88. package/dist/tools/resolve-type.js +19 -11
  89. package/dist/tools/review-feedback.d.ts +27 -24
  90. package/dist/tools/review-feedback.js +24 -20
  91. package/dist/tools/rollback-changes.d.ts +13 -9
  92. package/dist/tools/rollback-changes.js +10 -7
  93. package/dist/tools/run-angular-cli.d.ts +12 -10
  94. package/dist/tools/run-angular-cli.js +11 -8
  95. package/dist/tools/run-build.d.ts +13 -11
  96. package/dist/tools/run-build.js +11 -8
  97. package/dist/tools/run-schematic.d.ts +12 -10
  98. package/dist/tools/run-schematic.js +11 -8
  99. package/dist/tools/scan-all.d.ts +69 -12
  100. package/dist/tools/scan-all.js +55 -122
  101. package/dist/tools/scan-angular.d.ts +41 -9
  102. package/dist/tools/scan-angular.js +66 -135
  103. package/dist/tools/scan-architecture.d.ts +75 -14
  104. package/dist/tools/scan-architecture.js +180 -185
  105. package/dist/tools/scan-solid.d.ts +40 -9
  106. package/dist/tools/scan-solid.js +64 -133
  107. package/dist/tools/search-codebase.d.ts +30 -24
  108. package/dist/tools/search-codebase.js +13 -10
  109. package/dist/tools/server-status.d.ts +116 -24
  110. package/dist/tools/server-status.js +85 -26
  111. package/dist/tools/suggest-improvements.d.ts +22 -19
  112. package/dist/tools/suggest-improvements.js +21 -17
  113. package/dist/tools/trace-output-flow.d.ts +32 -25
  114. package/dist/tools/trace-output-flow.js +24 -21
  115. package/dist/tools/transform-code.d.ts +71 -10
  116. package/dist/tools/transform-code.js +60 -42
  117. package/dist/tools/validate-before-transform.d.ts +24 -9
  118. package/dist/tools/validate-before-transform.js +10 -7
  119. package/dist/tools/validate-project-compatibility.d.ts +18 -13
  120. package/dist/tools/validate-project-compatibility.js +17 -11
  121. package/dist/tools/validate-transformation.d.ts +28 -11
  122. package/dist/tools/validate-transformation.js +14 -8
  123. package/dist/tools/verify-citations.d.ts +37 -16
  124. package/dist/tools/verify-citations.js +19 -16
  125. package/dist/types.d.ts +40 -10
  126. package/dist/types.js +0 -5
  127. package/package.json +12 -18
  128. package/dist/tools/shared/scan-types.d.ts +0 -200
  129. package/dist/tools/shared/scan-types.js +0 -7
@@ -1,20 +1,3 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Analyze Parser Performance Tool
3
- *
4
- * MCP tool for analyzing parser performance metrics from transformation feedback sessions.
5
- * Generates actionable improvement recommendations based on parser behavior and efficiency.
6
- *
7
- * Multi-Session Aggregation:
8
- * - Aggregates metrics across multiple sessions
9
- * - Calculates average performance statistics
10
- * - Identifies common improvement opportunities
11
- *
12
- * Location Support:
13
- * - 'both' (default): the project, plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set
14
- * - Automatic session deduplication by sessionId
15
- *
16
- * Parser Configuration & Feedback
17
- */
18
1
  import { FeedbackStorage, ParserFeedbackAnalyzer, loadConfig, } from '@angular-modernizer/core';
19
2
  import { countList } from './helpers/analysis-output.js';
20
3
  import { STRING_ARRAY } from './helpers/investigation-schemas.js';
@@ -38,7 +21,18 @@ function describeParserPerformance(output) {
38
21
  return lines.join('\n');
39
22
  }
40
23
  /**
41
- * Analyze parser performance from transformation feedback sessions
24
+ * MCP tool for analyzing parser performance metrics from transformation feedback sessions.
25
+ * Generates improvement recommendations based on parser behavior and efficiency.
26
+ *
27
+ * @remarks
28
+ * Multi-Session Aggregation:
29
+ * - Aggregates metrics across multiple sessions
30
+ * - Calculates average performance statistics
31
+ * - Identifies common improvement opportunities
32
+ *
33
+ * Location Support:
34
+ * - 'both' (default): the project, plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set
35
+ * - Automatic session deduplication by sessionId
42
36
  */
43
37
  export class AnalyzeParserPerformanceTool {
44
38
  name = 'analyze-parser-performance';
@@ -53,6 +47,10 @@ export class AnalyzeParserPerformanceTool {
53
47
  'Generates actionable improvement recommendations based on parser behavior. ' +
54
48
  'Reads <projectRoot>/.claude-feedback, plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set. ' +
55
49
  'Supports multi-session aggregation. summary is a short text of the metrics and the top suggestions.';
50
+ /**
51
+ * JSON Schema of the tool arguments.
52
+ * @hidden
53
+ */
56
54
  inputSchema = {
57
55
  type: 'object',
58
56
  additionalProperties: false,
@@ -76,6 +74,10 @@ export class AnalyzeParserPerformanceTool {
76
74
  },
77
75
  required: [],
78
76
  };
77
+ /**
78
+ * JSON Schema of the tool result (`structuredContent`).
79
+ * @hidden
80
+ */
79
81
  outputSchema = {
80
82
  type: 'object',
81
83
  properties: {
@@ -1,47 +1,63 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Analyze Project Tool
3
- *
4
- * MCP tool for analyzing Angular projects to detect framework,
5
- * architecture, layers, and technologies.
6
- */
7
1
  import type { MCPTool, ToolAnnotations, ToolContext } from '../types.js';
8
2
  import { type CancelledExecution } from './helpers/tool-context.js';
9
3
  /**
10
4
  * Result from the analyze-project tool.
11
5
  */
12
- interface AnalyzeProjectResult {
6
+ export interface AnalyzeProjectResult {
13
7
  /**
14
8
  * Framework detection results.
15
9
  */
16
10
  framework: {
11
+ /** `true` when a framework was recognized. */
17
12
  detected: boolean;
13
+ /** Framework name, e.g. Angular CLI or Nx. */
18
14
  type: string;
15
+ /** Detection confidence. */
19
16
  confidence: number;
17
+ /** Findings that led to the detection. */
20
18
  indicators: string[];
21
19
  /**
22
20
  * All projects in the Angular workspace (applications + libraries).
23
21
  */
24
22
  projects?: {
23
+ /** Application projects. */
25
24
  applications: {
25
+ /** Project name. */
26
26
  name: string;
27
+ /** Project root folder. */
27
28
  root: string;
29
+ /** Source root folder. */
28
30
  sourceRoot?: string;
31
+ /** `true` when the application has a service worker. */
29
32
  hasServiceWorker: boolean;
33
+ /** Path of the service worker configuration. */
30
34
  serviceWorkerConfig?: string;
31
35
  }[];
36
+ /** Library projects. */
32
37
  libraries: {
38
+ /** Project name. */
33
39
  name: string;
40
+ /** Project root folder. */
34
41
  root: string;
42
+ /** Source root folder. */
35
43
  sourceRoot?: string;
36
44
  }[];
37
45
  };
46
+ /** Offline (PWA) capabilities of the workspace. */
38
47
  offlineApp?: {
48
+ /** `true` when offline support was found. */
39
49
  detected: boolean;
50
+ /** Findings that led to the detection. */
40
51
  indicators: string[];
52
+ /** `true` when a service worker is configured. */
41
53
  serviceWorker?: boolean;
54
+ /** Detected PWA features. */
42
55
  pwaFeatures?: string[];
56
+ /** Applications with offline support. */
43
57
  applications?: {
58
+ /** Project name. */
44
59
  name: string;
60
+ /** Path of the service worker configuration. */
45
61
  serviceWorkerConfig?: string;
46
62
  }[];
47
63
  };
@@ -50,11 +66,17 @@ interface AnalyzeProjectResult {
50
66
  * Architecture analysis results.
51
67
  */
52
68
  architecture: {
69
+ /** Detected architecture pattern. */
53
70
  pattern: string;
71
+ /** Detection confidence. */
54
72
  confidence: number;
73
+ /** Layers derived from the folder structure and path aliases. */
55
74
  layers: {
75
+ /** Layer name. */
56
76
  name: string;
77
+ /** Layer folder. */
57
78
  path: string;
79
+ /** Short description of the layer's role. */
58
80
  purpose: string;
59
81
  }[];
60
82
  };
@@ -62,27 +84,39 @@ interface AnalyzeProjectResult {
62
84
  * Technology stack analysis.
63
85
  */
64
86
  technologyStack: {
87
+ /** Languages used in the project. */
65
88
  languages: string[];
89
+ /** Frameworks and libraries found. */
66
90
  frameworks: string[];
91
+ /** Build tools found. */
67
92
  buildTools: string[];
93
+ /** Package manager (`npm`, `yarn` or `pnpm`) from the lock file. */
68
94
  packageManager: string;
69
95
  };
70
96
  /**
71
97
  * Analysis results from rules.
72
98
  */
73
99
  results: {
100
+ /** Rule that reported the finding. */
74
101
  ruleId: string;
102
+ /** Finding message. */
75
103
  message: string;
104
+ /** File the finding refers to. */
76
105
  filePath: string;
106
+ /** Rule-specific details. */
77
107
  metadata?: Record<string, unknown>;
78
108
  }[];
79
109
  /**
80
110
  * Counts of the run.
81
111
  */
82
112
  counts: {
113
+ /** Files in the project. */
83
114
  totalFiles: number;
115
+ /** Files analyzed by the rules. */
84
116
  analyzedFiles: number;
117
+ /** Number of analyzer rules run. */
85
118
  rulesExecuted: number;
119
+ /** Duration of the run in milliseconds. */
86
120
  duration: number;
87
121
  };
88
122
  /**
@@ -93,37 +127,58 @@ interface AnalyzeProjectResult {
93
127
  * Project metadata.
94
128
  */
95
129
  metadata: {
130
+ /** Analyzed project root. */
96
131
  projectRoot: string;
132
+ /** tsconfig used for the analysis. */
97
133
  tsconfigPath: string;
134
+ /** Path of `package.json`, when found. */
98
135
  packageJsonPath?: string;
136
+ /** Path of `angular.json`, when found. */
99
137
  angularJsonPath?: string;
100
138
  };
101
139
  /**
102
140
  * Pagination metadata (when pagination is used).
103
141
  */
104
142
  pagination?: {
143
+ /** Findings in total. */
105
144
  totalResults: number;
145
+ /** Findings in this page. */
106
146
  returnedResults: number;
147
+ /** Offset of the page (`resultOffset`). */
107
148
  offset: number;
149
+ /** `true` when more findings follow the page. */
108
150
  hasMore: boolean;
109
151
  };
110
152
  /**
111
- * Orchestration metrics (Phase 5b).
153
+ * Orchestration metrics, set when `parallel` or `incremental` was requested.
112
154
  */
113
155
  orchestration?: {
156
+ /** Parallel execution was requested. */
114
157
  parallel: boolean;
158
+ /** Incremental mode was requested. */
115
159
  incremental: boolean;
160
+ /** Files skipped by incremental analysis. */
116
161
  filesSkipped?: number;
162
+ /** Incremental cache hit rate. */
117
163
  cacheHitRate?: number;
164
+ /** Duration of the run in milliseconds. */
118
165
  duration: number;
166
+ /** Analyzed files per second. */
119
167
  throughput: number;
168
+ /** Heap figures from the kernel's resource stats. */
120
169
  memoryUsage?: {
170
+ /** Heap in use. */
121
171
  peak: number;
172
+ /** Half of the total heap. */
122
173
  average: number;
123
174
  };
175
+ /** Statistics of the parallel executor. */
124
176
  workerStats?: {
177
+ /** Completed tasks. */
125
178
  completedTasks: number;
179
+ /** Average task duration. */
126
180
  averageTaskDuration: number;
181
+ /** CPU time of all tasks. */
127
182
  totalCpuTime: number;
128
183
  };
129
184
  };
@@ -131,26 +186,38 @@ interface AnalyzeProjectResult {
131
186
  * Progress state (if enableProgress was true).
132
187
  */
133
188
  progress?: {
189
+ /** Processed items. */
134
190
  current: number;
191
+ /** Items in total. */
135
192
  total: number;
193
+ /** Progress in percent. */
136
194
  percentage: number;
195
+ /** Estimated time to completion. */
137
196
  eta?: number;
197
+ /** Progress type reported by the kernel. */
138
198
  phase: string;
139
199
  };
140
200
  /** Set when the client cancelled the analysis; counts cover the analyzed files. */
141
201
  execution?: CancelledExecution;
142
202
  }
143
203
  /**
144
- * Analyze Project Tool
204
+ * MCP tool `analyze-project`: detects the framework (Angular CLI, Nx),
205
+ * architecture pattern, layers, workspace projects and technology stack of
206
+ * an Angular project.
145
207
  *
146
- * Provides comprehensive project analysis capabilities through MCP.
147
- * Uses the Analyzer plugin to detect framework, architecture, and technologies.
208
+ * @remarks
209
+ * Uses the Analyzer plugin. Rule findings are returned only with
210
+ * `includeDetails`, paged by `maxResults` and `resultOffset`.
148
211
  */
149
212
  export declare class AnalyzeProjectTool implements MCPTool {
150
213
  readonly name = "analyze-project";
151
214
  readonly title = "Analyze Project";
152
215
  readonly annotations: ToolAnnotations;
153
216
  readonly description: string;
217
+ /**
218
+ * JSON Schema of the tool arguments.
219
+ * @hidden
220
+ */
154
221
  readonly inputSchema: {
155
222
  type: string;
156
223
  additionalProperties: boolean;
@@ -252,6 +319,10 @@ export declare class AnalyzeProjectTool implements MCPTool {
252
319
  };
253
320
  required: never[];
254
321
  };
322
+ /**
323
+ * JSON Schema of the tool result (`structuredContent`).
324
+ * @hidden
325
+ */
255
326
  readonly outputSchema: {
256
327
  type: string;
257
328
  properties: {
@@ -535,5 +606,4 @@ export declare class AnalyzeProjectTool implements MCPTool {
535
606
  */
536
607
  private loadConfig;
537
608
  }
538
- export {};
539
609
  //# sourceMappingURL=analyze-project.d.ts.map
@@ -1,22 +1,15 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Analyze Project Tool
3
- *
4
- * MCP tool for analyzing Angular projects to detect framework,
5
- * architecture, layers, and technologies.
6
- */
7
1
  import { findTsConfig } from './helpers/find-ts-config.js';
8
2
  import { toParallelOptions } from '../types.js';
9
- import { Kernel, loadConfig } from '@angular-modernizer/core';
3
+ import { Kernel } from '@angular-modernizer/core';
10
4
  import { AnalyzerPlugin } from '@angular-modernizer/plugin-analyzer';
11
- import { ContextFactory } from '@angular-modernizer/plugin-system';
12
- import { createPublicApi } from '@angular-modernizer/api';
13
5
  import { getWorkerScriptPath } from '@angular-modernizer/worker';
14
6
  import { getMCPWatcher } from '../mcp-watcher.js';
15
7
  import { glob } from 'glob';
16
8
  import { resolve, extname } from 'node:path';
17
9
  import { readFileSync, existsSync } from 'node:fs';
18
10
  import { PAGINATION_SCHEMA, SCAN_EXECUTION_SCHEMA, nameList, pageNote, } from './helpers/analysis-output.js';
19
- import { cancelledExecution, fileProgressMessage, forwardKernelProgress, yieldIfCancellable, } from './helpers/tool-context.js';
11
+ import { cancelledExecution, fileProgressMessage, forwardKernelProgress, } from './helpers/tool-context.js';
12
+ import { runScan } from '../scan-host/scan-host.js';
20
13
  import { STRING_ARRAY } from './helpers/investigation-schemas.js';
21
14
  /** Application or library entry of `framework.projects`. */
22
15
  const NAMED_PROJECT_SCHEMA = {
@@ -68,10 +61,13 @@ function describeAnalysis(analysis, totalResults) {
68
61
  return lines.join('\n');
69
62
  }
70
63
  /**
71
- * Analyze Project Tool
64
+ * MCP tool `analyze-project`: detects the framework (Angular CLI, Nx),
65
+ * architecture pattern, layers, workspace projects and technology stack of
66
+ * an Angular project.
72
67
  *
73
- * Provides comprehensive project analysis capabilities through MCP.
74
- * Uses the Analyzer plugin to detect framework, architecture, and technologies.
68
+ * @remarks
69
+ * Uses the Analyzer plugin. Rule findings are returned only with
70
+ * `includeDetails`, paged by `maxResults` and `resultOffset`.
75
71
  */
76
72
  export class AnalyzeProjectTool {
77
73
  name = 'analyze-project';
@@ -85,6 +81,10 @@ export class AnalyzeProjectTool {
85
81
  description = 'Analyze Angular projects to detect framework, architecture, layers, and technologies. ' +
86
82
  'counts holds the file and rule numbers, summary a short text; includeDetails returns the rule findings ' +
87
83
  '(maxResults and resultOffset page them).';
84
+ /**
85
+ * JSON Schema of the tool arguments.
86
+ * @hidden
87
+ */
88
88
  inputSchema = {
89
89
  type: 'object',
90
90
  additionalProperties: false,
@@ -115,16 +115,16 @@ export class AnalyzeProjectTool {
115
115
  },
116
116
  orchestration: {
117
117
  type: 'object',
118
- description: 'Advanced orchestration options for analysis',
118
+ description: 'Deprecated, kept in 1.x: parallel and incremental run the old WorkerPool path on the main thread. On a large app it was no faster than the default path, blocked the server for seconds and took about four times the memory. Leave unset; the default path runs in the scan worker and answers cancellation at once.',
119
119
  properties: {
120
120
  parallel: {
121
121
  type: 'boolean',
122
- description: 'Enable parallel execution for faster analysis',
122
+ description: 'Deprecated: runs the old WorkerPool path over the whole program instead of 50 files. Leave unset.',
123
123
  default: false,
124
124
  },
125
125
  incremental: {
126
126
  type: 'boolean',
127
- description: 'Only analyze changed files (requires git)',
127
+ description: 'Deprecated: analyzes files changed against baseBranch (requires git, else every file) on the main thread. Leave unset.',
128
128
  default: false,
129
129
  },
130
130
  baseBranch: {
@@ -184,6 +184,10 @@ export class AnalyzeProjectTool {
184
184
  },
185
185
  required: [],
186
186
  };
187
+ /**
188
+ * JSON Schema of the tool result (`structuredContent`).
189
+ * @hidden
190
+ */
187
191
  outputSchema = {
188
192
  type: 'object',
189
193
  properties: {
@@ -325,28 +329,6 @@ export class AnalyzeProjectTool {
325
329
  if (!tsConfigPath) {
326
330
  throw new Error('Could not find tsconfig.json in the project root');
327
331
  }
328
- if (opId) {
329
- watcher?.updateOperation(opId, 'initializing-kernel', 'Creating Kernel with AnalyzerPlugin');
330
- }
331
- // Initialize kernel with full Phase 6d/7b orchestration support + caching
332
- const kernel = new Kernel({
333
- tsConfigPath,
334
- plugins: [new AnalyzerPlugin()],
335
- cacheConfig: {
336
- enabled: true,
337
- cacheDir: resolve(mergedParams.rootPath, '.angular-modernizer-cache'),
338
- maxSize: 100 * 1024 * 1024, // 100MB
339
- maxAge: 24 * 60 * 60 * 1000, // 24 hours
340
- compression: true,
341
- },
342
- });
343
- await kernel.initialize();
344
- // Load rules config from .angular-modernizer.json for per-rule overrides (BUG-3)
345
- const fullAnalyzeConfig = loadConfig(mergedParams.rootPath ?? process.cwd());
346
- const analyzeRulesConfig = (fullAnalyzeConfig.rules ?? {});
347
- if (opId) {
348
- watcher?.updateOperation(opId, 'kernel-ready', 'Kernel initialized successfully');
349
- }
350
332
  // Analyze project structure
351
333
  if (opId) {
352
334
  watcher?.updateOperation(opId, 'analyzing-structure', 'Scanning project structure');
@@ -356,30 +338,55 @@ export class AnalyzeProjectTool {
356
338
  if (opId) {
357
339
  watcher?.updateOperation(opId, 'structure-complete', `Found ${projectStructure.totalFiles} files`);
358
340
  }
359
- // Setup progress tracking if requested
360
- let lastProgress;
361
- if (ctx.progress !== undefined) {
362
- forwardKernelProgress(kernel.getProgressReporter(), ctx.progress);
363
- }
364
- if (orchestration.enableProgress) {
365
- const progressReporter = kernel.getProgressReporter();
366
- if (progressReporter) {
367
- progressReporter.on('progress', (progress) => {
368
- lastProgress = {
369
- current: progress.current,
370
- total: progress.total,
371
- percentage: progress.percentage,
372
- eta: progress.eta,
373
- phase: progress.type,
374
- };
375
- });
376
- }
377
- }
378
341
  // Run analysis using full Phase 6d/7b orchestration
379
342
  let results = [];
380
343
  let filesAnalyzed = 0;
381
344
  let execution;
345
+ let lastProgress;
346
+ // The parallel and incremental paths run the kernel here (it starts its
347
+ // own analysis workers); the sequential path runs in a scan worker.
348
+ let parallelKernel;
349
+ let rulesExecuted = 0;
382
350
  if (orchestration.parallel || orchestration.incremental) {
351
+ if (opId) {
352
+ watcher?.updateOperation(opId, 'initializing-kernel', 'Creating Kernel with AnalyzerPlugin');
353
+ }
354
+ // Initialize kernel with full Phase 6d/7b orchestration support + caching
355
+ const kernel = new Kernel({
356
+ tsConfigPath,
357
+ plugins: [new AnalyzerPlugin()],
358
+ cacheConfig: {
359
+ enabled: true,
360
+ cacheDir: resolve(mergedParams.rootPath, '.angular-modernizer-cache'),
361
+ maxSize: 100 * 1024 * 1024, // 100MB
362
+ maxAge: 24 * 60 * 60 * 1000, // 24 hours
363
+ compression: true,
364
+ },
365
+ });
366
+ await kernel.initialize();
367
+ if (opId) {
368
+ watcher?.updateOperation(opId, 'kernel-ready', 'Kernel initialized successfully');
369
+ }
370
+ // Setup progress tracking if requested
371
+ if (ctx.progress !== undefined) {
372
+ forwardKernelProgress(kernel.getProgressReporter(), ctx.progress);
373
+ }
374
+ if (orchestration.enableProgress) {
375
+ const progressReporter = kernel.getProgressReporter();
376
+ if (progressReporter) {
377
+ progressReporter.on('progress', (progress) => {
378
+ lastProgress = {
379
+ current: progress.current,
380
+ total: progress.total,
381
+ percentage: progress.percentage,
382
+ eta: progress.eta,
383
+ phase: progress.type,
384
+ };
385
+ });
386
+ }
387
+ }
388
+ parallelKernel = kernel;
389
+ rulesExecuted = kernel.getPlugin('analyzer').getAnalysisRules().length;
383
390
  if (opId) {
384
391
  const mode = orchestration.incremental ? 'incremental' : 'parallel';
385
392
  watcher?.updateOperation(opId, `starting-${mode}`, `Running ${mode} analysis`);
@@ -434,53 +441,43 @@ export class AnalyzeProjectTool {
434
441
  if (opId) {
435
442
  watcher?.updateOperation(opId, 'starting-sequential', 'Running sequential analysis');
436
443
  }
437
- const project = kernel.getProject();
438
- const api = createPublicApi(project); // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
439
- const plugin = kernel.getPlugin('analyzer');
440
- const rules = plugin.getAnalysisRules();
441
444
  const tsFiles = await this.findTypeScriptFiles(mergedParams.rootPath, mergedParams.maxDepth ?? 3);
442
445
  if (opId) {
443
446
  watcher?.updateOperation(opId, 'scanning-files', `Found ${tsFiles.length} files to analyze`);
444
447
  }
448
+ // Kernel (the whole tsconfig program) and rules run in a scan worker,
449
+ // so the server keeps reading stdin while the program is built
445
450
  const sequentialFiles = tsFiles.slice(0, 50);
446
- for (let i = 0; i < sequentialFiles.length; i++) {
447
- const filePath = sequentialFiles[i];
448
- if (!filePath) {
449
- continue;
450
- }
451
- await yieldIfCancellable(ctx.signal);
452
- if (ctx.signal?.aborted === true) {
453
- execution = cancelledExecution(i, sequentialFiles.length - i);
454
- break;
455
- }
456
- ctx.progress?.(i, sequentialFiles.length, fileProgressMessage(i, sequentialFiles.length, results.length));
457
- // Update progress every 10 files
458
- if (opId && i > 0 && i % 10 === 0) {
459
- watcher?.updateOperation(opId, 'analyzing-files', `${i}/${tsFiles.slice(0, 50).length} files processed`);
460
- }
461
- try {
462
- const sourceFile = project.addSourceFileAtPath(filePath);
463
- for (const rule of rules) {
464
- const ruleResults = await rule.analyze(ContextFactory.createAnalysisContext({
465
- sourceFile,
466
- project,
467
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
468
- api,
469
- config: analyzeRulesConfig,
470
- }));
471
- for (const result of ruleResults) {
472
- results.push({
473
- ruleId: result.ruleId,
474
- message: result.message,
475
- filePath: result.filePath,
476
- metadata: result.metadata,
477
- });
478
- }
451
+ let done = 0;
452
+ ctx.progress?.(0, sequentialFiles.length, fileProgressMessage(0, sequentialFiles.length, 0));
453
+ const engine = await runScan({
454
+ tool: this.name,
455
+ plugins: 'analyzer',
456
+ tsConfigPath,
457
+ rootPath: mergedParams.rootPath,
458
+ files: sequentialFiles,
459
+ mode: 'sequential',
460
+ }, {
461
+ file: (event) => {
462
+ for (const finding of event.findings) {
463
+ results.push({
464
+ ruleId: finding.ruleId,
465
+ message: finding.message,
466
+ filePath: finding.filePath,
467
+ metadata: finding.metadata,
468
+ });
479
469
  }
480
- }
481
- catch (error) {
482
- console.warn(`Error analyzing ${filePath}:`, error);
483
- }
470
+ done++;
471
+ ctx.progress?.(done, sequentialFiles.length, fileProgressMessage(done, sequentialFiles.length, results.length));
472
+ // Update progress every 10 files
473
+ if (opId && done % 10 === 0) {
474
+ watcher?.updateOperation(opId, 'analyzing-files', `${done}/${sequentialFiles.length} files processed`);
475
+ }
476
+ },
477
+ }, { signal: ctx.signal });
478
+ rulesExecuted = engine.ruleIds.length;
479
+ if (engine.cancelled) {
480
+ execution = cancelledExecution(done, sequentialFiles.length - done);
484
481
  }
485
482
  filesAnalyzed =
486
483
  sequentialFiles.length - (execution?.skippedFiles ?? 0);
@@ -495,8 +492,8 @@ export class AnalyzeProjectTool {
495
492
  const duration = Date.now() - startTime;
496
493
  // Gather orchestration stats
497
494
  let orchestrationMetrics;
498
- if (orchestration.parallel || orchestration.incremental) {
499
- const stats = kernel.getOrchestrationStats();
495
+ if (parallelKernel !== undefined) {
496
+ const stats = parallelKernel.getOrchestrationStats();
500
497
  orchestrationMetrics = {
501
498
  parallel: orchestration.parallel ?? false,
502
499
  incremental: orchestration.incremental ?? false,
@@ -544,7 +541,7 @@ export class AnalyzeProjectTool {
544
541
  counts: {
545
542
  totalFiles: projectStructure.totalFiles,
546
543
  analyzedFiles: filesAnalyzed,
547
- rulesExecuted: kernel.getPlugin('analyzer').getAnalysisRules().length,
544
+ rulesExecuted,
548
545
  duration,
549
546
  },
550
547
  metadata: {
@@ -1,20 +1,13 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Check Incremental Compatibility Tool
3
- *
4
- * MCP tool for checking project compatibility with incremental build validation.
5
- * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
6
- * and complex monorepo structures. Provides clear recommendations and speedup estimates.
7
- */
8
1
  import { type MCPTool, type ToolAnnotations } from '../types.js';
9
2
  import { type IncompatibilityCheck } from '@angular-modernizer/core';
10
3
  /**
11
4
  * Recommendation type for incremental build usage.
12
5
  */
13
- type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
6
+ export type RecommendationType = 'use-incremental' | 'use-full' | 'use-with-caution';
14
7
  /**
15
8
  * Output result of compatibility check.
16
9
  */
17
- interface CompatibilityCheckOutput {
10
+ export interface CompatibilityCheckOutput {
18
11
  /**
19
12
  * Whether incremental build is compatible (no blockers).
20
13
  */
@@ -46,13 +39,19 @@ interface CompatibilityCheckOutput {
46
39
  summary: string;
47
40
  }
48
41
  /**
49
- * MCP tool for checking incremental build compatibility.
42
+ * MCP tool for checking project compatibility with incremental build validation.
43
+ * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
44
+ * and complex monorepo structures. Provides clear recommendations and speedup estimates.
50
45
  */
51
46
  export declare class CheckIncrementalCompatibilityTool implements MCPTool {
52
47
  name: string;
53
48
  title: string;
54
49
  annotations: ToolAnnotations;
55
50
  description: string;
51
+ /**
52
+ * JSON Schema of the tool arguments.
53
+ * @hidden
54
+ */
56
55
  inputSchema: {
57
56
  type: string;
58
57
  additionalProperties: boolean;
@@ -79,6 +78,10 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
79
78
  };
80
79
  required: string[];
81
80
  };
81
+ /**
82
+ * JSON Schema of the tool result (`structuredContent`).
83
+ * @hidden
84
+ */
82
85
  outputSchema: {
83
86
  type: string;
84
87
  properties: {
@@ -165,5 +168,4 @@ export declare class CheckIncrementalCompatibilityTool implements MCPTool {
165
168
  */
166
169
  private formatDetails;
167
170
  }
168
- export {};
169
171
  //# sourceMappingURL=check-incremental-compatibility.d.ts.map