@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 - 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 = {
@@ -28,6 +21,14 @@ const NAMED_PROJECT_SCHEMA = {
28
21
  },
29
22
  required: ['name', 'root'],
30
23
  };
24
+ /** Keys of `tools.analyze-project` taken from the config. */
25
+ const CONFIG_KEYS = [
26
+ 'includeDetails',
27
+ 'maxDepth',
28
+ 'excludePatterns',
29
+ 'maxResults',
30
+ 'resultOffset',
31
+ ];
31
32
  /** Layers, projects and stack entries named in the summary. */
32
33
  const SUMMARY_NAMES = 10;
33
34
  /**
@@ -68,10 +69,13 @@ function describeAnalysis(analysis, totalResults) {
68
69
  return lines.join('\n');
69
70
  }
70
71
  /**
71
- * Analyze Project Tool
72
+ * MCP tool `analyze-project`: detects the framework (Angular CLI, Nx),
73
+ * architecture pattern, layers, workspace projects and technology stack of
74
+ * an Angular project.
72
75
  *
73
- * Provides comprehensive project analysis capabilities through MCP.
74
- * Uses the Analyzer plugin to detect framework, architecture, and technologies.
76
+ * @remarks
77
+ * Uses the Analyzer plugin. Rule findings are returned only with
78
+ * `includeDetails`, paged by `maxResults` and `resultOffset`.
75
79
  */
76
80
  export class AnalyzeProjectTool {
77
81
  name = 'analyze-project';
@@ -85,6 +89,10 @@ export class AnalyzeProjectTool {
85
89
  description = 'Analyze Angular projects to detect framework, architecture, layers, and technologies. ' +
86
90
  'counts holds the file and rule numbers, summary a short text; includeDetails returns the rule findings ' +
87
91
  '(maxResults and resultOffset page them).';
92
+ /**
93
+ * JSON Schema of the tool arguments.
94
+ * @hidden
95
+ */
88
96
  inputSchema = {
89
97
  type: 'object',
90
98
  additionalProperties: false,
@@ -115,16 +123,16 @@ export class AnalyzeProjectTool {
115
123
  },
116
124
  orchestration: {
117
125
  type: 'object',
118
- description: 'Advanced orchestration options for analysis',
126
+ 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
127
  properties: {
120
128
  parallel: {
121
129
  type: 'boolean',
122
- description: 'Enable parallel execution for faster analysis',
130
+ description: 'Deprecated: runs the old WorkerPool path over the whole program instead of 50 files. Leave unset.',
123
131
  default: false,
124
132
  },
125
133
  incremental: {
126
134
  type: 'boolean',
127
- description: 'Only analyze changed files (requires git)',
135
+ description: 'Deprecated: analyzes files changed against baseBranch (requires git, else every file) on the main thread. Leave unset.',
128
136
  default: false,
129
137
  },
130
138
  baseBranch: {
@@ -184,6 +192,10 @@ export class AnalyzeProjectTool {
184
192
  },
185
193
  required: [],
186
194
  };
195
+ /**
196
+ * JSON Schema of the tool result (`structuredContent`).
197
+ * @hidden
198
+ */
187
199
  outputSchema = {
188
200
  type: 'object',
189
201
  properties: {
@@ -325,28 +337,6 @@ export class AnalyzeProjectTool {
325
337
  if (!tsConfigPath) {
326
338
  throw new Error('Could not find tsconfig.json in the project root');
327
339
  }
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
340
  // Analyze project structure
351
341
  if (opId) {
352
342
  watcher?.updateOperation(opId, 'analyzing-structure', 'Scanning project structure');
@@ -356,30 +346,55 @@ export class AnalyzeProjectTool {
356
346
  if (opId) {
357
347
  watcher?.updateOperation(opId, 'structure-complete', `Found ${projectStructure.totalFiles} files`);
358
348
  }
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
349
  // Run analysis using full Phase 6d/7b orchestration
379
350
  let results = [];
380
351
  let filesAnalyzed = 0;
381
352
  let execution;
353
+ let lastProgress;
354
+ // The parallel and incremental paths run the kernel here (it starts its
355
+ // own analysis workers); the sequential path runs in a scan worker.
356
+ let parallelKernel;
357
+ let rulesExecuted = 0;
382
358
  if (orchestration.parallel || orchestration.incremental) {
359
+ if (opId) {
360
+ watcher?.updateOperation(opId, 'initializing-kernel', 'Creating Kernel with AnalyzerPlugin');
361
+ }
362
+ // Initialize kernel with full Phase 6d/7b orchestration support + caching
363
+ const kernel = new Kernel({
364
+ tsConfigPath,
365
+ plugins: [new AnalyzerPlugin()],
366
+ cacheConfig: {
367
+ enabled: true,
368
+ cacheDir: resolve(mergedParams.rootPath, '.angular-modernizer-cache'),
369
+ maxSize: 100 * 1024 * 1024, // 100MB
370
+ maxAge: 24 * 60 * 60 * 1000, // 24 hours
371
+ compression: true,
372
+ },
373
+ });
374
+ await kernel.initialize();
375
+ if (opId) {
376
+ watcher?.updateOperation(opId, 'kernel-ready', 'Kernel initialized successfully');
377
+ }
378
+ // Setup progress tracking if requested
379
+ if (ctx.progress !== undefined) {
380
+ forwardKernelProgress(kernel.getProgressReporter(), ctx.progress);
381
+ }
382
+ if (orchestration.enableProgress) {
383
+ const progressReporter = kernel.getProgressReporter();
384
+ if (progressReporter) {
385
+ progressReporter.on('progress', (progress) => {
386
+ lastProgress = {
387
+ current: progress.current,
388
+ total: progress.total,
389
+ percentage: progress.percentage,
390
+ eta: progress.eta,
391
+ phase: progress.type,
392
+ };
393
+ });
394
+ }
395
+ }
396
+ parallelKernel = kernel;
397
+ rulesExecuted = kernel.getPlugin('analyzer').getAnalysisRules().length;
383
398
  if (opId) {
384
399
  const mode = orchestration.incremental ? 'incremental' : 'parallel';
385
400
  watcher?.updateOperation(opId, `starting-${mode}`, `Running ${mode} analysis`);
@@ -434,53 +449,43 @@ export class AnalyzeProjectTool {
434
449
  if (opId) {
435
450
  watcher?.updateOperation(opId, 'starting-sequential', 'Running sequential analysis');
436
451
  }
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
452
  const tsFiles = await this.findTypeScriptFiles(mergedParams.rootPath, mergedParams.maxDepth ?? 3);
442
453
  if (opId) {
443
454
  watcher?.updateOperation(opId, 'scanning-files', `Found ${tsFiles.length} files to analyze`);
444
455
  }
456
+ // Kernel (the whole tsconfig program) and rules run in a scan worker,
457
+ // so the server keeps reading stdin while the program is built
445
458
  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
- }
459
+ let done = 0;
460
+ ctx.progress?.(0, sequentialFiles.length, fileProgressMessage(0, sequentialFiles.length, 0));
461
+ const engine = await runScan({
462
+ tool: this.name,
463
+ plugins: 'analyzer',
464
+ tsConfigPath,
465
+ rootPath: mergedParams.rootPath,
466
+ files: sequentialFiles,
467
+ mode: 'sequential',
468
+ }, {
469
+ file: (event) => {
470
+ for (const finding of event.findings) {
471
+ results.push({
472
+ ruleId: finding.ruleId,
473
+ message: finding.message,
474
+ filePath: finding.filePath,
475
+ metadata: finding.metadata,
476
+ });
479
477
  }
480
- }
481
- catch (error) {
482
- console.warn(`Error analyzing ${filePath}:`, error);
483
- }
478
+ done++;
479
+ ctx.progress?.(done, sequentialFiles.length, fileProgressMessage(done, sequentialFiles.length, results.length));
480
+ // Update progress every 10 files
481
+ if (opId && done % 10 === 0) {
482
+ watcher?.updateOperation(opId, 'analyzing-files', `${done}/${sequentialFiles.length} files processed`);
483
+ }
484
+ },
485
+ }, { signal: ctx.signal });
486
+ rulesExecuted = engine.ruleIds.length;
487
+ if (engine.cancelled) {
488
+ execution = cancelledExecution(done, sequentialFiles.length - done);
484
489
  }
485
490
  filesAnalyzed =
486
491
  sequentialFiles.length - (execution?.skippedFiles ?? 0);
@@ -495,8 +500,8 @@ export class AnalyzeProjectTool {
495
500
  const duration = Date.now() - startTime;
496
501
  // Gather orchestration stats
497
502
  let orchestrationMetrics;
498
- if (orchestration.parallel || orchestration.incremental) {
499
- const stats = kernel.getOrchestrationStats();
503
+ if (parallelKernel !== undefined) {
504
+ const stats = parallelKernel.getOrchestrationStats();
500
505
  orchestrationMetrics = {
501
506
  parallel: orchestration.parallel ?? false,
502
507
  incremental: orchestration.incremental ?? false,
@@ -521,11 +526,11 @@ export class AnalyzeProjectTool {
521
526
  }
522
527
  // Apply pagination to results if includeDetails is true
523
528
  const totalResults = results.length;
524
- const maxResults = params.maxResults ?? 1000;
525
- const resultOffset = params.resultOffset ?? 0;
529
+ const maxResults = mergedParams.maxResults ?? 1000;
530
+ const resultOffset = mergedParams.resultOffset ?? 0;
526
531
  let paginatedResults = results;
527
532
  let paginationMetadata;
528
- if (params.includeDetails) {
533
+ if (mergedParams.includeDetails) {
529
534
  // Slice results for pagination
530
535
  paginatedResults = results.slice(resultOffset, resultOffset + maxResults);
531
536
  // Add pagination metadata
@@ -540,11 +545,11 @@ export class AnalyzeProjectTool {
540
545
  framework,
541
546
  architecture,
542
547
  technologyStack,
543
- results: params.includeDetails ? paginatedResults : [],
548
+ results: mergedParams.includeDetails ? paginatedResults : [],
544
549
  counts: {
545
550
  totalFiles: projectStructure.totalFiles,
546
551
  analyzedFiles: filesAnalyzed,
547
- rulesExecuted: kernel.getPlugin('analyzer').getAnalysisRules().length,
552
+ rulesExecuted,
548
553
  duration,
549
554
  },
550
555
  metadata: {
@@ -1104,31 +1109,44 @@ export class AnalyzeProjectTool {
1104
1109
  return layers;
1105
1110
  }
1106
1111
  /**
1107
- * Load configuration from .angular-modernizer.json file.
1108
- * Only loads from the provided root path to avoid cache directory issues.
1112
+ * Settings of `tools.analyze-project` from the project's
1113
+ * `.angular-modernizer.json` (only from the given root, never from the
1114
+ * server's working directory). Only {@link CONFIG_KEYS} are taken; the
1115
+ * config used to be read from a top-level `analyze-project` key, which the
1116
+ * schema does not allow, so no setting ever applied.
1109
1117
  */
1110
1118
  loadConfig(providedRootPath) {
1111
- // Only load config if rootPath is explicitly provided
1112
- // This prevents accidentally using process.cwd() which may point to the MCP server directory
1113
1119
  if (!providedRootPath) {
1114
1120
  return {};
1115
1121
  }
1116
1122
  const configPath = resolve(providedRootPath, '.angular-modernizer.json');
1117
- if (existsSync(configPath)) {
1118
- try {
1119
- // Disable no-unsafe-assignment: JSON.parse() returns 'any' but config structure is validated below
1120
- const config = JSON.parse(readFileSync(configPath, 'utf-8')); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
1121
- // Disable no-unsafe-member-access and no-unsafe-assignment: config is parsed from JSON and may be any, but we validate it below (line 1315)
1122
- const analyzeProjectConfig = config['analyze-project']; // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
1123
- if (analyzeProjectConfig && typeof analyzeProjectConfig === 'object') {
1124
- return analyzeProjectConfig;
1125
- }
1126
- }
1127
- catch (error) {
1128
- console.warn(`Error loading config from ${configPath}:`, error);
1123
+ if (!existsSync(configPath)) {
1124
+ return {};
1125
+ }
1126
+ try {
1127
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
1128
+ const section = toolSection(config, 'analyze-project');
1129
+ if (section === undefined) {
1130
+ return {};
1129
1131
  }
1132
+ return Object.fromEntries(CONFIG_KEYS.filter((key) => section[key] !== undefined).map((key) => [
1133
+ key,
1134
+ section[key],
1135
+ ]));
1136
+ }
1137
+ catch (error) {
1138
+ console.warn(`Error loading config from ${configPath}:`, error);
1139
+ return {};
1130
1140
  }
1131
- return {};
1132
1141
  }
1133
1142
  }
1143
+ /** `tools.<name>` of a parsed config, when it is an object. */
1144
+ function toolSection(config, name) {
1145
+ const tools = isRecord(config) ? config['tools'] : undefined;
1146
+ const section = isRecord(tools) ? tools[name] : undefined;
1147
+ return isRecord(section) ? section : undefined;
1148
+ }
1149
+ function isRecord(value) {
1150
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
1151
+ }
1134
1152
  //# sourceMappingURL=analyze-project.js.map
@@ -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
@@ -1,10 +1,3 @@
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 { Project } from 'ts-morph';
9
2
  import { IncompatibilityDetector, } from '@angular-modernizer/core';
10
3
  import { existsSync, readFileSync } from 'node:fs';
@@ -32,7 +25,9 @@ function describeCompatibility(output) {
32
25
  return lines.join('\n');
33
26
  }
34
27
  /**
35
- * MCP tool for checking incremental build compatibility.
28
+ * MCP tool for checking project compatibility with incremental build validation.
29
+ * Detects blockers like circular dependencies, old Angular versions, custom webpack config,
30
+ * and complex monorepo structures. Provides clear recommendations and speedup estimates.
36
31
  */
37
32
  export class CheckIncrementalCompatibilityTool {
38
33
  name = 'check-incremental-compatibility';
@@ -45,6 +40,10 @@ export class CheckIncrementalCompatibilityTool {
45
40
  };
46
41
  description = 'Check if a project is compatible with incremental build validation. Detects blockers like circular dependencies, old Angular versions, custom build configs, and complex monorepos. Returns compatibility status, issues, recommendations, and estimated speedup. ' +
47
42
  'summary is a short text with the verdict, the recommendation and the detected issues.';
43
+ /**
44
+ * JSON Schema of the tool arguments.
45
+ * @hidden
46
+ */
48
47
  inputSchema = {
49
48
  type: 'object',
50
49
  additionalProperties: false,
@@ -71,6 +70,10 @@ export class CheckIncrementalCompatibilityTool {
71
70
  },
72
71
  required: ['projectPath'],
73
72
  };
73
+ /**
74
+ * JSON Schema of the tool result (`structuredContent`).
75
+ * @hidden
76
+ */
74
77
  outputSchema = {
75
78
  type: 'object',
76
79
  properties: {
@@ -1,31 +1,9 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Collect Feedback Tool
3
- *
4
- * MCP tool for manually collecting transformation feedback for AI learning.
5
- * Stores feedback in the user's project (`<projectRoot>/.claude-feedback`).
6
- *
7
- * Record kinds:
8
- * - 'transformation' (default): outcome of a transform-code run
9
- * - 'analysis': a read-only tool result (find-usages, search-codebase, ...)
10
- * that had to be corrected via grep, build output, a script or manual reading
11
- *
12
- * Privacy-First:
13
- * - All file paths anonymized with SHA-256 hashing
14
- * - No code snippets stored, only metadata
15
- * - Privacy audit enforced before storage
16
- *
17
- * Storage Strategy:
18
- * - Always the project; a platform store only with ANGULAR_MODERNIZER_PLATFORM_ROOT
19
- * - 'both' (default): project, plus the platform store when configured
20
- * - 'project' / 'platform' ('platform' needs the variable)
21
- * - Graceful partial failure handling
22
- */
23
1
  import { type MCPTool, type ToolAnnotations } from '../types.js';
24
2
  import type { AnalysisFeedbackCategory, ErrorType, TransformFeedbackValidationIssue, Learning, ValidationIssue } from '@angular-modernizer/core';
25
3
  /**
26
4
  * Output from collect-feedback tool
27
5
  */
28
- interface CollectFeedbackOutput {
6
+ export interface CollectFeedbackOutput {
29
7
  /** Unique feedback identifier (UUID) */
30
8
  feedbackId: string;
31
9
  /** Session identifier (UUID) */
@@ -49,7 +27,8 @@ interface CollectFeedbackOutput {
49
27
  /**
50
28
  * Output from collect-feedback tool for kind 'analysis'
51
29
  */
52
- interface CollectAnalysisFeedbackOutput {
30
+ export interface CollectAnalysisFeedbackOutput {
31
+ /** Record kind; present only for analysis feedback. */
53
32
  kind: 'analysis';
54
33
  /** Session identifier (UUID) */
55
34
  sessionId: string;
@@ -59,21 +38,48 @@ interface CollectAnalysisFeedbackOutput {
59
38
  storageLocations: string[];
60
39
  /** Per-record result, in input order */
61
40
  records: {
41
+ /** Unique feedback identifier (UUID). */
62
42
  feedbackId: string;
43
+ /** Read-only tool whose result the record corrects. */
63
44
  tool: string;
45
+ /** Whether the record was stored. */
64
46
  stored: boolean;
47
+ /** Completeness score of the record (0-100). */
65
48
  completenessScore: number;
49
+ /** Validation issues of the record. */
66
50
  issues: TransformFeedbackValidationIssue[];
67
51
  }[];
68
52
  }
69
53
  /**
70
- * Collect transformation feedback for AI learning
54
+ * MCP tool for collecting transformation feedback for AI learning. Stores
55
+ * feedback in the user's project (`<projectRoot>/.claude-feedback`).
56
+ *
57
+ * @remarks
58
+ * Record kinds:
59
+ * - `transformation` (default): outcome of a transform-code run
60
+ * - `analysis`: a read-only tool result (find-usages, search-codebase, ...)
61
+ * that had to be corrected via grep, build output, a script or manual reading
62
+ *
63
+ * Privacy:
64
+ * - All file paths anonymized with SHA-256 hashing
65
+ * - No code snippets stored, only metadata
66
+ * - Privacy audit enforced before storage
67
+ *
68
+ * Storage:
69
+ * - Always the project; a platform store only with `ANGULAR_MODERNIZER_PLATFORM_ROOT`
70
+ * - `both` (default): the project, plus the platform store when configured
71
+ * - `project` / `platform` (`platform` needs the variable)
72
+ * - Handles partial failures across the locations
71
73
  */
72
74
  export declare class CollectFeedbackTool implements MCPTool {
73
75
  name: string;
74
76
  title: string;
75
77
  annotations: ToolAnnotations;
76
78
  description: string;
79
+ /**
80
+ * JSON Schema of the tool arguments.
81
+ * @hidden
82
+ */
77
83
  inputSchema: {
78
84
  readonly type: "object";
79
85
  readonly additionalProperties: false;
@@ -278,6 +284,10 @@ export declare class CollectFeedbackTool implements MCPTool {
278
284
  };
279
285
  readonly required: readonly [];
280
286
  };
287
+ /**
288
+ * JSON Schema of the tool result (`structuredContent`).
289
+ * @hidden
290
+ */
281
291
  outputSchema: {
282
292
  type: string;
283
293
  properties: {
@@ -408,10 +418,15 @@ export declare class CollectFeedbackTool implements MCPTool {
408
418
  };
409
419
  required: string[];
410
420
  };
421
+ /**
422
+ * Validates, anonymizes and stores the feedback.
423
+ * @param args - Tool arguments validated against the input schema
424
+ * @returns The stored feedback result with a text summary
425
+ */
411
426
  execute(args: Record<string, unknown>): Promise<(CollectFeedbackOutput | CollectAnalysisFeedbackOutput) & {
427
+ /** Short text: what was stored and the validation issues. */
412
428
  summary: string;
413
429
  }>;
414
430
  private collect;
415
431
  }
416
- export {};
417
432
  //# sourceMappingURL=collect-feedback.d.ts.map