@kurvball/rehearse 1.6.0 → 1.8.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/dist/commands/announce.js +3 -2
- package/dist/commands/compare.js +76 -4
- package/dist/commands/mcp.js +2 -1
- package/dist/commands/tools.d.ts +1 -1
- package/dist/commands/tools.js +1 -1
- package/dist/compare/gate.d.ts +33 -0
- package/dist/compare/gate.js +224 -0
- package/dist/compare/index.d.ts +1 -0
- package/dist/compare/index.js +1 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { RehearseError, usage } from '../errors.js';
|
|
|
7
7
|
import { locate, topOf } from '../git/index.js';
|
|
8
8
|
const FORMATS = ['yaml', 'changeset'];
|
|
9
9
|
export const NOT_COMPARED = 'not_compared';
|
|
10
|
+
const ONLY_FOR_A_GATE = ['gate', 'preview'];
|
|
10
11
|
const ONLY_WITH_A_DRAFT = {
|
|
11
12
|
bare: ['affected', 'fresh'],
|
|
12
13
|
valued: ['world', 'as', 'real', 'parallel'],
|
|
@@ -61,8 +62,8 @@ Without --draft it reads what rehearse compare would read: the announcement file
|
|
|
61
62
|
proposes one entry per scenario that changed without saying so, its why the first thing that changed: rewrite it.
|
|
62
63
|
--format changeset prints an announce block for a changeset instead of YAML. It writes no file.`,
|
|
63
64
|
spec: {
|
|
64
|
-
valued: [...compare.spec.valued, 'format'],
|
|
65
|
-
bare: [...compare.spec.bare, 'draft'],
|
|
65
|
+
valued: [...compare.spec.valued.filter((f) => !ONLY_FOR_A_GATE.includes(f)), 'format'],
|
|
66
|
+
bare: [...compare.spec.bare.filter((f) => !ONLY_FOR_A_GATE.includes(f)), 'draft'],
|
|
66
67
|
},
|
|
67
68
|
async run(args, ctx) {
|
|
68
69
|
const format = formatOf(args);
|
package/dist/commands/compare.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { announceFromOf, checkoutOf, manifestOf, parallelOf, said } from './command.js';
|
|
3
4
|
import { many, one } from '../args.js';
|
|
4
|
-
import { compare as compareSides } from '../compare/index.js';
|
|
5
|
+
import { compare as compareSides, gateAnswer, } from '../compare/index.js';
|
|
6
|
+
import { errorText, RehearseError, usage } from '../errors.js';
|
|
7
|
+
import { topOf } from '../git/index.js';
|
|
8
|
+
import { VERSION } from '../version.js';
|
|
5
9
|
const VERDICT_WORDS = {
|
|
6
10
|
fails: 'fails on the head',
|
|
7
11
|
new: 'new',
|
|
@@ -76,15 +80,83 @@ export function compareOptionsOf(args, ctx, repo) {
|
|
|
76
80
|
parallel,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
83
|
+
const PREVIEW_LIMIT = 2_000;
|
|
84
|
+
function linksOf(args, env) {
|
|
85
|
+
const preview = one(args, 'preview');
|
|
86
|
+
if (preview !== null && (!/^https?:\/\//.test(preview) || preview.length > PREVIEW_LIMIT))
|
|
87
|
+
throw usage(`--preview takes the preview's address, starting with http:// or https://, at most ${PREVIEW_LIMIT} characters, not “${preview.slice(0, 80)}”.`);
|
|
88
|
+
const run = env.GITHUB_SERVER_URL && env.GITHUB_REPOSITORY && env.GITHUB_RUN_ID
|
|
89
|
+
? `${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}`
|
|
90
|
+
: null;
|
|
91
|
+
return [
|
|
92
|
+
...(preview ? [{ title: 'Stage preview', url: preview, kind: 'preview' }] : []),
|
|
93
|
+
...(run ? [{ title: 'The CI run', url: run, kind: 'run' }] : []),
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
const real = (at) => {
|
|
97
|
+
try {
|
|
98
|
+
return realpathSync(at);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return path.resolve(at);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function fileInTheRepository(m, c) {
|
|
105
|
+
const head = real(c.head.checkout.path);
|
|
106
|
+
const manifest = real(m.dir);
|
|
107
|
+
const roots = { checkout: real(topOf(head) ?? head), manifest: real(topOf(manifest) ?? manifest) };
|
|
108
|
+
return (s) => {
|
|
109
|
+
const from = s.from === 'manifest' ? 'manifest' : 'checkout';
|
|
110
|
+
const file = path.relative(roots[from], real(path.resolve(from === 'manifest' ? manifest : head, s.file)));
|
|
111
|
+
return file === '' || file.startsWith('..') || path.isAbsolute(file)
|
|
112
|
+
? null
|
|
113
|
+
: file.split(path.sep).join('/');
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const cantCompare = (error) => error instanceof RehearseError
|
|
117
|
+
? new RehearseError(error.code, error.says, {
|
|
118
|
+
...(error.file !== undefined && { file: error.file }),
|
|
119
|
+
...(error.line !== undefined && { line: error.line }),
|
|
120
|
+
exit: 2,
|
|
121
|
+
})
|
|
122
|
+
: new RehearseError('crashed', errorText(error), { exit: 2 });
|
|
123
|
+
async function gated(args, ctx) {
|
|
124
|
+
try {
|
|
125
|
+
const links = linksOf(args, ctx.env);
|
|
126
|
+
const m = manifestOf(ctx);
|
|
127
|
+
const c = await compareSides(m, compareOptionsOf(args, ctx, checkoutOf(m, null, ctx.cwd)));
|
|
128
|
+
const answer = gateAnswer(c, { fileOf: fileInTheRepository(m, c), links, version: VERSION });
|
|
129
|
+
return said(answer, `${JSON.stringify(answer)}\n`, !c.base.ok ? 2 : answer.ok ? 0 : 1);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
throw cantCompare(error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
79
135
|
export const compare = {
|
|
80
136
|
name: 'compare',
|
|
81
137
|
summary: 'Runs scenarios on the base and on the head, compares them, and sorts each into a verdict.',
|
|
82
|
-
usage: "rehearse compare [<scenario>…] [--affected] [--base <ref|checkout>] [--head <ref|checkout>] [--announce <file>] [--announce-from changesets] [--said <scenario>]… [--world <name>] [--as <person>] [--real <stand-in>]… [--fresh] [--parallel <n>] [--json]\n\nThe base defaults to the manifest's base branch; the head to this checkout as it is now.\nScenario ids may be globs: 'apps/api/**'. It exits 0 when nothing fails on the head or changed without saying so.",
|
|
138
|
+
usage: "rehearse compare [<scenario>…] [--affected] [--base <ref|checkout>] [--head <ref|checkout>] [--announce <file>] [--announce-from changesets] [--said <scenario>]… [--world <name>] [--as <person>] [--real <stand-in>]… [--fresh] [--parallel <n>] [--gate [--preview <url>]] [--json]\n\nThe base defaults to the manifest's base branch; the head to this checkout as it is now.\nScenario ids may be globs: 'apps/api/**'. It exits 0 when nothing fails on the head or changed without saying so.\n--gate prints the gate answer instead, one JSON object a pull request report reads, with --preview as its stage preview link;\nit exits 0 when ok, 1 when not, and 2 when it can't compare, the base not coming up included.",
|
|
83
139
|
spec: {
|
|
84
|
-
valued: [
|
|
85
|
-
|
|
140
|
+
valued: [
|
|
141
|
+
'base',
|
|
142
|
+
'head',
|
|
143
|
+
'announce',
|
|
144
|
+
'announce-from',
|
|
145
|
+
'said',
|
|
146
|
+
'world',
|
|
147
|
+
'as',
|
|
148
|
+
'real',
|
|
149
|
+
'parallel',
|
|
150
|
+
'preview',
|
|
151
|
+
],
|
|
152
|
+
bare: ['affected', 'fresh', 'gate'],
|
|
86
153
|
},
|
|
87
154
|
async run(args, ctx) {
|
|
155
|
+
const gate = args.flags.has('gate');
|
|
156
|
+
if (!gate && one(args, 'preview') !== null)
|
|
157
|
+
throw usage('--preview needs --gate: only the gate answer links it.');
|
|
158
|
+
if (gate)
|
|
159
|
+
return gated(args, ctx);
|
|
88
160
|
const m = manifestOf(ctx);
|
|
89
161
|
const c = await compareSides(m, compareOptionsOf(args, ctx, checkoutOf(m, null, ctx.cwd)));
|
|
90
162
|
return said(c, comparisonText(c), c.ok ? 0 : 1);
|
package/dist/commands/mcp.js
CHANGED
|
@@ -12,12 +12,13 @@ export const TOOLS = [
|
|
|
12
12
|
toolOf(compare, {
|
|
13
13
|
output: 'comparison',
|
|
14
14
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
15
|
+
notArguments: ['gate', 'preview'],
|
|
15
16
|
}),
|
|
16
17
|
stepsToolOf(drive, { output: 'drive', annotations: { readOnlyHint: false, idempotentHint: false } }),
|
|
17
18
|
toolOf(announce, {
|
|
18
19
|
output: 'announce',
|
|
19
20
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
20
|
-
|
|
21
|
+
notArguments: ['format'],
|
|
21
22
|
}),
|
|
22
23
|
];
|
|
23
24
|
const inWords = (names) => names.length < 2 ? names.join('') : `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
package/dist/commands/tools.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const camelCase: (name: string) => string;
|
|
|
5
5
|
export interface ToolChoices {
|
|
6
6
|
output: SchemaName;
|
|
7
7
|
annotations: Annotations;
|
|
8
|
-
|
|
8
|
+
notArguments?: readonly string[];
|
|
9
9
|
}
|
|
10
10
|
export declare function toolOf(command: Command, choices: ToolChoices): Tool;
|
|
11
11
|
export declare function stepsToolOf(command: Command, choices: ToolChoices): Tool;
|
package/dist/commands/tools.js
CHANGED
|
@@ -44,7 +44,7 @@ export function toolOf(command, choices) {
|
|
|
44
44
|
const { flags, words } = synopsisOf(command.usage, command.spec.valued);
|
|
45
45
|
const valued = [...command.spec.valued, ...GLOBAL_VALUED];
|
|
46
46
|
const options = [...command.spec.valued, ...command.spec.bare, ...GLOBAL_VALUED]
|
|
47
|
-
.filter((name) => !choices.
|
|
47
|
+
.filter((name) => !choices.notArguments?.includes(name))
|
|
48
48
|
.map((name) => {
|
|
49
49
|
const flag = flags.find((f) => f.name === name) ?? fallbackOf(name);
|
|
50
50
|
return optionOf(flag, valued.includes(name), shownOf(flag, valued.includes(name)));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ScenarioRef } from '../scenarios/index.ts';
|
|
2
|
+
import type { Comparison } from './compare.ts';
|
|
3
|
+
export interface GateLink {
|
|
4
|
+
title: string;
|
|
5
|
+
url: string;
|
|
6
|
+
kind?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface GateAnnotation {
|
|
9
|
+
file: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
level: 'error' | 'warning' | 'notice';
|
|
12
|
+
title: string;
|
|
13
|
+
message: string;
|
|
14
|
+
id: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GateAnswer {
|
|
17
|
+
v: 1;
|
|
18
|
+
ok: boolean;
|
|
19
|
+
summary: string;
|
|
20
|
+
details: string;
|
|
21
|
+
annotations: GateAnnotation[];
|
|
22
|
+
links: GateLink[];
|
|
23
|
+
tool: {
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface GateOptions {
|
|
29
|
+
fileOf(s: ScenarioRef): string | null;
|
|
30
|
+
links: readonly GateLink[];
|
|
31
|
+
version: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function gateAnswer(c: Comparison, o: GateOptions): GateAnswer;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
const SUMMARY_LIMIT = 200;
|
|
3
|
+
const DETAILS_LIMIT = 10_000;
|
|
4
|
+
const KEPT_FOR_THE_ANNOUNCE_BLOCK = 2_000;
|
|
5
|
+
const VALUE_LIMIT = 80;
|
|
6
|
+
const DIFFERENCES_SHOWN = 3;
|
|
7
|
+
const ANNOUNCE_GUIDE = 'https://rehearse.kurvball.ca/guides/announce/';
|
|
8
|
+
const ID_LIMIT = 200;
|
|
9
|
+
const MESSAGE_LIMIT = 2_000;
|
|
10
|
+
const WORD_JOINER = '\u2060';
|
|
11
|
+
const oneLine = (text) => text.replace(/\s*[\r\n]+\s*/g, ' ').trim();
|
|
12
|
+
function clipped(text, limit) {
|
|
13
|
+
const points = Array.from(text);
|
|
14
|
+
return points.length <= limit
|
|
15
|
+
? text
|
|
16
|
+
: `${points
|
|
17
|
+
.slice(0, limit - 1)
|
|
18
|
+
.join('')
|
|
19
|
+
.trimEnd()}…`;
|
|
20
|
+
}
|
|
21
|
+
const noMention = (text) => text.replace(/@(?=[A-Za-z0-9])/g, `@${WORD_JOINER}`);
|
|
22
|
+
const plain = (text) => noMention(oneLine(text).replace(/[\\`*_[\]<>#|~]/g, (c) => `\\${c}`));
|
|
23
|
+
function idOf(prefix, scenario) {
|
|
24
|
+
const id = `${prefix}${scenario}`;
|
|
25
|
+
return id.length <= ID_LIMIT ? id : `${prefix}${createHash('sha256').update(scenario).digest('hex')}`;
|
|
26
|
+
}
|
|
27
|
+
const told = (text) => clipped(oneLine(text), MESSAGE_LIMIT);
|
|
28
|
+
function code(text) {
|
|
29
|
+
const shown = clipped(oneLine(text), VALUE_LIMIT);
|
|
30
|
+
const ticks = '`'.repeat(Math.max(0, ...[...shown.matchAll(/`+/g)].map((m) => m[0].length)) + 1);
|
|
31
|
+
return ticks.length === 1 ? `\`${shown}\`` : `${ticks} ${shown} ${ticks}`;
|
|
32
|
+
}
|
|
33
|
+
const whereOf = (s) => `${s.file}${s.line ? `:${s.line}` : ''}`;
|
|
34
|
+
const differenceLine = (d) => `${code(d.path)}: ${code(d.base)} → ${code(d.head)}${d.count > 1 ? ` (${d.count} places)` : ''}`;
|
|
35
|
+
const whatChanged = (d) => oneLine(`${d.path}: ${d.base} → ${d.head}`);
|
|
36
|
+
const failsOnlyHere = (s) => s.verdict === 'fails' && !s.failsOnBase;
|
|
37
|
+
function itemOf(s) {
|
|
38
|
+
const head = `- **${plain(s.scenario.name)}** · ${code(whereOf(s.scenario))}`;
|
|
39
|
+
if (s.verdict === 'fails') {
|
|
40
|
+
const f = s.failures[0];
|
|
41
|
+
const why = f
|
|
42
|
+
? ` — ${plain(f.text)}${f.expected !== null || f.got !== null ? `: expected ${code(f.expected ?? '—')}, got ${code(f.got ?? '—')}` : ''}`
|
|
43
|
+
: '';
|
|
44
|
+
return [`${head}${why}${s.failsOnBase ? ' (it fails on the base too)' : ''}`];
|
|
45
|
+
}
|
|
46
|
+
if (s.verdict === 'said') {
|
|
47
|
+
const said = s.said === 'announced' && s.why ? ` — announced: ${plain(s.why)}` : ' — its definition was edited';
|
|
48
|
+
return [`${head}${said}`];
|
|
49
|
+
}
|
|
50
|
+
const shown = s.differences.slice(0, DIFFERENCES_SHOWN).map((d) => ` - ${differenceLine(d)}`);
|
|
51
|
+
const more = s.differences.length - DIFFERENCES_SHOWN;
|
|
52
|
+
return [head, ...shown, ...(more > 0 ? [` - … ${more} more`] : [])];
|
|
53
|
+
}
|
|
54
|
+
function sectionsOf(c) {
|
|
55
|
+
const of = (pick) => c.scenarios.filter(pick).map(itemOf);
|
|
56
|
+
return [
|
|
57
|
+
{ heading: 'Fails on the head', items: of(failsOnlyHere) },
|
|
58
|
+
{ heading: 'Changed without saying so', items: of((s) => s.verdict === 'unsaid') },
|
|
59
|
+
{
|
|
60
|
+
heading: 'Not run',
|
|
61
|
+
items: c.notRun.map((n) => [
|
|
62
|
+
`- **${plain(n.scenario.name)}** · ${code(whereOf(n.scenario))} — on the ${n.side}, at ${plain(n.step)}: ${plain(n.says)}`,
|
|
63
|
+
]),
|
|
64
|
+
},
|
|
65
|
+
{ heading: 'Fails on the base too', items: of((s) => s.verdict === 'fails' && s.failsOnBase) },
|
|
66
|
+
{ heading: 'Changed and said so', items: of((s) => s.verdict === 'said') },
|
|
67
|
+
{ heading: 'New', items: of((s) => s.verdict === 'new') },
|
|
68
|
+
{
|
|
69
|
+
heading: 'Gone from the head',
|
|
70
|
+
items: c.gone.map((g) => [`- **${plain(g.name)}** · ${code(whereOf(g))}`]),
|
|
71
|
+
},
|
|
72
|
+
].filter((s) => s.items.length > 0);
|
|
73
|
+
}
|
|
74
|
+
function announceBlock(unsaid, room) {
|
|
75
|
+
if (unsaid.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
const intro = [
|
|
78
|
+
'### Announce what you meant',
|
|
79
|
+
'',
|
|
80
|
+
'If a change above was meant, add its line to the changeset this pull request adds, and rewrite its why. See',
|
|
81
|
+
`[announcing a change](${ANNOUNCE_GUIDE}).`,
|
|
82
|
+
'',
|
|
83
|
+
];
|
|
84
|
+
const lines = [];
|
|
85
|
+
let used = intro.join('\n').length + 40;
|
|
86
|
+
for (const s of unsaid) {
|
|
87
|
+
const line = `rehearse: ${s.scenario.id} — ${clipped(whatChanged(s.differences[0]), 160)}`;
|
|
88
|
+
if (used + line.length + 1 > room)
|
|
89
|
+
break;
|
|
90
|
+
lines.push(line);
|
|
91
|
+
used += line.length + 1;
|
|
92
|
+
}
|
|
93
|
+
const left = unsaid.length - lines.length;
|
|
94
|
+
return [
|
|
95
|
+
...intro,
|
|
96
|
+
'```announce',
|
|
97
|
+
...lines,
|
|
98
|
+
'```',
|
|
99
|
+
...(left > 0
|
|
100
|
+
? ['', `… and ${left} more: \`rehearse announce --draft --format changeset\` prints them all.`]
|
|
101
|
+
: []),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
function detailsOf(c) {
|
|
105
|
+
const out = [`**${plain(c.line)}**`];
|
|
106
|
+
if (!c.base.ok || !c.head.ok) {
|
|
107
|
+
const side = c.base.ok ? c.head : c.base;
|
|
108
|
+
out.push('', `The ${c.base.ok ? 'head' : 'base'} didn't come up, at ${plain(side.step ?? 'start')}: ${plain(side.says ?? '')}`);
|
|
109
|
+
return clipped(out.join('\n'), DETAILS_LIMIT);
|
|
110
|
+
}
|
|
111
|
+
const unsaid = c.scenarios.filter((s) => s.verdict === 'unsaid');
|
|
112
|
+
const room = DETAILS_LIMIT - (unsaid.length ? KEPT_FOR_THE_ANNOUNCE_BLOCK : 0) - 200;
|
|
113
|
+
let length = out[0].length;
|
|
114
|
+
let left = 0;
|
|
115
|
+
for (const section of sectionsOf(c)) {
|
|
116
|
+
const heading = ['', `### ${section.heading}`, ''];
|
|
117
|
+
let started = false;
|
|
118
|
+
for (const item of section.items) {
|
|
119
|
+
const text = [...(started ? [] : heading), ...item].join('\n');
|
|
120
|
+
if (length + text.length + 1 > room) {
|
|
121
|
+
left += 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
out.push(...(started ? [] : heading), ...item);
|
|
125
|
+
length += text.length + 1;
|
|
126
|
+
started = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (left > 0)
|
|
130
|
+
out.push('', `… and ${left} more: the full comparison is in the run.`);
|
|
131
|
+
const block = announceBlock(unsaid, KEPT_FOR_THE_ANNOUNCE_BLOCK);
|
|
132
|
+
if (block.length)
|
|
133
|
+
out.push('', ...block);
|
|
134
|
+
return out.join('\n');
|
|
135
|
+
}
|
|
136
|
+
function annotationOf(s, fileOf) {
|
|
137
|
+
const file = fileOf(s.scenario);
|
|
138
|
+
if (!file)
|
|
139
|
+
return null;
|
|
140
|
+
const at = { file, ...(s.scenario.line && { line: s.scenario.line }) };
|
|
141
|
+
const id = idOf(`rehearse:${s.verdict}:`, s.scenario.id);
|
|
142
|
+
const name = oneLine(s.scenario.name);
|
|
143
|
+
if (failsOnlyHere(s)) {
|
|
144
|
+
const f = s.failures[0];
|
|
145
|
+
return {
|
|
146
|
+
...at,
|
|
147
|
+
level: 'error',
|
|
148
|
+
title: 'Fails on the head',
|
|
149
|
+
message: told(`${name} fails on the head and not on the base${f ? `: ${f.text}` : ''}.`),
|
|
150
|
+
id,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (s.verdict === 'unsaid')
|
|
154
|
+
return {
|
|
155
|
+
...at,
|
|
156
|
+
level: 'error',
|
|
157
|
+
title: 'Changed without saying so',
|
|
158
|
+
message: told(`${name} changed: ${clipped(whatChanged(s.differences[0]), 300)}${s.differences.length > 1 ? `, and ${s.differences.length - 1} more` : ''}. If it was meant, announce it in the changeset (rehearse: ${s.scenario.id}); if not, fix it.`),
|
|
159
|
+
id,
|
|
160
|
+
};
|
|
161
|
+
if (s.verdict === 'fails')
|
|
162
|
+
return {
|
|
163
|
+
...at,
|
|
164
|
+
level: 'warning',
|
|
165
|
+
title: 'Fails on the base too',
|
|
166
|
+
message: told(`${name} fails on both sides: not this change's doing.`),
|
|
167
|
+
id,
|
|
168
|
+
};
|
|
169
|
+
if (s.verdict === 'said')
|
|
170
|
+
return {
|
|
171
|
+
...at,
|
|
172
|
+
level: 'notice',
|
|
173
|
+
title: 'Changed and said so',
|
|
174
|
+
message: told(`${name} changed, as ${s.said === 'announced' && s.why ? `announced: ${s.why}` : 'its definition was edited'}.`),
|
|
175
|
+
id,
|
|
176
|
+
};
|
|
177
|
+
if (s.verdict === 'new')
|
|
178
|
+
return { ...at, level: 'notice', title: 'New', message: told(`${name} is new on the head.`), id };
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const MOST_IMPORTANT_FIRST = [
|
|
182
|
+
'Fails on the head',
|
|
183
|
+
'Changed without saying so',
|
|
184
|
+
'Not run',
|
|
185
|
+
'Fails on the base too',
|
|
186
|
+
'Changed and said so',
|
|
187
|
+
'New',
|
|
188
|
+
];
|
|
189
|
+
const rankOf = (a) => MOST_IMPORTANT_FIRST.indexOf(a.title);
|
|
190
|
+
function annotationsOf(c, fileOf) {
|
|
191
|
+
const notRun = c.notRun.flatMap((n) => {
|
|
192
|
+
const file = fileOf(n.scenario);
|
|
193
|
+
if (!file)
|
|
194
|
+
return [];
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
file,
|
|
198
|
+
...(n.scenario.line && { line: n.scenario.line }),
|
|
199
|
+
level: 'error',
|
|
200
|
+
title: 'Not run',
|
|
201
|
+
message: told(`${n.scenario.name} didn't run on the ${n.side}, at ${n.step}: ${n.says}`),
|
|
202
|
+
id: idOf(`rehearse:not-run:${n.side}:`, n.scenario.id),
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
});
|
|
206
|
+
return [...c.scenarios.flatMap((s) => annotationOf(s, fileOf) ?? []), ...notRun]
|
|
207
|
+
.sort((a, b) => rankOf(a) - rankOf(b))
|
|
208
|
+
.slice(0, 1000);
|
|
209
|
+
}
|
|
210
|
+
export function gateAnswer(c, o) {
|
|
211
|
+
const unsaid = c.scenarios.some((s) => s.verdict === 'unsaid');
|
|
212
|
+
return {
|
|
213
|
+
v: 1,
|
|
214
|
+
ok: c.ok,
|
|
215
|
+
summary: clipped(noMention(oneLine(c.line)), SUMMARY_LIMIT),
|
|
216
|
+
details: detailsOf(c),
|
|
217
|
+
annotations: annotationsOf(c, o.fileOf),
|
|
218
|
+
links: [
|
|
219
|
+
...o.links,
|
|
220
|
+
...(unsaid ? [{ title: 'Announce a change', url: ANNOUNCE_GUIDE, kind: 'docs' }] : []),
|
|
221
|
+
].slice(0, 20),
|
|
222
|
+
tool: { name: 'rehearse', version: o.version },
|
|
223
|
+
};
|
|
224
|
+
}
|
package/dist/compare/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { announcedBy, readAnnouncement, SAID_ON_THE_COMMAND_LINE, type Announced, type AnnouncedFrom, } from './announce.ts';
|
|
2
2
|
export { addedChangesets, announcedByChangesets, announcedIn, type ChangesetAnnounced, } from './changesets.ts';
|
|
3
3
|
export { changedFiles, compare, type CompareOptions, type Compared, type Comparison } from './compare.ts';
|
|
4
|
+
export { gateAnswer, type GateAnnotation, type GateAnswer, type GateLink, type GateOptions } from './gate.ts';
|
|
4
5
|
export { clip, jsonDifferences, lineHunks, textDifferences, type Difference } from './diff.ts';
|
|
5
6
|
export { noCounts, noRules, setAsideJson, setAsideText, type Counts as AsideCounts, type Rules, } from './setaside.ts';
|
|
6
7
|
export { lineOf, verdictOf, type Counts } from './verdict.ts';
|
package/dist/compare/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { announcedBy, readAnnouncement, SAID_ON_THE_COMMAND_LINE, } from './announce.js';
|
|
2
2
|
export { addedChangesets, announcedByChangesets, announcedIn, } from './changesets.js';
|
|
3
3
|
export { changedFiles, compare } from './compare.js';
|
|
4
|
+
export { gateAnswer } from './gate.js';
|
|
4
5
|
export { clip, jsonDifferences, lineHunks, textDifferences } from './diff.js';
|
|
5
6
|
export { noCounts, noRules, setAsideJson, setAsideText, } from './setaside.js';
|
|
6
7
|
export { lineOf, verdictOf } from './verdict.js';
|
package/llms.txt
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
- `rehearse list [--affected <file>… | --since <ref>] [--json]`: the scenarios, or those a change reaches, each with reachedBy (schema list).
|
|
11
11
|
- `rehearse up [<service>…] [--world] [--real <stand-in>]` and `rehearse down [--all]`: services left running with a world built on them (schema up).
|
|
12
12
|
- `rehearse run <scenario> [--on <checkout|ref>] [--world] [--as <person>] [--real <stand-in>] [--keep] [--parallel <n>] --json`: one observation (schema observation).
|
|
13
|
-
- `rehearse compare [<id or glob>…] [--affected] [--base <ref|./folder>] [--head <ref|./folder>] [--announce <file>] [--announce-from changesets] [--said <id>]… [--world] [--as] [--real] [--fresh] [--parallel <n>] --json`: a verdict per scenario (schema comparison). --announce-from changesets also reads the `announce` blocks of the changesets the change adds. Exit 0 when both sides came up and nothing fails on the head or changed without saying so. --parallel runs groups that share no service at once, and the base beside the head when budget.services allows two; the result is the same as one at a time.
|
|
13
|
+
- `rehearse compare [<id or glob>…] [--affected] [--base <ref|./folder>] [--head <ref|./folder>] [--announce <file>] [--announce-from changesets] [--said <id>]… [--world] [--as] [--real] [--fresh] [--parallel <n>] [--gate [--preview <url>]] --json`: a verdict per scenario (schema comparison). --gate prints a gate answer instead ({v, ok, summary, details, annotations, links, tool}; exit 0 ok, 1 not, 2 can't compare). --announce-from changesets also reads the `announce` blocks of the changesets the change adds. Exit 0 when both sides came up and nothing fails on the head or changed without saying so. --parallel runs groups that share no service at once, and the base beside the head when budget.services allows two; the result is the same as one at a time.
|
|
14
14
|
- `rehearse announce [<id or glob>…] [--draft] [--base] [--head] [--announce <file>] [--announce-from changesets] [--said <id>]… [--format yaml|changeset] --json`: what a comparison would read as announced (schema announce); with --draft (and compare's own options) it compares and proposes {scenario, why} for each scenario whose verdict is unsaid, its why the first difference, for you to rewrite as the reason. --format changeset prints an `announce` block for a changeset. It writes no file; refuses with code not_compared when the base or head doesn't come up.
|
|
15
15
|
- `rehearse drive start [--service <name> | --piece <id>] [--world] [--as <person>] [--scheme light|dark]` (or DRIVE_SCHEME), then `rehearse drive click --name <name> [--role <role>] | fill --name <name> --with <text> | type <text> | key <key> | snapshot [--name <name> [--role <role>]] | screenshot <file.png> | stop`, each with --json: the drive result shape {ok, command, ms, file, tree} plus v and driver (schema drive). Exit 0 done, 1 failed, 2 usage.
|
|
16
16
|
- `rehearse stage [--base] [--head] [--port] [--announce <file>] [--announce-from changesets] [--said <id>]…`: the stage on 127.0.0.1 (default port 4400): every scenario in Base, Head and Diff, with Works, Doesn't and a note (kept in .rehearse/tries.jsonl, schema try).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurvball/rehearse",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Rehearse a change before it ships: bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head.",
|
|
5
5
|
"homepage": "https://rehearse.kurvball.ca/",
|
|
6
6
|
"repository": {
|