@angular-modernizer/adapter-mcp 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -35
- package/dist/cli.js +65 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-watcher.d.ts.map +1 -1
- package/dist/mcp-watcher.js +3 -0
- package/dist/mcp-watcher.js.map +1 -1
- package/dist/server/json-rpc-handler.d.ts +41 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -1
- package/dist/server/json-rpc-handler.js +85 -6
- package/dist/server/json-rpc-handler.js.map +1 -1
- package/dist/server/mcp-server.d.ts +31 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +76 -23
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/stdio-guard.d.ts +20 -0
- package/dist/server/stdio-guard.d.ts.map +1 -0
- package/dist/server/stdio-guard.js +48 -0
- package/dist/server/stdio-guard.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +169 -12
- package/dist/tools/analyze-build-impact.d.ts.map +1 -1
- package/dist/tools/analyze-build-impact.js +221 -36
- package/dist/tools/analyze-build-impact.js.map +1 -1
- package/dist/tools/analyze-parser-performance.d.ts.map +1 -1
- package/dist/tools/analyze-parser-performance.js +6 -4
- package/dist/tools/analyze-parser-performance.js.map +1 -1
- package/dist/tools/collect-feedback.d.ts +112 -1
- package/dist/tools/collect-feedback.d.ts.map +1 -1
- package/dist/tools/collect-feedback.js +240 -11
- package/dist/tools/collect-feedback.js.map +1 -1
- package/dist/tools/extract-libraries.d.ts +4 -0
- package/dist/tools/extract-libraries.d.ts.map +1 -1
- package/dist/tools/extract-libraries.js +40 -8
- package/dist/tools/extract-libraries.js.map +1 -1
- package/dist/tools/find-angular-symbol.d.ts +29 -6
- package/dist/tools/find-angular-symbol.d.ts.map +1 -1
- package/dist/tools/find-angular-symbol.js +51 -6
- package/dist/tools/find-angular-symbol.js.map +1 -1
- package/dist/tools/find-component-hosts.d.ts +114 -0
- package/dist/tools/find-component-hosts.d.ts.map +1 -0
- package/dist/tools/find-component-hosts.js +240 -0
- package/dist/tools/find-component-hosts.js.map +1 -0
- package/dist/tools/find-usages.d.ts +33 -4
- package/dist/tools/find-usages.d.ts.map +1 -1
- package/dist/tools/find-usages.js +102 -11
- package/dist/tools/find-usages.js.map +1 -1
- package/dist/tools/get-bootstrap-execution.d.ts +108 -0
- package/dist/tools/get-bootstrap-execution.d.ts.map +1 -0
- package/dist/tools/get-bootstrap-execution.js +243 -0
- package/dist/tools/get-bootstrap-execution.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +33 -4
- package/dist/tools/get-call-graph.d.ts.map +1 -1
- package/dist/tools/get-call-graph.js +76 -13
- package/dist/tools/get-call-graph.js.map +1 -1
- package/dist/tools/helpers/compact-output.d.ts +61 -0
- package/dist/tools/helpers/compact-output.d.ts.map +1 -0
- package/dist/tools/helpers/compact-output.js +83 -0
- package/dist/tools/helpers/compact-output.js.map +1 -0
- package/dist/tools/helpers/find-ts-config.d.ts +24 -1
- package/dist/tools/helpers/find-ts-config.d.ts.map +1 -1
- package/dist/tools/helpers/find-ts-config.js +213 -7
- package/dist/tools/helpers/find-ts-config.js.map +1 -1
- package/dist/tools/helpers/project-cache.d.ts +177 -0
- package/dist/tools/helpers/project-cache.d.ts.map +1 -0
- package/dist/tools/helpers/project-cache.js +313 -0
- package/dist/tools/helpers/project-cache.js.map +1 -0
- package/dist/tools/helpers/rule-runner.d.ts +67 -0
- package/dist/tools/helpers/rule-runner.d.ts.map +1 -0
- package/dist/tools/helpers/rule-runner.js +117 -0
- package/dist/tools/helpers/rule-runner.js.map +1 -0
- package/dist/tools/helpers/scan-plan.d.ts +45 -0
- package/dist/tools/helpers/scan-plan.d.ts.map +1 -0
- package/dist/tools/helpers/scan-plan.js +151 -0
- package/dist/tools/helpers/scan-plan.js.map +1 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts +10 -0
- package/dist/tools/helpers/stack-frame-file-index.d.ts.map +1 -0
- package/dist/tools/helpers/stack-frame-file-index.js +71 -0
- package/dist/tools/helpers/stack-frame-file-index.js.map +1 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +1 -1
- package/dist/tools/helpers/suggestion-generator.d.ts.map +1 -1
- package/dist/tools/helpers/suggestion-generator.js.map +1 -1
- package/dist/tools/inspect-form-group.d.ts +93 -0
- package/dist/tools/inspect-form-group.d.ts.map +1 -0
- package/dist/tools/inspect-form-group.js +161 -0
- package/dist/tools/inspect-form-group.js.map +1 -0
- package/dist/tools/inspect-i18n.d.ts +85 -0
- package/dist/tools/inspect-i18n.d.ts.map +1 -0
- package/dist/tools/inspect-i18n.js +203 -0
- package/dist/tools/inspect-i18n.js.map +1 -0
- package/dist/tools/inspect-template.d.ts +89 -0
- package/dist/tools/inspect-template.d.ts.map +1 -0
- package/dist/tools/inspect-template.js +166 -0
- package/dist/tools/inspect-template.js.map +1 -0
- package/dist/tools/list-imports.d.ts +119 -0
- package/dist/tools/list-imports.d.ts.map +1 -0
- package/dist/tools/list-imports.js +171 -0
- package/dist/tools/list-imports.js.map +1 -0
- package/dist/tools/orchestrate-migration.d.ts +1 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -1
- package/dist/tools/orchestrate-migration.js +33 -1
- package/dist/tools/orchestrate-migration.js.map +1 -1
- package/dist/tools/parse-stack-trace.d.ts +3 -1
- package/dist/tools/parse-stack-trace.d.ts.map +1 -1
- package/dist/tools/parse-stack-trace.js +18 -4
- package/dist/tools/parse-stack-trace.js.map +1 -1
- package/dist/tools/plan-migration.d.ts +89 -1
- package/dist/tools/plan-migration.d.ts.map +1 -1
- package/dist/tools/plan-migration.js +203 -7
- package/dist/tools/plan-migration.js.map +1 -1
- package/dist/tools/resolve-type.d.ts +3 -0
- package/dist/tools/resolve-type.d.ts.map +1 -1
- package/dist/tools/resolve-type.js +6 -2
- package/dist/tools/resolve-type.js.map +1 -1
- package/dist/tools/review-feedback.d.ts +7 -0
- package/dist/tools/review-feedback.d.ts.map +1 -1
- package/dist/tools/review-feedback.js +68 -16
- package/dist/tools/review-feedback.js.map +1 -1
- package/dist/tools/scan-all.d.ts +6 -6
- package/dist/tools/scan-all.d.ts.map +1 -1
- package/dist/tools/scan-all.js +7 -7
- package/dist/tools/scan-all.js.map +1 -1
- package/dist/tools/scan-angular.d.ts +1 -1
- package/dist/tools/scan-angular.js +1 -1
- package/dist/tools/scan-architecture.d.ts +25 -4
- package/dist/tools/scan-architecture.d.ts.map +1 -1
- package/dist/tools/scan-architecture.js +115 -134
- package/dist/tools/scan-architecture.js.map +1 -1
- package/dist/tools/scan-solid.d.ts +1 -1
- package/dist/tools/scan-solid.js +1 -1
- package/dist/tools/search-codebase.d.ts +32 -6
- package/dist/tools/search-codebase.d.ts.map +1 -1
- package/dist/tools/search-codebase.js +60 -14
- package/dist/tools/search-codebase.js.map +1 -1
- package/dist/tools/server-status.d.ts +96 -0
- package/dist/tools/server-status.d.ts.map +1 -0
- package/dist/tools/server-status.js +195 -0
- package/dist/tools/server-status.js.map +1 -0
- package/dist/tools/suggest-improvements.d.ts +3 -1
- package/dist/tools/suggest-improvements.d.ts.map +1 -1
- package/dist/tools/suggest-improvements.js +47 -10
- package/dist/tools/suggest-improvements.js.map +1 -1
- package/dist/tools/trace-output-flow.d.ts +111 -0
- package/dist/tools/trace-output-flow.d.ts.map +1 -0
- package/dist/tools/trace-output-flow.js +308 -0
- package/dist/tools/trace-output-flow.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -12
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Find Component Hosts Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool that lists every template using a component or directive and,
|
|
5
|
+
* per host, which inputs and outputs are bound, unbound or missing, plus
|
|
6
|
+
* the places creating a component in code (dialogs, `createComponent`,
|
|
7
|
+
* wrappers) as `dynamicHosts`.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Logic lives in `ComponentHostFinder` (`@angular-modernizer/api`); this tool
|
|
11
|
+
* resolves the project, validates arguments and applies the compact output
|
|
12
|
+
* contract (`maxResults` caps the host list and the dynamic host list each).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Via MCP:
|
|
17
|
+
* // tool: find-component-hosts
|
|
18
|
+
* // args: { className: 'ItemComponent', projectRoot: '/project' }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { ComponentHostFinder, } from '@angular-modernizer/api';
|
|
22
|
+
import { existsSync } from 'node:fs';
|
|
23
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
24
|
+
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
25
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
26
|
+
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
27
|
+
/** Host names listed per input/output in the text summary. */
|
|
28
|
+
const SUMMARY_MAX_NAMES = 5;
|
|
29
|
+
/**
|
|
30
|
+
* MCP tool that finds the template hosts of a component or directive.
|
|
31
|
+
*/
|
|
32
|
+
export class FindComponentHostsTool {
|
|
33
|
+
projects;
|
|
34
|
+
name = 'find-component-hosts';
|
|
35
|
+
constructor(projects = new ProjectCache()) {
|
|
36
|
+
this.projects = projects;
|
|
37
|
+
}
|
|
38
|
+
description = 'Find every component template that uses a component or directive (by className or selector) ' +
|
|
39
|
+
'and report per host: template file, element occurrences with line, which of the target\'s ' +
|
|
40
|
+
'inputs and outputs are bound or unbound, required inputs that are missing, and bindings no ' +
|
|
41
|
+
'matched project directive declares (native events, library directives, typos). coverage ' +
|
|
42
|
+
'lists per input/output which hosts bind it and which do not (e.g. "which hosts ignore ' +
|
|
43
|
+
'(formError)?"). Inputs/outputs come from @Input/@Output (aliases, required), signal input(), ' +
|
|
44
|
+
'input.required(), model(), output(), decorator inputs/outputs arrays and base classes. Test ' +
|
|
45
|
+
'hosts in spec files are skipped unless includeTestHosts. dynamicHosts lists places creating a ' +
|
|
46
|
+
'component in code: any call or new whose parameter takes a component type (MatDialog.open, ' +
|
|
47
|
+
'createComponent, ComponentPortal, project dialog wrappers), with sink, via (wrapper chain down ' +
|
|
48
|
+
'to the library call), resolution (literal, variable, field, di-token, method-return, callback, ' +
|
|
49
|
+
'selector, lazy-import, registry, promise), the other arguments (data) and what the caller does ' +
|
|
50
|
+
'with the result (e.g. afterClosed.subscribe; a stored result shows the use that subscribes to it). Route entries (component, loadComponent) are ' +
|
|
51
|
+
'dynamic hosts with route: path joined over children, guards, data, resolve, lazy. candidateHosts ' +
|
|
52
|
+
'lists places that may create it: lookups in a component registry (e.g. dynamicComponents) whose ' +
|
|
53
|
+
'selector comes from data (selectorExpression, selectorLiterals); a selector fixed by literals, a ' +
|
|
54
|
+
'switch mapping or an equality guard is decided (dynamicHosts or nothing). includeDynamic: false ' +
|
|
55
|
+
'skips both. ' +
|
|
56
|
+
'For result and data flow of a dialog use trace-output-flow. For widely used components start with ' +
|
|
57
|
+
'summaryOnly (counts per input/output only). summaryOnly drops the host list, ' +
|
|
58
|
+
'maxResults caps it and the host names in coverage; counts (incl. coverage bound/unbound) always ' +
|
|
59
|
+
'cover all hosts.';
|
|
60
|
+
inputSchema = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
className: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Class name of the component or directive. Give className or selector.',
|
|
66
|
+
},
|
|
67
|
+
selector: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Selector of the component or directive, e.g. "app-item" or "[appTooltip]". Give className or selector.',
|
|
70
|
+
},
|
|
71
|
+
file: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'File declaring the class (absolute, or relative to projectRoot). Picks one of several same-name classes. Optional.',
|
|
74
|
+
},
|
|
75
|
+
projectRoot: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'Absolute path to the project root. Must contain a tsconfig.json.',
|
|
78
|
+
},
|
|
79
|
+
includeOccurrences: {
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
description: 'Include per-element occurrences with line and bindings. Default: true.',
|
|
82
|
+
default: true,
|
|
83
|
+
},
|
|
84
|
+
includeTestHosts: {
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
description: 'Also report test host components declared in *.spec.ts / *.test.ts. Default: false.',
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
includeDynamic: {
|
|
90
|
+
type: 'boolean',
|
|
91
|
+
description: 'Also find places creating the component in code (dialogs, createComponent, wrappers) as dynamicHosts. Default: true.',
|
|
92
|
+
default: true,
|
|
93
|
+
},
|
|
94
|
+
...COMPACT_OUTPUT_SCHEMA,
|
|
95
|
+
},
|
|
96
|
+
required: ['projectRoot'],
|
|
97
|
+
};
|
|
98
|
+
async execute(args) {
|
|
99
|
+
const params = args;
|
|
100
|
+
if (!params.className && !params.selector) {
|
|
101
|
+
throw new Error('className or selector is required');
|
|
102
|
+
}
|
|
103
|
+
if (!params.projectRoot) {
|
|
104
|
+
throw new Error('projectRoot is required');
|
|
105
|
+
}
|
|
106
|
+
const compact = parseCompactOptions(args);
|
|
107
|
+
if (!existsSync(params.projectRoot)) {
|
|
108
|
+
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
109
|
+
}
|
|
110
|
+
const tsConfigPath = findTsConfig(params.projectRoot);
|
|
111
|
+
if (!tsConfigPath) {
|
|
112
|
+
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
113
|
+
}
|
|
114
|
+
const file = params.file === undefined || isAbsolute(params.file)
|
|
115
|
+
? params.file
|
|
116
|
+
: resolve(params.projectRoot, params.file);
|
|
117
|
+
const finder = new ComponentHostFinder(this.projects.get(tsConfigPath), {
|
|
118
|
+
includeTestHosts: params.includeTestHosts === true,
|
|
119
|
+
includeDynamic: params.includeDynamic !== false,
|
|
120
|
+
});
|
|
121
|
+
const result = finder.findHosts({
|
|
122
|
+
...(params.className ? { className: params.className } : {}),
|
|
123
|
+
...(params.selector ? { selector: params.selector } : {}),
|
|
124
|
+
...(file === undefined ? {} : { file }),
|
|
125
|
+
});
|
|
126
|
+
const { hosts, coverage, dynamicHosts, candidateHosts, ...rest } = result;
|
|
127
|
+
const summary = this.buildSummary(params, result);
|
|
128
|
+
if (compact.summaryOnly) {
|
|
129
|
+
return {
|
|
130
|
+
...rest,
|
|
131
|
+
coverage: this.shapeCoverage(coverage, (c) => ({ bound: c.bound, unbound: c.unbound })),
|
|
132
|
+
truncated: false,
|
|
133
|
+
dynamicTruncated: false,
|
|
134
|
+
candidateTruncated: false,
|
|
135
|
+
summary,
|
|
136
|
+
tsConfigPath,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const includeOccurrences = params.includeOccurrences !== false;
|
|
140
|
+
const shown = limitList(hosts, compact.maxResults);
|
|
141
|
+
const shownDynamic = limitList(dynamicHosts, compact.maxResults);
|
|
142
|
+
const shownCandidates = limitList(candidateHosts, compact.maxResults);
|
|
143
|
+
const note = [
|
|
144
|
+
truncationNote(shown.items.length, hosts.length, 'hosts'),
|
|
145
|
+
truncationNote(shownDynamic.items.length, dynamicHosts.length, 'dynamic hosts'),
|
|
146
|
+
truncationNote(shownCandidates.items.length, candidateHosts.length, 'candidate hosts'),
|
|
147
|
+
]
|
|
148
|
+
.filter((n) => n !== undefined)
|
|
149
|
+
.join('\n');
|
|
150
|
+
const cappedCoverage = this.shapeCoverage(coverage, (c) => ({
|
|
151
|
+
...c,
|
|
152
|
+
boundIn: limitList(c.boundIn, compact.maxResults).items,
|
|
153
|
+
unboundIn: limitList(c.unboundIn, compact.maxResults).items,
|
|
154
|
+
}));
|
|
155
|
+
return {
|
|
156
|
+
...rest,
|
|
157
|
+
coverage: cappedCoverage,
|
|
158
|
+
hosts: shown.items.map((h) => {
|
|
159
|
+
if (includeOccurrences) {
|
|
160
|
+
return h;
|
|
161
|
+
}
|
|
162
|
+
const { occurrences: _dropped, ...host } = h;
|
|
163
|
+
return host;
|
|
164
|
+
}),
|
|
165
|
+
truncated: shown.truncated,
|
|
166
|
+
dynamicHosts: shownDynamic.items,
|
|
167
|
+
dynamicTruncated: shownDynamic.truncated,
|
|
168
|
+
candidateHosts: shownCandidates.items,
|
|
169
|
+
candidateTruncated: shownCandidates.truncated,
|
|
170
|
+
summary: note ? `${note}\n${summary}` : summary,
|
|
171
|
+
tsConfigPath,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
buildSummary(params, result) {
|
|
175
|
+
const target = result.target;
|
|
176
|
+
if (target === undefined) {
|
|
177
|
+
const wanted = params.className ?? params.selector ?? '';
|
|
178
|
+
return (`No project component or directive matches '${wanted}'. Only classes with @Component, ` +
|
|
179
|
+
'@ExportComponent or @Directive and a selector in the tsconfig program are known; library ' +
|
|
180
|
+
'components are not. Check the name with find-angular-symbol.');
|
|
181
|
+
}
|
|
182
|
+
const lines = [
|
|
183
|
+
`${target.className} (${target.selector}): ${result.counts.hosts} host(s), ` +
|
|
184
|
+
`${result.counts.occurrences} occurrence(s) in ${result.counts.templatesScanned} candidate template(s).`,
|
|
185
|
+
];
|
|
186
|
+
if (result.alternatives.length > 0) {
|
|
187
|
+
lines.push(` Also matched: ${result.alternatives.map((a) => `${a.className} (${a.file})`).join(', ')}. ` +
|
|
188
|
+
'Pass file to pick one.');
|
|
189
|
+
}
|
|
190
|
+
for (const [kind, coverage] of [
|
|
191
|
+
['input', result.coverage.inputs],
|
|
192
|
+
['output', result.coverage.outputs],
|
|
193
|
+
]) {
|
|
194
|
+
for (const [name, c] of Object.entries(coverage)) {
|
|
195
|
+
const unbound = c.unbound > 0 ? `, not in ${c.unbound} (${this.nameList(c.unboundIn)})` : '';
|
|
196
|
+
lines.push(` ${kind} ${name}: bound in ${c.bound}${unbound}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (result.counts.occurrencesMissingRequired > 0) {
|
|
200
|
+
lines.push(` ${result.counts.occurrencesMissingRequired} occurrence(s) miss a required input.`);
|
|
201
|
+
}
|
|
202
|
+
if (result.counts.dynamicHosts > 0) {
|
|
203
|
+
lines.push(` Created in code at ${result.counts.dynamicHosts} place(s): ${this.sinkList(result.dynamicHosts)}.`);
|
|
204
|
+
}
|
|
205
|
+
const routes = result.dynamicHosts.filter((h) => h.route !== undefined);
|
|
206
|
+
if (routes.length > 0) {
|
|
207
|
+
lines.push(` Routes: ${this.nameList(routes.map((h) => `/${h.route?.path ?? ''}${h.route?.lazy === true ? ' (lazy)' : ''}`))}.`);
|
|
208
|
+
}
|
|
209
|
+
if (result.counts.candidateHosts > 0) {
|
|
210
|
+
const expressions = [...new Set(result.candidateHosts.map((h) => h.selectorExpression ?? '?'))];
|
|
211
|
+
lines.push(` May be created at ${result.counts.candidateHosts} more place(s) through a component registry with a ` +
|
|
212
|
+
`selector from data (${this.nameList(expressions)}).`);
|
|
213
|
+
}
|
|
214
|
+
if (result.counts.hosts === 0 && result.counts.dynamicHosts === 0 && result.counts.candidateHosts === 0) {
|
|
215
|
+
lines.push(params.includeDynamic === false
|
|
216
|
+
? ' No template uses it. It may be created in code; run again without includeDynamic: false.'
|
|
217
|
+
: ' No template uses it and no creation in code, route or registry lookup was found; ' +
|
|
218
|
+
'check with find-usages.');
|
|
219
|
+
}
|
|
220
|
+
return lines.join('\n');
|
|
221
|
+
}
|
|
222
|
+
shapeCoverage(coverage, shape) {
|
|
223
|
+
const map = (entries) => Object.fromEntries(Object.entries(entries).map(([name, c]) => [name, shape(c)]));
|
|
224
|
+
return { inputs: map(coverage.inputs), outputs: map(coverage.outputs) };
|
|
225
|
+
}
|
|
226
|
+
/** `SobSolDialog.open 24, new SobSolDialogRef 2` */
|
|
227
|
+
sinkList(hosts) {
|
|
228
|
+
const counts = new Map();
|
|
229
|
+
for (const h of hosts) {
|
|
230
|
+
counts.set(h.sink, (counts.get(h.sink) ?? 0) + 1);
|
|
231
|
+
}
|
|
232
|
+
const sorted = [...counts.entries()].sort((a, b) => b[1] - a[1]).map(([sink, n]) => `${sink} ${n}`);
|
|
233
|
+
return this.nameList(sorted);
|
|
234
|
+
}
|
|
235
|
+
nameList(names) {
|
|
236
|
+
const shown = names.slice(0, SUMMARY_MAX_NAMES).join(', ');
|
|
237
|
+
return names.length > SUMMARY_MAX_NAMES ? `${shown}, +${names.length - SUMMARY_MAX_NAMES} more` : shown;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=find-component-hosts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-component-hosts.js","sourceRoot":"","sources":["../../src/tools/find-component-hosts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EACL,mBAAmB,GAKpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,mBAAmB,EACnB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC,8DAA8D;AAC9D,MAAM,iBAAiB,GAAG,CAAC,CAAC;AA2E5B;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAGJ;IAFpB,IAAI,GAAG,sBAAsB,CAAC;IAEvC,YAA6B,WAAyB,IAAI,YAAY,EAAE;QAA3C,aAAQ,GAAR,QAAQ,CAAmC;IAAG,CAAC;IAEnE,WAAW,GAClB,8FAA8F;QAC9F,4F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AC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAEO,QAAQ,CAAC,KAAe;QAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,KAAK,CAAC,MAAM,GAAG,iBAAiB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1G,CAAC;CACF"}
|
|
@@ -17,27 +17,47 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
import { type MCPTool } from '../types.js';
|
|
20
|
-
import { type SymbolUsage } from '@angular-modernizer/api';
|
|
20
|
+
import { type SymbolUsage, type UsageType } from '@angular-modernizer/api';
|
|
21
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
21
22
|
/**
|
|
22
23
|
* Output of the find-usages tool.
|
|
23
24
|
*/
|
|
24
25
|
interface FindUsagesOutput {
|
|
25
|
-
/**
|
|
26
|
-
usages
|
|
27
|
-
/** Total number of usages found. */
|
|
26
|
+
/** Matching usages, cut to `maxResults`; omitted with `summaryOnly`. */
|
|
27
|
+
usages?: SymbolUsage[];
|
|
28
|
+
/** Total number of usages found (before `maxResults`). */
|
|
28
29
|
totalCount: number;
|
|
30
|
+
/** `true` when `maxResults` cut the usage list. */
|
|
31
|
+
truncated: boolean;
|
|
29
32
|
/** Human-readable summary for LLM consumption. */
|
|
30
33
|
summary: string;
|
|
34
|
+
/** Usage counts per usage type. */
|
|
35
|
+
countsByType: Partial<Record<UsageType, number>>;
|
|
36
|
+
/** Usage counts per directory (up to 3 levels below projectRoot), largest first. */
|
|
37
|
+
countsByDirectory: Record<string, number>;
|
|
38
|
+
/** The tsconfig whose program was searched. */
|
|
39
|
+
tsConfigPath: string;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* MCP tool that finds all references to a named symbol across a TypeScript project.
|
|
34
43
|
*/
|
|
35
44
|
export declare class FindUsagesTool implements MCPTool {
|
|
45
|
+
private readonly projects;
|
|
36
46
|
readonly name = "find-usages";
|
|
47
|
+
constructor(projects?: ProjectCache);
|
|
37
48
|
readonly description: string;
|
|
38
49
|
readonly inputSchema: {
|
|
39
50
|
type: string;
|
|
40
51
|
properties: {
|
|
52
|
+
summaryOnly: {
|
|
53
|
+
readonly type: "boolean";
|
|
54
|
+
readonly description: "Return counts and the text summary only, without the result list. Default: false.";
|
|
55
|
+
readonly default: false;
|
|
56
|
+
};
|
|
57
|
+
maxResults: {
|
|
58
|
+
readonly type: "number";
|
|
59
|
+
readonly description: string;
|
|
60
|
+
};
|
|
41
61
|
symbol: {
|
|
42
62
|
type: string;
|
|
43
63
|
description: string;
|
|
@@ -55,10 +75,19 @@ export declare class FindUsagesTool implements MCPTool {
|
|
|
55
75
|
enum: string[];
|
|
56
76
|
description: string;
|
|
57
77
|
};
|
|
78
|
+
includeTemplates: {
|
|
79
|
+
type: string;
|
|
80
|
+
description: string;
|
|
81
|
+
};
|
|
82
|
+
includeUnresolved: {
|
|
83
|
+
type: string;
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
58
86
|
};
|
|
59
87
|
required: string[];
|
|
60
88
|
};
|
|
61
89
|
execute(args: Record<string, unknown>): Promise<FindUsagesOutput>;
|
|
90
|
+
private buildCompactSummary;
|
|
62
91
|
private buildSummary;
|
|
63
92
|
}
|
|
64
93
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-usages.d.ts","sourceRoot":"","sources":["../../src/tools/find-usages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"find-usages.d.ts","sourceRoot":"","sources":["../../src/tools/find-usages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAmD1D;;GAEG;AACH,UAAU,gBAAgB;IACxB,wEAAwE;IACxE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IAEvB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IAEnB,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IAEnB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAEhB,mCAAmC;IACnC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjD,oFAAoF;IACpF,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,OAAO;IAGhC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,IAAI,iBAAiB;gBAED,QAAQ,GAAE,YAAiC;IAExE,QAAQ,CAAC,WAAW,SAayE;IAE7F,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgDlB;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA4EvE,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,YAAY;CAyCrB"}
|
|
@@ -16,19 +16,37 @@
|
|
|
16
16
|
* // args: { symbol: 'UserService', projectRoot: '/my/project', file: '/my/project/src/app/user.component.ts' }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { Project } from 'ts-morph';
|
|
20
19
|
import { UsageFinder, } from '@angular-modernizer/api';
|
|
21
20
|
import { existsSync } from 'node:fs';
|
|
22
21
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
22
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
23
|
+
import { COMPACT_OUTPUT_SCHEMA, countByDirectory, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
24
|
+
/** Directory depth (relative to projectRoot) used for `countsByDirectory`. */
|
|
25
|
+
const DIRECTORY_DEPTH = 3;
|
|
26
|
+
/** Directories listed in the summaryOnly text. */
|
|
27
|
+
const SUMMARY_TOP_DIRECTORIES = 10;
|
|
23
28
|
/**
|
|
24
29
|
* MCP tool that finds all references to a named symbol across a TypeScript project.
|
|
25
30
|
*/
|
|
26
31
|
export class FindUsagesTool {
|
|
32
|
+
projects;
|
|
27
33
|
name = 'find-usages';
|
|
34
|
+
constructor(projects = new ProjectCache()) {
|
|
35
|
+
this.projects = projects;
|
|
36
|
+
}
|
|
28
37
|
description = 'Find all references to a symbol (class, method, function, variable, or constant) ' +
|
|
29
38
|
'across a TypeScript project. Returns file paths, line numbers, source snippets, ' +
|
|
30
|
-
'and usage type
|
|
31
|
-
'
|
|
39
|
+
'and usage type: read/write/call/argument/decorator-argument (resolved references), ' +
|
|
40
|
+
'declaration (the name of the declaring class, method, property or interface member), ' +
|
|
41
|
+
'template (Angular template ' +
|
|
42
|
+
'usage: component/directive selector, pipe name, member read/call/write, input/output ' +
|
|
43
|
+
'binding; external templateUrl and inline templates; templateMatch is "verified" or ' +
|
|
44
|
+
'"template-unverified" for same-name matches that could not be tied to the symbol), ' +
|
|
45
|
+
'and unresolved (same-name identifiers whose symbol does not resolve, e.g. a class ' +
|
|
46
|
+
'still used after its import was removed). The file option filters reported usages only. ' +
|
|
47
|
+
'Use after parse-stack-trace to trace call paths and determine blast radius before ' +
|
|
48
|
+
'proposing a bug fix. countsByType and countsByDirectory always cover all usages; ' +
|
|
49
|
+
'use summaryOnly for a quick overview of widely used symbols, maxResults to cap the list.';
|
|
32
50
|
inputSchema = {
|
|
33
51
|
type: 'object',
|
|
34
52
|
properties: {
|
|
@@ -42,13 +60,33 @@ export class FindUsagesTool {
|
|
|
42
60
|
},
|
|
43
61
|
file: {
|
|
44
62
|
type: 'string',
|
|
45
|
-
description: '
|
|
63
|
+
description: 'Only report usages located in this file (absolute path, .ts or .html). ' +
|
|
64
|
+
'The symbol declaration may live in any file. Optional.',
|
|
46
65
|
},
|
|
47
66
|
usageType: {
|
|
48
67
|
type: 'string',
|
|
49
|
-
enum: [
|
|
50
|
-
|
|
68
|
+
enum: [
|
|
69
|
+
'declaration',
|
|
70
|
+
'read',
|
|
71
|
+
'write',
|
|
72
|
+
'call',
|
|
73
|
+
'argument',
|
|
74
|
+
'decorator-argument',
|
|
75
|
+
'template',
|
|
76
|
+
'unresolved',
|
|
77
|
+
],
|
|
78
|
+
description: 'Restrict results to this usage type. `call` is only the callee; ' +
|
|
79
|
+
'`inject(Foo)` is `argument`, `@ViewChild(Foo)` is `decorator-argument`. Optional.',
|
|
80
|
+
},
|
|
81
|
+
includeTemplates: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
description: 'Include Angular template usages (selectors, pipes, member reads/calls, bindings). Defaults to true.',
|
|
51
84
|
},
|
|
85
|
+
includeUnresolved: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
description: 'Include same-name identifiers that do not resolve to any symbol (e.g. missing import, TS2304). Defaults to true.',
|
|
88
|
+
},
|
|
89
|
+
...COMPACT_OUTPUT_SCHEMA,
|
|
52
90
|
},
|
|
53
91
|
required: ['symbol', 'projectRoot'],
|
|
54
92
|
};
|
|
@@ -60,6 +98,7 @@ export class FindUsagesTool {
|
|
|
60
98
|
if (!params.projectRoot) {
|
|
61
99
|
throw new Error('projectRoot is required');
|
|
62
100
|
}
|
|
101
|
+
const compact = parseCompactOptions(args);
|
|
63
102
|
if (!existsSync(params.projectRoot)) {
|
|
64
103
|
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
65
104
|
}
|
|
@@ -67,22 +106,71 @@ export class FindUsagesTool {
|
|
|
67
106
|
if (!tsConfigPath) {
|
|
68
107
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
69
108
|
}
|
|
70
|
-
|
|
109
|
+
// The shared ProjectCache: a fresh Project cost 4 to 6 s per call on
|
|
110
|
+
// ngUWI and sat next to the cached one while the search ran.
|
|
111
|
+
const project = this.projects.get(tsConfigPath);
|
|
71
112
|
const finder = new UsageFinder(project);
|
|
72
113
|
const usages = finder.findUsages(params.symbol, {
|
|
73
114
|
file: params.file,
|
|
74
115
|
usageType: params.usageType,
|
|
116
|
+
includeTemplates: params.includeTemplates !== false,
|
|
117
|
+
includeUnresolved: params.includeUnresolved !== false,
|
|
75
118
|
});
|
|
119
|
+
const countsByType = {};
|
|
120
|
+
for (const u of usages) {
|
|
121
|
+
countsByType[u.usageType] = (countsByType[u.usageType] ?? 0) + 1;
|
|
122
|
+
}
|
|
123
|
+
const countsByDirectory = countByDirectory(usages.map((u) => u.file), params.projectRoot, DIRECTORY_DEPTH);
|
|
124
|
+
const shown = limitList(usages, compact.maxResults);
|
|
125
|
+
if (compact.summaryOnly) {
|
|
126
|
+
return {
|
|
127
|
+
totalCount: usages.length,
|
|
128
|
+
truncated: false,
|
|
129
|
+
summary: this.buildCompactSummary(params.symbol, usages, countsByType, countsByDirectory, params.file),
|
|
130
|
+
countsByType,
|
|
131
|
+
countsByDirectory,
|
|
132
|
+
tsConfigPath,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const note = truncationNote(shown.items.length, usages.length, 'usages');
|
|
136
|
+
const summary = this.buildSummary(params.symbol, shown.items, params.file);
|
|
76
137
|
return {
|
|
77
|
-
usages,
|
|
138
|
+
usages: shown.items,
|
|
78
139
|
totalCount: usages.length,
|
|
79
|
-
|
|
140
|
+
truncated: shown.truncated,
|
|
141
|
+
summary: note ? `${note}\n${summary}` : summary,
|
|
142
|
+
countsByType,
|
|
143
|
+
countsByDirectory,
|
|
144
|
+
tsConfigPath,
|
|
80
145
|
};
|
|
81
146
|
}
|
|
147
|
+
buildCompactSummary(symbol, usages, countsByType, countsByDirectory, file) {
|
|
148
|
+
if (usages.length === 0) {
|
|
149
|
+
return this.buildSummary(symbol, usages, file);
|
|
150
|
+
}
|
|
151
|
+
const fileCount = new Set(usages.map((u) => u.file)).size;
|
|
152
|
+
const types = Object.entries(countsByType)
|
|
153
|
+
.map(([type, count]) => `${type} ${count}`)
|
|
154
|
+
.join(', ');
|
|
155
|
+
const directories = Object.entries(countsByDirectory);
|
|
156
|
+
const lines = [
|
|
157
|
+
`Found ${usages.length} usage(s) of '${symbol}' in ${fileCount} file(s). By type: ${types}.`,
|
|
158
|
+
'Top directories:',
|
|
159
|
+
...directories
|
|
160
|
+
.slice(0, SUMMARY_TOP_DIRECTORIES)
|
|
161
|
+
.map(([dir, count]) => ` ${dir} (${count})`),
|
|
162
|
+
];
|
|
163
|
+
if (directories.length > SUMMARY_TOP_DIRECTORIES) {
|
|
164
|
+
lines.push(` ... ${directories.length - SUMMARY_TOP_DIRECTORIES} more directories in countsByDirectory`);
|
|
165
|
+
}
|
|
166
|
+
return lines.join('\n');
|
|
167
|
+
}
|
|
82
168
|
buildSummary(symbol, usages, file) {
|
|
83
169
|
if (usages.length === 0) {
|
|
84
170
|
const scope = file ? `in ${file}` : 'across the project';
|
|
85
|
-
return `No usages of '${symbol}' found ${scope}
|
|
171
|
+
return (`No usages of '${symbol}' found ${scope}. Only files in the tsconfig program ` +
|
|
172
|
+
'and component templates were searched; verify with search-codebase (text mode) ' +
|
|
173
|
+
'before treating this as proof of absence.');
|
|
86
174
|
}
|
|
87
175
|
const byFile = new Map();
|
|
88
176
|
for (const u of usages) {
|
|
@@ -96,7 +184,10 @@ export class FindUsagesTool {
|
|
|
96
184
|
for (const [filePath, fileUsages] of byFile) {
|
|
97
185
|
lines.push(` ${filePath} (${fileUsages.length})`);
|
|
98
186
|
for (const u of fileUsages.slice(0, 3)) {
|
|
99
|
-
|
|
187
|
+
const tag = u.templateMatch === 'template-unverified'
|
|
188
|
+
? `${u.usageType}:unverified`
|
|
189
|
+
: u.usageType;
|
|
190
|
+
lines.push(` L${u.line}: [${tag}] ${u.snippet}`);
|
|
100
191
|
}
|
|
101
192
|
if (fileUsages.length > 3) {
|
|
102
193
|
lines.push(` ... and ${fileUsages.length - 3} more`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-usages.js","sourceRoot":"","sources":["../../src/tools/find-usages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"find-usages.js","sourceRoot":"","sources":["../../src/tools/find-usages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,WAAW,GAGZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,mBA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AM,GAAG,CAAC,EAAE,CAAC;gBAC1B,KAAK,CAAC,IAAI,CAAC,eAAe,UAAU,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Get Bootstrap Execution Tool
|
|
3
|
+
*
|
|
4
|
+
* MCP tool that lists what an Angular app runs at startup (initializers,
|
|
5
|
+
* bootstrap component/module), on the first HTTP request (interceptors) and
|
|
6
|
+
* on first injection (provider factories), including everything reached
|
|
7
|
+
* through calls and dependency injection, and where a watched expression
|
|
8
|
+
* such as `AppConfig.settings` is read or written on the way.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Logic lives in `BootstrapExecutionAnalyzer` (`@angular-modernizer/api`);
|
|
12
|
+
* this tool resolves the project, validates arguments and applies the
|
|
13
|
+
* compact output contract.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Via MCP:
|
|
18
|
+
* // tool: get-bootstrap-execution
|
|
19
|
+
* // args: { projectRoot: '/project', watch: ['AppConfig.settings'], summaryOnly: true }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { type MCPTool } from '../types.js';
|
|
23
|
+
import { type BootstrapExecutionResult, type BootstrapRoot, type BootstrapTiming, type BootstrapWatchHit } from '@angular-modernizer/api';
|
|
24
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
25
|
+
/** A root with its reached list optionally dropped or capped. */
|
|
26
|
+
type RootOutput = Omit<BootstrapRoot, 'reached'> & Partial<Pick<BootstrapRoot, 'reached'>> & {
|
|
27
|
+
reachedCount: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Output of the get-bootstrap-execution tool.
|
|
31
|
+
*/
|
|
32
|
+
interface GetBootstrapExecutionOutput {
|
|
33
|
+
roots?: RootOutput[];
|
|
34
|
+
watchHits?: BootstrapWatchHit[];
|
|
35
|
+
counts: BootstrapExecutionResult['counts'];
|
|
36
|
+
/** `true` when `maxResults` cut a reached list or the watch hits. */
|
|
37
|
+
truncated: boolean;
|
|
38
|
+
summary: string;
|
|
39
|
+
tsConfigPath: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* MCP tool that reports what runs at application startup.
|
|
43
|
+
*/
|
|
44
|
+
export declare class GetBootstrapExecutionTool implements MCPTool {
|
|
45
|
+
private readonly projects;
|
|
46
|
+
readonly name = "get-bootstrap-execution";
|
|
47
|
+
constructor(projects?: ProjectCache);
|
|
48
|
+
readonly description: string;
|
|
49
|
+
readonly inputSchema: {
|
|
50
|
+
type: string;
|
|
51
|
+
properties: {
|
|
52
|
+
summaryOnly: {
|
|
53
|
+
readonly type: "boolean";
|
|
54
|
+
readonly description: "Return counts and the text summary only, without the result list. Default: false.";
|
|
55
|
+
readonly default: false;
|
|
56
|
+
};
|
|
57
|
+
maxResults: {
|
|
58
|
+
readonly type: "number";
|
|
59
|
+
readonly description: string;
|
|
60
|
+
};
|
|
61
|
+
projectRoot: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
watch: {
|
|
66
|
+
type: string;
|
|
67
|
+
items: {
|
|
68
|
+
type: string;
|
|
69
|
+
};
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
timings: {
|
|
73
|
+
type: string;
|
|
74
|
+
items: {
|
|
75
|
+
type: string;
|
|
76
|
+
enum: BootstrapTiming[];
|
|
77
|
+
};
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
file: {
|
|
81
|
+
type: string;
|
|
82
|
+
description: string;
|
|
83
|
+
};
|
|
84
|
+
method: {
|
|
85
|
+
type: string;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
depth: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
maxNodes: {
|
|
93
|
+
type: string;
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
includeReached: {
|
|
97
|
+
type: string;
|
|
98
|
+
description: string;
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
required: string[];
|
|
103
|
+
};
|
|
104
|
+
execute(args: Record<string, unknown>): Promise<GetBootstrapExecutionOutput>;
|
|
105
|
+
private buildSummary;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=get-bootstrap-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-bootstrap-execution.d.ts","sourceRoot":"","sources":["../../src/tools/get-bootstrap-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAkD1D,iEAAiE;AACjE,KAAK,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;GAEG;AACH,UAAU,2BAA2B;IACnC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAE3C,qEAAqE;IACrE,SAAS,EAAE,OAAO,CAAC;IAEnB,OAAO,EAAE,M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