loopwright 0.1.8 → 0.1.10
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 +6 -2
- package/content/agents/implementer.md +2 -0
- package/content/agents/reviewer.md +5 -5
- package/content/agents/tester.md +1 -0
- package/content/hooks/default-config.json +1 -0
- package/content/hooks/lib.mjs +4 -0
- package/content/hooks/lw.mjs +7 -1
- package/content/hooks/plain-questions.mjs +79 -0
- package/content/hooks/precompact-instructions.mjs +12 -2
- package/content/hooks/reinject-context.mjs +17 -9
- package/content/prompts/reviewer.md +2 -0
- package/content/prompts/simplifier.md +42 -0
- package/content/prompts/standards.md +1 -0
- package/content/prompts/user-messages.md +50 -0
- package/content/skills/loopwright-build/SKILL.md +5 -2
- package/content/skills/loopwright-done/SKILL.md +9 -0
- package/content/skills/loopwright-explore/SKILL.md +2 -0
- package/content/skills/loopwright-fix/SKILL.md +3 -1
- package/content/skills/loopwright-flow/SKILL.md +8 -5
- package/content/skills/loopwright-park/SKILL.md +2 -0
- package/content/skills/loopwright-plan/SKILL.md +7 -5
- package/content/skills/loopwright-review/SKILL.md +30 -5
- package/content/skills/loopwright-test/SKILL.md +6 -3
- package/dist/cli.js +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,7 +50,9 @@ flowchart TD
|
|
|
50
50
|
tier -- "standard" --> test["Test<br/>tester writes and locks acceptance tests"]
|
|
51
51
|
tier -- "large" --> slices["Split into slices<br/>each runs Test, Build, Review,<br/>then one whole-branch review"]
|
|
52
52
|
test --> build["Build<br/>implementer makes the tests pass"]
|
|
53
|
-
build -->
|
|
53
|
+
build -- "round 1: standard, large, fix" --> simplify["Simplify<br/>reviewer proposes cuts, you pick,<br/>approved ones are applied"]
|
|
54
|
+
build -- "small feature or fix round" --> review
|
|
55
|
+
simplify --> review{"Review<br/>separate reviewer: passes?"}
|
|
54
56
|
review -- "blocking findings, rounds left" --> build
|
|
55
57
|
review -- "fix-round cap reached" --> you{{"You decide"}}
|
|
56
58
|
review -- "pass" --> done["Done<br/>AGENTS.md proposals, commit and PR draft"]
|
|
@@ -61,6 +63,7 @@ flowchart TD
|
|
|
61
63
|
- **Plan** runs in your session. Plan first restates your goal for you to confirm or correct. A read-only scout then maps the repo, then you answer the high-impact questions one at a time and confirm the plan. Nothing is built before that.
|
|
62
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.
|
|
63
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
|
+
- **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.
|
|
64
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.
|
|
65
68
|
- **Done**: proposes `AGENTS.md` updates and drafts the commit and PR message. You approve each change; loopwright never commits.
|
|
66
69
|
|
|
@@ -88,7 +91,8 @@ Run a single stage, or the whole loop with `flow`. In Codex, use `$` instead of
|
|
|
88
91
|
|---|---|---|---|
|
|
89
92
|
| Skills install | Supported, tested | WIP: installed, not tested end-to-end | WIP: reads `.agents/skills` |
|
|
90
93
|
| Subagents (scout, tester, implementer, reviewer) | Supported, tested | WIP: installed, not tested end-to-end | WIP: `.junie/agents` |
|
|
91
|
-
| Hook enforcement (locked-test guard, stop gate, context reinjection, compaction instructions on Claude Code) | Supported, tested | WIP: installed, not tested end-to-end | Experimental (`--experimental junie-hooks`, Early Access) |
|
|
94
|
+
| Hook enforcement (locked-test guard, stop gate, context reinjection, plus compaction instructions and the question check on Claude Code only) | Supported, tested | WIP: installed, not tested end-to-end | Experimental (`--experimental junie-hooks`, Early Access) |
|
|
95
|
+
| Plain-words rules for messages to you | Supported | WIP: installed, not tested end-to-end | WIP: reads `.agents/skills` |
|
|
92
96
|
| Structured questions | `AskUserQuestion` | Plain-text fallback (numbered options) | Plain-text fallback |
|
|
93
97
|
| Cross-agent review (as the reviewer) | Supported, tested | WIP: untested | Not supported |
|
|
94
98
|
| Global install | Supported, tested | WIP: installed, not tested end-to-end | WIP: `~/.junie/agents` |
|
|
@@ -9,6 +9,8 @@ You are the loopwright implementer. You make the smallest change that satisfies
|
|
|
9
9
|
|
|
10
10
|
The main thread gives you the task file path, and on a fix round the reviewer's Blocking findings. Read the task file fresh every time: goal, decisions (`D…`), acceptance criteria (`AC…`), check commands, locked tests. The task file wins over any summary in your prompt.
|
|
11
11
|
|
|
12
|
+
Approved simplifications (the main thread lists them verbatim, each approved by the user): apply only those, in place of Step 3's implementing, and add no unit tests. They are exempt from "no unrelated cleanups"; behavior must stay identical. Steps 1, 2 and 4 still run; skip Step 5, your own simplify pass, which could cut what the user did not approve. Write no `Root cause:` line on that run, even on a fix task.
|
|
13
|
+
|
|
12
14
|
## Boundaries
|
|
13
15
|
|
|
14
16
|
- Do not edit, move, delete or reformat locked test files (`node "{{LW_HOME}}/hooks/lw.mjs" status` lists them under `lockedTests`). Do not change test config to skip or weaken them. Review re-hashes them; any change fails the review.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: loopwright-reviewer
|
|
3
|
-
description:
|
|
3
|
+
description: Reads a change against its task file and standards under a procedure file the caller names (a review verdict by default, or a list of proposed simplifications) and returns that procedure's JSON output. Never edits code.
|
|
4
4
|
tools: Read, Grep, Glob, Bash
|
|
5
5
|
---
|
|
6
6
|
You are the loopwright reviewer, a context separate from the one that wrote the code.
|
|
7
7
|
|
|
8
|
-
Read
|
|
8
|
+
Read the procedure file the caller names and follow it exactly. It defines your inputs, the procedure and the output format. With no procedure file named, the default is `{{LW_HOME}}/prompts/reviewer.md`.
|
|
9
9
|
|
|
10
10
|
Boundaries, which hold even where your tools would allow more:
|
|
11
11
|
- Do not modify any file. Bash is for reading, running tests and check commands, and the read-only `lw.mjs` commands named in the procedure.
|
|
12
|
-
-
|
|
13
|
-
- You cannot ask the user questions.
|
|
12
|
+
- Under `reviewer.md`, in the blind pass, do not read or ask for the implementer's report. Run the second pass only when the caller supplies that report.
|
|
13
|
+
- You cannot ask the user questions. Under `reviewer.md`, anything you cannot confirm but can back with proof goes in `undecided`.
|
|
14
14
|
|
|
15
|
-
Your final message is the JSON verdict object and nothing else.
|
|
15
|
+
Your final message is the output the named procedure defines (for `reviewer.md`, the JSON verdict object) and nothing else.
|
package/content/agents/tester.md
CHANGED
|
@@ -14,6 +14,7 @@ The main thread gives you the task file path. Read its acceptance criteria (`AC
|
|
|
14
14
|
- Read implementation files only as far as needed to import public interfaces (module paths, exported names, signatures). Do not read or test internals.
|
|
15
15
|
- Reopened task (the main thread says so and names the scope): you may edit the existing locked tests for the named ACs, then re-lock them. Leave every other locked test untouched.
|
|
16
16
|
- Pulled locked tests (the main thread lists the files from `pulledLocks`): check each still tests its acceptance criteria, edit only what the pull broke, then re-lock only those files. Leave every other locked test untouched.
|
|
17
|
+
- Approved cuts to locked tests (the main thread lists them, each approved by the user): apply only those cuts, to the files they name. Each test must still pass against the built code and check the same behavior as before. Rerun the tests, then re-lock only the files you cut; leave every other locked test untouched.
|
|
17
18
|
- Re-dispatched during Test-stage verification (the main thread names the problem, e.g. comments restating a test name): you may edit and re-lock your own tests; this is the same re-lock as a reopen, before Build.
|
|
18
19
|
- Read `{{LW_HOME}}/prompts/standards.md` and follow it in the tests you write.
|
|
19
20
|
- Write only test files (and fixtures they need). Do not create or edit implementation code, not even stubs.
|
package/content/hooks/lib.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
writeFileSync,
|
|
13
13
|
} from 'node:fs';
|
|
14
14
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
15
16
|
|
|
16
17
|
/** Mirror of PROFILES in src/core/profiles.ts (a test pins them equal). */
|
|
17
18
|
export const PROFILES = {
|
|
@@ -21,6 +22,9 @@ export const PROFILES = {
|
|
|
21
22
|
deep: { scout: 'xhigh', tester: 'xhigh', implementer: 'xhigh', reviewer: 'xhigh' },
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
/** Hooks sit in `<loopwright home>/hooks`, the prompts beside them. */
|
|
26
|
+
export const USER_MESSAGES_RULES = fileURLToPath(new URL('../prompts/user-messages.md', import.meta.url));
|
|
27
|
+
|
|
24
28
|
const MAX_BUFFER = 1024 * 1024 * 1024;
|
|
25
29
|
|
|
26
30
|
function git(cwd, args) {
|
package/content/hooks/lw.mjs
CHANGED
|
@@ -836,7 +836,13 @@ try {
|
|
|
836
836
|
headMoved: state && movedHead(state),
|
|
837
837
|
ownCommits: state ? ownCommits(state) : undefined,
|
|
838
838
|
reopened: reopen ? { target: reopen.detail, reason: reopen.reason } : null,
|
|
839
|
-
config: {
|
|
839
|
+
config: {
|
|
840
|
+
maxFixRounds,
|
|
841
|
+
crossAgentReview,
|
|
842
|
+
simplify: cfg.simplify ?? true,
|
|
843
|
+
docsDir,
|
|
844
|
+
crossAgentReviewer: models?.crossAgentReviewer,
|
|
845
|
+
},
|
|
840
846
|
effort,
|
|
841
847
|
});
|
|
842
848
|
break;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// PreToolUse hook (Claude Code only): send an AskUserQuestion back for a rewrite when it holds a bare loopwright label.
|
|
3
|
+
// https://code.claude.com/docs/en/hooks.md (PreToolUse): tool_input.questions[] has question, header, options[].label and .description; exit 2 sends stderr to Claude.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
USER_MESSAGES_RULES,
|
|
8
|
+
allow,
|
|
9
|
+
deny,
|
|
10
|
+
exitIfHooksOff,
|
|
11
|
+
failOpen,
|
|
12
|
+
loopwrightDir,
|
|
13
|
+
readState,
|
|
14
|
+
readStdinJson,
|
|
15
|
+
worktreeId,
|
|
16
|
+
writeState,
|
|
17
|
+
} from './lib.mjs';
|
|
18
|
+
|
|
19
|
+
// Two denials in a row, then the question goes through, so a stubborn one never loops.
|
|
20
|
+
const CAP = 2;
|
|
21
|
+
// Words only loopwright uses; common words with a loopwright meaning (tier, slice, lock) are left to the rules file.
|
|
22
|
+
// The closing \b keeps everyday words out ("fix rounding", "two passwords", "stop gateway").
|
|
23
|
+
const PHRASES = /\b(?:stop[- ]gates?|re-?lock(?:s|ed|ing)?|fix[- ]rounds?|two[- ]pass|acceptance criteri(?:a|on))\b/gi;
|
|
24
|
+
// Text after a plain description: in brackets, parentheses or backticks.
|
|
25
|
+
const LABELLED = /\([^)]*\)|\[[^\]]*\]|`[^`]*`/g;
|
|
26
|
+
|
|
27
|
+
exitIfHooksOff();
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
// Unreadable input is not this hook's to report.
|
|
31
|
+
const input = await readStdinJson().catch(() => allow());
|
|
32
|
+
if (input.tool_name !== 'AskUserQuestion') allow();
|
|
33
|
+
const cwd = input.cwd || process.cwd();
|
|
34
|
+
const dir = loopwrightDir(cwd);
|
|
35
|
+
if (!dir) allow();
|
|
36
|
+
const id = worktreeId(cwd);
|
|
37
|
+
const state = readState(dir, id);
|
|
38
|
+
if (!state?.task) allow();
|
|
39
|
+
|
|
40
|
+
// Only ids this task file defines, so `S3` in a question about Amazon S3 passes.
|
|
41
|
+
const defined = [...readFileSync(join(dir, state.task), 'utf8').matchAll(/^\s*- ((?:AC|[ADSRU])\d+)\b/gm)];
|
|
42
|
+
const ids = defined.length ? new RegExp(`\\b(?:${defined.map((m) => m[1]).join('|')})\\b`, 'g') : null;
|
|
43
|
+
|
|
44
|
+
const questions = input.tool_input?.questions ?? [];
|
|
45
|
+
const texts = questions.flatMap((q) => [
|
|
46
|
+
q.question,
|
|
47
|
+
q.header,
|
|
48
|
+
...(q.options ?? []).flatMap((o) => [o.label, o.description]),
|
|
49
|
+
]);
|
|
50
|
+
const found = [];
|
|
51
|
+
for (const text of texts) {
|
|
52
|
+
if (typeof text !== 'string') continue;
|
|
53
|
+
const bare = text.replace(LABELLED, ' ');
|
|
54
|
+
const terms = [...new Set([...(ids ? bare.matchAll(ids) : []), ...bare.matchAll(PHRASES)].map((m) => m[0]))];
|
|
55
|
+
if (terms.length) found.push(`- "${text}": ${terms.join(', ')}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const blocks = Number(state.questionBlocks) || 0;
|
|
59
|
+
if (found.length === 0 || blocks >= CAP) {
|
|
60
|
+
if (blocks) {
|
|
61
|
+
delete state.questionBlocks;
|
|
62
|
+
writeState(dir, id, state);
|
|
63
|
+
}
|
|
64
|
+
allow();
|
|
65
|
+
}
|
|
66
|
+
state.questionBlocks = blocks + 1;
|
|
67
|
+
writeState(dir, id, state);
|
|
68
|
+
deny(
|
|
69
|
+
'',
|
|
70
|
+
'',
|
|
71
|
+
[
|
|
72
|
+
'loopwright: this question has loopwright labels the user has not met, so it was not shown:',
|
|
73
|
+
...found,
|
|
74
|
+
`Say each one in everyday words first and put the label in brackets after it, as in ${USER_MESSAGES_RULES}. Then ask again.`,
|
|
75
|
+
].join('\n'),
|
|
76
|
+
);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
failOpen(err);
|
|
79
|
+
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// PreCompact hook (Claude Code only): tell compaction what the summary must keep while a task is active.
|
|
3
3
|
// https://code.claude.com/docs/en/hooks.md (PreCompact output): exit 0 with stdout uses the stdout as instructions for the compaction summary.
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
USER_MESSAGES_RULES,
|
|
6
|
+
allow,
|
|
7
|
+
exitIfHooksOff,
|
|
8
|
+
failOpen,
|
|
9
|
+
loopwrightDir,
|
|
10
|
+
readState,
|
|
11
|
+
readStdinJson,
|
|
12
|
+
worktreeId,
|
|
13
|
+
} from './lib.mjs';
|
|
5
14
|
|
|
6
15
|
exitIfHooksOff();
|
|
7
16
|
|
|
@@ -21,7 +30,8 @@ try {
|
|
|
21
30
|
'- any question the user has not answered yet, with its options;',
|
|
22
31
|
'- unresolved review findings, verbatim;',
|
|
23
32
|
'- the implementer report, if a second review pass is still due;',
|
|
24
|
-
'- any user decision that is not yet written in the task file
|
|
33
|
+
'- any user decision that is not yet written in the task file;',
|
|
34
|
+
`- that every message to the user follows ${USER_MESSAGES_RULES}, which is read again after compaction.`,
|
|
25
35
|
'After compaction, re-read the task file before continuing.',
|
|
26
36
|
);
|
|
27
37
|
process.stdout.write(lines.join('\n') + '\n');
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
// SessionStart(compact) hook: re-inject the active task summary after context compaction.
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
USER_MESSAGES_RULES,
|
|
7
|
+
allow,
|
|
8
|
+
exitIfHooksOff,
|
|
9
|
+
failOpen,
|
|
10
|
+
loopwrightDir,
|
|
11
|
+
readState,
|
|
12
|
+
readStdinJson,
|
|
13
|
+
worktreeId,
|
|
14
|
+
} from './lib.mjs';
|
|
6
15
|
|
|
7
16
|
const NEXT = {
|
|
8
17
|
plan: 'Continue /loopwright-plan: finish the assumption ledger and confirm the tier.',
|
|
@@ -65,14 +74,13 @@ try {
|
|
|
65
74
|
} else {
|
|
66
75
|
lines.push(`Stage: ${state.stage}`);
|
|
67
76
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const out = body.join('\n');
|
|
77
|
+
const closing = [
|
|
78
|
+
`Write every message to the user by ${USER_MESSAGES_RULES}; read it again before your next one.`,
|
|
79
|
+
state.awaitingUser
|
|
80
|
+
? `Waiting on the user: ${state.awaitingUser} — do not proceed until they answer; then run lw.mjs resume.`
|
|
81
|
+
: (NEXT[state.stage] ?? NEXT.plan),
|
|
82
|
+
];
|
|
83
|
+
const out = [...lines.slice(0, 40 - closing.length), ...closing].join('\n');
|
|
76
84
|
|
|
77
85
|
if (tool === 'codex') {
|
|
78
86
|
process.stdout.write(
|
|
@@ -36,6 +36,7 @@ Second pass: only when the caller hands you the implementer's report. Verify eac
|
|
|
36
36
|
- bugs, regressions, security vulnerabilities;
|
|
37
37
|
- architecturally bad decisions;
|
|
38
38
|
- non-simplified code paths (a much simpler path does the same; the finding must show the smaller version);
|
|
39
|
+
- duplicated code (proof: both locations), fixed by calling or extending one of them;
|
|
39
40
|
- duplicated docs: the change states a fact that another doc, comment or contract already states (proof: both locations; the fix is to remove the new copy and link, never to delete the older home);
|
|
40
41
|
- bypassed mechanism: the change branches or hardcodes what an existing mechanism (config, registry, helper) already handles (proof: the mechanism `path:line`);
|
|
41
42
|
- missing tests for new behavior;
|
|
@@ -43,6 +44,7 @@ Second pass: only when the caller hands you the implementer's report. Verify eac
|
|
|
43
44
|
- violations of the other named rules in `standards.md` (comment rule included);
|
|
44
45
|
- deviations from the standards docs or established codebase patterns.
|
|
45
46
|
Exclude lint/format-level nits; mechanical checks own them. Exception: a lint or format check failing on a changed file that is not locked is Blocking; failing on a locked test file is Undecided (the user decides, Build cannot touch it). A failing test assertion stays Blocking.
|
|
47
|
+
Do not report a candidate that a task decision explicitly keeps.
|
|
46
48
|
A proven violation of a named rule in `standards.md` is high impact (Blocking when confidence is high). Without that proof (smaller version, both locations, mechanism `path:line`, or the hunk) it is dropped. A violation inside a locked test file stays Undecided (the user decides, Build cannot touch it).
|
|
47
49
|
5. **Investigate each candidate.** Self-verify first: re-read the code, run a repro or a test. Then assign impact (high/mid/low) and confidence (high/mid/low).
|
|
48
50
|
6. **Report.**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# loopwright simplify procedure
|
|
2
|
+
|
|
3
|
+
You propose behavior-preserving cuts to one change. You do not apply them. 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
|
+
|
|
5
|
+
State tool: `node "{{LW_HOME}}/hooks/lw.mjs" <cmd>`, run from the task's worktree. Use only `status`, invoked exactly as written here.
|
|
6
|
+
|
|
7
|
+
## Inputs
|
|
8
|
+
|
|
9
|
+
- the task file (the caller gives you its absolute path); read its goal, decisions (`D…`) and acceptance criteria (`AC…`),
|
|
10
|
+
- scope: the diff against the base commit (`baseCommit` in `status`): `git diff <baseCommit>` plus untracked files from `git status --porcelain`. Every changed file is in scope, prose included. Nothing outside the diff is in scope,
|
|
11
|
+
- standards: `{{LW_HOME}}/prompts/standards.md`, `AGENTS.md` and the `docs/agents/` docs it links.
|
|
12
|
+
|
|
13
|
+
## Procedure
|
|
14
|
+
|
|
15
|
+
1. Read the task file, the diff and the code around it until you know what each changed hunk is for.
|
|
16
|
+
2. Look for cuts: code the diff duplicates from existing code or from itself, wrappers and helpers with one call site that add nothing, dead or unused code, docs, tests or comments that repeat another place, speculative options nobody asked for. Use the rules in `standards.md` as the yardstick.
|
|
17
|
+
3. For each cut, check it against the task: a cut must never change public behavior, a decision or an acceptance criterion. A cut that weakens what a test checks is a trade-off, not an obvious cut.
|
|
18
|
+
4. Readability guard: never propose dense one-liners, nested ternaries, clever tricks, or merging separate concerns into one function to save lines. A cut that saves lines but makes the code harder to read is dropped.
|
|
19
|
+
5. Sort each kept cut:
|
|
20
|
+
- **obvious**: no one would object (dead code, an exact duplicate, a wrapper that only forwards). It loses nothing.
|
|
21
|
+
- **trade-off**: it saves lines but gives something up (a test case, a guard, a doc sentence, a named step).
|
|
22
|
+
- A cut inside a locked test file (`lockedTests` in `status`) is always a trade-off cut, never an obvious one.
|
|
23
|
+
6. Keep at most 8 trade-off cuts, largest net line change first; drop the rest. Obvious cuts have no cap.
|
|
24
|
+
|
|
25
|
+
## Output
|
|
26
|
+
|
|
27
|
+
Output exactly one JSON object with nothing before or after it: no prose, no code fence. Shape:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
{"obvious": [{"location": "src/a.ts:10-24", "change": "call parse() from b.ts instead of the copy", "lines": -12}], "tradeoffs": [{"location": "test/a.test.ts:5-40", "change": "merge the two cases that differ only in the input", "lines": -18, "basis": "both blocks at test/a.test.ts:5 and :23 differ only in the value", "loses": "a separate failure message for each input"}]}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `obvious` and `tradeoffs` — the two lists, both always present.
|
|
34
|
+
- `location` — `path:line` or `path:start-end`.
|
|
35
|
+
- `change` — the cut in one sentence, concrete enough to apply verbatim.
|
|
36
|
+
- `lines` — the net line change as a negative integer (a cut that adds lines elsewhere counts them).
|
|
37
|
+
- `basis` — proof the cut is safe: both locations of a duplicate, the existing mechanism `path:line`, or the unused symbol. Trade-off cuts only.
|
|
38
|
+
- `loses` — what the user gives up. Trade-off cuts only.
|
|
39
|
+
|
|
40
|
+
Both lists empty → `{"obvious": [], "tradeoffs": []}`.
|
|
41
|
+
|
|
42
|
+
Never write task ids (AC, D, S shorthands) into `change`, `basis` or `loses`.
|
|
@@ -8,6 +8,7 @@ Shared by the tester, implementer and reviewer. The repo's own docs on architect
|
|
|
8
8
|
- **Fewest clear lines.** Write the smallest version that is still readable. Why: every line is read, tested and maintained.
|
|
9
9
|
- **Respect the layers.** Keep code in the layer the repo docs (`AGENTS.md`, `ARCHITECTURE.md`, `docs/`) assign it; do not reach across them. Why: crossed layers make later changes spread.
|
|
10
10
|
- **No trivial wrappers or one-off helpers.** Call the underlying function. A helper with one call site exists only if it names a step the reader would otherwise have to decode. Why: an indirection that adds nothing hides where the work happens.
|
|
11
|
+
- **No duplicated code.** Call or extend existing code instead of writing a near-copy; two blocks that differ only in a value become one. Test files are code too: share setup and cases instead of repeating them. Why: each copy is a second place to fix and they drift apart.
|
|
11
12
|
- **Delete what you replace.** Remove the code, tests and docs your change makes dead: no old path kept "just in case", no unused parameters, no unrequested compatibility shims. Why: dead code reads as live behavior.
|
|
12
13
|
- **Validate at the boundaries.** Check input where it enters (user, network, files), not again in every inner function; trust types inside. No guards for impossible states, no catch blocks that swallow errors, no fallbacks that hide bugs. Why: repeated checks disagree and bury the real one.
|
|
13
14
|
- **No speculative generality.** Build for the cases the task states, not ones that might come: no interface with one implementation, no option or parameter nobody asked for, no generic version of a one-off. A requested per-environment flag is not speculative. Why: unused options are code to maintain with no proof they fit.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# loopwright user messages
|
|
2
|
+
|
|
3
|
+
How to write every message the main thread shows the user during loopwright work: stage updates, questions, the assumption list, the plan, review findings, deviations, Simplify cuts, Done questions. Read it once per conversation, before the first message to the user.
|
|
4
|
+
|
|
5
|
+
The reader knows neither loopwright nor this code, and every "what do you mean?" costs a full extra turn. Commit messages, PR descriptions and `AGENTS.md` text keep their own rules; these rules cover the messages that present them. Subagent reports keep their formats; rewrite what you relay from them.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
1. **Outcome or decision first.** Open with what happened or what you need decided, then the reason. Why: a reader who stops after one sentence still has the point.
|
|
10
|
+
2. **Write for a reader who has not seen the code, the tool output or the task file.** Say what a thing is before you use it, and never lean on something only you read. Why: you have seen files the user never opened, so your shorthand feels obvious to you and is a puzzle to them.
|
|
11
|
+
3. **Plain description first, the name in brackets after.** Say what it is in everyday words, then give the file, function or loopwright term in brackets as a lookup pointer; a name or id never stands alone. Why: the plain words make the point, and the name still lets the user find it.
|
|
12
|
+
4. **Say what each finding or trade-off means for the user.** State the effect on what they will see or do, not only the technical fact. Why: a fact without its effect leaves the user to work out why they should care.
|
|
13
|
+
5. **One idea per sentence.** Aim for 15–20 words; the target is soft, so split a long sentence rather than cut meaning. Why: short sentences are read once, long ones twice, and hard caps make prose choppy.
|
|
14
|
+
6. **Use active voice and say who acts.** "The tester locks the tests", not "the tests are locked". Why: the user needs to know who did a thing, and who they need to answer.
|
|
15
|
+
7. **Use the same word for the same thing.** Do not coin labels during the work; if a term needs a name, introduce it with its plain description. Why: a second word for a thing reads as a second thing.
|
|
16
|
+
8. **Decision questions say what is decided and why, each option says what happens if chosen, and one recommendation comes with a reason.** Never a bare yes/no. Why: the user can pick without asking what an option does.
|
|
17
|
+
9. **Give one concrete example for a trade-off.** Show what it looks like for this change. Why: a trade-off in the abstract is hard to weigh, and one real case is quick to judge.
|
|
18
|
+
10. **Give the short answer first and details on request.** Explain only what this message needs, and offer the rest. Why: extra detail costs the user reading time now, while an offer costs nothing.
|
|
19
|
+
11. **Use literal words.** Write "do X", not "simply do X"; leave out "just", "easy" and "quickly". Why: these words claim something is easy and make a reader who struggles feel slow.
|
|
20
|
+
12. **End a step with a stand-alone recap.** Say what is done, what comes next and what you need from the user, so the message makes sense without scrolling back. Why: the user may return after a break with none of the earlier messages in mind.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
**Before:** AC1 and AC2 covered; locked: test/login.test.ts. D3 accepted.
|
|
25
|
+
**After:** Tests now check the two sign-in behaviors you asked for (a wrong password shows an error; a right one opens the dashboard). They are frozen, so the code writer cannot change them (test/login.test.ts). Next, the implementer writes the code.
|
|
26
|
+
|
|
27
|
+
**Before:** Deviation: D4 conflicts with locked test/login.test.ts ("Invalid password" vs "Wrong password"); implemented to the test, test untouched.
|
|
28
|
+
**After:** Your choice of error text and a frozen test disagree. You chose "Wrong password" for a failed sign-in, but the test expects "Invalid password" (test/login.test.ts). The implementer cannot change the test, so it wrote the code to show "Invalid password". Do you want to keep "Invalid password", or go back to the test step so the test is corrected and the code then shows "Wrong password"? I recommend going back: the test, not your choice, is what looks wrong.
|
|
29
|
+
|
|
30
|
+
**Before:** Tier: large, two slices, two-pass review on, fix-round cap 3.
|
|
31
|
+
**After:** This is a big change, so I will build it in two parts and review each part, then the whole. The reviewer checks twice because the speed claim cannot be shown by tests. A review that finds problems gets up to 3 repair attempts. Is that right?
|
|
32
|
+
|
|
33
|
+
## Glossary
|
|
34
|
+
|
|
35
|
+
- **Task id** (AC3, D2, A1, S2, R1, U1): a short label in the task file for one acceptance criterion, decision, assumption, slice, review round or undecided finding; say what the item is, never the label alone.
|
|
36
|
+
- **Acceptance criterion** (AC): one thing the finished work must do that you can see, such as "an expired link shows a clear message".
|
|
37
|
+
- **Acceptance test**: an automated test, written before the code, that checks one acceptance criterion; when it passes, that behavior works.
|
|
38
|
+
- **Lock** (locked test): a test file frozen with a fingerprint so the code writer cannot change it to make it pass.
|
|
39
|
+
- **Re-lock**: freezing a test file again after it was edited, which is allowed only after you chose to go back or approved a pull.
|
|
40
|
+
- **Tier**: how big the task is (small, standard or large); it sets how much process the task gets.
|
|
41
|
+
- **Profile**: how much effort the helper agents spend (lean, balanced, thorough or deep); more effort costs more time and tokens.
|
|
42
|
+
- **Slice**: one separately built and checked part of a large task.
|
|
43
|
+
- **Stop gate**: a check that keeps the agent from ending its turn while a build or review is unfinished.
|
|
44
|
+
- **Fix round**: one pass of repairing what a review found, followed by another review; each task has a limit.
|
|
45
|
+
- **Two-pass review**: the reviewer checks the change twice, once without hints and once against the implementer's own report of what it did.
|
|
46
|
+
- **Undecided finding**: a review concern the reviewer cannot settle alone, so you decide whether to fix it or dismiss it.
|
|
47
|
+
- **Deviation**: something the implementer did differently from the plan or could not do as planned; you accept it, ask for a fix, or go back.
|
|
48
|
+
- **Simplify cut**: a proposed removal of code, tests or docs that the change added and does not need; you choose which to apply.
|
|
49
|
+
- **Worktree**: a separate working folder of the same repository, on its own branch, so two tasks do not mix.
|
|
50
|
+
- **Base commit**: the saved point in git history where the task began; the review compares the work against it.
|
|
@@ -8,6 +8,8 @@ The implementer subagent writes the code. This thread dispatches it and hands th
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
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
15
|
3. `task: null` → "no active task": point the user to `/loopwright-plan` or `/loopwright-flow`, stop.
|
|
@@ -16,6 +18,7 @@ The implementer subagent writes the code. This thread dispatches it and hands th
|
|
|
16
18
|
- `standard` or `large` with no `lockedTests` (or, large, the current slice is still `[todo]`) → run `/loopwright-test` first.
|
|
17
19
|
- `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
20
|
- `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.
|
|
21
|
+
- `## Review log` has a `- Simplify:` line ending in `— apply pending` (an approved Simplify apply was interrupted) → run `/loopwright-review` to finish it, and stop here: skip steps 5–7 and the Steps below.
|
|
19
22
|
5. Moved branch. Skip this on a fix round (called with Review findings). `headMoved` in `brief` (new commits since the base commit, at least one already on the upstream branch, and not answered yet for this HEAD) → run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "branch moved"`, list the commits to the user and ask one question: are they pulled commits (leave them out of the review) or this task's own commits (keep them in)? After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and record it as a decision `D<n> [asked]`.
|
|
20
23
|
- `headMoved.keptEarlier` → an earlier answer kept commits in the review, so the branch holds both kinds whatever the answer: list only the new commits, and a 'pulled' answer takes the keep-base path below, with the both-kinds notice.
|
|
21
24
|
- `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.
|
|
@@ -35,8 +38,8 @@ The implementer subagent writes the code. This thread dispatches it and hands th
|
|
|
35
38
|
Never paste chat history, your own summary of the decisions, or design ideas; the task file is the source.
|
|
36
39
|
3. Keep the implementer report verbatim in this conversation; a two-pass review needs it.
|
|
37
40
|
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.
|
|
38
|
-
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.
|
|
39
|
-
5. Go straight to `/loopwright-review
|
|
41
|
+
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, in plain words following the rules file (what the implementer did differently from the plan, and why; never the raw report text), and ask (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.
|
|
42
|
+
5. Go straight to `/loopwright-review`, which runs Simplify before its passes. The stop gate blocks ending the turn in Build without a passing review.
|
|
40
43
|
|
|
41
44
|
## Rules
|
|
42
45
|
|
|
@@ -8,6 +8,8 @@ Done runs in this main thread; do not spawn the subagents here. You propose; the
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
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
15
|
3. `task: null` → "no active task": stop. Then `node "{{LW_HOME}}/hooks/lw.mjs" fingerprint`.
|
|
@@ -41,6 +43,13 @@ Draft both and show them to the user:
|
|
|
41
43
|
- A `## Follow-ups` section for every kind of task, listing the parked stubs by title and any follow-ups in the task file (still no task paths or ids).
|
|
42
44
|
- Fix tasks (`kind: fix`): the PR also states the root cause in one line (from `## Root cause`), the repro test name(s) with "failed before, passes after", and the follow-ups from `## Follow-ups`.
|
|
43
45
|
|
|
46
|
+
## Going back
|
|
47
|
+
|
|
48
|
+
When the user says at any question above that something needs fixing, and before Close, offer to go back; do not ask it on every run. Run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "go back from done"` before asking one question, in plain words following the rules file: back to Test, back to Plan, or stay in Done. Recommend Test when only a test or the code changes, Plan when a decision, acceptance criterion or the scope changes.
|
|
49
|
+
- Stay in Done → run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and continue.
|
|
50
|
+
- Plan or Test → run `node "{{LW_HOME}}/hooks/lw.mjs" resume`, append `- Scope change: <reason>` to the review log (the next review starts at round 1 and Simplify runs again), and record the go-back as `D<n> [asked]` with the user's reason. Then 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), directly after `resume` with no other `lw.mjs` call between, and only after the user chooses it. Then continue with `/loopwright-plan` or `/loopwright-test`.
|
|
51
|
+
- Applied AGENTS.md/docs edits and carried stubs are kept, not reverted; tell the user they enter the next review's diff.
|
|
52
|
+
|
|
44
53
|
## 4. Close
|
|
45
54
|
|
|
46
55
|
1. Set `status: done` in the task file header.
|
|
@@ -8,6 +8,8 @@ Writes a walkthrough of a codebase (or one folder, `/loopwright-explore services
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>`. `null` inside a git repo → no task has started here yet; `lw.mjs explore` creates `.loopwright/`, so continue. Not a git repo → tell the user loopwright must run inside a git repo, stop.
|
|
13
15
|
3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. A task in `build` or `review` is active → run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "exploring the codebase"` before the first question and `node "{{LW_HOME}}/hooks/lw.mjs" resume` after the last, so the stop gate does not push you past the gates. "no active task" is normal. Remember whether the stage is `test`, `build` or `review` (see Finish).
|
|
@@ -8,10 +8,12 @@ Entry for bug fixes. It reuses Plan, Test, Build, Review and Done with `kind: fi
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
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
15
|
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
|
-
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
|
|
16
|
+
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 nothing stops the code writer from editing the frozen tests (locked tests), nothing keeps the agent from stopping with work unfinished (stop gate), and a shortened conversation loses track of the task (context restore); run `npx loopwright init` to install them." Continue unless the user objects.
|
|
15
17
|
|
|
16
18
|
## Goal intake
|
|
17
19
|
|
|
@@ -8,9 +8,11 @@ Runs the stage skills in order for the confirmed tier and resumes where a task l
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
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. Not a git repo → tell the user loopwright must run inside a git repo, stop.
|
|
13
|
-
3. 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
|
|
15
|
+
3. 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 nothing stops the code writer from editing the frozen tests (locked tests), nothing keeps the agent from stopping with work unfinished (stop gate), and a shortened conversation loses track of the task (context restore); run `npx loopwright init` to install them." Continue unless the user objects. In Codex, hooks also need approval via `/hooks`.
|
|
14
16
|
4. Junie: if a `loopwright-<role>` subagent fails because its configured model is not available to the user, spawn it again without `model` and `reasoningLevel` (Junie's default); this is not an error to report.
|
|
15
17
|
|
|
16
18
|
## Resume
|
|
@@ -48,7 +50,7 @@ Follow each stage skill in turn (Claude Code `/loopwright-<stage>`, Codex `$loop
|
|
|
48
50
|
- standard (and any fix): `loopwright-plan` → `loopwright-test` → `loopwright-build` → `loopwright-review` → `loopwright-done`
|
|
49
51
|
- large: `loopwright-plan` → for each slice in order: `loopwright-test` → `loopwright-build` → `loopwright-review` → then one whole-branch `loopwright-review` → `loopwright-done`
|
|
50
52
|
- 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.
|
|
51
|
-
- Going back is the user's choice only: at a deviation,
|
|
53
|
+
- Going back is the user's choice only: at a deviation, an undecided review finding, or a fix the user raises at Done, 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.
|
|
52
54
|
- A failed review returns to `loopwright-build` and then `loopwright-review`, up to the task's fix-round cap.
|
|
53
55
|
|
|
54
56
|
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.
|
|
@@ -57,7 +59,7 @@ Exploring is not a stage of the loop: to understand an unfamiliar codebase befor
|
|
|
57
59
|
|
|
58
60
|
Work found along the way that does not belong in the task goes to `loopwright-park` (`/loopwright-park`), which leaves the current task unchanged.
|
|
59
61
|
|
|
60
|
-
When a stage says to spawn the `loopwright-<role>` subagent, spawn the subagent and wait for its result; never do its work in this thread. After each stage, tell the user one line: what finished and what
|
|
62
|
+
When a stage says to spawn the `loopwright-<role>` subagent, spawn the subagent and wait for its result; never do its work in this thread. After each stage, tell the user one line in plain words, following the rules file: what finished and what the next stage does for the user.
|
|
61
63
|
|
|
62
64
|
## Gates: stop and wait for the user
|
|
63
65
|
|
|
@@ -66,7 +68,8 @@ When a stage says to spawn the `loopwright-<role>` subagent, spawn the subagent
|
|
|
66
68
|
- tester `Uncovered`/`Needs` items and implementer `Deviations`;
|
|
67
69
|
- the moved-branch question at the start of Build and Review, when the branch has new commits that are already on the upstream branch (pulled commits, or this task's own);
|
|
68
70
|
- 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);
|
|
69
|
-
- each undecided review finding, and the fix-round cap being reached;
|
|
71
|
+
- the Simplify question at the start of Review (which proposed cuts to apply; not asked when there is nothing to cut), each undecided review finding, and the fix-round cap being reached;
|
|
72
|
+
- going back from Done: when the user says at a Done question that something needs fixing, the question back to Plan, back to Test, or stay in Done;
|
|
70
73
|
- each AGENTS.md / docs change, and the commit message and PR draft.
|
|
71
74
|
|
|
72
|
-
In Test (no-repro gate), Build and
|
|
75
|
+
In Test (no-repro gate), Build, Review and Done (going back), run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "<reason>"` before asking and `resume` after the answer, as those skills say; otherwise the stop gate pushes you past the gate. Never answer a gate yourself or treat silence as approval. Do not commit at any point.
|
|
@@ -8,6 +8,8 @@ Captures work found mid-task (call it B) as a stub, so the current task (A) keep
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>`. `null` inside a git repo → no task has started here yet; `lw.mjs park` creates `.loopwright/`, so continue. Not a git repo → tell the user loopwright must run inside a git repo, stop.
|
|
13
15
|
3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. It prints a task → that is A. If A's `stage` is `build` or `review`, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "parking follow-up work"` before asking anything, and `node "{{LW_HOME}}/hooks/lw.mjs" resume` after the answers, so the stop gate does not push you past the questions. Other stages need neither. "no active task" → park without a link.
|
|
@@ -8,6 +8,8 @@ Plan runs in this main thread. You state assumptions; the user decides. Do not e
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
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
15
|
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>`:
|
|
@@ -60,12 +62,12 @@ List every assumption you would otherwise make silently, one line each: `A<n> [h
|
|
|
60
62
|
- **low-impact**: everything else (internal naming, file placement following an existing pattern, minor edge-case choices).
|
|
61
63
|
- 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.
|
|
62
64
|
|
|
63
|
-
Show the user the whole ledger in one compact message,
|
|
65
|
+
Show the user the whole ledger in one compact message, as a numbered list in plain words following the rules file: each item says what is assumed and what a wrong guess would change, with its label (`A<n>`, a path) in brackets after. The same goes for the decisions whenever you show them: a plain numbered list. The task file keeps its `A<n>`, `D<n>` and `AC<n>` line shapes unchanged, because hooks read them. 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.
|
|
64
66
|
|
|
65
67
|
## 4. High-impact questions, one at a time
|
|
66
68
|
|
|
67
69
|
For each high-impact item, most impactful first: ask ONE question, wait for the answer, write it to the task file immediately, then ask the next.
|
|
68
|
-
- Write every question for a reader who does not know the code: first say in one plain sentence what the feature does for its users and what will change
|
|
70
|
+
- Write every question for a reader who does not know the code, following the rules file: first say in one plain sentence what the feature does for its users and what will change.
|
|
69
71
|
- Claude Code: use `AskUserQuestion` with 2–4 options, your recommendation first and marked "(recommended)".
|
|
70
72
|
- Codex: numbered plain-text options, recommendation first. The first time, add: "Tip: `/plan` mode offers structured prompts."
|
|
71
73
|
Record the answer as `D<n> [asked] <decision> — rejected: <option, why>`. An answer that raises a new high-impact question goes into the ledger and is asked the same way.
|
|
@@ -77,18 +79,18 @@ Write the result immediately: accepted → `[batch-confirmed]`, changed by the u
|
|
|
77
79
|
|
|
78
80
|
## 6. Proposal
|
|
79
81
|
|
|
80
|
-
In one message, propose and explain each in one line:
|
|
82
|
+
In one message, propose and explain each in one line, in plain words following the rules file (how big the work is, how much testing, how much review effort), with the name in brackets after:
|
|
81
83
|
- **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).
|
|
82
84
|
- **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>`.
|
|
83
85
|
- **two-pass** review on/off: on when the implementer's claims matter beyond what tests show (performance, migrations, concurrency, external APIs); otherwise off.
|
|
84
86
|
- **fix-round cap**: default `maxFixRounds` from config; may be lower for small tasks.
|
|
85
87
|
- **check commands**: exact lint / typecheck / test commands from the scout report.
|
|
86
|
-
- **acceptance criteria** `AC<n>` (fix tasks: see "Fix tasks"): observable behavior, each with the module path and export the test will use (the tester stops without one), and the planned test file. Large tier: slices `S<n>` with their ACs.
|
|
88
|
+
- **acceptance criteria** `AC<n>` (fix tasks: see "Fix tasks"; show them as plain sentences of what the user will be able to see or do, with the label in brackets after): observable behavior, each with the module path and export the test will use (the tester stops without one), and the planned test file. Large tier: slices `S<n>` with their ACs.
|
|
87
89
|
The user confirms or edits each item; write the outcome to the header and sections immediately.
|
|
88
90
|
|
|
89
91
|
## 7. Confirm
|
|
90
92
|
|
|
91
|
-
Show the task file path and a short summary
|
|
93
|
+
Show the task file path and a short summary in plain words following the rules file: what will be built and why, how big the work is, what the user will be able to see or do when it is done, and how it will be checked; not counts of decisions or criteria. Ask for explicit confirmation. Until the user confirms, keep editing the plan; never start Test or Build.
|
|
92
94
|
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.
|
|
93
95
|
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
96
|
On "confirm and continue in a fresh context", after the `plan: confirmed` step and the base-commit rerun above, in this order:
|
|
@@ -8,8 +8,10 @@ Reviewers judge in their own context. This thread dispatches them, merges their
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
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.
|
|
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`. `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
15
|
3. `task: null` → "no active task": point the user to `/loopwright-flow`, stop.
|
|
14
16
|
4. Read the task file header (`tier`, `two-pass`, `fix-round cap`).
|
|
15
17
|
5. Scope: small/standard → the task. Large → the first `S<n> [tested]` slice, or `whole` once every slice is `[passed]`.
|
|
@@ -19,14 +21,37 @@ Reviewers judge in their own context. This thread dispatches them, merges their
|
|
|
19
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.
|
|
20
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).
|
|
21
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.
|
|
22
|
-
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
|
|
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.
|
|
23
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.
|
|
24
26
|
|
|
27
|
+
## Simplify
|
|
28
|
+
|
|
29
|
+
A read-only reviewer proposes cuts to the diff, you ask the user which to apply, and the existing roles apply only the approved ones. It never blocks Review.
|
|
30
|
+
|
|
31
|
+
Skip this section, silently and with no log line, when any of these holds: `simplify` is `false` in `brief`'s `config`; the task is a small-tier feature; this is not round 1 of the final review scope (the task for standard, `whole` for large); a `- Simplify:` line follows the last `- Scope change:` line in `## Review log` (so it runs again after `- Scope change: siblings included`). A small-tier fix runs it.
|
|
32
|
+
|
|
33
|
+
A `- Simplify:` line ending in `— apply pending` is not a skip: an earlier run was interrupted after the user approved cuts, so skip the question, resuming at the Apply (step 5), taking the approved cuts only from this run's `Simplify:` decisions in `## Decisions` (the last ones written, above the pending `- Simplify:` line), never from a `kept as written` line or an earlier run's decisions.
|
|
34
|
+
|
|
35
|
+
1. **Propose.** 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/simplifier.md`." Large tier: add "Scope: whole-branch review of all slices". On Claude Code pass `effort` = the `effort` from `brief`, as in Passes step 2. The result is one JSON object with `obvious` and `tradeoffs` lists. Invalid JSON → dispatch it once more asking for only the JSON; still invalid → append `- Simplify: skipped — invalid output` to `## Review log` and go to Passes.
|
|
36
|
+
2. Both lists empty → append `- Simplify: nothing to cut` and go to Passes with no question.
|
|
37
|
+
3. **Ask.** Run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "simplify"`, then ask everything in one prompt (Claude: `AskUserQuestion`, `multiSelect` for trade-offs; Codex and Junie: numbered text, the user replies with numbers). Write each cut in plain words following the rules file: what would be removed or merged and what the user gives up, with the location and line count in brackets after:
|
|
38
|
+
- `obvious` non-empty → one question listing each cut with its `lines`: apply all or skip all.
|
|
39
|
+
- one trade-off cut → one question with its `change`, `lines` and `loses`: apply or skip.
|
|
40
|
+
- 2–8 trade-off cuts → multi-select questions of up to 4 options each, split evenly into groups of 2 to 4 (an option is a cut: `change`, `lines`, `loses`); a selected option is approved.
|
|
41
|
+
After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume`.
|
|
42
|
+
4. **Record**, before applying anything. Each approved trade-off cut becomes a decision `D<n> [asked] Simplify: <location> — <change>; <lines> lines; gives up: <loses>`, approved obvious cuts (an apply-all answer) one decision line `D<n> [asked] Simplify: apply obvious: <location> — <change>; …`, and all declined cuts, trade-off cuts and the obvious cuts of a skip-all answer, one decision line `D<n> [asked] Simplify: kept as written: <location> — <change>; …` (each cut with its `change`, so it stays identifiable after applying other cuts moves line numbers), so Review does not report them. Then append `- Simplify: <o> obvious applied|skipped, <t> trade-off applied, <d> declined` to `## Review log`, ending it with ` — apply pending` when any cut is approved; write this line before applying, so a resume mid-apply does not ask again.
|
|
43
|
+
5. **Apply** each branch that has approved cuts; nothing approved → go to the Passes.
|
|
44
|
+
- Approved cuts in locked test files first: `node "{{LW_HOME}}/hooks/lw.mjs" stage test`, then spawn the `loopwright-tester` subagent and wait for its result (on Claude Code pass `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort tester`; if the spawn rejects `effort`, spawn without it), with the task file path and the approved cuts verbatim for those files only. It applies them, reruns the tests and re-locks only those files. Then run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --reason "<the decision in words>" <path>…` with those paths, so Review does not flag the re-lock.
|
|
45
|
+
- Approved cuts in other files (the approved obvious cuts and the rest): `node "{{LW_HOME}}/hooks/lw.mjs" stage build`, then spawn the `loopwright-implementer` subagent and wait for its result, as in Build step 2 but with `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort implementer`, not the reviewer's. Its prompt contains the task file path and "Approved simplifications:" with the approved cuts verbatim (`location`, `change`); never your own summary. Keep its report verbatim. `Deviations` not "none" → handle them as in Build step 4; if that sends the task back to Plan or Test, remove the ` — apply pending` ending from the `- Simplify:` line before running `reopen`, so Test does not skip the tester.
|
|
46
|
+
- `two-pass: on` → the second pass gets both implementer reports, Build's and this one.
|
|
47
|
+
- After the last branch, remove the ` — apply pending` ending from the `- Simplify:` line. On a resume, skip an approved cut that is already applied.
|
|
48
|
+
6. Go on with the Passes.
|
|
49
|
+
|
|
25
50
|
## Passes
|
|
26
51
|
|
|
27
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).
|
|
28
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.
|
|
29
|
-
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.
|
|
54
|
+
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.
|
|
30
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):
|
|
31
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 `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):
|
|
32
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"`
|
|
@@ -41,8 +66,8 @@ Human gates: before you ask the user anything in this stage (an undecided findin
|
|
|
41
66
|
|
|
42
67
|
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.
|
|
43
68
|
|
|
44
|
-
- **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.
|
|
45
|
-
- Only **Undecided** → present each to the user, one at a time (Claude: `AskUserQuestion`; Codex: numbered text), with its location
|
|
69
|
+
- **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
|
+
- 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.
|
|
46
71
|
- 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.
|
|
47
72
|
- Nothing open → `node "{{LW_HOME}}/hooks/lw.mjs" verdict pass --round <n>`.
|
|
48
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. 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.
|
|
@@ -8,6 +8,8 @@ The tester writes acceptance tests from the confirmed ACs and locks them. This t
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
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
|
+
|
|
11
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
12
14
|
2. `node "{{LW_HOME}}/hooks/lw.mjs" brief tester` → `dir` (`<lw>`), `task` (path relative to `<lw>`), `stage`, `lockedTests`, `reopened`, `pulledLocks`, `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
15
|
3. `task: null` → "no active task": stop and point the user to `/loopwright-plan` or `/loopwright-flow`.
|
|
@@ -17,6 +19,7 @@ The tester writes acceptance tests from the confirmed ACs and locks them. This t
|
|
|
17
19
|
- `pulledLocks` present (a pull the user approved changed locked tests) → the scope is the files in `pulledLocks`, not the ACs below: the tester checks each listed file still tests its acceptance criteria, edits only what the pull broke, and re-locks it; every other locked test stays untouched.
|
|
18
20
|
- 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.
|
|
19
21
|
- `tier: large`, not reopened → the current slice is the first `S<n> [todo]` line; test only its ACs.
|
|
22
|
+
- `## Review log` has a `- Simplify:` line ending in `— apply pending` (an approved Simplify apply was interrupted) → run `/loopwright-review` to finish it, and stop here: do not spawn the tester.
|
|
20
23
|
|
|
21
24
|
## Steps
|
|
22
25
|
|
|
@@ -28,14 +31,14 @@ The tester writes acceptance tests from the confirmed ACs and locks them. This t
|
|
|
28
31
|
- 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.
|
|
29
32
|
- 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.
|
|
30
33
|
- 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.
|
|
31
|
-
- 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`.
|
|
34
|
+
- 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` in plain words following the rules file (what it tried, what happened, what evidence is missing, and what that means for the fix), 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`.
|
|
32
35
|
- (a) Provide the missing evidence: add it to `## Bug report`, dispatch the tester again.
|
|
33
36
|
- (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.
|
|
34
37
|
- (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).
|
|
35
38
|
If (a) and (b) both fail, the task stops the same way, with what was tried recorded in the task file and an honest next step for the user (for example a normal `/loopwright-flow` task to add logging around the suspected code). No repro, no fix: there is no option to continue without a repro, and Build never starts.
|
|
36
|
-
- `Uncovered` or `Needs` not empty → show those items to the user, one at a time. The answer may change an AC or a decision: write it to the task file (`[asked]`), then dispatch the tester again.
|
|
39
|
+
- `Uncovered` or `Needs` not empty → show those items to the user, one at a time, in plain words following the rules file: what the tester could not cover or needs. The answer may change an AC or a decision: write it to the task file (`[asked]`), then dispatch the tester again.
|
|
37
40
|
4. Write the test file next to each AC line (`— test: <file>`). `pulledLocks`: leave the slice markers alone. Large tier otherwise: change the slice (reopened: every slice in scope) to `S<n> [tested]`.
|
|
38
|
-
5. Tell the user in a few lines:
|
|
41
|
+
5. Tell the user in a few lines, in plain words following the rules file: what behavior the new tests check, that the tests are now frozen so the code writer cannot change them, and the test file paths in brackets after. Then the next stage is `/loopwright-build`.
|
|
39
42
|
|
|
40
43
|
## Rules
|
|
41
44
|
|
package/dist/cli.js
CHANGED
|
@@ -137,6 +137,7 @@ function resolveTargets(opts) {
|
|
|
137
137
|
const DEFAULT_CONFIG = {
|
|
138
138
|
maxFixRounds: 3,
|
|
139
139
|
crossAgentReview: "off",
|
|
140
|
+
simplify: true,
|
|
140
141
|
docsDir: "docs/agents",
|
|
141
142
|
models: {
|
|
142
143
|
claude: {
|
|
@@ -417,6 +418,10 @@ function hookSpecs(tool) {
|
|
|
417
418
|
...tool === "claude" ? [{
|
|
418
419
|
event: "PreCompact",
|
|
419
420
|
script: "precompact-instructions.mjs"
|
|
421
|
+
}, {
|
|
422
|
+
event: "PreToolUse",
|
|
423
|
+
matcher: "AskUserQuestion",
|
|
424
|
+
script: "plain-questions.mjs"
|
|
420
425
|
}] : []
|
|
421
426
|
];
|
|
422
427
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loopwright",
|
|
3
3
|
"author": "Xuan Son Trinh",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.10",
|
|
5
5
|
"description": "Agent workflow installer for Claude Code, Codex and Junie",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^22.20.5",
|
|
40
|
-
"prettier": "^3.
|
|
40
|
+
"prettier": "^3.10.1",
|
|
41
41
|
"smol-toml": "^1.9.1",
|
|
42
42
|
"tsdown": "^0.23.7",
|
|
43
43
|
"typescript": "^7.0.2",
|