loopwright 0.1.10 → 0.1.11
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 +1 -1
- package/content/hooks/lib.mjs +39 -1
- package/content/hooks/lw.mjs +56 -1
- package/content/hooks/precompact-instructions.mjs +1 -0
- package/content/prompts/reviewer.md +17 -2
- package/content/skills/loopwright-plan/SKILL.md +1 -1
- package/content/skills/loopwright-review/SKILL.md +12 -9
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ flowchart TD
|
|
|
64
64
|
- **Test** (standard, large, and every fix): a tester subagent, which never sees the implementation, writes acceptance tests from your confirmed criteria and locks them.
|
|
65
65
|
- **Build**: an implementer subagent makes the locked tests pass. Small feature tasks skip Test, so the implementer writes the tests; a fix never skips it.
|
|
66
66
|
- **Simplify** (standard, large, and every fix): a read-only reviewer proposes behavior-preserving cuts to the diff, each with its net line change and what it gives up. You choose which to apply; nothing changes without your approval, and you are not asked when there is nothing to cut.
|
|
67
|
-
- **Review**: a reviewer that starts blind runs your checks, confirms the locked tests are untouched, and reports only proven, high-impact findings. Blocking findings send the task back to Build, up to 3 rounds by default; findings it cannot confirm come to you to fix or dismiss.
|
|
67
|
+
- **Review**: a reviewer that starts blind runs your checks, confirms the locked tests are untouched, and reports only proven, high-impact findings. Blocking findings send the task back to Build, up to 3 rounds by default, and after a fix, later rounds check only what changed; findings it cannot confirm come to you to fix or dismiss.
|
|
68
68
|
- **Done**: proposes `AGENTS.md` updates and drafts the commit and PR message. You approve each change; loopwright never commits.
|
|
69
69
|
|
|
70
70
|
Each task's goal, decisions, criteria and review log live in `.loopwright/tasks/<date>-<title>.md`. For the large-tier slice loop, step-by-step Plan and Review charts, and every point where loopwright waits for you, see [Workflow in detail](docs/workflow.md).
|
package/content/hooks/lib.mjs
CHANGED
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
import { execFileSync } from 'node:child_process';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import {
|
|
5
|
+
copyFileSync,
|
|
5
6
|
existsSync,
|
|
6
7
|
lstatSync,
|
|
7
8
|
mkdirSync,
|
|
9
|
+
mkdtempSync,
|
|
8
10
|
readFileSync,
|
|
9
11
|
readlinkSync,
|
|
10
12
|
realpathSync,
|
|
11
13
|
renameSync,
|
|
14
|
+
rmSync,
|
|
15
|
+
statSync,
|
|
16
|
+
utimesSync,
|
|
12
17
|
writeFileSync,
|
|
13
18
|
} from 'node:fs';
|
|
19
|
+
import { tmpdir } from 'node:os';
|
|
14
20
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
15
21
|
import { fileURLToPath } from 'node:url';
|
|
16
22
|
|
|
@@ -18,7 +24,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
18
24
|
export const PROFILES = {
|
|
19
25
|
lean: { scout: 'low', tester: 'low', implementer: 'low', reviewer: 'medium' },
|
|
20
26
|
balanced: { scout: 'medium', tester: 'medium', implementer: 'medium', reviewer: 'high' },
|
|
21
|
-
thorough: { scout: 'high', tester: 'high', implementer: 'high', reviewer: '
|
|
27
|
+
thorough: { scout: 'high', tester: 'high', implementer: 'high', reviewer: 'high' },
|
|
22
28
|
deep: { scout: 'xhigh', tester: 'xhigh', implementer: 'xhigh', reviewer: 'xhigh' },
|
|
23
29
|
};
|
|
24
30
|
|
|
@@ -152,6 +158,38 @@ export function fingerprint(cwd, baseCommit) {
|
|
|
152
158
|
return h.digest('hex');
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
/** Tree id of the working tree as it is now: the files in the user's index (force-added ignored files too) plus
|
|
162
|
+
* untracked files that are not ignored, the same set the fingerprint covers. Built in a temporary index seeded from a
|
|
163
|
+
* copy of the user's index (or HEAD when there is none), so the user's index and working tree are never written. */
|
|
164
|
+
export function workingTree(cwd) {
|
|
165
|
+
const top = gitTopLevel(cwd);
|
|
166
|
+
// A linked worktree's index lives under .git/worktrees/<name>/; git prints the path relative to `top`.
|
|
167
|
+
const userIndex = resolve(top, git(top, ['rev-parse', '--git-path', 'index']));
|
|
168
|
+
const tmp = mkdtempSync(join(tmpdir(), 'lw-index-'));
|
|
169
|
+
const index = join(tmp, 'index');
|
|
170
|
+
const run = (args) =>
|
|
171
|
+
execFileSync('git', args, {
|
|
172
|
+
cwd: top,
|
|
173
|
+
encoding: 'utf8',
|
|
174
|
+
maxBuffer: MAX_BUFFER,
|
|
175
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
176
|
+
env: { ...process.env, GIT_INDEX_FILE: index },
|
|
177
|
+
}).trim();
|
|
178
|
+
try {
|
|
179
|
+
if (existsSync(userIndex)) {
|
|
180
|
+
copyFileSync(userIndex, index);
|
|
181
|
+
// Keep the source mtime: git trusts an entry's stat data unless the entry is as new as the index file
|
|
182
|
+
// (racy check), so a fresh mtime on the copy would hide a same-size edit made just after the entry was written.
|
|
183
|
+
const st = statSync(userIndex);
|
|
184
|
+
utimesSync(index, st.atime, st.mtime);
|
|
185
|
+
} else run(['read-tree', 'HEAD']);
|
|
186
|
+
run(['add', '-A']);
|
|
187
|
+
return run(['write-tree']);
|
|
188
|
+
} finally {
|
|
189
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
155
193
|
/** Hooks call this first: LOOPWRIGHT_HOOKS=off (e.g. a headless cross-agent reviewer) disables them silently. */
|
|
156
194
|
export function exitIfHooksOff() {
|
|
157
195
|
if (process.env.LOOPWRIGHT_HOOKS === 'off') process.exit(0);
|
package/content/hooks/lw.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
repoRelative,
|
|
20
20
|
sha256File,
|
|
21
21
|
statePath,
|
|
22
|
+
workingTree,
|
|
22
23
|
worktreeId,
|
|
23
24
|
writeState,
|
|
24
25
|
} from './lib.mjs';
|
|
@@ -378,6 +379,18 @@ function ownCommits(state) {
|
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
|
|
382
|
+
/** The verdict's snapshot of the reviewed code, while its git tree still exists; else undefined. */
|
|
383
|
+
function usableSnapshot(state) {
|
|
384
|
+
const tree = state?.reviewed?.tree;
|
|
385
|
+
if (typeof tree !== 'string' || !/^[0-9a-f]{40,64}$/.test(tree)) return undefined;
|
|
386
|
+
try {
|
|
387
|
+
gitOut(['cat-file', '-e', `${tree}^{tree}`]);
|
|
388
|
+
return state.reviewed;
|
|
389
|
+
} catch {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
381
394
|
const [cmd, ...rest] = process.argv.slice(2);
|
|
382
395
|
try {
|
|
383
396
|
switch (cmd) {
|
|
@@ -454,6 +467,7 @@ try {
|
|
|
454
467
|
state.stage = target;
|
|
455
468
|
state.stopBlocks = 0;
|
|
456
469
|
delete state.awaitingUser;
|
|
470
|
+
delete state.reviewed;
|
|
457
471
|
note(state, 'reopen', target);
|
|
458
472
|
state.history.at(-1).reason = reason;
|
|
459
473
|
writeState(dir, id, state);
|
|
@@ -554,12 +568,52 @@ try {
|
|
|
554
568
|
fail('loopwright: verdict requires --round <n>');
|
|
555
569
|
const { dir, id, state } = requireState();
|
|
556
570
|
state.verdict = { pass: result === 'pass', fingerprint: fingerprint(cwd, state.baseCommit), round };
|
|
571
|
+
// The reviewed code as a git tree, so the next round can look only at what changed since (review-diff).
|
|
572
|
+
try {
|
|
573
|
+
state.reviewed = { tree: workingTree(cwd), round };
|
|
574
|
+
} catch (err) {
|
|
575
|
+
delete state.reviewed;
|
|
576
|
+
process.stderr.write(
|
|
577
|
+
`loopwright: reviewed snapshot not recorded (${err instanceof Error ? err.message : String(err)})\n`,
|
|
578
|
+
);
|
|
579
|
+
}
|
|
557
580
|
delete state.awaitingUser;
|
|
558
581
|
note(state, 'verdict', `${result} round ${round}`);
|
|
559
582
|
writeState(dir, id, state);
|
|
560
583
|
out(state.verdict);
|
|
561
584
|
break;
|
|
562
585
|
}
|
|
586
|
+
case 'review-diff': {
|
|
587
|
+
const stat = rest.includes('--stat');
|
|
588
|
+
if (stat) rest.splice(rest.indexOf('--stat'), 1);
|
|
589
|
+
const { state } = requireState();
|
|
590
|
+
const snapshot = usableSnapshot(state);
|
|
591
|
+
if (!snapshot) fail('loopwright: no reviewed snapshot; run a full review');
|
|
592
|
+
// Numstat, not stat: git cuts long paths to `...` when stdout is not a terminal, and the paths are reused.
|
|
593
|
+
// Stdout streams straight through, so a large diff never fills a buffer. Paths are relative to the worktree root.
|
|
594
|
+
execFileSync(
|
|
595
|
+
'git',
|
|
596
|
+
[
|
|
597
|
+
'--no-pager',
|
|
598
|
+
'-c',
|
|
599
|
+
'core.quotePath=false',
|
|
600
|
+
'diff',
|
|
601
|
+
'--src-prefix=a/',
|
|
602
|
+
'--dst-prefix=b/',
|
|
603
|
+
'--no-color',
|
|
604
|
+
'--no-ext-diff',
|
|
605
|
+
'--no-textconv',
|
|
606
|
+
'--no-renames',
|
|
607
|
+
...(stat ? ['--numstat'] : []),
|
|
608
|
+
snapshot.tree,
|
|
609
|
+
workingTree(cwd),
|
|
610
|
+
'--',
|
|
611
|
+
...rest,
|
|
612
|
+
],
|
|
613
|
+
{ cwd: gitTopLevel(cwd), stdio: ['ignore', 'inherit', 'pipe'] },
|
|
614
|
+
);
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
563
617
|
case 'await-user': {
|
|
564
618
|
const reason = rest.join(' ').trim();
|
|
565
619
|
if (!reason) fail('loopwright: usage: await-user <reason>');
|
|
@@ -830,6 +884,7 @@ try {
|
|
|
830
884
|
baseCommit: state?.baseCommit,
|
|
831
885
|
lockedTests: state?.lockedTests,
|
|
832
886
|
verdict: state?.verdict,
|
|
887
|
+
reviewed: usableSnapshot(state) ? { round: state.reviewed.round } : undefined,
|
|
833
888
|
awaitingUser: state?.awaitingUser,
|
|
834
889
|
flaggedLocks,
|
|
835
890
|
pulledLocks: pulledLocks.length ? pulledLocks : undefined,
|
|
@@ -998,7 +1053,7 @@ try {
|
|
|
998
1053
|
}
|
|
999
1054
|
default:
|
|
1000
1055
|
fail(
|
|
1001
|
-
'loopwright: usage: lw.mjs <dir|start|stage|reopen|lock|check-locks|accept-locks|keep-base|fingerprint|verdict|await-user|resume|park|explore|status|config|brief|tasks|adopt|worktree|carry|effort|done>',
|
|
1056
|
+
'loopwright: usage: lw.mjs <dir|start|stage|reopen|lock|check-locks|accept-locks|keep-base|fingerprint|verdict|review-diff|await-user|resume|park|explore|status|config|brief|tasks|adopt|worktree|carry|effort|done>',
|
|
1002
1057
|
);
|
|
1003
1058
|
}
|
|
1004
1059
|
} catch (err) {
|
|
@@ -29,6 +29,7 @@ try {
|
|
|
29
29
|
'- the task file path and the stage;',
|
|
30
30
|
'- any question the user has not answered yet, with its options;',
|
|
31
31
|
'- unresolved review findings, verbatim;',
|
|
32
|
+
"- the last review round's findings sent to Build and its undecided findings not yet asked, word for word until the next verdict;",
|
|
32
33
|
'- the implementer report, if a second review pass is still due;',
|
|
33
34
|
'- any user decision that is not yet written in the task file;',
|
|
34
35
|
`- that every message to the user follows ${USER_MESSAGES_RULES}, which is read again after compaction.`,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
You review one change against its task file. You judge; you do not fix. Do not modify any file: no edits, no formatting, no `git add`/`commit`/`stash`/`checkout`. Running read-only commands, tests and check commands is allowed; never with flags that rewrite files (snapshot updates, `--fix`, `--write`).
|
|
4
4
|
|
|
5
|
-
State tool: `node "{{LW_HOME}}/hooks/lw.mjs" <cmd>`, run from the task's worktree. Use only `status`, `check-locks`, `fingerprint`, invoked exactly as written here (a headless reviewer's allowlist matches that text).
|
|
5
|
+
State tool: `node "{{LW_HOME}}/hooks/lw.mjs" <cmd>`, run from the task's worktree. Use only `status`, `check-locks`, `fingerprint` and, in a change review, `review-diff`, invoked exactly as written here (a headless reviewer's allowlist matches that text).
|
|
6
6
|
|
|
7
7
|
## 0. Locked tests (always first)
|
|
8
8
|
|
|
@@ -53,11 +53,26 @@ Second pass: only when the caller hands you the implementer's report. Verify eac
|
|
|
53
53
|
- Everything else (no proof, or impact below high) is dropped. Count it in `droppedCount`; do not describe it. `droppedCount` is a non-negative integer.
|
|
54
54
|
7. **Verdict rule.** `pass` is true only when `blocking` and `undecided` are both empty. Undecided findings go to the user; only they can resolve them.
|
|
55
55
|
|
|
56
|
+
## Change review (round 2 or later)
|
|
57
|
+
|
|
58
|
+
Applies only when the caller says "Change review". The whole diff was reviewed in an earlier round; this round judges what changed since then. The caller gives you the earlier round's findings.
|
|
59
|
+
|
|
60
|
+
- Section 0 (locked tests) runs first, as always.
|
|
61
|
+
- Scope: the output of `node "{{LW_HOME}}/hooks/lw.mjs" review-diff` (the diff between the code as last reviewed and the working tree, new files included), plus the code those changed lines call or are called by. Read the task file as in a blind pass. Do not review again the parts of the diff against the base commit that `review-diff` does not show.
|
|
62
|
+
- Each earlier Blocking finding: check that the change fixes it. Not fixed, or fixed only in appearance (the symptom hidden, the check weakened) → report it again as Blocking, with proof from the current code.
|
|
63
|
+
- Each earlier Undecided finding: check whether it still applies. Still applies → report it again as Undecided, with its location updated. No longer applies → leave it out.
|
|
64
|
+
- Then run Procedure steps 3 to 7 over the changed lines: anything the change introduced or broke, including in code it did not touch. Run the check commands.
|
|
65
|
+
- If the `review-diff` output is cut off, run `review-diff --stat` and then `review-diff <path>` file by file, so every changed line is read.
|
|
66
|
+
- If `review-diff` fails, do a full blind pass instead. A change is never passed on a diff you could not read.
|
|
67
|
+
|
|
68
|
+
The implementer report stays out of this pass, as in a blind pass. Output: the same JSON object.
|
|
69
|
+
|
|
56
70
|
## Fix tasks
|
|
57
71
|
|
|
58
72
|
Applies when the task file header has `kind: fix`.
|
|
59
|
-
- Read `## Root cause` and `## Bug report`. The diff must change the code named in `## Root cause
|
|
73
|
+
- Read `## Root cause` and `## Bug report`. The diff must change the code named in `## Root cause` (the diff against the base commit; in a change review this was checked in an earlier round and is not checked again). A change that only hides the symptom (catching and discarding the error, special-casing the repro input, skipping or removing the failing path, widening a type or check only to silence the failure) is a Blocking finding with the hunk as proof.
|
|
60
74
|
- Search for siblings: other places with the same defect pattern. Return each in `siblings` as `{path, line, why}`. A sibling is never a blocking or undecided finding and does not affect `pass`.
|
|
75
|
+
- In a change review the sibling search is not repeated: return a sibling only when the changed lines themselves show a new one. In a change review the symptom-hiding rule applies to the changed lines.
|
|
61
76
|
|
|
62
77
|
## Findings
|
|
63
78
|
|
|
@@ -97,7 +97,7 @@ On "confirm and continue in a fresh context", after the `plan: confirmed` step a
|
|
|
97
97
|
1. Append `## Notes for Done` to the task file (add to it if it exists): up to five lines of things learned so far that Done may propose for `AGENTS.md`.
|
|
98
98
|
2. Re-read the task file and write any decision made in this conversation that it is missing.
|
|
99
99
|
3. Run `node "{{LW_HOME}}/hooks/lw.mjs" stage test` (it updates the header), so the next session resumes at Test and not at this confirmation.
|
|
100
|
-
4. Tell the user what to type, by tool: Claude Code "`/clear`, then `/loopwright-flow`" (`/compact` also works and keeps a summary); Codex and Junie: start a new session and run the flow. End the turn. If the user's next message arrives in the same session, continue with `/loopwright-test` as usual.
|
|
100
|
+
4. Tell the user what to type, by tool: Claude Code "`/clear`, then `/loopwright-flow`" (`/compact` also works and keeps a summary). On Claude Code also say, in plain words following the rules file, that the remaining stages cost less on a cheaper model: instead of `/clear`, leave this session and run `claude --model sonnet "/loopwright-flow"` in the same folder; subagents keep their configured models, and a role whose model is `inherit` follows the session model, so it would run on the cheaper model too; Codex and Junie: start a new session and run the flow. End the turn. If the user's next message arrives in the same session, continue with `/loopwright-test` as usual.
|
|
101
101
|
|
|
102
102
|
## Fix tasks
|
|
103
103
|
|
|
@@ -11,7 +11,7 @@ Reviewers judge in their own context. This thread dispatches them, merges their
|
|
|
11
11
|
Before your first message to the user, read `{{LW_HOME}}/prompts/user-messages.md` unless you already read it in this conversation, and write every message to the user by it.
|
|
12
12
|
|
|
13
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
14
|
-
2. `node "{{LW_HOME}}/hooks/lw.mjs" brief reviewer` → `dir` (`<lw>`), `task` (relative to `<lw>`), `baseCommit`, `config` (`crossAgentReview`, `crossAgentReviewer` = `models.crossAgentReviewer`; missing → `off`; `simplify`), `effort
|
|
14
|
+
2. `node "{{LW_HOME}}/hooks/lw.mjs" brief reviewer` → `dir` (`<lw>`), `task` (relative to `<lw>`), `baseCommit`, `config` (`crossAgentReview`, `crossAgentReviewer` = `models.crossAgentReviewer`; missing → `off`; `simplify`), `effort`, `reviewed` (`round`: the round of the last reviewed snapshot; present only when `review-diff` can run). `dir` `null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/` with the first task, so continue and `task: null` reports "no active task". Not a git repo → tell the user loopwright must run inside a git repo, stop.
|
|
15
15
|
3. `task: null` → "no active task": point the user to `/loopwright-flow`, stop.
|
|
16
16
|
4. Read the task file header (`tier`, `two-pass`, `fix-round cap`).
|
|
17
17
|
5. Scope: small/standard → the task. Large → the first `S<n> [tested]` slice, or `whole` once every slice is `[passed]`.
|
|
@@ -21,7 +21,7 @@ Before your first message to the user, read `{{LW_HOME}}/prompts/user-messages.m
|
|
|
21
21
|
- `headMoved.localOnly` → the listed short shas exist only locally, so they are the task's own work and the branch holds both kinds whatever the answer: a 'pulled' answer takes the keep-base path below, with the both-kinds notice. Never judge this from the commit subjects.
|
|
22
22
|
- Pulled → run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD && node "{{LW_HOME}}/hooks/lw.mjs" stage build` as one call (Passes step 1 sets the stage to review), update `base commit` in the task file header to the new HEAD, run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --restart --reason "<the decision in words>"`, then run `brief reviewer` again (the base commit changed).
|
|
23
23
|
- This task's own commits, or a branch holding both kinds → run `node "{{LW_HOME}}/hooks/lw.mjs" keep-base --reason "<the decision in words>"`; the base stays. Both kinds: add `--pulled` to that command, so the locked tests the new commits changed show in `pulledLocks` (run `brief reviewer` again, then step 8), and tell the user the pulled commits stay in the review, because the base cannot move past the task's own commits.
|
|
24
|
-
8. `pulledLocks` in `brief` (a pulled commit changed those locked tests) → before the first reviewer is spawned, send only the listed files to Test: `node "{{LW_HOME}}/hooks/lw.mjs" reopen test "<the pull decision in words>"` when Build has begun, `node "{{LW_HOME}}/hooks/lw.mjs" stage test` otherwise, then run `/loopwright-test` for those files. After the tester re-locked them, run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --reason "<the pull decision in words>" <path>…` with the `pulledLocks` paths, so the re-locks are accepted under the pull decision, and continue with step 9 and Simplify.
|
|
24
|
+
8. `pulledLocks` in `brief` (a pulled commit changed those locked tests) → before the first reviewer is spawned, send only the listed files to Test: `node "{{LW_HOME}}/hooks/lw.mjs" reopen test "<the pull decision in words>"` when Build has begun, `node "{{LW_HOME}}/hooks/lw.mjs" stage test` otherwise, then run `/loopwright-test` for those files. After the tester re-locked them, run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --reason "<the pull decision in words>" <path>…` with the `pulledLocks` paths, so the re-locks are accepted under the pull decision, then run `brief reviewer` again (`reopen` drops `reviewed`), and continue with step 9 and Simplify.
|
|
25
25
|
9. `flaggedLocks` in `brief` (present only while a re-lock or forced restart is flagged and not accepted) → before the first reviewer is spawned, compare each item with the task file's decisions. A decision covers an item when it names the test file, the return to Test, or the pull. Covered → run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --reason "<that decision in words>" [--restart] [<path>…]` without asking the user (paths for `lockedAfterBuild`, `--restart` for `forcedRestartAfterBuild`). No decision covers an item → leave it to the reviewer, unchanged.
|
|
26
26
|
|
|
27
27
|
## Simplify
|
|
@@ -51,10 +51,11 @@ A `- Simplify:` line ending in `— apply pending` is not a skip: an earlier run
|
|
|
51
51
|
|
|
52
52
|
1. `node "{{LW_HOME}}/hooks/lw.mjs" stage review` (it updates the task file header `stage:` line; if it prints `"header": false`, set that line by hand).
|
|
53
53
|
2. **Blind pass.** Now spawn the `loopwright-reviewer` subagent and wait for its result. Give it only: the absolute task file path, the base commit, and "Follow `{{LW_HOME}}/prompts/reviewer.md`. Blind pass." Large tier: add "Scope: slice S<n> (its ACs; earlier slices passed)" or "Scope: whole-branch review of all slices". Never include the implementer report, chat history or your opinion. On Claude Code pass `effort` = the `effort` from `brief` on the spawn; if `brief` has no `effort` (it warns on stderr) or the spawn rejects `effort`, spawn without it (the agent file's effort applies). Use the same effort for the second pass.
|
|
54
|
+
**Change review.** When round `n` is 2 or more, `reviewed` is in `brief`, and the earlier round's findings are still in this conversation word for word, spawn the same way with the same `effort`, but the prompt says "Follow `{{LW_HOME}}/prompts/reviewer.md`. Change review." in place of "Blind pass.", keeps the scope line for a large task, and adds "Findings of the earlier round:" with two lists, each finding word for word (location, expectation, proof): "Sent to Build:" (what Build was given) and "Undecided, not asked yet:" (undecided findings that were only counted last round); "Undecided, not asked yet:" may be "none"; when the last verdict failed (`verdict.pass` is false in `brief`) "Sent to Build:" is never "none", and "none" is possible only after a passing verdict (a stale pass); if those findings are not at hand word for word, run the blind pass; never include dismissed findings, the implementer report, chat history or your opinion; otherwise run the blind pass above.
|
|
54
55
|
3. **Second pass** (only if `two-pass: on`). Now spawn the `loopwright-reviewer` subagent and wait for its result, with the task file path, the base commit, "Follow `{{LW_HOME}}/prompts/reviewer.md`. Second pass.", and then "Verify the claims in this implementer report:" with the report verbatim (Simplify's apply report too, if it ran). Report no longer available → skip and note it in the log line.
|
|
55
|
-
4. **Cross-agent pass** (only if `crossAgentReview` is not `off`). `command -v <claude|codex>` fails → skip, note it. Otherwise, from the worktree root, set `PROMPT="Follow {{LW_HOME}}/prompts/reviewer.md. Task file: <abs path>. Base commit: <sha>. Blind pass."` and run (`LOOPWRIGHT_HOOKS=off` keeps loopwright's own hooks, such as the stop gate, out of the headless reviewer session):
|
|
56
|
-
- claude (omit `--model` when the model is `inherit`; add one `"Bash(<cmd>:*)"` per check command in the task header; the `lw.mjs` entries allow only the read-only `status`, `check-locks` and `
|
|
57
|
-
`LOOPWRIGHT_HOOKS=off claude -p --model <crossAgentReviewer.claude> --effort <effort> --output-format json --json-schema "$(cat "{{LW_HOME}}/schemas/verdict.json")" --allowedTools "Read" "Grep" "Glob" "Bash(git diff:*)" "Bash(git status:*)" "Bash(git log:*)" 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" status)' 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" check-locks)' 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" fingerprint)' "Bash(node {{LW_HOME}}/hooks/lw.mjs status)" "Bash(node {{LW_HOME}}/hooks/lw.mjs check-locks)" "Bash(node {{LW_HOME}}/hooks/lw.mjs fingerprint)" "Bash(<check command>:*)" --disallowedTools "Edit" "Write" "MultiEdit" "NotebookEdit" -- "$PROMPT"`
|
|
56
|
+
4. **Cross-agent pass** (only if `crossAgentReview` is not `off`). `command -v <claude|codex>` fails → skip, note it. Otherwise, from the worktree root, set `PROMPT` from a quoted heredoc, never inside double quotes (the findings quote code, and double quotes run backticks and expand `$`): `PROMPT="$(cat <<'EOF'` then the lines "Follow {{LW_HOME}}/prompts/reviewer.md. Task file: <abs path>. Base commit: <sha>. Blind pass." then `EOF` then `)"`. A change review writes "Change review." in place of "Blind pass." and, inside the same heredoc, adds the "Findings of the earlier round:" lists as in step 2; and run (`LOOPWRIGHT_HOOKS=off` keeps loopwright's own hooks, such as the stop gate, out of the headless reviewer session):
|
|
57
|
+
- claude (omit `--model` when the model is `inherit`; add one `"Bash(<cmd>:*)"` per check command in the task header; the `lw.mjs` entries allow only the read-only `status`, `check-locks`, `fingerprint` and `review-diff` (a prefix entry, because it takes `--stat` and paths), in the quoted form the reviewer prompt uses and unquoted; the prompt must come after `--` because the tool flags take several values; `<effort>` is the `effort` from `brief`; omit `--effort` if it is missing):
|
|
58
|
+
`LOOPWRIGHT_HOOKS=off claude -p --model <crossAgentReviewer.claude> --effort <effort> --output-format json --json-schema "$(cat "{{LW_HOME}}/schemas/verdict.json")" --allowedTools "Read" "Grep" "Glob" "Bash(git diff:*)" "Bash(git status:*)" "Bash(git log:*)" 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" status)' 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" check-locks)' 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" fingerprint)' 'Bash(node "{{LW_HOME}}/hooks/lw.mjs" review-diff:*)' "Bash(node {{LW_HOME}}/hooks/lw.mjs status)" "Bash(node {{LW_HOME}}/hooks/lw.mjs check-locks)" "Bash(node {{LW_HOME}}/hooks/lw.mjs fingerprint)" "Bash(node {{LW_HOME}}/hooks/lw.mjs review-diff:*)" "Bash(<check command>:*)" --disallowedTools "Edit" "Write" "MultiEdit" "NotebookEdit" -- "$PROMPT"`
|
|
58
59
|
The verdict is the top-level `structured_output` field.
|
|
59
60
|
- codex (best effort, untested; omit `-m` when the model is `inherit`): `OUT="$(mktemp)"; LOOPWRIGHT_HOOKS=off codex exec --sandbox read-only --output-schema "{{LW_HOME}}/schemas/verdict.json" -o "$OUT" -m <crossAgentReviewer.codex> "$PROMPT"`, then read the verdict from `$OUT`.
|
|
60
61
|
Any error, timeout or unparseable output → skip and note it. This pass never blocks on its own failure. A check-command failure reported only by this pass that looks sandbox-caused (permission denied, read-only filesystem) is noted in the log, not counted as blocking.
|
|
@@ -66,18 +67,20 @@ Human gates: before you ask the user anything in this stage (an undecided findin
|
|
|
66
67
|
|
|
67
68
|
Merge all passes: union of `blocking`, union of `undecided` (drop exact duplicates by location and expectation), sum of `droppedCount`. Decide from the arrays, not from the `pass` fields.
|
|
68
69
|
|
|
70
|
+
After a change review, the one-line result you give the user says, in plain words following the rules file, that this round checked only what changed since the last review.
|
|
71
|
+
|
|
69
72
|
- **Blocking** present → `node "{{LW_HOME}}/hooks/lw.mjs" verdict fail --round <n>`. Fix rounds used = n − 1. If that reaches or exceeds the `fix-round cap`, stop: show every open finding and let the user decide (raise the cap, fix by hand, or accept). Otherwise show the findings briefly, in plain words following the rules file (what is wrong, with the location in brackets after), and run `/loopwright-build` with the Blocking findings verbatim (only what you show the user is rewritten); then review again (round n + 1). Undecided findings of this round are only counted; the next round re-checks them.
|
|
70
73
|
- Only **Undecided** → present each to the user, one at a time (Claude: `AskUserQuestion`; Codex: numbered text), in plain words following the rules file: what the reviewer is unsure about and why, with its location in brackets after and the proof as what was checked; options: fix or dismiss. Record each answer under the round's log line: ` - U<k> <location>: fix|dismissed — <user's reason>`. Any "fix" → `verdict fail --round <n>` and Build with those findings, same cap rule. A dismissed re-lock or restart finding also runs `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --reason "<user's reason>" [--restart] [<path>…]`, so it is not asked again for that re-lock or restart. Every other Undecided finding is asked as above, each round. All dismissed → pass.
|
|
71
74
|
- An undecided finding the user wants resolved by changing the plan or a locked test (not just the code) → offer to go back: after `verdict fail --round <n>`, `await-user` and the answer's `resume`, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"` with the user's reason (it sets the header `stage:` line, and `plan: draft` for plan; if it prints `"header": false`, set those lines by hand), then continue with `/loopwright-plan` or `/loopwright-test`. Run it only after the user chooses it.
|
|
72
75
|
- Nothing open → `node "{{LW_HOME}}/hooks/lw.mjs" verdict pass --round <n>`.
|
|
73
|
-
- Fix tasks, sibling gate: asked once, at the final pass (the task review for small/standard, the whole-branch review for large), never after a slice review.
|
|
76
|
+
- Fix tasks, sibling gate: asked once, at the final pass (the task review for small/standard, the whole-branch review for large), never after a slice review. Every round of a fix task, failed or passed, records its merged `siblings` (union from all passes, dropping exact duplicates by `path` and `line`) as ` - Sibling <path>:<line> — <why>` lines under its log line; after a passing slice review the slice loop goes on.
|
|
74
77
|
- At the final pass, take the merged `siblings` of this verdict plus every `Sibling` line after the last `- Scope change:` line, dropping duplicates by `path` and `line`. Non-empty → run `node "{{LW_HOME}}/hooks/lw.mjs" verdict pass --round <n> && node "{{LW_HOME}}/hooks/lw.mjs" await-user "siblings of the fixed bug"` as one call, in this order because the verdict clears the wait; list each sibling (`path:line`, why), then ask one question for the batch, recommendation first: include the siblings (also fix them), or list them as follow-ups. After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume`.
|
|
75
78
|
- Include → append `- Scope change: siblings included` to the review log, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen plan "include siblings in the fix"` (it sets the header `stage:` and `plan: draft` lines; if it prints `"header": false`, set them by hand), then continue with `/loopwright-plan` (one `[repro]` criterion per sibling; Test locks the new repro tests and existing locks stay; Build and Review run again with a fresh fix-round budget, because rounds are counted after the scope change).
|
|
76
79
|
- No (follow-ups only) → write the siblings under `## Follow-ups` in the task file (`path:line — why`) and go to `/loopwright-done`.
|
|
77
80
|
|
|
78
|
-
Once the outcome is known (after the user's undecided answers) and before the verdict command, append one line to `## Review log`, followed by its `U<k>` lines if any:
|
|
81
|
+
Once the outcome is known (after the user's undecided answers) and before the verdict command, append one line to `## Review log`, followed by its `U<k>` lines if any and, on a fix task, its `Sibling` lines:
|
|
79
82
|
`- R<n>: <pass|fail> — <k> blocking, <m> undecided, <d> dropped — <key finding one-liners>; <skipped-pass notes>`
|
|
80
|
-
Large tier: `- R<n> S<k>: …` for a slice, `- R<n> whole: …` for the whole-branch review.
|
|
83
|
+
Large tier: `- R<n> S<k>: …` for a slice, `- R<n> whole: …` for the whole-branch review. A change review puts `changes only` in the notes part of its `- R<n>:` line.
|
|
81
84
|
|
|
82
85
|
## After a pass
|
|
83
86
|
|
|
@@ -87,5 +90,5 @@ Large tier: `- R<n> S<k>: …` for a slice, `- R<n> whole: …` for the whole-br
|
|
|
87
90
|
1. Append `## Notes for Done` to the task file (add to it if it exists): up to five lines of things learned so far that Done may propose for `AGENTS.md`.
|
|
88
91
|
2. Re-read the task file and write any decision made in this conversation that it is missing.
|
|
89
92
|
3. Run `node "{{LW_HOME}}/hooks/lw.mjs" stage test` (it updates the header; if it prints `"header": false`, set the `stage:` line by hand), so the next session resumes at the next slice's Test and not in Review with no slice in scope.
|
|
90
|
-
4. Tell the user what to type, by tool: Claude Code "`/clear`, then `/loopwright-flow`" (`/compact` also works and keeps a summary); Codex and Junie: start a new session and run the flow. End the turn. If the user's next message arrives in the same session, continue with `/loopwright-test` as usual.
|
|
93
|
+
4. Tell the user what to type, by tool: Claude Code "`/clear`, then `/loopwright-flow`" (`/compact` also works and keeps a summary). On Claude Code also say, in plain words following the rules file, that the remaining stages cost less on a cheaper model: instead of `/clear`, leave this session and run `claude --model sonnet "/loopwright-flow"` in the same folder; subagents keep their configured models, and a role whose model is `inherit` follows the session model, so it would run on the cheaper model too; Codex and Junie: start a new session and run the flow. End the turn. If the user's next message arrives in the same session, continue with `/loopwright-test` as usual.
|
|
91
94
|
- Any code edit after a pass makes the verdict stale; review again.
|
package/dist/cli.js
CHANGED