@angular-modernizer/adapter-mcp 0.3.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.
- package/README.md +181 -282
- package/dist/cli.js +21 -13
- package/dist/core/project-analyzer.d.ts +3 -12
- package/dist/core/project-analyzer.js +3 -12
- package/dist/index.d.ts +122 -6
- package/dist/index.js +49 -5
- package/dist/mcp-watcher.d.ts +32 -7
- package/dist/mcp-watcher.js +16 -15
- package/dist/scan-host/scan-host.d.ts +119 -0
- package/dist/scan-host/scan-host.js +376 -0
- package/dist/scan-host/scan-protocol.d.ts +35 -0
- package/dist/scan-host/scan-protocol.js +6 -0
- package/dist/scan-host/scan-worker.d.ts +14 -0
- package/dist/scan-host/scan-worker.js +48 -0
- package/dist/server/limited-stdio-transport.d.ts +75 -0
- package/dist/server/limited-stdio-transport.js +115 -0
- package/dist/server/mcp-server.d.ts +20 -18
- package/dist/server/mcp-server.js +42 -79
- package/dist/server/package-version.d.ts +16 -0
- package/dist/server/package-version.js +37 -0
- package/dist/server/sdk-server.d.ts +71 -0
- package/dist/server/sdk-server.js +113 -0
- package/dist/server/tool-registry.d.ts +6 -9
- package/dist/server/tool-registry.js +6 -12
- package/dist/streaming/progress-store.d.ts +22 -5
- package/dist/streaming/progress-store.js +9 -5
- package/dist/tools/analyze-build-impact.d.ts +276 -35
- package/dist/tools/analyze-build-impact.js +175 -28
- package/dist/tools/analyze-core-to-shared.d.ts +176 -16
- package/dist/tools/analyze-core-to-shared.js +124 -19
- package/dist/tools/analyze-parser-performance.d.ts +209 -15
- package/dist/tools/analyze-parser-performance.js +119 -56
- package/dist/tools/analyze-project.d.ts +349 -17
- package/dist/tools/analyze-project.js +282 -97
- package/dist/tools/check-incremental-compatibility.d.ts +74 -12
- package/dist/tools/check-incremental-compatibility.js +69 -10
- package/dist/tools/collect-feedback.d.ts +225 -21
- package/dist/tools/collect-feedback.js +199 -118
- package/dist/tools/compare-health.d.ts +413 -0
- package/dist/tools/compare-health.js +479 -0
- package/dist/tools/extract-libraries.d.ts +200 -24
- package/dist/tools/extract-libraries.js +131 -27
- package/dist/tools/find-angular-symbol.d.ts +92 -24
- package/dist/tools/find-angular-symbol.js +70 -20
- package/dist/tools/find-component-hosts.d.ts +603 -27
- package/dist/tools/find-component-hosts.js +223 -19
- package/dist/tools/find-usages.d.ts +102 -22
- package/dist/tools/find-usages.js +81 -21
- package/dist/tools/get-bootstrap-execution.d.ts +183 -25
- package/dist/tools/get-bootstrap-execution.js +109 -25
- package/dist/tools/get-call-graph.d.ts +127 -12
- package/dist/tools/get-call-graph.js +84 -19
- package/dist/tools/get-operation-progress-tool.d.ts +126 -8
- package/dist/tools/get-operation-progress-tool.js +124 -12
- package/dist/tools/get-operation-progress.d.ts +27 -1
- package/dist/tools/get-operation-progress.js +5 -5
- package/dist/tools/helpers/analysis-output.d.ts +182 -0
- package/dist/tools/helpers/analysis-output.js +165 -0
- package/dist/tools/helpers/batch-kernel.d.ts +14 -0
- package/dist/tools/helpers/batch-kernel.js +12 -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 +2 -1
- package/dist/tools/helpers/compact-output.js +2 -1
- 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 +99 -0
- package/dist/tools/helpers/health-delta.js +236 -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 +60 -37
- package/dist/tools/helpers/project-cache.js +54 -37
- 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 +25 -13
- package/dist/tools/helpers/rule-runner.js +45 -24
- package/dist/tools/helpers/scan-cache.d.ts +22 -0
- package/dist/tools/helpers/scan-cache.js +34 -0
- package/dist/tools/helpers/scan-engine.d.ts +107 -0
- package/dist/tools/helpers/scan-engine.js +197 -0
- package/dist/tools/helpers/scan-plan.d.ts +5 -2
- package/dist/tools/helpers/scan-plan.js +18 -3
- package/dist/tools/helpers/scope-paths.d.ts +17 -0
- package/dist/tools/helpers/scope-paths.js +32 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
- package/dist/tools/helpers/suggestion-generator.js +0 -12
- package/dist/tools/helpers/tool-cache.d.ts +11 -0
- package/dist/tools/helpers/tool-cache.js +15 -0
- package/dist/tools/helpers/tool-context.d.ts +63 -0
- package/dist/tools/helpers/tool-context.js +79 -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 +262 -24
- package/dist/tools/inspect-form-group.js +134 -13
- package/dist/tools/inspect-i18n.d.ts +410 -23
- package/dist/tools/inspect-i18n.js +213 -13
- package/dist/tools/inspect-template.d.ts +260 -22
- package/dist/tools/inspect-template.js +174 -13
- package/dist/tools/learn-patterns.d.ts +210 -13
- package/dist/tools/learn-patterns.js +113 -12
- package/dist/tools/list-imports.d.ts +152 -34
- package/dist/tools/list-imports.js +124 -18
- package/dist/tools/orchestrate-migration.d.ts +159 -14
- package/dist/tools/orchestrate-migration.js +147 -20
- package/dist/tools/parse-stack-trace.d.ts +78 -21
- package/dist/tools/parse-stack-trace.js +44 -7
- package/dist/tools/plan-migration.d.ts +395 -26
- package/dist/tools/plan-migration.js +173 -22
- package/dist/tools/resolve-type.d.ts +57 -9
- package/dist/tools/resolve-type.js +49 -12
- package/dist/tools/review-feedback.d.ts +214 -16
- package/dist/tools/review-feedback.js +142 -57
- package/dist/tools/rollback-changes.d.ts +88 -7
- package/dist/tools/rollback-changes.js +74 -19
- package/dist/tools/run-angular-cli.d.ts +57 -12
- package/dist/tools/run-angular-cli.js +76 -13
- package/dist/tools/run-build.d.ts +127 -13
- package/dist/tools/run-build.js +128 -16
- package/dist/tools/run-schematic.d.ts +82 -12
- package/dist/tools/run-schematic.js +115 -18
- package/dist/tools/scan-all.d.ts +88 -23
- package/dist/tools/scan-all.js +161 -220
- package/dist/tools/scan-angular.d.ts +60 -19
- package/dist/tools/scan-angular.js +100 -141
- package/dist/tools/scan-architecture.d.ts +92 -24
- package/dist/tools/scan-architecture.js +268 -211
- package/dist/tools/scan-solid.d.ts +59 -19
- package/dist/tools/scan-solid.js +98 -139
- package/dist/tools/search-codebase.d.ts +110 -23
- package/dist/tools/search-codebase.js +67 -11
- package/dist/tools/server-status.d.ts +392 -26
- package/dist/tools/server-status.js +260 -27
- package/dist/tools/suggest-improvements.d.ts +105 -10
- package/dist/tools/suggest-improvements.js +91 -51
- package/dist/tools/trace-output-flow.d.ts +713 -26
- package/dist/tools/trace-output-flow.js +396 -33
- 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 +402 -18
- package/dist/tools/transform-code.js +708 -649
- package/dist/tools/validate-before-transform.d.ts +136 -7
- package/dist/tools/validate-before-transform.js +65 -9
- package/dist/tools/validate-project-compatibility.d.ts +82 -15
- package/dist/tools/validate-project-compatibility.js +84 -15
- package/dist/tools/validate-transformation.d.ts +243 -8
- package/dist/tools/validate-transformation.js +127 -23
- package/dist/tools/verify-citations.d.ts +202 -0
- package/dist/tools/verify-citations.js +221 -0
- package/dist/types.d.ts +78 -11
- package/dist/types.js +0 -5
- package/dist/utils/format-tool-response.d.ts +22 -59
- package/dist/utils/format-tool-response.js +25 -134
- package/package.json +31 -20
- 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 -98
- package/dist/server/json-rpc-handler.d.ts.map +0 -1
- package/dist/server/json-rpc-handler.js +0 -301
- 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/stdio-guard.d.ts.map +0 -1
- package/dist/server/stdio-guard.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-component-hosts.d.ts.map +0 -1
- package/dist/tools/find-component-hosts.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-bootstrap-execution.d.ts.map +0 -1
- package/dist/tools/get-bootstrap-execution.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/compact-output.d.ts.map +0 -1
- package/dist/tools/helpers/compact-output.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/project-cache.d.ts.map +0 -1
- package/dist/tools/helpers/project-cache.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/rule-runner.d.ts.map +0 -1
- package/dist/tools/helpers/rule-runner.js.map +0 -1
- package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
- package/dist/tools/helpers/scan-plan.js.map +0 -1
- package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
- package/dist/tools/helpers/stack-frame-file-index.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/inspect-form-group.d.ts.map +0 -1
- package/dist/tools/inspect-form-group.js.map +0 -1
- package/dist/tools/inspect-i18n.d.ts.map +0 -1
- package/dist/tools/inspect-i18n.js.map +0 -1
- package/dist/tools/inspect-template.d.ts.map +0 -1
- package/dist/tools/inspect-template.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/server-status.d.ts.map +0 -1
- package/dist/tools/server-status.js.map +0 -1
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.d.ts.map +0 -1
- package/dist/tools/shared/scan-types.js +0 -7
- 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/trace-output-flow.d.ts.map +0 -1
- package/dist/tools/trace-output-flow.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
|
@@ -1,25 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Learn Patterns Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool for discovering and learning patterns from codebases using
|
|
5
|
-
* ML-based pattern recognition. Identifies recurring architectural patterns,
|
|
6
|
-
* anti-patterns, and transformation opportunities.
|
|
7
|
-
*
|
|
8
|
-
* Enhancement: Self-learning with style-aware pattern discovery
|
|
9
|
-
*/
|
|
10
1
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
11
2
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
12
3
|
import { writeFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
13
4
|
import { resolve, dirname } from 'node:path';
|
|
5
|
+
import { countList } from './helpers/analysis-output.js';
|
|
6
|
+
import { COUNT_OBJECT } from './helpers/investigation-schemas.js';
|
|
14
7
|
import { PatternKnowledgeBase, StyleConventionDetector, ContextAwareScorer, ContextAwareRuleGenerator, RealFileSystemAdapter, } from '@angular-modernizer/core';
|
|
8
|
+
/** Categories and patterns named in the summary. */
|
|
9
|
+
const SUMMARY_PATTERNS = 5;
|
|
10
|
+
/**
|
|
11
|
+
* Text summary: totals per category and complexity, the most frequent
|
|
12
|
+
* patterns, the style profile and what was written.
|
|
13
|
+
*/
|
|
14
|
+
function describePatterns(result) {
|
|
15
|
+
const { statistics } = result;
|
|
16
|
+
const categories = countList(statistics.byCategory, SUMMARY_PATTERNS);
|
|
17
|
+
const complexity = countList(statistics.byComplexity, SUMMARY_PATTERNS);
|
|
18
|
+
const lines = [
|
|
19
|
+
`${statistics.totalPatternsFound} pattern(s) in ${statistics.filesAnalyzed} analyzed file(s)` +
|
|
20
|
+
(categories === undefined ? '.' : ` (category ${categories}; complexity ${complexity ?? 'none'}).`),
|
|
21
|
+
];
|
|
22
|
+
const top = [...result.patterns]
|
|
23
|
+
.sort((a, b) => b.occurrences - a.occurrences || a.name.localeCompare(b.name))
|
|
24
|
+
.slice(0, SUMMARY_PATTERNS);
|
|
25
|
+
for (const p of top) {
|
|
26
|
+
const confidence = p.confidence === undefined ? '' : `, confidence ${p.confidence.toFixed(2)}`;
|
|
27
|
+
lines.push(`- ${p.name} (${p.category}): ${p.occurrences} occurrence(s), ${p.complexity}${confidence}`);
|
|
28
|
+
}
|
|
29
|
+
const style = result.styleProfile;
|
|
30
|
+
if (style !== undefined) {
|
|
31
|
+
lines.push(`Style: DI ${style.diPreference}, RxJS ${style.rxjsPreference}, change detection ` +
|
|
32
|
+
`${style.changeDetectionPreference}, modules ${style.moduleStyle}, state ${style.stateManagement}, ` +
|
|
33
|
+
`architecture ${style.architectureStyle} (confidence ${style.confidence.toFixed(2)}).`);
|
|
34
|
+
}
|
|
35
|
+
if (result.generatedRules !== undefined) {
|
|
36
|
+
lines.push(`${result.generatedRules.length} rule(s) generated.`);
|
|
37
|
+
}
|
|
38
|
+
const fixtures = result.artifacts?.fixtures?.length ?? 0;
|
|
39
|
+
const rules = result.artifacts?.rules?.length ?? 0;
|
|
40
|
+
if (fixtures + rules > 0) {
|
|
41
|
+
lines.push(`Written: ${fixtures} fixture file(s), ${rules} rule file(s).`);
|
|
42
|
+
}
|
|
43
|
+
return lines.join('\n');
|
|
44
|
+
}
|
|
15
45
|
/**
|
|
16
|
-
* MCP tool
|
|
46
|
+
* MCP tool `learn-patterns`: discovers recurring architectural patterns,
|
|
47
|
+
* anti-patterns and transformation opportunities in a codebase.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Detects a style profile of the codebase (DI, RxJS/signals, change
|
|
51
|
+
* detection, module style, state management), scores patterns by confidence
|
|
52
|
+
* and style alignment, tracks them across scans in a knowledge base and can
|
|
53
|
+
* write fixtures and generated rules.
|
|
17
54
|
*/
|
|
18
55
|
export class LearnPatternsTool {
|
|
19
56
|
name = 'learn-patterns';
|
|
20
|
-
|
|
57
|
+
title = 'Learn Patterns';
|
|
58
|
+
annotations = {
|
|
59
|
+
readOnlyHint: false,
|
|
60
|
+
destructiveHint: false,
|
|
61
|
+
idempotentHint: true,
|
|
62
|
+
openWorldHint: false,
|
|
63
|
+
};
|
|
64
|
+
description = 'Discover recurring architectural patterns, anti-patterns and transformation opportunities in a codebase with AST heuristics (RxJS, components, services, transformations, architecture), count their occurrences and store them in a pattern knowledge base that later runs extend. Detects the codebase style conventions. summary is a short text of patterns and style profile.';
|
|
65
|
+
/**
|
|
66
|
+
* JSON Schema of the tool arguments.
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
21
69
|
inputSchema = {
|
|
22
70
|
type: 'object',
|
|
71
|
+
additionalProperties: false,
|
|
23
72
|
properties: {
|
|
24
73
|
targetPath: {
|
|
25
74
|
type: 'string',
|
|
@@ -157,6 +206,58 @@ export class LearnPatternsTool {
|
|
|
157
206
|
},
|
|
158
207
|
required: ['targetPath'],
|
|
159
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
211
|
+
* @hidden
|
|
212
|
+
*/
|
|
213
|
+
outputSchema = {
|
|
214
|
+
type: 'object',
|
|
215
|
+
properties: {
|
|
216
|
+
patterns: {
|
|
217
|
+
type: 'array',
|
|
218
|
+
items: {
|
|
219
|
+
type: 'object',
|
|
220
|
+
properties: {
|
|
221
|
+
id: { type: 'string' },
|
|
222
|
+
name: { type: 'string' },
|
|
223
|
+
category: { type: 'string' },
|
|
224
|
+
description: { type: 'string' },
|
|
225
|
+
occurrences: { type: 'integer' },
|
|
226
|
+
complexity: { type: 'string' },
|
|
227
|
+
examples: { type: 'array', items: { type: 'object' } },
|
|
228
|
+
suggestedRule: { type: 'object' },
|
|
229
|
+
confidence: { type: 'number' },
|
|
230
|
+
confidenceExplanation: { type: 'string' },
|
|
231
|
+
alignsWithStyle: { type: 'boolean' },
|
|
232
|
+
styleAlignment: { type: 'number' },
|
|
233
|
+
dominancePercentage: { type: 'number' },
|
|
234
|
+
trending: { type: 'string' },
|
|
235
|
+
scanCount: { type: 'integer' },
|
|
236
|
+
},
|
|
237
|
+
required: ['id', 'name', 'category', 'occurrences', 'complexity'],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
statistics: {
|
|
241
|
+
type: 'object',
|
|
242
|
+
properties: {
|
|
243
|
+
totalPatternsFound: { type: 'integer' },
|
|
244
|
+
byCategory: COUNT_OBJECT,
|
|
245
|
+
byComplexity: COUNT_OBJECT,
|
|
246
|
+
filesAnalyzed: { type: 'integer' },
|
|
247
|
+
duration: { type: 'number' },
|
|
248
|
+
},
|
|
249
|
+
required: ['totalPatternsFound', 'byCategory', 'byComplexity', 'filesAnalyzed', 'duration'],
|
|
250
|
+
},
|
|
251
|
+
artifacts: { type: 'object' },
|
|
252
|
+
validation: { type: 'object' },
|
|
253
|
+
styleProfile: { type: 'object' },
|
|
254
|
+
learningEvolution: { type: 'object' },
|
|
255
|
+
confidenceAnalysis: { type: 'object' },
|
|
256
|
+
generatedRules: { type: 'array', items: { type: 'object' } },
|
|
257
|
+
summary: { type: 'string' },
|
|
258
|
+
},
|
|
259
|
+
required: ['patterns', 'statistics', 'summary'],
|
|
260
|
+
};
|
|
160
261
|
async execute(args) {
|
|
161
262
|
const params = args;
|
|
162
263
|
const targetPath = params.targetPath;
|
|
@@ -458,7 +559,7 @@ export class LearnPatternsTool {
|
|
|
458
559
|
if (generatedRulesResult) {
|
|
459
560
|
result.generatedRules = generatedRulesResult;
|
|
460
561
|
}
|
|
461
|
-
return result;
|
|
562
|
+
return { ...result, summary: describePatterns(result) };
|
|
462
563
|
}
|
|
463
564
|
/**
|
|
464
565
|
* Discover patterns from the project.
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* @angular-modernizer/adapter-mcp - List Imports Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool that lists the imports (and optionally `export ... from`
|
|
5
|
-
* re-exports) of a single file with their resolved targets.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
9
|
-
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
10
|
-
* instead of grepping import lines when classifying layer dependencies,
|
|
11
|
-
* checking barrels or tracing where a symbol really comes from.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Via MCP:
|
|
16
|
-
* // tool: list-imports
|
|
17
|
-
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
import { type MCPTool } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
21
2
|
import { type ModuleSpecifierKind } from '@angular-modernizer/core';
|
|
22
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
23
4
|
/**
|
|
24
5
|
* A named import / re-export specifier.
|
|
25
6
|
*/
|
|
26
|
-
interface NamedImportEntry {
|
|
7
|
+
export interface NamedImportEntry {
|
|
27
8
|
/** Name exported by the target module. */
|
|
28
9
|
name: string;
|
|
29
10
|
/** Local alias (import) or exported alias (re-export), if renamed. */
|
|
@@ -34,13 +15,18 @@ interface NamedImportEntry {
|
|
|
34
15
|
/**
|
|
35
16
|
* One import or re-export of the file.
|
|
36
17
|
*/
|
|
37
|
-
interface ImportEntry {
|
|
18
|
+
export interface ImportEntry {
|
|
19
|
+
/** Module specifier as written. */
|
|
38
20
|
moduleSpecifier: string;
|
|
21
|
+
/** Specifier kind: aliased (tsconfig `paths`), relative or external. */
|
|
39
22
|
kind: ModuleSpecifierKind;
|
|
40
23
|
/** Project-relative resolved path, or null when unresolved / external. */
|
|
41
24
|
resolvedPath: string | null;
|
|
25
|
+
/** Named import or re-export specifiers. */
|
|
42
26
|
namedImports: NamedImportEntry[];
|
|
27
|
+
/** Default import binding, or null. */
|
|
43
28
|
defaultImport: string | null;
|
|
29
|
+
/** Namespace import binding (`import * as x`), or null. */
|
|
44
30
|
namespaceImport: string | null;
|
|
45
31
|
/** Whole declaration is type-only (`import type` / `export type`). */
|
|
46
32
|
typeOnly: boolean;
|
|
@@ -54,35 +40,72 @@ interface ImportEntry {
|
|
|
54
40
|
/**
|
|
55
41
|
* Output of the list-imports tool.
|
|
56
42
|
*/
|
|
57
|
-
interface ListImportsOutput {
|
|
43
|
+
export interface ListImportsOutput {
|
|
44
|
+
/** Absolute path of the inspected file. */
|
|
58
45
|
file: string;
|
|
46
|
+
/** Absolute project root. */
|
|
59
47
|
projectRoot: string;
|
|
48
|
+
/** The tsconfig used to resolve the imports. */
|
|
60
49
|
tsConfigPath: string;
|
|
61
50
|
/** Imports in declaration order, cut to `maxResults`; omitted with `summaryOnly`. */
|
|
62
51
|
imports?: ImportEntry[];
|
|
63
52
|
/** `true` when `maxResults` cut the import list. */
|
|
64
53
|
truncated: boolean;
|
|
65
54
|
/** Counts over all imports, independent of `maxResults`. */
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
55
|
+
counts: ImportCounts;
|
|
56
|
+
/** Human-readable summary for LLM consumption. */
|
|
57
|
+
summary: string;
|
|
58
|
+
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
59
|
+
warnings?: string[];
|
|
60
|
+
}
|
|
61
|
+
/** Counts over all imports of the file. */
|
|
62
|
+
export interface ImportCounts {
|
|
63
|
+
/** All imports and re-exports. */
|
|
64
|
+
total: number;
|
|
65
|
+
/** Specifiers resolved through tsconfig `paths` aliases. */
|
|
66
|
+
aliased: number;
|
|
67
|
+
/** Relative specifiers. */
|
|
68
|
+
relative: number;
|
|
69
|
+
/** Package specifiers. */
|
|
70
|
+
external: number;
|
|
71
|
+
/** Non-external specifiers that did not resolve to a file. */
|
|
72
|
+
unresolved: number;
|
|
73
|
+
/** `export ... from` declarations. */
|
|
74
|
+
reExports: number;
|
|
75
|
+
/** Type-only declarations (`import type` / `export type`). */
|
|
76
|
+
typeOnly: number;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
|
-
* MCP tool that lists the
|
|
79
|
+
* MCP tool that lists the imports (and optionally `export ... from`
|
|
80
|
+
* re-exports) of a single file with their resolved targets.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Resolution goes through the TypeScript module resolver, so tsconfig `paths`
|
|
84
|
+
* aliases (`@shared/*`, `@core/*`, ...) resolve to real project files. Use it
|
|
85
|
+
* instead of grepping import lines when classifying layer dependencies,
|
|
86
|
+
* checking barrels or tracing where a symbol really comes from.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Via MCP:
|
|
91
|
+
* // tool: list-imports
|
|
92
|
+
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
93
|
+
* ```
|
|
78
94
|
*/
|
|
79
95
|
export declare class ListImportsTool implements MCPTool {
|
|
80
96
|
private readonly projects;
|
|
81
97
|
readonly name = "list-imports";
|
|
98
|
+
readonly title = "List Imports";
|
|
99
|
+
readonly annotations: ToolAnnotations;
|
|
82
100
|
constructor(projects?: ProjectCache);
|
|
83
101
|
readonly description: string;
|
|
102
|
+
/**
|
|
103
|
+
* JSON Schema of the tool arguments.
|
|
104
|
+
* @hidden
|
|
105
|
+
*/
|
|
84
106
|
readonly inputSchema: {
|
|
85
107
|
type: string;
|
|
108
|
+
additionalProperties: boolean;
|
|
86
109
|
properties: {
|
|
87
110
|
summaryOnly: {
|
|
88
111
|
readonly type: "boolean";
|
|
@@ -109,11 +132,106 @@ export declare class ListImportsTool implements MCPTool {
|
|
|
109
132
|
};
|
|
110
133
|
required: string[];
|
|
111
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
137
|
+
* @hidden
|
|
138
|
+
*/
|
|
139
|
+
readonly outputSchema: {
|
|
140
|
+
type: string;
|
|
141
|
+
properties: {
|
|
142
|
+
warnings: {
|
|
143
|
+
readonly type: "array";
|
|
144
|
+
readonly items: {
|
|
145
|
+
readonly type: "string";
|
|
146
|
+
};
|
|
147
|
+
readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
|
|
148
|
+
};
|
|
149
|
+
file: {
|
|
150
|
+
type: string;
|
|
151
|
+
};
|
|
152
|
+
projectRoot: {
|
|
153
|
+
type: string;
|
|
154
|
+
};
|
|
155
|
+
tsConfigPath: {
|
|
156
|
+
type: string;
|
|
157
|
+
};
|
|
158
|
+
imports: {
|
|
159
|
+
type: string;
|
|
160
|
+
items: {
|
|
161
|
+
type: string;
|
|
162
|
+
properties: {
|
|
163
|
+
moduleSpecifier: {
|
|
164
|
+
type: string;
|
|
165
|
+
};
|
|
166
|
+
kind: {
|
|
167
|
+
type: string;
|
|
168
|
+
};
|
|
169
|
+
resolvedPath: {
|
|
170
|
+
type: string[];
|
|
171
|
+
};
|
|
172
|
+
namedImports: {
|
|
173
|
+
type: string;
|
|
174
|
+
items: {
|
|
175
|
+
type: string;
|
|
176
|
+
properties: {
|
|
177
|
+
name: {
|
|
178
|
+
type: string;
|
|
179
|
+
};
|
|
180
|
+
alias: {
|
|
181
|
+
type: string[];
|
|
182
|
+
};
|
|
183
|
+
typeOnly: {
|
|
184
|
+
type: string;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
required: string[];
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
defaultImport: {
|
|
191
|
+
type: string[];
|
|
192
|
+
};
|
|
193
|
+
namespaceImport: {
|
|
194
|
+
type: string[];
|
|
195
|
+
};
|
|
196
|
+
typeOnly: {
|
|
197
|
+
type: string;
|
|
198
|
+
};
|
|
199
|
+
isReExport: {
|
|
200
|
+
type: string;
|
|
201
|
+
};
|
|
202
|
+
isStarReExport: {
|
|
203
|
+
type: string;
|
|
204
|
+
};
|
|
205
|
+
line: {
|
|
206
|
+
type: string;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
required: string[];
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
truncated: {
|
|
213
|
+
type: string;
|
|
214
|
+
};
|
|
215
|
+
counts: {
|
|
216
|
+
type: string;
|
|
217
|
+
properties: {
|
|
218
|
+
[k: string]: {
|
|
219
|
+
type: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
required: ("total" | "external" | "unresolved" | "aliased" | "relative" | "reExports" | "typeOnly")[];
|
|
223
|
+
};
|
|
224
|
+
summary: {
|
|
225
|
+
type: string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
required: string[];
|
|
229
|
+
};
|
|
112
230
|
execute(args: Record<string, unknown>): Promise<ListImportsOutput>;
|
|
113
231
|
private resolveFilePath;
|
|
114
232
|
private findProjectRoot;
|
|
115
233
|
private toEntry;
|
|
116
234
|
private buildSummary;
|
|
235
|
+
private countImports;
|
|
117
236
|
}
|
|
118
|
-
export {};
|
|
119
237
|
//# sourceMappingURL=list-imports.d.ts.map
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
import { Project } from 'ts-morph';
|
|
2
|
+
import { classifyModuleSpecifier, collectModuleEdges, } from '@angular-modernizer/core';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
5
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
6
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
7
|
+
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
8
|
+
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
9
|
+
/** Unresolved specifiers named in the summary. */
|
|
10
|
+
const SUMMARY_UNRESOLVED = 10;
|
|
11
|
+
const COUNT_KEYS = [
|
|
12
|
+
'total',
|
|
13
|
+
'aliased',
|
|
14
|
+
'relative',
|
|
15
|
+
'external',
|
|
16
|
+
'unresolved',
|
|
17
|
+
'reExports',
|
|
18
|
+
'typeOnly',
|
|
19
|
+
];
|
|
1
20
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - List Imports Tool
|
|
3
|
-
*
|
|
4
21
|
* MCP tool that lists the imports (and optionally `export ... from`
|
|
5
22
|
* re-exports) of a single file with their resolved targets.
|
|
6
23
|
*
|
|
@@ -17,19 +34,16 @@
|
|
|
17
34
|
* // args: { file: '/project/src/app/user.component.ts', projectRoot: '/project' }
|
|
18
35
|
* ```
|
|
19
36
|
*/
|
|
20
|
-
import { Project } from 'ts-morph';
|
|
21
|
-
import { classifyModuleSpecifier, collectModuleEdges, } from '@angular-modernizer/core';
|
|
22
|
-
import { existsSync } from 'node:fs';
|
|
23
|
-
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
24
|
-
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
25
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
26
|
-
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
|
|
27
|
-
/**
|
|
28
|
-
* MCP tool that lists the resolved imports of a file.
|
|
29
|
-
*/
|
|
30
37
|
export class ListImportsTool {
|
|
31
38
|
projects;
|
|
32
39
|
name = 'list-imports';
|
|
40
|
+
title = 'List Imports';
|
|
41
|
+
annotations = {
|
|
42
|
+
readOnlyHint: true,
|
|
43
|
+
destructiveHint: false,
|
|
44
|
+
idempotentHint: true,
|
|
45
|
+
openWorldHint: false,
|
|
46
|
+
};
|
|
33
47
|
constructor(projects = new ProjectCache()) {
|
|
34
48
|
this.projects = projects;
|
|
35
49
|
}
|
|
@@ -37,9 +51,14 @@ export class ListImportsTool {
|
|
|
37
51
|
'For each import: moduleSpecifier, kind (aliased | relative | external), ' +
|
|
38
52
|
'project-relative resolvedPath (tsconfig paths aware), named/default/namespace imports, ' +
|
|
39
53
|
'type-only flags and whether it is a re-export. Use instead of grepping import lines. ' +
|
|
40
|
-
'
|
|
54
|
+
'counts always cover all imports; summaryOnly returns only the counts and the summary.';
|
|
55
|
+
/**
|
|
56
|
+
* JSON Schema of the tool arguments.
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
41
59
|
inputSchema = {
|
|
42
60
|
type: 'object',
|
|
61
|
+
additionalProperties: false,
|
|
43
62
|
properties: {
|
|
44
63
|
file: {
|
|
45
64
|
type: 'string',
|
|
@@ -58,6 +77,68 @@ export class ListImportsTool {
|
|
|
58
77
|
},
|
|
59
78
|
required: ['file'],
|
|
60
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
outputSchema = {
|
|
85
|
+
type: 'object',
|
|
86
|
+
properties: {
|
|
87
|
+
file: { type: 'string' },
|
|
88
|
+
projectRoot: { type: 'string' },
|
|
89
|
+
tsConfigPath: { type: 'string' },
|
|
90
|
+
imports: {
|
|
91
|
+
type: 'array',
|
|
92
|
+
items: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
moduleSpecifier: { type: 'string' },
|
|
96
|
+
kind: { type: 'string' },
|
|
97
|
+
resolvedPath: { type: ['string', 'null'] },
|
|
98
|
+
namedImports: {
|
|
99
|
+
type: 'array',
|
|
100
|
+
items: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
name: { type: 'string' },
|
|
104
|
+
alias: { type: ['string', 'null'] },
|
|
105
|
+
typeOnly: { type: 'boolean' },
|
|
106
|
+
},
|
|
107
|
+
required: ['name', 'alias', 'typeOnly'],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
defaultImport: { type: ['string', 'null'] },
|
|
111
|
+
namespaceImport: { type: ['string', 'null'] },
|
|
112
|
+
typeOnly: { type: 'boolean' },
|
|
113
|
+
isReExport: { type: 'boolean' },
|
|
114
|
+
isStarReExport: { type: 'boolean' },
|
|
115
|
+
line: { type: 'integer' },
|
|
116
|
+
},
|
|
117
|
+
required: [
|
|
118
|
+
'moduleSpecifier',
|
|
119
|
+
'kind',
|
|
120
|
+
'resolvedPath',
|
|
121
|
+
'namedImports',
|
|
122
|
+
'defaultImport',
|
|
123
|
+
'namespaceImport',
|
|
124
|
+
'typeOnly',
|
|
125
|
+
'isReExport',
|
|
126
|
+
'isStarReExport',
|
|
127
|
+
'line',
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
truncated: { type: 'boolean' },
|
|
132
|
+
counts: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: Object.fromEntries(COUNT_KEYS.map((k) => [k, { type: 'integer' }])),
|
|
135
|
+
required: [...COUNT_KEYS],
|
|
136
|
+
},
|
|
137
|
+
summary: { type: 'string' },
|
|
138
|
+
...WARNINGS_OUTPUT_SCHEMA,
|
|
139
|
+
},
|
|
140
|
+
required: ['file', 'projectRoot', 'tsConfigPath', 'truncated', 'counts', 'summary'],
|
|
141
|
+
};
|
|
61
142
|
async execute(args) {
|
|
62
143
|
const params = args;
|
|
63
144
|
if (!params.file || typeof params.file !== 'string') {
|
|
@@ -84,19 +165,24 @@ export class ListImportsTool {
|
|
|
84
165
|
new Project({ tsConfigFilePath: tsConfigPath }).addSourceFileAtPath(filePath);
|
|
85
166
|
const includeReExports = params.includeReExports !== false;
|
|
86
167
|
const imports = collectModuleEdges(sourceFile, includeReExports).map((edge) => this.toEntry(sourceFile, edge, projectRoot));
|
|
87
|
-
const
|
|
168
|
+
const counts = this.countImports(imports);
|
|
169
|
+
const warnings = this.projects.warnings(tsConfigPath);
|
|
170
|
+
const label = relative(projectRoot, filePath) || filePath;
|
|
88
171
|
if (compact.summaryOnly) {
|
|
89
|
-
|
|
172
|
+
const summary = this.buildSummary(label, imports, counts, imports.length);
|
|
173
|
+
return withWarnings({ file: filePath, projectRoot, tsConfigPath, truncated: false, counts, summary }, warnings);
|
|
90
174
|
}
|
|
91
175
|
const shown = limitList(imports, compact.maxResults);
|
|
92
|
-
|
|
176
|
+
const summary = this.buildSummary(label, imports, counts, shown.items.length);
|
|
177
|
+
return withWarnings({
|
|
93
178
|
file: filePath,
|
|
94
179
|
projectRoot,
|
|
95
180
|
tsConfigPath,
|
|
96
181
|
imports: shown.items,
|
|
97
182
|
truncated: shown.truncated,
|
|
183
|
+
counts,
|
|
98
184
|
summary,
|
|
99
|
-
};
|
|
185
|
+
}, warnings);
|
|
100
186
|
}
|
|
101
187
|
resolveFilePath(file, projectRoot) {
|
|
102
188
|
if (isAbsolute(file)) {
|
|
@@ -155,7 +241,27 @@ export class ListImportsTool {
|
|
|
155
241
|
line: edge.declaration.getStartLineNumber(),
|
|
156
242
|
};
|
|
157
243
|
}
|
|
158
|
-
buildSummary(imports) {
|
|
244
|
+
buildSummary(file, imports, counts, shown) {
|
|
245
|
+
const lines = [
|
|
246
|
+
`${file}: ${counts.total} import(s) (${counts.aliased} aliased, ${counts.relative} relative, ` +
|
|
247
|
+
`${counts.external} external), ${counts.reExports} re-export(s), ${counts.typeOnly} type-only.`,
|
|
248
|
+
];
|
|
249
|
+
const unresolved = imports
|
|
250
|
+
.filter((e) => e.kind !== 'external' && e.resolvedPath === null)
|
|
251
|
+
.map((e) => `${e.moduleSpecifier} (line ${e.line})`);
|
|
252
|
+
if (unresolved.length > 0) {
|
|
253
|
+
const more = unresolved.length > SUMMARY_UNRESOLVED
|
|
254
|
+
? ` and ${unresolved.length - SUMMARY_UNRESOLVED} more`
|
|
255
|
+
: '';
|
|
256
|
+
lines.push(`${unresolved.length} unresolved: ${unresolved.slice(0, SUMMARY_UNRESOLVED).join(', ')}${more}.`);
|
|
257
|
+
}
|
|
258
|
+
const note = truncationNote(shown, counts.total, 'imports');
|
|
259
|
+
if (note !== undefined) {
|
|
260
|
+
lines.push(note);
|
|
261
|
+
}
|
|
262
|
+
return lines.join('\n');
|
|
263
|
+
}
|
|
264
|
+
countImports(imports) {
|
|
159
265
|
const count = (predicate) => imports.filter(predicate).length;
|
|
160
266
|
return {
|
|
161
267
|
total: imports.length,
|