slicekit 0.7.3 → 0.7.5

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 CHANGED
@@ -70,6 +70,7 @@ walkthrough on `examples/backend`, except the review's `verdict` line: it is the
70
70
  | Stage | Command | What you get |
71
71
  |---|---|---|
72
72
  | Any | `/slicekit` | any procedure below by name, for example `/slicekit build` |
73
+ | Next | `/slicekit next` | the one next step, read from the files, run and then stopped; `/loop /slicekit next` runs one step per iteration, and a person merges |
73
74
  | Brief | `/slicekit brief` | a brief written from the person's own answers, when there is only an idea and no requirement document |
74
75
  | Intake | `/slicekit intake` | a frozen snapshot of the requirement document and one decision row per answer |
75
76
  | Specify | `/slicekit specify` | spec files in which every requirement cites its source, and the spec pull request |
@@ -181,8 +182,10 @@ absolute path in `cli` or a global install.
181
182
  <details>
182
183
  <summary>Built with itself</summary>
183
184
 
184
- The kit is built with itself: each change to its code goes through a slice, with tests written first,
185
- a review and green CI; its plans and version changes go through pull requests of their own. `docs/spec/00-overview.md` says what the kit is and why, `docs/decisions.md` holds every
185
+ The kit is built with itself: every change to `src/`, `bin/` and `templates/` went through a slice,
186
+ with tests written first, a review and green CI; its plans and version changes go through pull requests
187
+ of their own. Test files have also changed in spec pull requests, and #94 is the one case so far.
188
+ `docs/spec/00-overview.md` says what the kit is and why, `docs/decisions.md` holds every
186
189
  choice made so far, and `BUILD.md` shows the order the kit is built in.
187
190
 
188
191
  </details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicekit",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Spec-driven agentic workflow kit",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -5,8 +5,8 @@
5
5
  // not committed, committed but not recorded, recorded but not pushed) finishes on a re-run with the
6
6
  // same file name.
7
7
  //
8
- // Two in-loop rounds (D-18): a third is refused before anything moves, and a blocker left at round 2
9
- // records `changes-requested` and stops the loop with the pull request still a draft. After every
8
+ // Two in-loop rounds (D-18), one for a slice marked `lane: quick` (D-103): a round past them is refused
9
+ // before anything moves, and a blocker left at the last in-loop round records `changes-requested` and stops the loop with the pull request still a draft. After every
10
10
  // verdict the body's "Reviewer blocked" names each blocker and whether it was fixed. The independent
11
11
  // rounds have their own budget (D-101): one, a second only after a blocker, any later one only with a
12
12
  // decision row; a blocker left at the last allowed round records `changes-requested` the same way.
@@ -31,6 +31,7 @@ import { kitPaths } from '../paths.js';
31
31
  import { lines as splitLines } from '../markdown.js';
32
32
  import { PrBodyError, getSection, prBodyProblems, setSection } from '../prbody.js';
33
33
  import { parseVerdict, verdictProblems } from '../verdict.js';
34
+ import { findSliceFiles, parseSliceFile } from '../slicefile.js';
34
35
  import { posixRel } from './red.js';
35
36
  import { commitBookkeeping, recordState } from './record.js';
36
37
  import { assertNotBehind } from './sync.js';
@@ -44,6 +45,8 @@ const FROM = ['draft-pr', 'changes-requested'];
44
45
  const fromStates = (independent) => (independent ? [...FROM, ...INDEPENDENT_ONLY] : FROM);
45
46
  const orList = (xs) => (xs.length < 3 ? xs.join(' or ') : `${xs.slice(0, -1).join(', ')} or ${xs.at(-1)}`);
46
47
  export const LOOP_ROUNDS = 2;
48
+ // A slice marked `lane: quick` has one in-loop round (REQ-2.5, D-103).
49
+ export const QUICK_LOOP_ROUNDS = 1;
47
50
  const REVIEWS = '.slicekit/reviews';
48
51
  const BLOCKED = 'Reviewer blocked';
49
52
  const ID = /^([BH])-([1-9]\d*)$/;
@@ -138,6 +141,31 @@ function verdictSource(wt, id, k, src, dest, rel, shown) {
138
141
 
139
142
  const inLoop = (verdicts) => verdicts.filter((x) => !x.independent).length;
140
143
 
144
+ // The in-loop rounds of slice `id` as its slice file under `root` gives them: one for a slice marked
145
+ // `lane: quick` (REQ-2.5, D-103), else two (D-18). A slice file that cannot be found or read keeps two.
146
+ export function loopRounds(root, cfg, id) {
147
+ let files;
148
+ try {
149
+ files = findSliceFiles(root, cfg ?? loadConfig(root));
150
+ } catch {
151
+ return LOOP_ROUNDS;
152
+ }
153
+ for (const f of files) {
154
+ let parsed;
155
+ try {
156
+ parsed = parseSliceFile(fs.readFileSync(f.path, 'utf8'), f.path);
157
+ } catch {
158
+ continue;
159
+ }
160
+ if (parsed.id === id) return parsed.lane === 'quick' ? QUICK_LOOP_ROUNDS : LOOP_ROUNDS;
161
+ }
162
+ return LOOP_ROUNDS;
163
+ }
164
+
165
+ // The refusal of a round past the in-loop budget.
166
+ const loopSpent = (rounds) =>
167
+ rounds === LOOP_ROUNDS ? 'two review rounds used; the loop stopped (D-18)' : 'one review round used; the loop of a quick slice stopped (D-103)';
168
+
141
169
  // ---- The independent round budget (REQ-2.8, D-101) ----
142
170
 
143
171
  const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -199,11 +227,12 @@ export function stopText(root, cfg, id, number, round, blockers) {
199
227
  const inSessionRoot = (root, name) => path.resolve(root, ...REVIEWS.split('/'), name).split(path.sep).join('/');
200
228
 
201
229
  // The absolute session-root path the next in-loop reviewer writes, `<root>/.slicekit/reviews/<P-S>-r<k>.md`
202
- // with k the slice's verdict count plus one; null once the in-loop rounds are used (D-18). `build pr`
230
+ // with k the slice's verdict count plus one; null once the in-loop rounds are used (D-18; one round
231
+ // for a quick slice, D-103, read from the slice file under `root` unless `rounds` is given). `build pr`
203
232
  // and `build verdict` print it so the procedure never computes k.
204
- export function nextVerdictPath(root, id, verdicts = []) {
233
+ export function nextVerdictPath(root, id, verdicts = [], rounds = loopRounds(root, undefined, id)) {
205
234
  // Once an independent review has given a verdict, the next review is a new session's `review start`.
206
- if (inLoop(verdicts) >= LOOP_ROUNDS || verdicts.some((v) => v.independent)) return null;
235
+ if (inLoop(verdicts) >= rounds || verdicts.some((v) => v.independent)) return null;
207
236
  return inSessionRoot(root, verdictFileName(id, verdicts.length + 1));
208
237
  }
209
238
 
@@ -223,34 +252,35 @@ export function latestVerdictPath(root, verdicts = []) {
223
252
  // there is no in-loop path: the next independent round's path comes from `review start`.
224
253
  const withNextPath = (root, id, result, verdicts, independent) => ({
225
254
  ...result,
226
- verdictPath: !independent && (result.next === 'fix' || result.next === 'ask') ? nextVerdictPath(root, id, verdicts) : null,
255
+ verdictPath: !independent && (result.next === 'fix' || result.next === 'ask') ? nextVerdictPath(root, id, verdicts, result.loopRounds) : null,
227
256
  });
228
257
 
229
258
  // An independent verdict sits outside the in-loop cap (D-18): its blockers ask for a fix while
230
259
  // another independent round is left (`left`, D-101), else `stuck`; without blockers it goes to CI;
231
260
  // its should-haves are the review procedure's to list.
232
- function outcome(k, v, verdicts, independent, left = true) {
261
+ // `rounds` is the slice's in-loop budget (loopRounds), returned as `loopRounds`.
262
+ function outcome(k, v, verdicts, independent, left = true, rounds = LOOP_ROUNDS) {
233
263
  const blockers = v.findings.filter((f) => f.kind === 'blocker').map((f) => f.id);
234
264
  const shouldHaves = v.findings.filter((f) => f.kind === 'should-have').map((f) => f.id);
235
265
  const roundsUsed = inLoop(verdicts);
236
266
  let next = 'ci';
237
- if (blockers.length > 0) next = (independent ? left : roundsUsed < LOOP_ROUNDS) ? 'fix' : 'stuck';
267
+ if (blockers.length > 0) next = (independent ? left : roundsUsed < rounds) ? 'fix' : 'stuck';
238
268
  else if (shouldHaves.length > 0 && !independent) next = 'ask';
239
- return { round: k, blockers, shouldHaves, roundsUsed, next };
269
+ return { round: k, blockers, shouldHaves, roundsUsed, loopRounds: rounds, next };
240
270
  }
241
271
 
242
272
  // The independent outcome with what a person needs (D-101): on `fix`, `reviewStart`, the command of
243
273
  // the next independent round; on `stuck`, `stop`, the open blockers and the three choices.
244
- function independentOutcome(root, cfg, id, number, k, v, verdicts) {
274
+ function independentOutcome(root, cfg, id, number, k, v, verdicts, rounds) {
245
275
  const left = independentRoundAllowed(independentBlockers(verdicts), extraRounds(root, cfg, id));
246
- const result = outcome(k, v, verdicts, true, left);
276
+ const result = outcome(k, v, verdicts, true, left, rounds);
247
277
  if (result.next === 'fix') return { ...result, reviewStart: `slicekit review start ${number}` };
248
278
  if (result.next === 'stuck') return { ...result, stop: stopText(root, cfg, id, number, k, v.findings.filter((f) => f.kind === 'blocker')) };
249
279
  return result;
250
280
  }
251
281
 
252
- const outcomeOf = (root, cfg, id, number, k, v, verdicts, independent) =>
253
- independent ? independentOutcome(root, cfg, id, number, k, v, verdicts) : outcome(k, v, verdicts, false);
282
+ const outcomeOf = (root, cfg, id, number, k, v, verdicts, independent, rounds = LOOP_ROUNDS) =>
283
+ independent ? independentOutcome(root, cfg, id, number, k, v, verdicts, rounds) : outcome(k, v, verdicts, false, true, rounds);
254
284
 
255
285
  const push = (wt, cfg) => pushBranch(wt, { protectedBranches: cfg.protectedBranches, defaultBranch: cfg.defaultBranch });
256
286
 
@@ -444,6 +474,8 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
444
474
 
445
475
  const current = readSlice(wt, cfg, id);
446
476
  const verdicts = current.verdicts ?? [];
477
+ // The in-loop budget, from the slice file in the worktree (REQ-2.5, D-103).
478
+ const rounds = loopRounds(wt, cfg, id);
447
479
 
448
480
  // The building session never approves itself through its own worktree: an independent verdict is
449
481
  // recorded only in the review worktree `review start` makes, decided by its path and its branch
@@ -475,12 +507,12 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
475
507
  fs.rmSync(src);
476
508
  }
477
509
  const v = checked(text, rel, name, independent);
478
- const result = outcomeOf(root, cfg, id, current.pr.number, k, v, verdicts, independent);
510
+ const result = outcomeOf(root, cfg, id, current.pr.number, k, v, verdicts, independent, rounds);
479
511
  return withNextPath(root, id, finish(wt, cfg, host, id, current, result, verdicts, independent), verdicts, independent);
480
512
  }
481
513
 
482
- // D-18: two in-loop rounds; independent verdicts (D-39) do not count against them.
483
- if (!independent && inLoop(verdicts) >= LOOP_ROUNDS) throw new BuildError('two review rounds used; the loop stopped (D-18)');
514
+ // D-18: two in-loop rounds, one for a quick slice (D-103); independent verdicts (D-39) do not count against them.
515
+ if (!independent && inLoop(verdicts) >= rounds) throw new BuildError(loopSpent(rounds));
484
516
 
485
517
  const from = fromStates(independent);
486
518
  if (!from.includes(current.state)) {
@@ -500,7 +532,7 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
500
532
  if (unknown.length > 0) throw new BuildError(unknown.join('\n'));
501
533
  // The line this round would write, judged against the live body before anything moves.
502
534
  const blockerCount = v.findings.filter((f) => f.kind === 'blocker').length;
503
- const stuck = outcomeOf(root, cfg, id, current.pr.number, k, v, [...verdicts, { round: k, independent, blockers: blockerCount }], independent).next === 'stuck';
535
+ const stuck = outcomeOf(root, cfg, id, current.pr.number, k, v, [...verdicts, { round: k, independent, blockers: blockerCount }], independent, rounds).next === 'stuck';
504
536
  const line = reviewerBlocked([...parsedVerdicts(wt, verdicts), { round: k, findings: v.findings, headSha: current.pr.headSha, independent }], {
505
537
  stuck,
506
538
  covers: coversIn(wt),
@@ -514,6 +546,6 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
514
546
  else if (here) move(src, dest);
515
547
  commitBookkeeping(wt, id, `verdict r${k}`, [rel]);
516
548
  const state = recordState(wt, cfg, id, 'in-review', { verdict: { round: k, path: rel, blockers: blockerCount, independent } });
517
- const result = outcomeOf(root, cfg, id, state.pr.number, k, v, state.verdicts, independent);
549
+ const result = outcomeOf(root, cfg, id, state.pr.number, k, v, state.verdicts, independent, rounds);
518
550
  return withNextPath(root, id, finish(wt, cfg, host, id, state, result, state.verdicts, independent), state.verdicts, independent);
519
551
  }
@@ -0,0 +1,100 @@
1
+ // lane (03 REQ-3.7, REQ-1.5, D-103): a slice marked `lane: quick` changes no file under `src/`, `bin/`
2
+ // or `templates/`. Two findings, each naming the slice and the path:
3
+ //
4
+ // - a quick slice file whose `## Expected changes` names a path in one of those folders, at that
5
+ // path's line of the slice file;
6
+ // - on the quick slice's own branch, a file in one of those folders that the branch changes against
7
+ // the default branch. The changes are read from git objects (the merge base with the default branch
8
+ // against the tip judged, as the frozen rule reads them), never the working tree, so a change merged
9
+ // in from the default branch is not the slice's.
10
+ //
11
+ // A slice with no lane is never a finding. A slice file that does not parse is the citations rule's
12
+ // to report.
13
+ import path from 'node:path';
14
+ import { GitError, git } from '../../git.js';
15
+ import { readText } from '../../fs.js';
16
+ import { sliceFromBranch } from '../../ids.js';
17
+ import { lines } from '../../markdown.js';
18
+ import { mergeBase } from '../../runbook.js';
19
+ import { findSliceFiles, parseSliceFile } from '../../slicefile.js';
20
+ import { branchTip } from '../ci-event.js';
21
+
22
+ export const id = 'lane';
23
+ export const blocking = true;
24
+ export const ratchet = false;
25
+
26
+ export const CODE_FOLDERS = ['src', 'bin', 'templates'];
27
+
28
+ const posixRel = (root, abs) => path.relative(root, abs).split(path.sep).join('/');
29
+
30
+ // True when `p`, a repository path, is one of the code folders or lies under one.
31
+ export function reachesCode(p) {
32
+ const clean = String(p).trim().replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, '');
33
+ const first = clean.split('/')[0];
34
+ return CODE_FOLDERS.includes(first);
35
+ }
36
+
37
+ // Every quick slice file in the working tree: [{ rel, parsed, text }].
38
+ function quickSlices(root, cfg) {
39
+ const out = [];
40
+ for (const f of findSliceFiles(root, cfg)) {
41
+ let text;
42
+ let parsed;
43
+ try {
44
+ text = readText(f.path);
45
+ parsed = parseSliceFile(text, f.path);
46
+ } catch {
47
+ continue;
48
+ }
49
+ if (parsed.lane === 'quick') out.push({ rel: posixRel(root, f.path), parsed, text });
50
+ }
51
+ return out;
52
+ }
53
+
54
+ // The paths the branch at `tip` changes against the default branch, or null when the merge base
55
+ // cannot be read.
56
+ function branchChanges(root, cfg, tip) {
57
+ let base;
58
+ try {
59
+ base = mergeBase(root, cfg, tip);
60
+ } catch (e) {
61
+ if (e instanceof GitError) return null;
62
+ throw e;
63
+ }
64
+ const out = git(root, ['--literal-pathspecs', 'diff', '--name-only', '--no-renames', base, tip]);
65
+ return out.split('\n').filter((l) => l !== '');
66
+ }
67
+
68
+ export function run(ctx) {
69
+ const { root, cfg } = ctx;
70
+ const quick = quickSlices(root, cfg);
71
+ if (quick.length === 0) return [];
72
+ const findings = [];
73
+ for (const s of quick) {
74
+ s.parsed.expectedChanges.forEach((p, i) => {
75
+ if (!reachesCode(p)) return;
76
+ findings.push({
77
+ file: s.rel,
78
+ line: s.parsed.expectedChangeLines[i] ?? 0,
79
+ message: `${s.parsed.id} is marked lane: quick but its expected changes name ${p}, under ${CODE_FOLDERS.map((d) => `${d}/`).join(', ')} (D-103)`,
80
+ });
81
+ });
82
+ }
83
+
84
+ const at = branchTip(ctx);
85
+ const slice = at ? sliceFromBranch(at.branch) : null;
86
+ const mine = slice ? quick.find((s) => s.parsed.id === slice) : undefined;
87
+ if (!mine) return findings;
88
+ const laneLine = lines(mine.text).findIndex((l) => /^lane\s*:/.test(l)) + 1;
89
+ const changed = branchChanges(root, cfg, at.tip);
90
+ if (changed === null) {
91
+ findings.push({ file: mine.rel, line: laneLine, message: `${slice} is marked lane: quick and the branch's changes against ${cfg.defaultBranch} cannot be read; fetch ${cfg.defaultBranch}` });
92
+ return findings;
93
+ }
94
+ for (const p of changed.filter(reachesCode)) {
95
+ findings.push({ file: mine.rel, line: laneLine, message: `${slice} is marked lane: quick but its branch changes ${p}, under ${CODE_FOLDERS.map((d) => `${d}/`).join(', ')} (D-103)` });
96
+ }
97
+ return findings;
98
+ }
99
+
100
+ export default { id, blocking, ratchet, run };
package/src/cli/build.js CHANGED
@@ -171,8 +171,10 @@ function verdictStep(root, io, positionals, values) {
171
171
  independent: Boolean(values.independent),
172
172
  });
173
173
  const list = (ids) => (ids.length > 0 ? ids.join(', ') : 'none');
174
- const out = [`next: ${r.next}`, `blockers: ${list(r.blockers)}`, `should-haves: ${list(r.shouldHaves)}`, `rounds: ${r.roundsUsed} of ${LOOP_ROUNDS}`];
175
- if (r.next === 'ask' && r.roundsUsed >= LOOP_ROUNDS) out.push('fix: not available after round 2; decline or leave for the independent review');
174
+ // The slice's in-loop budget: two, one for a quick slice (D-103).
175
+ const rounds = r.loopRounds ?? LOOP_ROUNDS;
176
+ const out = [`next: ${r.next}`, `blockers: ${list(r.blockers)}`, `should-haves: ${list(r.shouldHaves)}`, `rounds: ${r.roundsUsed} of ${rounds}`];
177
+ if (r.next === 'ask' && r.roundsUsed >= rounds) out.push(`fix: not available after round ${rounds}; decline or leave for the independent review`);
176
178
  if (r.verdictPath) out.push(`verdict ${r.verdictPath}`);
177
179
  // D-101: the command of the next independent round, when one is left after a blocker.
178
180
  if (r.reviewStart) out.push(`review: ${r.reviewStart}`);
package/src/cli/index.js CHANGED
@@ -21,6 +21,7 @@ import { intakeCommand } from './intake.js';
21
21
  import { prCommand } from './pr.js';
22
22
  import { instructionsCommand } from './instructions.js';
23
23
  import { journalCommand } from './journal.js';
24
+ import { nextCommand } from './next.js';
24
25
  import { opsCommand } from './ops.js';
25
26
  import { planCommand } from './plan.js';
26
27
  import { hookCommand } from './hook.js';
@@ -58,6 +59,7 @@ export const COMMANDS = {
58
59
  instructions: instructionsCommand,
59
60
  hook: hookCommand,
60
61
  journal: journalCommand,
62
+ next: nextCommand,
61
63
  ops: opsCommand,
62
64
  plan: planCommand,
63
65
  pr: prCommand,
@@ -131,17 +133,21 @@ export async function main(argv, io) {
131
133
  // branch or a slice's review branch (writesMigration), and `slicekit branch` of every kind, which
132
134
  // refuses a changed tracked file; the branch is cut first and the next command writes on it. A
133
135
  // migration an earlier command already wrote is carried by `slicekit branch` itself (D-94).
136
+ // `slicekit next` writes no file anywhere (REQ-2.16, P8/S-62): it reads the config migrated too.
134
137
  if (command !== COMMANDS.hook && typeof io.cwd === 'string') {
135
138
  try {
136
139
  // The branch is asked about only when the config is older, so a current one costs no git call.
137
140
  const older = migrateConfigFile(io.cwd, { write: false });
138
141
  const here = older !== null && writesMigration(io.cwd);
139
- const write = here && command !== COMMANDS.branch;
142
+ const write = here && command !== COMMANDS.branch && command !== COMMANDS.next;
140
143
  const migrated = write ? migrateConfigFile(io.cwd) : older;
141
144
  if (migrated && !write) {
142
- const where = here
143
- ? 'slicekit branch writes nothing, and the next command writes it on the branch it runs on'
144
- : 'it is migrated on the default branch or on a plan branch';
145
+ const where =
146
+ command === COMMANDS.next
147
+ ? 'slicekit next writes nothing, and the next command that writes migrates it'
148
+ : here
149
+ ? 'slicekit branch writes nothing, and the next command writes it on the branch it runs on'
150
+ : 'it is migrated on the default branch or on a plan branch';
145
151
  io.stderr(`config: ${CONFIG_FILE} is at configVersion ${migrated.from} and is read as ${migrated.to} here, unwritten; ${where}
146
152
  `);
147
153
  } else if (migrated) {
@@ -0,0 +1,29 @@
1
+ // `slicekit next` (REQ-2.16, D-104): prints the one next step on its first line and the command that
2
+ // runs it on its second. It reads files only, writes none and asks no git host; a step that is a
3
+ // person's (a merge, a publish, an Open decision row, the review budget stop) is printed for the
4
+ // person and exits 0 like any other step.
5
+ import { ConfigError, loadConfig } from '../config.js';
6
+ import { SliceFileError } from '../slicefile.js';
7
+ import { nextStep, stepLines } from '../next.js';
8
+
9
+ const USAGE = 'next';
10
+
11
+ async function run(args, io) {
12
+ if (args.length > 0) {
13
+ io.stderr(`slicekit: next takes no arguments\nusage: slicekit ${USAGE}\n`);
14
+ return 2;
15
+ }
16
+ try {
17
+ const step = nextStep(io.cwd, loadConfig(io.cwd));
18
+ io.stdout(`${stepLines(step).join('\n')}\n`);
19
+ return 0;
20
+ } catch (e) {
21
+ if (e instanceof ConfigError || e instanceof SliceFileError) {
22
+ io.stderr(`slicekit: ${e.message}\n`);
23
+ return 2;
24
+ }
25
+ throw e;
26
+ }
27
+ }
28
+
29
+ export const nextCommand = { run, usage: USAGE };
@@ -16,7 +16,7 @@ import { kitPaths } from './paths.js';
16
16
  import { findSliceFiles } from './slicefile.js';
17
17
  import { reqBlocks } from './stage.js';
18
18
 
19
- export const PROCEDURES = ['brief', 'intake','specify', 'gaps', 'plan', 'build', 'review', 'release', 'ops', 'audit'];
19
+ export const PROCEDURES = ['brief', 'intake','specify', 'gaps', 'plan', 'build', 'review', 'release', 'ops', 'audit', 'next'];
20
20
  export const TEMPLATES = fileURLToPath(new URL('../templates/instructions', import.meta.url));
21
21
 
22
22
  const KIT_SKILL = fileURLToPath(new URL('../templates/claude-code/skills/slicekit-writing/SKILL.md', import.meta.url));
package/src/next.js ADDED
@@ -0,0 +1,283 @@
1
+ // The one next step of the program (REQ-2.16, D-104, D-101). Read from files only: the stage files
2
+ // programStage reads, `.slicekit/state/` (a slice's worktree copy while it is being built), the slice
3
+ // files, the verdict files and `decisions.md`. Nothing is written and no git host is asked. A step is
4
+ // `{ step, command, more, person }`: the step on the first line, the command that runs it on the
5
+ // second, any further lines after them. `person` marks a step only a person takes (a merge, a
6
+ // publish, an Open decision row, the review budget stop): the command is printed for the person and
7
+ // nothing runs it.
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import { readDecisions } from './decisions.js';
11
+ import { exists, readText } from './fs.js';
12
+ import { currentBranch, git, isRepo } from './git.js';
13
+ import { parseSliceAddr, sliceFromBranch, stateFileName } from './ids.js';
14
+ import { kitPaths } from './paths.js';
15
+ import { findSliceFiles, parseSliceFile } from './slicefile.js';
16
+ import { programStage } from './stage.js';
17
+ import { readSlice } from './state/index.js';
18
+ import { STATES, independentProblem, verdictsOnHead } from './state/transitions.js';
19
+ import { parseVerdict } from './verdict.js';
20
+ import { REVIEW_DESCR, reviewWorktreeDir, worktreeDir } from './worktrees.js';
21
+ import { sliceSteps } from './build/order.js';
22
+ import { LOOP_ROUNDS, QUICK_LOOP_ROUNDS, STOP_CHOICES, independentBlockers, independentRoundAllowed, independentVerdictPath, nextVerdictPath } from './build/verdict.js';
23
+
24
+ const DONE = ['merged', 'released'];
25
+ const posix = (p) => p.split(path.sep).join('/');
26
+ const rel = (root, p) => posix(path.relative(root, p));
27
+
28
+ // The slash command of each stage before the build, as stage.js names them.
29
+ const STAGE_COMMANDS = {
30
+ intake: '/slicekit intake',
31
+ clarify: '/slicekit intake',
32
+ specify: '/slicekit specify',
33
+ 'spec-review': '/slicekit specify',
34
+ 'gap-scan': '/slicekit gaps',
35
+ stack: '/slicekit plan',
36
+ plan: '/slicekit plan',
37
+ };
38
+
39
+ const person = (step, command, more = []) => ({ step, command: `person: ${command}`, more, person: true });
40
+ const agent = (step, command, more = []) => ({ step, command, more, person: false });
41
+
42
+ // The decision rows of `decisions.md` as the file holds them; none when it is missing.
43
+ function decisionRows(root, cfg) {
44
+ const file = kitPaths(root, cfg).decisions;
45
+ return exists(file) ? readDecisions(readText(file)).rows : [];
46
+ }
47
+
48
+ // The settled rows that allow `id` one more independent round (D-101), read from the file on disk.
49
+ function extraRounds(rows, id) {
50
+ const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
51
+ const names = new RegExp(`(?<![\\w/])${escaped}(?!\\d)`);
52
+ return rows.filter((r) => r.table === 'settled' && names.test(r.answer) && /\bone more round\b/i.test(r.answer)).length;
53
+ }
54
+
55
+ // The command a person merges pull request `n` with: the GitHub CLI's on a GitHub host.
56
+ const mergeCommand = (cfg, n) => (cfg.gitHost?.kind === 'github' ? `gh pr merge ${n}` : `merge pull request #${n} on the git host`);
57
+
58
+ // The state file of slice `id` at the tip of its branch as git holds it: the local branch, else
59
+ // `origin/<branch>`, read with `git show` only. Null when neither holds the file or this is no repository.
60
+ function stateOnBranch(root, cfg, id, branch) {
61
+ if (!branch || !isRepo(root)) return null;
62
+ const rel = posix(path.relative(root, path.join(kitPaths(root, cfg).state, stateFileName(id))));
63
+ for (const ref of [`refs/heads/${branch}`, `refs/remotes/origin/${branch}`]) {
64
+ try {
65
+ return JSON.parse(git(root, ['show', `${ref}:${rel}`]));
66
+ } catch {
67
+ // No such ref or file there, or not valid JSON: the next place is read.
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+
73
+ // The state file of slice `id` under `dir`, or null when it is missing or not valid JSON.
74
+ function stateIn(cfg, id, dir) {
75
+ const file = path.join(kitPaths(dir, cfg).state, stateFileName(id));
76
+ if (!exists(file)) return null;
77
+ try {
78
+ return JSON.parse(readText(file));
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+
84
+ // The state of slice `id`: the most advanced of the checkout's state file, the build worktree's, the
85
+ // review worktree's and the one at the slice branch's tip, since the build commits its moves on the
86
+ // slice branch and the independent round records in the review worktree (D-39). The most advanced
87
+ // has the most verdicts, then the longest history, then the latest state in the state order: the
88
+ // order alone puts a `changes-requested` after an independent round behind the `ci-green` it
89
+ // followed. The checkout's wins once it records a merge or a release.
90
+ function sliceState(root, cfg, id, wt, reviewWt) {
91
+ const here = readSlice(root, cfg, id);
92
+ if (DONE.includes(here.state)) return here;
93
+ const found = [stateIn(cfg, id, wt), stateIn(cfg, id, reviewWt)].filter((s) => s && typeof s === 'object');
94
+ const branch = [here, ...found].map((s) => s.branch).find((b) => typeof b === 'string' && b !== '' && !b.endsWith(`-${REVIEW_DESCR}`));
95
+ const onBranch = stateOnBranch(root, cfg, id, branch);
96
+ if (onBranch && typeof onBranch === 'object') found.push(onBranch);
97
+ const count = (list) => (Array.isArray(list) ? list.length : 0);
98
+ const rank = (s) => [count(s.verdicts), count(s.history), STATES.indexOf(s.state)];
99
+ const ahead = (a, b) => {
100
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return a[i] > b[i];
101
+ return true;
102
+ };
103
+ let best = here;
104
+ for (const s of found) if (ahead(rank(s), rank(best))) best = s;
105
+ return best === here ? here : { ...here, ...best };
106
+ }
107
+
108
+ // The blocker IDs of the latest verdict, read from its file in the build worktree, the review
109
+ // worktree or the checkout; an
110
+ // empty list when neither holds it.
111
+ function latestBlockers(root, wt, verdict, reviewWt) {
112
+ if (!verdict?.path) return [];
113
+ for (const base of [wt, reviewWt, root]) {
114
+ const file = path.join(base, ...verdict.path.split('/'));
115
+ if (!exists(file)) continue;
116
+ return parseVerdict(readText(file), verdict.path)
117
+ .findings.filter((f) => f.kind === 'blocker')
118
+ .map((f) => f.id);
119
+ }
120
+ return [];
121
+ }
122
+
123
+ const choicesFor = (id, n, decisions) =>
124
+ STOP_CHOICES.map((c, i) => `${i + 1}. ${c.replaceAll('<id>', id).replaceAll('<n>', String(n)).replaceAll('<decisions>', decisions)}`);
125
+
126
+ // The step a slice's state calls for.
127
+ function sliceStep(root, cfg, slice, rows) {
128
+ const { id } = slice;
129
+ const addr = parseSliceAddr(id);
130
+ // Run inside a worktree under `.worktrees`, the slice's worktrees are found beside it, under the
131
+ // main checkout.
132
+ const main = path.basename(path.dirname(root)) === '.worktrees' ? path.dirname(path.dirname(root)) : root;
133
+ const wtAbs = worktreeDir(main, addr);
134
+ const reviewAbs = reviewWorktreeDir(main, addr);
135
+ const wt = posix(wtAbs);
136
+ const reviewWt = posix(reviewAbs);
137
+ const cli = cfg.cli ?? 'slicekit';
138
+ const s = sliceState(root, cfg, id, wtAbs, reviewAbs);
139
+ const n = s.pr?.number ?? null;
140
+ const verdicts = s.verdicts ?? [];
141
+ const rounds = slice.lane === 'quick' ? QUICK_LOOP_ROUNDS : LOOP_ROUNDS;
142
+ const inLoop = verdicts.filter((v) => !v.independent).length;
143
+ const decisions = rel(root, kitPaths(root, cfg).decisions);
144
+ // What follows `review start` in the same step (D-104): the independent reviewer, then its verdict
145
+ // recorded from the review worktree.
146
+ const reviewThen = [
147
+ `then: ${cli} instructions reviewer ${id} --worktree ${reviewWt}`,
148
+ `then: ${cli} build verdict ${id} ${independentVerdictPath(main, id, verdicts)} --independent --worktree ${reviewWt}`,
149
+ ];
150
+
151
+ // An Open row the slice cites holds its build back until a person settles it.
152
+ const open = new Set(rows.filter((r) => r.table === 'open').map((r) => r.id));
153
+ const waiting = slice.decisions.filter((d) => open.has(d));
154
+ if (['todo', 'tests-red', 'building'].includes(s.state) && waiting.length > 0) {
155
+ return person(
156
+ `${id} waits on ${waiting.join(', ')}, Open in ${decisions}: a person answers ${waiting.length === 1 ? 'it' : 'each'} before the build goes on`,
157
+ `${cli} decide settle ${waiting[0]} --answer "<answer>"`,
158
+ );
159
+ }
160
+
161
+ switch (s.state) {
162
+ case 'todo':
163
+ if (!fs.existsSync(wtAbs)) return agent(`${id} is todo: start its build (/slicekit build, step 1)`, `${cli} build start ${id}`);
164
+ return agent(
165
+ `${id} is todo in ${wt}: the developer writes the evaluation set's tests, then build red (/slicekit build, steps 2 and 3)`,
166
+ `${cli} instructions developer ${id} --worktree ${wt}`,
167
+ );
168
+ case 'tests-red': {
169
+ const tests = [...new Set((s.frozenTests ?? []).map((t) => (typeof t === 'string' ? t : t.file)))];
170
+ return agent(
171
+ `${id} is tests-red: build red records the failing tests and moves it to building (/slicekit build, step 3)`,
172
+ `${cli} build red ${id} --tests ${tests.join(',') || '<a>,<b>'} --worktree ${wt}`,
173
+ );
174
+ }
175
+ case 'building':
176
+ return agent(
177
+ `${id} is building: the developer makes the tests pass, then build commit --require-green and build pr (/slicekit build, steps 4 and 5)`,
178
+ `${cli} instructions developer ${id} --worktree ${wt}`,
179
+ );
180
+ case 'draft-pr': {
181
+ const next = nextVerdictPath(root, id, verdicts, rounds);
182
+ if (next) {
183
+ return agent(
184
+ `${id} is draft-pr on #${n}: the reviewer gives the round ${verdicts.length + 1} verdict, then build verdict records it (/slicekit build, step 6)`,
185
+ `${cli} instructions reviewer ${id} --worktree ${wt}`,
186
+ [`then: ${cli} build verdict ${id} ${next} --worktree ${wt}`],
187
+ );
188
+ }
189
+ return agent(
190
+ `${id} is draft-pr on #${n}: the independent review, from a reviewer started in the main checkout (/slicekit review)`,
191
+ `${cli} review start ${n}`,
192
+ reviewThen,
193
+ );
194
+ }
195
+ case 'in-review':
196
+ return agent(`${id} is in-review on #${n}: wait for green CI and mark the pull request ready (/slicekit build, step 9)`, `${cli} build finish ${id} --worktree ${wt}`);
197
+ case 'changes-requested': {
198
+ const latest = verdicts.at(-1);
199
+ const blockers = latestBlockers(root, wt, latest, reviewWt);
200
+ const named = blockers.length > 0 ? ` ${blockers.join(', ')}` : '';
201
+ if (latest?.independent) {
202
+ if (independentRoundAllowed(independentBlockers(verdicts), extraRounds(rows, id))) {
203
+ return agent(
204
+ `${id} has open blockers${named} on #${n}: the fixer answers them, then build commit and build pr, then the next independent round (/slicekit review)`,
205
+ `${cli} instructions fixer ${id} --worktree ${wt}`,
206
+ [`then: ${cli} review start ${n}`],
207
+ );
208
+ }
209
+ return person(`${id} has open blockers${named} on #${n} and no independent round is left (D-101): a person chooses one of three`, `choose one:`, choicesFor(id, n, decisions));
210
+ }
211
+ if (inLoop < rounds) {
212
+ return agent(
213
+ `${id} has open blockers${named} on #${n}: the fixer answers them, then build commit and build pr open the round ${verdicts.length + 1} review (/slicekit build, step 7)`,
214
+ `${cli} instructions fixer ${id} --worktree ${wt}`,
215
+ );
216
+ }
217
+ return person(`${id} has open blockers${named} on #${n} after the in-loop review rounds: a person chooses one of three`, `choose one:`, [
218
+ `1. fix the open blockers by hand in ${wt} and push them with ${cli} build pr ${id}`,
219
+ '2. re-scope the slice: amend the slice file so the blockers fall outside it, or move them to a new slice',
220
+ `3. start the independent review: ${cli} review start ${n}`,
221
+ ]);
222
+ }
223
+ case 'ci-green': {
224
+ const problem = independentProblem(verdictsOnHead(s));
225
+ if (problem && cfg.review?.independent !== 'optional') {
226
+ return agent(`${id} is ci-green on #${n}, ${problem}: the independent review, from a reviewer started in the main checkout (/slicekit review)`, `${cli} review start ${n}`, reviewThen);
227
+ }
228
+ return agent(`${id} is ci-green on #${n}: build finish marks it ready`, `${cli} build finish ${id} --worktree ${wt}`);
229
+ }
230
+ case 'ready':
231
+ return person(`${id} is ready: a person merges pull request #${n}`, mergeCommand(cfg, n), [`then: ${cli} status --sync records the merge`]);
232
+ default:
233
+ return agent(`${id} is ${s.state}`, `${cli} status`);
234
+ }
235
+ }
236
+
237
+ // The slices in phase and Order-step order, each with its parsed slice file.
238
+ function orderedSlices(root, cfg) {
239
+ const files = new Map();
240
+ for (const f of findSliceFiles(root, cfg)) {
241
+ const slice = parseSliceFile(readText(f.path), f.path);
242
+ files.set(slice.id, slice);
243
+ }
244
+ const steps = [...sliceSteps(root, cfg)].map(([id, s], i) => ({ id, ...s, i }));
245
+ steps.sort((a, b) => Number(a.phase.slice(1)) - Number(b.phase.slice(1)) || a.step - b.step || a.i - b.i);
246
+ return steps.map((s) => files.get(s.id));
247
+ }
248
+
249
+ export function nextStep(root, cfg) {
250
+ const cli = cfg.cli ?? 'slicekit';
251
+ const rows = decisionRows(root, cfg);
252
+ // On a slice branch the branch's own changes under docs/ (an amended slice file) are not a spec or
253
+ // plan pull request waiting to merge: the stages are judged as the default branch has them.
254
+ const branch = isRepo(root) ? currentBranch(root) : null;
255
+ const asDefaultBranch = branch !== null && sliceFromBranch(branch) !== null;
256
+ const before = programStage(root, cfg, { upTo: 'plan', asDefaultBranch });
257
+ if (!before.complete) {
258
+ const blocker = before.blockers[0];
259
+ const openRow = /^(D-\d+) is Open/.exec(blocker);
260
+ if (openRow) return person(`${before.stage}: ${blocker}: a person answers it`, `${cli} decide settle ${openRow[1]} --answer "<answer>"`);
261
+ if (/merge the pull request/.test(blocker)) {
262
+ return person(`${before.stage}: ${blocker}: a person merges that pull request`, `merge the ${before.stage === 'plan' ? 'plan' : 'spec'} pull request on the git host`, [`then: ${cli} stage require ${before.stage}`]);
263
+ }
264
+ return agent(`${before.stage} not done: ${blocker}`, STAGE_COMMANDS[before.stage]);
265
+ }
266
+ for (const slice of orderedSlices(root, cfg)) {
267
+ const s = readSlice(root, cfg, slice.id);
268
+ if (DONE.includes(s.state)) continue;
269
+ return sliceStep(root, cfg, slice, rows);
270
+ }
271
+ const all = programStage(root, cfg, { asDefaultBranch });
272
+ if (!all.complete) {
273
+ const phase = /^(P\d+) has no releases/.exec(all.blockers[0]);
274
+ if (phase) return agent(`${phase[1]}: every slice is merged; write its release record and open the release pull request`, `/slicekit release ${phase[1]}`);
275
+ return agent(`${all.stage} not done: ${all.blockers[0]}`, `${cli} stage require ${all.stage}`);
276
+ }
277
+ return person('every phase is released: a publish, when the team makes one, is approved by a person', 'approve the publish in the team\'s release workflow', [
278
+ 'slicekit next approves no publish and pushes nothing',
279
+ ]);
280
+ }
281
+
282
+ // The step's lines, the step first and its command second.
283
+ export const stepLines = (s) => [s.step, s.command, ...s.more];
package/src/slicefile.js CHANGED
@@ -16,6 +16,7 @@ export class SliceFileError extends Error {
16
16
  const KINDS = ['happy', 'negative', 'e2e'];
17
17
  const SCALARS = ['slice', 'name', 'repo', 'group', 'runbook'];
18
18
  const LISTS = ['requirements', 'decisions'];
19
+ const LANES = ['quick'];
19
20
 
20
21
  // The text under the first `## <title>` heading, up to the next level-2 heading.
21
22
  function section(body, title) {
@@ -67,6 +68,12 @@ export function parseSliceFile(text, file) {
67
68
  if (!['yes', 'true', 'no', 'false'].includes(rb)) {
68
69
  fail(`front-matter field "runbook" must be yes or no, got "${data.runbook}"`, 'runbook');
69
70
  }
71
+ // The optional lane (REQ-1.5, D-103): absent, or `quick`.
72
+ let lane = null;
73
+ if ('lane' in data && data.lane !== '' && data.lane != null) {
74
+ lane = String(data.lane).trim().toLowerCase();
75
+ if (!LANES.includes(lane)) fail(`front-matter field "lane" must be quick, got "${data.lane}"`, 'lane');
76
+ }
70
77
 
71
78
  const done = section(body, 'Done when');
72
79
  if (done === null) fail('missing section "## Done when"', 'Done when');
@@ -117,6 +124,7 @@ export function parseSliceFile(text, file) {
117
124
  repo: String(data.repo),
118
125
  group: String(data.group),
119
126
  runbook: rb === 'yes' || rb === 'true',
127
+ lane,
120
128
  requirements: asList(data.requirements),
121
129
  decisions: asList(data.decisions),
122
130
  doneWhen,
package/src/stage.js CHANGED
@@ -180,8 +180,11 @@ function specify(root, cfg) {
180
180
  }
181
181
 
182
182
  // A directory counts as merged when nothing in it is untracked or changed and its content equals the default branch's.
183
- // `exclude` lists files under `dir` left out of the comparison.
184
- function unmerged(root, cfg, dir, what, exclude = []) {
183
+ // `exclude` lists files under `dir` left out of the comparison. With `asDefaultBranch` (the checkout
184
+ // is on a slice branch, whose own changes are not a pull request waiting to merge) the directory is
185
+ // judged as the default branch has it, which equals itself: nothing is unmerged.
186
+ function unmerged(root, cfg, dir, what, exclude = [], { asDefaultBranch = false } = {}) {
187
+ if (asDefaultBranch) return [];
185
188
  if (!isRepo(root)) return [`${what} needs a git repository`];
186
189
  if (!hasCommits(root)) return [`${what} needs a commit on ${cfg.defaultBranch}`];
187
190
  const base = cfg.defaultBranch;
@@ -206,9 +209,9 @@ function unmerged(root, cfg, dir, what, exclude = []) {
206
209
 
207
210
  // The gaps file is written on the gaps branch and stack.md on the plan branch, both after the spec
208
211
  // merges, so this stage leaves them out.
209
- function specReview(root, cfg) {
212
+ function specReview(root, cfg, opts) {
210
213
  const p = kitPaths(root, cfg);
211
- return unmerged(root, cfg, p.spec, 'spec review', [p.gaps, p.stack]);
214
+ return unmerged(root, cfg, p.spec, 'spec review', [p.gaps, p.stack], opts);
212
215
  }
213
216
 
214
217
  // The line `gaps scan` writes into the gaps file. Without it the gap scan has not run, whatever the
@@ -265,7 +268,7 @@ function readSlices(root, cfg) {
265
268
  return { slices, errors };
266
269
  }
267
270
 
268
- function plan(root, cfg) {
271
+ function plan(root, cfg, opts) {
269
272
  const { slices, errors } = readSlices(root, cfg);
270
273
  const named = new Set(slices.flatMap((s) => s.requirements));
271
274
  const ids = [...new Set(reqBlocks(root, cfg).map((r) => r.id))];
@@ -273,7 +276,7 @@ function plan(root, cfg) {
273
276
  ...errors,
274
277
  ...ids.filter((id) => !named.has(id)).map((id) => `${id} is named by no slice file`),
275
278
  ];
276
- return [...blockers, ...unmerged(root, cfg, kitPaths(root, cfg).phases, 'plan review')];
279
+ return [...blockers, ...unmerged(root, cfg, kitPaths(root, cfg).phases, 'plan review', [], opts)];
277
280
  }
278
281
 
279
282
  function build(root, cfg) {
@@ -328,7 +331,8 @@ export function briefStage(root, cfg) {
328
331
  const CHECKS = { intake, clarify, specify, 'spec-review': specReview, 'gap-scan': gapScan, stack, plan, build, release };
329
332
 
330
333
  // Evaluates the stages in order and stops after `upTo` (default: all), so later stages cost nothing.
331
- export function programStage(root, cfg, { upTo = 'release' } = {}) {
334
+ // `asDefaultBranch` judges the spec and plan reviews as the default branch has them (see unmerged).
335
+ export function programStage(root, cfg, { upTo = 'release', asDefaultBranch = false } = {}) {
332
336
  const last = STAGES.indexOf(upTo);
333
337
  if (last === -1) throw new Error(`unknown stage ${upTo}`);
334
338
  // A check returns its blockers, or `{blockers, pending}` when it also lists rows that do not
@@ -336,7 +340,7 @@ export function programStage(root, cfg, { upTo = 'release' } = {}) {
336
340
  const pending = [];
337
341
  const result = (r) => (pending.length > 0 ? { ...r, pending } : r);
338
342
  for (const stage of STAGES.slice(0, last + 1)) {
339
- const out = CHECKS[stage](root, cfg);
343
+ const out = CHECKS[stage](root, cfg, { asDefaultBranch });
340
344
  const blockers = Array.isArray(out) ? out : out.blockers;
341
345
  if (!Array.isArray(out)) pending.push(...out.pending);
342
346
  if (blockers.length > 0) return result({ stage, complete: false, blockers });
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Run the one next step of the program that slicekit next prints, then stop. Under /loop, one step per iteration.
3
+ argument-hint: ""
4
+ ---
5
+ Run `{{cli}} instructions --command next $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
6
+
7
+ Writing rules: `.claude/skills/slicekit-writing/SKILL.md`.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Run a slicekit command: brief, intake, specify, gaps, plan, build, review, release, ops or audit. /slicekit <command> [args]"
2
+ description: "Run a slicekit command: brief, intake, specify, gaps, plan, build, review, release, ops, audit or next. /slicekit <command> [args]"
3
3
  argument-hint: "<command> [args]"
4
4
  ---
5
5
  Run `{{cli}} instructions --command $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
@@ -98,6 +98,15 @@
98
98
  "data"
99
99
  ]
100
100
  },
101
+ {
102
+ "src": "commands/slicekit-next.md",
103
+ "dest": ".claude/commands/slicekit-next.md",
104
+ "shapes": [
105
+ "backend",
106
+ "fullstack",
107
+ "data"
108
+ ]
109
+ },
101
110
  {
102
111
  "src": "agents/developer.md",
103
112
  "dest": ".claude/agents/developer.md",
@@ -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). Arguments: {{args}}.
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 round 2. Stop and tell the human.
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
@@ -166,7 +168,8 @@ after `-r` in the verdict file's name) and the verdict path: the `verdict <file>
166
168
 
167
169
  When the reviewer stops, run `{{cli}} build verdict <id> <file> --worktree <path>` with that verdict
168
170
  path. It commits the verdict into the worktree, pushes, and prints `next: <step>`,
169
- `blockers: <IDs or none>`, `should-haves: <IDs or none>` and `rounds: <used> of 2`, and last a new
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
170
173
  `verdict <file>` line when another round is allowed. A refusal that names the verdict's content (a
171
174
  finding with no "How verified", a reused finding number, a banned phrase, a `<!--`, an unknown ID or
172
175
  path) goes back to the reviewer with the printed message; run this command again with the file it writes. A refusal that
@@ -184,7 +187,8 @@ print it and stop. Then act on `next:`:
184
187
  - `next: fix`: step 7.
185
188
  - `next: ask`: step 8.
186
189
  - `next: ci`: step 9.
187
- - `next: stuck`: it exits 1. A blocker survived round 2: the state is `changes-requested` and the
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
188
192
  pull request stays a draft. Print the output and stop; the human decides what happens to the
189
193
  slice.
190
194
 
@@ -223,8 +227,9 @@ which is success too. Then:
223
227
  - with no blockers and should-haves to fix: step 7 for those should-haves alone.
224
228
  - with every should-have declined and no blockers: step 9.
225
229
 
226
- After round 2 no fix is offered: `build verdict` prints
227
- `fix: not available after round 2; decline or leave for the independent review`. Ask only whether
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
228
233
  to decline each should-have or leave it for the independent review, then go to step 9.
229
234
 
230
235
  ## 9. Green CI, then the independent review
@@ -0,0 +1,42 @@
1
+ # /slicekit next
2
+
3
+ Run the one next step of the program, then stop (REQ-2.16). It takes no arguments.
4
+
5
+ `{{cli}} next` reads the state from files only: `.slicekit/state/` (a slice's worktree copy while it
6
+ is being built), the slice files, the verdict files and `decisions.md`. It writes no file and asks
7
+ nothing of the host of the pull requests. Each run is one step, so `/loop /slicekit next` runs one step per iteration, and a step
8
+ resumes after a restart or a compaction: the files say where the program is, and nothing has to be
9
+ remembered from an earlier turn (D-104).
10
+
11
+ ## Steps
12
+
13
+ 1. Run `{{cli}} next`. Its first line is the step; its second line is the command that runs it. Any
14
+ later lines belong to the step: a `then:` line is the command to run once the second line's
15
+ command is done, and a numbered line is one of the choices of a person's step.
16
+ 2. When the second line starts with `person:`, the step is a person's: a merge, the approval of a
17
+ publish, an Open decision row the step depends on, or the review budget stop of REQ-2.8, which
18
+ lists three choices. Print every line `{{cli}} next` printed, tell the human the command after
19
+ `person:` is theirs to run, and stop. Run nothing of it yourself.
20
+ 3. Otherwise run the one command on the second line:
21
+ - A `{{cli}}` command: run it, then each `then:` line in order, in this same iteration. Stop at
22
+ the first that exits non-zero and print what it printed. A `then:` line
23
+ `{{cli}} instructions reviewer <id> --worktree <path>` spawns that reviewer with the output as
24
+ its whole prompt and waits for its verdict file; the `then:` line after it records that
25
+ verdict. After `{{cli}} review start <n>` these lines spawn the independent reviewer and run
26
+ `{{cli}} build verdict <id> <file> --independent` from the review worktree: run them before you
27
+ stop, or the next iteration starts the same review again.
28
+ - `{{cli}} instructions <role> <id> --worktree <path>`: spawn that agent with the output as its
29
+ whole prompt, and take its report through the step of `/slicekit build` that the first line
30
+ names (`{{cli}} instructions --command build` prints that procedure); the first line names the
31
+ step by its number.
32
+ - A slash command such as `/slicekit release P1`: follow the procedure
33
+ `{{cli}} instructions --command <name> <args>` prints.
34
+ 4. Stop. Print the step's first line and the last line its command printed. Do not run
35
+ `{{cli}} next` again in this turn: the next iteration does that.
36
+
37
+ ## What this procedure never does
38
+
39
+ It never merges a pull request, approves a publish or deployment, or pushes with force, and it runs
40
+ no git or gh command itself. When a command it runs refuses with a line that only a person can
41
+ answer (a branch that `has diverged from origin`, a default branch behind origin, a force push),
42
+ print that line and stop: the person decides.
@@ -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 2`; the rounds stay as they were. On `next: fix` it also prints
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