loopwright 0.1.11 → 0.1.13

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
@@ -33,7 +33,7 @@ Then open Claude Code in the repo and run:
33
33
  /loopwright-flow add rate limiting to the login endpoint
34
34
  ```
35
35
 
36
- The agent scouts your repo, asks you about its high-impact assumptions, and then walks the task through Test, Build, Review and Done, stopping wherever you need to decide. Nothing is committed for you.
36
+ The agent scouts your repo, asks you about its high-impact assumptions, and then walks the task through Test, Build, Review and Done, stopping wherever you need to decide. loopwright commits only after you approve, only on a [working branch](docs/configuration.md#where-commits-are-made), and never pushes.
37
37
 
38
38
  `init` writes skills, subagents, hooks and a local `.loopwright/` folder. Commit the result to share it with your team, or use `npx loopwright init --global` to install into your home directory instead. See [Installation](docs/installation.md) for flags and the exact files written.
39
39
 
@@ -57,7 +57,7 @@ flowchart TD
57
57
  review -- "fix-round cap reached" --> you{{"You decide"}}
58
58
  review -- "pass" --> done["Done<br/>AGENTS.md proposals, commit and PR draft"]
59
59
  slices -.-> done
60
- done --> commit(["You commit"])
60
+ done --> commit(["You approve the commit"])
61
61
  ```
62
62
 
63
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.
@@ -65,9 +65,9 @@ flowchart TD
65
65
  - **Build**: an implementer subagent makes the locked tests pass. Small feature tasks skip Test, so the implementer writes the tests; a fix never skips it.
66
66
  - **Simplify** (standard, large, and every fix): a read-only reviewer proposes behavior-preserving cuts to the diff, each with its net line change and what it gives up. You choose which to apply; nothing changes without your approval, and you are not asked when there is nothing to cut.
67
67
  - **Review**: a reviewer that starts blind runs your checks, confirms the locked tests are untouched, and reports only proven, high-impact findings. Blocking findings send the task back to Build, up to 3 rounds by default, and after a fix, later rounds check only what changed; findings it cannot confirm come to you to fix or dismiss.
68
- - **Done**: proposes `AGENTS.md` updates and drafts the commit and PR message. You approve each change; loopwright never commits.
68
+ - **Done**: proposes `AGENTS.md` updates and drafts the commit and PR message. You approve each change, and then the local commit (also after each slice of a large task); loopwright never pushes.
69
69
 
70
- Each task's goal, decisions, criteria and review log live in `.loopwright/tasks/<date>-<title>.md`. For the large-tier slice loop, step-by-step Plan and Review charts, and every point where loopwright waits for you, see [Workflow in detail](docs/workflow.md).
70
+ Each task's goal, decisions, criteria and review log live in `.loopwright/tasks/<date>-<HH-MM>-<title>.md`. For the large-tier slice loop, step-by-step Plan and Review charts, and every point where loopwright waits for you, see [Workflow in detail](docs/workflow.md).
71
71
 
72
72
  ### Commands
73
73
 
@@ -91,7 +91,7 @@ Run a single stage, or the whole loop with `flow`. In Codex, use `$` instead of
91
91
  |---|---|---|---|
92
92
  | Skills install | Supported, tested | WIP: installed, not tested end-to-end | WIP: reads `.agents/skills` |
93
93
  | Subagents (scout, tester, implementer, reviewer) | Supported, tested | WIP: installed, not tested end-to-end | WIP: `.junie/agents` |
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) |
94
+ | Hook enforcement (locked-test guard, stop gate, context restore, 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
95
  | Plain-words rules for messages to you | Supported | WIP: installed, not tested end-to-end | WIP: reads `.agents/skills` |
96
96
  | Structured questions | `AskUserQuestion` | Plain-text fallback (numbered options) | Plain-text fallback |
97
97
  | Cross-agent review (as the reviewer) | Supported, tested | WIP: untested | Not supported |
@@ -106,7 +106,7 @@ Codex and Junie CLI support is work in progress.
106
106
 
107
107
  - [Installation](docs/installation.md): flags, files written, update, uninstall, worktrees.
108
108
  - [Configuration](docs/configuration.md): models, fix rounds, cross-agent review, effort profiles (`lean`, `balanced`, `thorough`, `deep`; set with `--profile`), experimental features.
109
- - [Workflow in detail](docs/workflow.md): the full flow with charts: slices, the Plan and Review steps, and where it waits for you.
109
+ - [Workflow in detail](docs/workflow.md): the full flow with charts: slices, the Plan and Review stages, and where it waits for you.
110
110
  - [Enforcement and its limits](docs/enforcement.md): what the hooks block, and what they cannot.
111
111
  - [Dogfood checklist](docs/dogfood-checklist.md): a manual end-to-end test run.
112
112
 
@@ -9,7 +9,7 @@ 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.
12
+ Approved Simplify cuts (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
13
 
14
14
  ## Boundaries
15
15
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: loopwright-reviewer
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.
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 Simplify cuts) 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.
@@ -3,6 +3,7 @@
3
3
  "crossAgentReview": "off",
4
4
  "simplify": true,
5
5
  "docsDir": "docs/agents",
6
+ "protectedBranches": [],
6
7
  "models": {
7
8
  "claude": {
8
9
  "scout": "opus",
@@ -68,7 +68,7 @@ try {
68
68
  if (locked.size === 0) continue;
69
69
  const rel = repoRelative(top, abs);
70
70
  if (locked.has(rel))
71
- deny('', '', `loopwright: ${rel} is a locked acceptance test. Ask the user before changing it.`);
71
+ deny('PreToolUse', `loopwright: ${rel} is a locked acceptance test. Ask the user before changing it.`);
72
72
  }
73
73
  }
74
74
  allow();
@@ -28,6 +28,59 @@ export const PROFILES = {
28
28
  deep: { scout: 'xhigh', tester: 'xhigh', implementer: 'xhigh', reviewer: 'xhigh' },
29
29
  };
30
30
 
31
+ /**
32
+ * Icons in the task file: settings keys, section headings, tags, and progress marks. The plan skill's template uses
33
+ * the same ones (a test pins them equal); `lw.mjs` repairs a missing or wrong icon on the lines it knows.
34
+ * Some carry a variation selector (U+FE0F): compare exact code points.
35
+ */
36
+ export const TASK_FILE_ICONS = {
37
+ settings: {
38
+ kind: '🏷️',
39
+ status: '🚦',
40
+ stage: '📍',
41
+ plan: '📋',
42
+ tier: '📐',
43
+ profile: '🎚️',
44
+ 'two-pass': '👀',
45
+ 'fix-round cap': '🔧',
46
+ checks: '🔬',
47
+ worktree: '🌿',
48
+ 'base commit': '⚓',
49
+ 'found while': '🔗',
50
+ blocks: '⛔',
51
+ },
52
+ headings: {
53
+ Goal: '🎯',
54
+ Decisions: '⚖️',
55
+ Assumptions: '🔎',
56
+ 'Acceptance criteria': '🧪',
57
+ Slices: '🧩',
58
+ 'Review log': '🔁',
59
+ 'Open questions': '❓',
60
+ 'Notes for Done': '🗒️',
61
+ 'Follow-ups': '📌',
62
+ 'Bug report': '🐞',
63
+ 'Root cause': '🌱',
64
+ Evidence: '📎',
65
+ },
66
+ tags: {
67
+ asked: '🙋',
68
+ 'batch-confirmed': '☑️',
69
+ overridden: '✏️',
70
+ confirmed: '☑️',
71
+ todo: '⬜',
72
+ tested: '🧪',
73
+ passed: '✅',
74
+ },
75
+ progress: { finished: '✅', failed: '❌', running: '▶️', paused: '⏸️', back: '↩️' },
76
+ };
77
+
78
+ /** Regex source for a leading icon (and its space) before a settings key, heading name or tag; the line may have none. */
79
+ export const ICON_PREFIX = '(?:[^\\x00-\\x7F]\\S*[ \\t]+)?';
80
+
81
+ /** The first word after `key:` on a settings line, with or without a leading icon; undefined when there is no such line. */
82
+ export const settingValue = (text, key) => new RegExp(`^${ICON_PREFIX}${key}:[ \\t]*(\\S+)`, 'm').exec(text)?.[1];
83
+
31
84
  /** Hooks sit in `<loopwright home>/hooks`, the prompts beside them. */
32
85
  export const USER_MESSAGES_RULES = fileURLToPath(new URL('../prompts/user-messages.md', import.meta.url));
33
86
 
@@ -96,11 +149,11 @@ export function readState(dir, id) {
96
149
  }
97
150
  }
98
151
 
99
- export function writeState(dir, id, state) {
100
- const path = statePath(dir, id);
152
+ /** Write `text` to `path` through a temp file and a rename, so a reader never sees half a file. */
153
+ export function writeFileAtomic(path, text) {
101
154
  mkdirSync(dirname(path), { recursive: true });
102
155
  const tmp = `${path}.${process.pid}.tmp`;
103
- writeFileSync(tmp, JSON.stringify(state, null, 2) + '\n');
156
+ writeFileSync(tmp, text);
104
157
  // Windows: rename fails with EPERM/EBUSY/EACCES while another process briefly holds the target.
105
158
  for (let attempt = 0; ; attempt++) {
106
159
  try {
@@ -113,6 +166,9 @@ export function writeState(dir, id, state) {
113
166
  }
114
167
  }
115
168
 
169
+ export const writeState = (dir, id, state) =>
170
+ writeFileAtomic(statePath(dir, id), JSON.stringify(state, null, 2) + '\n');
171
+
116
172
  export function sha256File(path) {
117
173
  return createHash('sha256').update(readFileSync(path)).digest('hex');
118
174
  }
@@ -120,29 +176,31 @@ export function sha256File(path) {
120
176
  export function fingerprint(cwd, baseCommit) {
121
177
  const h = createHash('sha256');
122
178
  const top = gitTopLevel(cwd);
123
- const diffArgs = [
124
- '-c',
125
- 'core.quotePath=false',
126
- 'diff',
127
- '--binary',
128
- '--no-color',
129
- '--no-ext-diff',
130
- '--no-textconv',
131
- '--no-renames',
132
- '--full-index',
133
- '--no-relative',
134
- '--src-prefix=a/',
135
- '--dst-prefix=b/',
136
- baseCommit,
137
- ];
138
- h.update(execFileSync('git', diffArgs, { cwd: top, maxBuffer: MAX_BUFFER, stdio: ['ignore', 'pipe', 'pipe'] }));
139
- const out = execFileSync('git', ['-c', 'core.quotePath=false', 'ls-files', '--others', '--exclude-standard', '-z'], {
140
- cwd: top,
141
- maxBuffer: MAX_BUFFER,
142
- stdio: ['ignore', 'pipe', 'pipe'],
143
- encoding: 'utf8',
144
- });
145
- const files = out.split('\0').filter(Boolean).sort();
179
+ const run = (args) =>
180
+ execFileSync('git', ['-c', 'core.quotePath=false', ...args], {
181
+ cwd: top,
182
+ maxBuffer: MAX_BUFFER,
183
+ stdio: ['ignore', 'pipe', 'pipe'],
184
+ });
185
+ const diff = (...extra) =>
186
+ run([
187
+ 'diff',
188
+ ...extra,
189
+ '--no-color',
190
+ '--no-ext-diff',
191
+ '--no-textconv',
192
+ '--no-renames',
193
+ '--no-relative',
194
+ '--src-prefix=a/',
195
+ '--dst-prefix=b/',
196
+ baseCommit,
197
+ ]);
198
+ // Files new since the base are hashed by content like untracked ones, so adding them to the index or committing
199
+ // them never changes the fingerprint.
200
+ h.update(diff('--binary', '--full-index', '--diff-filter=a'));
201
+ const added = diff('--name-only', '-z', '--diff-filter=A').toString().split('\0');
202
+ const others = run(['ls-files', '--others', '--exclude-standard', '-z']).toString().split('\0');
203
+ const files = [...new Set([...added, ...others])].filter(Boolean).sort();
146
204
  for (const f of files) {
147
205
  h.update(f + '\0');
148
206
  try {
@@ -206,10 +264,24 @@ export function allow() {
206
264
  process.exit(0);
207
265
  }
208
266
 
209
- // Claude and Codex both block via stderr reason + exit 2. The reason must be
210
- // non-empty: Codex ignores exit 2 with empty stderr.
211
- export function deny(_tool, _event, reason) {
267
+ // Claude Code blocks through JSON on stdout, which it shows without the hook's command path
268
+ // (https://code.claude.com/docs/en/hooks.md: PreToolUse permissionDecision, Stop decision control).
269
+ // Codex and Junie block via stderr reason + exit 2; Codex ignores exit 2 with empty stderr, so the reason is never empty.
270
+ export function deny(event, reason) {
212
271
  const text = String(reason ?? '').trim() || 'loopwright: blocked';
272
+ const i = process.argv.indexOf('--tool');
273
+ if (i !== -1 && process.argv[i + 1] === 'claude') {
274
+ process.stdout.write(
275
+ JSON.stringify(
276
+ event === 'Stop'
277
+ ? { decision: 'block', reason: text }
278
+ : {
279
+ hookSpecificOutput: { hookEventName: event, permissionDecision: 'deny', permissionDecisionReason: text },
280
+ },
281
+ ) + '\n',
282
+ );
283
+ process.exit(0);
284
+ }
213
285
  process.stderr.write(text + '\n');
214
286
  process.exit(2);
215
287
  }