@angular-modernizer/adapter-mcp 1.0.0 → 1.2.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 +81 -65
- package/dist/cli.js +8 -0
- package/dist/core/project-analyzer.d.ts +3 -12
- package/dist/core/project-analyzer.js +3 -12
- package/dist/index.d.ts +118 -3
- package/dist/index.js +46 -3
- package/dist/mcp-watcher.d.ts +28 -8
- package/dist/mcp-watcher.js +7 -7
- package/dist/scan-host/scan-host.d.ts +119 -0
- package/dist/scan-host/scan-host.js +376 -0
- package/dist/scan-host/scan-protocol.d.ts +35 -0
- package/dist/scan-host/scan-protocol.js +6 -0
- package/dist/scan-host/scan-worker.d.ts +14 -0
- package/dist/scan-host/scan-worker.js +48 -0
- package/dist/server/limited-stdio-transport.d.ts +7 -0
- package/dist/server/mcp-server.d.ts +11 -7
- package/dist/server/mcp-server.js +4 -7
- package/dist/server/sdk-server.d.ts +1 -0
- package/dist/server/tool-registry.d.ts +3 -7
- package/dist/server/tool-registry.js +1 -7
- package/dist/streaming/progress-store.d.ts +22 -5
- package/dist/streaming/progress-store.js +9 -5
- package/dist/tools/analyze-build-impact.d.ts +58 -36
- package/dist/tools/analyze-build-impact.js +36 -29
- package/dist/tools/analyze-core-to-shared.d.ts +42 -12
- package/dist/tools/analyze-core-to-shared.js +11 -10
- package/dist/tools/analyze-parser-performance.d.ts +23 -22
- package/dist/tools/analyze-parser-performance.js +20 -18
- package/dist/tools/analyze-project.d.ts +87 -14
- package/dist/tools/analyze-project.js +140 -122
- package/dist/tools/check-incremental-compatibility.d.ts +13 -11
- package/dist/tools/check-incremental-compatibility.js +11 -8
- package/dist/tools/collect-feedback.d.ts +41 -26
- package/dist/tools/collect-feedback.js +32 -23
- package/dist/tools/compare-health.d.ts +76 -19
- package/dist/tools/compare-health.js +26 -19
- package/dist/tools/extract-libraries.d.ts +44 -20
- package/dist/tools/extract-libraries.js +16 -17
- package/dist/tools/find-angular-symbol.d.ts +27 -25
- package/dist/tools/find-angular-symbol.js +19 -16
- package/dist/tools/find-component-hosts.d.ts +33 -27
- package/dist/tools/find-component-hosts.js +27 -24
- package/dist/tools/find-usages.d.ts +25 -23
- package/dist/tools/find-usages.js +21 -18
- package/dist/tools/get-bootstrap-execution.d.ts +35 -27
- package/dist/tools/get-bootstrap-execution.js +28 -25
- package/dist/tools/get-call-graph.d.ts +19 -14
- package/dist/tools/get-call-graph.js +26 -23
- package/dist/tools/get-operation-progress-tool.d.ts +12 -6
- package/dist/tools/get-operation-progress-tool.js +11 -6
- package/dist/tools/get-operation-progress.d.ts +26 -0
- package/dist/tools/helpers/analysis-output.d.ts +5 -0
- package/dist/tools/helpers/batch-kernel.d.ts +14 -0
- package/dist/tools/helpers/batch-kernel.js +12 -0
- package/dist/tools/helpers/compact-output.d.ts +2 -1
- package/dist/tools/helpers/compact-output.js +2 -1
- package/dist/tools/helpers/health-delta.d.ts +27 -14
- package/dist/tools/helpers/health-delta.js +11 -14
- package/dist/tools/helpers/project-cache.d.ts +123 -36
- package/dist/tools/helpers/project-cache.js +227 -43
- package/dist/tools/helpers/rule-runner.d.ts +23 -16
- package/dist/tools/helpers/rule-runner.js +24 -17
- package/dist/tools/helpers/scan-engine.d.ts +107 -0
- package/dist/tools/helpers/scan-engine.js +197 -0
- package/dist/tools/helpers/scan-plan.d.ts +1 -1
- package/dist/tools/helpers/scan-plan.js +1 -1
- package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
- package/dist/tools/helpers/suggestion-generator.js +0 -12
- package/dist/tools/helpers/tool-cache.d.ts +11 -0
- package/dist/tools/helpers/tool-cache.js +15 -0
- package/dist/tools/helpers/tool-context.d.ts +11 -8
- package/dist/tools/helpers/tool-context.js +5 -8
- package/dist/tools/inspect-form-group.d.ts +34 -27
- package/dist/tools/inspect-form-group.js +27 -24
- package/dist/tools/inspect-i18n.d.ts +31 -25
- package/dist/tools/inspect-i18n.js +23 -20
- package/dist/tools/inspect-template.d.ts +32 -25
- package/dist/tools/inspect-template.js +26 -23
- package/dist/tools/learn-patterns.d.ts +88 -12
- package/dist/tools/learn-patterns.js +17 -11
- package/dist/tools/list-imports.d.ts +45 -28
- package/dist/tools/list-imports.js +26 -23
- package/dist/tools/orchestrate-migration.d.ts +31 -9
- package/dist/tools/orchestrate-migration.js +12 -7
- package/dist/tools/parse-stack-trace.d.ts +23 -21
- package/dist/tools/parse-stack-trace.js +10 -7
- package/dist/tools/plan-migration.d.ts +67 -27
- package/dist/tools/plan-migration.js +22 -21
- package/dist/tools/resolve-type.d.ts +20 -10
- package/dist/tools/resolve-type.js +21 -13
- package/dist/tools/review-feedback.d.ts +27 -24
- package/dist/tools/review-feedback.js +24 -20
- package/dist/tools/rollback-changes.d.ts +13 -9
- package/dist/tools/rollback-changes.js +10 -7
- package/dist/tools/run-angular-cli.d.ts +12 -10
- package/dist/tools/run-angular-cli.js +11 -8
- package/dist/tools/run-build.d.ts +13 -11
- package/dist/tools/run-build.js +11 -8
- package/dist/tools/run-schematic.d.ts +12 -10
- package/dist/tools/run-schematic.js +11 -8
- package/dist/tools/scan-all.d.ts +69 -12
- package/dist/tools/scan-all.js +55 -122
- package/dist/tools/scan-angular.d.ts +41 -9
- package/dist/tools/scan-angular.js +66 -135
- package/dist/tools/scan-architecture.d.ts +75 -14
- package/dist/tools/scan-architecture.js +180 -185
- package/dist/tools/scan-solid.d.ts +40 -9
- package/dist/tools/scan-solid.js +64 -133
- package/dist/tools/search-codebase.d.ts +32 -26
- package/dist/tools/search-codebase.js +15 -12
- package/dist/tools/server-status.d.ts +116 -24
- package/dist/tools/server-status.js +85 -26
- package/dist/tools/suggest-improvements.d.ts +22 -19
- package/dist/tools/suggest-improvements.js +21 -17
- package/dist/tools/trace-output-flow.d.ts +34 -27
- package/dist/tools/trace-output-flow.js +27 -24
- package/dist/tools/transform-code.d.ts +71 -10
- package/dist/tools/transform-code.js +148 -54
- package/dist/tools/validate-before-transform.d.ts +24 -9
- package/dist/tools/validate-before-transform.js +10 -7
- package/dist/tools/validate-project-compatibility.d.ts +18 -13
- package/dist/tools/validate-project-compatibility.js +17 -11
- package/dist/tools/validate-transformation.d.ts +28 -11
- package/dist/tools/validate-transformation.js +14 -8
- package/dist/tools/verify-citations.d.ts +37 -16
- package/dist/tools/verify-citations.js +19 -16
- package/dist/types.d.ts +40 -10
- package/dist/types.js +0 -5
- package/package.json +12 -18
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.js +0 -7
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Inspect Form Group Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool that returns the Reactive Forms of a component or service file
|
|
5
|
-
* as structure: controls with validators and initial state, and every
|
|
6
|
-
* enable/disable/validator change per control, including what an ancestor
|
|
7
|
-
* group's enable()/disable() switches with it.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* Logic lives in `FormGroupInspector` (`@angular-modernizer/api`); this tool
|
|
11
|
-
* resolves the project, validates arguments and applies the compact output
|
|
12
|
-
* contract (`maxResults` caps the control list per form).
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* // Via MCP:
|
|
17
|
-
* // tool: inspect-form-group
|
|
18
|
-
* // args: { file: 'src/app/edit/edit.component.ts', projectRoot: '/project' }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
1
|
import { FormGroupInspector, } from '@angular-modernizer/api';
|
|
22
2
|
import { existsSync } from 'node:fs';
|
|
23
3
|
import { isAbsolute, resolve } from 'node:path';
|
|
24
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
25
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
26
6
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
|
|
27
7
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
28
8
|
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
@@ -125,7 +105,22 @@ const FORM_SCHEMA = {
|
|
|
125
105
|
],
|
|
126
106
|
};
|
|
127
107
|
/**
|
|
128
|
-
* MCP tool that
|
|
108
|
+
* MCP tool that returns the Reactive Forms of a component or service file
|
|
109
|
+
* as structure: controls with validators and initial state, and every
|
|
110
|
+
* enable/disable/validator change per control, including what an ancestor
|
|
111
|
+
* group's enable()/disable() switches with it.
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Logic lives in `FormGroupInspector` (`@angular-modernizer/api`); this tool
|
|
115
|
+
* resolves the project, validates arguments and applies the compact output
|
|
116
|
+
* contract (`maxResults` caps the control list per form).
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Via MCP:
|
|
121
|
+
* // tool: inspect-form-group
|
|
122
|
+
* // args: { file: 'src/app/edit/edit.component.ts', projectRoot: '/project' }
|
|
123
|
+
* ```
|
|
129
124
|
*/
|
|
130
125
|
export class InspectFormGroupTool {
|
|
131
126
|
projects;
|
|
@@ -150,6 +145,10 @@ export class InspectFormGroupTool {
|
|
|
150
145
|
'lists paths that do not exist in the form (typos, stale names: a runtime error when called); ' +
|
|
151
146
|
'dynamicOperations lists computed keys (controls[key] in a loop). Only this file is searched. summaryOnly ' +
|
|
152
147
|
'drops the control lists, maxResults caps them.';
|
|
148
|
+
/**
|
|
149
|
+
* JSON Schema of the tool arguments.
|
|
150
|
+
* @hidden
|
|
151
|
+
*/
|
|
153
152
|
inputSchema = {
|
|
154
153
|
type: 'object',
|
|
155
154
|
additionalProperties: false,
|
|
@@ -184,6 +183,10 @@ export class InspectFormGroupTool {
|
|
|
184
183
|
},
|
|
185
184
|
required: ['file', 'projectRoot'],
|
|
186
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
188
|
+
* @hidden
|
|
189
|
+
*/
|
|
187
190
|
outputSchema = {
|
|
188
191
|
type: 'object',
|
|
189
192
|
properties: {
|
|
@@ -194,7 +197,7 @@ export class InspectFormGroupTool {
|
|
|
194
197
|
},
|
|
195
198
|
required: ['forms', 'summary', 'tsConfigPath'],
|
|
196
199
|
};
|
|
197
|
-
async execute(args) {
|
|
200
|
+
async execute(args, ctx = {}) {
|
|
198
201
|
const params = args;
|
|
199
202
|
if (!params.file || typeof params.file !== 'string') {
|
|
200
203
|
throw new Error('file is required');
|
|
@@ -214,7 +217,7 @@ export class InspectFormGroupTool {
|
|
|
214
217
|
if (!tsConfigPath) {
|
|
215
218
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
216
219
|
}
|
|
217
|
-
const project = this.projects
|
|
220
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
218
221
|
if (!project.getSourceFile(filePath)) {
|
|
219
222
|
throw new Error(`file is not part of the tsconfig program: ${filePath}`);
|
|
220
223
|
}
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Inspect i18n Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool over `I18nInspector`: where translation keys are defined (per
|
|
5
|
-
* language, with file, line and value), where they are used in templates and
|
|
6
|
-
* code, in which language they are missing, which used keys are defined
|
|
7
|
-
* nowhere and which defined keys have no static usage. Sources are found
|
|
8
|
-
* without configuration (setTranslation, TranslateHttpLoader, TranslocoLoader,
|
|
9
|
-
* assets/i18n convention).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* await tool.execute({ projectRoot: '/app', key: 'ERRORS.NO_ACCESS' });
|
|
14
|
-
* // { keys: [{ key: 'ERRORS.NO_ACCESS', status: 'used', definitions: [...], usages: [...] }], summary: '...' }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
18
2
|
import { type I18nReport, type I18nSourceSummary } from '@angular-modernizer/api';
|
|
19
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
20
|
-
|
|
4
|
+
/** List fields of the report that `summaryOnly` drops and `maxResults` caps. */
|
|
5
|
+
export type ListField = 'keys' | 'undefinedKeys' | 'missingTranslations' | 'unused' | 'dynamicPrefixes' | 'unresolvedUsages';
|
|
21
6
|
/** Source fields only the full output carries. */
|
|
22
|
-
type DetailField = 'registeredAt' | 'discoveredBy' | 'kind' | 'conditionReason';
|
|
7
|
+
export type DetailField = 'registeredAt' | 'discoveredBy' | 'kind' | 'conditionReason';
|
|
23
8
|
/** A source; `summaryOnly` keeps file, lang, app, conditional, group and keyCount. */
|
|
24
|
-
type SourceOutput = Omit<I18nSourceSummary, DetailField> & Partial<Pick<I18nSourceSummary, DetailField>>;
|
|
9
|
+
export type SourceOutput = Omit<I18nSourceSummary, DetailField> & Partial<Pick<I18nSourceSummary, DetailField>>;
|
|
25
10
|
/**
|
|
26
11
|
* Output of the inspect-i18n tool.
|
|
27
12
|
*/
|
|
28
|
-
type InspectI18nOutput = Omit<I18nReport, ListField | 'sources'> & Partial<Pick<I18nReport, ListField>> & {
|
|
13
|
+
export type InspectI18nOutput = Omit<I18nReport, ListField | 'sources'> & Partial<Pick<I18nReport, ListField>> & {
|
|
14
|
+
/** Translation sources found in the project. */
|
|
29
15
|
sources: SourceOutput[];
|
|
30
16
|
/** `true` when `maxResults` cut a list. */
|
|
31
17
|
truncated: boolean;
|
|
18
|
+
/** Short text summary of the report. */
|
|
32
19
|
summary: string;
|
|
20
|
+
/** The tsconfig whose program was used. */
|
|
33
21
|
tsConfigPath: string;
|
|
34
22
|
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
35
23
|
warnings?: string[];
|
|
36
24
|
};
|
|
37
25
|
/**
|
|
38
|
-
* MCP tool
|
|
26
|
+
* MCP tool over `I18nInspector`: where translation keys are defined (per
|
|
27
|
+
* language, with file, line and value), where they are used in templates and
|
|
28
|
+
* code, in which language they are missing, which used keys are defined
|
|
29
|
+
* nowhere and which defined keys have no static usage. Sources are found
|
|
30
|
+
* without configuration (setTranslation, TranslateHttpLoader, TranslocoLoader,
|
|
31
|
+
* assets/i18n convention).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* await tool.execute({ projectRoot: '/app', key: 'ERRORS.NO_ACCESS' });
|
|
36
|
+
* // { keys: [{ key: 'ERRORS.NO_ACCESS', status: 'used', definitions: [...], usages: [...] }], summary: '...' }
|
|
37
|
+
* ```
|
|
39
38
|
*/
|
|
40
39
|
export declare class InspectI18nTool implements MCPTool {
|
|
41
40
|
private readonly projects;
|
|
@@ -44,6 +43,10 @@ export declare class InspectI18nTool implements MCPTool {
|
|
|
44
43
|
readonly annotations: ToolAnnotations;
|
|
45
44
|
constructor(projects?: ProjectCache);
|
|
46
45
|
readonly description: string;
|
|
46
|
+
/**
|
|
47
|
+
* JSON Schema of the tool arguments.
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
47
50
|
readonly inputSchema: {
|
|
48
51
|
type: string;
|
|
49
52
|
additionalProperties: boolean;
|
|
@@ -79,6 +82,10 @@ export declare class InspectI18nTool implements MCPTool {
|
|
|
79
82
|
};
|
|
80
83
|
required: string[];
|
|
81
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
87
|
+
* @hidden
|
|
88
|
+
*/
|
|
82
89
|
readonly outputSchema: {
|
|
83
90
|
type: string;
|
|
84
91
|
properties: {
|
|
@@ -441,7 +448,7 @@ export declare class InspectI18nTool implements MCPTool {
|
|
|
441
448
|
type: string;
|
|
442
449
|
};
|
|
443
450
|
};
|
|
444
|
-
required: ("usages" | "templatesScanned" | "
|
|
451
|
+
required: ("usages" | "templatesScanned" | "definedKeys" | "sources" | "usedKeys" | "undefinedKeys" | "missingTranslations" | "noStaticUsage" | "coveredByDynamic" | "referencedAsLiteral" | "dynamicPrefixes" | "dynamicUsages" | "unresolvedUsages")[];
|
|
445
452
|
};
|
|
446
453
|
truncated: {
|
|
447
454
|
type: string;
|
|
@@ -455,12 +462,11 @@ export declare class InspectI18nTool implements MCPTool {
|
|
|
455
462
|
};
|
|
456
463
|
required: string[];
|
|
457
464
|
};
|
|
458
|
-
execute(args: Record<string, unknown
|
|
465
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<InspectI18nOutput>;
|
|
459
466
|
private parseText;
|
|
460
467
|
private parseI18nNames;
|
|
461
468
|
private shape;
|
|
462
469
|
private buildSummary;
|
|
463
470
|
private keyLines;
|
|
464
471
|
}
|
|
465
|
-
export {};
|
|
466
472
|
//# sourceMappingURL=inspect-i18n.d.ts.map
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Inspect i18n Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool over `I18nInspector`: where translation keys are defined (per
|
|
5
|
-
* language, with file, line and value), where they are used in templates and
|
|
6
|
-
* code, in which language they are missing, which used keys are defined
|
|
7
|
-
* nowhere and which defined keys have no static usage. Sources are found
|
|
8
|
-
* without configuration (setTranslation, TranslateHttpLoader, TranslocoLoader,
|
|
9
|
-
* assets/i18n convention).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* await tool.execute({ projectRoot: '/app', key: 'ERRORS.NO_ACCESS' });
|
|
14
|
-
* // { keys: [{ key: 'ERRORS.NO_ACCESS', status: 'used', definitions: [...], usages: [...] }], summary: '...' }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
1
|
import { I18nInspector, } from '@angular-modernizer/api';
|
|
18
2
|
import { existsSync } from 'node:fs';
|
|
19
3
|
import { relative } from 'node:path';
|
|
20
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
21
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
22
6
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
|
|
23
7
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
24
8
|
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
@@ -73,7 +57,18 @@ const I18N_COUNT_KEYS = [
|
|
|
73
57
|
'templatesScanned',
|
|
74
58
|
];
|
|
75
59
|
/**
|
|
76
|
-
* MCP tool
|
|
60
|
+
* MCP tool over `I18nInspector`: where translation keys are defined (per
|
|
61
|
+
* language, with file, line and value), where they are used in templates and
|
|
62
|
+
* code, in which language they are missing, which used keys are defined
|
|
63
|
+
* nowhere and which defined keys have no static usage. Sources are found
|
|
64
|
+
* without configuration (setTranslation, TranslateHttpLoader, TranslocoLoader,
|
|
65
|
+
* assets/i18n convention).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* await tool.execute({ projectRoot: '/app', key: 'ERRORS.NO_ACCESS' });
|
|
70
|
+
* // { keys: [{ key: 'ERRORS.NO_ACCESS', status: 'used', definitions: [...], usages: [...] }], summary: '...' }
|
|
71
|
+
* ```
|
|
77
72
|
*/
|
|
78
73
|
export class InspectI18nTool {
|
|
79
74
|
projects;
|
|
@@ -106,6 +101,10 @@ export class InspectI18nTool {
|
|
|
106
101
|
'key text appears as a string elsewhere, e.g. a menu config) or no-static-usage. For a project report ' +
|
|
107
102
|
'start with summaryOnly (drops the lists and the source details registeredAt, discoveredBy, kind, ' +
|
|
108
103
|
'conditionReason); maxResults caps every list and the usages per key, counts cover everything.';
|
|
104
|
+
/**
|
|
105
|
+
* JSON Schema of the tool arguments.
|
|
106
|
+
* @hidden
|
|
107
|
+
*/
|
|
109
108
|
inputSchema = {
|
|
110
109
|
type: 'object',
|
|
111
110
|
additionalProperties: false,
|
|
@@ -131,6 +130,10 @@ export class InspectI18nTool {
|
|
|
131
130
|
},
|
|
132
131
|
required: ['projectRoot'],
|
|
133
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
135
|
+
* @hidden
|
|
136
|
+
*/
|
|
134
137
|
outputSchema = {
|
|
135
138
|
type: 'object',
|
|
136
139
|
properties: {
|
|
@@ -268,7 +271,7 @@ export class InspectI18nTool {
|
|
|
268
271
|
'tsConfigPath',
|
|
269
272
|
],
|
|
270
273
|
};
|
|
271
|
-
async execute(args) {
|
|
274
|
+
async execute(args, ctx = {}) {
|
|
272
275
|
const params = args;
|
|
273
276
|
if (!params.projectRoot || typeof params.projectRoot !== 'string') {
|
|
274
277
|
throw new Error('projectRoot is required');
|
|
@@ -287,7 +290,7 @@ export class InspectI18nTool {
|
|
|
287
290
|
if (!tsConfigPath) {
|
|
288
291
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
289
292
|
}
|
|
290
|
-
const project = this.projects
|
|
293
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
291
294
|
const report = new I18nInspector(project, {
|
|
292
295
|
rootDir: params.projectRoot,
|
|
293
296
|
...(key === undefined ? {} : { key }),
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
import { type MCPTool, type ToolAnnotations, type ToolContext } from '../types.js';
|
|
2
|
+
import { type ComponentTemplateReport } from '@angular-modernizer/api';
|
|
3
|
+
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
|
+
/** List fields of a template report that `summaryOnly` drops and `maxResults` caps. */
|
|
5
|
+
export type ListField = 'elements' | 'i18nKeys' | 'dynamicI18nPrefixes';
|
|
6
|
+
/** A report shaped by the compact options. */
|
|
7
|
+
export type TemplateReportOutput = Omit<ComponentTemplateReport, ListField> & Partial<Pick<ComponentTemplateReport, ListField>> & {
|
|
8
|
+
/** `true` when `maxResults` cut one of the lists. */
|
|
9
|
+
truncated: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Output of the inspect-template tool.
|
|
13
|
+
*/
|
|
14
|
+
export interface InspectTemplateOutput {
|
|
15
|
+
/** One report per inspected template. */
|
|
16
|
+
templates: TemplateReportOutput[];
|
|
17
|
+
/** Short text summary of the inspected templates. */
|
|
18
|
+
summary: string;
|
|
19
|
+
/** The tsconfig whose program was used. */
|
|
20
|
+
tsConfigPath: string;
|
|
21
|
+
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
22
|
+
warnings?: string[];
|
|
23
|
+
}
|
|
1
24
|
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Inspect Template Tool
|
|
3
|
-
*
|
|
4
25
|
* MCP tool that returns the structure of an Angular component template:
|
|
5
26
|
* elements with their bindings, the project components/directives and
|
|
6
27
|
* pipes they resolve to, control-flow nesting and i18n keys.
|
|
@@ -17,27 +38,6 @@
|
|
|
17
38
|
* // args: { file: '/project/src/app/list/list.component.html', projectRoot: '/project' }
|
|
18
39
|
* ```
|
|
19
40
|
*/
|
|
20
|
-
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
21
|
-
import { type ComponentTemplateReport } from '@angular-modernizer/api';
|
|
22
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
23
|
-
/** A report shaped by the compact options. */
|
|
24
|
-
type ListField = 'elements' | 'i18nKeys' | 'dynamicI18nPrefixes';
|
|
25
|
-
type TemplateReportOutput = Omit<ComponentTemplateReport, ListField> & Partial<Pick<ComponentTemplateReport, ListField>> & {
|
|
26
|
-
truncated: boolean;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Output of the inspect-template tool.
|
|
30
|
-
*/
|
|
31
|
-
interface InspectTemplateOutput {
|
|
32
|
-
templates: TemplateReportOutput[];
|
|
33
|
-
summary: string;
|
|
34
|
-
tsConfigPath: string;
|
|
35
|
-
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
36
|
-
warnings?: string[];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* MCP tool that inspects the structure of component templates.
|
|
40
|
-
*/
|
|
41
41
|
export declare class InspectTemplateTool implements MCPTool {
|
|
42
42
|
private readonly projects;
|
|
43
43
|
readonly name = "inspect-template";
|
|
@@ -45,6 +45,10 @@ export declare class InspectTemplateTool implements MCPTool {
|
|
|
45
45
|
readonly annotations: ToolAnnotations;
|
|
46
46
|
constructor(projects?: ProjectCache);
|
|
47
47
|
readonly description: string;
|
|
48
|
+
/**
|
|
49
|
+
* JSON Schema of the tool arguments.
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
48
52
|
readonly inputSchema: {
|
|
49
53
|
type: string;
|
|
50
54
|
additionalProperties: boolean;
|
|
@@ -85,6 +89,10 @@ export declare class InspectTemplateTool implements MCPTool {
|
|
|
85
89
|
};
|
|
86
90
|
required: string[];
|
|
87
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
88
96
|
readonly outputSchema: {
|
|
89
97
|
type: string;
|
|
90
98
|
properties: {
|
|
@@ -311,10 +319,9 @@ export declare class InspectTemplateTool implements MCPTool {
|
|
|
311
319
|
};
|
|
312
320
|
required: string[];
|
|
313
321
|
};
|
|
314
|
-
execute(args: Record<string, unknown
|
|
322
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<InspectTemplateOutput>;
|
|
315
323
|
private parseI18nNames;
|
|
316
324
|
private shape;
|
|
317
325
|
private buildSummary;
|
|
318
326
|
}
|
|
319
|
-
export {};
|
|
320
327
|
//# sourceMappingURL=inspect-template.d.ts.map
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/adapter-mcp - Inspect Template Tool
|
|
3
|
-
*
|
|
4
|
-
* MCP tool that returns the structure of an Angular component template:
|
|
5
|
-
* elements with their bindings, the project components/directives and
|
|
6
|
-
* pipes they resolve to, control-flow nesting and i18n keys.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Logic lives in `TemplateInspector` (`@angular-modernizer/api`); this tool
|
|
10
|
-
* only resolves the project, validates arguments and applies the compact
|
|
11
|
-
* output contract. Accepts the `.html` template or the component `.ts` file.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Via MCP:
|
|
16
|
-
* // tool: inspect-template
|
|
17
|
-
* // args: { file: '/project/src/app/list/list.component.html', projectRoot: '/project' }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
1
|
import { TemplateInspector, } from '@angular-modernizer/api';
|
|
21
2
|
import { existsSync } from 'node:fs';
|
|
22
3
|
import { isAbsolute, resolve } from 'node:path';
|
|
23
4
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
24
|
-
import { ProjectCache } from './helpers/project-cache.js';
|
|
5
|
+
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
25
6
|
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, } from './helpers/compact-output.js';
|
|
26
7
|
import { configuredComponentDecorators } from './helpers/project-decorators.js';
|
|
27
8
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
@@ -163,7 +144,21 @@ const TEMPLATE_REPORT_SCHEMA = {
|
|
|
163
144
|
],
|
|
164
145
|
};
|
|
165
146
|
/**
|
|
166
|
-
* MCP tool that
|
|
147
|
+
* MCP tool that returns the structure of an Angular component template:
|
|
148
|
+
* elements with their bindings, the project components/directives and
|
|
149
|
+
* pipes they resolve to, control-flow nesting and i18n keys.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* Logic lives in `TemplateInspector` (`@angular-modernizer/api`); this tool
|
|
153
|
+
* only resolves the project, validates arguments and applies the compact
|
|
154
|
+
* output contract. Accepts the `.html` template or the component `.ts` file.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Via MCP:
|
|
159
|
+
* // tool: inspect-template
|
|
160
|
+
* // args: { file: '/project/src/app/list/list.component.html', projectRoot: '/project' }
|
|
161
|
+
* ```
|
|
167
162
|
*/
|
|
168
163
|
export class InspectTemplateTool {
|
|
169
164
|
projects;
|
|
@@ -189,6 +184,10 @@ export class InspectTemplateTool {
|
|
|
189
184
|
'inspect-i18n). Plain elements without bindings are ' +
|
|
190
185
|
'omitted unless includePlainElements; counts always cover all elements. summaryOnly drops the ' +
|
|
191
186
|
'element, key and prefix lists, maxResults caps them.';
|
|
187
|
+
/**
|
|
188
|
+
* JSON Schema of the tool arguments.
|
|
189
|
+
* @hidden
|
|
190
|
+
*/
|
|
192
191
|
inputSchema = {
|
|
193
192
|
type: 'object',
|
|
194
193
|
additionalProperties: false,
|
|
@@ -219,6 +218,10 @@ export class InspectTemplateTool {
|
|
|
219
218
|
},
|
|
220
219
|
required: ['file', 'projectRoot'],
|
|
221
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
223
|
+
* @hidden
|
|
224
|
+
*/
|
|
222
225
|
outputSchema = {
|
|
223
226
|
type: 'object',
|
|
224
227
|
properties: {
|
|
@@ -229,7 +232,7 @@ export class InspectTemplateTool {
|
|
|
229
232
|
},
|
|
230
233
|
required: ['templates', 'summary', 'tsConfigPath'],
|
|
231
234
|
};
|
|
232
|
-
async execute(args) {
|
|
235
|
+
async execute(args, ctx = {}) {
|
|
233
236
|
const params = args;
|
|
234
237
|
if (!params.file || typeof params.file !== 'string') {
|
|
235
238
|
throw new Error('file is required');
|
|
@@ -252,7 +255,7 @@ export class InspectTemplateTool {
|
|
|
252
255
|
if (!tsConfigPath) {
|
|
253
256
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
254
257
|
}
|
|
255
|
-
const project = this.projects
|
|
258
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
256
259
|
if (!filePath.endsWith('.html') && !project.getSourceFile(filePath)) {
|
|
257
260
|
throw new Error(`file is not part of the tsconfig program: ${filePath}`);
|
|
258
261
|
}
|