loopwright 0.1.5 → 0.1.7

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.
@@ -9,19 +9,19 @@ The implementer subagent writes the code. This thread dispatches it and hands th
9
9
  ## Setup
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
- 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>` (`null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/` with the first task, so continue and the next step reports "no active task". Not a git repo → tell the user loopwright must run inside a git repo, stop).
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status` → `task` (relative to `<lw>`) and `lockedTests`. "no active task" → point the user to `/loopwright-plan` or `/loopwright-flow`, stop.
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" brief implementer` → `dir` (`<lw>`), `task` (relative to `<lw>`), `stage`, `lockedTests`, `effort`. `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.
13
+ 3. `task: null` → "no active task": point the user to `/loopwright-plan` or `/loopwright-flow`, stop.
14
14
  4. Read the task file header (`tier`, `checks`).
15
15
  - Header not `plan: confirmed` → stop; the plan is not confirmed yet, point the user to `/loopwright-plan`.
16
16
  - `standard` or `large` with no `lockedTests` (or, large, the current slice is still `[todo]`) → run `/loopwright-test` first.
17
17
  - `kind: fix` with no `lockedTests`, at any tier including small → run `/loopwright-test` first; a fix is never built without a locked repro test.
18
18
  - `large` → the current slice is the first `S<n> [tested]` line; build only that slice. Every slice `[passed]` → this is a whole-branch fix round; no slice limit.
19
- 5. Upstream check. Skip this check on a fix round (called with Review findings). Otherwise run `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; failure, e.g. offline or no auth → skip). List `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. For `large`, check before each slice's first Build. If the new commits touch the task's files or feature, or a sibling repo the task touches, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "upstream changed"`, show them to the user and ask whether to pull first or stop (someone may already have done this work) before spawning the implementer. After the answer, run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and record it as a decision `D<n> [asked]`. If the user pulled, rebase the review scope so pulled commits are not judged as this task's change: run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD` (keeps locks and history, resets the stage to plan), then `node "{{LW_HOME}}/hooks/lw.mjs" stage build`, and update `base commit` in the task file header to the new HEAD. Otherwise continue.
19
+ 5. Upstream check. Skip this check on a fix round (called with Review findings). Otherwise run `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; failure, e.g. offline or no auth → skip). List `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. For `large`, check before each slice's first Build. If the new commits touch the task's files or feature, or a sibling repo the task touches, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "upstream changed"`, show them to the user and ask whether to pull first or stop (someone may already have done this work) before spawning the implementer. After the answer, run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and record it as a decision `D<n> [asked]`. If the user pulled, rebase the review scope so pulled commits are not judged as this task's change: run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD && node "{{LW_HOME}}/hooks/lw.mjs" stage build` as one call (`start` keeps locks and history and resets the stage to plan; `stage build` sets it back), and update `base commit` in the task file header to the new HEAD. Otherwise continue.
20
20
 
21
21
  ## Steps
22
22
 
23
- 1. `node "{{LW_HOME}}/hooks/lw.mjs" stage build`, and set `stage: build` in the task file header.
24
- 2. Now spawn the `loopwright-implementer` subagent and wait for its result. On Claude Code pass `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort implementer` on the spawn; if the spawn rejects `effort`, fall back to spawning without it (the agent file's effort applies). The prompt contains only:
23
+ 1. `node "{{LW_HOME}}/hooks/lw.mjs" stage build` (it updates the task file header `stage:` line; if it prints `"header": false`, set that line by hand).
24
+ 2. Now spawn the `loopwright-implementer` subagent and wait for its result. 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). The prompt contains only:
25
25
  - the absolute task file path (`<lw>/<task>`);
26
26
  - large tier: "Implement slice S<n> only.";
27
27
  - small feature (no locked tests): "This task has no locked acceptance tests. Write tests covering each acceptance criterion (AC…) as part of your change.";
@@ -29,7 +29,7 @@ The implementer subagent writes the code. This thread dispatches it and hands th
29
29
  Never paste chat history, your own summary of the decisions, or design ideas; the task file is the source.
30
30
  3. Keep the implementer report verbatim in this conversation; a two-pass review needs it.
31
31
  Fix task: write the report's `Root cause:` line to `## Root cause` in the task file. A root cause that differs from the plan's hypothesis is a `Deviation`, handled in step 4.
32
- 4. `Deviations` not "none" → run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "deviations in build"` (so the stop gate lets you end the turn), then show each to the user before Review, one at a time (Claude: `AskUserQuestion`; Codex: numbered text, then end the turn). After the answers, run `node "{{LW_HOME}}/hooks/lw.mjs" resume`. The user either accepts it (write a new decision `D<n> [asked]` to the task file), wants it fixed (run `node "{{LW_HOME}}/hooks/lw.mjs" stage build` first, so a `reopen` the implementer runs on its own does not directly follow the `resume` and is not counted as the user's choice; then spawn the `loopwright-implementer` subagent and wait for its result again, with the deviation as the finding), or wants to go back: offer that when the deviation needs a changed decision or locked test. Going back: directly after `resume`, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"`, set `stage: <plan|test>` in the task file header (for plan also `plan: draft`), record the decision, and continue with `/loopwright-plan` or `/loopwright-test` as the target says.
32
+ 4. `Deviations` not "none" → run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "deviations in build"` (so the stop gate lets you end the turn), then show each to the user before Review, one at a time (Claude: `AskUserQuestion`; Codex: numbered text, then end the turn). After the answers, run `node "{{LW_HOME}}/hooks/lw.mjs" resume`. The user either accepts it (write a new decision `D<n> [asked]` to the task file), wants it fixed (run `node "{{LW_HOME}}/hooks/lw.mjs" stage build` first, so a `reopen` the implementer runs on its own does not directly follow the `resume` and is not counted as the user's choice; then spawn the `loopwright-implementer` subagent and wait for its result again, with the deviation as the finding), or wants to go back: offer that when the deviation needs a changed decision or locked test. Going back: directly after `resume`, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"` (it sets the header `stage:` line, and `plan: draft` for plan; if it prints `"header": false`, set those lines by hand), record the decision, and continue with `/loopwright-plan` or `/loopwright-test` as the target says.
33
33
  5. Go straight to `/loopwright-review`. The stop gate blocks ending the turn in Build without a passing review.
34
34
 
35
35
  ## Rules
@@ -9,19 +9,19 @@ Done runs in this main thread; do not spawn the subagents here. You propose; the
9
9
  ## Setup
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
- 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>` (`null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/` with the first task, so continue and the next step reports "no active task". Not a git repo → tell the user loopwright must run inside a git repo, stop). Read `docsDir` from `<lw>/config.json` (default `docs/agents`).
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status` → `task`, `verdict`. Then `node "{{LW_HOME}}/hooks/lw.mjs" fingerprint`.
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" brief` → `dir` (`<lw>`), `task`, `verdict`, `config.docsDir` (the main checkout's config; default `docs/agents`). `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.
13
+ 3. `task: null` → "no active task": stop. Then `node "{{LW_HOME}}/hooks/lw.mjs" fingerprint`.
14
14
  - No `verdict.pass: true`, or its `fingerprint` differs from the current one → the code changed since review or never passed: run `/loopwright-review` first. Continue only if the user explicitly says so, and note it in the review log.
15
- 4. `node "{{LW_HOME}}/hooks/lw.mjs" stage done`, and set `stage: done` in the task file header.
15
+ 4. `node "{{LW_HOME}}/hooks/lw.mjs" stage done` (it updates the task file header `stage:` line; if it prints `"header": false`, set that line by hand).
16
16
 
17
17
  ## 1. Knowledge (AGENTS.md)
18
18
 
19
- From the task file (decisions, overrides, review log) and what this task taught you, find durable cross-task knowledge: conventions, "we don't do X here", gotchas a future task would hit. Not task history, not what the code or README already says.
19
+ From the task file (decisions, overrides, review log, and `## Notes for Done` when present, written before a fresh-context reset) and what this task taught you, find durable cross-task knowledge: conventions, "we don't do X here", gotchas a future task would hit. Not task history, not what the code or README already says. A fact already stated in the repo docs or the contract (spec, schema, config) is not added: link instead of restating.
20
20
  - Write concepts, not file paths; one line per entry.
21
21
  - An entry that needs more than ~3 lines goes to `docs/agents/<topic>.md` (the configured `docsDir`), plus one line in AGENTS.md: "Read `docs/agents/<topic>.md` when <situation>."
22
22
  - Prune: AGENTS.md or docs entries this task showed to be stale or wrong → propose an edit or removal.
23
23
  - No AGENTS.md → propose creating one with the first entry.
24
- Propose each change individually, with the exact text, and wait for approval (Claude: `AskUserQuestion`; Codex: numbered text). Apply only approved changes. Nothing worth adding → say so.
24
+ Notes from `## Notes for Done` are candidates, not approved entries: each goes through the user like the rest. Propose each change individually, with the exact text, and wait for approval (Claude: `AskUserQuestion`; Codex: numbered text). Apply only approved changes. Nothing worth adding → say so.
25
25
 
26
26
  If `CLAUDE.md` exists and has no line `@AGENTS.md`, propose adding that import line instead of copying content into CLAUDE.md. Never duplicate AGENTS.md content elsewhere.
27
27
 
@@ -29,6 +29,8 @@ If `CLAUDE.md` exists and has no line `@AGENTS.md`, propose adding that import l
29
29
 
30
30
  `grep -l "^found while: <this task path>" <lw>/tasks/*.md` lists the stubs parked while this task ran (`status: proposed` ones are still open). For each, draft issue text (title, what and why, `path:line` evidence from its `## Evidence`) and show it to the user. It is shown only: never file it, and write no task paths or ids into it. A stub with `blocks: <this task path>` that is still `proposed` → ask one question: clear the flag (the stub no longer blocks) or note it in the PR.
31
31
 
32
+ In a linked worktree, its `status: proposed` stubs are deleted along with the worktree. List them and offer one question: move them to the main checkout with `node "{{LW_HOME}}/hooks/lw.mjs" carry` (it copies each into the main checkout's `tasks/` and marks the source `status: moved`; it fails in the main checkout, where the stubs already are). Run it only on yes; a stub the user keeps here is lost when the worktree is removed, so say so.
33
+
32
34
  ## 3. Commit message and PR description
33
35
 
34
36
  Never write task ids (AC, D, S shorthands) into tests, code, comments, commit messages or PR drafts. Describe decisions in words.
@@ -10,13 +10,30 @@ Entry for bug fixes. It reuses Plan, Test, Build, Review and Done with `kind: fi
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
12
  2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` prints the `.loopwright` directory (`<lw>` below). `null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/`, so continue with a new task. Not a git repo → tell the user loopwright must run inside a git repo, stop.
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. It prints a task → the task is in progress; tell the user to continue it with `/loopwright-flow` and do not start a second. "no active task" → continue.
13
+ 3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. "no active task" → this worktree is free; the bug is a new goal, so run "Goal intake" below before Steps (a related task in another worktree is not started again here). It prints a task → this worktree is occupied; follow "Goal intake" below instead of starting a second task here.
14
14
  4. Hooks check: `grep -l "loopwright/hooks/" .claude/settings.json .codex/config.toml .junie/config.json ~/.claude/settings.json ~/.codex/config.toml ~/.junie/config.json 2>/dev/null`. No match → warn the user once: "loopwright hooks are not installed, so locked tests, the stop gate and context restore are not enforced; run `npx loopwright init` to install them." Continue unless the user objects.
15
15
 
16
+ ## Goal intake
17
+
18
+ A new goal, while open tasks may exist: `node "{{LW_HOME}}/hooks/lw.mjs" tasks` lists every worktree's open tasks (`inProgress`, each with its `goal` and `current`) and the parked stubs. Whether a task is related to the goal is your judgment; ask the user when unsure.
19
+
20
+ First step, before any question or message: if `node "{{LW_HOME}}/hooks/lw.mjs" status` shows this worktree's task in `build` or `review`, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "handing a new goal to a new worktree"` once, so the stop gate does not push this session into that task or spend its stop-block cap on any turn of this intake. Never run `resume` in goal intake: the wait clears when that task's own work resumes (its stage skill's `stage` call, `reopen` or `verdict`), also when the user switches to continuing it.
21
+ - A related task in this worktree → ask whether to continue it with `/loopwright-flow`. A related task in another worktree → do not start here; tell the user to continue it there and print the start command.
22
+ - Only unrelated tasks, and this worktree is free (`status` prints "no active task") → start the goal here.
23
+ - This worktree is occupied (`status` prints a task; the Plan stage counts) → say which task occupies it, suggest a new worktree, and never offer to close or shelve an unrelated task. On yes, pass the goal on stdin through a quoted heredoc, so backticks and `$` in it stay text (pick a delimiter that does not appear alone on a line in the goal), then print the start command.
24
+ ```bash
25
+ node "{{LW_HOME}}/hooks/lw.mjs" worktree "<title>" --kind fix <<'LW_GOAL'
26
+ <goal, exactly as the user wrote it>
27
+ LW_GOAL
28
+ ```
29
+ It prints `{worktree, branch, base, stub, installMissing}`. Planning happens in the new session, from the stub, not here.
30
+ - `installMissing` true → the new worktree lacks the repo-mode install: say so and print `npx loopwright update` (run in that folder) before the start command.
31
+ - Start command, by tool: Claude `cd <path> && claude "/loopwright-flow"`; Codex `cd <path> && codex '$loopwright-flow'`; Junie `cd <path>`, then start Junie and run `/loopwright-flow`. This session does not change directory; the user starts the new session.
32
+
16
33
  ## Steps
17
34
 
18
35
  1. Input: a bug description, issue text, or a path to a log or report. None given → ask the user for one.
19
- 2. Follow `loopwright-plan` with `kind: fix` (`/loopwright-plan` in Claude Code, `$loopwright-plan` in Codex). The plan skill's fix rules apply: the scout reads the report first, the user is asked once for missing evidence, and the root-cause hypothesis is confirmed with the user.
36
+ 2. Follow `loopwright-plan` with `kind: fix` (`/loopwright-plan` in Claude Code, `$loopwright-plan` in Codex). The plan skill's fix rules apply: the goal is restated and confirmed first (with the effort profile), then the scout reads the report, the user is asked once for missing evidence, and the root-cause hypothesis is confirmed with the user.
20
37
  3. Continue as `/loopwright-flow` does: Test runs at every tier, then Build, Review and Done. `/loopwright-flow` resumes a fix task like any other.
21
38
 
22
39
  ## Rules
@@ -16,12 +16,30 @@ Runs the stage skills in order for the confirmed tier and resumes where a task l
16
16
  ## Resume
17
17
 
18
18
  `node "{{LW_HOME}}/hooks/lw.mjs" status`:
19
- - Prints a task → read `<lw>/<task>` and continue at its `stage` (plan: run `loopwright-plan`, which resumes the open plan; review: count rounds from the review log).
19
+ - Prints a task, and the user gave a new goal → the worktree is occupied: follow "Goal intake" below, never continue the task unasked. Prints a task, and no goal or the goal is that task → read `<lw>/<task>` and continue at its `stage` (plan: run `loopwright-plan`, which resumes the open plan; review: count rounds from the review log).
20
20
  - "no active task" → `grep -l "^status: active" <lw>/tasks/*.md`.
21
21
  - One or more files → ask the user which one (or a new task). For the chosen file, offer to rebuild state from it: `node "{{LW_HOME}}/hooks/lw.mjs" start tasks/<file>.md --base <base commit from its header>`, then `node "{{LW_HOME}}/hooks/lw.mjs" stage <stage from its header>`. Locked-test hashes are lost with the state: if the task already has acceptance tests and is past Test, tell the user; re-lock the test files named in its AC lines (`stage test`, `lock <files>`, then `stage <stage>`) only if the user confirms they are unchanged.
22
22
  - None, or the user wants a new task → continue below.
23
- - Also list stubs parked by `/loopwright-park`: `grep -l "^status: proposed" <lw>/tasks/*.md`. Offer each as start, drop, or a new task instead. Start → run `loopwright-plan` on it as in that skill ("Parked stubs"). Drop → set `status: dropped` in the stub; never delete it.
24
- - No stubs and no task, or the user wants a new task → start at Plan with the user's goal or spec path.
23
+ - Also list stubs parked by `/loopwright-park` (`status: proposed` in `lw.mjs tasks`, from any worktree; `grep -l "^status: proposed" <lw>/tasks/*.md` lists this worktree's). Offer each as start, drop, or a new task instead. Start → run `loopwright-plan` on it as in that skill ("Parked stubs"); a stub that sits in another worktree starts in a new worktree instead (`lw.mjs worktree "<title>" --stub <absolute path>`, then print the start command). Drop → set `status: dropped` in the stub; never delete it.
24
+ - An `olderLayout` entry listed under this worktree is a task from before tasks were kept per worktree: offer `node "{{LW_HOME}}/hooks/lw.mjs" adopt <task>` to copy it and its state (with locks) in. Nothing moves or is deleted unasked.
25
+ - No stubs and no task, or the user wants a new task → run "Goal intake" below for the user's goal, then start at Plan with the goal or spec path.
26
+
27
+ ## Goal intake
28
+
29
+ A new goal, while open tasks may exist: `node "{{LW_HOME}}/hooks/lw.mjs" tasks` lists every worktree's open tasks (`inProgress`, each with its `goal` and `current`) and the parked stubs (`proposed`). Whether a task is related to the goal is your judgment; ask the user when unsure.
30
+
31
+ First step, before any question or message: if `node "{{LW_HOME}}/hooks/lw.mjs" status` shows this worktree's task in `build` or `review`, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "handing a new goal to a new worktree"` once, so the stop gate does not push this session into that task or spend its stop-block cap on any turn of this intake. Never run `resume` in goal intake: the wait clears when that task's own work resumes (its stage skill's `stage` call, `reopen` or `verdict`), also when the user switches to continuing it.
32
+ - A related task in this worktree → ask whether to continue it. A related task in another worktree → do not start here; tell the user to continue it there and print the start command.
33
+ - Only unrelated tasks, and this worktree is free (`status` prints "no active task") → start the goal here.
34
+ - This worktree is occupied (`status` prints a task; the Plan stage counts) → say which task occupies it, suggest a new worktree, and never offer to close or shelve an unrelated task. On yes, pass the goal on stdin through a quoted heredoc, so backticks and `$` in it stay text (pick a delimiter that does not appear alone on a line in the goal), then print the start command.
35
+ ```bash
36
+ node "{{LW_HOME}}/hooks/lw.mjs" worktree "<title>" <<'LW_GOAL'
37
+ <goal, exactly as the user wrote it>
38
+ LW_GOAL
39
+ ```
40
+ It prints `{worktree, branch, base, stub, installMissing}`. Planning happens in the new session, from the stub, not here.
41
+ - `installMissing` true → the new worktree lacks the repo-mode install: say so and print `npx loopwright update` (run in that folder) before the start command.
42
+ - Start command, by tool: Claude `cd <path> && claude "/loopwright-flow"`; Codex `cd <path> && codex '$loopwright-flow'`; Junie `cd <path>`, then start Junie and run `/loopwright-flow`. This session does not change directory; the user starts the new session.
25
43
 
26
44
  ## Run
27
45
 
@@ -30,9 +48,11 @@ Follow each stage skill in turn (Claude Code `/loopwright-<stage>`, Codex `$loop
30
48
  - standard (and any fix): `loopwright-plan` → `loopwright-test` → `loopwright-build` → `loopwright-review` → `loopwright-done`
31
49
  - large: `loopwright-plan` → for each slice in order: `loopwright-test` → `loopwright-build` → `loopwright-review` → then one whole-branch `loopwright-review` → `loopwright-done`
32
50
  - A fix (`kind: fix` in the task file header; set by `/loopwright-fix`, or by Plan after the user agrees to run a bug-like goal as a fix) runs `loopwright-test` at every tier: a small fix is never built without a locked repro test. Large keeps its slice loop.
33
- - Going back is the user's choice only: at a deviation, or an undecided review finding, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"` (plan or test; accepted only after Build began) and set `stage: <plan|test>` in the task file header (for plan also `plan: draft`), then follow the stage skill it names. Locked tests may then be edited by the tester in Test and are re-locked.
51
+ - Going back is the user's choice only: at a deviation, or an undecided review finding, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"` (plan or test; accepted only after Build began; it sets the header `stage:` line, and `plan: draft` for plan; if it prints `"header": false`, set those lines by hand), then follow the stage skill it names. Locked tests may then be edited by the tester in Test and are re-locked.
34
52
  - A failed review returns to `loopwright-build` and then `loopwright-review`, up to the task's fix-round cap.
35
53
 
54
+ A "fresh context" answer (at the plan confirmation, or at a slice boundary) ends the turn after the stage is advanced; the next session resumes from `status` and the task file, as in Resume.
55
+
36
56
  Exploring is not a stage of the loop: to understand an unfamiliar codebase before any task, run `loopwright-explore` (`/loopwright-explore [folder]`).
37
57
 
38
58
  Work found along the way that does not belong in the task goes to `loopwright-park` (`/loopwright-park`), which leaves the current task unchanged.
@@ -41,7 +61,8 @@ When a stage says to spawn the `loopwright-<role>` subagent, spawn the subagent
41
61
 
42
62
  ## Gates: stop and wait for the user
43
63
 
44
- - each high-impact question, the "run this as a fix?" question for a bug-like goal, the low-impact batch, the tier/settings proposal, and the final plan confirmation;
64
+ - the goal restatement and the effort profile (one prompt) before the scout, each high-impact question, the "run this as a fix?" question for a bug-like goal, the low-impact batch, the tier/settings proposal, and the final plan confirmation;
65
+ - the slice-boundary question after a large-tier slice review passes while a `[todo]` slice remains (continue here or in a fresh context);
45
66
  - tester `Uncovered`/`Needs` items and implementer `Deviations`;
46
67
  - fixes: the no-repro gate (no locked repro test: provide evidence, find the faulty unit, or stop; never continue without one) and, after the final passing review (whole-branch for large), the sibling gate (include siblings in this fix or list them as follow-ups);
47
68
  - each undecided review finding, and the fix-round cap being reached;
@@ -18,8 +18,8 @@ Captures work found mid-task (call it B) as a stub, so the current task (A) keep
18
18
  2. Ask one question, "Does this block the current task?", recommendation "no" (Claude: `AskUserQuestion`; Codex: numbered text). It needs an active task; with none, skip it.
19
19
  3. Run `node "{{LW_HOME}}/hooks/lw.mjs" park "<title>"`, adding `--blocks` when the answer is yes and `--kind fix` when B is a bug. It prints `{stub, foundWhile, blocks}`.
20
20
  4. Write the agreed goal under `## Goal` and the evidence under `## Evidence` of `<lw>/<stub>`.
21
- 5. Blocking → suggest running B first in another worktree (the stub is shared by all worktrees), and leave A as it is.
22
- 6. Tell the user the stub path and that it is listed under A's `## Follow-ups`. Resume A where it was.
21
+ 5. Blocking → suggest running B first in a new worktree (`node "{{LW_HOME}}/hooks/lw.mjs" worktree "<title>" --stub <stub>` moves the stub there; print the start command as `loopwright-flow` describes under "Goal intake"), and leave A as it is.
22
+ 6. Tell the user the stub path (it lives in this worktree's `.loopwright/`) and that it is listed under A's `## Follow-ups`. Resume A where it was.
23
23
 
24
24
  ## Rules
25
25
 
@@ -10,28 +10,47 @@ Plan runs in this main thread. You state assumptions; the user decides. Do not e
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
12
  2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` prints the `.loopwright` directory (`<lw>` below). `null` inside a git repo → no task has started here yet; `lw.mjs start` (section 3) creates `.loopwright/`, so continue with a new task. Not a git repo → tell the user loopwright must run inside a git repo, stop.
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. "no active task" → continue with a new task. If it prints a task, read `<lw>/<task>`:
13
+ 3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. "no active task" → this worktree is free; a new goal still goes through "Goal intake" below first (a related task in another worktree is not started again here), then continue with a new task. If it prints a task, read `<lw>/<task>`:
14
14
  - `stage: plan` and reopened (`status` `history` has a `reopen` event after the last `stage build` event; that event's `reason` says why) → this is the same task returning to Plan for added scope, not a second task: keep its decisions, ACs and tests, run sections 2–6 only for what the reason adds or changes (a new slice starts `[todo]`), then section 7. Do not ask whether the plan is abandoned.
15
+ - `stage: plan`, and the user gave a new goal unrelated to this plan → the worktree is occupied: follow "Goal intake" below, do not resume.
15
16
  - `stage: plan` → resume this plan: the first `— pending` item under `## Open questions`, else the proposal (step 6), else the confirmation (step 7). If the user says this plan is abandoned, offer to start the new one with `start tasks/<new file>.md --force` (the old task file stays).
16
- - past `plan` → the task is in progress; tell the user to continue it with `/loopwright-flow`. Do not start a second.
17
- 4. Read `<lw>/config.json` for `maxFixRounds` (missing file or key → 3).
17
+ - past `plan` → the task is in progress; tell the user to continue it with `/loopwright-flow`. Do not start a second here; a new goal follows "Goal intake".
18
+ 4. `node "{{LW_HOME}}/hooks/lw.mjs" config` prints the main checkout's config; read `maxFixRounds` from it (missing key → 3).
18
19
  5. `git status --porcelain` not empty → uncommitted changes will be part of the reviewed diff. Ask the user whether to commit/stash them first or include them; record the answer as a decision once the task file exists.
19
20
  6. Upstream check: `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; it fails offline or without auth → skip this check). Then list `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. Repeat in any sibling repo the goal touches (e.g. a separate frontend repo). New upstream commits → tell the user and ask whether to pull first. A commit or branch that already touches the goal's feature → ask whether someone has already done this work. Record the answers as decisions once the task file exists.
20
21
 
22
+ ## Goal intake
23
+
24
+ A new goal, while open tasks may exist: `node "{{LW_HOME}}/hooks/lw.mjs" tasks` lists every worktree's open tasks (`inProgress`, each with its `goal` and `current`) and the parked stubs. Whether a task is related to the goal is your judgment; ask the user when unsure.
25
+
26
+ First step, before any question or message: if `node "{{LW_HOME}}/hooks/lw.mjs" status` shows this worktree's task in `build` or `review`, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "handing a new goal to a new worktree"` once, so the stop gate does not push this session into that task or spend its stop-block cap on any turn of this intake. Never run `resume` in goal intake: the wait clears when that task's own work resumes (its stage skill's `stage` call, `reopen` or `verdict`), also when the user switches to continuing it.
27
+ - A related task in this worktree → ask whether to continue it with `/loopwright-flow`. A related task in another worktree → do not start here; tell the user to continue it there and print the start command.
28
+ - Only unrelated tasks, and this worktree is free (`status` prints "no active task") → start the goal here.
29
+ - This worktree is occupied (`status` prints a task; the Plan stage counts) → say which task occupies it, suggest a new worktree, and never offer to close or shelve an unrelated task. On yes, pass the goal on stdin through a quoted heredoc, so backticks and `$` in it stay text (pick a delimiter that does not appear alone on a line in the goal), then print the start command.
30
+ ```bash
31
+ node "{{LW_HOME}}/hooks/lw.mjs" worktree "<title>" <<'LW_GOAL'
32
+ <goal, exactly as the user wrote it>
33
+ LW_GOAL
34
+ ```
35
+ Add `--kind fix` for a fix. It prints `{worktree, branch, base, stub, installMissing}`. Planning happens in the new session, from the stub, not here.
36
+ - `installMissing` true → the new worktree lacks the repo-mode install: say so and print `npx loopwright update` (run in that folder) before the start command.
37
+ - Start command, by tool: Claude `cd <path> && claude "/loopwright-flow"`; Codex `cd <path> && codex '$loopwright-flow'`; Junie `cd <path>`, then start Junie and run `/loopwright-flow`. This session does not change directory; the user starts the new session.
38
+
21
39
  ## Parked stubs
22
40
 
23
- Invoked without a goal (and no active task) → run `grep -l "^status: proposed" <lw>/tasks/*.md` and list the stubs `/loopwright-park` left, one line each (title, `kind`, `found while`, `blocks`). Offer: start one, drop one, or a new task. Drop → set `status: dropped` in the stub; never delete it. Start → treat the stub as an imported spec: run `start tasks/<stub>.md`, and fill that same file in place (status `active`, the Plan template's header lines and sections) instead of creating a second file. Keep its `kind`, `found while` and `blocks` lines. Its `## Goal` is confirmed with the batch; its `## Evidence` is a lead for the scout, not a verified fact.
41
+ Invoked without a goal (and no active task) → run `grep -l "^status: proposed" <lw>/tasks/*.md` and list the stubs `/loopwright-park` left, one line each (title, `kind`, `found while`, `blocks`). Offer: start one, drop one, or a new task. Drop → set `status: dropped` in the stub; never delete it. Start → treat the stub as an imported spec: run `start tasks/<stub>.md`, and fill that same file in place (status `active`, the Plan template's header lines and sections) instead of creating a second file. Keep its `kind`, `found while` and `blocks` lines. Unlike an imported spec, its goal is confirmed before the scout (section 1); its `## Evidence` is a lead for the scout, not a verified fact.
24
42
 
25
43
  ## 1. Input
26
44
 
27
45
  - A goal in the user's words, or a path to an imported spec/plan (e.g. from superpowers).
46
+ - Restate the goal first, on every task with a typed goal, a bug report or a parked stub's goal, before the scout runs. Say in your own plain words what the user wants and what will change, and ask it as one question in the format of section 4: the user must confirm or correct it before you go on. In the same prompt as the restatement, ask which effort profile the task runs at (lean: trivial or mechanical; balanced: most tasks; thorough: cross-module or risky; deep: major refactors), the recommended profile first. The recommendation is your best guess from the restatement, and `balanced` when it does not show the size; the user has the last say and may confirm or change it. A corrected restatement asks both again. A goal with more than one reading lists the readings as options in the same question. Never skip it because the goal looks clear or obvious. A bug is restated in one sentence, observed and expected; its evidence intake stays after the scout. An imported spec skips the restatement but still gets the profile question on its own before its scout; a reopened plan skips both and asks nothing about the profile, since its header already has one. The confirmed restatement becomes the task file's `## Goal` paragraph and is recorded as an `[asked]` decision once the task file exists. No `await-user` here: no task state exists yet.
28
47
  - Called from `/loopwright-fix` → `kind: fix`; read "Fix tasks" below. Otherwise `kind: feature`.
29
- - A goal that looks like a bug, without `/loopwright-fix` → never switch silently. Ask one question first (format of section 4), recommendation first: "Run this as a fix (repro test first)?" Yes → `kind: fix`; no → `kind: feature`. Record the answer as a decision once the task file exists.
48
+ - A goal that looks like a bug, without `/loopwright-fix` → never switch silently. After the restatement, ask one question (format of section 4), recommendation first: "Run this as a fix (repro test first)?" Yes → `kind: fix`; no → `kind: feature`. Record the answer as a decision once the task file exists.
30
49
  - Imported spec: read it fully. Do not interview from scratch; run the assumption pass over it. What the spec states explicitly becomes a decision tagged `batch-confirmed` once the user confirms the batch; what it leaves implicit goes in the ledger.
31
50
 
32
51
  ## 2. Scout
33
52
 
34
- Before writing any assumption, spawn the `loopwright-scout` subagent and wait for its result. Give it only the goal text or the spec path (a fix: the bug report text, and "Fix tasks: report the fix inputs"). On Claude Code pass `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort scout` on the spawn; if the spawn rejects `effort`, fall back to spawning without it (the agent file's effort applies).
53
+ Only after the restatement is confirmed, and before writing any assumption, spawn the `loopwright-scout` subagent and wait for its result. Give it the goal text plus the confirmed restatement, or the spec path (a fix: the bug report text, and "Fix tasks: report the fix inputs"). On Claude Code pass `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort scout --profile <chosen profile>` on the first spawn (follow-up scouts below use plain `lw.mjs" effort scout`, which reads the header); if the spawn rejects `effort`, fall back to spawning without it (the agent file's effort applies).
35
54
  Never ask the user a question the repo can answer. If the scout report leaves a repo fact open, look it up yourself or spawn the `loopwright-scout` subagent and wait for its result again with that one question.
36
55
 
37
56
  ## 3. Assumption ledger
@@ -39,9 +58,9 @@ Never ask the user a question the repo can answer. If the scout report leaves a
39
58
  List every assumption you would otherwise make silently, one line each: `A<n> [high|low] <assumption> — <evidence: scout path:line, or "none">`.
40
59
  - **high-impact**: a wrong guess changes public behavior, an interface or name others use, a data/file format, scope, architecture, the test runner, or forces more than a small rework. When unsure, tag high.
41
60
  - **low-impact**: everything else (internal naming, file placement following an existing pattern, minor edge-case choices).
42
- - Cover: scope in/out, behavior and edge cases, interfaces and paths, error handling, compatibility, how it is tested (no test runner in the repo → high-impact), docs to update.
61
+ - Cover: scope in/out, behavior and edge cases, interfaces and paths, error handling, compatibility, how it is tested (no test runner in the repo → high-impact), docs to update, extending an existing mechanism (the scout's `Mechanisms` line) vs adding something new. Behavior that differs by environment, deployment or tenant is high-impact unless it extends a mechanism the scout found.
43
62
 
44
- Show the user the whole ledger in one compact message, then run `node "{{LW_HOME}}/hooks/lw.mjs" start tasks/<file>.md` (path relative to `<lw>`; if `dir` printed `null`, this creates `.loopwright/`, so run `dir` again for `<lw>`) and create the task file (see Task file) with status `active`, stage `plan` and `plan: draft`. Copy `baseCommit`, `worktree` and `branch` from its output into the header. Put every unresolved ledger line under `## Open questions` with `— pending`; move each to Decisions or Assumptions as it is resolved, so a resumed session knows what is still open. Starting early lets the hooks restore this task after compaction; it builds nothing.
63
+ Show the user the whole ledger in one compact message, then run `node "{{LW_HOME}}/hooks/lw.mjs" start tasks/<file>.md` (path relative to `<lw>`; if `dir` printed `null`, this creates `.loopwright/`, so run `dir` again for `<lw>`) and create the task file (see Task file) with status `active`, stage `plan` and `plan: draft`, and the profile chosen before the scout in `profile:`. Copy `baseCommit`, `worktree` and `branch` from its output into the header. Put every unresolved ledger line under `## Open questions` with `— pending`; move each to Decisions or Assumptions as it is resolved, so a resumed session knows what is still open. Starting early lets the hooks restore this task after compaction; it builds nothing.
45
64
 
46
65
  ## 4. High-impact questions, one at a time
47
66
 
@@ -60,7 +79,7 @@ Write the result immediately: accepted → `[batch-confirmed]`, changed by the u
60
79
 
61
80
  In one message, propose and explain each in one line:
62
81
  - **tier**: `small` (one area, few files, low risk; no acceptance-test stage for features, the implementer writes tests for every AC; a fix always runs Test), `standard` (default; tests first, then build), `large` (several separable parts; split into ordered slices, each run Test → Build → Review, then one whole-branch review).
63
- - **profile**: `lean` (trivial or mechanical), `balanced` (default; most tasks), `thorough` (cross-module work, risky changes), `deep` (major refactors, complex redesigns). It sets subagent effort for the task; the user confirms. Written as `profile: <name>` in the header; Test, Build and Review read it via `lw.mjs effort <role>`.
82
+ - **profile**: `lean` (trivial or mechanical), `balanced` (default; most tasks), `thorough` (cross-module work, risky changes), `deep` (major refactors, complex redesigns). It sets subagent effort for the task. It is pre-filled with the profile chosen before the scout; say so when the scout's findings suggest a different one. The user confirms or changes it. Written as `profile: <name>` in the header; Test, Build and Review read it via `lw.mjs brief <role>`.
64
83
  - **two-pass** review on/off: on when the implementer's claims matter beyond what tests show (performance, migrations, concurrency, external APIs); otherwise off.
65
84
  - **fix-round cap**: default `maxFixRounds` from config; may be lower for small tasks.
66
85
  - **check commands**: exact lint / typecheck / test commands from the scout report.
@@ -70,7 +89,13 @@ The user confirms or edits each item; write the outcome to the header and sectio
70
89
  ## 7. Confirm
71
90
 
72
91
  Show the task file path and a short summary (tier, decisions count, ACs). Ask for explicit confirmation. Until the user confirms, keep editing the plan; never start Test or Build.
92
+ Safe point: for tier standard or large (fixes of those tiers included) and a task that was not reopened, the confirmation offers three answers: confirm and continue here; confirm and continue in a fresh context; keep editing. The small tier and a reopened task (Build has begun, so findings and the implementer report live in this conversation) keep the two answers confirm and keep editing, with no fresh-context offer. Give the reason in one sentence, stated as a tradeoff: later turns re-read the whole conversation, so a fresh context saves tokens when much of the task remains (a large task, a long plan conversation), but the new session rewrites the cache, which can cost more than it saves on a short task; nothing is lost either way because the task file holds the plan.
73
93
  On explicit confirmation, set the header line to `plan: confirmed` (Test and Build refuse to run without it). Then, unless the task was reopened (keep its base commit so the review scope stays whole), if `git rev-parse HEAD` differs from the recorded base commit, rerun `node "{{LW_HOME}}/hooks/lw.mjs" start tasks/<file>.md --force` and update the header. Then the next stage is `/loopwright-test` (standard, large, and every fix) or `/loopwright-build` (small feature); under `/loopwright-flow`, return to the flow.
94
+ On "confirm and continue in a fresh context", after the `plan: confirmed` step and the base-commit rerun above, in this order:
95
+ 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`.
96
+ 2. Re-read the task file and write any decision made in this conversation that it is missing.
97
+ 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.
98
+ 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.
74
99
 
75
100
  ## Fix tasks
76
101
 
@@ -9,19 +9,19 @@ Reviewers judge in their own context. This thread dispatches them, merges their
9
9
  ## Setup
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
- 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>` (`null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/` with the first task, so continue and the next step reports "no active task". Not a git repo → tell the user loopwright must run inside a git repo, stop).
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status` → `task` (relative to `<lw>`) and `baseCommit`. "no active task" → point the user to `/loopwright-flow`, stop.
14
- 4. Read the task file header (`tier`, `two-pass`, `fix-round cap`) and `<lw>/config.json` (`crossAgentReview`, `models.crossAgentReviewer`; missing → `off`).
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" brief reviewer` → `dir` (`<lw>`), `task` (relative to `<lw>`), `baseCommit`, `config` (`crossAgentReview`, `crossAgentReviewer` = `models.crossAgentReviewer`; missing → `off`), `effort`. `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.
13
+ 3. `task: null` → "no active task": point the user to `/loopwright-flow`, stop.
14
+ 4. Read the task file header (`tier`, `two-pass`, `fix-round cap`).
15
15
  5. Scope: small/standard → the task. Large → the first `S<n> [tested]` slice, or `whole` once every slice is `[passed]`.
16
16
  6. Round `n` = number of `- R` lines in `## Review log` for this scope after the last `- Scope change:` line (all of them if there is none) + 1.
17
17
 
18
18
  ## Passes
19
19
 
20
- 1. `node "{{LW_HOME}}/hooks/lw.mjs" stage review`, and set `stage: review` in the header.
21
- 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 output of `node "{{LW_HOME}}/hooks/lw.mjs" effort reviewer` on the spawn; if the spawn rejects `effort`, fall back to spawning without it (the agent file's effort applies). Use the same effort for the second pass.
20
+ 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).
21
+ 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.
22
22
  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. Report no longer available → skip and note it in the log line.
23
23
  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):
24
- - 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 `fingerprint`, 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 output of `lw.mjs effort reviewer`; omit `--effort` if that command fails):
24
+ - 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 `fingerprint`, 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):
25
25
  `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"`
26
26
  The verdict is the top-level `structured_output` field.
27
27
  - 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`.
@@ -36,11 +36,11 @@ Merge all passes: union of `blocking`, union of `undecided` (drop exact duplicat
36
36
 
37
37
  - **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 and run `/loopwright-build` with the Blocking findings verbatim; then review again (round n + 1). Undecided findings of this round are only counted; the next round re-checks them.
38
38
  - Only **Undecided** → present each to the user, one at a time (Claude: `AskUserQuestion`; Codex: numbered text), with its location, expectation and proof; 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. All dismissed → pass.
39
- - 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, set `stage: <plan|test>` in the task file header (for plan also `plan: draft`), then continue with `/loopwright-plan` or `/loopwright-test`. Run it only after the user chooses it.
39
+ - 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.
40
40
  - Nothing open → `node "{{LW_HOME}}/hooks/lw.mjs" verdict pass --round <n>`.
41
41
  - 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. A passing slice review only 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, then the slice loop goes on.
42
- - 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" await-user "siblings of the fixed bug"` after the `verdict` command (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`.
43
- - Include → append `- Scope change: siblings included` to the review log, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen plan "include siblings in the fix"`, set `stage: plan` and `plan: draft` in the task file header, 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).
42
+ - 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`.
43
+ - 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).
44
44
  - No (follow-ups only) → write the siblings under `## Follow-ups` in the task file (`path:line — why`) and go to `/loopwright-done`.
45
45
 
46
46
  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:
@@ -50,5 +50,10 @@ Large tier: `- R<n> S<k>: …` for a slice, `- R<n> whole: …` for the whole-br
50
50
  ## After a pass
51
51
 
52
52
  - small/standard → `/loopwright-done`.
53
- - large → mark the slice `S<n> [passed]`; next `[todo]` slice → `/loopwright-test`. When the last slice passes, run this skill again with scope `whole` (the diff against the base commit, all ACs); its fixes go through Build without new tests. Whole-branch pass → `/loopwright-done`.
53
+ - large → mark the slice `S<n> [passed]`; a `[todo]` slice remains → ask the question below, then `/loopwright-test` (or the fresh-context steps). When the last slice passes, run this skill again with scope `whole` (the diff against the base commit, all ACs); its fixes go through Build without new tests. Whole-branch pass → `/loopwright-done`.
54
+ - Large, after marking the slice `[passed]`, and a [todo] slice remains: ask one question, continue here or continue in a fresh context, with the reason in one sentence, stated as a tradeoff: later turns re-read the whole conversation, so a fresh context saves tokens when much of the task remains (several slices left), but the new session rewrites the cache, which can cost more than it saves when little remains; nothing is lost either way because the task file holds the plan. Not asked after the last slice, after a whole-branch review, or on a small or standard task. Run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "<reason>"` before asking and `resume` after the answer. On "continue in a fresh context", in this order:
55
+ 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`.
56
+ 2. Re-read the task file and write any decision made in this conversation that it is missing.
57
+ 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.
58
+ 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.
54
59
  - Any code edit after a pass makes the verdict stale; review again.
@@ -9,24 +9,25 @@ The tester writes acceptance tests from the confirmed ACs and locks them. This t
9
9
  ## Setup
10
10
 
11
11
  1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
- 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>` (`null` inside a git repo → no task has started here yet; `lw.mjs start` creates `.loopwright/` with the first task, so continue and the next step reports "no active task". Not a git repo → tell the user loopwright must run inside a git repo, stop).
13
- 3. `node "{{LW_HOME}}/hooks/lw.mjs" status` → `task` (path relative to `<lw>`). "no active task" → stop and point the user to `/loopwright-plan` or `/loopwright-flow`.
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" brief tester` → `dir` (`<lw>`), `task` (path relative to `<lw>`), `stage`, `lockedTests`, `reopened`, `effort`. `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.
13
+ 3. `task: null` → "no active task": stop and point the user to `/loopwright-plan` or `/loopwright-flow`.
14
14
  4. Read the task file header.
15
15
  - `tier: small` and `kind` feature (or no `kind`) → there is no Test stage; say so and go to `/loopwright-build`. `kind: fix` at tier small → Test runs: a fix is never built without a locked repro test.
16
16
  - Header not `plan: confirmed` (or no ACs, or ACs without an interface) → stop; point the user to `/loopwright-plan`.
17
- - Reopened task (`status` `history` has a `reopen` event after the last `stage build` event; that event's `reason` says why) → the scope is the ACs the reason and the task file's added or changed ACs name, in whichever slices hold them (a `[tested]` or `[passed]` slice included), not the first `[todo]` slice. Existing locked tests for those ACs may be edited and re-locked.
17
+ - Reopened task (`reopened` is not `null`; its `reason` says why) → the scope is the ACs the reason and the task file's added or changed ACs name, in whichever slices hold them (a `[tested]` or `[passed]` slice included), not the first `[todo]` slice. Existing locked tests for those ACs may be edited and re-locked.
18
18
  - `tier: large`, not reopened → the current slice is the first `S<n> [todo]` line; test only its ACs.
19
19
 
20
20
  ## Steps
21
21
 
22
- 1. `node "{{LW_HOME}}/hooks/lw.mjs" stage test`, and set `stage: test` in the task file header.
23
- 2. Now spawn the `loopwright-tester` subagent and wait for its result. Give it only the absolute task file path (`<lw>/<task>`) and, for large tier, "Write tests only for slice S<n>: AC…". Reopened: "Reopened task: the reason is … Write or edit tests only for AC…; existing locked tests for them may be edited and re-locked." No chat history, no implementation hints. On Claude Code pass `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort tester` on the spawn; if the spawn rejects `effort`, fall back to spawning without it (the agent file's effort applies).
22
+ 1. `node "{{LW_HOME}}/hooks/lw.mjs" stage test` (it updates the task file header `stage:` line; if it prints `"header": false`, set that line by hand).
23
+ 2. Now spawn the `loopwright-tester` subagent and wait for its result. Give it only the absolute task file path (`<lw>/<task>`) and, for large tier, "Write tests only for slice S<n>: AC…". Reopened: "Reopened task: the reason is … Write or edit tests only for AC…; existing locked tests for them may be edited and re-locked." No chat history, no implementation hints. 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).
24
24
  Fix tasks: also say the task is a fix whose `## Bug report` it must read, and name any existing test the scout or the user found already failing with the reported symptom.
25
25
  3. Verify the report:
26
- - `node "{{LW_HOME}}/hooks/lw.mjs" status` → `lockedTests` must contain every test file and fixture the report lists. A reported file missing from the locks → run `node "{{LW_HOME}}/hooks/lw.mjs" lock <file>` yourself.
26
+ - `node "{{LW_HOME}}/hooks/lw.mjs" brief tester` → `lockedTests` must contain every test file and fixture the report lists. A reported file missing from the locks → run `node "{{LW_HOME}}/hooks/lw.mjs" lock <file>` yourself.
27
27
  - Every in-scope AC has a test, and each failure excerpt shows the expected reason (missing behavior, missing module/export at the named path), not a syntax or setup error. Reopened: an edited or re-locked test for behavior Build already implemented may pass; the report must say so, and a pass is accepted only when the test checks the changed contract. Otherwise spawn the `loopwright-tester` subagent and wait for its result again, naming the problem.
28
+ - Read the new test files. Comments or doc blocks that restate a test name or an acceptance criterion break the standards: spawn the `loopwright-tester` subagent and wait for its result again, naming the files, before Build; it may edit and re-lock its own tests for this.
28
29
  - Fix tasks: compare each repro failure excerpt with the `observed` line in `## Bug report`. A different error type or message, or a different wrong output, is a mismatch (the test does not match the reported symptom): send the tester back with the mismatch described, via the same spawn rule. A `[regression]` test is expected to pass; one that fails is a `Needs` item.
29
- - Fix tasks, no repro (the tester locked no `[repro]` test and `Needs` says it could not reproduce): run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "no repro for the reported bug"`, show the tester's `Needs` (what it tried, what happened, what evidence is missing), then ask one question, recommendation first. After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume`, then `node "{{LW_HOME}}/hooks/lw.mjs" stage test`, so a `reopen` by a subagent you spawn next does not directly follow the `resume`.
30
+ - Fix tasks, no repro (the tester locked no `[repro]` test and `Needs` says it could not reproduce): run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "no repro for the reported bug"`, show the tester's `Needs` (what it tried, what happened, what evidence is missing), then ask one question, recommendation first. After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume && node "{{LW_HOME}}/hooks/lw.mjs" stage test` as one call, so a `reopen` by a subagent you spawn next does not directly follow the `resume`.
30
31
  - (a) Provide the missing evidence: add it to `## Bug report`, dispatch the tester again.
31
32
  - (b) Find the faulty unit: spawn the `loopwright-scout` subagent and wait for its result, asking it to investigate the internals and name a suspect unit and why. The user confirms or corrects the unit. Then add a `[repro]` criterion at that unit's interface to the task file (`[asked]` decision) and dispatch the tester again.
32
33
  - (c) Stop the task: set `status: stopped` in the task file header and run `node "{{LW_HOME}}/hooks/lw.mjs" done` (the task file stays).
@@ -38,5 +39,5 @@ The tester writes acceptance tests from the confirmed ACs and locks them. This t
38
39
  ## Rules
39
40
 
40
41
  - Never write task ids (AC, D, S shorthands) into tests, code, comments, commit messages or PR drafts.
41
- - Lock only in this stage, and only the tests for this stage's scope (the task, or the current slice). Never re-lock an existing locked test, except after a reopen (the user chose to go back), where the tester may edit and re-lock the tests in the reopened scope. Outside a reopen, if one is wrong, tell the user and let them decide.
42
+ - Lock only in this stage, and only the tests for this stage's scope (the task, or the current slice). Never re-lock an existing locked test, except after a reopen (the user chose to go back), where the tester may edit and re-lock the tests in the reopened scope, or when this stage's verification re-dispatches the tester before Build. Outside a reopen, if one is wrong, tell the user and let them decide.
42
43
  - Do not read the implementation to judge the tests; the ACs are the contract.
package/dist/cli.js CHANGED
@@ -413,7 +413,11 @@ function hookSpecs(tool) {
413
413
  event: "SessionStart",
414
414
  matcher: "compact",
415
415
  script: "reinject-context.mjs"
416
- }
416
+ },
417
+ ...tool === "claude" ? [{
418
+ event: "PreCompact",
419
+ script: "precompact-instructions.mjs"
420
+ }] : []
417
421
  ];
418
422
  }
419
423
  function hookCommand(tool, targets, script) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "loopwright",
3
3
  "author": "Xuan Son Trinh",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "Agent workflow installer for Claude Code, Codex and Junie",
6
6
  "type": "module",
7
7
  "bin": {