@angular-modernizer/adapter-mcp 0.1.4 → 0.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 +22 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/analyze-build-impact.d.ts +47 -3
- package/dist/tools/analyze-build-impact.d.ts.map +1 -1
- package/dist/tools/analyze-build-impact.js +57 -14
- 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-usages.d.ts +13 -1
- package/dist/tools/find-usages.d.ts.map +1 -1
- package/dist/tools/find-usages.js +34 -6
- package/dist/tools/find-usages.js.map +1 -1
- package/dist/tools/get-call-graph.d.ts +5 -1
- package/dist/tools/get-call-graph.d.ts.map +1 -1
- package/dist/tools/get-call-graph.js +21 -6
- package/dist/tools/get-call-graph.js.map +1 -1
- 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/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/list-imports.d.ts +103 -0
- package/dist/tools/list-imports.d.ts.map +1 -0
- package/dist/tools/list-imports.js +154 -0
- package/dist/tools/list-imports.js.map +1 -0
- 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/search-codebase.d.ts +29 -6
- package/dist/tools/search-codebase.d.ts.map +1 -1
- package/dist/tools/search-codebase.js +54 -12
- package/dist/tools/search-codebase.js.map +1 -1
- 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/package.json +13 -12
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
import { Project } from 'ts-morph';
|
|
23
|
-
import { CodebaseSearcher } from '@angular-modernizer/api';
|
|
23
|
+
import { CodebaseSearcher, } from '@angular-modernizer/api';
|
|
24
24
|
import { existsSync } from 'node:fs';
|
|
25
25
|
import { findTsConfig } from './helpers/find-ts-config.js';
|
|
26
26
|
/**
|
|
@@ -32,8 +32,12 @@ export class SearchCodebaseTool {
|
|
|
32
32
|
'"text" (literal substring), "pattern" (regular expression), ' +
|
|
33
33
|
'"symbol" (TypeScript class/function/interface/enum/type declaration by name). ' +
|
|
34
34
|
'Returns file path, line, column, and source snippet for each match. ' +
|
|
35
|
-
'
|
|
36
|
-
'
|
|
35
|
+
'Text and pattern modes also scan Angular templates (.html) and .ts files outside ' +
|
|
36
|
+
'the tsconfig program (e.g. src/i18n/*.ts) under projectRoot, skipping node_modules, ' +
|
|
37
|
+
'dist, .angular, coverage and hidden directories. The response includes a coverage ' +
|
|
38
|
+
'object (programFileCount, extraFileCount); 0 hits only prove absence within the ' +
|
|
39
|
+
'covered files. Use during bug investigation to locate error strings, find symbol ' +
|
|
40
|
+
'declarations, or discover all files that reference a specific pattern.';
|
|
37
41
|
inputSchema = {
|
|
38
42
|
type: 'object',
|
|
39
43
|
properties: {
|
|
@@ -44,9 +48,9 @@ export class SearchCodebaseTool {
|
|
|
44
48
|
mode: {
|
|
45
49
|
type: 'string',
|
|
46
50
|
enum: ['text', 'pattern', 'symbol'],
|
|
47
|
-
description: '"text"
|
|
48
|
-
'"pattern"
|
|
49
|
-
'"symbol"
|
|
51
|
+
description: '"text" - literal substring match. ' +
|
|
52
|
+
'"pattern" - regular expression match. ' +
|
|
53
|
+
'"symbol" - finds TypeScript named declarations (class, function, interface, enum, type alias, variable).',
|
|
50
54
|
},
|
|
51
55
|
projectRoot: {
|
|
52
56
|
type: 'string',
|
|
@@ -60,6 +64,15 @@ export class SearchCodebaseTool {
|
|
|
60
64
|
type: 'number',
|
|
61
65
|
description: 'Maximum number of results to return. Defaults to 100.',
|
|
62
66
|
},
|
|
67
|
+
includeTemplates: {
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
description: 'Text/pattern modes: also scan .html templates under projectRoot. Defaults to true.',
|
|
70
|
+
},
|
|
71
|
+
includeNonProgramFiles: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
description: 'Text/pattern modes: also scan .ts files under projectRoot that are not part of the ' +
|
|
74
|
+
'tsconfig program (e.g. src/i18n/*.ts). Defaults to true.',
|
|
75
|
+
},
|
|
63
76
|
},
|
|
64
77
|
required: ['query', 'mode', 'projectRoot'],
|
|
65
78
|
};
|
|
@@ -83,27 +96,56 @@ export class SearchCodebaseTool {
|
|
|
83
96
|
}
|
|
84
97
|
const project = new Project({ tsConfigFilePath: tsConfigPath });
|
|
85
98
|
const searcher = new CodebaseSearcher(project);
|
|
86
|
-
const results = searcher.
|
|
99
|
+
const { results, coverage } = searcher.searchWithCoverage(params.query, {
|
|
87
100
|
mode: params.mode,
|
|
88
101
|
include: params.include,
|
|
89
102
|
maxResults: params.maxResults ?? 100,
|
|
103
|
+
rootDir: params.projectRoot,
|
|
104
|
+
includeTemplates: params.includeTemplates !== false,
|
|
105
|
+
includeNonProgramFiles: params.includeNonProgramFiles !== false,
|
|
90
106
|
});
|
|
107
|
+
const hint = results.length === 0 ? this.buildZeroHitHint(params.mode, coverage) : undefined;
|
|
91
108
|
return {
|
|
92
109
|
results,
|
|
93
110
|
totalCount: results.length,
|
|
94
|
-
summary: this.buildSummary(params.query, params.mode, results),
|
|
111
|
+
summary: this.buildSummary(params.query, params.mode, results, hint),
|
|
112
|
+
coverage: {
|
|
113
|
+
...coverage,
|
|
114
|
+
tsConfigPath,
|
|
115
|
+
...(hint === undefined ? {} : { hint }),
|
|
116
|
+
},
|
|
95
117
|
};
|
|
96
118
|
}
|
|
97
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Explains why 0 hits is not proof of absence, naming what was excluded.
|
|
121
|
+
*/
|
|
122
|
+
buildZeroHitHint(mode, coverage) {
|
|
123
|
+
const excluded = [
|
|
124
|
+
`directories ${coverage.excludedDirectories.join(', ')}`,
|
|
125
|
+
];
|
|
126
|
+
if (mode === 'symbol') {
|
|
127
|
+
excluded.push('templates and non-program files (symbol mode only searches program declarations)');
|
|
128
|
+
}
|
|
129
|
+
if (mode !== 'symbol' && !coverage.templatesScanned) {
|
|
130
|
+
excluded.push('.html templates (includeTemplates=false)');
|
|
131
|
+
}
|
|
132
|
+
if (mode !== 'symbol' && !coverage.nonProgramFilesScanned) {
|
|
133
|
+
excluded.push('.ts files outside the tsconfig program (includeNonProgramFiles=false)');
|
|
134
|
+
}
|
|
135
|
+
return (`0 hits does not prove absence: searched ${coverage.programFileCount} program file(s) ` +
|
|
136
|
+
`and ${coverage.extraFileCount} non-program file(s); excluded ${excluded.join('; ')}. ` +
|
|
137
|
+
'Verify with a raw grep if the result matters.');
|
|
138
|
+
}
|
|
139
|
+
buildSummary(query, mode, results, hint) {
|
|
98
140
|
if (results.length === 0) {
|
|
99
|
-
return `No ${mode} matches found for '${query}'
|
|
141
|
+
return `No ${mode} matches found for '${query}'. ${hint ?? ''}`.trim();
|
|
100
142
|
}
|
|
101
143
|
return (`Found ${results.length} ${mode} match${results.length === 1 ? '' : 'es'} for '${query}':\n` +
|
|
102
144
|
results
|
|
103
145
|
.slice(0, 5)
|
|
104
|
-
.map((r) => ` ${r.file}:${r.line}:${r.col}
|
|
146
|
+
.map((r) => ` ${r.file}:${r.line}:${r.col} - ${r.snippet}`)
|
|
105
147
|
.join('\n') +
|
|
106
|
-
(results.length > 5 ? `\n
|
|
148
|
+
(results.length > 5 ? `\n ... and ${results.length - 5} more` : ''));
|
|
107
149
|
}
|
|
108
150
|
}
|
|
109
151
|
//# sourceMappingURL=search-codebase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-codebase.js","sourceRoot":"","sources":["../../src/tools/search-codebase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"search-codebase.js","sourceRoot":"","sources":["../../src/tools/search-codebase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAqD3D;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,iBAAiB,CAAC;IAEzB,WAAW,GAClB,4DAA4D;QAC5D,8DAA8D;QAC9D,gFAAgF;QAChF,sEAAsE;QACtE,mFAAmF;QACnF,sFAAsF;QACtF,oFAAoF;QACpF,kFAAkF;QAClF,mFAAmF;QACnF,wEAAwE,CAAC;IAElE,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,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E,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;iBAC3D,IAAI,CAAC,IAAI,CAAC;YACb,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CACrE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* - Prerequisite check: Add validation when common failure patterns detected
|
|
10
10
|
* - Approach change: Switch to more successful approach alternatives
|
|
11
11
|
* - Validation enhancement: Improve validation based on quality trends
|
|
12
|
+
* - Tool blind spot: an analysis tool (ruleId = tool name, e.g. 'find-usages')
|
|
13
|
+
* was corrected repeatedly via kind 'analysis' feedback
|
|
12
14
|
*
|
|
13
15
|
* All suggestions require human approval before implementation.
|
|
14
16
|
*/
|
|
@@ -29,7 +31,7 @@ export declare class SuggestImprovementsTool implements MCPTool {
|
|
|
29
31
|
};
|
|
30
32
|
readonly ruleId: {
|
|
31
33
|
readonly type: "string";
|
|
32
|
-
readonly description: "Rule identifier to analyze (e.g., 'standalone-migration', 'constructor-to-inject')";
|
|
34
|
+
readonly description: "Rule identifier to analyze (e.g., 'standalone-migration', 'constructor-to-inject'), or an analysis tool name (e.g. 'find-usages') to get blind-spot suggestions from kind 'analysis' feedback";
|
|
33
35
|
readonly minLength: 1;
|
|
34
36
|
};
|
|
35
37
|
readonly minConfidence: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-improvements.d.ts","sourceRoot":"","sources":["../../src/tools/suggest-improvements.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"suggest-improvements.d.ts","sourceRoot":"","sources":["../../src/tools/suggest-improvements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AA4D3C;;GAEG;AACH,qBAAa,uBAAwB,YAAW,OAAO;IACrD,IAAI,SAA0B;IAC9B,WAAW,SAIiC;IAG5C,OAAO,CAAC,YAAY,CAAuB;IAE3C,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;MA4BA;IAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IAEG,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CA2F/D"}
|
|
@@ -9,17 +9,21 @@
|
|
|
9
9
|
* - Prerequisite check: Add validation when common failure patterns detected
|
|
10
10
|
* - Approach change: Switch to more successful approach alternatives
|
|
11
11
|
* - Validation enhancement: Improve validation based on quality trends
|
|
12
|
+
* - Tool blind spot: an analysis tool (ruleId = tool name, e.g. 'find-usages')
|
|
13
|
+
* was corrected repeatedly via kind 'analysis' feedback
|
|
12
14
|
*
|
|
13
15
|
* All suggestions require human approval before implementation.
|
|
14
16
|
*/
|
|
15
|
-
import { FeedbackStorage, loadConfig, } from '@angular-modernizer/core';
|
|
17
|
+
import { FeedbackStorage, loadConfig, findRepeatedToolMisses, fromLegacyAnalysisRecord, summarizeAnalysisFeedback, } from '@angular-modernizer/core';
|
|
16
18
|
import * as path from 'node:path';
|
|
17
19
|
import { fileURLToPath } from 'node:url';
|
|
18
20
|
import { calculatePerformance, generateSuggestions, } from './helpers/suggestion-generator.js';
|
|
19
21
|
import { resolvePlatformRoot } from './helpers/platform-root-resolver.js';
|
|
20
|
-
// ESM-compatible __dirname alternative
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
// ESM-compatible __dirname alternative. Named _module* (not __filename/
|
|
23
|
+
// __dirname) so the CJS jest runtime, which already injects those wrapper
|
|
24
|
+
// identifiers, does not collide with these module-scope declarations.
|
|
25
|
+
const _moduleFilename = fileURLToPath(import.meta.url);
|
|
26
|
+
const _moduleDirname = path.dirname(_moduleFilename);
|
|
23
27
|
/**
|
|
24
28
|
* Suggest rule improvements based on transformation feedback analysis
|
|
25
29
|
*/
|
|
@@ -40,7 +44,7 @@ export class SuggestImprovementsTool {
|
|
|
40
44
|
},
|
|
41
45
|
ruleId: {
|
|
42
46
|
type: 'string',
|
|
43
|
-
description: "Rule identifier to analyze (e.g., 'standalone-migration', 'constructor-to-inject')",
|
|
47
|
+
description: "Rule identifier to analyze (e.g., 'standalone-migration', 'constructor-to-inject'), or an analysis tool name (e.g. 'find-usages') to get blind-spot suggestions from kind 'analysis' feedback",
|
|
44
48
|
minLength: 1,
|
|
45
49
|
},
|
|
46
50
|
minConfidence: {
|
|
@@ -119,7 +123,7 @@ export class SuggestImprovementsTool {
|
|
|
119
123
|
const minConfidence = input.minConfidence ?? 0.7;
|
|
120
124
|
const source = input.source ?? 'both';
|
|
121
125
|
// Resolve platform root intelligently (searches for monorepo root)
|
|
122
|
-
this.platformRoot ??= resolvePlatformRoot(
|
|
126
|
+
this.platformRoot ??= resolvePlatformRoot(_moduleDirname, '../../../..');
|
|
123
127
|
const platformRoot = this.platformRoot;
|
|
124
128
|
// Initialize FeedbackStorage
|
|
125
129
|
const feedbackStorage = new FeedbackStorage({
|
|
@@ -137,12 +141,17 @@ export class SuggestImprovementsTool {
|
|
|
137
141
|
const feedbackDir = path.join(root, '.claude-feedback/sessions');
|
|
138
142
|
sourcesRead.push(feedbackDir);
|
|
139
143
|
}
|
|
140
|
-
// Load and filter feedback for this rule
|
|
144
|
+
// Load and filter feedback for this rule (or analysis tool)
|
|
141
145
|
const ruleFeedback = [];
|
|
146
|
+
const toolAnalyses = [];
|
|
142
147
|
for (const sessionId of sessionIds) {
|
|
143
148
|
try {
|
|
144
149
|
const session = await feedbackStorage.loadSession(sessionId);
|
|
145
|
-
const
|
|
150
|
+
const legacyAnalyses = session.transformations
|
|
151
|
+
.map((f) => fromLegacyAnalysisRecord(f))
|
|
152
|
+
.filter((a) => a !== null);
|
|
153
|
+
toolAnalyses.push(...[...(session.analyses ?? []), ...legacyAnalyses].filter((a) => a.tool === input.ruleId));
|
|
154
|
+
const matchingFeedback = session.transformations.filter((f) => f.rule.ruleId === input.ruleId && !fromLegacyAnalysisRecord(f));
|
|
146
155
|
ruleFeedback.push(...matchingFeedback);
|
|
147
156
|
}
|
|
148
157
|
catch {
|
|
@@ -151,14 +160,18 @@ export class SuggestImprovementsTool {
|
|
|
151
160
|
}
|
|
152
161
|
// Calculate current performance
|
|
153
162
|
const currentPerformance = calculatePerformance(ruleFeedback);
|
|
154
|
-
// Generate suggestions
|
|
155
|
-
const suggestions =
|
|
163
|
+
// Generate suggestions (transformation outcomes + repeated tool misses)
|
|
164
|
+
const suggestions = [
|
|
165
|
+
...generateSuggestions(ruleFeedback, minConfidence),
|
|
166
|
+
...toolMissSuggestions(toolAnalyses, minConfidence),
|
|
167
|
+
].sort((a, b) => b.confidence - a.confidence);
|
|
156
168
|
// Return output
|
|
157
169
|
const output = {
|
|
158
170
|
ruleId: input.ruleId,
|
|
159
171
|
currentPerformance,
|
|
160
172
|
suggestions,
|
|
161
173
|
feedbackCount: ruleFeedback.length,
|
|
174
|
+
analysisFeedbackCount: toolAnalyses.length,
|
|
162
175
|
sourcesRead,
|
|
163
176
|
};
|
|
164
177
|
return output;
|
|
@@ -179,4 +192,28 @@ function getStorageLocations(storageLocation) {
|
|
|
179
192
|
return ['project', 'platform'];
|
|
180
193
|
}
|
|
181
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Turn repeated analysis-tool misses (blind-spot, false-negative,
|
|
197
|
+
* missing-capability; at least 2 records) into improvement suggestions.
|
|
198
|
+
*/
|
|
199
|
+
function toolMissSuggestions(analyses, minConfidence) {
|
|
200
|
+
const repeated = findRepeatedToolMisses(summarizeAnalysisFeedback(analyses));
|
|
201
|
+
return repeated
|
|
202
|
+
.map((insight) => {
|
|
203
|
+
const example = insight.examples[0];
|
|
204
|
+
const exampleText = example
|
|
205
|
+
? ` Example: tool said "${example.claimed}", actual "${example.actual}".`
|
|
206
|
+
: '';
|
|
207
|
+
return {
|
|
208
|
+
type: 'tool-blind-spot',
|
|
209
|
+
description: `${insight.tool}: ${insight.count} ${insight.category} reports needed a ${insight.fallbacks.join('/') || 'manual'} fallback`,
|
|
210
|
+
reasoning: `Callers corrected ${insight.tool} ${insight.count} times (${insight.highImpact} high impact).${exampleText}`,
|
|
211
|
+
confidence: Math.min(0.5 + insight.count * 0.1, 0.95),
|
|
212
|
+
expectedImprovement: `Fewer ${insight.fallbacks.join('/') || 'manual'} fallbacks when using ${insight.tool}`,
|
|
213
|
+
implementation: `Reproduce the listed claimed/actual pairs as tests for ${insight.tool}, then extend its coverage`,
|
|
214
|
+
requiresApproval: true,
|
|
215
|
+
};
|
|
216
|
+
})
|
|
217
|
+
.filter((suggestion) => suggestion.confidence >= minConfidence);
|
|
218
|
+
}
|
|
182
219
|
//# sourceMappingURL=suggest-improvements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-improvements.js","sourceRoot":"","sources":["../../src/tools/suggest-improvements.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"suggest-improvements.js","sourceRoot":"","sources":["../../src/tools/suggest-improvements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,GAK1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,wEAAwE;AACxE,0EAA0E;AAC1E,sEAAsE;AACtE,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,IA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xH,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE,IAAI,CAAC;YACrD,mBAAmB,EAAE,SAAS,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,yBAAyB,OAAO,CAAC,IAAI,EAAE;YAC5G,cAAc,EAAE,0DAA0D,OAAO,CAAC,IAAI,4BAA4B;YAClH,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,IAAI,aAAa,CAAC,CAAC;AACpE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-modernizer/adapter-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP Server to expose Angular Modernizer tools to an AI assistant.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -33,22 +33,23 @@
|
|
|
33
33
|
"express": "^4.17.1",
|
|
34
34
|
"glob": "^11.0.3",
|
|
35
35
|
"ts-morph": "^27.0.2",
|
|
36
|
-
"@angular-modernizer/
|
|
37
|
-
"@angular-modernizer/
|
|
38
|
-
"@angular-modernizer/
|
|
39
|
-
"@angular-modernizer/plugin-
|
|
40
|
-
"@angular-modernizer/plugin-
|
|
41
|
-
"@angular-modernizer/plugin-
|
|
42
|
-
"@angular-modernizer/
|
|
43
|
-
"@angular-modernizer/plugin-standalone": "0.
|
|
44
|
-
"@angular-modernizer/
|
|
45
|
-
"@angular-modernizer/plugin-
|
|
36
|
+
"@angular-modernizer/core": "0.2.0",
|
|
37
|
+
"@angular-modernizer/api": "0.2.0",
|
|
38
|
+
"@angular-modernizer/orchestration": "0.2.0",
|
|
39
|
+
"@angular-modernizer/plugin-analyzer": "0.2.0",
|
|
40
|
+
"@angular-modernizer/plugin-architecture": "0.2.0",
|
|
41
|
+
"@angular-modernizer/plugin-angular": "0.2.0",
|
|
42
|
+
"@angular-modernizer/plugin-solid": "0.2.0",
|
|
43
|
+
"@angular-modernizer/plugin-standalone": "0.2.0",
|
|
44
|
+
"@angular-modernizer/worker": "0.2.0",
|
|
45
|
+
"@angular-modernizer/plugin-system": "0.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/express": "^4.17.13",
|
|
49
49
|
"@types/jest": "^30.0.0",
|
|
50
50
|
"jest": "^30.2.0",
|
|
51
|
-
"ts-jest": "^29.4.5"
|
|
51
|
+
"ts-jest": "^29.4.5",
|
|
52
|
+
"ts-jest-mock-import-meta": "1.3.2"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|