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.
- package/README.md +2 -2
- package/content/agents/implementer.md +3 -2
- package/content/agents/scout.md +2 -0
- package/content/agents/tester.md +5 -2
- package/content/hooks/guard-locked-tests.mjs +34 -9
- package/content/hooks/lib.mjs +11 -2
- package/content/hooks/lw.mjs +386 -42
- package/content/hooks/precompact-instructions.mjs +31 -0
- package/content/prompts/reviewer.md +6 -3
- package/content/prompts/standards.md +18 -0
- package/content/skills/loopwright-build/SKILL.md +6 -6
- package/content/skills/loopwright-done/SKILL.md +7 -5
- package/content/skills/loopwright-fix/SKILL.md +19 -2
- package/content/skills/loopwright-flow/SKILL.md +26 -5
- package/content/skills/loopwright-park/SKILL.md +2 -2
- package/content/skills/loopwright-plan/SKILL.md +34 -9
- package/content/skills/loopwright-review/SKILL.md +15 -10
- package/content/skills/loopwright-test/SKILL.md +9 -8
- package/dist/cli.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ flowchart TD
|
|
|
58
58
|
done --> commit(["You commit"])
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
- **Plan** runs in your session. A read-only scout maps the repo, then you answer the high-impact questions one at a time and confirm the plan. Nothing is built before that.
|
|
61
|
+
- **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
62
|
- **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
63
|
- **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.
|
|
64
64
|
- **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.
|
|
@@ -88,7 +88,7 @@ Run a single stage, or the whole loop with `flow`. In Codex, use `$` instead of
|
|
|
88
88
|
|---|---|---|---|
|
|
89
89
|
| Skills install | Supported, tested | WIP: installed, not tested end-to-end | WIP: reads `.agents/skills` |
|
|
90
90
|
| 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) | Supported, tested | WIP: installed, not tested end-to-end | Experimental (`--experimental junie-hooks`, Early Access) |
|
|
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) |
|
|
92
92
|
| Structured questions | `AskUserQuestion` | Plain-text fallback (numbered options) | Plain-text fallback |
|
|
93
93
|
| Cross-agent review (as the reviewer) | Supported, tested | WIP: untested | Not supported |
|
|
94
94
|
| Global install | Supported, tested | WIP: installed, not tested end-to-end | WIP: `~/.junie/agents` |
|
|
@@ -22,7 +22,7 @@ The main thread gives you the task file path, and on a fix round the reviewer's
|
|
|
22
22
|
|
|
23
23
|
- Follow `AGENTS.md` and the `docs/agents/` docs it links, and the patterns of nearby code (error handling, naming, layout, test style).
|
|
24
24
|
- Prefer the simplest code path that does the job. Reuse existing helpers before adding new ones.
|
|
25
|
-
-
|
|
25
|
+
- Read `{{LW_HOME}}/prompts/standards.md` and follow it, including its comment rule.
|
|
26
26
|
|
|
27
27
|
## Steps
|
|
28
28
|
|
|
@@ -30,7 +30,8 @@ The main thread gives you the task file path, and on a fix round the reviewer's
|
|
|
30
30
|
2. Read the locked tests and the code they exercise.
|
|
31
31
|
3. Implement. Add unit tests for logic the acceptance tests do not pin down (edge cases, error paths), in new or existing non-locked test files.
|
|
32
32
|
4. Run the task's check commands (lint, typecheck, tests). Fix until they pass. Do not mark a check as passing that you did not run.
|
|
33
|
-
5.
|
|
33
|
+
5. Simplify pass: read your diff against the base commit (`baseCommit` in `status`) and apply the standards: cut what is redundant, remove wrappers and duplicated docs. If anything changed, rerun the checks.
|
|
34
|
+
6. On a fix round, address each Blocking finding; if you disagree with one, say why with proof instead of changing code.
|
|
34
35
|
|
|
35
36
|
## Fix tasks
|
|
36
37
|
|
package/content/agents/scout.md
CHANGED
|
@@ -100,6 +100,8 @@ Return plain text, at most ~60 lines, one line per item, each with `path` or `pa
|
|
|
100
100
|
Relevant files: path — role in the goal
|
|
101
101
|
Standards: rule — source path
|
|
102
102
|
Conventions: convention — example path:line
|
|
103
|
+
Mechanisms: existing config, registry or helper this goal could extend instead of adding new code — path:line
|
|
104
|
+
Layers: layers or boundaries the repo docs define for the code the goal touches — doc path
|
|
103
105
|
Checks: test (all) / test (one file) / lint / format / typecheck — exact command, or "none found"
|
|
104
106
|
Tests: runner, location and style of existing tests near the goal
|
|
105
107
|
Risks: risk — evidence path:line
|
package/content/agents/tester.md
CHANGED
|
@@ -13,6 +13,8 @@ The main thread gives you the task file path. Read its acceptance criteria (`AC
|
|
|
13
13
|
|
|
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
|
+
- 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.
|
|
17
|
+
- Read `{{LW_HOME}}/prompts/standards.md` and follow it in the tests you write.
|
|
16
18
|
- Write only test files (and fixtures they need). Do not create or edit implementation code, not even stubs.
|
|
17
19
|
- Use the repo's existing test runner, file layout and test style. Do not add a test framework or dependency.
|
|
18
20
|
- Never write task ids (AC, D, S shorthands) into tests, code, comments, commit messages or PR drafts. Task ids live only in the task file.
|
|
@@ -25,8 +27,9 @@ The main thread gives you the task file path. Read its acceptance criteria (`AC
|
|
|
25
27
|
3. Confirm each test fails for the expected reason: the behavior is missing or wrong (assertion failure, missing export). A syntax error, a typo, an import path the task file does not name, or a crashing setup is the wrong reason; fix the test and rerun.
|
|
26
28
|
Reopened task: a test you edited for behavior the implementation already has may pass now; that is fine when it checks the changed contract. Say which tests pass and why in `Run`.
|
|
27
29
|
When the module or interface the task file names does not exist yet, import it from that path. "Module not found" or a missing export at that path is the expected failure; one file-level excerpt covers every AC in that file. If the task file names no module path or interface for an AC, stop and report it under Needs.
|
|
28
|
-
4.
|
|
29
|
-
5.
|
|
30
|
+
4. Standards pass: reread your test files against `{{LW_HOME}}/prompts/standards.md`. Remove comments and doc blocks that restate a test name or an acceptance criterion, and helpers that have one call site and do not name a step the reader would otherwise have to decode. Then rerun the tests (steps 2-3) to confirm they still fail for the right reason.
|
|
31
|
+
5. Run the task's format check (its format command from `checks`) on your test files and fix what it reports; they must be clean before the lock step. No format command in the checks → skip. Accept lint errors that come only from the missing module (it does not exist yet) and list them in `Run`.
|
|
32
|
+
6. When every test fails for the right reason (reopened: or passes for the reason given in `Run`), lock them:
|
|
30
33
|
`node "{{LW_HOME}}/hooks/lw.mjs" lock <test-file> [<test-file>…]`
|
|
31
34
|
Lock every acceptance test file and fixture you wrote. Locking only works in stage `test`; if it errors, report the error.
|
|
32
35
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// PreToolUse guard: block edits to locked acceptance tests during the build stage.
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
3
5
|
import {
|
|
4
6
|
allow,
|
|
5
7
|
exitIfHooksOff,
|
|
6
8
|
deny,
|
|
7
9
|
failOpen,
|
|
10
|
+
gitTopLevel,
|
|
8
11
|
loopwrightDir,
|
|
12
|
+
realpathLoose,
|
|
9
13
|
readState,
|
|
10
14
|
readStdinJson,
|
|
11
15
|
repoRelative,
|
|
@@ -22,17 +26,31 @@ function patchPaths(command) {
|
|
|
22
26
|
return out;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/** Top-level of the worktree holding abs (via its nearest existing folder); null outside git. */
|
|
30
|
+
function ownerTop(abs) {
|
|
31
|
+
let cur = dirname(abs);
|
|
32
|
+
while (!existsSync(cur) && dirname(cur) !== cur) cur = dirname(cur);
|
|
33
|
+
try {
|
|
34
|
+
return gitTopLevel(cur);
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Locked test paths of the task building in the worktree at top; empty unless it is in build. */
|
|
41
|
+
function lockedTests(top) {
|
|
42
|
+
const dir = loopwrightDir(top);
|
|
43
|
+
const state = dir && readState(dir, worktreeId(top));
|
|
44
|
+
if (!state || state.stage !== 'build' || !Array.isArray(state.lockedTests)) return new Set();
|
|
45
|
+
return new Set(state.lockedTests.map((l) => l.path));
|
|
46
|
+
}
|
|
47
|
+
|
|
25
48
|
exitIfHooksOff();
|
|
26
49
|
|
|
27
50
|
try {
|
|
28
51
|
const input = await readStdinJson();
|
|
29
52
|
// Junie runs hooks from ~/.junie and reports the repo as project_path.
|
|
30
53
|
const cwd = input.project_path || input.cwd || process.cwd();
|
|
31
|
-
const dir = loopwrightDir(cwd);
|
|
32
|
-
if (!dir) allow();
|
|
33
|
-
const state = readState(dir, worktreeId(cwd));
|
|
34
|
-
if (!state || state.stage !== 'build' || !Array.isArray(state.lockedTests) || state.lockedTests.length === 0) allow();
|
|
35
|
-
|
|
36
54
|
const ti = input.tool_input ?? {};
|
|
37
55
|
const raw =
|
|
38
56
|
input.tool_name === 'apply_patch'
|
|
@@ -40,11 +58,18 @@ try {
|
|
|
40
58
|
: ti.file_path && input.tool_name !== 'Read' // Junie fires PreToolUse for reads too; only edits are guarded
|
|
41
59
|
? [ti.file_path]
|
|
42
60
|
: [];
|
|
43
|
-
|
|
61
|
+
// A file is locked by the session worktree's task or by its own worktree's, which need not match: check both.
|
|
62
|
+
const lockedByTop = new Map();
|
|
44
63
|
for (const p of raw) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
const abs = realpathLoose(isAbsolute(p) ? resolve(p) : resolve(cwd, p));
|
|
65
|
+
for (const top of new Set([cwd, ownerTop(abs) ?? cwd])) {
|
|
66
|
+
if (!lockedByTop.has(top)) lockedByTop.set(top, lockedTests(top));
|
|
67
|
+
const locked = lockedByTop.get(top);
|
|
68
|
+
if (locked.size === 0) continue;
|
|
69
|
+
const rel = repoRelative(top, abs);
|
|
70
|
+
if (locked.has(rel))
|
|
71
|
+
deny('', '', `loopwright: ${rel} is a locked acceptance test. Ask the user before changing it.`);
|
|
72
|
+
}
|
|
48
73
|
}
|
|
49
74
|
allow();
|
|
50
75
|
} catch (err) {
|
package/content/hooks/lib.mjs
CHANGED
|
@@ -38,8 +38,17 @@ export function mainWorktreeRoot(cwd) {
|
|
|
38
38
|
return gitTopLevel(cwd);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
41
|
+
/** This worktree's .loopwright path (tasks and state live per worktree; whether or not it exists); null outside git. */
|
|
42
42
|
export function loopwrightPath(cwd) {
|
|
43
|
+
try {
|
|
44
|
+
return join(gitTopLevel(cwd), '.loopwright');
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The main checkout's .loopwright path, where config.json and manifest.json live once; null outside git. */
|
|
51
|
+
export function mainLoopwrightPath(cwd) {
|
|
43
52
|
try {
|
|
44
53
|
return join(mainWorktreeRoot(cwd), '.loopwright');
|
|
45
54
|
} catch {
|
|
@@ -47,7 +56,7 @@ export function loopwrightPath(cwd) {
|
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
/**
|
|
59
|
+
/** This worktree's .loopwright directory if it exists; null outside git or if absent. */
|
|
51
60
|
export function loopwrightDir(cwd) {
|
|
52
61
|
const dir = loopwrightPath(cwd);
|
|
53
62
|
return dir && existsSync(dir) ? dir : null;
|