@angular-modernizer/adapter-mcp 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +662 -0
- package/README.md +86 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -0
- package/dist/scan-host/scan-host.d.ts +7 -0
- package/dist/scan-host/scan-host.js +73 -10
- package/dist/scan-host/scan-protocol.d.ts +2 -0
- package/dist/scan-host/scan-worker.js +14 -8
- package/dist/server/limited-stdio-transport.d.ts +6 -3
- package/dist/server/limited-stdio-transport.js +26 -9
- package/dist/server/mcp-server.js +1 -1
- package/dist/server/sdk-server.d.ts +14 -3
- package/dist/server/sdk-server.js +54 -6
- package/dist/server/tool-registry.d.ts +3 -1
- package/dist/server/tool-registry.js +8 -3
- package/dist/streaming/progress-store.d.ts +19 -7
- package/dist/streaming/progress-store.js +19 -8
- package/dist/tools/analyze-build-impact.d.ts +9 -6
- package/dist/tools/analyze-build-impact.js +14 -7
- package/dist/tools/analyze-core-to-shared.d.ts +10 -6
- package/dist/tools/analyze-core-to-shared.js +63 -60
- package/dist/tools/analyze-parser-performance.d.ts +57 -13
- package/dist/tools/analyze-parser-performance.js +67 -6
- package/dist/tools/analyze-project.d.ts +35 -6
- package/dist/tools/analyze-project.js +141 -36
- package/dist/tools/check-incremental-compatibility.d.ts +30 -41
- package/dist/tools/check-incremental-compatibility.js +32 -264
- package/dist/tools/collect-feedback.js +15 -2
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.d.ts +2 -2
- package/dist/tools/find-angular-symbol.js +6 -5
- package/dist/tools/find-component-hosts.d.ts +2 -2
- package/dist/tools/find-component-hosts.js +6 -5
- package/dist/tools/find-usages.d.ts +2 -2
- package/dist/tools/find-usages.js +24 -15
- package/dist/tools/get-bootstrap-execution.d.ts +2 -2
- package/dist/tools/get-bootstrap-execution.js +3 -3
- package/dist/tools/get-call-graph.d.ts +2 -2
- package/dist/tools/get-call-graph.js +18 -5
- package/dist/tools/get-operation-progress-tool.d.ts +1 -1
- package/dist/tools/get-operation-progress-tool.js +2 -2
- package/dist/tools/get-operation-progress.d.ts +4 -1
- package/dist/tools/get-operation-progress.js +6 -2
- package/dist/tools/helpers/analysis-output.d.ts +32 -1
- package/dist/tools/helpers/analysis-output.js +22 -1
- package/dist/tools/helpers/build-cache.d.ts +27 -0
- package/dist/tools/helpers/build-cache.js +86 -0
- package/dist/tools/helpers/class-filter.d.ts +18 -0
- package/dist/tools/helpers/class-filter.js +30 -0
- package/dist/tools/helpers/cli-arguments.d.ts +23 -0
- package/dist/tools/helpers/cli-arguments.js +35 -0
- package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
- package/dist/tools/helpers/feedback-catalog.js +196 -0
- package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
- package/dist/tools/helpers/feedback-sidecar.js +381 -0
- package/dist/tools/helpers/file-type-check.d.ts +34 -0
- package/dist/tools/helpers/file-type-check.js +56 -0
- package/dist/tools/helpers/output-contract.d.ts +42 -0
- package/dist/tools/helpers/output-contract.js +54 -0
- package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
- package/dist/tools/helpers/pattern-anonymizer.js +159 -0
- package/dist/tools/helpers/project-cache.d.ts +78 -6
- package/dist/tools/helpers/project-cache.js +205 -15
- package/dist/tools/helpers/project-decorators.d.ts +11 -4
- package/dist/tools/helpers/project-decorators.js +13 -6
- package/dist/tools/helpers/refresh-apply.d.ts +94 -0
- package/dist/tools/helpers/refresh-apply.js +460 -0
- package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
- package/dist/tools/helpers/refresh-inventory.js +610 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +74 -5
- package/dist/tools/helpers/scan-cache.js +134 -6
- package/dist/tools/helpers/scan-engine.d.ts +30 -6
- package/dist/tools/helpers/scan-engine.js +131 -22
- package/dist/tools/helpers/scan-plan.d.ts +1 -1
- package/dist/tools/helpers/scan-plan.js +16 -2
- package/dist/tools/helpers/source-map-loader.d.ts +55 -0
- package/dist/tools/helpers/source-map-loader.js +226 -0
- package/dist/tools/helpers/template-check.d.ts +76 -0
- package/dist/tools/helpers/template-check.js +158 -0
- package/dist/tools/helpers/tool-cache.d.ts +7 -2
- package/dist/tools/helpers/tool-cache.js +9 -3
- package/dist/tools/helpers/tool-context.d.ts +18 -0
- package/dist/tools/helpers/tool-context.js +29 -0
- package/dist/tools/helpers/transform-safety.d.ts +151 -1
- package/dist/tools/helpers/transform-safety.js +357 -4
- package/dist/tools/inspect-form-group.d.ts +2 -2
- package/dist/tools/inspect-form-group.js +8 -3
- package/dist/tools/inspect-i18n.d.ts +2 -2
- package/dist/tools/inspect-i18n.js +3 -3
- package/dist/tools/inspect-template.d.ts +2 -2
- package/dist/tools/inspect-template.js +11 -5
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +2 -2
- package/dist/tools/list-imports.js +3 -3
- package/dist/tools/orchestrate-migration.d.ts +19 -1
- package/dist/tools/orchestrate-migration.js +52 -10
- package/dist/tools/parse-stack-trace.d.ts +48 -1
- package/dist/tools/parse-stack-trace.js +108 -9
- package/dist/tools/plan-migration.d.ts +2 -2
- package/dist/tools/plan-migration.js +25 -12
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.d.ts +2 -2
- package/dist/tools/resolve-type.js +13 -6
- package/dist/tools/review-feedback.d.ts +42 -7
- package/dist/tools/review-feedback.js +24 -17
- package/dist/tools/rollback-changes.d.ts +5 -0
- package/dist/tools/rollback-changes.js +7 -2
- package/dist/tools/run-angular-cli.js +36 -22
- package/dist/tools/run-build.d.ts +33 -28
- package/dist/tools/run-build.js +136 -438
- package/dist/tools/run-schematic.d.ts +8 -2
- package/dist/tools/run-schematic.js +80 -50
- package/dist/tools/scan-all.d.ts +31 -15
- package/dist/tools/scan-all.js +75 -109
- package/dist/tools/scan-angular.d.ts +27 -14
- package/dist/tools/scan-angular.js +70 -92
- package/dist/tools/scan-architecture.d.ts +29 -12
- package/dist/tools/scan-architecture.js +205 -135
- package/dist/tools/scan-solid.d.ts +27 -14
- package/dist/tools/scan-solid.js +73 -89
- package/dist/tools/search-codebase.d.ts +8 -3
- package/dist/tools/search-codebase.js +16 -10
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.d.ts +2 -2
- package/dist/tools/trace-output-flow.js +6 -5
- package/dist/tools/transform-code-batch.d.ts +9 -9
- package/dist/tools/transform-code.d.ts +161 -12
- package/dist/tools/transform-code.js +782 -197
- package/dist/tools/validate-before-transform.js +2 -1
- package/dist/tools/validate-project-compatibility.d.ts +28 -55
- package/dist/tools/validate-project-compatibility.js +33 -225
- package/dist/tools/validate-transformation.d.ts +40 -26
- package/dist/tools/validate-transformation.js +115 -294
- package/dist/tools/verify-citations.js +8 -2
- package/dist/types.d.ts +9 -9
- package/dist/utils/format-tool-response.d.ts +3 -1
- package/dist/utils/format-tool-response.js +8 -3
- package/package.json +14 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AngularSymbolFinder, } from '@angular-modernizer/api';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
5
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
6
6
|
import { configuredComponentDecorators } from './helpers/project-decorators.js';
|
|
7
7
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
@@ -123,7 +123,7 @@ export class FindAngularSymbolTool {
|
|
|
123
123
|
},
|
|
124
124
|
required: ['totalCount', 'truncated', 'countsByType', 'summary'],
|
|
125
125
|
};
|
|
126
|
-
async execute(args) {
|
|
126
|
+
async execute(args, ctx = {}) {
|
|
127
127
|
const params = args;
|
|
128
128
|
if (!params.query) {
|
|
129
129
|
throw new Error('query is required');
|
|
@@ -139,12 +139,13 @@ export class FindAngularSymbolTool {
|
|
|
139
139
|
if (!tsConfigPath) {
|
|
140
140
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
141
141
|
}
|
|
142
|
-
const project = this.projects
|
|
142
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
143
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
143
144
|
const finder = new AngularSymbolFinder(project, {
|
|
144
|
-
componentDecorators:
|
|
145
|
+
componentDecorators: decorators.componentDecorators,
|
|
145
146
|
});
|
|
146
147
|
const results = finder.findSymbol(params.query, params.type);
|
|
147
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
148
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
148
149
|
const countsByType = {};
|
|
149
150
|
for (const r of results) {
|
|
150
151
|
countsByType[r.angularType] = (countsByType[r.angularType] ?? 0) + 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
2
|
import { type BindingCoverage, type ComponentHost, type ComponentHostResult, type DynamicHost } from '@angular-modernizer/api';
|
|
3
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
4
|
/** Coverage entry with the host name lists dropped (summaryOnly) or capped (maxResults). */
|
|
@@ -680,7 +680,7 @@ export declare class FindComponentHostsTool implements MCPTool {
|
|
|
680
680
|
};
|
|
681
681
|
required: string[];
|
|
682
682
|
};
|
|
683
|
-
execute(args: Record<string, unknown
|
|
683
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<FindComponentHostsOutput>;
|
|
684
684
|
private buildSummary;
|
|
685
685
|
private shapeCoverage;
|
|
686
686
|
/** `AppDialog.open 24, new AppDialogRef 2` */
|
|
@@ -2,7 +2,7 @@ import { ComponentHostFinder, } from '@angular-modernizer/api';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { isAbsolute, resolve } from 'node:path';
|
|
4
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
5
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
6
6
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
7
7
|
import { configuredComponentDecorators } from './helpers/project-decorators.js';
|
|
8
8
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
@@ -296,7 +296,7 @@ export class FindComponentHostsTool {
|
|
|
296
296
|
'tsConfigPath',
|
|
297
297
|
],
|
|
298
298
|
};
|
|
299
|
-
async execute(args) {
|
|
299
|
+
async execute(args, ctx = {}) {
|
|
300
300
|
const params = args;
|
|
301
301
|
if (!params.className && !params.selector) {
|
|
302
302
|
throw new Error('className or selector is required');
|
|
@@ -315,8 +315,9 @@ export class FindComponentHostsTool {
|
|
|
315
315
|
const file = params.file === undefined || isAbsolute(params.file)
|
|
316
316
|
? params.file
|
|
317
317
|
: resolve(params.projectRoot, params.file);
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
319
|
+
const finder = new ComponentHostFinder((await acquireProject(this.projects, tsConfigPath, ctx)), {
|
|
320
|
+
componentDecorators: decorators.componentDecorators,
|
|
320
321
|
includeTestHosts: params.includeTestHosts === true,
|
|
321
322
|
includeDynamic: params.includeDynamic !== false,
|
|
322
323
|
});
|
|
@@ -327,7 +328,7 @@ export class FindComponentHostsTool {
|
|
|
327
328
|
});
|
|
328
329
|
const { hosts, coverage, dynamicHosts, candidateHosts, ...rest } = result;
|
|
329
330
|
const summary = this.buildSummary(params, result);
|
|
330
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
331
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
331
332
|
if (compact.summaryOnly) {
|
|
332
333
|
return withWarnings({
|
|
333
334
|
...rest,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
2
|
import { type SymbolUsage, type UsageType } from '@angular-modernizer/api';
|
|
3
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
4
|
/**
|
|
@@ -167,7 +167,7 @@ export declare class FindUsagesTool implements MCPTool {
|
|
|
167
167
|
};
|
|
168
168
|
required: string[];
|
|
169
169
|
};
|
|
170
|
-
execute(args: Record<string, unknown
|
|
170
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<FindUsagesOutput>;
|
|
171
171
|
private buildCompactSummary;
|
|
172
172
|
private buildSummary;
|
|
173
173
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { UsageFinder, } from '@angular-modernizer/api';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
6
|
import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
6
7
|
import { configuredComponentDecorators } from './helpers/project-decorators.js';
|
|
7
8
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
@@ -69,7 +70,7 @@ export class FindUsagesTool {
|
|
|
69
70
|
},
|
|
70
71
|
file: {
|
|
71
72
|
type: 'string',
|
|
72
|
-
description: 'Only report usages located in this file (absolute
|
|
73
|
+
description: 'Only report usages located in this file (absolute, or relative to projectRoot; .ts or .html). ' +
|
|
73
74
|
'The symbol declaration may live in any file. Optional.',
|
|
74
75
|
},
|
|
75
76
|
usageType: {
|
|
@@ -147,7 +148,7 @@ export class FindUsagesTool {
|
|
|
147
148
|
'tsConfigPath',
|
|
148
149
|
],
|
|
149
150
|
};
|
|
150
|
-
async execute(args) {
|
|
151
|
+
async execute(args, ctx = {}) {
|
|
151
152
|
const params = args;
|
|
152
153
|
if (!params.symbol) {
|
|
153
154
|
throw new Error('symbol is required');
|
|
@@ -165,12 +166,16 @@ export class FindUsagesTool {
|
|
|
165
166
|
}
|
|
166
167
|
// The shared ProjectCache: a fresh Project cost 4 to 6 s per call on a
|
|
167
168
|
// large workspace and sat next to the cached one while the search ran.
|
|
168
|
-
const project = this.projects
|
|
169
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
170
|
+
const decorators = configuredComponentDecorators(params.projectRoot);
|
|
169
171
|
const finder = new UsageFinder(project, {
|
|
170
|
-
componentDecorators:
|
|
172
|
+
componentDecorators: decorators.componentDecorators,
|
|
171
173
|
});
|
|
174
|
+
const file = params.file === undefined || isAbsolute(params.file)
|
|
175
|
+
? params.file
|
|
176
|
+
: resolve(params.projectRoot, params.file);
|
|
172
177
|
const usages = finder.findUsages(params.symbol, {
|
|
173
|
-
file
|
|
178
|
+
file,
|
|
174
179
|
usageType: params.usageType,
|
|
175
180
|
includeTemplates: params.includeTemplates !== false,
|
|
176
181
|
includeUnresolved: params.includeUnresolved !== false,
|
|
@@ -181,19 +186,19 @@ export class FindUsagesTool {
|
|
|
181
186
|
}
|
|
182
187
|
const countsByDirectory = countByDirectory(usages.map((u) => u.file), params.projectRoot, DIRECTORY_DEPTH);
|
|
183
188
|
const shown = limitList(usages, compact.maxResults);
|
|
184
|
-
const warnings = this.projects.warnings(tsConfigPath);
|
|
189
|
+
const warnings = [...decorators.warnings, ...this.projects.warnings(tsConfigPath)];
|
|
185
190
|
if (compact.summaryOnly) {
|
|
186
191
|
return withWarnings({
|
|
187
192
|
totalCount: usages.length,
|
|
188
193
|
truncated: false,
|
|
189
|
-
summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, params.
|
|
194
|
+
summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, file, params.usageType),
|
|
190
195
|
countsByType,
|
|
191
196
|
countsByDirectory,
|
|
192
197
|
tsConfigPath,
|
|
193
198
|
}, warnings);
|
|
194
199
|
}
|
|
195
200
|
const note = truncationNote(shown.items.length, usages.length, 'usages');
|
|
196
|
-
const summary = this.buildSummary(params.symbol, shown.items, params.
|
|
201
|
+
const summary = this.buildSummary(params.symbol, shown.items, file, params.usageType);
|
|
197
202
|
return withWarnings({
|
|
198
203
|
usages: shown.items,
|
|
199
204
|
totalCount: usages.length,
|
|
@@ -204,9 +209,9 @@ export class FindUsagesTool {
|
|
|
204
209
|
tsConfigPath,
|
|
205
210
|
}, warnings);
|
|
206
211
|
}
|
|
207
|
-
buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file) {
|
|
212
|
+
buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file, usageType) {
|
|
208
213
|
if (usages.length === 0) {
|
|
209
|
-
return this.buildSummary(symbol, usages, file);
|
|
214
|
+
return this.buildSummary(symbol, usages, file, usageType);
|
|
210
215
|
}
|
|
211
216
|
const fileCount = new Set(usages.map((u) => u.file)).size;
|
|
212
217
|
const types = Object.entries(countsByType)
|
|
@@ -214,7 +219,7 @@ export class FindUsagesTool {
|
|
|
214
219
|
.join(', ');
|
|
215
220
|
const directories = Object.entries(countsByDirectory);
|
|
216
221
|
const lines = [
|
|
217
|
-
`Found ${usages.length} usage(s) of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
|
|
222
|
+
`Found ${usages.length} usage(s)${ofType(usageType)} of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
|
|
218
223
|
'Top directories:',
|
|
219
224
|
...directories
|
|
220
225
|
.slice(0, SUMMARY_TOP_DIRECTORIES)
|
|
@@ -225,10 +230,10 @@ export class FindUsagesTool {
|
|
|
225
230
|
}
|
|
226
231
|
return lines.join('\n');
|
|
227
232
|
}
|
|
228
|
-
buildSummary(symbol, usages, file) {
|
|
233
|
+
buildSummary(symbol, usages, file, usageType) {
|
|
229
234
|
if (usages.length === 0) {
|
|
230
235
|
const scope = file ? `in ${file}` : 'across the project';
|
|
231
|
-
return (`No usages of '${symbol}' found ${scope}. Only files in the tsconfig program ` +
|
|
236
|
+
return (`No usages${ofType(usageType)} of '${symbol}' found ${scope}. Only files in the tsconfig program ` +
|
|
232
237
|
'and component templates were searched; verify with search-codebase (text mode) ' +
|
|
233
238
|
'before treating this as proof of absence.');
|
|
234
239
|
}
|
|
@@ -239,7 +244,7 @@ export class FindUsagesTool {
|
|
|
239
244
|
byFile.set(u.file, list);
|
|
240
245
|
}
|
|
241
246
|
const lines = [
|
|
242
|
-
`Found ${usages.length} usage(s) of '${symbol}' across ${byFile.size} file(s):`,
|
|
247
|
+
`Found ${usages.length} usage(s)${ofType(usageType)} of '${symbol}' across ${byFile.size} file(s):`,
|
|
243
248
|
];
|
|
244
249
|
for (const [filePath, fileUsages] of byFile) {
|
|
245
250
|
lines.push(` ${filePath} (${fileUsages.length})`);
|
|
@@ -256,4 +261,8 @@ export class FindUsagesTool {
|
|
|
256
261
|
return lines.join('\n');
|
|
257
262
|
}
|
|
258
263
|
}
|
|
264
|
+
/** Names the `usageType` filter in the summary (` of type call`), empty without one. */
|
|
265
|
+
function ofType(usageType) {
|
|
266
|
+
return usageType === undefined ? '' : ` of type ${usageType}`;
|
|
267
|
+
}
|
|
259
268
|
//# sourceMappingURL=find-usages.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
2
|
import { type BootstrapExecutionResult, type BootstrapRoot, type BootstrapTiming, type BootstrapWatchHit } from '@angular-modernizer/api';
|
|
3
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
4
|
/** A root with its reached list optionally dropped or capped. */
|
|
@@ -260,7 +260,7 @@ export declare class GetBootstrapExecutionTool implements MCPTool {
|
|
|
260
260
|
};
|
|
261
261
|
required: string[];
|
|
262
262
|
};
|
|
263
|
-
execute(args: Record<string, unknown
|
|
263
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<GetBootstrapExecutionOutput>;
|
|
264
264
|
private buildSummary;
|
|
265
265
|
}
|
|
266
266
|
//# sourceMappingURL=get-bootstrap-execution.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { BootstrapExecutionAnalyzer, normalizeWatchExpression, } from '@angular-
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { isAbsolute, relative, resolve } from 'node:path';
|
|
4
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
5
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
6
6
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
|
|
7
7
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
8
8
|
import { COUNT_OBJECT, STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
@@ -213,7 +213,7 @@ export class GetBootstrapExecutionTool {
|
|
|
213
213
|
},
|
|
214
214
|
required: ['counts', 'truncated', 'summary', 'tsConfigPath'],
|
|
215
215
|
};
|
|
216
|
-
async execute(args) {
|
|
216
|
+
async execute(args, ctx = {}) {
|
|
217
217
|
const params = args;
|
|
218
218
|
if (!params.projectRoot) {
|
|
219
219
|
throw new Error('projectRoot is required');
|
|
@@ -240,7 +240,7 @@ export class GetBootstrapExecutionTool {
|
|
|
240
240
|
const file = params.file === undefined || isAbsolute(params.file)
|
|
241
241
|
? params.file
|
|
242
242
|
: resolve(params.projectRoot, params.file);
|
|
243
|
-
const result = new BootstrapExecutionAnalyzer(this.projects
|
|
243
|
+
const result = new BootstrapExecutionAnalyzer((await acquireProject(this.projects, tsConfigPath, ctx))).analyze({
|
|
244
244
|
...(watch === undefined ? {} : { watch }),
|
|
245
245
|
...(timings === undefined ? {} : { timings: timings }),
|
|
246
246
|
...(file === undefined ? {} : { file }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
2
|
import { type CallGraphResult } from '@angular-modernizer/api';
|
|
3
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
4
|
/** Tool output: the call graph (trees omitted with `summaryOnly`) plus a text summary. */
|
|
@@ -191,7 +191,7 @@ export declare class GetCallGraphTool implements MCPTool {
|
|
|
191
191
|
};
|
|
192
192
|
required: string[];
|
|
193
193
|
};
|
|
194
|
-
execute(args: Record<string, unknown
|
|
194
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<GetCallGraphOutput>;
|
|
195
195
|
private buildSummary;
|
|
196
196
|
/**
|
|
197
197
|
* Summary lines for the direct callers or callees, at most
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CallGraphBuilder, } from '@angular-modernizer/api';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
4
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
6
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
6
7
|
/** Direct callers and callees spelled out per list in the summary. */
|
|
7
8
|
const SUMMARY_MAX_NODES = 50;
|
|
@@ -64,6 +65,9 @@ export class GetCallGraphTool {
|
|
|
64
65
|
'Callers of component members include calls from the component template as leaf nodes ' +
|
|
65
66
|
'(kind "template", template file and line, snippet), also from templates of subclasses that inherit the member ' +
|
|
66
67
|
'(className of the subclass, inheritedFrom of the declaring class; a subclass overriding it is left out). ' +
|
|
68
|
+
'Calls at the top level of a file, also inside anonymous callbacks there (describe/it blocks), are leaf callers ' +
|
|
69
|
+
'with name "<module>" and kind "module" (file, line and snippet of the call); calls in anonymous callbacks ' +
|
|
70
|
+
'inside a method or function count for that method or function. ' +
|
|
67
71
|
'Use method "ClassName.constructor" to see what runs transitively during construction. ' +
|
|
68
72
|
'Use after parse-stack-trace to trace error propagation through the call hierarchy.';
|
|
69
73
|
/**
|
|
@@ -81,7 +85,7 @@ export class GetCallGraphTool {
|
|
|
81
85
|
},
|
|
82
86
|
file: {
|
|
83
87
|
type: 'string',
|
|
84
|
-
description: '
|
|
88
|
+
description: 'Source file containing the method (absolute path, or relative to projectRoot).',
|
|
85
89
|
},
|
|
86
90
|
projectRoot: {
|
|
87
91
|
type: 'string',
|
|
@@ -150,7 +154,7 @@ export class GetCallGraphTool {
|
|
|
150
154
|
},
|
|
151
155
|
required: ['target', 'nodeCount', 'truncated', 'summary'],
|
|
152
156
|
};
|
|
153
|
-
async execute(args) {
|
|
157
|
+
async execute(args, ctx = {}) {
|
|
154
158
|
const params = args;
|
|
155
159
|
if (!params.method) {
|
|
156
160
|
throw new Error('method is required');
|
|
@@ -164,6 +168,12 @@ export class GetCallGraphTool {
|
|
|
164
168
|
if (!existsSync(params.projectRoot)) {
|
|
165
169
|
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
166
170
|
}
|
|
171
|
+
const filePath = isAbsolute(params.file)
|
|
172
|
+
? params.file
|
|
173
|
+
: resolve(params.projectRoot, params.file);
|
|
174
|
+
if (!existsSync(filePath)) {
|
|
175
|
+
throw new Error(`file does not exist: ${filePath}`);
|
|
176
|
+
}
|
|
167
177
|
const tsConfigPath = findTsConfig(params.projectRoot);
|
|
168
178
|
if (!tsConfigPath) {
|
|
169
179
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
@@ -172,7 +182,7 @@ export class GetCallGraphTool {
|
|
|
172
182
|
(!Number.isInteger(params.maxNodes) || params.maxNodes < 1)) {
|
|
173
183
|
throw new Error('maxNodes must be a positive integer');
|
|
174
184
|
}
|
|
175
|
-
const graphBuilder = new CallGraphBuilder(this.projects
|
|
185
|
+
const graphBuilder = new CallGraphBuilder((await acquireProject(this.projects, tsConfigPath, ctx)));
|
|
176
186
|
const warnings = this.projects.warnings(tsConfigPath);
|
|
177
187
|
const options = {
|
|
178
188
|
direction: params.direction ?? 'both',
|
|
@@ -180,7 +190,7 @@ export class GetCallGraphTool {
|
|
|
180
190
|
maxNodes: params.maxNodes ?? 200,
|
|
181
191
|
includeLifecycleHooks: params.includeLifecycleHooks ?? false,
|
|
182
192
|
};
|
|
183
|
-
const result = graphBuilder.buildCallGraph(params.method,
|
|
193
|
+
const result = graphBuilder.buildCallGraph(params.method, filePath, options);
|
|
184
194
|
const summary = this.buildSummary(params.method, result);
|
|
185
195
|
if (params.summaryOnly) {
|
|
186
196
|
const { callers: _callers, callees: _callees, ...rest } = result;
|
|
@@ -233,6 +243,9 @@ export class GetCallGraphTool {
|
|
|
233
243
|
return lines;
|
|
234
244
|
}
|
|
235
245
|
label(node) {
|
|
246
|
+
if (node.kind === 'module') {
|
|
247
|
+
return `module level: ${node.snippet ?? ''}`;
|
|
248
|
+
}
|
|
236
249
|
if (node.kind === 'template') {
|
|
237
250
|
const inherited = node.inheritedFrom === undefined ? '' : ` (inherits ${node.inheritedFrom})`;
|
|
238
251
|
return `template of ${node.className ?? 'component'}${inherited}: ${node.snippet ?? ''}`;
|
|
@@ -3,7 +3,7 @@ import { getOperationProgress } from './get-operation-progress.js';
|
|
|
3
3
|
type OperationProgress = Awaited<ReturnType<typeof getOperationProgress>>;
|
|
4
4
|
/**
|
|
5
5
|
* MCP tool for querying the progress of streaming operations (deprecated, kept
|
|
6
|
-
* in
|
|
6
|
+
* in 2.x): polls an operation started with `streaming: true` by transform-code
|
|
7
7
|
* or scan-architecture.
|
|
8
8
|
*/
|
|
9
9
|
export declare class GetOperationProgressTool implements MCPTool {
|
|
@@ -30,7 +30,7 @@ function describeProgress(progress) {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* MCP tool for querying the progress of streaming operations (deprecated, kept
|
|
33
|
-
* in
|
|
33
|
+
* in 2.x): polls an operation started with `streaming: true` by transform-code
|
|
34
34
|
* or scan-architecture.
|
|
35
35
|
*/
|
|
36
36
|
export class GetOperationProgressTool {
|
|
@@ -42,7 +42,7 @@ export class GetOperationProgressTool {
|
|
|
42
42
|
idempotentHint: true,
|
|
43
43
|
openWorldHint: false,
|
|
44
44
|
};
|
|
45
|
-
description = 'Deprecated, kept in
|
|
45
|
+
description = 'Deprecated, kept in 2.x: polls an operation started with streaming: true (transform-code, scan-architecture). ' +
|
|
46
46
|
'Call those tools synchronously instead: they send MCP progress notifications when the request has a progressToken ' +
|
|
47
47
|
'and stop on notifications/cancelled. ' +
|
|
48
48
|
'Get progress for a streaming operation (transformation or analysis). ' +
|
|
@@ -65,7 +65,10 @@ export declare function getOperationProgress(input: GetOperationProgressInput):
|
|
|
65
65
|
}[];
|
|
66
66
|
/** Number of all events of the operation, regardless of `sinceTimestamp`. */
|
|
67
67
|
totalEvents: number;
|
|
68
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Milliseconds from the start to now for a running operation, to the moment
|
|
70
|
+
* it completed, failed, timed out or was cancelled for a finished one.
|
|
71
|
+
*/
|
|
69
72
|
elapsedTime: number;
|
|
70
73
|
/** Estimated milliseconds until completion; only for running operations with progress. */
|
|
71
74
|
eta?: number;
|
|
@@ -36,8 +36,12 @@ export async function getOperationProgress(input) {
|
|
|
36
36
|
// Get metadata
|
|
37
37
|
const metadata = store.getMetadata(operationId);
|
|
38
38
|
const events = store.getEvents(operationId, sinceTimestamp);
|
|
39
|
-
//
|
|
40
|
-
|
|
39
|
+
// A finished operation's clock stops when it completed, failed, timed out
|
|
40
|
+
// or was cancelled; only a running operation counts up to now.
|
|
41
|
+
const endTime = metadata.status === 'running'
|
|
42
|
+
? Date.now()
|
|
43
|
+
: (metadata.completedAt ?? Date.now());
|
|
44
|
+
const elapsedTime = endTime - metadata.startTime;
|
|
41
45
|
// Estimate ETA based on progress (only for running operations)
|
|
42
46
|
let eta;
|
|
43
47
|
if (metadata.status === 'running' && events.length > 0) {
|
|
@@ -135,7 +135,8 @@ export declare const SCAN_VIOLATION_SCHEMA: {
|
|
|
135
135
|
readonly required: readonly ["ruleId", "severity", "message", "filePath"];
|
|
136
136
|
};
|
|
137
137
|
/**
|
|
138
|
-
* Run details of a scan that stopped early (time budget or cancellation)
|
|
138
|
+
* Run details of a scan that stopped early (time budget or cancellation) or,
|
|
139
|
+
* in scan-architecture, left files out at its `maxFiles` cap;
|
|
139
140
|
* scan-architecture always reports them.
|
|
140
141
|
*/
|
|
141
142
|
export declare const SCAN_EXECUTION_SCHEMA: {
|
|
@@ -153,6 +154,9 @@ export declare const SCAN_EXECUTION_SCHEMA: {
|
|
|
153
154
|
readonly skippedFiles: {
|
|
154
155
|
readonly type: "integer";
|
|
155
156
|
};
|
|
157
|
+
readonly scopeFiles: {
|
|
158
|
+
readonly type: "integer";
|
|
159
|
+
};
|
|
156
160
|
readonly ruleTimings: {
|
|
157
161
|
readonly type: "array";
|
|
158
162
|
readonly items: {
|
|
@@ -165,6 +169,33 @@ export declare const SCAN_EXECUTION_SCHEMA: {
|
|
|
165
169
|
};
|
|
166
170
|
readonly required: readonly ["incomplete", "skippedFiles"];
|
|
167
171
|
};
|
|
172
|
+
/**
|
|
173
|
+
* Notice for an `orchestration` argument of scan-all, scan-solid or
|
|
174
|
+
* scan-angular. They always run in the scan worker; the argument used to be
|
|
175
|
+
* ignored while the result claimed a parallel run.
|
|
176
|
+
*/
|
|
177
|
+
export declare const SCAN_ORCHESTRATION_NOTICE = "orchestration is deprecated and has no effect: the scan always runs in the scan worker. Leave it unset.";
|
|
178
|
+
/**
|
|
179
|
+
* Input schema of the deprecated `orchestration` argument of scan-all,
|
|
180
|
+
* scan-solid and scan-angular, kept so 1.x callers are not rejected.
|
|
181
|
+
*/
|
|
182
|
+
export declare const DEPRECATED_SCAN_ORCHESTRATION_SCHEMA: {
|
|
183
|
+
readonly type: "object";
|
|
184
|
+
readonly description: "Deprecated, no effect, kept in 2.x: the scan always runs in the scan worker and answers with a notice in warnings. Leave unset.";
|
|
185
|
+
readonly deprecated: true;
|
|
186
|
+
readonly properties: {
|
|
187
|
+
readonly parallel: {
|
|
188
|
+
readonly type: "boolean";
|
|
189
|
+
readonly description: "Deprecated, no effect.";
|
|
190
|
+
readonly deprecated: true;
|
|
191
|
+
};
|
|
192
|
+
readonly maxWorkers: {
|
|
193
|
+
readonly type: "number";
|
|
194
|
+
readonly description: "Deprecated, no effect.";
|
|
195
|
+
readonly deprecated: true;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
};
|
|
168
199
|
/**
|
|
169
200
|
* Output schema of a scan: violations, counts, metadata and summary, plus
|
|
170
201
|
* the tool's own fields. Only `counts`, `metadata` and `summary` are required.
|
|
@@ -79,7 +79,8 @@ export const SCAN_VIOLATION_SCHEMA = {
|
|
|
79
79
|
required: ['ruleId', 'severity', 'message', 'filePath'],
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* Run details of a scan that stopped early (time budget or cancellation)
|
|
82
|
+
* Run details of a scan that stopped early (time budget or cancellation) or,
|
|
83
|
+
* in scan-architecture, left files out at its `maxFiles` cap;
|
|
83
84
|
* scan-architecture always reports them.
|
|
84
85
|
*/
|
|
85
86
|
export const SCAN_EXECUTION_SCHEMA = {
|
|
@@ -89,11 +90,31 @@ export const SCAN_EXECUTION_SCHEMA = {
|
|
|
89
90
|
incomplete: { type: 'boolean' },
|
|
90
91
|
stopReason: { type: 'string' },
|
|
91
92
|
skippedFiles: { type: 'integer' },
|
|
93
|
+
scopeFiles: { type: 'integer' },
|
|
92
94
|
ruleTimings: { type: 'array', items: { type: 'object' } },
|
|
93
95
|
note: { type: 'string' },
|
|
94
96
|
},
|
|
95
97
|
required: ['incomplete', 'skippedFiles'],
|
|
96
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Notice for an `orchestration` argument of scan-all, scan-solid or
|
|
101
|
+
* scan-angular. They always run in the scan worker; the argument used to be
|
|
102
|
+
* ignored while the result claimed a parallel run.
|
|
103
|
+
*/
|
|
104
|
+
export const SCAN_ORCHESTRATION_NOTICE = 'orchestration is deprecated and has no effect: the scan always runs in the scan worker. Leave it unset.';
|
|
105
|
+
/**
|
|
106
|
+
* Input schema of the deprecated `orchestration` argument of scan-all,
|
|
107
|
+
* scan-solid and scan-angular, kept so 1.x callers are not rejected.
|
|
108
|
+
*/
|
|
109
|
+
export const DEPRECATED_SCAN_ORCHESTRATION_SCHEMA = {
|
|
110
|
+
type: 'object',
|
|
111
|
+
description: 'Deprecated, no effect, kept in 2.x: the scan always runs in the scan worker and answers with a notice in warnings. Leave unset.',
|
|
112
|
+
deprecated: true,
|
|
113
|
+
properties: {
|
|
114
|
+
parallel: { type: 'boolean', description: 'Deprecated, no effect.', deprecated: true },
|
|
115
|
+
maxWorkers: { type: 'number', description: 'Deprecated, no effect.', deprecated: true },
|
|
116
|
+
},
|
|
117
|
+
};
|
|
97
118
|
/**
|
|
98
119
|
* Output schema of a scan: violations, counts, metadata and summary, plus
|
|
99
120
|
* the tool's own fields. Only `counts`, `metadata` and `summary` are required.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Build cache clearing (`cacheStrategy: 'clear'`)
|
|
3
|
+
*
|
|
4
|
+
* run-build and validate-transformation remove the build caches of the project
|
|
5
|
+
* before an incremental build. Each cache is resolved through symlinks first and
|
|
6
|
+
* removed only when it lies inside the project root and not under `node_modules`:
|
|
7
|
+
* a linked or shared `node_modules` (pnpm, monorepos, project copies) leads out
|
|
8
|
+
* of the project, and `rm -rf` used to delete there.
|
|
9
|
+
*/
|
|
10
|
+
/** Outcome of {@link clearBuildCaches}. */
|
|
11
|
+
export interface CacheClearResult {
|
|
12
|
+
/** Caches removed, relative to the project root. */
|
|
13
|
+
cleared: string[];
|
|
14
|
+
/** Caches left in place, with the reason. */
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Remove the Angular CLI cache and, in an Nx workspace, the Nx cache of a project.
|
|
19
|
+
*
|
|
20
|
+
* Missing caches are skipped silently; a cache that resolves outside the project
|
|
21
|
+
* root or under `node_modules`, or that cannot be removed, is left in place and
|
|
22
|
+
* reported in `warnings`.
|
|
23
|
+
*
|
|
24
|
+
* @param projectRoot - Root folder of the project
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearBuildCaches(projectRoot: string): CacheClearResult;
|
|
27
|
+
//# sourceMappingURL=build-cache.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Build cache clearing (`cacheStrategy: 'clear'`)
|
|
3
|
+
*
|
|
4
|
+
* run-build and validate-transformation remove the build caches of the project
|
|
5
|
+
* before an incremental build. Each cache is resolved through symlinks first and
|
|
6
|
+
* removed only when it lies inside the project root and not under `node_modules`:
|
|
7
|
+
* a linked or shared `node_modules` (pnpm, monorepos, project copies) leads out
|
|
8
|
+
* of the project, and `rm -rf` used to delete there.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, realpathSync, rmSync } from 'node:fs';
|
|
11
|
+
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
12
|
+
/** Angular CLI build cache, relative to the project root. */
|
|
13
|
+
const ANGULAR_CACHE = '.angular/cache';
|
|
14
|
+
/** Nx cache of Nx 17 and later, relative to the project root. */
|
|
15
|
+
const NX_CACHE = '.nx/cache';
|
|
16
|
+
/** Nx cache of older Nx versions; under node_modules, so it is never removed. */
|
|
17
|
+
const LEGACY_NX_CACHE = 'node_modules/.cache/nx';
|
|
18
|
+
/**
|
|
19
|
+
* Remove the Angular CLI cache and, in an Nx workspace, the Nx cache of a project.
|
|
20
|
+
*
|
|
21
|
+
* Missing caches are skipped silently; a cache that resolves outside the project
|
|
22
|
+
* root or under `node_modules`, or that cannot be removed, is left in place and
|
|
23
|
+
* reported in `warnings`.
|
|
24
|
+
*
|
|
25
|
+
* @param projectRoot - Root folder of the project
|
|
26
|
+
*/
|
|
27
|
+
export function clearBuildCaches(projectRoot) {
|
|
28
|
+
const result = { cleared: [], warnings: [] };
|
|
29
|
+
let root;
|
|
30
|
+
try {
|
|
31
|
+
root = realpathSync(projectRoot);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
result.warnings.push(`Build caches not cleared: ${errorMessage(error)}`);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
const isNx = existsSync(join(root, 'nx.json'));
|
|
38
|
+
const targets = isNx ? [ANGULAR_CACHE, NX_CACHE] : [ANGULAR_CACHE];
|
|
39
|
+
for (const target of targets) {
|
|
40
|
+
clearCache(root, target, result);
|
|
41
|
+
}
|
|
42
|
+
if (isNx && existsSync(join(root, LEGACY_NX_CACHE))) {
|
|
43
|
+
result.warnings.push(`${LEGACY_NX_CACHE} left in place: caches under node_modules are never removed; run \`nx reset\` to clear it`);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function clearCache(root, target, result) {
|
|
48
|
+
let resolved;
|
|
49
|
+
try {
|
|
50
|
+
resolved = realpathSync(join(root, target));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (isMissing(error)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
result.warnings.push(`${target} not cleared: ${errorMessage(error)}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!isInsideProject(root, resolved)) {
|
|
60
|
+
result.warnings.push(`${target} not cleared: it resolves to ${resolved}, outside the project root or under node_modules`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
rmSync(resolved, { recursive: true, force: true });
|
|
65
|
+
result.cleared.push(target);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
result.warnings.push(`${target} could not be removed: ${errorMessage(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function isInsideProject(root, resolved) {
|
|
72
|
+
const path = relative(root, resolved);
|
|
73
|
+
const outside = path === '' || path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path);
|
|
74
|
+
return !outside && !path.split(sep).includes('node_modules');
|
|
75
|
+
}
|
|
76
|
+
// Structural checks: fs errors from another realm (Jest's vm) fail `instanceof Error`
|
|
77
|
+
function isMissing(error) {
|
|
78
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
|
|
79
|
+
}
|
|
80
|
+
function errorMessage(error) {
|
|
81
|
+
if (typeof error === 'object' && error !== null && 'message' in error) {
|
|
82
|
+
return String(error.message);
|
|
83
|
+
}
|
|
84
|
+
return String(error);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=build-cache.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Class filter
|
|
3
|
+
*
|
|
4
|
+
* Explains an empty result of a tool that takes `className` for a file
|
|
5
|
+
* (inspect-template, inspect-form-group) when no class of the file has that
|
|
6
|
+
* name, instead of the generic "nothing found" message.
|
|
7
|
+
*/
|
|
8
|
+
import { type SourceFile } from 'ts-morph';
|
|
9
|
+
/**
|
|
10
|
+
* Message for a `className` that matches no class of `sourceFile`.
|
|
11
|
+
*
|
|
12
|
+
* @param sourceFile - The inspected file; `undefined` (an `.html` file) never matches.
|
|
13
|
+
* @param className - The requested class, if any.
|
|
14
|
+
* @param filePath - Path shown in the message.
|
|
15
|
+
* @returns The message, or `undefined` when no class was requested or the file declares it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function missingClassMessage(sourceFile: SourceFile | undefined, className: string | undefined, filePath: string): string | undefined;
|
|
18
|
+
//# sourceMappingURL=class-filter.d.ts.map
|