@angular-modernizer/adapter-mcp 0.1.1
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/LICENSE +21 -0
- package/README.md +917 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/project-analyzer.d.ts +59 -0
- package/dist/core/project-analyzer.d.ts.map +1 -0
- package/dist/core/project-analyzer.js +116 -0
- package/dist/core/project-analyzer.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-watcher.d.ts +119 -0
- package/dist/mcp-watcher.d.ts.map +1 -0
- package/dist/mcp-watcher.js +380 -0
- package/dist/mcp-watcher.js.map +1 -0
- package/dist/server/json-rpc-handler.d.ts +57 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -0
- package/dist/server/json-rpc-handler.js +222 -0
- package/dist/server/json-rpc-handler.js.map +1 -0
- package/dist/server/mcp-server.d.ts +62 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +184 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/server/tool-registry.d.ts +73 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +102 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/streaming/progress-store.d.ts +120 -0
- package/dist/streaming/progress-store.d.ts.map +1 -0
- package/dist/streaming/progress-store.js +238 -0
- package/dist/streaming/progress-store.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +127 -0
- package/dist/tools/analyze-build-impact.d.ts.map +1 -0
- package/dist/tools/analyze-build-impact.js +194 -0
- package/dist/tools/analyze-build-impact.js.map +1 -0
- package/dist/tools/analyze-core-to-shared.d.ts +163 -0
- package/dist/tools/analyze-core-to-shared.d.ts.map +1 -0
- package/dist/tools/analyze-core-to-shared.js +436 -0
- package/dist/tools/analyze-core-to-shared.js.map +1 -0
- package/dist/tools/analyze-parser-performance.d.ts +105 -0
- package/dist/tools/analyze-parser-performance.d.ts.map +1 -0
- package/dist/tools/analyze-parser-performance.js +313 -0
- package/dist/tools/analyze-parser-performance.js.map +1 -0
- package/dist/tools/analyze-project.d.ts +277 -0
- package/dist/tools/analyze-project.d.ts.map +1 -0
- package/dist/tools/analyze-project.js +946 -0
- package/dist/tools/analyze-project.js.map +1 -0
- package/dist/tools/check-incremental-compatibility.d.ts +109 -0
- package/dist/tools/check-incremental-compatibility.d.ts.map +1 -0
- package/dist/tools/check-incremental-compatibility.js +302 -0
- package/dist/tools/check-incremental-compatibility.js.map +1 -0
- package/dist/tools/collect-feedback.d.ts +117 -0
- package/dist/tools/collect-feedback.d.ts.map +1 -0
- package/dist/tools/collect-feedback.js +773 -0
- package/dist/tools/collect-feedback.js.map +1 -0
- package/dist/tools/extract-libraries.d.ts +121 -0
- package/dist/tools/extract-libraries.d.ts.map +1 -0
- package/dist/tools/extract-libraries.js +223 -0
- package/dist/tools/extract-libraries.js.map +1 -0
- package/dist/tools/find-angular-symbol.d.ts +55 -0
- package/dist/tools/find-angular-symbol.d.ts.map +1 -0
- package/dist/tools/find-angular-symbol.js +104 -0
- package/dist/tools/find-angular-symbol.js.map +1 -0
- package/dist/tools/find-usages.d.ts +65 -0
- package/dist/tools/find-usages.d.ts.map +1 -0
- package/dist/tools/find-usages.js +108 -0
- package/dist/tools/find-usages.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +61 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +119 -0
- package/dist/tools/get-call-graph.js.map +1 -0
- package/dist/tools/get-operation-progress-tool.d.ts +29 -0
- package/dist/tools/get-operation-progress-tool.d.ts.map +1 -0
- package/dist/tools/get-operation-progress-tool.js +36 -0
- package/dist/tools/get-operation-progress-tool.js.map +1 -0
- package/dist/tools/get-operation-progress.d.ts +51 -0
- package/dist/tools/get-operation-progress.d.ts.map +1 -0
- package/dist/tools/get-operation-progress.js +93 -0
- package/dist/tools/get-operation-progress.js.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts +43 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.js +196 -0
- package/dist/tools/helpers/feedback-analyzer.js.map +1 -0
- package/dist/tools/helpers/find-ts-config.d.ts +10 -0
- package/dist/tools/helpers/find-ts-config.d.ts.map +1 -0
- package/dist/tools/helpers/find-ts-config.js +32 -0
- package/dist/tools/helpers/find-ts-config.js.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +33 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.js +60 -0
- package/dist/tools/helpers/platform-root-resolver.js.map +1 -0
- package/dist/tools/helpers/rule-matcher.d.ts +84 -0
- package/dist/tools/helpers/rule-matcher.d.ts.map +1 -0
- package/dist/tools/helpers/rule-matcher.js +212 -0
- package/dist/tools/helpers/rule-matcher.js.map +1 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +66 -0
- package/dist/tools/helpers/suggestion-generator.d.ts.map +1 -0
- package/dist/tools/helpers/suggestion-generator.js +248 -0
- package/dist/tools/helpers/suggestion-generator.js.map +1 -0
- package/dist/tools/learn-patterns.d.ts +368 -0
- package/dist/tools/learn-patterns.d.ts.map +1 -0
- package/dist/tools/learn-patterns.js +1089 -0
- package/dist/tools/learn-patterns.js.map +1 -0
- package/dist/tools/orchestrate-migration.d.ts +187 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -0
- package/dist/tools/orchestrate-migration.js +235 -0
- package/dist/tools/orchestrate-migration.js.map +1 -0
- package/dist/tools/parse-stack-trace.d.ts +63 -0
- package/dist/tools/parse-stack-trace.d.ts.map +1 -0
- package/dist/tools/parse-stack-trace.js +92 -0
- package/dist/tools/parse-stack-trace.js.map +1 -0
- package/dist/tools/plan-migration.d.ts +388 -0
- package/dist/tools/plan-migration.d.ts.map +1 -0
- package/dist/tools/plan-migration.js +826 -0
- package/dist/tools/plan-migration.js.map +1 -0
- package/dist/tools/resolve-type.d.ts +54 -0
- package/dist/tools/resolve-type.d.ts.map +1 -0
- package/dist/tools/resolve-type.js +101 -0
- package/dist/tools/resolve-type.js.map +1 -0
- package/dist/tools/review-feedback.d.ts +124 -0
- package/dist/tools/review-feedback.d.ts.map +1 -0
- package/dist/tools/review-feedback.js +276 -0
- package/dist/tools/review-feedback.js.map +1 -0
- package/dist/tools/rollback-changes.d.ts +42 -0
- package/dist/tools/rollback-changes.d.ts.map +1 -0
- package/dist/tools/rollback-changes.js +95 -0
- package/dist/tools/rollback-changes.js.map +1 -0
- package/dist/tools/run-angular-cli.d.ts +102 -0
- package/dist/tools/run-angular-cli.d.ts.map +1 -0
- package/dist/tools/run-angular-cli.js +152 -0
- package/dist/tools/run-angular-cli.js.map +1 -0
- package/dist/tools/run-build.d.ts +201 -0
- package/dist/tools/run-build.d.ts.map +1 -0
- package/dist/tools/run-build.js +554 -0
- package/dist/tools/run-build.js.map +1 -0
- package/dist/tools/run-schematic.d.ts +173 -0
- package/dist/tools/run-schematic.d.ts.map +1 -0
- package/dist/tools/run-schematic.js +410 -0
- package/dist/tools/run-schematic.js.map +1 -0
- package/dist/tools/scan-all.d.ts +160 -0
- package/dist/tools/scan-all.d.ts.map +1 -0
- package/dist/tools/scan-all.js +486 -0
- package/dist/tools/scan-all.js.map +1 -0
- package/dist/tools/scan-angular.d.ts +132 -0
- package/dist/tools/scan-angular.d.ts.map +1 -0
- package/dist/tools/scan-angular.js +411 -0
- package/dist/tools/scan-angular.js.map +1 -0
- package/dist/tools/scan-architecture.d.ts +351 -0
- package/dist/tools/scan-architecture.d.ts.map +1 -0
- package/dist/tools/scan-architecture.js +1290 -0
- package/dist/tools/scan-architecture.js.map +1 -0
- package/dist/tools/scan-solid.d.ts +132 -0
- package/dist/tools/scan-solid.d.ts.map +1 -0
- package/dist/tools/scan-solid.js +435 -0
- package/dist/tools/scan-solid.js.map +1 -0
- package/dist/tools/search-codebase.d.ts +64 -0
- package/dist/tools/search-codebase.d.ts.map +1 -0
- package/dist/tools/search-codebase.js +109 -0
- package/dist/tools/search-codebase.js.map +1 -0
- package/dist/tools/shared/scan-types.d.ts +200 -0
- package/dist/tools/shared/scan-types.d.ts.map +1 -0
- package/dist/tools/shared/scan-types.js +7 -0
- package/dist/tools/shared/scan-types.js.map +1 -0
- package/dist/tools/suggest-improvements.d.ts +96 -0
- package/dist/tools/suggest-improvements.d.ts.map +1 -0
- package/dist/tools/suggest-improvements.js +182 -0
- package/dist/tools/suggest-improvements.js.map +1 -0
- package/dist/tools/transform-code-batch.d.ts +57 -0
- package/dist/tools/transform-code-batch.d.ts.map +1 -0
- package/dist/tools/transform-code-batch.js +107 -0
- package/dist/tools/transform-code-batch.js.map +1 -0
- package/dist/tools/transform-code.d.ts +352 -0
- package/dist/tools/transform-code.d.ts.map +1 -0
- package/dist/tools/transform-code.js +1171 -0
- package/dist/tools/transform-code.js.map +1 -0
- package/dist/tools/validate-before-transform.d.ts +54 -0
- package/dist/tools/validate-before-transform.d.ts.map +1 -0
- package/dist/tools/validate-before-transform.js +141 -0
- package/dist/tools/validate-before-transform.js.map +1 -0
- package/dist/tools/validate-project-compatibility.d.ts +119 -0
- package/dist/tools/validate-project-compatibility.d.ts.map +1 -0
- package/dist/tools/validate-project-compatibility.js +243 -0
- package/dist/tools/validate-project-compatibility.js.map +1 -0
- package/dist/tools/validate-transformation.d.ts +105 -0
- package/dist/tools/validate-transformation.d.ts.map +1 -0
- package/dist/tools/validate-transformation.js +391 -0
- package/dist/tools/validate-transformation.js.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +38 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format-tool-response.d.ts +72 -0
- package/dist/utils/format-tool-response.d.ts.map +1 -0
- package/dist/utils/format-tool-response.js +149 -0
- package/dist/utils/format-tool-response.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Comprehensive Scan Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for comprehensive scanning with all plugins:
|
|
5
|
+
* - SolidPlugin (5 rules): SOLID principles
|
|
6
|
+
* - AngularPlugin (17 rules): Angular best practices
|
|
7
|
+
* - ArchitecturePlugin (13 rules): Architectural issues
|
|
8
|
+
* Total: 35 rules
|
|
9
|
+
*/
|
|
10
|
+
import type { MCPTool } from '../types.js';
|
|
11
|
+
interface ScanAllResult {
|
|
12
|
+
violations: {
|
|
13
|
+
id: string;
|
|
14
|
+
ruleId: string;
|
|
15
|
+
severity: 'error' | 'warning' | 'info';
|
|
16
|
+
message: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
line?: number;
|
|
19
|
+
column?: number;
|
|
20
|
+
category: string;
|
|
21
|
+
suggestedFix?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}[];
|
|
24
|
+
summary: {
|
|
25
|
+
totalViolations: number;
|
|
26
|
+
analyzedFiles: number;
|
|
27
|
+
bySeverity: Record<string, number>;
|
|
28
|
+
byCategory: Record<string, number>;
|
|
29
|
+
byRule: Record<string, number>;
|
|
30
|
+
};
|
|
31
|
+
metadata: {
|
|
32
|
+
rulesExecuted: string[];
|
|
33
|
+
duration: number;
|
|
34
|
+
projectRoot: string;
|
|
35
|
+
cacheStats?: {
|
|
36
|
+
totalFilesChecked: number;
|
|
37
|
+
filesFromCache: number;
|
|
38
|
+
filesToProcess: number;
|
|
39
|
+
hitRate: number;
|
|
40
|
+
hitsBySource: Record<string, number>;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
cache?: {
|
|
44
|
+
totalFilesChecked: number;
|
|
45
|
+
filesFromCache: number;
|
|
46
|
+
filesToProcess: number;
|
|
47
|
+
hitRate: number;
|
|
48
|
+
hitsBySource: Record<string, number>;
|
|
49
|
+
stats: {
|
|
50
|
+
totalEntries: number;
|
|
51
|
+
totalSize: number;
|
|
52
|
+
hits: number;
|
|
53
|
+
misses: number;
|
|
54
|
+
hitRate: number;
|
|
55
|
+
entriesByType: {
|
|
56
|
+
ast: number;
|
|
57
|
+
analysis: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
orchestration?: {
|
|
62
|
+
parallel: boolean;
|
|
63
|
+
incremental: boolean;
|
|
64
|
+
filesAnalyzed: number;
|
|
65
|
+
filesSkipped: number;
|
|
66
|
+
cacheHitRate: number;
|
|
67
|
+
duration: number;
|
|
68
|
+
throughput: number;
|
|
69
|
+
};
|
|
70
|
+
pagination?: {
|
|
71
|
+
totalResults: number;
|
|
72
|
+
returnedResults: number;
|
|
73
|
+
offset: number;
|
|
74
|
+
hasMore: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Comprehensive scan with all available plugins (35 rules total).
|
|
79
|
+
*/
|
|
80
|
+
export declare class ScanAllTool implements MCPTool {
|
|
81
|
+
readonly name = "scan-all";
|
|
82
|
+
readonly description = "Comprehensive code quality scan with all plugins (SOLID, Angular, Architecture - 35 rules total)";
|
|
83
|
+
readonly inputSchema: {
|
|
84
|
+
type: string;
|
|
85
|
+
properties: {
|
|
86
|
+
rootPath: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
rules: {
|
|
91
|
+
type: string;
|
|
92
|
+
items: {
|
|
93
|
+
type: string;
|
|
94
|
+
};
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
includePatterns: {
|
|
98
|
+
type: string;
|
|
99
|
+
items: {
|
|
100
|
+
type: string;
|
|
101
|
+
};
|
|
102
|
+
description: string;
|
|
103
|
+
default: string[];
|
|
104
|
+
};
|
|
105
|
+
excludePatterns: {
|
|
106
|
+
type: string;
|
|
107
|
+
items: {
|
|
108
|
+
type: string;
|
|
109
|
+
};
|
|
110
|
+
description: string;
|
|
111
|
+
default: string[];
|
|
112
|
+
};
|
|
113
|
+
includeAutoFixes: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
default: boolean;
|
|
117
|
+
};
|
|
118
|
+
maxFiles: {
|
|
119
|
+
type: string;
|
|
120
|
+
description: string;
|
|
121
|
+
default: number;
|
|
122
|
+
};
|
|
123
|
+
maxResults: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
default: number;
|
|
127
|
+
};
|
|
128
|
+
resultOffset: {
|
|
129
|
+
type: string;
|
|
130
|
+
description: string;
|
|
131
|
+
default: number;
|
|
132
|
+
};
|
|
133
|
+
orchestration: {
|
|
134
|
+
type: string;
|
|
135
|
+
description: string;
|
|
136
|
+
properties: {
|
|
137
|
+
parallel: {
|
|
138
|
+
type: string;
|
|
139
|
+
description: string;
|
|
140
|
+
default: boolean;
|
|
141
|
+
};
|
|
142
|
+
maxWorkers: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
required: string[];
|
|
150
|
+
};
|
|
151
|
+
execute(args: Record<string, unknown>): Promise<ScanAllResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Load scan-all tool configuration from .angular-modernizer.json file.
|
|
154
|
+
* Only loads from the provided root path to avoid cache directory issues.
|
|
155
|
+
*/
|
|
156
|
+
private loadConfig;
|
|
157
|
+
private calculateSummary;
|
|
158
|
+
}
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=scan-all.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-all.d.ts","sourceRoot":"","sources":["../../src/tools/scan-all.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Comprehensive Scan Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for comprehensive scanning with all plugins:
|
|
5
|
+
* - SolidPlugin (5 rules): SOLID principles
|
|
6
|
+
* - AngularPlugin (17 rules): Angular best practices
|
|
7
|
+
* - ArchitecturePlugin (13 rules): Architectural issues
|
|
8
|
+
* Total: 35 rules
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
12
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
13
|
+
import { Kernel, MultiCacheFallbackManager, RealFileSystemAdapter, createToolCacheConfig, createMultiCacheConfig, loadConfig, } from '@angular-modernizer/core';
|
|
14
|
+
import { SolidPlugin } from '@angular-modernizer/plugin-solid';
|
|
15
|
+
import { AngularPlugin } from '@angular-modernizer/plugin-angular';
|
|
16
|
+
import { ArchitecturePlugin } from '@angular-modernizer/plugin-architecture';
|
|
17
|
+
import { ContextFactory } from '@angular-modernizer/plugin-system';
|
|
18
|
+
import { createPublicApi } from '@angular-modernizer/api';
|
|
19
|
+
import { glob } from 'glob';
|
|
20
|
+
import { relative } from 'node:path';
|
|
21
|
+
/**
|
|
22
|
+
* Comprehensive scan with all available plugins (35 rules total).
|
|
23
|
+
*/
|
|
24
|
+
export class ScanAllTool {
|
|
25
|
+
name = 'scan-all';
|
|
26
|
+
description = 'Comprehensive code quality scan with all plugins (SOLID, Angular, Architecture - 35 rules total)';
|
|
27
|
+
inputSchema = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
rootPath: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Root path of the project to scan',
|
|
33
|
+
},
|
|
34
|
+
rules: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
items: { type: 'string' },
|
|
37
|
+
description: 'Specific rules to run (optional, runs all 35 if not specified)',
|
|
38
|
+
},
|
|
39
|
+
includePatterns: {
|
|
40
|
+
type: 'array',
|
|
41
|
+
items: { type: 'string' },
|
|
42
|
+
description: 'File patterns to include',
|
|
43
|
+
default: ['**/*.{ts,tsx}'],
|
|
44
|
+
},
|
|
45
|
+
excludePatterns: {
|
|
46
|
+
type: 'array',
|
|
47
|
+
items: { type: 'string' },
|
|
48
|
+
description: 'File patterns to exclude',
|
|
49
|
+
default: [
|
|
50
|
+
'**/node_modules/**',
|
|
51
|
+
'**/dist/**',
|
|
52
|
+
'**/build/**',
|
|
53
|
+
'**/coverage/**',
|
|
54
|
+
'**/e2e/**',
|
|
55
|
+
'**/.*/**',
|
|
56
|
+
'**/*.spec.ts',
|
|
57
|
+
'**/*.test.ts',
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
includeAutoFixes: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
description: 'Whether to include auto-fix suggestions',
|
|
63
|
+
default: true,
|
|
64
|
+
},
|
|
65
|
+
maxFiles: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
description: 'Batch size for processing files (default: 100 to prevent memory issues)',
|
|
68
|
+
default: 100,
|
|
69
|
+
},
|
|
70
|
+
maxResults: {
|
|
71
|
+
type: 'number',
|
|
72
|
+
description: 'Maximum number of violations to return',
|
|
73
|
+
default: 1000,
|
|
74
|
+
},
|
|
75
|
+
resultOffset: {
|
|
76
|
+
type: 'number',
|
|
77
|
+
description: 'Offset for result pagination',
|
|
78
|
+
default: 0,
|
|
79
|
+
},
|
|
80
|
+
orchestration: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
description: 'Advanced orchestration options',
|
|
83
|
+
properties: {
|
|
84
|
+
parallel: {
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
description: 'Enable parallel rule execution',
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
maxWorkers: {
|
|
90
|
+
type: 'number',
|
|
91
|
+
description: 'Maximum concurrent workers',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
required: ['rootPath'],
|
|
97
|
+
};
|
|
98
|
+
async execute(args) {
|
|
99
|
+
const params = args;
|
|
100
|
+
const config = this.loadConfig(params.rootPath);
|
|
101
|
+
const mergedParams = { ...config, ...params };
|
|
102
|
+
const orchestration = mergedParams.orchestration ?? {};
|
|
103
|
+
if (!mergedParams.rootPath) {
|
|
104
|
+
throw new Error('rootPath is required');
|
|
105
|
+
}
|
|
106
|
+
const startTime = Date.now();
|
|
107
|
+
const tsConfigPath = findTsConfig(mergedParams.rootPath);
|
|
108
|
+
if (!tsConfigPath) {
|
|
109
|
+
throw new Error('Could not find tsconfig.json');
|
|
110
|
+
}
|
|
111
|
+
// Initialize kernel with all plugins and caching
|
|
112
|
+
// IMPORTANT: skipAddingFilesFromTsConfig prevents loading dist/, e2e/, etc.
|
|
113
|
+
const kernel = new Kernel({
|
|
114
|
+
tsConfigPath,
|
|
115
|
+
plugins: [
|
|
116
|
+
new SolidPlugin(),
|
|
117
|
+
new AngularPlugin(),
|
|
118
|
+
new ArchitecturePlugin(),
|
|
119
|
+
],
|
|
120
|
+
fileSystem: undefined,
|
|
121
|
+
projectOptions: {
|
|
122
|
+
skipAddingFilesFromTsConfig: true, // We'll add filtered files manually
|
|
123
|
+
},
|
|
124
|
+
cacheConfig: createToolCacheConfig(mergedParams.rootPath, 'all'),
|
|
125
|
+
});
|
|
126
|
+
// Find files to analyze
|
|
127
|
+
const includePatterns = mergedParams.includePatterns ?? ['**/*.{ts,tsx}'];
|
|
128
|
+
const excludePatterns = mergedParams.excludePatterns ?? [
|
|
129
|
+
'**/node_modules/**',
|
|
130
|
+
'**/dist/**',
|
|
131
|
+
'**/build/**',
|
|
132
|
+
'**/coverage/**',
|
|
133
|
+
'**/e2e/**',
|
|
134
|
+
'**/.*/**',
|
|
135
|
+
'**/*.spec.ts',
|
|
136
|
+
'**/*.test.ts',
|
|
137
|
+
];
|
|
138
|
+
const allFiles = [];
|
|
139
|
+
for (const pattern of includePatterns) {
|
|
140
|
+
const files = await glob(pattern, {
|
|
141
|
+
cwd: mergedParams.rootPath,
|
|
142
|
+
absolute: true,
|
|
143
|
+
ignore: excludePatterns,
|
|
144
|
+
});
|
|
145
|
+
allFiles.push(...files);
|
|
146
|
+
}
|
|
147
|
+
const uniqueFiles = Array.from(new Set(allFiles));
|
|
148
|
+
const filesToAnalyze = uniqueFiles; // Analyze ALL files found (batch processing prevents memory issues)
|
|
149
|
+
const maxFiles = mergedParams.maxFiles ?? 100; // Batch size (default 100)
|
|
150
|
+
// Initialize kernel
|
|
151
|
+
await kernel.initialize();
|
|
152
|
+
// Reuse the already-initialized plugin instances from the kernel so that
|
|
153
|
+
// ruleConfigs loaded from .angular-modernizer.json are applied correctly.
|
|
154
|
+
const allRules = kernel
|
|
155
|
+
.getAllPlugins()
|
|
156
|
+
.flatMap((p) => p.getAnalysisRules());
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// CROSS-CACHE READ SYSTEM (UNIDIRECTIONAL)
|
|
159
|
+
// ============================================================================
|
|
160
|
+
// Before analyzing files, check if cached results exist in ANY cache directory.
|
|
161
|
+
// This provides massive token savings when running scan-all after individual scans.
|
|
162
|
+
//
|
|
163
|
+
// Cache read order (first cache wins):
|
|
164
|
+
// 1. .angular-modernizer-cache/all/ (primary cache for scan-all)
|
|
165
|
+
// 2. .angular-modernizer-cache/solid/ (fallback to SOLID scan cache)
|
|
166
|
+
// 3. .angular-modernizer-cache/angular/ (fallback to Angular scan cache)
|
|
167
|
+
// 4. .angular-modernizer-cache/architecture/ (fallback to Architecture scan cache)
|
|
168
|
+
//
|
|
169
|
+
// Performance benefits (Phase 3):
|
|
170
|
+
// - Before: scan-solid (63s) + scan-architecture (203s) + scan-all (360s) = 626s
|
|
171
|
+
// - After: scan-solid (63s) + scan-architecture (203s) + scan-all (~5s) = 271s
|
|
172
|
+
// - Savings: 355 seconds (57% time reduction)
|
|
173
|
+
//
|
|
174
|
+
// Performance (when only scan-all cache exists):
|
|
175
|
+
// - First run: 359.8s (analyzes all files, writes cache)
|
|
176
|
+
// - Second run: 24.2s (14.9x speedup, 93.3% faster, reads from cache)
|
|
177
|
+
//
|
|
178
|
+
// UNIDIRECTIONAL: Only scan-all reads from individual caches, not vice versa.
|
|
179
|
+
// Individual scans remain independent and focused on their specific rule categories.
|
|
180
|
+
// ============================================================================
|
|
181
|
+
const fileSystem = new RealFileSystemAdapter();
|
|
182
|
+
const multiCacheManager = new MultiCacheFallbackManager(fileSystem, ['all', 'solid', 'angular', 'architecture'], // Check in this order
|
|
183
|
+
createMultiCacheConfig(mergedParams.rootPath));
|
|
184
|
+
await multiCacheManager.initialize();
|
|
185
|
+
// Load rules config from .angular-modernizer.json for per-rule overrides (BUG-3)
|
|
186
|
+
const fullConfig = loadConfig(mergedParams.rootPath);
|
|
187
|
+
const rulesConfig = fullConfig.rules;
|
|
188
|
+
const cachedResults = []; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
189
|
+
const filesToProcess = [];
|
|
190
|
+
const cacheHitsBySource = {};
|
|
191
|
+
for (const filePath of filesToAnalyze) {
|
|
192
|
+
const cached = await multiCacheManager.getAnalysisResult(filePath);
|
|
193
|
+
if (cached?.results && cached.results.length > 0) {
|
|
194
|
+
// File is cached in one of the cache directories
|
|
195
|
+
cachedResults.push(...cached.results);
|
|
196
|
+
// Track which cache was used for logging
|
|
197
|
+
const source = cached.source ?? 'unknown';
|
|
198
|
+
cacheHitsBySource[source] = (cacheHitsBySource[source] ?? 0) + 1;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
// File not cached in any directory or has changed
|
|
202
|
+
filesToProcess.push(filePath);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const stats = multiCacheManager.getStats();
|
|
206
|
+
console.info(`Cache: ${cachedResults.length} results from cache, ${filesToProcess.length} files to analyze (hit rate: ${stats.hitRate.toFixed(1)}%)`);
|
|
207
|
+
// Show cache hit breakdown by source (Phase 3 feature)
|
|
208
|
+
if (Object.keys(cacheHitsBySource).length > 0) {
|
|
209
|
+
console.info(`Cache hits by source:`);
|
|
210
|
+
for (const [source, count] of Object.entries(cacheHitsBySource)) {
|
|
211
|
+
console.info(` - ${source}: ${count} file(s)`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// ============================================================================
|
|
215
|
+
// BATCH PROCESSING SYSTEM
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Process files in chunks (batches) to prevent memory exhaustion on large codebases.
|
|
218
|
+
// Same implementation as scan-solid.ts - see that file for detailed explanation.
|
|
219
|
+
//
|
|
220
|
+
// Key points for scan-all:
|
|
221
|
+
// - Runs 35 total rules (SOLID + Angular + Architecture combined)
|
|
222
|
+
// - Highest memory pressure of all scan tools
|
|
223
|
+
// - Batch size of 100 is critical for stability
|
|
224
|
+
// - Longest analysis time but also biggest cache speedup (14.9x)
|
|
225
|
+
// ============================================================================
|
|
226
|
+
const batchSize = maxFiles;
|
|
227
|
+
const totalFiles = filesToProcess.length;
|
|
228
|
+
const totalBatches = Math.ceil(totalFiles / batchSize);
|
|
229
|
+
console.info(`\nProcessing ${totalFiles} files in ${totalBatches} batch(es) of ${batchSize} files each`);
|
|
230
|
+
// Separate arrays for two concerns:
|
|
231
|
+
// - allResultsForCache: all violations from newly-analyzed files (needed for cache writes)
|
|
232
|
+
// - results: violations from cache + in-window violations from new files (bounded, for return)
|
|
233
|
+
// PERF-1: heap is bounded because results only grows up to offset+maxResults entries.
|
|
234
|
+
const paginationOffset = mergedParams.resultOffset ?? 0;
|
|
235
|
+
const paginationLimit = mergedParams.maxResults ?? 1000;
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
const allResultsForCache = [];
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
+
const results = [...cachedResults];
|
|
240
|
+
let filesAnalyzed = cachedResults.length;
|
|
241
|
+
// Running count of valid violations seen (cached + newly analyzed).
|
|
242
|
+
let totalViolationCount = cachedResults.filter((r) => r['ruleId'] && r['filePath']).length;
|
|
243
|
+
// Process each batch
|
|
244
|
+
for (let batchNum = 0; batchNum < totalBatches; batchNum++) {
|
|
245
|
+
const batchStart = batchNum * batchSize;
|
|
246
|
+
const batchEnd = Math.min(batchStart + batchSize, totalFiles);
|
|
247
|
+
const batchFiles = filesToProcess.slice(batchStart, batchEnd);
|
|
248
|
+
console.info(`\nBatch ${batchNum + 1}/${totalBatches}: Processing files ${batchStart + 1}-${batchEnd} (${batchFiles.length} files)`);
|
|
249
|
+
// Clear project and add batch files
|
|
250
|
+
const project = kernel.getProject();
|
|
251
|
+
// Remove all source files from previous batch
|
|
252
|
+
const existingFiles = project.getSourceFiles();
|
|
253
|
+
for (const file of existingFiles) {
|
|
254
|
+
project.removeSourceFile(file);
|
|
255
|
+
}
|
|
256
|
+
// Add current batch files
|
|
257
|
+
for (const filePath of batchFiles) {
|
|
258
|
+
try {
|
|
259
|
+
project.addSourceFileAtPath(filePath);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
console.warn(`Failed to add file ${filePath}:`, error);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
console.info(`Batch ${batchNum + 1}: Project now has ${project.getSourceFiles().length} source files`);
|
|
266
|
+
// Create PublicApi for this batch
|
|
267
|
+
const api = createPublicApi(project); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
268
|
+
// Analyze files in this batch
|
|
269
|
+
let batchViolationCount = 0;
|
|
270
|
+
for (const sourceFile of project.getSourceFiles()) {
|
|
271
|
+
for (const rule of allRules) {
|
|
272
|
+
try {
|
|
273
|
+
const ruleResults = await rule.analyze(ContextFactory.createAnalysisContext({
|
|
274
|
+
sourceFile,
|
|
275
|
+
project,
|
|
276
|
+
api,
|
|
277
|
+
config: rulesConfig,
|
|
278
|
+
}));
|
|
279
|
+
for (const result of ruleResults) {
|
|
280
|
+
const entry = {
|
|
281
|
+
ruleId: result.ruleId,
|
|
282
|
+
severity: rule.severity,
|
|
283
|
+
message: result.message,
|
|
284
|
+
filePath: result.filePath,
|
|
285
|
+
line: result.line,
|
|
286
|
+
column: result.column,
|
|
287
|
+
category: rule.category,
|
|
288
|
+
suggestedFix: result.suggestedFix,
|
|
289
|
+
metadata: result.metadata,
|
|
290
|
+
};
|
|
291
|
+
// Always accumulate for cache writes.
|
|
292
|
+
allResultsForCache.push(entry);
|
|
293
|
+
// Only store in the paginated return array if inside the requested window.
|
|
294
|
+
totalViolationCount++;
|
|
295
|
+
if (totalViolationCount > paginationOffset &&
|
|
296
|
+
results.length < paginationOffset + paginationLimit) {
|
|
297
|
+
results.push(entry);
|
|
298
|
+
}
|
|
299
|
+
batchViolationCount++;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.warn(`Failed to analyze with rule ${rule.id}:`, error);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
filesAnalyzed += batchFiles.length;
|
|
308
|
+
console.info(`Batch ${batchNum + 1}: Found ${batchViolationCount} violations in ${batchFiles.length} files`);
|
|
309
|
+
}
|
|
310
|
+
console.info(`\nBatch processing complete: ${totalBatches} batch(es), ${filesAnalyzed} total files analyzed, ${totalViolationCount} total violations`);
|
|
311
|
+
// ============================================================================
|
|
312
|
+
// CACHE WRITE SYSTEM (Enhanced with MultiCacheFallbackManager)
|
|
313
|
+
// ============================================================================
|
|
314
|
+
// After analyzing all files, write results to cache for future runs.
|
|
315
|
+
// This enables cache reads to skip unchanged files on subsequent runs.
|
|
316
|
+
//
|
|
317
|
+
// Cache write behavior:
|
|
318
|
+
// - Writes ONLY to primary cache (.angular-modernizer-cache/all/)
|
|
319
|
+
// - Does NOT write to fallback caches (solid, angular, architecture)
|
|
320
|
+
// - Individual scans remain authoritative for their own caches
|
|
321
|
+
//
|
|
322
|
+
// Cache entry format: Same as scan-solid (metadata + results[] + dependencies)
|
|
323
|
+
//
|
|
324
|
+
// Performance impact:
|
|
325
|
+
// - First run: Writes cache (adds ~1-2% overhead)
|
|
326
|
+
// - Second run: Reads cache (14.9x speedup - best overall improvement!)
|
|
327
|
+
//
|
|
328
|
+
// Why scan-all benefits most from caching:
|
|
329
|
+
// - Runs 35 total rules (SOLID + Angular + Architecture)
|
|
330
|
+
// - Each file analyzed with ALL rules = most expensive analysis
|
|
331
|
+
// - Cache hit eliminates analysis for ALL 35 rules per file
|
|
332
|
+
// - 93.3% time saved on second run (359.8s → 24.2s)
|
|
333
|
+
//
|
|
334
|
+
// Enhancement: Cache can now be read from individual tool caches
|
|
335
|
+
// when running scan-all after individual scans (57% time reduction overall).
|
|
336
|
+
// ============================================================================
|
|
337
|
+
// Group newly-analyzed results by file path for cache writes.
|
|
338
|
+
const resultsByFile = new Map();
|
|
339
|
+
for (const result of allResultsForCache) {
|
|
340
|
+
const filePath = result.filePath;
|
|
341
|
+
if (!resultsByFile.has(filePath)) {
|
|
342
|
+
resultsByFile.set(filePath, []);
|
|
343
|
+
}
|
|
344
|
+
resultsByFile.get(filePath).push(result);
|
|
345
|
+
}
|
|
346
|
+
// Write each file's results to PRIMARY cache only (multiCacheManager writes to first cache)
|
|
347
|
+
for (const [filePath, fileResults] of resultsByFile.entries()) {
|
|
348
|
+
await multiCacheManager.setAnalysisResult(filePath, fileResults);
|
|
349
|
+
}
|
|
350
|
+
// Log cache effectiveness
|
|
351
|
+
const writeStats = multiCacheManager.getStats();
|
|
352
|
+
console.info(`Cached ${resultsByFile.size} files to primary cache (hit rate: ${writeStats.hitRate.toFixed(1)}%)`);
|
|
353
|
+
// results[] is already bounded to the pagination window (PERF-1).
|
|
354
|
+
// Apply rule filter and map for the MCP response.
|
|
355
|
+
let paginatedViolations = results
|
|
356
|
+
.filter((r) => r.ruleId && r.filePath)
|
|
357
|
+
.map((r, index) => ({
|
|
358
|
+
id: `all-${index}`,
|
|
359
|
+
ruleId: r.ruleId,
|
|
360
|
+
severity: r.severity,
|
|
361
|
+
message: r.message,
|
|
362
|
+
filePath: relative(mergedParams.rootPath, r.filePath),
|
|
363
|
+
line: r.line,
|
|
364
|
+
column: r.column,
|
|
365
|
+
category: r.category ?? 'General',
|
|
366
|
+
suggestedFix: mergedParams.includeAutoFixes
|
|
367
|
+
? r.suggestedFix
|
|
368
|
+
: undefined,
|
|
369
|
+
metadata: r.metadata,
|
|
370
|
+
}));
|
|
371
|
+
if (mergedParams.rules?.length) {
|
|
372
|
+
paginatedViolations = paginatedViolations.filter((v) => mergedParams.rules.includes(v.ruleId));
|
|
373
|
+
}
|
|
374
|
+
const offset = paginationOffset;
|
|
375
|
+
const maxResults = paginationLimit;
|
|
376
|
+
// totalViolationCount tracks all violations seen; use it for accurate pagination metadata.
|
|
377
|
+
const totalViolations = totalViolationCount;
|
|
378
|
+
// Calculate summary
|
|
379
|
+
const summary = this.calculateSummary(paginatedViolations, filesToAnalyze.length);
|
|
380
|
+
const duration = Date.now() - startTime;
|
|
381
|
+
// Get all rule IDs from the rules we executed
|
|
382
|
+
const allRuleIds = allRules.map((r) => r.id);
|
|
383
|
+
// Get final cache statistics (Phase 3)
|
|
384
|
+
const finalStats = multiCacheManager.getStats();
|
|
385
|
+
return {
|
|
386
|
+
violations: paginatedViolations,
|
|
387
|
+
summary,
|
|
388
|
+
metadata: {
|
|
389
|
+
rulesExecuted: allRuleIds,
|
|
390
|
+
duration,
|
|
391
|
+
projectRoot: mergedParams.rootPath,
|
|
392
|
+
// Add cache stats to metadata for visibility
|
|
393
|
+
cacheStats: {
|
|
394
|
+
totalFilesChecked: filesToAnalyze.length,
|
|
395
|
+
filesFromCache: cachedResults.length,
|
|
396
|
+
filesToProcess: filesToProcess.length,
|
|
397
|
+
hitRate: finalStats.hitRate,
|
|
398
|
+
hitsBySource: cacheHitsBySource,
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
// Cache statistics with source breakdown
|
|
402
|
+
//
|
|
403
|
+
// IMPORTANT: Understanding cache statistics
|
|
404
|
+
// ==========================================
|
|
405
|
+
// - hitRate: Shows PRIMARY cache hit rate (first cache directory: /all/)
|
|
406
|
+
// - hitsBySource: Shows FALLBACK cache hits (solid/angular/architecture)
|
|
407
|
+
//
|
|
408
|
+
// Why hitRate can be 0% while hitsBySource has values:
|
|
409
|
+
// - If /all/ cache is deleted/empty, hitRate = 0% (primary cache empty)
|
|
410
|
+
// - But fallback caches (solid/angular/architecture) can provide cached results
|
|
411
|
+
// - hitsBySource tracks which fallback caches were used
|
|
412
|
+
//
|
|
413
|
+
// Example Test 3 scenario:
|
|
414
|
+
// - Delete /all/ cache → hitRate: 0% (primary cache empty)
|
|
415
|
+
// - But hitsBySource: {"solid": 630, "architecture": 10} (640 fallback hits!)
|
|
416
|
+
// - Result: Only 2,118 files analyzed (not 2,758) = Phase 3 working! ✅
|
|
417
|
+
//
|
|
418
|
+
// This is CORRECT Phase 3 behavior - fallback system saved 640 file analyses.
|
|
419
|
+
cache: {
|
|
420
|
+
totalFilesChecked: filesToAnalyze.length,
|
|
421
|
+
filesFromCache: cachedResults.length,
|
|
422
|
+
filesToProcess: filesToProcess.length,
|
|
423
|
+
hitRate: finalStats.hitRate,
|
|
424
|
+
hitsBySource: cacheHitsBySource,
|
|
425
|
+
stats: finalStats,
|
|
426
|
+
},
|
|
427
|
+
orchestration: orchestration.useWorkerThreads
|
|
428
|
+
? {
|
|
429
|
+
parallel: true,
|
|
430
|
+
incremental: false,
|
|
431
|
+
filesAnalyzed: filesToAnalyze.length,
|
|
432
|
+
filesSkipped: 0,
|
|
433
|
+
cacheHitRate: finalStats.hitRate,
|
|
434
|
+
duration,
|
|
435
|
+
throughput: filesToAnalyze.length / (duration / 1000),
|
|
436
|
+
}
|
|
437
|
+
: undefined,
|
|
438
|
+
pagination: {
|
|
439
|
+
totalResults: totalViolations,
|
|
440
|
+
returnedResults: paginatedViolations.length,
|
|
441
|
+
offset,
|
|
442
|
+
hasMore: offset + maxResults < totalViolations,
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Load scan-all tool configuration from .angular-modernizer.json file.
|
|
448
|
+
* Only loads from the provided root path to avoid cache directory issues.
|
|
449
|
+
*/
|
|
450
|
+
loadConfig(rootPath) {
|
|
451
|
+
if (!rootPath) {
|
|
452
|
+
return {};
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
const fullConfig = loadConfig(rootPath);
|
|
456
|
+
const scanAllConfig = fullConfig.tools?.['scan-all'];
|
|
457
|
+
if (scanAllConfig && typeof scanAllConfig === 'object') {
|
|
458
|
+
return scanAllConfig;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
console.warn(`Error loading config:`, error);
|
|
463
|
+
}
|
|
464
|
+
return {};
|
|
465
|
+
}
|
|
466
|
+
calculateSummary(violations, analyzedFiles) {
|
|
467
|
+
const bySeverity = {};
|
|
468
|
+
const byCategory = {};
|
|
469
|
+
const byRule = {};
|
|
470
|
+
for (const violation of violations) {
|
|
471
|
+
bySeverity[violation.severity] =
|
|
472
|
+
(bySeverity[violation.severity] ?? 0) + 1;
|
|
473
|
+
byCategory[violation.category] =
|
|
474
|
+
(byCategory[violation.category] ?? 0) + 1;
|
|
475
|
+
byRule[violation.ruleId] = (byRule[violation.ruleId] ?? 0) + 1;
|
|
476
|
+
}
|
|
477
|
+
return {
|
|
478
|
+
totalViolations: violations.length,
|
|
479
|
+
analyzedFiles,
|
|
480
|
+
bySeverity,
|
|
481
|
+
byCategory,
|
|
482
|
+
byRule,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
//# sourceMappingURL=scan-all.js.map
|