@angular-modernizer/adapter-mcp 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -235
- package/dist/cli.js +77 -27
- package/dist/index.d.ts +11 -3
- package/dist/index.js +10 -2
- package/dist/mcp-watcher.d.ts +6 -1
- package/dist/mcp-watcher.js +14 -10
- package/dist/server/limited-stdio-transport.d.ts +68 -0
- package/dist/server/limited-stdio-transport.js +115 -0
- package/dist/server/mcp-server.d.ts +41 -12
- package/dist/server/mcp-server.js +113 -94
- package/dist/server/package-version.d.ts +16 -0
- package/dist/server/package-version.js +37 -0
- package/dist/server/sdk-server.d.ts +70 -0
- package/dist/server/sdk-server.js +113 -0
- package/dist/server/stdio-guard.d.ts +20 -0
- package/dist/server/stdio-guard.js +48 -0
- package/dist/server/tool-registry.d.ts +3 -2
- package/dist/server/tool-registry.js +5 -5
- package/dist/tools/analyze-build-impact.d.ts +346 -14
- package/dist/tools/analyze-build-impact.js +315 -31
- package/dist/tools/analyze-core-to-shared.d.ts +134 -4
- package/dist/tools/analyze-core-to-shared.js +113 -9
- package/dist/tools/analyze-parser-performance.d.ts +200 -7
- package/dist/tools/analyze-parser-performance.js +108 -47
- package/dist/tools/analyze-project.d.ts +267 -5
- package/dist/tools/analyze-project.js +196 -8
- package/dist/tools/check-incremental-compatibility.d.ts +61 -1
- package/dist/tools/check-incremental-compatibility.js +58 -2
- package/dist/tools/collect-feedback.d.ts +199 -10
- package/dist/tools/collect-feedback.js +171 -99
- package/dist/tools/compare-health.d.ts +356 -0
- package/dist/tools/compare-health.js +472 -0
- package/dist/tools/extract-libraries.d.ts +156 -4
- package/dist/tools/extract-libraries.js +115 -10
- package/dist/tools/find-angular-symbol.d.ts +98 -9
- package/dist/tools/find-angular-symbol.js +104 -12
- package/dist/tools/find-component-hosts.d.ts +684 -0
- package/dist/tools/find-component-hosts.js +441 -0
- package/dist/tools/find-usages.d.ts +99 -4
- package/dist/tools/find-usages.js +131 -11
- package/dist/tools/get-bootstrap-execution.d.ts +258 -0
- package/dist/tools/get-bootstrap-execution.js +324 -0
- package/dist/tools/get-call-graph.d.ts +139 -4
- package/dist/tools/get-call-graph.js +123 -13
- package/dist/tools/get-operation-progress-tool.d.ts +114 -2
- package/dist/tools/get-operation-progress-tool.js +114 -7
- package/dist/tools/get-operation-progress.d.ts +1 -1
- package/dist/tools/get-operation-progress.js +5 -5
- package/dist/tools/helpers/analysis-output.d.ts +177 -0
- package/dist/tools/helpers/analysis-output.js +165 -0
- package/dist/tools/helpers/build-schemas.d.ts +36 -0
- package/dist/tools/helpers/build-schemas.js +23 -0
- package/dist/tools/helpers/citation-file-source.d.ts +10 -0
- package/dist/tools/helpers/citation-file-source.js +82 -0
- package/dist/tools/helpers/compact-output.d.ts +61 -0
- package/dist/tools/helpers/compact-output.js +83 -0
- package/dist/tools/helpers/finding-window.d.ts +43 -0
- package/dist/tools/helpers/finding-window.js +64 -0
- package/dist/tools/helpers/health-delta.d.ts +86 -0
- package/dist/tools/helpers/health-delta.js +239 -0
- package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
- package/dist/tools/helpers/investigation-schemas.js +48 -0
- package/dist/tools/helpers/library-imports.d.ts +57 -0
- package/dist/tools/helpers/library-imports.js +151 -0
- package/dist/tools/helpers/load-source-files.d.ts +30 -0
- package/dist/tools/helpers/load-source-files.js +34 -0
- package/dist/tools/helpers/output-contract.d.ts +32 -0
- package/dist/tools/helpers/output-contract.js +32 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
- package/dist/tools/helpers/platform-root-resolver.js +75 -48
- package/dist/tools/helpers/process-output.d.ts +19 -0
- package/dist/tools/helpers/process-output.js +31 -0
- package/dist/tools/helpers/project-cache.d.ts +184 -0
- package/dist/tools/helpers/project-cache.js +331 -0
- package/dist/tools/helpers/project-decorators.d.ts +14 -0
- package/dist/tools/helpers/project-decorators.js +22 -0
- package/dist/tools/helpers/rule-matcher.js +5 -0
- package/dist/tools/helpers/rule-runner.d.ts +72 -0
- package/dist/tools/helpers/rule-runner.js +131 -0
- package/dist/tools/helpers/scan-cache.d.ts +22 -0
- package/dist/tools/helpers/scan-cache.js +34 -0
- package/dist/tools/helpers/scan-plan.d.ts +48 -0
- package/dist/tools/helpers/scan-plan.js +166 -0
- package/dist/tools/helpers/scope-paths.d.ts +17 -0
- package/dist/tools/helpers/scope-paths.js +32 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
- package/dist/tools/helpers/stack-frame-file-index.js +71 -0
- package/dist/tools/helpers/tool-context.d.ts +60 -0
- package/dist/tools/helpers/tool-context.js +82 -0
- package/dist/tools/helpers/transform-safety.d.ts +40 -0
- package/dist/tools/helpers/transform-safety.js +87 -0
- package/dist/tools/helpers/validation-output.d.ts +53 -0
- package/dist/tools/helpers/validation-output.js +48 -0
- package/dist/tools/inspect-form-group.d.ts +324 -0
- package/dist/tools/inspect-form-group.js +279 -0
- package/dist/tools/inspect-i18n.d.ts +466 -0
- package/dist/tools/inspect-i18n.js +400 -0
- package/dist/tools/inspect-template.d.ts +320 -0
- package/dist/tools/inspect-template.js +324 -0
- package/dist/tools/learn-patterns.d.ts +122 -1
- package/dist/tools/learn-patterns.js +97 -2
- package/dist/tools/list-imports.d.ts +128 -11
- package/dist/tools/list-imports.js +128 -8
- package/dist/tools/orchestrate-migration.d.ts +129 -5
- package/dist/tools/orchestrate-migration.js +166 -12
- package/dist/tools/parse-stack-trace.d.ts +59 -2
- package/dist/tools/parse-stack-trace.js +52 -4
- package/dist/tools/plan-migration.d.ts +418 -1
- package/dist/tools/plan-migration.js +355 -8
- package/dist/tools/resolve-type.d.ts +42 -1
- package/dist/tools/resolve-type.js +37 -4
- package/dist/tools/review-feedback.d.ts +206 -11
- package/dist/tools/review-feedback.js +132 -51
- package/dist/tools/rollback-changes.d.ts +79 -2
- package/dist/tools/rollback-changes.js +66 -14
- package/dist/tools/run-angular-cli.d.ts +45 -2
- package/dist/tools/run-angular-cli.js +67 -7
- package/dist/tools/run-build.d.ts +114 -2
- package/dist/tools/run-build.js +117 -8
- package/dist/tools/run-schematic.d.ts +70 -2
- package/dist/tools/run-schematic.js +104 -10
- package/dist/tools/scan-all.d.ts +24 -16
- package/dist/tools/scan-all.js +145 -137
- package/dist/tools/scan-angular.d.ts +20 -11
- package/dist/tools/scan-angular.js +52 -24
- package/dist/tools/scan-architecture.d.ts +42 -14
- package/dist/tools/scan-architecture.js +206 -163
- package/dist/tools/scan-solid.d.ts +20 -11
- package/dist/tools/scan-solid.js +52 -24
- package/dist/tools/search-codebase.d.ts +85 -1
- package/dist/tools/search-codebase.js +61 -4
- package/dist/tools/server-status.d.ts +370 -0
- package/dist/tools/server-status.js +369 -0
- package/dist/tools/suggest-improvements.d.ts +97 -5
- package/dist/tools/suggest-improvements.js +80 -44
- package/dist/tools/trace-output-flow.d.ts +791 -0
- package/dist/tools/trace-output-flow.js +668 -0
- package/dist/tools/transform-code-batch.d.ts +3 -0
- package/dist/tools/transform-code-batch.js +10 -5
- package/dist/tools/transform-code.d.ts +335 -12
- package/dist/tools/transform-code.js +649 -608
- package/dist/tools/validate-before-transform.d.ts +116 -2
- package/dist/tools/validate-before-transform.js +55 -2
- package/dist/tools/validate-project-compatibility.d.ts +64 -2
- package/dist/tools/validate-project-compatibility.js +67 -4
- package/dist/tools/validate-transformation.d.ts +220 -2
- package/dist/tools/validate-transformation.js +113 -15
- package/dist/tools/verify-citations.d.ts +181 -0
- package/dist/tools/verify-citations.js +218 -0
- package/dist/types.d.ts +45 -1
- package/dist/utils/format-tool-response.d.ts +22 -59
- package/dist/utils/format-tool-response.js +25 -134
- package/package.json +30 -13
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/project-analyzer.d.ts.map +0 -1
- package/dist/core/project-analyzer.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp-watcher.d.ts.map +0 -1
- package/dist/mcp-watcher.js.map +0 -1
- package/dist/server/json-rpc-handler.d.ts +0 -57
- package/dist/server/json-rpc-handler.d.ts.map +0 -1
- package/dist/server/json-rpc-handler.js +0 -222
- package/dist/server/json-rpc-handler.js.map +0 -1
- package/dist/server/mcp-server.d.ts.map +0 -1
- package/dist/server/mcp-server.js.map +0 -1
- package/dist/server/tool-registry.d.ts.map +0 -1
- package/dist/server/tool-registry.js.map +0 -1
- package/dist/streaming/progress-store.d.ts.map +0 -1
- package/dist/streaming/progress-store.js.map +0 -1
- package/dist/tools/analyze-build-impact.d.ts.map +0 -1
- package/dist/tools/analyze-build-impact.js.map +0 -1
- package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
- package/dist/tools/analyze-core-to-shared.js.map +0 -1
- package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
- package/dist/tools/analyze-parser-performance.js.map +0 -1
- package/dist/tools/analyze-project.d.ts.map +0 -1
- package/dist/tools/analyze-project.js.map +0 -1
- package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
- package/dist/tools/check-incremental-compatibility.js.map +0 -1
- package/dist/tools/collect-feedback.d.ts.map +0 -1
- package/dist/tools/collect-feedback.js.map +0 -1
- package/dist/tools/extract-libraries.d.ts.map +0 -1
- package/dist/tools/extract-libraries.js.map +0 -1
- package/dist/tools/find-angular-symbol.d.ts.map +0 -1
- package/dist/tools/find-angular-symbol.js.map +0 -1
- package/dist/tools/find-usages.d.ts.map +0 -1
- package/dist/tools/find-usages.js.map +0 -1
- package/dist/tools/get-call-graph.d.ts.map +0 -1
- package/dist/tools/get-call-graph.js.map +0 -1
- package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
- package/dist/tools/get-operation-progress-tool.js.map +0 -1
- package/dist/tools/get-operation-progress.d.ts.map +0 -1
- package/dist/tools/get-operation-progress.js.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
- package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
- package/dist/tools/helpers/find-ts-config.js.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
- package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
- package/dist/tools/helpers/rule-matcher.js.map +0 -1
- package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
- package/dist/tools/helpers/suggestion-generator.js.map +0 -1
- package/dist/tools/learn-patterns.d.ts.map +0 -1
- package/dist/tools/learn-patterns.js.map +0 -1
- package/dist/tools/list-imports.d.ts.map +0 -1
- package/dist/tools/list-imports.js.map +0 -1
- package/dist/tools/orchestrate-migration.d.ts.map +0 -1
- package/dist/tools/orchestrate-migration.js.map +0 -1
- package/dist/tools/parse-stack-trace.d.ts.map +0 -1
- package/dist/tools/parse-stack-trace.js.map +0 -1
- package/dist/tools/plan-migration.d.ts.map +0 -1
- package/dist/tools/plan-migration.js.map +0 -1
- package/dist/tools/resolve-type.d.ts.map +0 -1
- package/dist/tools/resolve-type.js.map +0 -1
- package/dist/tools/review-feedback.d.ts.map +0 -1
- package/dist/tools/review-feedback.js.map +0 -1
- package/dist/tools/rollback-changes.d.ts.map +0 -1
- package/dist/tools/rollback-changes.js.map +0 -1
- package/dist/tools/run-angular-cli.d.ts.map +0 -1
- package/dist/tools/run-angular-cli.js.map +0 -1
- package/dist/tools/run-build.d.ts.map +0 -1
- package/dist/tools/run-build.js.map +0 -1
- package/dist/tools/run-schematic.d.ts.map +0 -1
- package/dist/tools/run-schematic.js.map +0 -1
- package/dist/tools/scan-all.d.ts.map +0 -1
- package/dist/tools/scan-all.js.map +0 -1
- package/dist/tools/scan-angular.d.ts.map +0 -1
- package/dist/tools/scan-angular.js.map +0 -1
- package/dist/tools/scan-architecture.d.ts.map +0 -1
- package/dist/tools/scan-architecture.js.map +0 -1
- package/dist/tools/scan-solid.d.ts.map +0 -1
- package/dist/tools/scan-solid.js.map +0 -1
- package/dist/tools/search-codebase.d.ts.map +0 -1
- package/dist/tools/search-codebase.js.map +0 -1
- package/dist/tools/shared/scan-types.d.ts.map +0 -1
- package/dist/tools/shared/scan-types.js.map +0 -1
- package/dist/tools/suggest-improvements.d.ts.map +0 -1
- package/dist/tools/suggest-improvements.js.map +0 -1
- package/dist/tools/transform-code-batch.d.ts.map +0 -1
- package/dist/tools/transform-code-batch.js.map +0 -1
- package/dist/tools/transform-code.d.ts.map +0 -1
- package/dist/tools/transform-code.js.map +0 -1
- package/dist/tools/validate-before-transform.d.ts.map +0 -1
- package/dist/tools/validate-before-transform.js.map +0 -1
- package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
- package/dist/tools/validate-project-compatibility.js.map +0 -1
- package/dist/tools/validate-transformation.d.ts.map +0 -1
- package/dist/tools/validate-transformation.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/format-tool-response.d.ts.map +0 -1
- package/dist/utils/format-tool-response.js.map +0 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Enhancement: Self-learning with style-aware pattern discovery
|
|
9
9
|
*/
|
|
10
|
-
import { type MCPTool } from '../types.js';
|
|
10
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
11
11
|
/**
|
|
12
12
|
* Pattern discovery result.
|
|
13
13
|
*/
|
|
@@ -131,15 +131,22 @@ interface LearnPatternsResult {
|
|
|
131
131
|
alignedWithStyle: boolean;
|
|
132
132
|
rationale: string;
|
|
133
133
|
}[];
|
|
134
|
+
/**
|
|
135
|
+
* Human-readable summary for LLM consumption.
|
|
136
|
+
*/
|
|
137
|
+
summary: string;
|
|
134
138
|
}
|
|
135
139
|
/**
|
|
136
140
|
* MCP tool for learning patterns from codebases.
|
|
137
141
|
*/
|
|
138
142
|
export declare class LearnPatternsTool implements MCPTool {
|
|
139
143
|
name: string;
|
|
144
|
+
title: string;
|
|
145
|
+
annotations: ToolAnnotations;
|
|
140
146
|
description: string;
|
|
141
147
|
inputSchema: {
|
|
142
148
|
type: string;
|
|
149
|
+
additionalProperties: boolean;
|
|
143
150
|
properties: {
|
|
144
151
|
targetPath: {
|
|
145
152
|
type: string;
|
|
@@ -269,6 +276,120 @@ export declare class LearnPatternsTool implements MCPTool {
|
|
|
269
276
|
};
|
|
270
277
|
required: string[];
|
|
271
278
|
};
|
|
279
|
+
outputSchema: {
|
|
280
|
+
type: string;
|
|
281
|
+
properties: {
|
|
282
|
+
patterns: {
|
|
283
|
+
type: string;
|
|
284
|
+
items: {
|
|
285
|
+
type: string;
|
|
286
|
+
properties: {
|
|
287
|
+
id: {
|
|
288
|
+
type: string;
|
|
289
|
+
};
|
|
290
|
+
name: {
|
|
291
|
+
type: string;
|
|
292
|
+
};
|
|
293
|
+
category: {
|
|
294
|
+
type: string;
|
|
295
|
+
};
|
|
296
|
+
description: {
|
|
297
|
+
type: string;
|
|
298
|
+
};
|
|
299
|
+
occurrences: {
|
|
300
|
+
type: string;
|
|
301
|
+
};
|
|
302
|
+
complexity: {
|
|
303
|
+
type: string;
|
|
304
|
+
};
|
|
305
|
+
examples: {
|
|
306
|
+
type: string;
|
|
307
|
+
items: {
|
|
308
|
+
type: string;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
suggestedRule: {
|
|
312
|
+
type: string;
|
|
313
|
+
};
|
|
314
|
+
confidence: {
|
|
315
|
+
type: string;
|
|
316
|
+
};
|
|
317
|
+
confidenceExplanation: {
|
|
318
|
+
type: string;
|
|
319
|
+
};
|
|
320
|
+
alignsWithStyle: {
|
|
321
|
+
type: string;
|
|
322
|
+
};
|
|
323
|
+
styleAlignment: {
|
|
324
|
+
type: string;
|
|
325
|
+
};
|
|
326
|
+
dominancePercentage: {
|
|
327
|
+
type: string;
|
|
328
|
+
};
|
|
329
|
+
trending: {
|
|
330
|
+
type: string;
|
|
331
|
+
};
|
|
332
|
+
scanCount: {
|
|
333
|
+
type: string;
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
required: string[];
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
statistics: {
|
|
340
|
+
type: string;
|
|
341
|
+
properties: {
|
|
342
|
+
totalPatternsFound: {
|
|
343
|
+
type: string;
|
|
344
|
+
};
|
|
345
|
+
byCategory: {
|
|
346
|
+
readonly type: "object";
|
|
347
|
+
readonly additionalProperties: {
|
|
348
|
+
readonly type: "integer";
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
byComplexity: {
|
|
352
|
+
readonly type: "object";
|
|
353
|
+
readonly additionalProperties: {
|
|
354
|
+
readonly type: "integer";
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
filesAnalyzed: {
|
|
358
|
+
type: string;
|
|
359
|
+
};
|
|
360
|
+
duration: {
|
|
361
|
+
type: string;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
required: string[];
|
|
365
|
+
};
|
|
366
|
+
artifacts: {
|
|
367
|
+
type: string;
|
|
368
|
+
};
|
|
369
|
+
validation: {
|
|
370
|
+
type: string;
|
|
371
|
+
};
|
|
372
|
+
styleProfile: {
|
|
373
|
+
type: string;
|
|
374
|
+
};
|
|
375
|
+
learningEvolution: {
|
|
376
|
+
type: string;
|
|
377
|
+
};
|
|
378
|
+
confidenceAnalysis: {
|
|
379
|
+
type: string;
|
|
380
|
+
};
|
|
381
|
+
generatedRules: {
|
|
382
|
+
type: string;
|
|
383
|
+
items: {
|
|
384
|
+
type: string;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
summary: {
|
|
388
|
+
type: string;
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
required: string[];
|
|
392
|
+
};
|
|
272
393
|
execute(args: Record<string, unknown>): Promise<LearnPatternsResult>;
|
|
273
394
|
/**
|
|
274
395
|
* Discover patterns from the project.
|
|
@@ -11,15 +11,62 @@ import { findTsConfig } from './helpers/find-ts-config.js';
|
|
|
11
11
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
12
12
|
import { writeFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
13
13
|
import { resolve, dirname } from 'node:path';
|
|
14
|
+
import { countList } from './helpers/analysis-output.js';
|
|
15
|
+
import { COUNT_OBJECT } from './helpers/investigation-schemas.js';
|
|
14
16
|
import { PatternKnowledgeBase, StyleConventionDetector, ContextAwareScorer, ContextAwareRuleGenerator, RealFileSystemAdapter, } from '@angular-modernizer/core';
|
|
17
|
+
/** Categories and patterns named in the summary. */
|
|
18
|
+
const SUMMARY_PATTERNS = 5;
|
|
19
|
+
/**
|
|
20
|
+
* Text summary: totals per category and complexity, the most frequent
|
|
21
|
+
* patterns, the style profile and what was written.
|
|
22
|
+
*/
|
|
23
|
+
function describePatterns(result) {
|
|
24
|
+
const { statistics } = result;
|
|
25
|
+
const categories = countList(statistics.byCategory, SUMMARY_PATTERNS);
|
|
26
|
+
const complexity = countList(statistics.byComplexity, SUMMARY_PATTERNS);
|
|
27
|
+
const lines = [
|
|
28
|
+
`${statistics.totalPatternsFound} pattern(s) in ${statistics.filesAnalyzed} analyzed file(s)` +
|
|
29
|
+
(categories === undefined ? '.' : ` (category ${categories}; complexity ${complexity ?? 'none'}).`),
|
|
30
|
+
];
|
|
31
|
+
const top = [...result.patterns]
|
|
32
|
+
.sort((a, b) => b.occurrences - a.occurrences || a.name.localeCompare(b.name))
|
|
33
|
+
.slice(0, SUMMARY_PATTERNS);
|
|
34
|
+
for (const p of top) {
|
|
35
|
+
const confidence = p.confidence === undefined ? '' : `, confidence ${p.confidence.toFixed(2)}`;
|
|
36
|
+
lines.push(`- ${p.name} (${p.category}): ${p.occurrences} occurrence(s), ${p.complexity}${confidence}`);
|
|
37
|
+
}
|
|
38
|
+
const style = result.styleProfile;
|
|
39
|
+
if (style !== undefined) {
|
|
40
|
+
lines.push(`Style: DI ${style.diPreference}, RxJS ${style.rxjsPreference}, change detection ` +
|
|
41
|
+
`${style.changeDetectionPreference}, modules ${style.moduleStyle}, state ${style.stateManagement}, ` +
|
|
42
|
+
`architecture ${style.architectureStyle} (confidence ${style.confidence.toFixed(2)}).`);
|
|
43
|
+
}
|
|
44
|
+
if (result.generatedRules !== undefined) {
|
|
45
|
+
lines.push(`${result.generatedRules.length} rule(s) generated.`);
|
|
46
|
+
}
|
|
47
|
+
const fixtures = result.artifacts?.fixtures?.length ?? 0;
|
|
48
|
+
const rules = result.artifacts?.rules?.length ?? 0;
|
|
49
|
+
if (fixtures + rules > 0) {
|
|
50
|
+
lines.push(`Written: ${fixtures} fixture file(s), ${rules} rule file(s).`);
|
|
51
|
+
}
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
}
|
|
15
54
|
/**
|
|
16
55
|
* MCP tool for learning patterns from codebases.
|
|
17
56
|
*/
|
|
18
57
|
export class LearnPatternsTool {
|
|
19
58
|
name = 'learn-patterns';
|
|
20
|
-
|
|
59
|
+
title = 'Learn Patterns';
|
|
60
|
+
annotations = {
|
|
61
|
+
readOnlyHint: false,
|
|
62
|
+
destructiveHint: false,
|
|
63
|
+
idempotentHint: true,
|
|
64
|
+
openWorldHint: false,
|
|
65
|
+
};
|
|
66
|
+
description = 'Discover and learn patterns from codebases using ML-based pattern recognition with self-learning capabilities. Identifies recurring architectural patterns, anti-patterns, and transformation opportunities while respecting codebase style conventions. summary is a short text of patterns and style profile.';
|
|
21
67
|
inputSchema = {
|
|
22
68
|
type: 'object',
|
|
69
|
+
additionalProperties: false,
|
|
23
70
|
properties: {
|
|
24
71
|
targetPath: {
|
|
25
72
|
type: 'string',
|
|
@@ -157,6 +204,54 @@ export class LearnPatternsTool {
|
|
|
157
204
|
},
|
|
158
205
|
required: ['targetPath'],
|
|
159
206
|
};
|
|
207
|
+
outputSchema = {
|
|
208
|
+
type: 'object',
|
|
209
|
+
properties: {
|
|
210
|
+
patterns: {
|
|
211
|
+
type: 'array',
|
|
212
|
+
items: {
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
id: { type: 'string' },
|
|
216
|
+
name: { type: 'string' },
|
|
217
|
+
category: { type: 'string' },
|
|
218
|
+
description: { type: 'string' },
|
|
219
|
+
occurrences: { type: 'integer' },
|
|
220
|
+
complexity: { type: 'string' },
|
|
221
|
+
examples: { type: 'array', items: { type: 'object' } },
|
|
222
|
+
suggestedRule: { type: 'object' },
|
|
223
|
+
confidence: { type: 'number' },
|
|
224
|
+
confidenceExplanation: { type: 'string' },
|
|
225
|
+
alignsWithStyle: { type: 'boolean' },
|
|
226
|
+
styleAlignment: { type: 'number' },
|
|
227
|
+
dominancePercentage: { type: 'number' },
|
|
228
|
+
trending: { type: 'string' },
|
|
229
|
+
scanCount: { type: 'integer' },
|
|
230
|
+
},
|
|
231
|
+
required: ['id', 'name', 'category', 'occurrences', 'complexity'],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
statistics: {
|
|
235
|
+
type: 'object',
|
|
236
|
+
properties: {
|
|
237
|
+
totalPatternsFound: { type: 'integer' },
|
|
238
|
+
byCategory: COUNT_OBJECT,
|
|
239
|
+
byComplexity: COUNT_OBJECT,
|
|
240
|
+
filesAnalyzed: { type: 'integer' },
|
|
241
|
+
duration: { type: 'number' },
|
|
242
|
+
},
|
|
243
|
+
required: ['totalPatternsFound', 'byCategory', 'byComplexity', 'filesAnalyzed', 'duration'],
|
|
244
|
+
},
|
|
245
|
+
artifacts: { type: 'object' },
|
|
246
|
+
validation: { type: 'object' },
|
|
247
|
+
styleProfile: { type: 'object' },
|
|
248
|
+
learningEvolution: { type: 'object' },
|
|
249
|
+
confidenceAnalysis: { type: 'object' },
|
|
250
|
+
generatedRules: { type: 'array', items: { type: 'object' } },
|
|
251
|
+
summary: { type: 'string' },
|
|
252
|
+
},
|
|
253
|
+
required: ['patterns', 'statistics', 'summary'],
|
|
254
|
+
};
|
|
160
255
|
async execute(args) {
|
|
161
256
|
const params = args;
|
|
162
257
|
const targetPath = params.targetPath;
|
|
@@ -458,7 +553,7 @@ export class LearnPatternsTool {
|
|
|
458
553
|
if (generatedRulesResult) {
|
|
459
554
|
result.generatedRules = generatedRulesResult;
|
|
460
555
|
}
|
|
461
|
-
return result;
|
|
556
|
+
return { ...result, summary: describePatterns(result) };
|
|
462
557
|
}
|
|
463
558
|
/**
|
|
464
559
|
* Discover patterns from the project.
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import { type MCPTool } from '../types.js';
|
|
20
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
21
21
|
import { type ModuleSpecifierKind } from '@angular-modernizer/core';
|
|
22
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
22
23
|
/**
|
|
23
24
|
* A named import / re-export specifier.
|
|
24
25
|
*/
|
|
@@ -57,26 +58,50 @@ interface ListImportsOutput {
|
|
|
57
58
|
file: string;
|
|
58
59
|
projectRoot: string;
|
|
59
60
|
tsConfigPath: string;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
/** Imports in declaration order, cut to `maxResults`; omitted with `summaryOnly`. */
|
|
62
|
+
imports?: ImportEntry[];
|
|
63
|
+
/** `true` when `maxResults` cut the import list. */
|
|
64
|
+
truncated: boolean;
|
|
65
|
+
/** Counts over all imports, independent of `maxResults`. */
|
|
66
|
+
counts: ImportCounts;
|
|
67
|
+
/** Human-readable summary for LLM consumption. */
|
|
68
|
+
summary: string;
|
|
69
|
+
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
70
|
+
warnings?: string[];
|
|
71
|
+
}
|
|
72
|
+
/** Counts over all imports of the file. */
|
|
73
|
+
interface ImportCounts {
|
|
74
|
+
total: number;
|
|
75
|
+
aliased: number;
|
|
76
|
+
relative: number;
|
|
77
|
+
external: number;
|
|
78
|
+
unresolved: number;
|
|
79
|
+
reExports: number;
|
|
80
|
+
typeOnly: number;
|
|
70
81
|
}
|
|
71
82
|
/**
|
|
72
83
|
* MCP tool that lists the resolved imports of a file.
|
|
73
84
|
*/
|
|
74
85
|
export declare class ListImportsTool implements MCPTool {
|
|
86
|
+
private readonly projects;
|
|
75
87
|
readonly name = "list-imports";
|
|
88
|
+
readonly title = "List Imports";
|
|
89
|
+
readonly annotations: ToolAnnotations;
|
|
90
|
+
constructor(projects?: ProjectCache);
|
|
76
91
|
readonly description: string;
|
|
77
92
|
readonly inputSchema: {
|
|
78
93
|
type: string;
|
|
94
|
+
additionalProperties: boolean;
|
|
79
95
|
properties: {
|
|
96
|
+
summaryOnly: {
|
|
97
|
+
readonly type: "boolean";
|
|
98
|
+
readonly description: "Return counts and the text summary only, without the result list. Default: false.";
|
|
99
|
+
readonly default: false;
|
|
100
|
+
};
|
|
101
|
+
maxResults: {
|
|
102
|
+
readonly type: "number";
|
|
103
|
+
readonly description: string;
|
|
104
|
+
};
|
|
80
105
|
file: {
|
|
81
106
|
type: string;
|
|
82
107
|
description: string;
|
|
@@ -93,11 +118,103 @@ export declare class ListImportsTool implements MCPTool {
|
|
|
93
118
|
};
|
|
94
119
|
required: string[];
|
|
95
120
|
};
|
|
121
|
+
readonly outputSchema: {
|
|
122
|
+
type: string;
|
|
123
|
+
properties: {
|
|
124
|
+
warnings: {
|
|
125
|
+
readonly type: "array";
|
|
126
|
+
readonly items: {
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
};
|
|
129
|
+
readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
|
|
130
|
+
};
|
|
131
|
+
file: {
|
|
132
|
+
type: string;
|
|
133
|
+
};
|
|
134
|
+
projectRoot: {
|
|
135
|
+
type: string;
|
|
136
|
+
};
|
|
137
|
+
tsConfigPath: {
|
|
138
|
+
type: string;
|
|
139
|
+
};
|
|
140
|
+
imports: {
|
|
141
|
+
type: string;
|
|
142
|
+
items: {
|
|
143
|
+
type: string;
|
|
144
|
+
properties: {
|
|
145
|
+
moduleSpecifier: {
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
kind: {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
151
|
+
resolvedPath: {
|
|
152
|
+
type: string[];
|
|
153
|
+
};
|
|
154
|
+
namedImports: {
|
|
155
|
+
type: string;
|
|
156
|
+
items: {
|
|
157
|
+
type: string;
|
|
158
|
+
properties: {
|
|
159
|
+
name: {
|
|
160
|
+
type: string;
|
|
161
|
+
};
|
|
162
|
+
alias: {
|
|
163
|
+
type: string[];
|
|
164
|
+
};
|
|
165
|
+
typeOnly: {
|
|
166
|
+
type: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
required: string[];
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
defaultImport: {
|
|
173
|
+
type: string[];
|
|
174
|
+
};
|
|
175
|
+
namespaceImport: {
|
|
176
|
+
type: string[];
|
|
177
|
+
};
|
|
178
|
+
typeOnly: {
|
|
179
|
+
type: string;
|
|
180
|
+
};
|
|
181
|
+
isReExport: {
|
|
182
|
+
type: string;
|
|
183
|
+
};
|
|
184
|
+
isStarReExport: {
|
|
185
|
+
type: string;
|
|
186
|
+
};
|
|
187
|
+
line: {
|
|
188
|
+
type: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
required: string[];
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
truncated: {
|
|
195
|
+
type: string;
|
|
196
|
+
};
|
|
197
|
+
counts: {
|
|
198
|
+
type: string;
|
|
199
|
+
properties: {
|
|
200
|
+
[k: string]: {
|
|
201
|
+
type: string;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
required: ("total" | "external" | "unresolved" | "aliased" | "relative" | "reExports" | "typeOnly")[];
|
|
205
|
+
};
|
|
206
|
+
summary: {
|
|
207
|
+
type: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
required: string[];
|
|
211
|
+
};
|
|
96
212
|
execute(args: Record<string, unknown>): Promise<ListImportsOutput>;
|
|
97
213
|
private resolveFilePath;
|
|
98
214
|
private findProjectRoot;
|
|
99
215
|
private toEntry;
|
|
100
216
|
private buildSummary;
|
|
217
|
+
private countImports;
|
|
101
218
|
}
|
|
102
219
|
export {};
|
|
103
220
|
//# sourceMappingURL=list-imports.d.ts.map
|
|
@@ -22,17 +22,44 @@ import { classifyModuleSpecifier, collectModuleEdges, } from '@angular-modernize
|
|
|
22
22
|
import { existsSync } from 'node:fs';
|
|
23
23
|
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
24
24
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
25
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
26
|
+
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
27
|
+
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
28
|
+
/** Unresolved specifiers named in the summary. */
|
|
29
|
+
const SUMMARY_UNRESOLVED = 10;
|
|
30
|
+
const COUNT_KEYS = [
|
|
31
|
+
'total',
|
|
32
|
+
'aliased',
|
|
33
|
+
'relative',
|
|
34
|
+
'external',
|
|
35
|
+
'unresolved',
|
|
36
|
+
'reExports',
|
|
37
|
+
'typeOnly',
|
|
38
|
+
];
|
|
25
39
|
/**
|
|
26
40
|
* MCP tool that lists the resolved imports of a file.
|
|
27
41
|
*/
|
|
28
42
|
export class ListImportsTool {
|
|
43
|
+
projects;
|
|
29
44
|
name = 'list-imports';
|
|
45
|
+
title = 'List Imports';
|
|
46
|
+
annotations = {
|
|
47
|
+
readOnlyHint: true,
|
|
48
|
+
destructiveHint: false,
|
|
49
|
+
idempotentHint: true,
|
|
50
|
+
openWorldHint: false,
|
|
51
|
+
};
|
|
52
|
+
constructor(projects = new ProjectCache()) {
|
|
53
|
+
this.projects = projects;
|
|
54
|
+
}
|
|
30
55
|
description = 'List the imports (and export-from re-exports) of a file with resolved targets. ' +
|
|
31
56
|
'For each import: moduleSpecifier, kind (aliased | relative | external), ' +
|
|
32
57
|
'project-relative resolvedPath (tsconfig paths aware), named/default/namespace imports, ' +
|
|
33
|
-
'type-only flags and whether it is a re-export. Use instead of grepping import lines.'
|
|
58
|
+
'type-only flags and whether it is a re-export. Use instead of grepping import lines. ' +
|
|
59
|
+
'counts always cover all imports; summaryOnly returns only the counts and the summary.';
|
|
34
60
|
inputSchema = {
|
|
35
61
|
type: 'object',
|
|
62
|
+
additionalProperties: false,
|
|
36
63
|
properties: {
|
|
37
64
|
file: {
|
|
38
65
|
type: 'string',
|
|
@@ -47,14 +74,74 @@ export class ListImportsTool {
|
|
|
47
74
|
description: 'Include `export ... from` declarations. Default: true.',
|
|
48
75
|
default: true,
|
|
49
76
|
},
|
|
77
|
+
...COMPACT_OUTPUT_SCHEMA,
|
|
50
78
|
},
|
|
51
79
|
required: ['file'],
|
|
52
80
|
};
|
|
81
|
+
outputSchema = {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
file: { type: 'string' },
|
|
85
|
+
projectRoot: { type: 'string' },
|
|
86
|
+
tsConfigPath: { type: 'string' },
|
|
87
|
+
imports: {
|
|
88
|
+
type: 'array',
|
|
89
|
+
items: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
moduleSpecifier: { type: 'string' },
|
|
93
|
+
kind: { type: 'string' },
|
|
94
|
+
resolvedPath: { type: ['string', 'null'] },
|
|
95
|
+
namedImports: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
items: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
name: { type: 'string' },
|
|
101
|
+
alias: { type: ['string', 'null'] },
|
|
102
|
+
typeOnly: { type: 'boolean' },
|
|
103
|
+
},
|
|
104
|
+
required: ['name', 'alias', 'typeOnly'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
defaultImport: { type: ['string', 'null'] },
|
|
108
|
+
namespaceImport: { type: ['string', 'null'] },
|
|
109
|
+
typeOnly: { type: 'boolean' },
|
|
110
|
+
isReExport: { type: 'boolean' },
|
|
111
|
+
isStarReExport: { type: 'boolean' },
|
|
112
|
+
line: { type: 'integer' },
|
|
113
|
+
},
|
|
114
|
+
required: [
|
|
115
|
+
'moduleSpecifier',
|
|
116
|
+
'kind',
|
|
117
|
+
'resolvedPath',
|
|
118
|
+
'namedImports',
|
|
119
|
+
'defaultImport',
|
|
120
|
+
'namespaceImport',
|
|
121
|
+
'typeOnly',
|
|
122
|
+
'isReExport',
|
|
123
|
+
'isStarReExport',
|
|
124
|
+
'line',
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
truncated: { type: 'boolean' },
|
|
129
|
+
counts: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: Object.fromEntries(COUNT_KEYS.map((k) => [k, { type: 'integer' }])),
|
|
132
|
+
required: [...COUNT_KEYS],
|
|
133
|
+
},
|
|
134
|
+
summary: { type: 'string' },
|
|
135
|
+
...WARNINGS_OUTPUT_SCHEMA,
|
|
136
|
+
},
|
|
137
|
+
required: ['file', 'projectRoot', 'tsConfigPath', 'truncated', 'counts', 'summary'],
|
|
138
|
+
};
|
|
53
139
|
async execute(args) {
|
|
54
140
|
const params = args;
|
|
55
141
|
if (!params.file || typeof params.file !== 'string') {
|
|
56
142
|
throw new Error('file is required');
|
|
57
143
|
}
|
|
144
|
+
const compact = parseCompactOptions(args);
|
|
58
145
|
if (params.projectRoot !== undefined && !existsSync(params.projectRoot)) {
|
|
59
146
|
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
60
147
|
}
|
|
@@ -69,17 +156,30 @@ export class ListImportsTool {
|
|
|
69
156
|
if (!projectRoot || !tsConfigPath) {
|
|
70
157
|
throw new Error(`tsconfig.json not found in projectRoot: ${projectRoot ?? dirname(filePath)}`);
|
|
71
158
|
}
|
|
72
|
-
|
|
73
|
-
|
|
159
|
+
// A file outside the program (a spec excluded by the tsconfig, say) gets
|
|
160
|
+
// its own Project: the cached one must not grow.
|
|
161
|
+
const sourceFile = this.projects.get(tsConfigPath).getSourceFile(filePath) ??
|
|
162
|
+
new Project({ tsConfigFilePath: tsConfigPath }).addSourceFileAtPath(filePath);
|
|
74
163
|
const includeReExports = params.includeReExports !== false;
|
|
75
164
|
const imports = collectModuleEdges(sourceFile, includeReExports).map((edge) => this.toEntry(sourceFile, edge, projectRoot));
|
|
76
|
-
|
|
165
|
+
const counts = this.countImports(imports);
|
|
166
|
+
const warnings = this.projects.warnings(tsConfigPath);
|
|
167
|
+
const label = relative(projectRoot, filePath) || filePath;
|
|
168
|
+
if (compact.summaryOnly) {
|
|
169
|
+
const summary = this.buildSummary(label, imports, counts, imports.length);
|
|
170
|
+
return withWarnings({ file: filePath, projectRoot, tsConfigPath, truncated: false, counts, summary }, warnings);
|
|
171
|
+
}
|
|
172
|
+
const shown = limitList(imports, compact.maxResults);
|
|
173
|
+
const summary = this.buildSummary(label, imports, counts, shown.items.length);
|
|
174
|
+
return withWarnings({
|
|
77
175
|
file: filePath,
|
|
78
176
|
projectRoot,
|
|
79
177
|
tsConfigPath,
|
|
80
|
-
imports,
|
|
81
|
-
|
|
82
|
-
|
|
178
|
+
imports: shown.items,
|
|
179
|
+
truncated: shown.truncated,
|
|
180
|
+
counts,
|
|
181
|
+
summary,
|
|
182
|
+
}, warnings);
|
|
83
183
|
}
|
|
84
184
|
resolveFilePath(file, projectRoot) {
|
|
85
185
|
if (isAbsolute(file)) {
|
|
@@ -138,7 +238,27 @@ export class ListImportsTool {
|
|
|
138
238
|
line: edge.declaration.getStartLineNumber(),
|
|
139
239
|
};
|
|
140
240
|
}
|
|
141
|
-
buildSummary(imports) {
|
|
241
|
+
buildSummary(file, imports, counts, shown) {
|
|
242
|
+
const lines = [
|
|
243
|
+
`${file}: ${counts.total} import(s) (${counts.aliased} aliased, ${counts.relative} relative, ` +
|
|
244
|
+
`${counts.external} external), ${counts.reExports} re-export(s), ${counts.typeOnly} type-only.`,
|
|
245
|
+
];
|
|
246
|
+
const unresolved = imports
|
|
247
|
+
.filter((e) => e.kind !== 'external' && e.resolvedPath === null)
|
|
248
|
+
.map((e) => `${e.moduleSpecifier} (line ${e.line})`);
|
|
249
|
+
if (unresolved.length > 0) {
|
|
250
|
+
const more = unresolved.length > SUMMARY_UNRESOLVED
|
|
251
|
+
? ` and ${unresolved.length - SUMMARY_UNRESOLVED} more`
|
|
252
|
+
: '';
|
|
253
|
+
lines.push(`${unresolved.length} unresolved: ${unresolved.slice(0, SUMMARY_UNRESOLVED).join(', ')}${more}.`);
|
|
254
|
+
}
|
|
255
|
+
const note = truncationNote(shown, counts.total, 'imports');
|
|
256
|
+
if (note !== undefined) {
|
|
257
|
+
lines.push(note);
|
|
258
|
+
}
|
|
259
|
+
return lines.join('\n');
|
|
260
|
+
}
|
|
261
|
+
countImports(imports) {
|
|
142
262
|
const count = (predicate) => imports.filter(predicate).length;
|
|
143
263
|
return {
|
|
144
264
|
total: imports.length,
|