@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
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { loadConfig } from '@angular-modernizer/core';
|
|
3
|
+
import { COMPACT_OUTPUT_SCHEMA, limitList, parseCompactOptions, truncationNote, } from './helpers/compact-output.js';
|
|
4
|
+
import { DEFAULT_KEEP_NEWEST, DEFAULT_RETENTION_DAYS, inventoryPlatformState, } from './helpers/refresh-inventory.js';
|
|
5
|
+
import { REFRESH_PARTS, RefreshPlans, } from './helpers/refresh-apply.js';
|
|
6
|
+
/** Listed entries spelled out in the summary. */
|
|
7
|
+
const SUMMARY_ITEMS = 10;
|
|
8
|
+
function formatBytes(bytes) {
|
|
9
|
+
if (bytes < 1024) {
|
|
10
|
+
return `${bytes} B`;
|
|
11
|
+
}
|
|
12
|
+
if (bytes < 1024 * 1024) {
|
|
13
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
14
|
+
}
|
|
15
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
16
|
+
}
|
|
17
|
+
function describeStore(s) {
|
|
18
|
+
if (!s.present) {
|
|
19
|
+
return `- ${s.store}: none${s.note === undefined ? '' : ` (${s.note})`}`;
|
|
20
|
+
}
|
|
21
|
+
const age = s.oldestAgeDays === undefined
|
|
22
|
+
? ''
|
|
23
|
+
: `, age ${s.newestAgeDays} to ${s.oldestAgeDays} days`;
|
|
24
|
+
const listed = s.listed === 0
|
|
25
|
+
? 'nothing listed'
|
|
26
|
+
: `${s.listed} listed (${formatBytes(s.listedBytes)})`;
|
|
27
|
+
return `- ${s.store}: ${s.entries} entr${s.entries === 1 ? 'y' : 'ies'}, ${formatBytes(s.bytes)}${age}; ${listed}${s.note === undefined ? '' : `; ${s.note}`}`;
|
|
28
|
+
}
|
|
29
|
+
function describe(output, allItems) {
|
|
30
|
+
const lines = [
|
|
31
|
+
`Platform state of ${output.projectRoot} (report only, nothing changed): ${output.counts.items} item(s) listed, ${formatBytes(output.counts.bytes)}.`,
|
|
32
|
+
`planId ${output.planId} (valid until ${output.expiresAt}): refresh-state mode 'apply' with parts ${REFRESH_PARTS.map((p) => `'${p}'`).join(', ')} removes the listed items of those parts that are still unchanged.`,
|
|
33
|
+
...output.stores.map(describeStore),
|
|
34
|
+
];
|
|
35
|
+
for (const item of allItems.slice(0, SUMMARY_ITEMS)) {
|
|
36
|
+
lines.push(`- [${item.store}/${item.reason}] ${item.action} ${item.path}${item.detail === undefined ? '' : `: ${item.detail}`}`);
|
|
37
|
+
}
|
|
38
|
+
if (allItems.length > SUMMARY_ITEMS) {
|
|
39
|
+
lines.push(`... ${allItems.length - SUMMARY_ITEMS} more in items.`);
|
|
40
|
+
}
|
|
41
|
+
const note = truncationNote(output.items?.length ?? allItems.length, allItems.length, 'items');
|
|
42
|
+
if (note !== undefined && output.items !== undefined) {
|
|
43
|
+
lines.push(note);
|
|
44
|
+
}
|
|
45
|
+
return lines.join('\n');
|
|
46
|
+
}
|
|
47
|
+
function describeApply(output, removed, marked, skipped) {
|
|
48
|
+
const causes = Object.entries(output.counts.skippedByCause)
|
|
49
|
+
.map(([cause, n]) => `${n} ${cause}`)
|
|
50
|
+
.join(', ');
|
|
51
|
+
const lines = [
|
|
52
|
+
`Applied plan ${output.planId} to ${output.projectRoot} (parts: ${output.parts.join(', ')}): ${output.counts.items} item(s) removed, ${formatBytes(output.counts.bytes)} freed; ${output.counts.marked} feedback item(s) marked (${output.counts.markedRecords} record(s), session files unchanged); ${output.counts.skipped} kept${causes === '' ? '' : ` (${causes})`}.`,
|
|
53
|
+
];
|
|
54
|
+
for (const item of removed.slice(0, SUMMARY_ITEMS)) {
|
|
55
|
+
lines.push(`- removed [${item.store}/${item.reason}] ${item.path}`);
|
|
56
|
+
}
|
|
57
|
+
if (removed.length > SUMMARY_ITEMS) {
|
|
58
|
+
lines.push(`... ${removed.length - SUMMARY_ITEMS} more removed.`);
|
|
59
|
+
}
|
|
60
|
+
for (const item of marked.slice(0, SUMMARY_ITEMS)) {
|
|
61
|
+
lines.push(`- marked [${item.store}/${item.reason}] ${item.path}: ${item.records} record(s) in the sidecar`);
|
|
62
|
+
}
|
|
63
|
+
if (marked.length > SUMMARY_ITEMS) {
|
|
64
|
+
lines.push(`... ${marked.length - SUMMARY_ITEMS} more marked.`);
|
|
65
|
+
}
|
|
66
|
+
for (const item of skipped.slice(0, SUMMARY_ITEMS)) {
|
|
67
|
+
lines.push(`- kept [${item.store}/${item.reason}] ${item.path}: ${item.cause}${item.detail === undefined ? '' : ` (${item.detail})`}`);
|
|
68
|
+
}
|
|
69
|
+
if (skipped.length > SUMMARY_ITEMS) {
|
|
70
|
+
lines.push(`... ${skipped.length - SUMMARY_ITEMS} more kept.`);
|
|
71
|
+
}
|
|
72
|
+
return lines.join('\n');
|
|
73
|
+
}
|
|
74
|
+
const ITEM_SCHEMA = {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
store: { type: 'string' },
|
|
78
|
+
reason: { type: 'string' },
|
|
79
|
+
action: { type: 'string', enum: ['remove', 'mark', 'regenerate'] },
|
|
80
|
+
path: { type: 'string' },
|
|
81
|
+
bytes: { type: 'integer' },
|
|
82
|
+
ageDays: { type: 'integer' },
|
|
83
|
+
detail: { type: 'string' },
|
|
84
|
+
},
|
|
85
|
+
required: ['store', 'reason', 'action', 'path', 'bytes'],
|
|
86
|
+
};
|
|
87
|
+
const STORE_SCHEMA = {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
store: { type: 'string' },
|
|
91
|
+
present: { type: 'boolean' },
|
|
92
|
+
entries: { type: 'integer' },
|
|
93
|
+
bytes: { type: 'integer' },
|
|
94
|
+
listed: { type: 'integer' },
|
|
95
|
+
listedBytes: { type: 'integer' },
|
|
96
|
+
newestAgeDays: { type: 'integer' },
|
|
97
|
+
oldestAgeDays: { type: 'integer' },
|
|
98
|
+
note: { type: 'string' },
|
|
99
|
+
},
|
|
100
|
+
required: ['store', 'present', 'entries', 'bytes', 'listed', 'listedBytes'],
|
|
101
|
+
};
|
|
102
|
+
const APPLIED_SCHEMA = {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
store: { type: 'string' },
|
|
106
|
+
reason: { type: 'string' },
|
|
107
|
+
path: { type: 'string' },
|
|
108
|
+
bytes: { type: 'integer' },
|
|
109
|
+
cause: { type: 'string' },
|
|
110
|
+
detail: { type: 'string' },
|
|
111
|
+
},
|
|
112
|
+
required: ['store', 'reason', 'path'],
|
|
113
|
+
};
|
|
114
|
+
const MARKED_SCHEMA = {
|
|
115
|
+
type: 'object',
|
|
116
|
+
properties: {
|
|
117
|
+
store: { type: 'string' },
|
|
118
|
+
reason: { type: 'string' },
|
|
119
|
+
path: { type: 'string' },
|
|
120
|
+
records: { type: 'integer' },
|
|
121
|
+
},
|
|
122
|
+
required: ['store', 'reason', 'path', 'records'],
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* MCP tool that reports the platform state kept in a target project: what is stale, orphaned or duplicated in the
|
|
126
|
+
* scan caches, legacy cache layouts, transform backups, snapshot refs, feedback sessions and the NGM-CACHE block.
|
|
127
|
+
* `mode: 'apply'` removes the cache, backup and snapshot ref items of an earlier report that are still unchanged and
|
|
128
|
+
* marks the listed feedback records in `.claude-feedback/index/consolidated.json`; nothing else is changed.
|
|
129
|
+
*/
|
|
130
|
+
export class RefreshStateTool {
|
|
131
|
+
inventoryOptions;
|
|
132
|
+
toolCatalog;
|
|
133
|
+
name = 'refresh-state';
|
|
134
|
+
title = 'Refresh Platform State';
|
|
135
|
+
annotations = {
|
|
136
|
+
readOnlyHint: false,
|
|
137
|
+
destructiveHint: true,
|
|
138
|
+
idempotentHint: true,
|
|
139
|
+
openWorldHint: false,
|
|
140
|
+
};
|
|
141
|
+
description = 'Lists the state the platform keeps in a project and what of it is stale, orphaned or duplicated: scan caches ' +
|
|
142
|
+
'(.angular-modernizer-cache: entries of deleted files, entries past the 24 h cache limit, unreadable entries), legacy ' +
|
|
143
|
+
'cache layouts, health snapshot and pattern knowledge (age only), transform backups (.angular-modernizer-backups: ' +
|
|
144
|
+
'groups older than the retention outside the newest groups, backups without metadata), git snapshot refs ' +
|
|
145
|
+
'(refs/angular-modernizer/snapshots), feedback sessions (.claude-feedback: duplicate records, records of unregistered rules, transformation types or tools and of deprecated tools) and the NGM-CACHE ' +
|
|
146
|
+
'block of .claude/CLAUDE.md. mode report (default) reads only, changes nothing and returns a planId (valid 10 min). ' +
|
|
147
|
+
"mode apply with that planId and parts (caches, backups, refs, feedback) removes the listed items of those parts that a fresh " +
|
|
148
|
+
'inventory with the retention of the report still lists for the same reason and that are unchanged (size and mtime, ' +
|
|
149
|
+
'every file of a backup group, the commit a ref points at); feedback marks the records in .claude-feedback/index/consolidated.json ' +
|
|
150
|
+
'and never changes a session file (review-feedback, suggest-improvements and analyze-parser-performance skip marked records); ' +
|
|
151
|
+
'everything else stays, and the plan is used up. Apply ' +
|
|
152
|
+
'only after the user confirmed the report. Never follows or removes symbolic links. Retention defaults come from ' +
|
|
153
|
+
"tools['refresh-state'] of .angular-modernizer.json. " +
|
|
154
|
+
'Each item says what a cleanup would do (remove, mark, regenerate). summary is one line per store plus the first items.';
|
|
155
|
+
/**
|
|
156
|
+
* JSON Schema of the tool arguments.
|
|
157
|
+
* @hidden
|
|
158
|
+
*/
|
|
159
|
+
inputSchema = {
|
|
160
|
+
type: 'object',
|
|
161
|
+
additionalProperties: false,
|
|
162
|
+
properties: {
|
|
163
|
+
projectRoot: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'Project root whose platform state is reported (default: the current working directory)',
|
|
166
|
+
},
|
|
167
|
+
mode: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
enum: ['report', 'apply'],
|
|
170
|
+
default: 'report',
|
|
171
|
+
description: 'report: list what is stale, orphaned or duplicated, change nothing, return a planId; apply: remove the unchanged items of a report and mark its feedback records (needs planId and parts)',
|
|
172
|
+
},
|
|
173
|
+
planId: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
description: "planId of a report of the same project, at most 10 minutes old (mode 'apply' only); used up by the apply",
|
|
176
|
+
},
|
|
177
|
+
parts: {
|
|
178
|
+
type: 'array',
|
|
179
|
+
items: { type: 'string', enum: [...REFRESH_PARTS] },
|
|
180
|
+
minItems: 1,
|
|
181
|
+
uniqueItems: true,
|
|
182
|
+
description: "Parts to act on (mode 'apply' only). caches: scan cache entries listed as orphan, expired or unreadable, and the legacy cache folders; backups: backup groups listed by retention (exactly the files the report saw) and backup files without metadata; refs: snapshot refs listed by retention or without a backup group (deleted only while they still point at the commit of the report); feedback: session files listed with duplicate or outdated records, marked in .claude-feedback/index/consolidated.json while the file is unchanged (the session files stay as written)",
|
|
183
|
+
},
|
|
184
|
+
retentionDays: {
|
|
185
|
+
type: 'integer',
|
|
186
|
+
minimum: 0,
|
|
187
|
+
default: DEFAULT_RETENTION_DAYS,
|
|
188
|
+
description: `Backup groups and snapshot refs older than this many days are listed (mode 'report' only; default tools['refresh-state'].retentionDays, else ${DEFAULT_RETENTION_DAYS}); an apply uses the retention of its report`,
|
|
189
|
+
},
|
|
190
|
+
keepNewest: {
|
|
191
|
+
type: 'integer',
|
|
192
|
+
minimum: 1,
|
|
193
|
+
default: DEFAULT_KEEP_NEWEST,
|
|
194
|
+
description: `Newest backup groups that are never listed, whatever their age (mode 'report' only; default tools['refresh-state'].keepNewest, else ${DEFAULT_KEEP_NEWEST}); at least 1, because the newest group is what rollback-changes restores`,
|
|
195
|
+
},
|
|
196
|
+
...COMPACT_OUTPUT_SCHEMA,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* JSON Schema of the tool result (`structuredContent`).
|
|
201
|
+
* @hidden
|
|
202
|
+
*/
|
|
203
|
+
outputSchema = {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
mode: { type: 'string', enum: ['report', 'apply'] },
|
|
207
|
+
projectRoot: { type: 'string' },
|
|
208
|
+
generatedAt: { type: 'string' },
|
|
209
|
+
planId: { type: 'string' },
|
|
210
|
+
expiresAt: { type: 'string' },
|
|
211
|
+
parts: { type: 'array', items: { type: 'string' } },
|
|
212
|
+
removed: { type: 'array', items: APPLIED_SCHEMA },
|
|
213
|
+
marked: { type: 'array', items: MARKED_SCHEMA },
|
|
214
|
+
skipped: { type: 'array', items: APPLIED_SCHEMA },
|
|
215
|
+
retention: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
days: { type: 'integer' },
|
|
219
|
+
keepNewest: { type: 'integer' },
|
|
220
|
+
},
|
|
221
|
+
required: ['days', 'keepNewest'],
|
|
222
|
+
},
|
|
223
|
+
stores: { type: 'array', items: STORE_SCHEMA },
|
|
224
|
+
items: { type: 'array', items: ITEM_SCHEMA },
|
|
225
|
+
truncated: { type: 'boolean' },
|
|
226
|
+
counts: {
|
|
227
|
+
type: 'object',
|
|
228
|
+
properties: {
|
|
229
|
+
items: { type: 'integer' },
|
|
230
|
+
bytes: { type: 'integer' },
|
|
231
|
+
byReason: {
|
|
232
|
+
type: 'object',
|
|
233
|
+
additionalProperties: { type: 'integer' },
|
|
234
|
+
},
|
|
235
|
+
skipped: { type: 'integer' },
|
|
236
|
+
marked: { type: 'integer' },
|
|
237
|
+
markedRecords: { type: 'integer' },
|
|
238
|
+
skippedByCause: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
additionalProperties: { type: 'integer' },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
required: ['items', 'bytes', 'byReason'],
|
|
244
|
+
},
|
|
245
|
+
summary: { type: 'string' },
|
|
246
|
+
},
|
|
247
|
+
required: ['mode', 'projectRoot', 'generatedAt', 'planId', 'counts', 'summary'],
|
|
248
|
+
};
|
|
249
|
+
/** Plans handed out by reports of this instance. */
|
|
250
|
+
plans;
|
|
251
|
+
/**
|
|
252
|
+
* @param inventoryOptions clock and git for tests
|
|
253
|
+
* @param toolCatalog tools the server registers (feedback records of other tools count as outdated); without it
|
|
254
|
+
* tools are not checked
|
|
255
|
+
*/
|
|
256
|
+
constructor(inventoryOptions = {}, toolCatalog) {
|
|
257
|
+
this.inventoryOptions = inventoryOptions;
|
|
258
|
+
this.toolCatalog = toolCatalog;
|
|
259
|
+
this.plans = new RefreshPlans(inventoryOptions.now ?? Date.now, inventoryOptions.git);
|
|
260
|
+
}
|
|
261
|
+
async execute(args) {
|
|
262
|
+
const { projectRoot, retentionDays, keepNewest, mode, planId, parts } = args;
|
|
263
|
+
const root = typeof projectRoot === 'string' ? projectRoot : process.cwd();
|
|
264
|
+
if (mode === 'apply') {
|
|
265
|
+
if (typeof planId !== 'string' || !Array.isArray(parts) || parts.length === 0) {
|
|
266
|
+
throw new Error("mode 'apply' needs the planId of a report and parts (e.g. ['caches']); nothing was changed");
|
|
267
|
+
}
|
|
268
|
+
if (retentionDays !== undefined || keepNewest !== undefined) {
|
|
269
|
+
throw new Error("retentionDays and keepNewest are read only with mode 'report'; an apply uses the retention of its report. Nothing was changed");
|
|
270
|
+
}
|
|
271
|
+
return this.apply(args, realpathSync(root), planId, parts);
|
|
272
|
+
}
|
|
273
|
+
if (planId !== undefined || parts !== undefined) {
|
|
274
|
+
throw new Error("planId and parts are read only with mode 'apply'; nothing was changed");
|
|
275
|
+
}
|
|
276
|
+
const config = loadConfig(root).tools?.['refresh-state'] ?? {};
|
|
277
|
+
const inventory = inventoryPlatformState(root, {
|
|
278
|
+
...this.inventoryOptions,
|
|
279
|
+
tools: this.toolCatalog?.(),
|
|
280
|
+
retentionDays: typeof retentionDays === 'number' ? retentionDays : config.retentionDays,
|
|
281
|
+
keepNewest: typeof keepNewest === 'number' ? keepNewest : config.keepNewest,
|
|
282
|
+
});
|
|
283
|
+
return this.report(args, inventory);
|
|
284
|
+
}
|
|
285
|
+
report(args, inventory) {
|
|
286
|
+
const compact = parseCompactOptions(args);
|
|
287
|
+
const plan = this.plans.create(inventory.projectRoot, inventory.items, inventory.retention);
|
|
288
|
+
const byReason = {};
|
|
289
|
+
for (const item of inventory.items) {
|
|
290
|
+
byReason[item.reason] = (byReason[item.reason] ?? 0) + 1;
|
|
291
|
+
}
|
|
292
|
+
const limited = limitList(inventory.items, compact.maxResults);
|
|
293
|
+
const output = {
|
|
294
|
+
mode: 'report',
|
|
295
|
+
planId: plan.planId,
|
|
296
|
+
expiresAt: new Date(plan.expiresAt).toISOString(),
|
|
297
|
+
projectRoot: inventory.projectRoot,
|
|
298
|
+
generatedAt: inventory.generatedAt,
|
|
299
|
+
retention: inventory.retention,
|
|
300
|
+
stores: inventory.stores,
|
|
301
|
+
...(compact.summaryOnly
|
|
302
|
+
? {}
|
|
303
|
+
: { items: limited.items, truncated: limited.truncated }),
|
|
304
|
+
counts: {
|
|
305
|
+
items: inventory.items.length,
|
|
306
|
+
bytes: inventory.items.reduce((sum, i) => sum + i.bytes, 0),
|
|
307
|
+
byReason,
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
return { ...output, summary: describe(output, inventory.items) };
|
|
311
|
+
}
|
|
312
|
+
apply(args, projectRoot, planId, parts) {
|
|
313
|
+
const compact = parseCompactOptions(args);
|
|
314
|
+
let generatedAt = new Date((this.inventoryOptions.now ?? Date.now)()).toISOString();
|
|
315
|
+
const tools = this.toolCatalog?.();
|
|
316
|
+
const outcome = this.plans.apply(planId, projectRoot, parts, (retention) => {
|
|
317
|
+
const inventory = inventoryPlatformState(projectRoot, {
|
|
318
|
+
...this.inventoryOptions,
|
|
319
|
+
tools,
|
|
320
|
+
retentionDays: retention.days,
|
|
321
|
+
keepNewest: retention.keepNewest,
|
|
322
|
+
});
|
|
323
|
+
generatedAt = inventory.generatedAt;
|
|
324
|
+
return inventory.items;
|
|
325
|
+
}, tools);
|
|
326
|
+
const byReason = {};
|
|
327
|
+
for (const item of outcome.removed) {
|
|
328
|
+
byReason[item.reason] = (byReason[item.reason] ?? 0) + 1;
|
|
329
|
+
}
|
|
330
|
+
const skippedByCause = {};
|
|
331
|
+
for (const item of outcome.skipped) {
|
|
332
|
+
skippedByCause[item.cause] = (skippedByCause[item.cause] ?? 0) + 1;
|
|
333
|
+
}
|
|
334
|
+
const removed = limitList(outcome.removed, compact.maxResults);
|
|
335
|
+
const marked = limitList(outcome.marked, compact.maxResults);
|
|
336
|
+
const skipped = limitList(outcome.skipped, compact.maxResults);
|
|
337
|
+
const output = {
|
|
338
|
+
mode: 'apply',
|
|
339
|
+
projectRoot,
|
|
340
|
+
generatedAt,
|
|
341
|
+
planId,
|
|
342
|
+
parts,
|
|
343
|
+
...(compact.summaryOnly
|
|
344
|
+
? {}
|
|
345
|
+
: {
|
|
346
|
+
removed: removed.items,
|
|
347
|
+
marked: marked.items,
|
|
348
|
+
skipped: skipped.items,
|
|
349
|
+
truncated: removed.truncated || marked.truncated || skipped.truncated,
|
|
350
|
+
}),
|
|
351
|
+
counts: {
|
|
352
|
+
items: outcome.removed.length,
|
|
353
|
+
bytes: outcome.removed.reduce((sum, i) => sum + i.bytes, 0),
|
|
354
|
+
byReason,
|
|
355
|
+
skipped: outcome.skipped.length,
|
|
356
|
+
skippedByCause,
|
|
357
|
+
marked: outcome.marked.length,
|
|
358
|
+
// A session file listed for two reasons counts once
|
|
359
|
+
markedRecords: [
|
|
360
|
+
...new Map(outcome.marked.map((i) => [i.path, i.records])).values(),
|
|
361
|
+
].reduce((sum, n) => sum + n, 0),
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
return {
|
|
365
|
+
...output,
|
|
366
|
+
summary: describeApply(output, outcome.removed, outcome.marked, outcome.skipped),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=refresh-state.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 ResolvedTypeInfo } from '@angular-modernizer/api';
|
|
3
3
|
import { ProjectCache } from './helpers/project-cache.js';
|
|
4
4
|
/**
|
|
@@ -94,7 +94,7 @@ export declare class ResolveTypeTool implements MCPTool {
|
|
|
94
94
|
* @param args - Tool arguments validated against the input schema
|
|
95
95
|
* @returns The resolved type with a text summary
|
|
96
96
|
*/
|
|
97
|
-
execute(args: Record<string, unknown
|
|
97
|
+
execute(args: Record<string, unknown>, ctx?: ToolContext): Promise<ResolvedTypeInfo & {
|
|
98
98
|
/** Short text summary of the resolved type. */
|
|
99
99
|
summary: string;
|
|
100
100
|
/** Conditions that can make the result incomplete (unresolved library imports). */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TypeResolver } 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
|
/**
|
|
7
8
|
* MCP tool for resolving the TypeScript type at a given source position.
|
|
@@ -46,7 +47,7 @@ export class ResolveTypeTool {
|
|
|
46
47
|
properties: {
|
|
47
48
|
file: {
|
|
48
49
|
type: 'string',
|
|
49
|
-
description: '
|
|
50
|
+
description: 'Source file (absolute path, or relative to projectRoot).',
|
|
50
51
|
},
|
|
51
52
|
line: {
|
|
52
53
|
type: 'number',
|
|
@@ -92,7 +93,7 @@ export class ResolveTypeTool {
|
|
|
92
93
|
* @param args - Tool arguments validated against the input schema
|
|
93
94
|
* @returns The resolved type with a text summary
|
|
94
95
|
*/
|
|
95
|
-
async execute(args) {
|
|
96
|
+
async execute(args, ctx = {}) {
|
|
96
97
|
const params = args;
|
|
97
98
|
if (!params.file) {
|
|
98
99
|
throw new Error('file is required');
|
|
@@ -109,16 +110,22 @@ export class ResolveTypeTool {
|
|
|
109
110
|
if (!existsSync(params.projectRoot)) {
|
|
110
111
|
throw new Error(`projectRoot does not exist: ${params.projectRoot}`);
|
|
111
112
|
}
|
|
113
|
+
const filePath = isAbsolute(params.file)
|
|
114
|
+
? params.file
|
|
115
|
+
: resolve(params.projectRoot, params.file);
|
|
116
|
+
if (!existsSync(filePath)) {
|
|
117
|
+
throw new Error(`file does not exist: ${filePath}`);
|
|
118
|
+
}
|
|
112
119
|
const tsConfigPath = findTsConfig(params.projectRoot);
|
|
113
120
|
if (!tsConfigPath) {
|
|
114
121
|
throw new Error(`tsconfig.json not found in projectRoot: ${params.projectRoot}`);
|
|
115
122
|
}
|
|
116
|
-
const project = this.projects
|
|
123
|
+
const project = await acquireProject(this.projects, tsConfigPath, ctx);
|
|
117
124
|
const typeResolver = new TypeResolver(project);
|
|
118
|
-
const info = typeResolver.resolveType(
|
|
125
|
+
const info = typeResolver.resolveType(filePath, params.line, params.column);
|
|
119
126
|
return withWarnings({
|
|
120
127
|
...info,
|
|
121
|
-
summary: this.buildSummary(
|
|
128
|
+
summary: this.buildSummary(filePath, params.line, params.column, info),
|
|
122
129
|
}, this.projects.warnings(tsConfigPath));
|
|
123
130
|
}
|
|
124
131
|
buildSummary(file, line, column, info) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
2
2
|
import { type AnalysisInsight } from '@angular-modernizer/core';
|
|
3
|
+
import { type SkippedRecords } from './helpers/feedback-sidecar.js';
|
|
3
4
|
/**
|
|
4
5
|
* Output from review-feedback tool
|
|
5
6
|
*/
|
|
6
7
|
export interface ReviewFeedbackOutput {
|
|
8
|
+
/** Analysis that ran: the argument, `tools['review-feedback'].analysisType` or 'all' */
|
|
9
|
+
analysisType: 'success-patterns' | 'failure-patterns' | 'quality-trends' | 'all';
|
|
7
10
|
/** Number of sessions analyzed */
|
|
8
11
|
sessions: number;
|
|
9
12
|
/** Total number of transformations analyzed */
|
|
@@ -20,6 +23,10 @@ export interface ReviewFeedbackOutput {
|
|
|
20
23
|
analysisRecords: number;
|
|
21
24
|
/** Analysis records grouped by tool and category */
|
|
22
25
|
analysisInsights: AnalysisInsight[];
|
|
26
|
+
/** Records skipped because the feedback sidecar marks them (0 with `includeOutdated`) */
|
|
27
|
+
skippedRecords: SkippedRecords;
|
|
28
|
+
/** Unusable sidecar, or session files changed since refresh-state marked them */
|
|
29
|
+
sidecarWarnings?: string[];
|
|
23
30
|
/** Short text: counts, success rate, top insights and quality warnings */
|
|
24
31
|
summary: string;
|
|
25
32
|
}
|
|
@@ -88,6 +95,11 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
88
95
|
readonly type: "object";
|
|
89
96
|
readonly additionalProperties: false;
|
|
90
97
|
readonly properties: {
|
|
98
|
+
readonly includeOutdated: {
|
|
99
|
+
readonly type: "boolean";
|
|
100
|
+
readonly default: false;
|
|
101
|
+
readonly description: "Also read the records that .claude-feedback/index/consolidated.json marks as duplicate or outdated (written by refresh-state apply, part 'feedback'); default false skips them and counts them in skippedRecords";
|
|
102
|
+
};
|
|
91
103
|
readonly projectRoot: {
|
|
92
104
|
readonly type: "string";
|
|
93
105
|
readonly description: "Project root path (defaults to process.cwd() if not provided)";
|
|
@@ -112,7 +124,7 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
112
124
|
readonly analysisType: {
|
|
113
125
|
readonly type: "string";
|
|
114
126
|
readonly enum: readonly ["success-patterns", "failure-patterns", "quality-trends", "all"];
|
|
115
|
-
readonly description: "Type of analysis to perform";
|
|
127
|
+
readonly description: "Type of analysis to perform (default: tools['review-feedback'].analysisType, else 'all')";
|
|
116
128
|
};
|
|
117
129
|
readonly minConfidence: {
|
|
118
130
|
readonly type: "number";
|
|
@@ -124,7 +136,7 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
124
136
|
readonly type: "number";
|
|
125
137
|
readonly minimum: 0;
|
|
126
138
|
readonly maximum: 100;
|
|
127
|
-
readonly description:
|
|
139
|
+
readonly description: string;
|
|
128
140
|
};
|
|
129
141
|
readonly source: {
|
|
130
142
|
readonly type: "string";
|
|
@@ -136,7 +148,6 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
136
148
|
readonly description: "Optional tool filter for analysis records (e.g. 'find-usages')";
|
|
137
149
|
};
|
|
138
150
|
};
|
|
139
|
-
readonly required: readonly ["analysisType"];
|
|
140
151
|
};
|
|
141
152
|
/**
|
|
142
153
|
* JSON Schema of the tool result (`structuredContent`).
|
|
@@ -145,6 +156,33 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
145
156
|
outputSchema: {
|
|
146
157
|
type: string;
|
|
147
158
|
properties: {
|
|
159
|
+
summary: {
|
|
160
|
+
type: string;
|
|
161
|
+
};
|
|
162
|
+
skippedRecords: {
|
|
163
|
+
readonly type: "object";
|
|
164
|
+
readonly properties: {
|
|
165
|
+
readonly total: {
|
|
166
|
+
readonly type: "integer";
|
|
167
|
+
};
|
|
168
|
+
readonly byReason: {
|
|
169
|
+
readonly type: "object";
|
|
170
|
+
readonly additionalProperties: {
|
|
171
|
+
readonly type: "integer";
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
readonly required: readonly ["total", "byReason"];
|
|
176
|
+
};
|
|
177
|
+
sidecarWarnings: {
|
|
178
|
+
readonly type: "array";
|
|
179
|
+
readonly items: {
|
|
180
|
+
readonly type: "string";
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
analysisType: {
|
|
184
|
+
type: string;
|
|
185
|
+
};
|
|
148
186
|
sessions: {
|
|
149
187
|
type: string;
|
|
150
188
|
};
|
|
@@ -267,9 +305,6 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
267
305
|
required: string[];
|
|
268
306
|
};
|
|
269
307
|
};
|
|
270
|
-
summary: {
|
|
271
|
-
type: string;
|
|
272
|
-
};
|
|
273
308
|
};
|
|
274
309
|
required: string[];
|
|
275
310
|
};
|
|
@@ -286,7 +321,7 @@ export declare class ReviewFeedbackTool implements MCPTool {
|
|
|
286
321
|
* @param args.since - Optional ISO 8601 date filter for recent feedback
|
|
287
322
|
* @param args.analysisType - Type of analysis: 'success-patterns', 'failure-patterns', 'quality-trends', or 'all'
|
|
288
323
|
* @param args.minConfidence - Minimum confidence threshold 0.0-1.0 (default: 0.7)
|
|
289
|
-
* @param args.minCompleteness - Minimum completeness threshold 0-100 (default:
|
|
324
|
+
* @param args.minCompleteness - Minimum completeness threshold 0-100 (default: 40)
|
|
290
325
|
* @param args.source - Storage location strategy: 'project', 'platform', or 'both' (default: 'both')
|
|
291
326
|
*
|
|
292
327
|
* @returns ReviewFeedbackOutput containing:
|