loopwright 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # loopwright
2
2
 
3
- Make your AI coding agent plan, test, build and review like a careful team: a **Plan → Test → Build → Review → Done** workflow (Test is skipped for small feature tasks, and Review loops back to Build until it passes), installed into your repo as skills, subagents and hooks.
3
+ Make your AI coding agent plan, test, build and review like a careful team: a **Plan → Test → Build → Review → Done** workflow (Test is skipped for small feature tasks, and Review loops back to Build until it passes), installed into your repo as skills, subagents and hooks. `/loopwright-explore` also writes a verified walkthrough of a codebase you are new to.
4
4
 
5
5
  ## Why
6
6
 
@@ -74,6 +74,8 @@ Run a single stage, or the whole loop with `flow`. In Codex, use `$` instead of
74
74
  |---|---|
75
75
  | `/loopwright-flow` | Run or resume the whole loop, stopping wherever you must decide |
76
76
  | `/loopwright-fix` | Fix a bug: a repro test is locked first, then the root cause is fixed |
77
+ | `/loopwright-park` | Capture work found mid-task as a startable stub, without growing the current task |
78
+ | `/loopwright-explore` | Understand an unfamiliar codebase: a verified walkthrough, written under `.loopwright/` |
77
79
  | `/loopwright-plan` | Plan stage |
78
80
  | `/loopwright-test` | Test stage |
79
81
  | `/loopwright-build` | Build stage |
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: loopwright-scout
3
- description: Read-only codebase scout for the Plan stage. Maps the files, conventions, check commands and risks relevant to a goal, before any decision is made.
3
+ description: Read-only codebase scout. In Plan it maps the files, conventions, check commands and risks relevant to a goal before any decision is made; in explore runs it maps a codebase, reports one component, or checks cited claims.
4
4
  tools: Read, Grep, Glob, Bash, WebSearch, WebFetch
5
5
  ---
6
- You are the loopwright scout. The main thread gives you a goal (or an imported spec). You investigate the repository and report facts, so the planner can write an assumption ledger from evidence instead of guesses.
6
+ You are the loopwright scout. The main thread gives you a goal (or an imported spec), or an explore task (see "Explore tasks"). You investigate the repository and report facts, so the planner can write an assumption ledger from evidence instead of guesses.
7
7
 
8
8
  ## Boundaries
9
9
 
@@ -35,6 +35,63 @@ When the goal is a bug report (`kind: fix`), also report:
35
35
  - Other places with the same defect pattern, if you see them.
36
36
  - Faulty unit investigation, when the main thread says the bug cannot be reproduced: read the internals and name the suspect unit (module, export) and why; report facts for the user to confirm.
37
37
 
38
+ ## Explore tasks
39
+
40
+ When the main thread says "Explore tasks" with a mode, you serve `/loopwright-explore`. Report facts only, each line with `path:line`. The other boundaries apply unchanged, except: in explore mode run no repo commands (no test, build, lint or script runs); read-only git stays allowed. Take build, run and test commands from manifests, CI config or docs and give their source path.
41
+
42
+ Scope is a folder: code outside it is not traced. Report it only where in-scope code touches it, as a boundary node cited at the in-scope side (the call site, or the in-scope file that is called). Callers outside the folder that start a key flow are found with a search and cited where they call in.
43
+
44
+ Mode map (given the scope): use directory listings, manifests, entry points, READMEs, existing docs and read-only git (change counts, last-change dates). Do not read every file. Report:
45
+
46
+ ```
47
+ Purpose: what the project appears to be for — evidence
48
+ Languages and size: language — rough file count
49
+ Entry points: binary/server/CLI/job — path:line
50
+ Run/build/test: kind — exact command — source path
51
+ External systems: database/queue/HTTP API/file store — evidence path:line
52
+ Candidate components: name — folder(s) — one-line job — evidence
53
+ Candidate key flows: name — trigger — entry path:line
54
+ Error handling: where errors are caught, logged or turned into responses — path:line
55
+ Hotspots: path — change count, last change date
56
+ Existing docs: path — what it covers, how current it looks
57
+ Unknowns: question the repo cannot answer
58
+ ```
59
+
60
+ Mode component (given one component and the confirmed key flows): at most ~100 lines. Report:
61
+
62
+ ```
63
+ Job: what this component does, in plain words — evidence
64
+ Key files: path — role
65
+ Entry points / public interface: path:line — what calls in
66
+ Depends on: other component or external system — call site path:line
67
+ Used by: other component — call site path:line
68
+ Data it owns: table/file/schema — path:line
69
+ Internal parts: part — what it calls among the other parts — path:line (list only when the component has parts that call each other; otherwise "none")
70
+ Flow steps here: flow name — step — path:line
71
+ Terms: domain or code term — meaning — where defined path:line
72
+ Gotchas: surprising behavior, dead code, config switches — path:line
73
+ Cross-cutting: how this component does errors, logging, config, auth, concurrency — path:line
74
+ Rules it keeps: invariants and boundaries, including absences ("never imports X") — path:line, or the search that found no match
75
+ Unknowns: question the code cannot answer
76
+ ```
77
+
78
+ Mode answer (given only a numbered question list, `Q<n>`): look for each answer in the repo's docs, `CLAUDE.md` and `AGENTS.md`, tests, and read-only git history. Run no repo commands. Return one line per question:
79
+
80
+ ```
81
+ Q<n>: answered — the answer — path:line
82
+ Q<n>: problem — what is wrong (a defect, with evidence) — path:line
83
+ Q<n>: open — what was searched
84
+ ```
85
+
86
+ Mode check (given only a claim list: id, claim, cited `path:line`): you never see the document. Open each cited location, any in scope or not, and try to disprove the claim. Return one line per claim id:
87
+
88
+ ```
89
+ C<n>: confirmed — the code shows it
90
+ C<n>: refuted — correct fact — path:line
91
+ C<n>: narrower — what the code shows — path:line (true, but narrower than written)
92
+ C<n>: unconfirmed — the citation does not show it and nothing better was found
93
+ ```
94
+
38
95
  ## Report
39
96
 
40
97
  Return plain text, at most ~60 lines, one line per item, each with `path` or `path:line`:
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  // Loopwright state tool. Usage: node lw.mjs <cmd> [args]
3
- import { copyFileSync, existsSync, readFileSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';
3
+ import { copyFileSync, existsSync, readFileSync, readdirSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';
4
4
  import { homedir } from 'node:os';
5
- import { isAbsolute, join, resolve } from 'node:path';
5
+ import { isAbsolute, join, relative, resolve, sep } from 'node:path';
6
6
  import { execFileSync } from 'node:child_process';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import {
@@ -277,6 +277,150 @@ try {
277
277
  case 'effort':
278
278
  process.stdout.write(effortFor(rest[0]) + '\n');
279
279
  break;
280
+ case 'park': {
281
+ // Captures work found mid-task as a proposed stub. Reads state only to find the active task; never writes it.
282
+ const usage = 'loopwright: usage: park "<title>" [--blocks] [--kind feature|fix]';
283
+ const blocks = rest.includes('--blocks');
284
+ if (blocks) rest.splice(rest.indexOf('--blocks'), 1);
285
+ const kind = flag(rest, '--kind') ?? 'feature';
286
+ if (kind !== 'feature' && kind !== 'fix') fail(`${usage} (kind must be feature or fix)`);
287
+ const title = rest.join(' ').trim();
288
+ if (!title) fail(usage);
289
+ const existing = loopwrightDir(cwd);
290
+ const active = existing ? (readState(existing, worktreeId(cwd))?.task ?? null) : null;
291
+ if (blocks && !active) fail('loopwright: park --blocks needs an active task');
292
+ const { dir } = ctx(true);
293
+ const d = new Date();
294
+ const p2 = (n) => String(n).padStart(2, '0');
295
+ const base = `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())}-${title.replace(/\s+/g, '-').replace(/[\\/:*?"<>|]/g, '-')}`;
296
+ const foundWhile = active && existsSync(join(dir, active)) ? active : null;
297
+ if (active && !foundWhile)
298
+ process.stderr.write(`loopwright: warning: active task file ${active} is missing; follow-up not linked\n`);
299
+ const header = [`# ${title}`, '', `kind: ${kind}`, 'status: proposed', 'stage: plan', 'plan: draft'];
300
+ if (foundWhile) header.push(`found while: ${foundWhile}`);
301
+ if (blocks && foundWhile) header.push(`blocks: ${foundWhile}`);
302
+ const text = header.join('\n') + '\n\n## Goal\n\n## Evidence\n';
303
+ let stub;
304
+ for (let n = 1; ; n++) {
305
+ stub = `tasks/${base}${n === 1 ? '' : `-${n}`}.md`;
306
+ try {
307
+ writeFileSync(join(dir, stub), text, { flag: 'wx' });
308
+ break;
309
+ } catch (err) {
310
+ if (err.code !== 'EEXIST') throw err;
311
+ }
312
+ }
313
+ if (foundWhile) {
314
+ const line = `- ${title} — ${stub}${blocks ? ' [blocking]' : ''}`;
315
+ const file = join(dir, foundWhile);
316
+ const body = readFileSync(file, 'utf8');
317
+ const m = /^## Follow-ups[ \t]*$/m.exec(body);
318
+ let next;
319
+ if (!m) next = body.replace(/\n*$/, '\n') + `\n## Follow-ups\n${line}\n`;
320
+ else {
321
+ const start = m.index + m[0].length;
322
+ const end = body.slice(start).search(/^## /m);
323
+ const stop = end === -1 ? body.length : start + end;
324
+ const section = body.slice(start, stop).replace(/\s*$/, '');
325
+ next = body.slice(0, start) + section + `\n${line}\n` + (end === -1 ? '' : '\n') + body.slice(stop);
326
+ }
327
+ writeFileSync(file, next);
328
+ }
329
+ out({ stub, foundWhile, blocks: Boolean(blocks && foundWhile) });
330
+ break;
331
+ }
332
+ case 'explore': {
333
+ // Run-folder bookkeeping for /loopwright-explore. Never reads or writes worktree state.
334
+ const usage = 'loopwright: usage: explore "<scope>" [--new]';
335
+ const fresh = rest.includes('--new');
336
+ if (fresh) rest.splice(rest.indexOf('--new'), 1);
337
+ if (rest.length > 1) fail(usage);
338
+ const top = gitTopLevel(cwd);
339
+ const abs = resolve(top, rest[0] ?? '.');
340
+ const rel = relative(top, abs).split(sep).join('/');
341
+ if (rel.startsWith('..') || isAbsolute(rel) || !existsSync(abs))
342
+ fail(`loopwright: explore: scope path does not exist in this repository: ${rest[0] ?? '.'}`);
343
+ const scope = rel || '.';
344
+ const headSha = () => {
345
+ try {
346
+ return gitOut(['rev-parse', 'HEAD']);
347
+ } catch {
348
+ return null; // repo without commits
349
+ }
350
+ };
351
+ const { dir } = ctx(true);
352
+ const root = join(dir, 'explore');
353
+ mkdirSync(root, { recursive: true });
354
+ const field = (text, name) => new RegExp(`^${name}: (.*)$`, 'm').exec(text)?.[1];
355
+ // Same date, then the shorter name first, so `-2` sorts before `-10`.
356
+ const byAge = (a, b) => a.slice(0, 10).localeCompare(b.slice(0, 10)) || a.length - b.length || a.localeCompare(b);
357
+ let open = null;
358
+ for (const name of readdirSync(root).sort(byAge)) {
359
+ let text;
360
+ try {
361
+ text = readFileSync(join(root, name, 'run.md'), 'utf8');
362
+ } catch {
363
+ continue;
364
+ }
365
+ if (field(text, 'scope') === scope && field(text, 'status') === 'in-progress') open = { name, text };
366
+ }
367
+ const head = headSha();
368
+ // Paths, not a boolean, so the skill can name them. -z keeps odd names unquoted; -uall lists files inside new folders.
369
+ const dirty = [];
370
+ const entries = execFileSync('git', ['status', '--porcelain', '-z', '-uall'], {
371
+ cwd: top,
372
+ encoding: 'utf8',
373
+ stdio: ['ignore', 'pipe', 'pipe'],
374
+ })
375
+ .split('\0')
376
+ .filter(Boolean);
377
+ for (let i = 0; i < entries.length; i++) {
378
+ dirty.push(entries[i].slice(3));
379
+ if (/^[RC]/.test(entries[i])) i++; // renames carry the old path as the next entry
380
+ }
381
+ dirty.sort();
382
+ let name;
383
+ let commit;
384
+ let resume = false;
385
+ if (open && !fresh) {
386
+ ({ name } = open);
387
+ resume = true;
388
+ const c = field(open.text, 'commit');
389
+ commit = c === undefined || c === 'null' ? null : c;
390
+ } else {
391
+ if (open)
392
+ writeFileSync(join(root, open.name, 'run.md'), open.text.replace(/^status: .*$/m, 'status: abandoned'));
393
+ const d = new Date();
394
+ const p2 = (n) => String(n).padStart(2, '0');
395
+ const today = `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())}`;
396
+ const slug = scope === '.' ? 'repo' : scope.replace(/\s+/g, '-').replace(/[\\/:*?"<>|]/g, '-');
397
+ for (let n = 1; ; n++) {
398
+ name = `${today}-${slug}${n === 1 ? '' : `-${n}`}`;
399
+ try {
400
+ mkdirSync(join(root, name));
401
+ break;
402
+ } catch (err) {
403
+ if (err.code !== 'EEXIST') throw err;
404
+ }
405
+ }
406
+ commit = head;
407
+ writeFileSync(
408
+ join(root, name, 'run.md'),
409
+ `scope: ${scope}\ncommit: ${commit}\nstarted: ${today}\nstatus: in-progress\ndirty: ${dirty.length ? 'yes' : 'no'}\n`,
410
+ );
411
+ }
412
+ const present = [];
413
+ const walk = (sub) => {
414
+ for (const e of readdirSync(join(root, name, sub), { withFileTypes: true })) {
415
+ const r = sub ? `${sub}/${e.name}` : e.name;
416
+ if (e.isDirectory()) walk(r);
417
+ else present.push(r);
418
+ }
419
+ };
420
+ if (resume) walk('');
421
+ out({ dir: `explore/${name}`, resume, commit, head, dirty, present: present.sort() });
422
+ break;
423
+ }
280
424
  case 'status': {
281
425
  out(requireState().state);
282
426
  break;
@@ -292,7 +436,7 @@ try {
292
436
  }
293
437
  default:
294
438
  fail(
295
- 'loopwright: usage: lw.mjs <dir|start|stage|reopen|lock|check-locks|fingerprint|verdict|await-user|resume|status|effort|done>',
439
+ 'loopwright: usage: lw.mjs <dir|start|stage|reopen|lock|check-locks|fingerprint|verdict|await-user|resume|park|explore|status|effort|done>',
296
440
  );
297
441
  }
298
442
  } catch (err) {
@@ -25,16 +25,21 @@ Propose each change individually, with the exact text, and wait for approval (Cl
25
25
 
26
26
  If `CLAUDE.md` exists and has no line `@AGENTS.md`, propose adding that import line instead of copying content into CLAUDE.md. Never duplicate AGENTS.md content elsewhere.
27
27
 
28
- ## 2. Commit message and PR description
28
+ ## 2. Parked follow-ups
29
+
30
+ `grep -l "^found while: <this task path>" <lw>/tasks/*.md` lists the stubs parked while this task ran (`status: proposed` ones are still open). For each, draft issue text (title, what and why, `path:line` evidence from its `## Evidence`) and show it to the user. It is shown only: never file it, and write no task paths or ids into it. A stub with `blocks: <this task path>` that is still `proposed` → ask one question: clear the flag (the stub no longer blocks) or note it in the PR.
31
+
32
+ ## 3. Commit message and PR description
29
33
 
30
34
  Never write task ids (AC, D, S shorthands) into tests, code, comments, commit messages or PR drafts. Describe decisions in words.
31
35
 
32
36
  Draft both and show them to the user:
33
37
  - Commit: imperative subject ≤ 72 chars; body says why, the key decisions, and the rejected options with the reason.
34
38
  - PR: summary of intent; decisions and rejected options; notable assumptions the reviewer should know; how it was verified (check commands, acceptance tests, review rounds from the log). Do not list the diff file by file. Run `node "{{LW_HOME}}/hooks/lw.mjs" check-locks`; when `relockedAfterReopen` is non-empty, add a section listing each locked test changed after a reopen with its reason.
39
+ - 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).
35
40
  - 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`.
36
41
 
37
- ## 3. Close
42
+ ## 4. Close
38
43
 
39
44
  1. Set `status: done` in the task file header.
40
45
  2. `node "{{LW_HOME}}/hooks/lw.mjs" done` (removes this worktree's machine state; the task file stays).
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: loopwright-explore
3
+ description: Use to understand an unfamiliar codebase, or one folder of it. Produces a newcomer walkthrough where every claim and diagram edge cites path:line and a blind checker has tried to disprove each one.
4
+ ---
5
+ # loopwright explore
6
+
7
+ Writes a walkthrough of a codebase (or one folder, `/loopwright-explore services/billing`) for someone new to it. Exploration is staged: map, a confirmed outline, one read-only scout per component, a draft, a repo-answer pass, a blind claim check, questions for the team. Exploring is not a stage of the Plan → Done loop and changes no task.
8
+
9
+ ## Setup
10
+
11
+ 1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>`. `null` inside a git repo → no task has started here yet; `lw.mjs explore` creates `.loopwright/`, so continue. Not a git repo → tell the user loopwright must run inside a git repo, stop.
13
+ 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).
14
+ 4. `node "{{LW_HOME}}/hooks/lw.mjs" explore "<scope>"` (no scope → `.`) → `{dir, resume, commit, head, dirty, present}`; `dirty` lists the changed and untracked paths now (`[]` when clean); `dir` is relative to `<lw>`. An unknown path is an error: tell the user. Call it `<run>`.
15
+ 5. `resume` true and `commit` differs from `head` → tell the user and ask one question, recommending to continue (the header then names both commits) or start over (`explore "<scope>" --new`).
16
+ 6. Continue at the first stage whose file is missing from `present`. After any interruption or context compaction, start again from this Setup: the files on disk are the truth, not the conversation.
17
+
18
+ ## Stages
19
+
20
+ Spawn each scout on Claude Code with `effort` = the output of `node "{{LW_HOME}}/hooks/lw.mjs" effort scout`; if the spawn rejects `effort`, spawn without it. Scouts only report; this main thread writes every file. Save each report verbatim.
21
+
22
+ 1. Map: spawn the `loopwright-scout` subagent with the scope and "Explore tasks: map". Save its report to `<run>/map.md`.
23
+ 2. Outline gate: if `dirty` is not empty, raise it first with one question (recommend commit or stash first, or go on): the walkthrough would describe uncommitted code. Going on → the header says "plus uncommitted changes in N files". Then show the user, recommendation first, the scope; the component list (merge, split, rename or drop; target 4 to 8, more → propose grouping or narrowing the scope); and 1 to 3 key flows with a recommended pick (those touching the most components), one may be an error path. One question per decision (Claude: `AskUserQuestion`; Codex and Junie: numbered text, then end the turn). Never a silent default. Save the confirmed outline (scope, components with folders and one-line jobs, key flows) to `<run>/outline.md`.
24
+ 3. Components: spawn one read-only `loopwright-scout` subagent per component, in parallel, each with "Explore tasks: component", its component and the confirmed flows. Save each report to `<run>/components/<component-slug>.md` as it arrives. On resume spawn only components without a report.
25
+ 4. Draft: write `<run>/walkthrough.md` from `outline.md` and the saved reports, not from memory of the conversation. Also write `<run>/claims.md`: every factual statement and diagram edge, one per line, `C<n> | claim | path:line`. A statement with no citation is cut or moved to "Questions only the team can answer". Number the open questions `Q<n>`.
26
+ 5. Answer: spawn a fresh `loopwright-scout` subagent with "Explore tasks: answer" and only the question list, never the document or your reasoning. Save its report to `<run>/answers.md`. Then: `answered` → state the answer in the prose and add it to `claims.md` with its citation; `problem` → list it under "Possible problems found" and add it to `claims.md`; `open` → keep it under "Questions only the team can answer". The Check step then verifies the new claims.
27
+ 6. Check: spawn a fresh `loopwright-scout` subagent with "Explore tasks: check" and only the claim list, never the document or your reasoning (split a long list across several scouts by component). Save results to `<run>/check.md`. Then: fix `refuted` claims with the checker's evidence (cited, not re-checked); for `narrower` claims, narrow the claim or fold the caveat in with the checker's evidence (not re-checked); remove `unconfirmed` claims from prose or keep them only under "Questions only the team can answer"; remove `unconfirmed` diagram edges or draw them dashed labeled `unconfirmed`; put the counts in the header, `narrower` counted separately. One check round.
28
+ 7. Questions gate: show "Possible problems found" and "Questions only the team can answer" in one message, and ask only about "Questions only the team can answer" (section 12). The user may answer any; mark answers `(per <user>, not verified in code)`, kept apart from code-backed claims. Then set `status: done` in `<run>/run.md`.
29
+
30
+ ## Finish
31
+
32
+ Tell the user the walkthrough path and the check counts. Offer, never do by default, to copy it into the repo at a path the user names (e.g. `docs/architecture.md`); the copy rewrites nothing else and commits nothing. If Setup found a task in `test`, `build` or `review`, do not offer the copy: it would join that task's diff. Say to copy it once the task is closed, or from another worktree, and give the source path.
33
+
34
+ ## The walkthrough
35
+
36
+ For a developer new to the codebase. Sections in this order; one with nothing to say is omitted, not filled.
37
+
38
+ 1. Header: title, scope, commit explored, date, check counts (`narrower` counted separately), and "plus uncommitted changes in N files" if the user went on with a dirty tree.
39
+ 2. What this is: one plain paragraph: who uses it, what goes in, what comes out. No code names yet.
40
+ 3. Words you will meet: glossary, each term defined once, plain words first, then where it lives. Diagrams use these names.
41
+ 4. The system and its surroundings: context diagram (the system as one box, its users, outside systems).
42
+ 5. The big pieces: component diagram, then a codemap table: component, folder, what it does, "look here for…". Folder scope: outside code appears only as boundary nodes, cited at the in-scope side, not counted toward the 4 to 8.
43
+ 6. How a request moves through it: per key flow a Mermaid sequence or flowchart, then numbered steps each with `path:line`.
44
+ 7. Components: per component job, key files, entry points, depends on, used by, data it owns, gotchas. Optional diagrams, under the same box, edge-table and check rules as the others: a zoom diagram for a component whose scout reports 4 or more internal parts that call each other; one data (ER) diagram when 2 or more components report data they own.
45
+ 8. How things are done everywhere: errors, logging, config, auth, concurrency as present, and the rules the code keeps, including absences, each cited.
46
+ 9. Running it locally: commands from manifests, CI or docs, each marked with its source and "not run".
47
+ 10. A tour of the code: 5 to 10 ordered stops, each a file with `path:line`, what to notice, and where it leads next.
48
+ 11. Possible problems found: defects the code shows, each with evidence.
49
+ 12. Questions only the team can answer: what the code could not answer.
50
+ 13. Evidence: the claim table (claim, citation, check result).
51
+
52
+ Writing rules:
53
+ - Second person, plain words, short sentences. Define a term before using it and keep one word for it.
54
+ - Big picture before detail; no reference tables before "The big pieces".
55
+ - Diagrams are Mermaid. Each has a title naming its level and scope, a legend for what arrows mean, one zoom level, and at most about 8 boxes (more → split). Context diagram before component diagram.
56
+ - Every edge is numbered, labeled with a verb, and has a table row under the diagram: number, meaning, `path:line`. No edge without a row.
57
+ - Prose names modules, files and types; `path:line` goes in edge tables, flow steps, tour stops and Evidence, all tied to the header commit.
58
+ - No claim without a citation in Evidence.
59
+
60
+ ## Rules
61
+
62
+ - Never edit code or any file outside `<lw>`; the one exception is the copy the user asks for.
63
+ - Run no repo commands (no build, test, install or scripts). Read-only git is fine. Commands in the walkthrough are taken from files and not run.
64
+ - Never change the active task, its state or its tests.
65
+ - Do not write task ids into the walkthrough.
@@ -19,7 +19,9 @@ Runs the stage skills in order for the confirmed tier and resumes where a task l
19
19
  - Prints a task → read `<lw>/<task>` and continue at its `stage` (plan: run `loopwright-plan`, which resumes the open plan; review: count rounds from the review log).
20
20
  - "no active task" → `grep -l "^status: active" <lw>/tasks/*.md`.
21
21
  - One or more files → ask the user which one (or a new task). For the chosen file, offer to rebuild state from it: `node "{{LW_HOME}}/hooks/lw.mjs" start tasks/<file>.md --base <base commit from its header>`, then `node "{{LW_HOME}}/hooks/lw.mjs" stage <stage from its header>`. Locked-test hashes are lost with the state: if the task already has acceptance tests and is past Test, tell the user; re-lock the test files named in its AC lines (`stage test`, `lock <files>`, then `stage <stage>`) only if the user confirms they are unchanged.
22
- - None, or the user wants a new task → start at Plan with the user's goal or spec path.
22
+ - None, or the user wants a new task → continue below.
23
+ - Also list stubs parked by `/loopwright-park`: `grep -l "^status: proposed" <lw>/tasks/*.md`. Offer each as start, drop, or a new task instead. Start → run `loopwright-plan` on it as in that skill ("Parked stubs"). Drop → set `status: dropped` in the stub; never delete it.
24
+ - No stubs and no task, or the user wants a new task → start at Plan with the user's goal or spec path.
23
25
 
24
26
  ## Run
25
27
 
@@ -31,6 +33,10 @@ Follow each stage skill in turn (Claude Code `/loopwright-<stage>`, Codex `$loop
31
33
  - Going back is the user's choice only: at a deviation, or an undecided review finding, run `node "{{LW_HOME}}/hooks/lw.mjs" reopen <plan|test> "<reason>"` (plan or test; accepted only after Build began) and set `stage: <plan|test>` in the task file header (for plan also `plan: draft`), then follow the stage skill it names. Locked tests may then be edited by the tester in Test and are re-locked.
32
34
  - A failed review returns to `loopwright-build` and then `loopwright-review`, up to the task's fix-round cap.
33
35
 
36
+ Exploring is not a stage of the loop: to understand an unfamiliar codebase before any task, run `loopwright-explore` (`/loopwright-explore [folder]`).
37
+
38
+ Work found along the way that does not belong in the task goes to `loopwright-park` (`/loopwright-park`), which leaves the current task unchanged.
39
+
34
40
  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 runs next.
35
41
 
36
42
  ## Gates: stop and wait for the user
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: loopwright-park
3
+ description: Use when work turns up while doing a task that does not belong in it. Captures it as a startable local task stub so the current task stays unchanged and the new one is planned later in a fresh context.
4
+ ---
5
+ # loopwright park
6
+
7
+ Captures work found mid-task (call it B) as a stub, so the current task (A) keeps its scope, tests, state and diff. B is picked up later through normal Plan. Park runs in this main thread; do not spawn the subagents here.
8
+
9
+ ## Setup
10
+
11
+ 1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
12
+ 2. `node "{{LW_HOME}}/hooks/lw.mjs" dir` → `<lw>`. `null` inside a git repo → no task has started here yet; `lw.mjs park` creates `.loopwright/`, so continue. Not a git repo → tell the user loopwright must run inside a git repo, stop.
13
+ 3. `node "{{LW_HOME}}/hooks/lw.mjs" status`. It prints a task → 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.
14
+
15
+ ## Steps
16
+
17
+ 1. Restate B for the user to edit: a title, a one-paragraph goal, and evidence as `path:line` leads from what you already saw. No scouting: do not read more code to fill this in.
18
+ 2. Ask one question, "Does this block the current task?", recommendation "no" (Claude: `AskUserQuestion`; Codex: numbered text). It needs an active task; with none, skip it.
19
+ 3. Run `node "{{LW_HOME}}/hooks/lw.mjs" park "<title>"`, adding `--blocks` when the answer is yes and `--kind fix` when B is a bug. It prints `{stub, foundWhile, blocks}`.
20
+ 4. Write the agreed goal under `## Goal` and the evidence under `## Evidence` of `<lw>/<stub>`.
21
+ 5. Blocking → suggest running B first in another worktree (the stub is shared by all worktrees), and leave A as it is.
22
+ 6. Tell the user the stub path and that it is listed under A's `## Follow-ups`. Resume A where it was.
23
+
24
+ ## Rules
25
+
26
+ - Never change the current task (A): its scope, tests, state and diff stay as they were, apart from the follow-up line `park` adds to its task file. Do not edit code.
27
+ - Never start B. Starting it is `/loopwright-plan` or `/loopwright-flow` later, in a fresh context.
28
+ - Do not write task ids into the stub.
@@ -18,6 +18,10 @@ Plan runs in this main thread. You state assumptions; the user decides. Do not e
18
18
  5. `git status --porcelain` not empty → uncommitted changes will be part of the reviewed diff. Ask the user whether to commit/stash them first or include them; record the answer as a decision once the task file exists.
19
19
  6. Upstream check: `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; it fails offline or without auth → skip this check). Then list `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. Repeat in any sibling repo the goal touches (e.g. a separate frontend repo). New upstream commits → tell the user and ask whether to pull first. A commit or branch that already touches the goal's feature → ask whether someone has already done this work. Record the answers as decisions once the task file exists.
20
20
 
21
+ ## Parked stubs
22
+
23
+ Invoked without a goal (and no active task) → run `grep -l "^status: proposed" <lw>/tasks/*.md` and list the stubs `/loopwright-park` left, one line each (title, `kind`, `found while`, `blocks`). Offer: start one, drop one, or a new task. Drop → set `status: dropped` in the stub; never delete it. Start → treat the stub as an imported spec: run `start tasks/<stub>.md`, and fill that same file in place (status `active`, the Plan template's header lines and sections) instead of creating a second file. Keep its `kind`, `found while` and `blocks` lines. Its `## Goal` is confirmed with the batch; its `## Evidence` is a lead for the scout, not a verified fact.
24
+
21
25
  ## 1. Input
22
26
 
23
27
  - A goal in the user's words, or a path to an imported spec/plan (e.g. from superpowers).
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",
4
+ "version": "0.1.5",
5
5
  "description": "Agent workflow installer for Claude Code, Codex and Junie",
6
6
  "type": "module",
7
7
  "bin": {