@angular-modernizer/adapter-mcp 1.2.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 +84 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +9 -0
- 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 +7 -4
- package/dist/tools/analyze-build-impact.js +8 -3
- 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 +30 -4
- package/dist/tools/analyze-project.js +99 -15
- 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.js +3 -2
- package/dist/tools/find-component-hosts.js +3 -2
- package/dist/tools/find-usages.js +21 -12
- package/dist/tools/get-call-graph.js +15 -2
- 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 +5 -4
- package/dist/tools/helpers/project-cache.js +21 -16
- 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.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.js +5 -0
- package/dist/tools/inspect-i18n.d.ts +1 -1
- package/dist/tools/inspect-template.js +8 -2
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +1 -1
- 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.js +22 -10
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.js +10 -3
- 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 +6 -1
- package/dist/tools/search-codebase.js +13 -7
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.js +3 -2
- 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 +715 -206
- 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,5 +1,6 @@
|
|
|
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
5
|
import { ProjectCache, acquireProject } from './helpers/project-cache.js';
|
|
5
6
|
import { WARNINGS_OUTPUT_SCHEMA, withWarnings, } from './helpers/output-contract.js';
|
|
@@ -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',
|
|
@@ -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
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:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FeedbackStorage, OutlierDetector, loadConfig, fromLegacyAnalysisRecord, scoreAnalysisCompleteness, summarizeAnalysisFeedback, } from '@angular-modernizer/core';
|
|
2
2
|
import { feedbackSessionDirs, feedbackStorageConfig, resolveFeedbackRoots, } from './helpers/platform-root-resolver.js';
|
|
3
3
|
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
4
|
+
import { INCLUDE_OUTDATED_SCHEMA, SKIPPED_RECORDS_OUTPUT_SCHEMA, describeSkipped, skipMarkedRecords, } from './helpers/feedback-sidecar.js';
|
|
4
5
|
/** Insights and analysis groups spelled out in the summary. */
|
|
5
6
|
const SUMMARY_INSIGHTS = 5;
|
|
6
7
|
/** Text summary: what was read, success rate, top insights, analysis groups, warnings. */
|
|
@@ -20,6 +21,7 @@ function describeReview(output) {
|
|
|
20
21
|
for (const warning of output.qualityWarnings) {
|
|
21
22
|
lines.push(`Warning: ${warning.message}`);
|
|
22
23
|
}
|
|
24
|
+
lines.push(...describeSkipped(output.skippedRecords, output.sidecarWarnings ?? []));
|
|
23
25
|
return lines.join('\n');
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
@@ -81,7 +83,7 @@ export class ReviewFeedbackTool {
|
|
|
81
83
|
analysisType: {
|
|
82
84
|
type: 'string',
|
|
83
85
|
enum: ['success-patterns', 'failure-patterns', 'quality-trends', 'all'],
|
|
84
|
-
description:
|
|
86
|
+
description: "Type of analysis to perform (default: tools['review-feedback'].analysisType, else 'all')",
|
|
85
87
|
},
|
|
86
88
|
minConfidence: {
|
|
87
89
|
type: 'number',
|
|
@@ -93,7 +95,8 @@ export class ReviewFeedbackTool {
|
|
|
93
95
|
type: 'number',
|
|
94
96
|
minimum: 0,
|
|
95
97
|
maximum: 100,
|
|
96
|
-
description: 'Minimum completeness
|
|
98
|
+
description: 'Minimum completeness score 0-100 of a feedback record (default: 40). collect-feedback scores 20 points each for execution, validation, outcome metrics, diff and learnings; ' +
|
|
99
|
+
'a successful transformation sent with execution and validation results scores 40, without validation 20.',
|
|
97
100
|
},
|
|
98
101
|
source: {
|
|
99
102
|
type: 'string',
|
|
@@ -106,8 +109,8 @@ export class ReviewFeedbackTool {
|
|
|
106
109
|
type: 'string',
|
|
107
110
|
description: "Optional tool filter for analysis records (e.g. 'find-usages')",
|
|
108
111
|
},
|
|
112
|
+
...INCLUDE_OUTDATED_SCHEMA,
|
|
109
113
|
},
|
|
110
|
-
required: ['analysisType'],
|
|
111
114
|
};
|
|
112
115
|
/**
|
|
113
116
|
* JSON Schema of the tool result (`structuredContent`).
|
|
@@ -116,6 +119,7 @@ export class ReviewFeedbackTool {
|
|
|
116
119
|
outputSchema = {
|
|
117
120
|
type: 'object',
|
|
118
121
|
properties: {
|
|
122
|
+
analysisType: { type: 'string' },
|
|
119
123
|
sessions: { type: 'integer' },
|
|
120
124
|
transformations: { type: 'integer' },
|
|
121
125
|
successRate: { type: 'number' },
|
|
@@ -183,6 +187,7 @@ export class ReviewFeedbackTool {
|
|
|
183
187
|
required: ['tool', 'category', 'count'],
|
|
184
188
|
},
|
|
185
189
|
},
|
|
190
|
+
...SKIPPED_RECORDS_OUTPUT_SCHEMA,
|
|
186
191
|
summary: { type: 'string' },
|
|
187
192
|
},
|
|
188
193
|
required: [
|
|
@@ -210,7 +215,7 @@ export class ReviewFeedbackTool {
|
|
|
210
215
|
* @param args.since - Optional ISO 8601 date filter for recent feedback
|
|
211
216
|
* @param args.analysisType - Type of analysis: 'success-patterns', 'failure-patterns', 'quality-trends', or 'all'
|
|
212
217
|
* @param args.minConfidence - Minimum confidence threshold 0.0-1.0 (default: 0.7)
|
|
213
|
-
* @param args.minCompleteness - Minimum completeness threshold 0-100 (default:
|
|
218
|
+
* @param args.minCompleteness - Minimum completeness threshold 0-100 (default: 40)
|
|
214
219
|
* @param args.source - Storage location strategy: 'project', 'platform', or 'both' (default: 'both')
|
|
215
220
|
*
|
|
216
221
|
* @returns ReviewFeedbackOutput containing:
|
|
@@ -262,8 +267,9 @@ export class ReviewFeedbackTool {
|
|
|
262
267
|
fullConfig.projectRoot ??
|
|
263
268
|
initialProjectRoot;
|
|
264
269
|
// Apply defaults
|
|
270
|
+
const analysisType = input.analysisType ?? 'all';
|
|
265
271
|
const minConfidence = input.minConfidence ?? 0.7;
|
|
266
|
-
const minCompleteness = input.minCompleteness ??
|
|
272
|
+
const minCompleteness = input.minCompleteness ?? 40;
|
|
267
273
|
const source = input.source ?? 'both';
|
|
268
274
|
// The project always; the platform store only when configured
|
|
269
275
|
const roots = resolveFeedbackRoots(projectRoot, source);
|
|
@@ -286,7 +292,9 @@ export class ReviewFeedbackTool {
|
|
|
286
292
|
// Session not found in any location, skip
|
|
287
293
|
}
|
|
288
294
|
}
|
|
289
|
-
|
|
295
|
+
// Records the sidecar marks (duplicates, outdated) stay out unless includeOutdated
|
|
296
|
+
const marked = skipMarkedRecords(projectRoot, sessionMap, input.includeOutdated === true);
|
|
297
|
+
const sessions = marked.sessions;
|
|
290
298
|
// Flatten all transformations and analysis records. Analysis misses that
|
|
291
299
|
// were backfilled as transformation records are moved to the analysis list.
|
|
292
300
|
let allFeedback = [];
|
|
@@ -335,11 +343,12 @@ export class ReviewFeedbackTool {
|
|
|
335
343
|
const successRate = validFeedback.length > 0 ? successfulCount / validFeedback.length : 0;
|
|
336
344
|
// Analyze patterns
|
|
337
345
|
const { analyzePatterns } = await import('./helpers/feedback-analyzer.js');
|
|
338
|
-
const insights = analyzePatterns(validFeedback,
|
|
346
|
+
const insights = analyzePatterns(validFeedback, analysisType, minConfidence);
|
|
339
347
|
// Generate quality warnings
|
|
340
348
|
const qualityWarnings = generateQualityWarnings(unfilteredFeedback, outlierReport, minCompleteness, analysisScores);
|
|
341
349
|
// Return output
|
|
342
350
|
const output = {
|
|
351
|
+
analysisType,
|
|
343
352
|
sessions: sessions.length,
|
|
344
353
|
transformations: validFeedback.length,
|
|
345
354
|
successRate,
|
|
@@ -348,12 +357,12 @@ export class ReviewFeedbackTool {
|
|
|
348
357
|
qualityWarnings,
|
|
349
358
|
analysisRecords: validAnalyses.length,
|
|
350
359
|
analysisInsights,
|
|
360
|
+
skippedRecords: marked.skipped,
|
|
361
|
+
...(marked.warnings.length === 0 ? {} : { sidecarWarnings: marked.warnings }),
|
|
351
362
|
};
|
|
352
363
|
return { ...output, summary: describeReview(output) };
|
|
353
364
|
}
|
|
354
365
|
}
|
|
355
|
-
/** Completeness below this value is reported as low quality */
|
|
356
|
-
const LOW_COMPLETENESS_THRESHOLD = 70;
|
|
357
366
|
/**
|
|
358
367
|
* Generate quality warnings about feedback data
|
|
359
368
|
*
|
|
@@ -371,19 +380,17 @@ function generateQualityWarnings(allFeedback, outlierReport, minCompleteness, an
|
|
|
371
380
|
if (scores.length === 0) {
|
|
372
381
|
return warnings;
|
|
373
382
|
}
|
|
374
|
-
// Low-completeness records (transformation + analysis)
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
|
|
383
|
+
// Low-completeness records (transformation + analysis): the records the
|
|
384
|
+
// minCompleteness filter drops, counted on the unfiltered list so they are
|
|
385
|
+
// visible here. A fixed threshold above the filter warned about every record
|
|
386
|
+
// the agents send (collect-feedback never stores metrics or a diff).
|
|
387
|
+
const lowCompletenessCount = scores.filter((score) => score < minCompleteness).length;
|
|
378
388
|
if (lowCompletenessCount > 0) {
|
|
379
|
-
const excludedNote = excludedCount > 0
|
|
380
|
-
? `; ${excludedCount} excluded from learning by minCompleteness ${minCompleteness}`
|
|
381
|
-
: '';
|
|
382
389
|
warnings.push({
|
|
383
390
|
type: 'low-completeness',
|
|
384
391
|
count: lowCompletenessCount,
|
|
385
392
|
percentage: (lowCompletenessCount / scores.length) * 100,
|
|
386
|
-
message: `${lowCompletenessCount} feedback records
|
|
393
|
+
message: `${lowCompletenessCount} feedback records below minCompleteness ${minCompleteness} are excluded from learning`,
|
|
387
394
|
});
|
|
388
395
|
}
|
|
389
396
|
if (allFeedback.length === 0) {
|