slicekit 0.7.2 → 0.7.4
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/package.json +1 -1
- package/src/build/commit.js +128 -42
- package/src/build/red.js +41 -36
- package/src/build/verdict.js +50 -18
- package/src/check/rules/frozen.js +70 -19
- package/src/check/rules/lane.js +100 -0
- package/src/cli/build.js +9 -5
- package/src/hooks/paths.js +25 -10
- package/src/hooks/pre-edit.js +148 -17
- package/src/slicefile.js +8 -0
- package/src/state/index.js +28 -8
- package/src/state/transitions.js +24 -3
- package/src/testnames.js +293 -0
- package/templates/instructions/commands/build.md +26 -16
- package/templates/instructions/commands/plan.md +9 -1
- package/templates/instructions/commands/review.md +2 -1
package/src/state/transitions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { isDate, isSha, sameSha } from '../evidence.js';
|
|
4
|
+
import { TestNameError, entryFile, entryLabel, findTest, isEntry } from '../testnames.js';
|
|
4
5
|
import { isReviewWorktreeAt } from '../worktrees.js';
|
|
5
6
|
import { headCovers } from './covers.js';
|
|
6
7
|
|
|
@@ -29,6 +30,19 @@ const last = (list) => list[list.length - 1];
|
|
|
29
30
|
const isInt = (n) => Number.isInteger(n) && n >= 0;
|
|
30
31
|
const isStr = (s) => typeof s === 'string' && s !== '';
|
|
31
32
|
const present = (root, rel) => fs.existsSync(path.resolve(root, rel));
|
|
33
|
+
// A frozen entry's file is present, and a test frozen by name is found in it; a file the reader
|
|
34
|
+
// cannot parse is not judged present.
|
|
35
|
+
function presentTest(root, entry) {
|
|
36
|
+
const file = entryFile(entry);
|
|
37
|
+
if (!present(root, file)) return false;
|
|
38
|
+
if (typeof entry === 'string') return true;
|
|
39
|
+
try {
|
|
40
|
+
return findTest(fs.readFileSync(path.resolve(root, file), 'utf8'), entry.name) !== null;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
if (e instanceof TestNameError) return false;
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
32
46
|
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
33
47
|
|
|
34
48
|
// The verdicts that hold on the pull request head as it stands now: those given on it, and, with a
|
|
@@ -73,6 +87,10 @@ export function validateEvidence(ev) {
|
|
|
73
87
|
if (ev.tests !== undefined && !(Array.isArray(ev.tests) && ev.tests.every(isStr))) {
|
|
74
88
|
return bad('tests', 'an array of non-empty strings');
|
|
75
89
|
}
|
|
90
|
+
// P8/S-60 (D-102): the evaluation tests frozen by name, { file, name } or a whole file's path.
|
|
91
|
+
if (ev.frozen !== undefined && !(Array.isArray(ev.frozen) && ev.frozen.every(isEntry))) {
|
|
92
|
+
return bad('frozen', 'an array of { file, name } entries or paths');
|
|
93
|
+
}
|
|
76
94
|
const pr = ev.pr;
|
|
77
95
|
if (pr !== undefined) {
|
|
78
96
|
if (pr === null || typeof pr !== 'object') return bad('pr', 'an object');
|
|
@@ -121,15 +139,18 @@ export const TRANSITIONS = {
|
|
|
121
139
|
}
|
|
122
140
|
return null;
|
|
123
141
|
},
|
|
124
|
-
|
|
142
|
+
// `frozen`, given by build red, holds each evaluation test by its file and name (D-102); without
|
|
143
|
+
// it (`state set` with --tests) the files are recorded whole, as before P8/S-60.
|
|
144
|
+
apply: (_current, ev) => ({ redCommit: ev.commit, frozenTests: ev.frozen ? ev.frozen.map((e) => (typeof e === 'string' ? e : { file: e.file, name: e.name })) : [...ev.tests] }),
|
|
125
145
|
},
|
|
126
146
|
building: {
|
|
127
147
|
from: ['tests-red'],
|
|
128
148
|
required: [],
|
|
149
|
+
// Each frozen file is present and each test frozen by name is found in its file (D-102).
|
|
129
150
|
check(current, _ev, ctx) {
|
|
130
151
|
if (!current.redCommit) return 'building needs a recorded red commit';
|
|
131
|
-
const missing = current.frozenTests.filter((t) => !
|
|
132
|
-
return missing.length > 0 ? `frozen tests are missing: ${missing.join(', ')}` : null;
|
|
152
|
+
const missing = current.frozenTests.filter((t) => !isEntry(t) || !presentTest(ctx.root, t));
|
|
153
|
+
return missing.length > 0 ? `frozen tests are missing: ${missing.map((t) => (isEntry(t) ? entryLabel(t) : String(t))).join(', ')}` : null;
|
|
133
154
|
},
|
|
134
155
|
apply: () => ({}),
|
|
135
156
|
},
|
package/src/testnames.js
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// A test of the evaluation set, found in its file by its name (REQ-3.3, REQ-3.15, D-102), and the
|
|
2
|
+
// frozen entries of a state file read as { file, name }.
|
|
3
|
+
//
|
|
4
|
+
// `findTest(text, name)` finds the one `test(...)` or `it(...)` call, at any depth, whose first argument
|
|
5
|
+
// is a string literal (single, double or backtick quotes, no substitution) equal to `name`. It returns
|
|
6
|
+
// { line, text }: the 1-based line the call starts on, and the text from `test`/`it` to the call's
|
|
7
|
+
// matching close parenthesis; null when no call has the name. Strings, template literals, comments
|
|
8
|
+
// and regular expression literals are skipped, so a parenthesis or a brace inside them does not count.
|
|
9
|
+
// A file the reader cannot parse (an unterminated string, comment or call), or a name given to two
|
|
10
|
+
// calls, throws a TestNameError: every caller treats it as "cannot judge".
|
|
11
|
+
//
|
|
12
|
+
// Only `node:` modules (D-04): none are needed.
|
|
13
|
+
|
|
14
|
+
export class TestNameError extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'TestNameError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const IDENT_START = /[A-Za-z_$]/;
|
|
22
|
+
const IDENT = /[A-Za-z0-9_$]/;
|
|
23
|
+
// An escaped quote or backslash keeps a literal plain; any other escape does not.
|
|
24
|
+
const QUOTE_ESCAPE = /['"`\\]/;
|
|
25
|
+
// After one of these tokens a `/` starts a regular expression literal, not a division.
|
|
26
|
+
const REGEX_AFTER_PUNCT = new Set(['(', ',', '=', ':', '[', '!', '&', '|', '?', '{', '}', ';', '+', '-', '*', '%', '<', '>', '~', '^', '=>']);
|
|
27
|
+
const REGEX_AFTER_WORD = new Set(['return', 'typeof', 'instanceof', 'in', 'of', 'new', 'delete', 'void', 'throw', 'case', 'do', 'else', 'yield', 'await']);
|
|
28
|
+
|
|
29
|
+
// The tokens of `text` that matter here: identifiers, punctuation, and string literals (a template
|
|
30
|
+
// with no substitution counts as one). Each is { type, value, start, end, line }; a string's value is
|
|
31
|
+
// its raw content between the quotes, and `plain` is false when it holds an escape or a substitution.
|
|
32
|
+
function tokens(text) {
|
|
33
|
+
const out = [];
|
|
34
|
+
let i = 0;
|
|
35
|
+
let line = 1;
|
|
36
|
+
// Each open `{` in code, and each `${` of a template: a `}` closing a `${` resumes the template.
|
|
37
|
+
const braces = [];
|
|
38
|
+
const prevSignificant = () => out.at(-1);
|
|
39
|
+
const regexAllowed = () => {
|
|
40
|
+
const p = prevSignificant();
|
|
41
|
+
if (!p) return true;
|
|
42
|
+
if (p.type === 'punct') return REGEX_AFTER_PUNCT.has(p.value);
|
|
43
|
+
if (p.type === 'ident') return REGEX_AFTER_WORD.has(p.value);
|
|
44
|
+
return false;
|
|
45
|
+
};
|
|
46
|
+
const fail = (what, at) => {
|
|
47
|
+
throw new TestNameError(`cannot read the test file: ${what} at line ${at}`);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Reads a template literal from just after a backtick or a `}` closing a substitution. -> whether it
|
|
51
|
+
// ended at a backtick (true) or at a `${` (false); adds a string token for the part read.
|
|
52
|
+
const template = (start, startLine, fromBacktick) => {
|
|
53
|
+
let plain = fromBacktick;
|
|
54
|
+
let j = i;
|
|
55
|
+
while (j < text.length) {
|
|
56
|
+
const c = text[j];
|
|
57
|
+
if (c === '\\') {
|
|
58
|
+
if (!QUOTE_ESCAPE.test(text[j + 1] ?? '')) plain = false;
|
|
59
|
+
if (text[j + 1] === '\n') line += 1;
|
|
60
|
+
j += 2;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (c === '\n') line += 1;
|
|
64
|
+
if (c === '`') {
|
|
65
|
+
out.push({ type: 'string', value: text.slice(i, j), plain, start, end: j + 1, line: startLine });
|
|
66
|
+
i = j + 1;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (c === '$' && text[j + 1] === '{') {
|
|
70
|
+
out.push({ type: 'string', value: text.slice(i, j), plain: false, start, end: j + 2, line: startLine });
|
|
71
|
+
i = j + 2;
|
|
72
|
+
braces.push('template');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
j += 1;
|
|
76
|
+
}
|
|
77
|
+
return fail('an unterminated template literal', startLine);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
while (i < text.length) {
|
|
81
|
+
const c = text[i];
|
|
82
|
+
if (c === '\n') {
|
|
83
|
+
line += 1;
|
|
84
|
+
i += 1;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (c === ' ' || c === '\t' || c === '\r' || c === '\f' || c === '\v' || c === '\uFEFF') {
|
|
88
|
+
i += 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (c === '/' && text[i + 1] === '/') {
|
|
92
|
+
const nl = text.indexOf('\n', i);
|
|
93
|
+
i = nl === -1 ? text.length : nl;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (c === '/' && text[i + 1] === '*') {
|
|
97
|
+
const close = text.indexOf('*/', i + 2);
|
|
98
|
+
if (close === -1) fail('an unterminated comment', line);
|
|
99
|
+
for (let k = i; k < close; k += 1) if (text[k] === '\n') line += 1;
|
|
100
|
+
i = close + 2;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (c === '#' && i === 0 && text[1] === '!') {
|
|
104
|
+
const nl = text.indexOf('\n', i);
|
|
105
|
+
i = nl === -1 ? text.length : nl;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (c === "'" || c === '"') {
|
|
109
|
+
const start = i;
|
|
110
|
+
const startLine = line;
|
|
111
|
+
let plain = true;
|
|
112
|
+
let j = i + 1;
|
|
113
|
+
while (j < text.length && text[j] !== c) {
|
|
114
|
+
if (text[j] === '\n') fail('an unterminated string', startLine);
|
|
115
|
+
if (text[j] === '\\') {
|
|
116
|
+
if (!QUOTE_ESCAPE.test(text[j + 1] ?? '')) plain = false;
|
|
117
|
+
if (text[j + 1] === '\n') line += 1;
|
|
118
|
+
j += 2;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
j += 1;
|
|
122
|
+
}
|
|
123
|
+
if (j >= text.length) fail('an unterminated string', startLine);
|
|
124
|
+
out.push({ type: 'string', value: text.slice(i + 1, j), plain, start, end: j + 1, line: startLine });
|
|
125
|
+
i = j + 1;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (c === '`') {
|
|
129
|
+
const start = i;
|
|
130
|
+
i += 1;
|
|
131
|
+
template(start, line, true);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (c === '/' && regexAllowed()) {
|
|
135
|
+
const startLine = line;
|
|
136
|
+
let j = i + 1;
|
|
137
|
+
let inClass = false;
|
|
138
|
+
while (j < text.length) {
|
|
139
|
+
const d = text[j];
|
|
140
|
+
if (d === '\n') fail('an unterminated regular expression', startLine);
|
|
141
|
+
if (d === '\\') {
|
|
142
|
+
j += 2;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (d === '[') inClass = true;
|
|
146
|
+
else if (d === ']') inClass = false;
|
|
147
|
+
else if (d === '/' && !inClass) break;
|
|
148
|
+
j += 1;
|
|
149
|
+
}
|
|
150
|
+
if (j >= text.length) fail('an unterminated regular expression', startLine);
|
|
151
|
+
j += 1;
|
|
152
|
+
while (j < text.length && IDENT.test(text[j])) j += 1;
|
|
153
|
+
out.push({ type: 'regex', value: text.slice(i, j), start: i, end: j, line: startLine });
|
|
154
|
+
i = j;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (IDENT_START.test(c)) {
|
|
158
|
+
let j = i + 1;
|
|
159
|
+
while (j < text.length && IDENT.test(text[j])) j += 1;
|
|
160
|
+
out.push({ type: 'ident', value: text.slice(i, j), start: i, end: j, line });
|
|
161
|
+
i = j;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (/[0-9]/.test(c)) {
|
|
165
|
+
let j = i + 1;
|
|
166
|
+
while (j < text.length && /[0-9A-Za-z_.]/.test(text[j])) j += 1;
|
|
167
|
+
out.push({ type: 'number', value: text.slice(i, j), start: i, end: j, line });
|
|
168
|
+
i = j;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (c === '}' && braces.at(-1) === 'template') {
|
|
172
|
+
braces.pop();
|
|
173
|
+
const start = i;
|
|
174
|
+
i += 1;
|
|
175
|
+
template(start, line, false);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (c === '{') braces.push('code');
|
|
179
|
+
if (c === '}') braces.pop();
|
|
180
|
+
if (c === '=' && text[i + 1] === '>') {
|
|
181
|
+
out.push({ type: 'punct', value: '=>', start: i, end: i + 2, line });
|
|
182
|
+
i += 2;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
out.push({ type: 'punct', value: c, start: i, end: i + 1, line });
|
|
186
|
+
i += 1;
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// A literal's raw content with its quote and backslash escapes read; any other escape keeps its
|
|
192
|
+
// backslash, so a name with one never matches.
|
|
193
|
+
const unescape = (raw) => raw.replace(/\\(['"`\\])/g, '$1');
|
|
194
|
+
|
|
195
|
+
const OPEN = { '(': ')', '[': ']', '{': '}' };
|
|
196
|
+
|
|
197
|
+
// The index of the token closing the call whose `(` is at index `open`, or a TestNameError.
|
|
198
|
+
function closeOf(toks, open) {
|
|
199
|
+
const stack = [];
|
|
200
|
+
for (let k = open; k < toks.length; k += 1) {
|
|
201
|
+
const t = toks[k];
|
|
202
|
+
if (t.type !== 'punct') continue;
|
|
203
|
+
if (OPEN[t.value]) stack.push(OPEN[t.value]);
|
|
204
|
+
else if (t.value === ')' || t.value === ']' || t.value === '}') {
|
|
205
|
+
if (stack.pop() !== t.value) throw new TestNameError(`cannot read the test file: an unbalanced ${t.value} at line ${t.line}`);
|
|
206
|
+
if (stack.length === 0) return k;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
throw new TestNameError(`cannot read the test file: the call at line ${toks[open].line} is not closed`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Every `test(...)` or `it(...)` call named `name`: [{ line, text }].
|
|
213
|
+
function calls(text, name) {
|
|
214
|
+
const toks = tokens(text);
|
|
215
|
+
const found = [];
|
|
216
|
+
for (let k = 0; k + 2 < toks.length; k += 1) {
|
|
217
|
+
const t = toks[k];
|
|
218
|
+
if (t.type !== 'ident' || (t.value !== 'test' && t.value !== 'it')) continue;
|
|
219
|
+
const before = toks[k - 1];
|
|
220
|
+
if (before && before.type === 'punct' && before.value === '.') continue;
|
|
221
|
+
const open = toks[k + 1];
|
|
222
|
+
const label = toks[k + 2];
|
|
223
|
+
if (open.type !== 'punct' || open.value !== '(' || label.type !== 'string' || !label.plain) continue;
|
|
224
|
+
if (unescape(label.value) !== name) continue;
|
|
225
|
+
const end = closeOf(toks, k + 1);
|
|
226
|
+
found.push({ line: t.line, text: text.slice(t.start, toks[end].end) });
|
|
227
|
+
}
|
|
228
|
+
return found;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function findTest(text, name) {
|
|
232
|
+
const found = calls(String(text).replace(/\r\n/g, '\n'), name);
|
|
233
|
+
if (found.length > 1) {
|
|
234
|
+
throw new TestNameError(`the test name "${name}" is given twice, at lines ${found.map((f) => f.line).join(' and ')}`);
|
|
235
|
+
}
|
|
236
|
+
return found[0] ?? null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// ---- the evaluation set's rows and the state file's frozen entries ----
|
|
240
|
+
|
|
241
|
+
export const SEP = ' » ';
|
|
242
|
+
|
|
243
|
+
// One evaluation-set cell, `<file> » <name>` or a bare `<file>`: { row, file, name } (name null).
|
|
244
|
+
export function parseRow(cell) {
|
|
245
|
+
const row = String(cell).replace(/^`|`$/g, '').trim();
|
|
246
|
+
const at = row.indexOf(SEP);
|
|
247
|
+
return {
|
|
248
|
+
row,
|
|
249
|
+
file: (at === -1 ? row : row.slice(0, at)).trim(),
|
|
250
|
+
name: at === -1 ? null : row.slice(at + SEP.length).trim(),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// The rows of a parsed slice file's evaluation set.
|
|
255
|
+
export const evaluationRows = (slice) => (slice?.evaluation ?? []).map(({ test }) => parseRow(test));
|
|
256
|
+
|
|
257
|
+
// A listed test path ends with a row's file: the row `hooks/a.test.js` names `test/hooks/a.test.js`.
|
|
258
|
+
export const endsWithFile = (t, file) => t === file || t.endsWith(`/${file}`);
|
|
259
|
+
|
|
260
|
+
// An entry as a state file stores it: a path string (a whole file, written before P8/S-60, or a file
|
|
261
|
+
// `build amend --test <file>` unfroze whole), or { file, name }.
|
|
262
|
+
export const isEntry = (e) =>
|
|
263
|
+
(typeof e === 'string' && e !== '') ||
|
|
264
|
+
(e !== null && typeof e === 'object' && !Array.isArray(e) && typeof e.file === 'string' && e.file !== '' && typeof e.name === 'string' && e.name !== '');
|
|
265
|
+
|
|
266
|
+
export const entryFile = (e) => (typeof e === 'string' ? e : e.file);
|
|
267
|
+
export const entryLabel = (e) => (typeof e === 'string' || e.name === null ? entryFile(e) : `${e.file}${SEP}${e.name}`);
|
|
268
|
+
|
|
269
|
+
// The frozen entries as [{ file, name }], `name` null for a whole file. A path string, the form of a
|
|
270
|
+
// state file written before P8/S-60, is read as every evaluation test of that file by name when
|
|
271
|
+
// `rows` (the slice file's evaluation set) names tests in it; else as the whole file. `same` compares
|
|
272
|
+
// two paths (case-folded on win32 by callers that need it).
|
|
273
|
+
export function frozenEntries(list, rows = [], same = (a, b) => a === b) {
|
|
274
|
+
const out = [];
|
|
275
|
+
const add = (e) => {
|
|
276
|
+
if (!out.some((o) => same(o.file, e.file) && o.name === e.name)) out.push(e);
|
|
277
|
+
};
|
|
278
|
+
for (const e of list ?? []) {
|
|
279
|
+
if (typeof e !== 'string') {
|
|
280
|
+
add({ file: e.file, name: e.name });
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const named = rows.filter((r) => r.name !== null && endsWithFile(e, r.file));
|
|
284
|
+
if (named.length === 0) add({ file: e, name: null });
|
|
285
|
+
else for (const r of named) add({ file: e, name: r.name });
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Whether `unfrozen` lifts the freeze on entry { file, name }: it lists the file whole, or the same test.
|
|
291
|
+
export function isUnfrozen(entry, unfrozen, same = (a, b) => a === b) {
|
|
292
|
+
return (unfrozen ?? []).some((u) => (typeof u === 'string' ? same(u, entry.file) : same(u.file, entry.file) && u.name === entry.name));
|
|
293
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Build one slice from `todo` to a pull request ready for a human to merge: the tests first and
|
|
4
4
|
failing, then the code that makes them pass, then at most two review rounds and green CI (REQ-2.6,
|
|
5
|
-
steps 1 to 9).
|
|
5
|
+
steps 1 to 9). A slice marked `lane: quick` in its slice file has one in-loop review round in place of
|
|
6
|
+
two (REQ-2.5, D-103); its independent review is the same as for any slice. Arguments: {{args}}.
|
|
6
7
|
|
|
7
8
|
`<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`. Every step that touches the
|
|
8
9
|
repository's history goes through `{{cli}}`; run no git or gh command yourself. The developer writes
|
|
@@ -41,7 +42,8 @@ already started prints `resumed <path> at <state>`; keep the path and go on at t
|
|
|
41
42
|
again and prints that round's `next:`. After an independent round the second line is
|
|
42
43
|
`next review: /slicekit review <n> in a new session` instead: stop and tell the human to run that
|
|
43
44
|
in a new session, since this session built the slice.
|
|
44
|
-
- `changes-requested`: the loop stopped with a blocker after
|
|
45
|
+
- `changes-requested`: the loop stopped with a blocker after the last in-loop round (round 2, or
|
|
46
|
+
round 1 for a quick slice). Stop and tell the human.
|
|
45
47
|
- any later state: stop and tell the human the slice is in review, at that state.
|
|
46
48
|
|
|
47
49
|
When it refuses with `already started in origin/<branch>; another clone holds it`, stop and tell the
|
|
@@ -74,9 +76,11 @@ After each developer report in which a test newly passes, run
|
|
|
74
76
|
`feat(<id>): <what now works>`. It prints `<sha7> exit <n>`, or `nothing to commit` with exit 0,
|
|
75
77
|
which is success. With nothing staged it commits every changed path; with paths staged it commits
|
|
76
78
|
those alone, as staged, and runs the tests on the staged content; a tracked path changed but not
|
|
77
|
-
staged stays in the worktree, out of the commit. A
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
staged stays in the worktree, out of the commit. A test is frozen by its name, as the evaluation
|
|
80
|
+
set's `<file> » <name>` cell names it, not by the file that holds it: another test or line of that
|
|
81
|
+
file may change. A refusal naming a frozen test, `frozen test <file> » <name> changed since <sha7>`,
|
|
82
|
+
means the developer changed one: send it back with the message. While tests still fail, spawn the
|
|
83
|
+
developer again with what is left.
|
|
80
84
|
|
|
81
85
|
When the developer reports a line `amend: <test path> — <why>`, ask the human whether that test may
|
|
82
86
|
change. On no, tell the developer the test stands. On yes:
|
|
@@ -86,20 +90,23 @@ change. On no, tell the developer the test stands. On yes:
|
|
|
86
90
|
2. Change the evaluation set's row when the test's name or kind changes. When the row stays the
|
|
87
91
|
same (only the test was wrong), still record the amendment in that file, as a line under the
|
|
88
92
|
evaluation set naming the test and the reason: `build amend` refuses a slice file with no change.
|
|
89
|
-
3. Run `{{cli}} build amend <id> --test <test path> --reason "<why>" --worktree <path>`,
|
|
90
|
-
the developer it may change that one test.
|
|
93
|
+
3. Run `{{cli}} build amend <id> --test "<test path> » <test name>" --reason "<why>" --worktree <path>`,
|
|
94
|
+
and tell the developer it may change that one test. It commits the slice file, records the
|
|
95
|
+
test, the amendment commit and the reason in the state file, and prints
|
|
96
|
+
`unfroze <test path> » <test name>`; every other frozen test stays frozen. Naming a test already
|
|
97
|
+
unfrozen records a second amendment of it and its reason, and prints
|
|
98
|
+
`<sha7> amended the slice file; <test path> » <test name> was already unfrozen`.
|
|
91
99
|
|
|
92
100
|
`build amend` also runs at `draft-pr`, `in-review` and `changes-requested`, for a finding that sits
|
|
93
101
|
inside a frozen test: the same three steps, then the slice is back at `building`. The fixer (or the
|
|
94
102
|
developer) changes that test, and step 7's `build commit` and `build pr` take the slice back to
|
|
95
103
|
`draft-pr` on the same pull request.
|
|
96
104
|
|
|
97
|
-
When the human changes the slice file and
|
|
98
|
-
to name: edit the slice file in the worktree as in step 1, then run
|
|
105
|
+
When the human changes the slice file and no test is to change (a Done when item, a pending marker,
|
|
106
|
+
a note), there is no test to name: edit the slice file in the worktree as in step 1, then run
|
|
99
107
|
`{{cli}} build amend <id> --reason "<why>" --worktree <path>`. It commits the slice file alone,
|
|
100
|
-
records the reason in the state file, leaves the state as it is, and
|
|
101
|
-
`<sha7> amended the slice file`.
|
|
102
|
-
`--test`.
|
|
108
|
+
records the amendment commit and the reason in the state file, leaves the state as it is, and
|
|
109
|
+
prints `<sha7> amended the slice file`. Every frozen test stays frozen.
|
|
103
110
|
|
|
104
111
|
## 5. Green, then the draft pull request
|
|
105
112
|
|
|
@@ -161,7 +168,8 @@ after `-r` in the verdict file's name) and the verdict path: the `verdict <file>
|
|
|
161
168
|
|
|
162
169
|
When the reviewer stops, run `{{cli}} build verdict <id> <file> --worktree <path>` with that verdict
|
|
163
170
|
path. It commits the verdict into the worktree, pushes, and prints `next: <step>`,
|
|
164
|
-
`blockers: <IDs or none>`, `should-haves: <IDs or none>` and `rounds: <used> of 2
|
|
171
|
+
`blockers: <IDs or none>`, `should-haves: <IDs or none>` and `rounds: <used> of <budget>` (2, or 1
|
|
172
|
+
for a quick slice), and last a new
|
|
165
173
|
`verdict <file>` line when another round is allowed. A refusal that names the verdict's content (a
|
|
166
174
|
finding with no "How verified", a reused finding number, a banned phrase, a `<!--`, an unknown ID or
|
|
167
175
|
path) goes back to the reviewer with the printed message; run this command again with the file it writes. A refusal that
|
|
@@ -179,7 +187,8 @@ print it and stop. Then act on `next:`:
|
|
|
179
187
|
- `next: fix`: step 7.
|
|
180
188
|
- `next: ask`: step 8.
|
|
181
189
|
- `next: ci`: step 9.
|
|
182
|
-
- `next: stuck`: it exits 1. A blocker survived round 2
|
|
190
|
+
- `next: stuck`: it exits 1. A blocker survived the last in-loop round (round 2, or round 1 for a
|
|
191
|
+
quick slice): the state is `changes-requested` and the
|
|
183
192
|
pull request stays a draft. Print the output and stop; the human decides what happens to the
|
|
184
193
|
slice.
|
|
185
194
|
|
|
@@ -218,8 +227,9 @@ which is success too. Then:
|
|
|
218
227
|
- with no blockers and should-haves to fix: step 7 for those should-haves alone.
|
|
219
228
|
- with every should-have declined and no blockers: step 9.
|
|
220
229
|
|
|
221
|
-
After round
|
|
222
|
-
`fix: not available after round 2; decline or leave for the independent review
|
|
230
|
+
After the last in-loop round no fix is offered: `build verdict` prints
|
|
231
|
+
`fix: not available after round 2; decline or leave for the independent review` (`after round 1`
|
|
232
|
+
for a quick slice). Ask only whether
|
|
223
233
|
to decline each should-have or leave it for the independent review, then go to step 9.
|
|
224
234
|
|
|
225
235
|
## 9. Green CI, then the independent review
|
|
@@ -35,7 +35,10 @@ repository's history goes through `{{cli}}`; run no git or gh command yourself.
|
|
|
35
35
|
one `negative` row, each row naming the REQ it covers;
|
|
36
36
|
- a `## Expected changes` list of the files or packages the slice changes, each in backticks;
|
|
37
37
|
- the runbook flag set to `yes` when the slice touches configuration, infrastructure,
|
|
38
|
-
migrations, alerts, queues or integrations (D-21), else `no
|
|
38
|
+
migrations, alerts, queues or integrations (D-21), else `no`;
|
|
39
|
+
- optionally `lane: quick` in the front matter (D-103). Mark a slice `lane: quick` only when its
|
|
40
|
+
expected changes name no file under `src/`, `bin/` or `templates/`; `{{cli}} check` refuses a
|
|
41
|
+
quick slice whose expected changes or branch reach one of those folders.
|
|
39
42
|
|
|
40
43
|
Every REQ in the spec is named by at least one slice. No two slices of one Order step expect the
|
|
41
44
|
same path, apart from the shared roots: `.`, anything under `test/`, `src/cli/index.js` and
|
|
@@ -56,5 +59,10 @@ repository's history goes through `{{cli}}`; run no git or gh command yourself.
|
|
|
56
59
|
|
|
57
60
|
Then run `{{cli}} pr open --title "[plan] <program name>" --body-file <file> --commit "docs(plan): <program name>" --paths <docsRoot>/spec/stack.md,<docsRoot>/phases,<docsRoot>/decisions.md,BUILD.md`,
|
|
58
61
|
with the program name from `.slicekit/config.json`.
|
|
62
|
+
|
|
63
|
+
A quick slice gets one combined plan step: when it is added to a plan that is already merged,
|
|
64
|
+
its slice file, its phase file and `BUILD.md` are written and merged in one `[plan]` pull request,
|
|
65
|
+
steps 1 to 8 run once, and no second plan pull request follows. Its build then has one in-loop
|
|
66
|
+
review round in place of two, and the independent review as for any slice.
|
|
59
67
|
8. Print the pull request line `pr open` printed, and tell the human that merging the pull request
|
|
60
68
|
approves the plan; `/slicekit build` then takes the first slice.
|
|
@@ -62,7 +62,8 @@ section lets it write that one file outside the worktree.
|
|
|
62
62
|
When the reviewer stops, run `{{cli}} build verdict <id> <path> --independent --worktree <wt>` with
|
|
63
63
|
step 2's verdict path. It commits the verdict into the review worktree, pushes it to the slice
|
|
64
64
|
branch, and prints `next: <step>`, `blockers: <IDs or none>`, `should-haves: <IDs or none>` and
|
|
65
|
-
`rounds: <used> of
|
|
65
|
+
`rounds: <used> of <budget>` (the in-loop budget: 2, or 1 for a quick slice); the rounds stay as
|
|
66
|
+
they were. On `next: fix` it also prints
|
|
66
67
|
`review: <command>`, the `review start` command of the next independent round that the budget
|
|
67
68
|
allows (D-101); keep it for step 5. By what it prints:
|
|
68
69
|
|