@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,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Progress Store
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Thread-safe singleton store for streaming operation progress
|
|
6
|
+
* Provides TTL-based cleanup and efficient event querying
|
|
7
|
+
*/
|
|
8
|
+
export class ProgressStore {
|
|
9
|
+
static instance = null;
|
|
10
|
+
operations = new Map();
|
|
11
|
+
ttlMs;
|
|
12
|
+
cleanupTimer = null;
|
|
13
|
+
/** TTL for running operations before they are considered timed-out (default: 10 minutes). */
|
|
14
|
+
runningTtlMs;
|
|
15
|
+
constructor(ttlMs = 5 * 60 * 1000, runningTtlMs = 10 * 60 * 1000) {
|
|
16
|
+
this.ttlMs = ttlMs;
|
|
17
|
+
this.runningTtlMs = runningTtlMs;
|
|
18
|
+
this.startCleanupTimer();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get singleton instance
|
|
22
|
+
*/
|
|
23
|
+
static getInstance() {
|
|
24
|
+
ProgressStore.instance ??= new ProgressStore();
|
|
25
|
+
return ProgressStore.instance;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reset singleton instance (for testing)
|
|
29
|
+
*/
|
|
30
|
+
static resetInstance() {
|
|
31
|
+
if (ProgressStore.instance?.cleanupTimer) {
|
|
32
|
+
clearInterval(ProgressStore.instance.cleanupTimer);
|
|
33
|
+
}
|
|
34
|
+
ProgressStore.instance = null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a new operation
|
|
38
|
+
*/
|
|
39
|
+
createOperation(operationId, metadata) {
|
|
40
|
+
this.operations.set(operationId, {
|
|
41
|
+
metadata: { ...metadata, status: 'running' },
|
|
42
|
+
events: [],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add progress event to operation
|
|
47
|
+
*/
|
|
48
|
+
addEvent(operationId, event) {
|
|
49
|
+
const operation = this.operations.get(operationId);
|
|
50
|
+
if (!operation) {
|
|
51
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
52
|
+
}
|
|
53
|
+
operation.events.push(event);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get events for operation, optionally filtering by timestamp
|
|
57
|
+
*/
|
|
58
|
+
getEvents(operationId, sinceTimestamp) {
|
|
59
|
+
const operation = this.operations.get(operationId);
|
|
60
|
+
if (!operation) {
|
|
61
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
62
|
+
}
|
|
63
|
+
if (sinceTimestamp === undefined) {
|
|
64
|
+
return [...operation.events];
|
|
65
|
+
}
|
|
66
|
+
return operation.events.filter((event) => event.timestamp >= sinceTimestamp);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get operation metadata
|
|
70
|
+
*/
|
|
71
|
+
getMetadata(operationId) {
|
|
72
|
+
const operation = this.operations.get(operationId);
|
|
73
|
+
if (!operation) {
|
|
74
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
75
|
+
}
|
|
76
|
+
return operation.metadata;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Mark operation as complete
|
|
80
|
+
*/
|
|
81
|
+
markComplete(operationId) {
|
|
82
|
+
const operation = this.operations.get(operationId);
|
|
83
|
+
if (!operation) {
|
|
84
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
85
|
+
}
|
|
86
|
+
operation.metadata.status = 'completed';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Mark operation as failed
|
|
90
|
+
*/
|
|
91
|
+
markFailed(operationId, error) {
|
|
92
|
+
const operation = this.operations.get(operationId);
|
|
93
|
+
if (!operation) {
|
|
94
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
95
|
+
}
|
|
96
|
+
operation.metadata.status = 'failed';
|
|
97
|
+
operation.metadata.error = error;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Store the final result of a completed operation (e.g. violations array).
|
|
101
|
+
* Must be called before markComplete so callers can retrieve it via get-operation-progress.
|
|
102
|
+
*/
|
|
103
|
+
setResult(operationId, result) {
|
|
104
|
+
const operation = this.operations.get(operationId);
|
|
105
|
+
if (!operation) {
|
|
106
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
107
|
+
}
|
|
108
|
+
operation.result = result;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Retrieve the stored result for an operation.
|
|
112
|
+
* Returns undefined if no result has been stored yet.
|
|
113
|
+
*/
|
|
114
|
+
getResult(operationId) {
|
|
115
|
+
const operation = this.operations.get(operationId);
|
|
116
|
+
if (!operation) {
|
|
117
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
118
|
+
}
|
|
119
|
+
return operation.result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Cancel a running operation. No-op if already completed or cancelled.
|
|
123
|
+
*/
|
|
124
|
+
cancelOperation(operationId) {
|
|
125
|
+
const operation = this.operations.get(operationId);
|
|
126
|
+
if (operation?.metadata.status !== 'running') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
operation.metadata.status = 'cancelled';
|
|
130
|
+
operation.metadata.error = 'Cancelled by user';
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Returns true if the operation has been cancelled.
|
|
134
|
+
*/
|
|
135
|
+
isCancelled(operationId) {
|
|
136
|
+
return this.operations.get(operationId)?.metadata.status === 'cancelled';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if operation exists
|
|
140
|
+
*/
|
|
141
|
+
hasOperation(operationId) {
|
|
142
|
+
return this.operations.has(operationId);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get all operation IDs
|
|
146
|
+
*/
|
|
147
|
+
getAllOperationIds() {
|
|
148
|
+
return Array.from(this.operations.keys());
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Delete operation (for cleanup)
|
|
152
|
+
*/
|
|
153
|
+
deleteOperation(operationId) {
|
|
154
|
+
this.operations.delete(operationId);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Start periodic cleanup of expired operations
|
|
158
|
+
*/
|
|
159
|
+
startCleanupTimer() {
|
|
160
|
+
this.cleanupTimer = setInterval(() => {
|
|
161
|
+
this.cleanupExpiredOperations();
|
|
162
|
+
}, 60 * 1000); // Run every minute
|
|
163
|
+
// Don't keep process alive for cleanup timer
|
|
164
|
+
this.cleanupTimer.unref();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Clean up operations that have exceeded TTL.
|
|
168
|
+
* - Running operations older than runningTtlMs (default 10 min) are marked as
|
|
169
|
+
* failed and a synthetic timeout-error event is appended so that a late poll
|
|
170
|
+
* still receives a meaningful failure response (BUG-4).
|
|
171
|
+
* - Completed/failed operations older than ttlMs (default 5 min) are deleted.
|
|
172
|
+
*/
|
|
173
|
+
cleanupExpiredOperations() {
|
|
174
|
+
const now = Date.now();
|
|
175
|
+
const expiredIds = [];
|
|
176
|
+
for (const [operationId, operation] of this.operations.entries()) {
|
|
177
|
+
const age = now - operation.metadata.startTime;
|
|
178
|
+
const isCompleted = operation.metadata.status === 'completed' ||
|
|
179
|
+
operation.metadata.status === 'failed' ||
|
|
180
|
+
operation.metadata.status === 'cancelled';
|
|
181
|
+
if (isCompleted) {
|
|
182
|
+
// Delete completed/failed operations past the short TTL.
|
|
183
|
+
if (age > this.ttlMs) {
|
|
184
|
+
expiredIds.push(operationId);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// Mark still-running operations as failed after the long running TTL.
|
|
189
|
+
if (age > this.runningTtlMs) {
|
|
190
|
+
operation.metadata.status = 'failed';
|
|
191
|
+
operation.metadata.error = `Operation timed out after ${Math.round(age / 1000)}s`;
|
|
192
|
+
operation.events.push({
|
|
193
|
+
phase: 'complete',
|
|
194
|
+
percentage: 100,
|
|
195
|
+
message: `Operation timed out after ${Math.round(age / 1000)}s without completing`,
|
|
196
|
+
timestamp: now,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
for (const operationId of expiredIds) {
|
|
202
|
+
this.operations.delete(operationId);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get store statistics (for monitoring)
|
|
207
|
+
*/
|
|
208
|
+
getStats() {
|
|
209
|
+
let running = 0;
|
|
210
|
+
let completed = 0;
|
|
211
|
+
let failed = 0;
|
|
212
|
+
let cancelled = 0;
|
|
213
|
+
for (const operation of this.operations.values()) {
|
|
214
|
+
switch (operation.metadata.status) {
|
|
215
|
+
case 'running':
|
|
216
|
+
running++;
|
|
217
|
+
break;
|
|
218
|
+
case 'completed':
|
|
219
|
+
completed++;
|
|
220
|
+
break;
|
|
221
|
+
case 'failed':
|
|
222
|
+
failed++;
|
|
223
|
+
break;
|
|
224
|
+
case 'cancelled':
|
|
225
|
+
cancelled++;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
totalOperations: this.operations.size,
|
|
231
|
+
runningOperations: running,
|
|
232
|
+
completedOperations: completed,
|
|
233
|
+
failedOperations: failed,
|
|
234
|
+
cancelledOperations: cancelled,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=progress-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-store.js","sourceRoot":"","sources":["../../src/streaming/progress-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwBH;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAC;IACpC,UAAU,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC/C,KAAK,CAAS;IACvB,YAAY,GAA0B,IAAI,CA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mB,EAAE,SAAS;YAC9B,gBAAgB,EAAE,MAAM;YACxB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Analyze Build Impact Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for analyzing build impact before transformations.
|
|
5
|
+
* Estimates affected files, modules, build time, and provides AI-friendly recommendations.
|
|
6
|
+
* Uses IncrementalAnalyzer for scope calculation, DependencyGraphBuilder for transitive dependents,
|
|
7
|
+
* and AngularModuleDetector for module detection.
|
|
8
|
+
*/
|
|
9
|
+
import { type MCPTool } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Build scope strategy
|
|
12
|
+
*/
|
|
13
|
+
type BuildScopeStrategy = 'affected-only' | 'partial' | 'full';
|
|
14
|
+
/**
|
|
15
|
+
* Estimated build scope information
|
|
16
|
+
*/
|
|
17
|
+
interface EstimatedBuildScope {
|
|
18
|
+
/**
|
|
19
|
+
* Recommended build strategy based on impact
|
|
20
|
+
*/
|
|
21
|
+
strategy: BuildScopeStrategy;
|
|
22
|
+
/**
|
|
23
|
+
* Files that will be directly changed
|
|
24
|
+
*/
|
|
25
|
+
changedFiles: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Files that depend on the changed files (transitive dependents)
|
|
28
|
+
*/
|
|
29
|
+
dependentFiles: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Affected Angular modules
|
|
32
|
+
*/
|
|
33
|
+
affectedModules: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Estimated build time in seconds
|
|
36
|
+
*/
|
|
37
|
+
estimatedBuildTime: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Dependency information for a file
|
|
41
|
+
*/
|
|
42
|
+
interface DependencyInfo {
|
|
43
|
+
/**
|
|
44
|
+
* File path
|
|
45
|
+
*/
|
|
46
|
+
file: string;
|
|
47
|
+
/**
|
|
48
|
+
* Number of files that depend on this file
|
|
49
|
+
*/
|
|
50
|
+
dependents: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether this file is exported from a public API (index.ts)
|
|
53
|
+
*/
|
|
54
|
+
isPublicApi: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Affected Angular module name, if applicable
|
|
57
|
+
*/
|
|
58
|
+
affectedModule?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Output result of build impact analysis.
|
|
62
|
+
*/
|
|
63
|
+
interface AnalyzeBuildImpactOutput {
|
|
64
|
+
/**
|
|
65
|
+
* Estimated build scope with strategy and recommendations
|
|
66
|
+
*/
|
|
67
|
+
estimatedBuildScope: EstimatedBuildScope;
|
|
68
|
+
/**
|
|
69
|
+
* All affected files (changed + dependents)
|
|
70
|
+
*/
|
|
71
|
+
affectedFiles: string[];
|
|
72
|
+
/**
|
|
73
|
+
* Affected Angular module names
|
|
74
|
+
*/
|
|
75
|
+
affectedModules: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Estimated build time in seconds
|
|
78
|
+
*/
|
|
79
|
+
estimatedBuildTime: number;
|
|
80
|
+
/**
|
|
81
|
+
* AI-friendly recommendation
|
|
82
|
+
*/
|
|
83
|
+
recommendation: string;
|
|
84
|
+
/**
|
|
85
|
+
* Detailed dependency information for each changed file
|
|
86
|
+
*/
|
|
87
|
+
dependencies: DependencyInfo[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* MCP tool for analyzing build impact before transformations.
|
|
91
|
+
*/
|
|
92
|
+
export declare class AnalyzeBuildImpactTool implements MCPTool {
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: string;
|
|
97
|
+
properties: {
|
|
98
|
+
projectPath: {
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
};
|
|
102
|
+
filesToChange: {
|
|
103
|
+
type: string;
|
|
104
|
+
items: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
required: string[];
|
|
111
|
+
};
|
|
112
|
+
execute(args: Record<string, unknown>): Promise<AnalyzeBuildImpactOutput>;
|
|
113
|
+
/**
|
|
114
|
+
* Generate AI-friendly recommendation
|
|
115
|
+
*/
|
|
116
|
+
private generateRecommendation;
|
|
117
|
+
/**
|
|
118
|
+
* Check if a file is a public API file (exported from index.ts)
|
|
119
|
+
*/
|
|
120
|
+
private isPublicApiFile;
|
|
121
|
+
/**
|
|
122
|
+
* Get component class name from a source file
|
|
123
|
+
*/
|
|
124
|
+
private getComponentClass;
|
|
125
|
+
}
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=analyze-build-impact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-build-impact.d.ts","sourceRoot":"","sources":["../../src/tools/analyze-build-impact.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAyB3C;;GAEG;AACH,KAAK,kBAAkB,GAAG,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/D;;GAEG;AACH,UAAU,mBAAmB;IAC3B;;OAEG;IACH,QAAQ,EAAE,kBAAkB,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,UAAU,cAAc;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,UAAU,wBAAwB;IAChC;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;IAEzC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,qBAAa,sBAAuB,YAAW,OAAO;IACpD,IAAI,SAA0B;IAC9B,WAAW,SAC6N;IAExO,WAAW;;;;;;;;;;;;;;;;MAiBT;IAEI,OAAO,CACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IA4HpC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAsB9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAkCvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAiB1B"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Analyze Build Impact Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for analyzing build impact before transformations.
|
|
5
|
+
* Estimates affected files, modules, build time, and provides AI-friendly recommendations.
|
|
6
|
+
* Uses IncrementalAnalyzer for scope calculation, DependencyGraphBuilder for transitive dependents,
|
|
7
|
+
* and AngularModuleDetector for module detection.
|
|
8
|
+
*/
|
|
9
|
+
import { Project } from 'ts-morph';
|
|
10
|
+
import { IncrementalAnalyzer, DependencyGraphBuilder, } from '@angular-modernizer/core';
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
/**
|
|
14
|
+
* MCP tool for analyzing build impact before transformations.
|
|
15
|
+
*/
|
|
16
|
+
export class AnalyzeBuildImpactTool {
|
|
17
|
+
name = 'analyze-build-impact';
|
|
18
|
+
description = 'Analyze build impact before transformations. Estimates affected files, transitive dependents, Angular modules, build time, and provides clear recommendations for AI usage. Helps determine if a transformation is safe to proceed.';
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
projectPath: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'Project root path to analyze',
|
|
25
|
+
},
|
|
26
|
+
filesToChange: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
items: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
description: 'Array of file paths that will be changed (relative to project root or absolute)',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ['projectPath', 'filesToChange'],
|
|
35
|
+
};
|
|
36
|
+
async execute(args) {
|
|
37
|
+
const params = args;
|
|
38
|
+
if (!params.projectPath) {
|
|
39
|
+
throw new Error('projectPath is required');
|
|
40
|
+
}
|
|
41
|
+
if (!params.filesToChange || !Array.isArray(params.filesToChange)) {
|
|
42
|
+
throw new Error('filesToChange is required and must be an array');
|
|
43
|
+
}
|
|
44
|
+
const projectPath = params.projectPath;
|
|
45
|
+
const filesToChange = params.filesToChange;
|
|
46
|
+
// Validate project path
|
|
47
|
+
if (!existsSync(projectPath)) {
|
|
48
|
+
throw new Error(`Project path does not exist: ${projectPath}`);
|
|
49
|
+
}
|
|
50
|
+
const tsConfigPath = join(projectPath, 'tsconfig.json');
|
|
51
|
+
if (!existsSync(tsConfigPath)) {
|
|
52
|
+
throw new Error(`tsconfig.json not found in project: ${projectPath}`);
|
|
53
|
+
}
|
|
54
|
+
// Initialize ts-morph project
|
|
55
|
+
const project = new Project({
|
|
56
|
+
tsConfigFilePath: tsConfigPath,
|
|
57
|
+
skipAddingFilesFromTsConfig: false,
|
|
58
|
+
});
|
|
59
|
+
// Normalize file paths to absolute paths
|
|
60
|
+
const normalizedFiles = filesToChange.map((file) => {
|
|
61
|
+
if (file.startsWith('/')) {
|
|
62
|
+
return file;
|
|
63
|
+
}
|
|
64
|
+
return join(projectPath, file);
|
|
65
|
+
});
|
|
66
|
+
// Validate that all files exist in the project
|
|
67
|
+
for (const filePath of normalizedFiles) {
|
|
68
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
69
|
+
if (!sourceFile) {
|
|
70
|
+
throw new Error(`File not found in project: ${filePath}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Create IncrementalAnalyzer and get build scope using core infrastructure
|
|
74
|
+
const incrementalAnalyzer = new IncrementalAnalyzer(project);
|
|
75
|
+
// Simulate changed files by providing forceFiles option
|
|
76
|
+
const buildScope = await incrementalAnalyzer.getBuildScope({
|
|
77
|
+
forceFiles: normalizedFiles,
|
|
78
|
+
});
|
|
79
|
+
// Extract build scope information
|
|
80
|
+
const strategy = buildScope.strategy;
|
|
81
|
+
const dependentFiles = buildScope.dependentFiles;
|
|
82
|
+
const affectedModules = buildScope.affectedModules.map((m) => m.moduleName);
|
|
83
|
+
const estimatedBuildTime = buildScope.estimatedBuildTime;
|
|
84
|
+
// Build dependency graph for detailed dependency info
|
|
85
|
+
const dependencyGraphBuilder = new DependencyGraphBuilder(project);
|
|
86
|
+
await dependencyGraphBuilder.buildGraph();
|
|
87
|
+
dependencyGraphBuilder.computeTransitiveDependencies();
|
|
88
|
+
// Calculate detailed dependency info for each changed file
|
|
89
|
+
const dependencies = [];
|
|
90
|
+
for (const changedFile of normalizedFiles) {
|
|
91
|
+
const transitiveDependents = dependencyGraphBuilder.getTransitiveDependents(changedFile);
|
|
92
|
+
// Check if file is public API
|
|
93
|
+
const isPublicApi = this.isPublicApiFile(project, changedFile);
|
|
94
|
+
// Find affected module for this file
|
|
95
|
+
const affectedModule = buildScope.affectedModules.find((m) => m.filePath === changedFile ||
|
|
96
|
+
m.declarations.some((decl) => this.getComponentClass(project, changedFile)?.includes(decl)));
|
|
97
|
+
// Get dependency info
|
|
98
|
+
dependencies.push({
|
|
99
|
+
file: changedFile,
|
|
100
|
+
dependents: transitiveDependents.length,
|
|
101
|
+
isPublicApi,
|
|
102
|
+
affectedModule: affectedModule?.moduleName,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Generate recommendation
|
|
106
|
+
const totalAffectedFiles = normalizedFiles.length + dependentFiles.length;
|
|
107
|
+
const recommendation = this.generateRecommendation(totalAffectedFiles, strategy, estimatedBuildTime, dependencies);
|
|
108
|
+
// Build estimated scope
|
|
109
|
+
const estimatedBuildScope = {
|
|
110
|
+
strategy,
|
|
111
|
+
changedFiles: normalizedFiles,
|
|
112
|
+
dependentFiles,
|
|
113
|
+
affectedModules,
|
|
114
|
+
estimatedBuildTime,
|
|
115
|
+
};
|
|
116
|
+
// All affected files (changed + dependents)
|
|
117
|
+
const affectedFiles = [...normalizedFiles, ...dependentFiles];
|
|
118
|
+
return {
|
|
119
|
+
estimatedBuildScope,
|
|
120
|
+
affectedFiles,
|
|
121
|
+
affectedModules,
|
|
122
|
+
estimatedBuildTime,
|
|
123
|
+
recommendation,
|
|
124
|
+
dependencies,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Generate AI-friendly recommendation
|
|
129
|
+
*/
|
|
130
|
+
generateRecommendation(totalAffectedFiles, strategy, estimatedBuildTime, dependencies) {
|
|
131
|
+
// Check if any public API files are affected
|
|
132
|
+
const publicApiAffected = dependencies.some((dep) => dep.isPublicApi);
|
|
133
|
+
if (publicApiAffected) {
|
|
134
|
+
return `Public API change detected (${totalAffectedFiles} files affected, ~${estimatedBuildTime}s build time). High impact - may affect many files. Consider smaller batch or review dependents carefully.`;
|
|
135
|
+
}
|
|
136
|
+
if (totalAffectedFiles <= 10) {
|
|
137
|
+
return `Safe to transform, minimal impact (${totalAffectedFiles} files affected, ~${estimatedBuildTime}s build time). Recommended strategy: ${strategy}`;
|
|
138
|
+
}
|
|
139
|
+
else if (totalAffectedFiles <= 50) {
|
|
140
|
+
return `Medium impact (${totalAffectedFiles} files affected, ~${estimatedBuildTime}s build time). Incremental build recommended. Strategy: ${strategy}`;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return `High impact (${totalAffectedFiles} files affected, ~${estimatedBuildTime}s build time). Consider smaller batch or use full build. Strategy: ${strategy}`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if a file is a public API file (exported from index.ts)
|
|
148
|
+
*/
|
|
149
|
+
isPublicApiFile(project, filePath) {
|
|
150
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
151
|
+
if (!sourceFile) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
// Get the directory
|
|
155
|
+
const directory = sourceFile.getDirectory();
|
|
156
|
+
// Check if there's an index.ts in the same directory
|
|
157
|
+
const indexFile = directory.getSourceFile('index.ts');
|
|
158
|
+
if (!indexFile) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
// Check if index.ts exports anything from this file
|
|
162
|
+
const exportDeclarations = indexFile.getExportDeclarations();
|
|
163
|
+
for (const exportDecl of exportDeclarations) {
|
|
164
|
+
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
165
|
+
if (!moduleSpecifier) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// Check if export is from this file
|
|
169
|
+
const resolvedPath = directory.getSourceFile(moduleSpecifier);
|
|
170
|
+
if (resolvedPath?.getFilePath() === filePath) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get component class name from a source file
|
|
178
|
+
*/
|
|
179
|
+
getComponentClass(project, filePath) {
|
|
180
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
181
|
+
if (!sourceFile) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const classes = sourceFile.getClasses();
|
|
185
|
+
for (const cls of classes) {
|
|
186
|
+
const decorator = cls.getDecorator('Component');
|
|
187
|
+
if (decorator) {
|
|
188
|
+
return cls.getName() ?? null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=analyze-build-impact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-build-impact.js","sourceRoot":"","sources":["../../src/tools/analyze-build-impact.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAiHjC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACjC,IAAI,GAAG,sBAAsB,CAAC;IAC9B,WAAW,GACT,qOAAqO,CAAC;IAExO,WAAW,GAAG;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;gBACD,WAAW,EACT,iFAAiF;aACpF;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,eAAe,CAAC;KAC3C,CAAC;IAEF,KAAK,CAAC,OAAO,CACX,IAA6B;QAE7B,MAAM,MAAM,GAAG,IAAwC,CAAC;QAExD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC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