toolmenu 0.25.2 → 0.27.1
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 +170 -683
- package/dist/args.d.ts +14 -2
- package/dist/args.js +44 -1
- package/dist/auth-check.d.ts +27 -0
- package/dist/auth-check.js +177 -0
- package/dist/auth.d.ts +7 -0
- package/dist/auth.js +29 -1
- package/dist/auto.d.ts +8 -0
- package/dist/auto.js +9 -2
- package/dist/breakdown.js +14 -10
- package/dist/cli.js +151 -49
- package/dist/clients.d.ts +13 -2
- package/dist/clients.js +65 -11
- package/dist/config.js +6 -0
- package/dist/diff.d.ts +35 -1
- package/dist/diff.js +57 -12
- package/dist/failures.js +4 -3
- package/dist/help.d.ts +1 -1
- package/dist/help.js +45 -18
- package/dist/history.js +5 -0
- package/dist/html.d.ts +29 -0
- package/dist/html.js +360 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/init.d.ts +14 -0
- package/dist/init.js +20 -6
- package/dist/junit.d.ts +6 -1
- package/dist/junit.js +12 -3
- package/dist/mcp-env.d.ts +6 -0
- package/dist/mcp-env.js +6 -0
- package/dist/mcp.d.ts +11 -1
- package/dist/mcp.js +123 -22
- package/dist/menu.d.ts +6 -0
- package/dist/menu.js +12 -1
- package/dist/options.d.ts +10 -0
- package/dist/options.js +3 -0
- package/dist/report.d.ts +14 -0
- package/dist/report.js +57 -51
- package/dist/review.d.ts +48 -0
- package/dist/review.js +212 -0
- package/dist/rule-docs.json +49 -4
- package/dist/rules/clients.d.ts +11 -0
- package/dist/rules/clients.js +65 -2
- package/dist/rules/determinism.d.ts +3 -0
- package/dist/rules/determinism.js +44 -7
- package/dist/rules/ids.js +5 -1
- package/dist/rules/index.js +5 -2
- package/dist/rules/output.d.ts +21 -0
- package/dist/rules/output.js +49 -0
- package/dist/rules/search.js +1 -1
- package/dist/rules/spec.d.ts +19 -0
- package/dist/rules/spec.js +86 -1
- package/dist/sanitize.d.ts +42 -0
- package/dist/sanitize.js +142 -0
- package/dist/scan.d.ts +9 -2
- package/dist/scan.js +46 -24
- package/dist/session.d.ts +17 -0
- package/dist/session.js +119 -13
- package/dist/snapshot.js +2 -1
- package/package.json +5 -3
package/dist/report.js
CHANGED
|
@@ -3,6 +3,7 @@ import { clip, stepLabel, stepsText } from './session.js';
|
|
|
3
3
|
import { SEVERITY_RANK } from './types.js';
|
|
4
4
|
import { breakdown, breakdownLines, breakdownMarkdown } from './breakdown.js';
|
|
5
5
|
import { autoSummary } from './auto.js';
|
|
6
|
+
import { mdCode, mdText, plain } from './sanitize.js';
|
|
6
7
|
const LABEL = { error: 'ERROR', warn: 'WARN ', info: 'INFO ' };
|
|
7
8
|
export function counts(findings) {
|
|
8
9
|
const c = { error: 0, warn: 0, info: 0 };
|
|
@@ -22,10 +23,10 @@ function otherLists(menu) {
|
|
|
22
23
|
].filter(Boolean).join(' · ');
|
|
23
24
|
}
|
|
24
25
|
/** --client: "as Claude Code: up front ~N tokens (…) · on demand ~M per tool loaded (largest: x, ~K)". */
|
|
25
|
-
function costLine(cost) {
|
|
26
|
+
export function costLine(cost, name = plain) {
|
|
26
27
|
const parts = [
|
|
27
28
|
cost.upfront !== undefined ? `up front ~${cost.upfront.toLocaleString('en-US')} tokens${cost.loaded.length ? ` (names, and ${plural(cost.loaded.length, 'tool')} loaded in full)` : ''}` : '',
|
|
28
|
-
`on demand ~${cost.perTool.toLocaleString('en-US')} per tool a search loads${cost.largest ? ` (largest: ${cost.largest.tool}, ~${cost.largest.tokens.toLocaleString('en-US')})` : ''}`,
|
|
29
|
+
`on demand ~${cost.perTool.toLocaleString('en-US')} per tool a search loads${cost.largest ? ` (largest: ${name(cost.largest.tool)}, ~${cost.largest.tokens.toLocaleString('en-US')})` : ''}`,
|
|
29
30
|
].filter(Boolean);
|
|
30
31
|
return `as ${cost.label}: ${parts.join(' · ')}`;
|
|
31
32
|
}
|
|
@@ -59,10 +60,10 @@ export function formatSnapshot(menu, findings, format, outPath, cost, notOffered
|
|
|
59
60
|
if (format === 'markdown') {
|
|
60
61
|
const s = menu.server;
|
|
61
62
|
return [
|
|
62
|
-
`### toolmenu snapshot:
|
|
63
|
+
`### toolmenu snapshot: ${mdCode(s.name ?? 'server')} ${mdText(s.version ?? '')}`.trimEnd(),
|
|
63
64
|
'',
|
|
64
|
-
`Protocol ${s.protocolVersion ?? 'unknown'} · ${plural(menu.tools.length, 'tool')} · ~${menu.totalTokens.toLocaleString('en-US')} tokens (estimate)${appOnlyNote(view.appOnly)}`,
|
|
65
|
-
...(cost ? ['', `${costLine(cost)}. _${cost.basis}._`] : []),
|
|
65
|
+
`Protocol ${mdText(s.protocolVersion ?? 'unknown')} · ${plural(menu.tools.length, 'tool')} · ~${menu.totalTokens.toLocaleString('en-US')} tokens (estimate)${appOnlyNote(view.appOnly)}`,
|
|
66
|
+
...(cost ? ['', `${costLine(cost, mdCode)}. _${cost.basis}._`] : []),
|
|
66
67
|
...(otherLists(menu) ? ['', `Also listed: ${otherLists(menu)}`] : []),
|
|
67
68
|
'',
|
|
68
69
|
...mdFindings(findings),
|
|
@@ -71,8 +72,8 @@ export function formatSnapshot(menu, findings, format, outPath, cost, notOffered
|
|
|
71
72
|
}
|
|
72
73
|
const s = menu.server;
|
|
73
74
|
const lines = [
|
|
74
|
-
`toolmenu snapshot ${s.name ?? 'unknown server'} ${s.version ?? ''}`.trimEnd(),
|
|
75
|
-
` protocol ${s.protocolVersion ?? 'unknown'} · ${plural(menu.tools.length, 'tool')} · ~${menu.totalTokens.toLocaleString('en-US')} tokens (estimate)${appOnlyNote(view.appOnly)}`,
|
|
75
|
+
`toolmenu snapshot ${plain(s.name ?? 'unknown server')} ${plain(s.version ?? '')}`.trimEnd(),
|
|
76
|
+
` protocol ${plain(s.protocolVersion ?? 'unknown')} · ${plural(menu.tools.length, 'tool')} · ~${menu.totalTokens.toLocaleString('en-US')} tokens (estimate)${appOnlyNote(view.appOnly)}`,
|
|
76
77
|
];
|
|
77
78
|
if (cost)
|
|
78
79
|
lines.push(` ${costLine(cost)}`, ` ${cost.basis}`);
|
|
@@ -98,11 +99,11 @@ export function findingLines(findings) {
|
|
|
98
99
|
const lines = [];
|
|
99
100
|
for (const f of findings) {
|
|
100
101
|
lines.push(`${LABEL[f.severity]} ${f.rule}${unsureMark(f)}`);
|
|
101
|
-
lines.push(` ${f.message}`);
|
|
102
|
+
lines.push(` ${plain(f.message)}`);
|
|
102
103
|
for (const d of f.detail ?? [])
|
|
103
|
-
lines.push(` ${d}`);
|
|
104
|
+
lines.push(` ${plain(d)}`);
|
|
104
105
|
if (f.fix)
|
|
105
|
-
lines.push(` → Next: ${f.fix}`);
|
|
106
|
+
lines.push(` → Next: ${plain(f.fix)}`);
|
|
106
107
|
}
|
|
107
108
|
lines.push(findings.length ? '' : 'No findings.');
|
|
108
109
|
return lines;
|
|
@@ -116,11 +117,12 @@ function summaryLine(findings) {
|
|
|
116
117
|
export function githubLines(findings) {
|
|
117
118
|
return findings.map((f) => {
|
|
118
119
|
const level = f.severity === 'error' ? 'error' : f.severity === 'warn' ? 'warning' : 'notice';
|
|
119
|
-
|
|
120
|
+
// plain(): a newline in the server's text is shown, not a line of the annotation.
|
|
121
|
+
const body = [f.message, ...(f.detail ?? []), ...(f.fix ? [`→ Next: ${f.fix}`] : [])].map(plain).join('\n').replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
120
122
|
return `::${level} title=toolmenu ${f.rule}${unsureMark(f)}::${body}`;
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
|
-
function signed(n) {
|
|
125
|
+
export function signed(n) {
|
|
124
126
|
return `${n > 0 ? '+' : n < 0 ? '−' : '±'}${Math.abs(n).toLocaleString('en-US')}`;
|
|
125
127
|
}
|
|
126
128
|
function tokenSentence(d) {
|
|
@@ -132,7 +134,7 @@ function tokenSentence(d) {
|
|
|
132
134
|
return 'no change in menu size';
|
|
133
135
|
}
|
|
134
136
|
/** "3 breaking (25 tools) · 2 minor (2 tools) · 11 notice (10 tools)": changes, and the tools they touch. */
|
|
135
|
-
function classLine(d) {
|
|
137
|
+
export function classLine(d) {
|
|
136
138
|
const part = (c) => {
|
|
137
139
|
const { changes, tools } = d.classes[c];
|
|
138
140
|
return `${changes} ${c}${changes && tools ? ` (${plural(tools, 'tool')})` : ''}`;
|
|
@@ -143,22 +145,25 @@ function classLine(d) {
|
|
|
143
145
|
* The version verdict: the bump these changes suggest, then whether the release's
|
|
144
146
|
* bump is enough (and what to release instead), or why it wasn't checked.
|
|
145
147
|
*/
|
|
146
|
-
function bumpVerdict(d, md = false) {
|
|
148
|
+
export function bumpVerdict(d, md = false) {
|
|
147
149
|
const b = (s) => (md ? `**${s}**` : s);
|
|
150
|
+
/** A version, as given: from --release or the server. */
|
|
151
|
+
const v = (s) => (md ? mdText(s) : plain(s));
|
|
148
152
|
const suggested = `suggested bump: ${b(d.suggestedBump)}`;
|
|
149
153
|
if (!d.actualBump || !d.release)
|
|
150
154
|
return { line: `${suggested} · not checked (${d.bumpNotChecked ?? 'pass --release old..new'})`, short: false };
|
|
151
|
-
const pair = `${d.release.before} → ${d.release.after} is a ${d.actualBump} bump`;
|
|
155
|
+
const pair = `${v(d.release.before)} → ${v(d.release.after)} is a ${d.actualBump} bump`;
|
|
152
156
|
const required = d.requiredBump ?? d.suggestedBump;
|
|
153
157
|
const below1 = required !== d.suggestedBump ? ` (under 1.0.0 ${required === 'none' ? 'anything goes' : `a ${required} is enough`})` : '';
|
|
154
158
|
const rank = { none: 0, patch: 1, minor: 2, major: 3 };
|
|
155
159
|
if (rank[d.actualBump] >= rank[required])
|
|
156
160
|
return { line: `${suggested} · ${pair}: enough${below1}`, short: false };
|
|
157
|
-
return { line: `${suggested} · ${pair}: ${b(`too small, release ${d.releaseAs
|
|
161
|
+
return { line: `${suggested} · ${pair}: ${b(`too small, release ${d.releaseAs ? v(d.releaseAs) : `a ${required}`}`)}${below1}`, short: true };
|
|
158
162
|
}
|
|
159
|
-
function releasePair(d) {
|
|
163
|
+
export function releasePair(d, md = false) {
|
|
164
|
+
const v = (s) => (md ? mdText(s) : plain(s));
|
|
160
165
|
// Name the release versions when there are some; otherwise say whose version this is.
|
|
161
|
-
return d.release?.source === 'release' ? `${d.release.before} → ${d.release.after}` : `${d.before.version ?? '?'} → ${d.after.version ?? '?'} (server-reported)`;
|
|
166
|
+
return d.release?.source === 'release' ? `${v(d.release.before)} → ${v(d.release.after)}` : `${v(d.before.version ?? '?')} → ${v(d.after.version ?? '?')} (server-reported)`;
|
|
162
167
|
}
|
|
163
168
|
export function formatDiff(d, beforeTools, afterTools, format) {
|
|
164
169
|
if (format === 'json') {
|
|
@@ -169,12 +174,12 @@ export function formatDiff(d, beforeTools, afterTools, format) {
|
|
|
169
174
|
const verdict = bumpVerdict(d);
|
|
170
175
|
const tokenLine = `~${d.tokens.before.toLocaleString('en-US')} → ~${d.tokens.after.toLocaleString('en-US')} (${signed(d.tokens.delta)}, estimate): ${tokenSentence(d)}`;
|
|
171
176
|
if (format === 'github') {
|
|
172
|
-
return [...githubLines(d.findings), `::notice title=toolmenu diff::${name} ${pair}. Changes: ${classLine(d)}. Tokens: ${tokenLine}. Version: ${verdict.line}.`].join('\n');
|
|
177
|
+
return [...githubLines(d.findings), `::notice title=toolmenu diff::${ghEscape(`${name} ${pair}. Changes: ${classLine(d)}. Tokens: ${tokenLine}. Version: ${verdict.line}.`)}`].join('\n');
|
|
173
178
|
}
|
|
174
179
|
if (format === 'markdown')
|
|
175
180
|
return mdDiff(d, beforeTools, afterTools);
|
|
176
181
|
const lines = [
|
|
177
|
-
`toolmenu diff ${name} ${pair}`,
|
|
182
|
+
`toolmenu diff ${plain(name)} ${pair}`,
|
|
178
183
|
` changes ${classLine(d)}`,
|
|
179
184
|
` version ${verdict.line}`,
|
|
180
185
|
` tokens ${tokenLine}`,
|
|
@@ -185,7 +190,7 @@ export function formatDiff(d, beforeTools, afterTools, format) {
|
|
|
185
190
|
if (d.tokens.tools.length) {
|
|
186
191
|
lines.push('Token change by tool (estimate):');
|
|
187
192
|
for (const t of d.tokens.tools.slice(0, 10))
|
|
188
|
-
lines.push(` ${signed(t.delta).padStart(7)} ${t.name}`);
|
|
193
|
+
lines.push(` ${signed(t.delta).padStart(7)} ${plain(t.name)}`);
|
|
189
194
|
if (d.tokens.tools.length > 10)
|
|
190
195
|
lines.push(` …and ${d.tokens.tools.length - 10} more`);
|
|
191
196
|
lines.push('');
|
|
@@ -205,7 +210,7 @@ function mdDiff(d, beforeTools, afterTools) {
|
|
|
205
210
|
`**${signed(d.tokens.delta)} tokens** (~${d.tokens.before.toLocaleString('en-US')} → ~${d.tokens.after.toLocaleString('en-US')}, estimate)`,
|
|
206
211
|
`${beforeTools} → ${afterTools} tools`,
|
|
207
212
|
].join(' · ');
|
|
208
|
-
const lines = [`### toolmenu diff:
|
|
213
|
+
const lines = [`### toolmenu diff: ${mdCode(name)} ${releasePair(d, true)}`, '', headline, '', `> **Version:** ${verdict.line}`, ''];
|
|
209
214
|
if (d.tokens.delta !== 0)
|
|
210
215
|
lines.splice(lines.length - 1, 0, '>', `> **Tokens:** ${tokenSentence(d)}.`);
|
|
211
216
|
const table = (findings) => ['| | Rule | Change |', '|---|---|---|', ...findings.map(mdDiffRow)];
|
|
@@ -230,7 +235,7 @@ function mdDiff(d, beforeTools, afterTools) {
|
|
|
230
235
|
if (d.tokens.tools.length) {
|
|
231
236
|
lines.push('<details><summary>Token change by tool (estimate)</summary>', '', '| Tool | Before | After | Change |', '|---|---:|---:|---:|');
|
|
232
237
|
for (const t of d.tokens.tools.slice(0, 30))
|
|
233
|
-
lines.push(`|
|
|
238
|
+
lines.push(`| ${mdCode(t.name, { cell: true })} | ${t.before.toLocaleString('en-US')} | ${t.after.toLocaleString('en-US')} | ${signed(t.delta)} |`);
|
|
234
239
|
if (d.tokens.tools.length > 30)
|
|
235
240
|
lines.push(`| …and ${d.tokens.tools.length - 30} more | | | |`);
|
|
236
241
|
lines.push('', '</details>', '');
|
|
@@ -244,7 +249,7 @@ function mdDiffRow(f) {
|
|
|
244
249
|
const list = /^(tools|operations|moved): (.*)$/.exec(line);
|
|
245
250
|
if (list)
|
|
246
251
|
return `<details><summary>all ${list[2].split(', ').length} ${list[1] === 'moved' ? 'moved tools' : list[1]}</summary>${mdCell(list[2])}</details>`;
|
|
247
|
-
return `<br><sub>${mdCell(line)
|
|
252
|
+
return `<br><sub>${mdCell(line)}</sub>`;
|
|
248
253
|
});
|
|
249
254
|
const sev = f.severity === 'error' ? '**error**' : f.severity;
|
|
250
255
|
return `| ${sev} | \`${f.rule}\`${f.confidence === 'unsure' ? ' · _unsure_' : ''} | ${mdCell(f.message)}${detail.join('')}${f.fix ? `<br>**→ Next:** ${mdCell(f.fix)}` : ''} |`;
|
|
@@ -291,7 +296,7 @@ export function formatHistory(h, format, outDir, csvPath) {
|
|
|
291
296
|
: [r.version, r.published?.slice(0, 10) ?? '', r.protocolVersion ?? '?', String(r.tools ?? ''), `~${(r.tokens ?? 0).toLocaleString('en-US')}`, sdkOf(r), zodOf(r), findingsOf(r), versus(r)];
|
|
292
297
|
if (format === 'markdown') {
|
|
293
298
|
const lines = [
|
|
294
|
-
`### toolmenu history:
|
|
299
|
+
`### toolmenu history: ${mdCode(h.package)}`,
|
|
295
300
|
'',
|
|
296
301
|
`${scope.charAt(0).toUpperCase()}${scope.slice(1)}.`,
|
|
297
302
|
'',
|
|
@@ -303,23 +308,23 @@ export function formatHistory(h, format, outDir, csvPath) {
|
|
|
303
308
|
lines.push('', '**Breaking changes**', '');
|
|
304
309
|
for (const r of breaking) {
|
|
305
310
|
for (const m of r.diff.breakingChanges.slice(0, BREAKING_SHOWN))
|
|
306
|
-
lines.push(`-
|
|
311
|
+
lines.push(`- ${mdCode(r.version)} (vs ${mdText(r.diff.from)}): ${mdCell(m)}`);
|
|
307
312
|
if (r.diff.breakingChanges.length > BREAKING_SHOWN)
|
|
308
|
-
lines.push(`-
|
|
313
|
+
lines.push(`- ${mdCode(r.version)}: …and ${r.diff.breakingChanges.length - BREAKING_SHOWN} more (all in history.json)`);
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
316
|
if (failed.length) {
|
|
312
317
|
lines.push('', `**Failed** (${failed.length} of ${h.rows.length})`, '');
|
|
313
318
|
for (const g of failureGroups(failed, failure))
|
|
314
|
-
lines.push(`-
|
|
319
|
+
lines.push(`- ${mdCode(g.versions)} · ${g.row.reason}${g.row.confidence === 'unsure' ? ' · _unsure_' : ''}: ${mdCell(g.message)}${g.fix ? `<br>**→ Next:** ${mdCell(g.fix)}` : ''}`);
|
|
315
320
|
}
|
|
316
321
|
lines.push('', `**${summary}**`, '', `<sub>${saved.charAt(0).toUpperCase()}${saved.slice(1)}.</sub>`);
|
|
317
322
|
return lines.join('\n');
|
|
318
323
|
}
|
|
319
|
-
const table = [head, ...h.rows.map(cells)];
|
|
324
|
+
const table = [head, ...h.rows.map((r) => cells(r).map(plain))];
|
|
320
325
|
const widths = table[0].map((_, c) => Math.max(...table.map((row) => row[c].length)));
|
|
321
326
|
const lines = [
|
|
322
|
-
`toolmenu history ${h.package}`,
|
|
327
|
+
`toolmenu history ${plain(h.package)}`,
|
|
323
328
|
` ${scope}`,
|
|
324
329
|
'',
|
|
325
330
|
...table.map((row) => ' ' + row.map((cell, c) => cell.padEnd(widths[c])).join(' ').trimEnd()),
|
|
@@ -329,19 +334,19 @@ export function formatHistory(h, format, outDir, csvPath) {
|
|
|
329
334
|
lines.push('Breaking changes:');
|
|
330
335
|
for (const r of breaking) {
|
|
331
336
|
for (const m of r.diff.breakingChanges.slice(0, BREAKING_SHOWN))
|
|
332
|
-
lines.push(` ${r.version} (vs ${r.diff.from}): ${m}`);
|
|
337
|
+
lines.push(` ${plain(r.version)} (vs ${plain(r.diff.from)}): ${plain(m)}`);
|
|
333
338
|
if (r.diff.breakingChanges.length > BREAKING_SHOWN)
|
|
334
|
-
lines.push(` ${r.version}: …and ${r.diff.breakingChanges.length - BREAKING_SHOWN} more (all in history.json)`);
|
|
339
|
+
lines.push(` ${plain(r.version)}: …and ${r.diff.breakingChanges.length - BREAKING_SHOWN} more (all in history.json)`);
|
|
335
340
|
}
|
|
336
341
|
lines.push('');
|
|
337
342
|
}
|
|
338
343
|
if (failed.length) {
|
|
339
344
|
lines.push(`Failed (${failed.length} of ${h.rows.length}):`);
|
|
340
345
|
for (const g of failureGroups(failed, failure)) {
|
|
341
|
-
lines.push(` ${g.versions} ${g.row.reason}${g.row.confidence === 'unsure' ? ' · unsure' : ''}`);
|
|
342
|
-
lines.push(` ${g.message}`);
|
|
346
|
+
lines.push(` ${plain(g.versions)} ${g.row.reason}${g.row.confidence === 'unsure' ? ' · unsure' : ''}`);
|
|
347
|
+
lines.push(` ${plain(g.message)}`);
|
|
343
348
|
if (g.fix)
|
|
344
|
-
lines.push(` → Next: ${g.fix}`);
|
|
349
|
+
lines.push(` → Next: ${plain(g.fix)}`);
|
|
345
350
|
}
|
|
346
351
|
lines.push('');
|
|
347
352
|
}
|
|
@@ -374,7 +379,7 @@ function failureGroups(failed, failure) {
|
|
|
374
379
|
});
|
|
375
380
|
}
|
|
376
381
|
function ghEscape(text) {
|
|
377
|
-
return text.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
382
|
+
return plain(text).replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
378
383
|
}
|
|
379
384
|
export function formatSession(s, format) {
|
|
380
385
|
if (format === 'json') {
|
|
@@ -387,17 +392,17 @@ export function formatSession(s, format) {
|
|
|
387
392
|
}
|
|
388
393
|
if (format === 'markdown') {
|
|
389
394
|
const lines = [
|
|
390
|
-
`### toolmenu session:
|
|
395
|
+
`### toolmenu session: ${mdCode(s.scenario)}`,
|
|
391
396
|
'',
|
|
392
|
-
|
|
397
|
+
`${mdCode(s.server.name ?? 'server')} ${mdText(s.server.version ?? '')} · protocol ${mdText(s.server.protocolVersion ?? '?')} · ${s.transport} · ${s.baseline.tools} → ${s.final.tools} tools · ~${s.baseline.tokens.toLocaleString('en-US')} → ~${s.final.tokens.toLocaleString('en-US')} tokens (estimate)`,
|
|
393
398
|
'',
|
|
394
|
-
...(s.auto ? [...autoSummary(s.auto).map((l, i) => (i === 0 ?
|
|
399
|
+
...(s.auto ? [...autoSummary(s.auto).map((l, i) => (i === 0 ? `**auto:** ${mdText(l.replace(/^auto: /, ''))}` : `- ${mdText(l.trim())}`)), ''] : []),
|
|
395
400
|
...(callCounts(s) ? [`**Calls:** ${callCounts(s)}`, ''] : []),
|
|
396
401
|
...(menuChange(s) ? [`**Menu:** ${menuChange(s)}`, ''] : []),
|
|
397
402
|
...causes(s.findings, (count, f, where, text) => count ? `**${count}:**` : `- ${f.severity === 'error' ? '**ERROR**' : LABEL[f.severity].trim()} \`${f.rule}\` · ${where} · ${mdCell(text)}`),
|
|
398
403
|
'| Step | Menu | list_changed | Scope |',
|
|
399
404
|
'|---|---|---|---|',
|
|
400
|
-
...s.steps.map((st) => `| ${st.index}. ${mdCell(st.label)} | ${st.status !== 'ok' ? st.status : st.changed ? `changed (${st.tools} tools)` : 'no change'} | ${st.changed ? (st.listChanged ? 'received' : '**missing**') : ''} | ${st.scope ?? ''} |`),
|
|
405
|
+
...s.steps.map((st) => `| ${st.index}. ${mdCell(st.label)} | ${st.status !== 'ok' ? st.status : st.changed ? `changed (${st.tools} tools)` : 'no change'} | ${st.changed ? (st.listChanged ? 'received' : '**missing**') : ''} | ${mdCell(st.scope ?? '')} |`),
|
|
401
406
|
'',
|
|
402
407
|
...mdFindings(s.findings.map((f) => ({ ...f, message: stepPrefix(f, `Step ${f.step}: `) }))),
|
|
403
408
|
];
|
|
@@ -405,26 +410,26 @@ export function formatSession(s, format) {
|
|
|
405
410
|
}
|
|
406
411
|
const tok = (n) => `~${n.toLocaleString('en-US')}`;
|
|
407
412
|
const lines = [
|
|
408
|
-
`toolmenu session ${s.scenario}`,
|
|
409
|
-
` ${s.server.name ?? 'server'} ${s.server.version ?? ''} · protocol ${s.server.protocolVersion ?? '?'} · ${s.transport}`,
|
|
413
|
+
`toolmenu session ${plain(s.scenario)}`,
|
|
414
|
+
` ${plain(s.server.name ?? 'server')} ${plain(s.server.version ?? '')} · protocol ${plain(s.server.protocolVersion ?? '?')} · ${s.transport}`,
|
|
410
415
|
` baseline: ${plural(s.baseline.tools, 'tool')} · ${tok(s.baseline.tokens)} tokens (estimate) · listening for list_changed: ${s.listening ? 'yes' : 'no'}`,
|
|
411
|
-
...(s.auto ? autoSummary(s.auto).map((l, i) => (i === 0 ? ` ${l}` : ` ${l}`)) : []),
|
|
416
|
+
...(s.auto ? autoSummary(s.auto).map((l, i) => (i === 0 ? ` ${plain(l)}` : ` ${plain(l)}`)) : []),
|
|
412
417
|
...(callCounts(s) ? [` calls: ${callCounts(s)}`] : []),
|
|
413
418
|
// Before the first step only: what a fresh one sees after a change is each step's scope.
|
|
414
419
|
` fresh-${s.transport === 'stdio' ? 'process' : 'connection'} check of the starting menu: ${s.connectionCheck === undefined ? 'not checked' : s.connectionCheck === 'same' ? 'the same' : 'DIFFERENT'}`,
|
|
415
420
|
'',
|
|
416
421
|
...(menuChange(s) ? [`menu: ${menuChange(s)}`] : []),
|
|
417
|
-
...causes(s.findings, (count, f, where, text) => (count ? `${count}:` : ` ${LABEL[f.severity]} ${f.rule} · ${where} · ${text}`)),
|
|
422
|
+
...causes(s.findings, (count, f, where, text) => (count ? `${count}:` : ` ${LABEL[f.severity]} ${f.rule} · ${where} · ${plain(text)}`)),
|
|
418
423
|
];
|
|
419
424
|
const at = (step) => s.findings.filter((f) => f.step === step);
|
|
420
425
|
const block = (findings) => {
|
|
421
426
|
for (const f of findings) {
|
|
422
427
|
lines.push(` ${LABEL[f.severity]} ${f.rule}${unsureMark(f)}`);
|
|
423
|
-
lines.push(` ${f.message}`);
|
|
428
|
+
lines.push(` ${plain(f.message)}`);
|
|
424
429
|
for (const d of f.detail ?? [])
|
|
425
|
-
lines.push(` ${d}`);
|
|
430
|
+
lines.push(` ${plain(d)}`);
|
|
426
431
|
if (f.fix)
|
|
427
|
-
lines.push(` → Next: ${f.fix}`);
|
|
432
|
+
lines.push(` → Next: ${plain(f.fix)}`);
|
|
428
433
|
}
|
|
429
434
|
};
|
|
430
435
|
block(at(0));
|
|
@@ -441,9 +446,9 @@ export function formatSession(s, format) {
|
|
|
441
446
|
step.changed ? `menu changed${delta ? ` · ${delta > 0 ? '+' : '−'}${plural(Math.abs(delta), 'tool')}` : ''}` : step.status === 'ok' ? 'no change' : '',
|
|
442
447
|
step.changed ? (step.listChanged ? 'list_changed received' : 'no list_changed') : '',
|
|
443
448
|
step.scope ? `scope: ${step.scope}` : '',
|
|
444
|
-
step.note ?? '',
|
|
449
|
+
plain(step.note ?? ''),
|
|
445
450
|
].filter(Boolean);
|
|
446
|
-
lines.push(`step ${step.index}: ${step.label} · ${facts.join(' · ')}`);
|
|
451
|
+
lines.push(`step ${step.index}: ${plain(step.label)} · ${facts.join(' · ')}`);
|
|
447
452
|
block(at(step.index));
|
|
448
453
|
}
|
|
449
454
|
// Findings about the whole run (session/untested), after the steps.
|
|
@@ -524,7 +529,7 @@ function callCounts(s) {
|
|
|
524
529
|
}
|
|
525
530
|
export function formatPlan(scenario, name) {
|
|
526
531
|
const lines = [`toolmenu session --plan ${name}`, ` allow_writes: ${scenario.allowWrites}${scenario.allowWrites ? '' : ' (tools not marked readOnlyHint will be refused)'}`, ''];
|
|
527
|
-
scenario.steps.forEach((step, i) => lines.push(`step ${i + 1}: ${stepLabel(step)}${step.kind === 'wait_for' ? ` (up to ${step.timeoutMs} ms)` : ''}`));
|
|
532
|
+
scenario.steps.forEach((step, i) => lines.push(`step ${i + 1}: ${plain(stepLabel(step))}${step.kind === 'wait_for' ? ` (up to ${step.timeoutMs} ms)` : ''}`));
|
|
528
533
|
lines.push('', 'After every step the menu is listed and compared with the one before. Nothing was run.');
|
|
529
534
|
return lines.join('\n');
|
|
530
535
|
}
|
|
@@ -538,8 +543,9 @@ function stepPrefix(f, prefix) {
|
|
|
538
543
|
return f.message;
|
|
539
544
|
return prefix + f.message;
|
|
540
545
|
}
|
|
546
|
+
/** Text in a table cell: escaped (sanitize.ts), so a server's words stay words. */
|
|
541
547
|
function mdCell(text) {
|
|
542
|
-
return text
|
|
548
|
+
return mdText(text, { cell: true });
|
|
543
549
|
}
|
|
544
550
|
export function mdFindings(findings) {
|
|
545
551
|
if (findings.length === 0)
|
package/dist/review.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type DiffOptions, type DiffResult } from './diff.js';
|
|
2
|
+
import { type RuleSettings } from './rules/index.js';
|
|
3
|
+
import { type Finding, type Menu, type Severity } from './types.js';
|
|
4
|
+
import { type Format } from './report.js';
|
|
5
|
+
/**
|
|
6
|
+
* - `unchanged`: the same menu, the same findings.
|
|
7
|
+
* - `safe`: nothing breaks callers and no finding at or above --fail-on is new.
|
|
8
|
+
* - `breaking-released`: breaking changes, and the release versions given allow them.
|
|
9
|
+
* - `breaking`: breaking changes, and no release that allows them (none given, too small, or not checkable).
|
|
10
|
+
* - `review`: nothing breaks, but the new menu has findings at or above --fail-on the old one didn't,
|
|
11
|
+
* or diff's own checks (token budget, version bump) fail.
|
|
12
|
+
*/
|
|
13
|
+
export type Verdict = 'unchanged' | 'safe' | 'breaking-released' | 'breaking' | 'review';
|
|
14
|
+
export interface ReviewResult {
|
|
15
|
+
verdict: Verdict;
|
|
16
|
+
/** Whether the new baseline can be accepted as it is: the exit code is 0 when true. */
|
|
17
|
+
accept: boolean;
|
|
18
|
+
diff: DiffResult;
|
|
19
|
+
findings: {
|
|
20
|
+
/** In the new menu only. */
|
|
21
|
+
introduced: Finding[];
|
|
22
|
+
/** In the old menu only. */
|
|
23
|
+
resolved: Finding[];
|
|
24
|
+
/**
|
|
25
|
+
* In both, for the same rule, but saying something else: a summary that now lists
|
|
26
|
+
* more tools, one tool's finding that became a summary. `worse`: louder, or now
|
|
27
|
+
* naming a tool the old one didn't; counted with the new findings for the verdict.
|
|
28
|
+
*/
|
|
29
|
+
changed: {
|
|
30
|
+
before: Finding;
|
|
31
|
+
after: Finding;
|
|
32
|
+
worse: boolean;
|
|
33
|
+
}[];
|
|
34
|
+
/** In both, unchanged. */
|
|
35
|
+
kept: number;
|
|
36
|
+
};
|
|
37
|
+
tools: {
|
|
38
|
+
before: number;
|
|
39
|
+
after: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface ReviewOptions extends DiffOptions, RuleSettings {
|
|
43
|
+
failOn?: Severity;
|
|
44
|
+
}
|
|
45
|
+
/** The menu rules on a menu file, as far as a file can tell: no second list, no probes. */
|
|
46
|
+
export declare function fileFindings(menu: Menu, settings?: RuleSettings): Finding[];
|
|
47
|
+
export declare function reviewMenus(before: Menu, after: Menu, options?: ReviewOptions): ReviewResult;
|
|
48
|
+
export declare function formatReview(r: ReviewResult, paths: [string, string], format: Format, failOn?: Severity): string;
|
package/dist/review.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* toolmenu review: should this new menu file replace the committed baseline?
|
|
3
|
+
*
|
|
4
|
+
* `diff` says what changed between two menus. Accepting a new baseline is a further
|
|
5
|
+
* question: did the menu get worse for agents (findings it didn't have), better
|
|
6
|
+
* (findings gone), or break callers without a release that allows it? `review`
|
|
7
|
+
* answers that from the two files alone, with one verdict and an exit code to match.
|
|
8
|
+
*/
|
|
9
|
+
import { diffMenus } from './diff.js';
|
|
10
|
+
import { MENU_RULES, runRules } from './rules/index.js';
|
|
11
|
+
import { SEVERITY_RANK } from './types.js';
|
|
12
|
+
import { bumpVerdict, classLine, counts, findingLines, mdFindings, releasePair, signed } from './report.js';
|
|
13
|
+
import { mdCode, mdText, plain } from './sanitize.js';
|
|
14
|
+
// Rules that read the wire (the raw tools/list pages, the handshake), which a menu
|
|
15
|
+
// file doesn't hold: run on a file they'd say the same about both menus, or nothing true.
|
|
16
|
+
const WIRE_ONLY = new Set(['spec/schema', 'spec/discover']);
|
|
17
|
+
// diff findings that say what it couldn't compare, not what changed.
|
|
18
|
+
const NOT_COMPARED = new Set(['diff/lists-unread', 'diff/catalog-queries']);
|
|
19
|
+
/** The menu rules on a menu file, as far as a file can tell: no second list, no probes. */
|
|
20
|
+
export function fileFindings(menu, settings = {}) {
|
|
21
|
+
return runRules(MENU_RULES, { menu, pages: [], capabilities: { tools: {} }, usedAuth: false, protocolVersion: menu.server.protocolVersion, era: menu.server.era }, settings).filter((f) => !WIRE_ONLY.has(f.rule));
|
|
22
|
+
}
|
|
23
|
+
/** A finding's identity across two menus: its rule, and the tool or tools it's about. */
|
|
24
|
+
function key(f) {
|
|
25
|
+
const tools = f.tools;
|
|
26
|
+
return `${f.rule}\0${f.tool ?? (tools ? tools.join(',') : '')}`;
|
|
27
|
+
}
|
|
28
|
+
const said = (f) => JSON.stringify([f.severity, f.message, f.detail ?? []]);
|
|
29
|
+
export function reviewMenus(before, after, options = {}) {
|
|
30
|
+
const failOn = options.failOn ?? 'error';
|
|
31
|
+
const atLeast = (f) => SEVERITY_RANK[f.severity] >= SEVERITY_RANK[failOn];
|
|
32
|
+
const diff = diffMenus(before, after, options);
|
|
33
|
+
const settings = { rules: options.rules, ignore: options.ignore };
|
|
34
|
+
const old = fileFindings(before, settings);
|
|
35
|
+
const now = fileFindings(after, settings);
|
|
36
|
+
// Matched by rule and tool first; what's left of a rule on both sides is the same
|
|
37
|
+
// finding said differently (one tool's finding became a summary of two).
|
|
38
|
+
const oldBy = new Map();
|
|
39
|
+
for (const f of old)
|
|
40
|
+
oldBy.set(key(f), [...(oldBy.get(key(f)) ?? []), f]);
|
|
41
|
+
const unmatched = [];
|
|
42
|
+
const changed = [];
|
|
43
|
+
let kept = 0;
|
|
44
|
+
for (const f of now) {
|
|
45
|
+
const match = oldBy.get(key(f))?.shift();
|
|
46
|
+
if (!match)
|
|
47
|
+
unmatched.push(f);
|
|
48
|
+
else if (said(match) === said(f))
|
|
49
|
+
kept++;
|
|
50
|
+
else
|
|
51
|
+
changed.push({ before: match, after: f, worse: false });
|
|
52
|
+
}
|
|
53
|
+
const left = [...oldBy.values()].flat();
|
|
54
|
+
const introduced = [];
|
|
55
|
+
for (const f of unmatched) {
|
|
56
|
+
const i = left.findIndex((o) => o.rule === f.rule);
|
|
57
|
+
if (i === -1)
|
|
58
|
+
introduced.push(f);
|
|
59
|
+
else
|
|
60
|
+
changed.push({ before: left.splice(i, 1)[0], after: f, worse: false });
|
|
61
|
+
}
|
|
62
|
+
const resolved = left;
|
|
63
|
+
// A changed finding is worse when it's louder, or now names a tool the old one didn't.
|
|
64
|
+
const names = after.tools.map((t) => t.name);
|
|
65
|
+
const text = (f) => [f.message, ...(f.detail ?? []), f.tool ?? '', ...(f.tools ?? [])].join('\n');
|
|
66
|
+
const mentions = (f) => new Set(names.filter((n) => new RegExp(`(?<![\\w-])${n.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w-])`).test(text(f))));
|
|
67
|
+
const grew = (c) => {
|
|
68
|
+
if (SEVERITY_RANK[c.after.severity] > SEVERITY_RANK[c.before.severity])
|
|
69
|
+
return true;
|
|
70
|
+
const had = mentions(c.before);
|
|
71
|
+
return [...mentions(c.after)].some((n) => !had.has(n));
|
|
72
|
+
};
|
|
73
|
+
const breaking = diff.findings.filter((f) => f.class === 'breaking' && atLeast(f));
|
|
74
|
+
// The release allows the breaking changes when its bump was checked and is big enough.
|
|
75
|
+
const released = diff.actualBump !== undefined && diff.releaseAs === undefined && !diff.bumpNotChecked;
|
|
76
|
+
// diff's own checks that aren't changes to the menu: the token budget, the version bump.
|
|
77
|
+
const checks = diff.findings.filter((f) => f.class === undefined && atLeast(f));
|
|
78
|
+
for (const c of changed)
|
|
79
|
+
c.worse = grew(c);
|
|
80
|
+
const worse = [...introduced, ...changed.filter((c) => c.worse).map((c) => c.after)].filter(atLeast);
|
|
81
|
+
let verdict;
|
|
82
|
+
if (breaking.length)
|
|
83
|
+
verdict = released ? 'breaking-released' : 'breaking';
|
|
84
|
+
else if (worse.length || checks.length)
|
|
85
|
+
verdict = 'review';
|
|
86
|
+
// Notes that something wasn't compared (lists read on one side only) aren't changes.
|
|
87
|
+
else if (!diff.findings.some((f) => !NOT_COMPARED.has(f.rule)) && !introduced.length && !resolved.length && !changed.length && diff.tokens.delta === 0)
|
|
88
|
+
verdict = 'unchanged';
|
|
89
|
+
else
|
|
90
|
+
verdict = 'safe';
|
|
91
|
+
// A released breaking change still needs the rest to be clean.
|
|
92
|
+
const accept = verdict === 'unchanged' || verdict === 'safe' || (verdict === 'breaking-released' && !worse.length && !checks.length);
|
|
93
|
+
return { verdict, accept, diff, findings: { introduced, resolved, changed, kept }, tools: { before: before.tools.length, after: after.tools.length } };
|
|
94
|
+
}
|
|
95
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
96
|
+
function verdictLine(r, failOn) {
|
|
97
|
+
const b = r.diff.classes.breaking.changes;
|
|
98
|
+
const worse = [...r.findings.introduced, ...r.findings.changed.filter((c) => c.worse).map((c) => c.after)].filter((f) => SEVERITY_RANK[f.severity] >= SEVERITY_RANK[failOn]).length;
|
|
99
|
+
switch (r.verdict) {
|
|
100
|
+
case 'unchanged':
|
|
101
|
+
return { mark: '✓', text: 'unchanged: the same menu and the same findings. Nothing to accept.' };
|
|
102
|
+
case 'safe':
|
|
103
|
+
return { mark: '✓', text: 'safe to accept: nothing breaks callers, and no new finding at or above ' + failOn + '.' };
|
|
104
|
+
case 'breaking-released':
|
|
105
|
+
return r.accept
|
|
106
|
+
? { mark: '✓', text: `accept with the release: ${plural(b, 'breaking change')}, and the release's ${r.diff.actualBump} bump allows ${b === 1 ? 'it' : 'them'}.` }
|
|
107
|
+
: { mark: '✗', text: `${plural(b, 'breaking change')} the release allows, but ${worse ? plural(worse, 'new finding') : "diff's own checks"} at or above ${failOn} too.` };
|
|
108
|
+
case 'breaking':
|
|
109
|
+
return {
|
|
110
|
+
mark: '✗',
|
|
111
|
+
text: `don't accept as is: ${plural(b, 'breaking change')}, and ${r.diff.releaseAs ? `the release's ${r.diff.actualBump} bump is too small (release ${r.diff.releaseAs})` : r.diff.bumpNotChecked ? `the bump wasn't checked (${r.diff.bumpNotChecked})` : 'no release versions to check them against (--release old..new)'}.`,
|
|
112
|
+
};
|
|
113
|
+
case 'review':
|
|
114
|
+
return { mark: '!', text: `review before accepting: nothing breaks callers, but ${worse ? `${plural(worse, 'finding')} at or above ${failOn} ${worse === 1 ? 'is' : 'are'} new` : "diff's own checks fail"}.` };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function nextStep(r, paths) {
|
|
118
|
+
const [base, next] = paths.map(plain);
|
|
119
|
+
switch (r.verdict) {
|
|
120
|
+
case 'unchanged':
|
|
121
|
+
return 'Nothing to do.';
|
|
122
|
+
case 'safe':
|
|
123
|
+
case 'breaking-released':
|
|
124
|
+
return r.accept ? `Commit ${next} as ${base}.` : 'Fix the new findings, or turn their rules down in toolmenu.config.json if they are expected, then review again.';
|
|
125
|
+
case 'breaking':
|
|
126
|
+
return r.diff.releaseAs ? `Release it as ${r.diff.releaseAs}, or keep the old shape for one more release. Then review again with --release.` : 'Keep the old shape for one more release, or pass the release versions (--release old..new) for a major release.';
|
|
127
|
+
case 'review':
|
|
128
|
+
return 'Fix the new findings, or turn their rules down in toolmenu.config.json if they are expected, then review again.';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function formatReview(r, paths, format, failOn = 'error') {
|
|
132
|
+
const f = r.findings;
|
|
133
|
+
if (format === 'json') {
|
|
134
|
+
const v = verdictLine(r, failOn);
|
|
135
|
+
return JSON.stringify({
|
|
136
|
+
command: 'review',
|
|
137
|
+
verdict: r.verdict,
|
|
138
|
+
accept: r.accept,
|
|
139
|
+
// The verdict and next step as the text report says them, for a PR comment or a log line.
|
|
140
|
+
summary: `${v.mark} ${v.text}`,
|
|
141
|
+
next: nextStep(r, paths),
|
|
142
|
+
baseline: paths[0],
|
|
143
|
+
candidate: paths[1],
|
|
144
|
+
tools: r.tools,
|
|
145
|
+
counts: { introduced: f.introduced.length, resolved: f.resolved.length, changed: f.changed.length, worse: f.changed.filter((c) => c.worse).length, kept: f.kept },
|
|
146
|
+
findings: f,
|
|
147
|
+
diff: { ...r.diff, counts: counts(r.diff.findings) },
|
|
148
|
+
}, null, 2);
|
|
149
|
+
}
|
|
150
|
+
const v = verdictLine(r, failOn);
|
|
151
|
+
const d = r.diff;
|
|
152
|
+
const breaking = d.findings.filter((x) => x.class === 'breaking');
|
|
153
|
+
const otherDiff = d.findings.filter((x) => x.class !== 'breaking');
|
|
154
|
+
const name = d.after.name ?? d.before.name ?? 'server';
|
|
155
|
+
const findingsLine = `${f.introduced.length} new · ${f.resolved.length} gone · ${f.changed.length} changed · ${f.kept} unchanged`;
|
|
156
|
+
const toolsLine = `${r.tools.before} → ${r.tools.after}`;
|
|
157
|
+
const tokens = `~${d.tokens.before.toLocaleString('en-US')} → ~${d.tokens.after.toLocaleString('en-US')} (${signed(d.tokens.delta)}, estimate)`;
|
|
158
|
+
if (format === 'markdown' || format === 'github') {
|
|
159
|
+
const lines = [
|
|
160
|
+
`### toolmenu review: ${mdCode(paths[1])} as the new ${mdCode(paths[0])}`,
|
|
161
|
+
'',
|
|
162
|
+
`**${v.mark} ${mdText(v.text)}**`,
|
|
163
|
+
'',
|
|
164
|
+
`| | |`,
|
|
165
|
+
`|---|---|`,
|
|
166
|
+
`| Server | ${mdCode(name, { cell: true })} ${releasePair(d, true)} |`,
|
|
167
|
+
`| Changes | ${classLine(d)} |`,
|
|
168
|
+
`| Version | ${bumpVerdict(d, true).line} |`,
|
|
169
|
+
`| Tokens | ${tokens} |`,
|
|
170
|
+
`| Tools | ${toolsLine} |`,
|
|
171
|
+
`| Findings | ${findingsLine} |`,
|
|
172
|
+
'',
|
|
173
|
+
];
|
|
174
|
+
if (breaking.length)
|
|
175
|
+
lines.push(`#### Breaking (${breaking.length})`, '', ...mdFindings(breaking), '');
|
|
176
|
+
if (f.introduced.length)
|
|
177
|
+
lines.push(`#### New findings (${f.introduced.length})`, '', ...mdFindings(f.introduced), '');
|
|
178
|
+
if (f.changed.length)
|
|
179
|
+
lines.push(`#### Changed findings (${f.changed.length})`, '', ...mdFindings(f.changed.map((c) => c.after)), '');
|
|
180
|
+
if (f.resolved.length)
|
|
181
|
+
lines.push(`<details><summary>Findings gone (${f.resolved.length})</summary>`, '', ...mdFindings(f.resolved), '', '</details>', '');
|
|
182
|
+
if (otherDiff.length)
|
|
183
|
+
lines.push(`<details><summary>Other changes (${otherDiff.length})</summary>`, '', ...mdFindings(otherDiff), '', '</details>', '');
|
|
184
|
+
lines.push(`**→ Next:** ${mdText(nextStep(r, paths))}`);
|
|
185
|
+
return lines.join('\n');
|
|
186
|
+
}
|
|
187
|
+
const lines = [
|
|
188
|
+
`toolmenu review ${plain(paths[1])} as the new ${plain(paths[0])}`,
|
|
189
|
+
` verdict ${v.mark} ${v.text}`,
|
|
190
|
+
` server ${plain(name)} ${releasePair(d)}`,
|
|
191
|
+
` changes ${classLine(d)}`,
|
|
192
|
+
` version ${bumpVerdict(d).line}`,
|
|
193
|
+
` tokens ${tokens}`,
|
|
194
|
+
` tools ${toolsLine}`,
|
|
195
|
+
` findings ${findingsLine}`,
|
|
196
|
+
'',
|
|
197
|
+
];
|
|
198
|
+
const section = (title, list) => {
|
|
199
|
+
if (list.length)
|
|
200
|
+
lines.push(`${title}:`, ...findingLines(list).map((l) => (l ? ` ${l}` : l)));
|
|
201
|
+
};
|
|
202
|
+
section('Breaking changes', breaking);
|
|
203
|
+
section('New findings', f.introduced);
|
|
204
|
+
section('Changed findings, as they are now (worse: louder or about more tools)', f.changed.filter((c) => c.worse).map((c) => c.after));
|
|
205
|
+
section('Changed findings, as they are now', f.changed.filter((c) => !c.worse).map((c) => c.after));
|
|
206
|
+
if (f.resolved.length)
|
|
207
|
+
lines.push('Findings gone:', ...f.resolved.map((x) => ` ${x.rule}${x.tool ? ` ${plain(x.tool)}` : ''}`), '');
|
|
208
|
+
if (otherDiff.length)
|
|
209
|
+
lines.push(`Other changes: ${plural(otherDiff.length, 'finding')} from diff (toolmenu diff ${plain(paths[0])} ${plain(paths[1])} lists them).`, '');
|
|
210
|
+
lines.push(`→ Next: ${nextStep(r, paths)}`);
|
|
211
|
+
return lines.join('\n');
|
|
212
|
+
}
|