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 +6 -6
- package/content/agents/implementer.md +1 -1
- package/content/agents/reviewer.md +1 -1
- package/content/hooks/default-config.json +1 -0
- package/content/hooks/guard-locked-tests.mjs +1 -1
- package/content/hooks/lib.mjs +101 -29
- package/content/hooks/lw.mjs +469 -67
- package/content/hooks/plain-questions.mjs +6 -10
- package/content/hooks/reinject-context.mjs +10 -3
- package/content/hooks/stop-gate.mjs +1 -2
- package/content/hooks/task-file.mjs +243 -0
- package/content/prompts/blocked-branch.md +9 -0
- package/content/prompts/commit-and-pr.md +55 -0
- package/content/prompts/glossary.md +37 -0
- package/content/prompts/standards.md +1 -0
- package/content/prompts/user-messages.md +6 -25
- package/content/skills/loopwright-build/SKILL.md +7 -7
- package/content/skills/loopwright-done/SKILL.md +25 -16
- package/content/skills/loopwright-explore/SKILL.md +1 -1
- package/content/skills/loopwright-fix/SKILL.md +2 -2
- package/content/skills/loopwright-flow/SKILL.md +10 -8
- package/content/skills/loopwright-park/SKILL.md +10 -2
- package/content/skills/loopwright-plan/SKILL.md +73 -48
- package/content/skills/loopwright-review/SKILL.md +29 -22
- package/content/skills/loopwright-test/SKILL.md +9 -9
- package/dist/cli.js +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// PreToolUse hook (Claude Code only): send an AskUserQuestion back for a rewrite when it holds a bare
|
|
3
|
-
// https://code.claude.com/docs/en/hooks.md (PreToolUse): tool_input.questions[] has question, header, options[].label and .description
|
|
2
|
+
// PreToolUse hook (Claude Code only): send an AskUserQuestion back for a rewrite when it holds a bare task id.
|
|
3
|
+
// https://code.claude.com/docs/en/hooks.md (PreToolUse): tool_input.questions[] has question, header, options[].label and .description.
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import {
|
|
@@ -18,9 +18,6 @@ import {
|
|
|
18
18
|
|
|
19
19
|
// Two denials in a row, then the question goes through, so a stubborn one never loops.
|
|
20
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
21
|
// Text after a plain description: in brackets, parentheses or backticks.
|
|
25
22
|
const LABELLED = /\([^)]*\)|\[[^\]]*\]|`[^`]*`/g;
|
|
26
23
|
|
|
@@ -51,7 +48,7 @@ try {
|
|
|
51
48
|
for (const text of texts) {
|
|
52
49
|
if (typeof text !== 'string') continue;
|
|
53
50
|
const bare = text.replace(LABELLED, ' ');
|
|
54
|
-
const terms = [...new Set([...(ids ? bare.matchAll(ids) : [])
|
|
51
|
+
const terms = [...new Set([...(ids ? bare.matchAll(ids) : [])].map((m) => m[0]))];
|
|
55
52
|
if (terms.length) found.push(`- "${text}": ${terms.join(', ')}`);
|
|
56
53
|
}
|
|
57
54
|
|
|
@@ -66,12 +63,11 @@ try {
|
|
|
66
63
|
state.questionBlocks = blocks + 1;
|
|
67
64
|
writeState(dir, id, state);
|
|
68
65
|
deny(
|
|
69
|
-
'',
|
|
70
|
-
'',
|
|
66
|
+
'PreToolUse',
|
|
71
67
|
[
|
|
72
|
-
'loopwright: this question
|
|
68
|
+
'loopwright: this question was not shown because it names task ids the user has never seen:',
|
|
73
69
|
...found,
|
|
74
|
-
`
|
|
70
|
+
`Rewrite it so each id is described in plain words first and the id is only a bracketed pointer, as in ${USER_MESSAGES_RULES}. Then ask again.`,
|
|
75
71
|
].join('\n'),
|
|
76
72
|
);
|
|
77
73
|
} catch (err) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import {
|
|
6
|
+
ICON_PREFIX,
|
|
6
7
|
USER_MESSAGES_RULES,
|
|
7
8
|
allow,
|
|
8
9
|
exitIfHooksOff,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
loopwrightDir,
|
|
11
12
|
readState,
|
|
12
13
|
readStdinJson,
|
|
14
|
+
settingValue,
|
|
13
15
|
worktreeId,
|
|
14
16
|
} from './lib.mjs';
|
|
15
17
|
|
|
@@ -21,9 +23,14 @@ const NEXT = {
|
|
|
21
23
|
done: 'Run /loopwright-done.',
|
|
22
24
|
};
|
|
23
25
|
|
|
26
|
+
function headingAt(lines, name) {
|
|
27
|
+
const heading = new RegExp(`^#{1,6}\\s*${ICON_PREFIX}${name}\\b`, 'i');
|
|
28
|
+
return lines.findIndex((l) => heading.test(l.trim()));
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
function goalParagraph(text) {
|
|
25
32
|
const lines = text.split(/\r?\n/);
|
|
26
|
-
const i = lines
|
|
33
|
+
const i = headingAt(lines, 'goal');
|
|
27
34
|
if (i === -1) return [];
|
|
28
35
|
const out = [];
|
|
29
36
|
for (const l of lines.slice(i + 1)) {
|
|
@@ -40,7 +47,7 @@ function goalParagraph(text) {
|
|
|
40
47
|
// First non-empty line under `## Root cause`; one line keeps the 40-line cap for the decisions.
|
|
41
48
|
function rootCauseLine(text) {
|
|
42
49
|
const lines = text.split(/\r?\n/);
|
|
43
|
-
const i = lines
|
|
50
|
+
const i = headingAt(lines, 'root cause');
|
|
44
51
|
if (i === -1) return null;
|
|
45
52
|
for (const l of lines.slice(i + 1)) {
|
|
46
53
|
if (/^#{1,6}\s/.test(l)) return null;
|
|
@@ -64,7 +71,7 @@ try {
|
|
|
64
71
|
const file = join(dir, String(state.task));
|
|
65
72
|
if (existsSync(file)) {
|
|
66
73
|
const text = readFileSync(file, 'utf8');
|
|
67
|
-
const fix =
|
|
74
|
+
const fix = settingValue(text, 'kind') === 'fix';
|
|
68
75
|
if (fix) lines.push('kind: fix');
|
|
69
76
|
lines.push(...goalParagraph(text));
|
|
70
77
|
const root = fix ? rootCauseLine(text) : null;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// Task-file edits behind the writer commands of lw.mjs. Every function maps the file's text (LF line endings) to its
|
|
2
|
+
// next text, or throws a message for the user; icons are written only in a file that has the yaml settings fence.
|
|
3
|
+
import { ICON_PREFIX, TASK_FILE_ICONS, settingValue } from './lib.mjs';
|
|
4
|
+
|
|
5
|
+
const { settings: SETTING_ICONS, headings: HEADING_ICONS, tags: TAG_ICONS } = TASK_FILE_ICONS;
|
|
6
|
+
|
|
7
|
+
export const SETTING_KEYS = Object.keys(SETTING_ICONS);
|
|
8
|
+
/** Section names in the order a new heading is placed. */
|
|
9
|
+
export const SECTION_NAMES = [
|
|
10
|
+
'Goal',
|
|
11
|
+
'Bug report',
|
|
12
|
+
'Root cause',
|
|
13
|
+
'Evidence',
|
|
14
|
+
'Decisions',
|
|
15
|
+
'Assumptions',
|
|
16
|
+
'Acceptance criteria',
|
|
17
|
+
'Slices',
|
|
18
|
+
'Review log',
|
|
19
|
+
'Open questions',
|
|
20
|
+
'Notes for Done',
|
|
21
|
+
'Follow-ups',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export const header = (t) => t.split(/^## /m)[0];
|
|
25
|
+
export const fenced = (t) => /^```yaml[ \t]*$/m.test(header(t));
|
|
26
|
+
const icon = (t, table, name) => (fenced(t) ? `${table[name]} ` : '');
|
|
27
|
+
const tagged = (t, tag) => `${icon(t, TAG_ICONS, tag)}[${tag}]`;
|
|
28
|
+
const nextNumber = (text, re) => 1 + Math.max(0, ...Array.from(text.matchAll(re), (m) => Number(m[1])));
|
|
29
|
+
|
|
30
|
+
/** Set `key: value` in the settings (added when missing), or drop the line when `value` is null. */
|
|
31
|
+
export function setSetting(t, key, value) {
|
|
32
|
+
const head = header(t);
|
|
33
|
+
const rest = t.slice(head.length);
|
|
34
|
+
const line = new RegExp(`^(${ICON_PREFIX})${key}:[^\\n]*(\\n?)`, 'm');
|
|
35
|
+
if (line.test(head))
|
|
36
|
+
return head.replace(line, (_, ic, nl) => (value === null ? '' : `${ic}${key}: ${value}${nl}`)) + rest;
|
|
37
|
+
if (value === null) return t;
|
|
38
|
+
const added = `${icon(t, SETTING_ICONS, key)}${key}: ${value}\n`;
|
|
39
|
+
if (fenced(t)) {
|
|
40
|
+
const open = /^```yaml[ \t]*\n/m.exec(head);
|
|
41
|
+
const from = open.index + open[0].length;
|
|
42
|
+
const close = from + head.slice(from).search(/^```[ \t]*$/m);
|
|
43
|
+
return head.slice(0, close) + added + head.slice(close) + rest;
|
|
44
|
+
}
|
|
45
|
+
const last = [...head.matchAll(new RegExp(`^${ICON_PREFIX}(?:${SETTING_KEYS.join('|')}):[^\\n]*\\n`, 'gm'))].at(-1);
|
|
46
|
+
const at = last ? last.index + last[0].length : head.length;
|
|
47
|
+
return head.slice(0, at) + added + head.slice(at) + rest;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const headingRe = (name) => new RegExp(`^## ${ICON_PREFIX}${name}[ \\t]*$`, 'm');
|
|
51
|
+
|
|
52
|
+
/** Add the section's heading when missing, before the first later section of the template order (else last). */
|
|
53
|
+
export function ensureSection(t, name) {
|
|
54
|
+
if (headingRe(name).test(t)) return t;
|
|
55
|
+
const heading = `## ${icon(t, HEADING_ICONS, name)}${name}`;
|
|
56
|
+
const later = SECTION_NAMES.slice(SECTION_NAMES.indexOf(name) + 1)
|
|
57
|
+
.map((n) => headingRe(n).exec(t))
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
const at = Math.min(...later.map((m) => m.index));
|
|
60
|
+
return later.length ? `${t.slice(0, at)}${heading}\n\n${t.slice(at)}` : `${t.replace(/\n*$/, '\n')}\n${heading}\n`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function sectionSpan(t, name) {
|
|
64
|
+
const m = headingRe(name).exec(t);
|
|
65
|
+
const from = m.index + m[0].length;
|
|
66
|
+
const next = t.slice(from).search(/^## /m);
|
|
67
|
+
return { from, to: next === -1 ? t.length : from + next };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const sectionBody = (t, name) => {
|
|
71
|
+
const { from, to } = sectionSpan(t, name);
|
|
72
|
+
return t.slice(from, to).trim();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Replace the section's body with the lines `change` returns for the current ones; creates a missing section. */
|
|
76
|
+
function changeLines(t, name, change) {
|
|
77
|
+
const text = ensureSection(t, name);
|
|
78
|
+
const body = sectionBody(text, name);
|
|
79
|
+
const lines = change(body ? body.split('\n') : []).join('\n');
|
|
80
|
+
const { from, to } = sectionSpan(text, name);
|
|
81
|
+
return `${text.slice(0, from)}${lines ? `\n\n${lines}\n` : '\n'}${to < text.length ? '\n' : ''}${text.slice(to)}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const writeSection = (t, name, body, append) =>
|
|
85
|
+
changeLines(t, name, (lines) => [...(append ? lines : []), ...(body ? body.split('\n') : [])]);
|
|
86
|
+
|
|
87
|
+
const DECISION_TAGS = ['asked', 'batch-confirmed', 'overridden'];
|
|
88
|
+
const ASSUMPTION_TAGS = ['confirmed', 'batch-confirmed', 'overridden'];
|
|
89
|
+
|
|
90
|
+
/** `flags`: the options an entry type takes; `tags`: its allowed `--tag` values; `section`: where it is appended. */
|
|
91
|
+
const ENTRY_TYPES = {
|
|
92
|
+
decision: { section: 'Decisions', flags: ['tag', 'resolves'], tags: DECISION_TAGS, tagRequired: true },
|
|
93
|
+
assumption: { section: 'Assumptions', flags: ['tag', 'resolves'], tags: ASSUMPTION_TAGS, tagRequired: true },
|
|
94
|
+
question: { section: 'Open questions', flags: [], prefix: '- ', suffix: ' — pending' },
|
|
95
|
+
ac: { section: 'Acceptance criteria', flags: ['tag', 'interface', 'test'], tags: ['repro', 'regression'] },
|
|
96
|
+
slice: { section: 'Slices', flags: [] },
|
|
97
|
+
round: { section: 'Review log', flags: ['scope'] },
|
|
98
|
+
finding: { section: 'Review log', flags: [], nested: true },
|
|
99
|
+
sibling: { section: 'Review log', flags: [], nested: true },
|
|
100
|
+
'scope-change': { section: 'Review log', flags: [], prefix: '- Scope change: ' },
|
|
101
|
+
simplify: { section: 'Review log', flags: [], prefix: '- Simplify: ' },
|
|
102
|
+
followup: { section: 'Follow-ups', flags: [], prefix: '- ' },
|
|
103
|
+
};
|
|
104
|
+
export const ENTRY_NAMES = Object.keys(ENTRY_TYPES);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Append the next-numbered entry of `type`. `opts` holds the flags given, `input` the stdin lines: the first is the
|
|
108
|
+
* entry's text, the rest become sub-lines. Returns the new text and the entry's id, when it has one.
|
|
109
|
+
*/
|
|
110
|
+
export function addEntry(t, type, opts, input) {
|
|
111
|
+
const spec = ENTRY_TYPES[type];
|
|
112
|
+
const extra = Object.keys(opts).find((k) => !spec.flags.includes(k));
|
|
113
|
+
if (extra) throw new Error(`add ${type} does not take --${extra}`);
|
|
114
|
+
if (opts.tag === undefined ? spec.tagRequired : !spec.tags.includes(opts.tag))
|
|
115
|
+
throw new Error(`add ${type} needs --tag, one of ${spec.tags.join(', ')}`);
|
|
116
|
+
if (!input.length) throw new Error(`add ${type} needs its text on stdin`);
|
|
117
|
+
if (spec.nested && input.length > 1) throw new Error(`add ${type} takes one line of text`);
|
|
118
|
+
const [text, ...more] = input;
|
|
119
|
+
const subs = [
|
|
120
|
+
...(opts.interface === undefined ? [] : [`interface: ${opts.interface}`]),
|
|
121
|
+
...(opts.test === undefined ? [] : [`test: ${opts.test}`]),
|
|
122
|
+
...more,
|
|
123
|
+
].map((l) => ` - ${l}`);
|
|
124
|
+
let id;
|
|
125
|
+
const number = (letters) => `${letters}${nextNumber(t, new RegExp(`^- ${letters}(\\d+) `, 'gm'))}`;
|
|
126
|
+
const entry = (lines) => (log) => [...log, ...lines];
|
|
127
|
+
let change;
|
|
128
|
+
if (type === 'decision' || type === 'assumption') {
|
|
129
|
+
id = number(type === 'decision' ? 'D' : 'A');
|
|
130
|
+
change = entry([`- ${id} ${tagged(t, opts.tag)} ${text}`, ...subs]);
|
|
131
|
+
} else if (type === 'ac') {
|
|
132
|
+
id = number('AC');
|
|
133
|
+
change = entry([`- ${id}${opts.tag ? ` [${opts.tag}]` : ''} ${text}`, ...subs]);
|
|
134
|
+
} else if (type === 'slice') {
|
|
135
|
+
id = number('S');
|
|
136
|
+
change = entry([`- ${id} ${tagged(t, 'todo')} ${text}`, ...subs]);
|
|
137
|
+
} else if (type === 'round') {
|
|
138
|
+
change = (log) => {
|
|
139
|
+
const rounds = log
|
|
140
|
+
.slice(log.findLastIndex((l) => l.startsWith('- Scope change:')) + 1)
|
|
141
|
+
.map((l) => /^- R(\d+)(?: (\S+))?:/.exec(l))
|
|
142
|
+
.filter((m) => m && m[2] === opts.scope);
|
|
143
|
+
id = `R${1 + Math.max(0, ...rounds.map((m) => Number(m[1])))}`;
|
|
144
|
+
return [...log, `- ${id}${opts.scope ? ` ${opts.scope}` : ''}: ${text}`, ...subs];
|
|
145
|
+
};
|
|
146
|
+
} else if (spec.nested) {
|
|
147
|
+
change = (log) => {
|
|
148
|
+
const round = log.findLastIndex((l) => /^- R\d+/.test(l));
|
|
149
|
+
if (round === -1) throw new Error(`add ${type}: no review round to attach it to`);
|
|
150
|
+
let end = round + 1;
|
|
151
|
+
while (log[end]?.startsWith(' ')) end++;
|
|
152
|
+
const n = nextNumber(log.slice(round, end).join('\n'), /^ {2}- U(\d+) /gm);
|
|
153
|
+
id = type === 'finding' ? `U${n}` : undefined;
|
|
154
|
+
return log.toSpliced(end, 0, type === 'finding' ? ` - ${id} ${text}` : ` - Sibling ${text}`);
|
|
155
|
+
};
|
|
156
|
+
} else change = entry([`${spec.prefix}${text}${spec.suffix ?? ''}`, ...subs]);
|
|
157
|
+
let next = t;
|
|
158
|
+
if (opts.resolves !== undefined) {
|
|
159
|
+
const pending = `- ${opts.resolves} — pending`;
|
|
160
|
+
if (!headingRe('Open questions').test(t) || !sectionBody(t, 'Open questions').split('\n').includes(pending))
|
|
161
|
+
throw new Error(`add ${type}: no open question '${opts.resolves}'`);
|
|
162
|
+
next = changeLines(t, 'Open questions', (lines) => lines.filter((l) => l !== pending));
|
|
163
|
+
}
|
|
164
|
+
return { text: changeLines(next, spec.section, change), id };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Set a slice to todo, tested or passed (with its icon), or drop the `— apply pending` ending of the Simplify line. */
|
|
168
|
+
export function markEntry(t, id, state) {
|
|
169
|
+
if (id === 'simplify') {
|
|
170
|
+
if (state !== 'applied') throw new Error('mark simplify takes the state applied');
|
|
171
|
+
const lines = t.split('\n');
|
|
172
|
+
const at = lines.findLastIndex((l) => /^- Simplify: .* — apply pending$/.test(l));
|
|
173
|
+
if (at === -1) throw new Error('mark: no Simplify line is waiting to be applied');
|
|
174
|
+
lines[at] = lines[at].replace(/ — apply pending$/, '');
|
|
175
|
+
return lines.join('\n');
|
|
176
|
+
}
|
|
177
|
+
if (!/^S\d+$/.test(id ?? '')) throw new Error('mark: expected a slice id (S<n>) or simplify');
|
|
178
|
+
if (!['todo', 'tested', 'passed'].includes(state)) throw new Error('mark: the state is todo, tested or passed');
|
|
179
|
+
const line = new RegExp(`^- ${id} ${ICON_PREFIX}\\[(?:todo|tested|passed)\\]`, 'm');
|
|
180
|
+
if (!line.test(t)) throw new Error(`mark: ${id} not found`);
|
|
181
|
+
return t.replace(line, () => `- ${id} ${tagged(t, state)}`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Replace the text of a decision, assumption, criterion or slice, and/or its `interface:` and `test:` sub-lines. */
|
|
185
|
+
export function editEntry(t, id, { text, interface: iface, test }) {
|
|
186
|
+
if (!/^(?:D|A|AC|S)\d+$/.test(id ?? '')) throw new Error('edit: expected an id such as D1, A1, AC1 or S1');
|
|
187
|
+
const lines = t.split('\n');
|
|
188
|
+
const at = lines.findIndex((l) => l.startsWith(`- ${id} `));
|
|
189
|
+
if (at === -1) throw new Error(`edit: ${id} not found`);
|
|
190
|
+
if (text !== undefined)
|
|
191
|
+
lines[at] = new RegExp(`^- ${id} (?:${ICON_PREFIX}\\[[a-z-]+\\] )?`).exec(lines[at])[0] + text;
|
|
192
|
+
for (const [key, value] of [
|
|
193
|
+
['interface', iface],
|
|
194
|
+
['test', test],
|
|
195
|
+
]) {
|
|
196
|
+
if (value === undefined) continue;
|
|
197
|
+
let end = at + 1;
|
|
198
|
+
while (lines[end]?.startsWith(' ')) end++;
|
|
199
|
+
const subs = lines.slice(at + 1, end);
|
|
200
|
+
const own = subs.findIndex((l) => l.startsWith(` - ${key}:`));
|
|
201
|
+
const after = key === 'test' ? subs.findIndex((l) => l.startsWith(' - interface:')) : -1;
|
|
202
|
+
if (own === -1) lines.splice(at + 1 + (after + 1), 0, ` - ${key}: ${value}`);
|
|
203
|
+
else lines[at + 1 + own] = ` - ${key}: ${value}`;
|
|
204
|
+
}
|
|
205
|
+
return lines.join('\n');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A new task file: the title and the kind; `fillTask` adds the rest. */
|
|
209
|
+
export const skeleton = (title, kind) => `# ${title}\n\n\`\`\`yaml\n${SETTING_ICONS.kind} kind: ${kind}\n\`\`\`\n`;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Bring a new file or a proposed stub to a task file at Plan: active, the settings the plan fills in later set to
|
|
213
|
+
* pending, and every empty section. What the stub already has (kind, plan, links, goal, evidence) is kept.
|
|
214
|
+
*/
|
|
215
|
+
export function fillTask(t, { profile, worktree, base }) {
|
|
216
|
+
const settings = [
|
|
217
|
+
['status', 'active', true],
|
|
218
|
+
['stage', 'plan', true],
|
|
219
|
+
['plan', 'draft'],
|
|
220
|
+
['tier', 'pending'],
|
|
221
|
+
['profile', profile ?? 'pending', profile !== undefined],
|
|
222
|
+
['two-pass', 'pending'],
|
|
223
|
+
['fix-round cap', 'pending'],
|
|
224
|
+
['checks', 'pending'],
|
|
225
|
+
['worktree', worktree, true],
|
|
226
|
+
['base commit', base, true],
|
|
227
|
+
];
|
|
228
|
+
const withSettings = settings.reduce(
|
|
229
|
+
(text, [key, value, force]) =>
|
|
230
|
+
force || settingValue(header(text), key) === undefined ? setSetting(text, key, value) : text,
|
|
231
|
+
t,
|
|
232
|
+
);
|
|
233
|
+
const fix = settingValue(header(t), 'kind') === 'fix';
|
|
234
|
+
return [
|
|
235
|
+
'Goal',
|
|
236
|
+
'Decisions',
|
|
237
|
+
'Assumptions',
|
|
238
|
+
'Acceptance criteria',
|
|
239
|
+
'Review log',
|
|
240
|
+
'Open questions',
|
|
241
|
+
...(fix ? ['Bug report', 'Root cause', 'Follow-ups', 'Evidence'] : []),
|
|
242
|
+
].reduce((text, name) => ensureSection(text, name), withSettings);
|
|
243
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Blocked branch
|
|
2
|
+
|
|
3
|
+
`lw.mjs commit --prepare` or `commit` refused because the current branch is not a working branch. The message names the branch, the reason and a suggested branch name. Never commit on that branch, and never try to get around the refusal.
|
|
4
|
+
|
|
5
|
+
1. Run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "new branch"`.
|
|
6
|
+
2. Tell the user in plain words following `{{LW_HOME}}/prompts/user-messages.md` why the branch is refused (the reason from the message), and ask one question: create a working branch here and commit there (offer the suggested name; the user may change it), or skip the commit.
|
|
7
|
+
3. After the answer run `node "{{LW_HOME}}/hooks/lw.mjs" resume`.
|
|
8
|
+
- New branch → run `node "{{LW_HOME}}/hooks/lw.mjs" branch <name>`. It switches in place and keeps the changes. A name that is taken fails with its own message: show it and ask for another name, or skip. Then go on with the commit step from `commit --prepare`.
|
|
9
|
+
- Skip → nothing is committed and the changes stay in the working tree. The task goes on: the slice is still marked passed and Done still closes.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# loopwright commit and PR rules
|
|
2
|
+
|
|
3
|
+
How to write a commit message, a PR description and issue (ticket) text, for the main thread at Done and Review. People read them later to review, trace and maintain the change, and long or jargon-heavy text defeats that. The rules for the messages that present these drafts to the user are in `user-messages.md`.
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
1. **Commit message: imperative subject of 72 characters or less, then a body of about 5 lines.** The body says why the change was made and what it changes. Add a rejected option only when a future reader would otherwise try it again; leave out lists of decisions and rejected options. Why: a reader of `git blame` needs the reason, and a long body hides it.
|
|
8
|
+
2. **PR description: a summary of 1–3 sentences on what changed and why, one or two lines on how it was checked, and the decisions a reviewer would question, one line each.** A section built from task records (tests changed after going back, follow-ups, a fix's root cause and repro test) appears only when it has content; add no assumptions section. Why: a reviewer reads the summary first, and an empty or low-value section makes the PR longer without helping.
|
|
9
|
+
3. **Plain words.** Use none of the terms of the loopwright process that made the change: stage names, review rounds, locked tests and task ids never appear. A change to loopwright itself still names the feature it changes. Name a file, function or command only where a reader needs it to find the change, in backticks. Why: the reader never saw the process, and a name they cannot place is noise.
|
|
10
|
+
4. **Issue text: a title, then what and why in a few lines, with `path:line` evidence.** The same plain words apply, and it names no task file. Why: an issue is picked up by someone who has not seen this work.
|
|
11
|
+
5. **The length targets are soft.** Split or cut a sentence rather than cut meaning. Why: a hard cap makes text choppy, but long text is the problem this file exists to prevent.
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
**Before (commit message):**
|
|
16
|
+
Add slice commit
|
|
17
|
+
|
|
18
|
+
Implements D2 and D3 after review round 2. Decisions: commit via lw.mjs, never push. Rejected: auto-commit without approval, because the user wants to approve; rejected squashing slices, because history is lost. Locked tests: test/commit.test.ts. AC1-AC4 pass.
|
|
19
|
+
|
|
20
|
+
**After:**
|
|
21
|
+
Commit locally after each slice with the user's approval
|
|
22
|
+
|
|
23
|
+
A large change was left uncommitted until the end, so a failed later slice put earlier work at risk. The new `commit` command commits what is staged and never pushes.
|
|
24
|
+
|
|
25
|
+
**Before (PR description):**
|
|
26
|
+
## Summary
|
|
27
|
+
Implements the commit flow.
|
|
28
|
+
## Key decisions
|
|
29
|
+
D1, D2, D3, D4 (see task file)
|
|
30
|
+
## Rejected options
|
|
31
|
+
Auto-commit; squash.
|
|
32
|
+
## Notable assumptions
|
|
33
|
+
Git is installed.
|
|
34
|
+
## Verification
|
|
35
|
+
Round 1 failed, round 2 passed, locked tests unchanged.
|
|
36
|
+
## Follow-ups
|
|
37
|
+
None.
|
|
38
|
+
|
|
39
|
+
**After:**
|
|
40
|
+
## Summary
|
|
41
|
+
Commit locally after each slice and at the end, with the user's approval. A failed later slice no longer puts earlier work at risk.
|
|
42
|
+
|
|
43
|
+
## Checked
|
|
44
|
+
`npm test` passes, including new tests for the `commit` command.
|
|
45
|
+
|
|
46
|
+
## Decisions
|
|
47
|
+
- The command never pushes; the user pushes after reading the commit.
|
|
48
|
+
|
|
49
|
+
**Before (issue text):**
|
|
50
|
+
Follow-up from task 2026-11-02 AC3: the thing is slow, see task file.
|
|
51
|
+
|
|
52
|
+
**After:**
|
|
53
|
+
Title: Full-repo scan runs on every hook call
|
|
54
|
+
|
|
55
|
+
`content/hooks/lib.mjs:120` lists every tracked file on each call, so a hook takes seconds in a large repo. Cache the list for the length of one hook run.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# loopwright glossary
|
|
2
|
+
|
|
3
|
+
Use one term for each idea, in every skill, agent file, prompt, doc and message to the user. A second word for the same thing reads as a second thing. Each entry gives the term, a one-line definition, and the phrases not to use for it; a test fails when a `Not:` phrase appears in the shipped files or docs. A new term goes into both copies of this file (`GLOSSARY.md` and `content/prompts/glossary.md`).
|
|
4
|
+
|
|
5
|
+
- **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.
|
|
6
|
+
- **acceptance criterion** (AC): one thing the finished work must do that you can see, such as "an expired link shows a clear message".
|
|
7
|
+
- **acceptance test**: an automated test, written before the code, that checks one acceptance criterion; when it passes, that behavior works.
|
|
8
|
+
- **locked test**: a test file fixed with a fingerprint so the implementer cannot change it to make it pass.
|
|
9
|
+
Not: frozen, frozen test, frozen tests
|
|
10
|
+
- **re-lock**: locking a test file again after it was edited, which is allowed only after you chose to go back or approved a pull.
|
|
11
|
+
- **tier**: how big the task is (small, standard or large); it sets how much process the task gets.
|
|
12
|
+
- **profile**: how much effort the helper agents spend (lean, balanced, thorough or deep); more effort costs more time and tokens.
|
|
13
|
+
- **slice**: one separately built and checked piece of a large task.
|
|
14
|
+
- **stop gate**: a check that keeps the agent from ending its turn while a build or review is unfinished.
|
|
15
|
+
- **fix round**: one pass of fixing what a review found, followed by another review; each task has a limit.
|
|
16
|
+
Not: repair round, repair rounds, repair attempt, repair attempts
|
|
17
|
+
- **review round**: one run of the reviewer over the change, counted from 1 in the review log.
|
|
18
|
+
- **two-pass review**: the reviewer checks the change twice, once without hints and once against the implementer's own report of what it did.
|
|
19
|
+
- **undecided finding**: a review concern the reviewer cannot settle alone, so you decide whether to fix it or dismiss it.
|
|
20
|
+
Not: open finding, open findings
|
|
21
|
+
- **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.
|
|
22
|
+
- **simplify cut**: a proposed removal of code, tests or docs that the change added and does not need; you choose which to apply.
|
|
23
|
+
Not: simplification, simplifications
|
|
24
|
+
- **worktree**: a separate working folder of the same repository, on its own branch, so two tasks do not mix.
|
|
25
|
+
- **base commit**: the saved point in git history where the task began; the review compares the work against it.
|
|
26
|
+
- **implementer**: the agent that writes the code in Build; the tester writes the tests.
|
|
27
|
+
Not: code writer
|
|
28
|
+
- **stage**: one of Plan, Test, Build, Review and Done; "step" is kept for the numbered steps inside a stage.
|
|
29
|
+
Not: Plan step, Test step, Review step, Done step, Build step
|
|
30
|
+
- **context restore**: what runs after compaction to print the goal, stage, decisions and next step again from the task file.
|
|
31
|
+
Not: context reinjection
|
|
32
|
+
- **go back**: return to an earlier stage after Build began, by `reopen`, only on your choice.
|
|
33
|
+
- **state tool**: the script (`lw.mjs`) that records the stage, history and locked tests and edits the task file; name the file only in brackets or in commands.
|
|
34
|
+
- **stub**: a short task file saved for later by Park, with a goal and nothing decided.
|
|
35
|
+
Not: proposed task, proposed tasks
|
|
36
|
+
- **park**: save a stub for later instead of working on it now.
|
|
37
|
+
- **follow-up**: a change found while working that belongs in its own later task, not in this one.
|
|
@@ -16,4 +16,5 @@ Shared by the tester, implementer and reviewer. The repo's own docs on architect
|
|
|
16
16
|
- **Comments.** Comments explain why, briefly. State each rationale in exactly one place. Never restate what the code does. Why: a comment that repeats the code or another comment goes stale first.
|
|
17
17
|
- **No change-log comments.** Do not write "added", "changed from" or "now uses"; history lives in git. Why: the comment is wrong once the next change lands.
|
|
18
18
|
- **Leave existing docs alone.** Edit docs and comments you did not need to change only when your change makes them false. Why: unrelated rewrites bury the real diff.
|
|
19
|
+
- **One term per idea.** Use the terms in `glossary.md` (next to this file) in code comments, test names and reports; never a second word for a glossary term. Why: a second word for a thing reads as a second thing.
|
|
19
20
|
- **The test name carries the behavior.** Name a test for what it checks and skip doc blocks or comments that restate the name or the criterion. Why: a restated criterion is a second copy to keep in sync.
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
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
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
|
|
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 issue text follow `commit-and-pr.md`, and `AGENTS.md` text keeps its own rules; these rules cover the messages that present them. Subagent reports keep their formats; rewrite what you relay from them.
|
|
6
6
|
|
|
7
7
|
## Rules
|
|
8
8
|
|
|
9
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
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
|
|
11
|
+
3. **Plain description first, the name in brackets after.** Say what it is in everyday words, then give the file, function or task id in brackets as a lookup pointer; brackets carry names only (files, functions, task ids), and a name or id never stands alone. A glossary term is not a name: use it as an ordinary word, and explain it in plain words the first time it comes up. Why: the plain words make the point, and the name still lets the user find it.
|
|
12
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
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
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.**
|
|
15
|
+
7. **Use the same word for the same thing.** Use the terms in `glossary.md`, and 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
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
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
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.
|
|
@@ -22,29 +22,10 @@ The reader knows neither loopwright nor this code, and every "what do you mean?"
|
|
|
22
22
|
## Examples
|
|
23
23
|
|
|
24
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
|
|
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 locked, so the implementer cannot change them (test/login.test.ts). Next, the implementer writes the code.
|
|
26
26
|
|
|
27
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
|
|
28
|
+
**After:** Your choice of error text and a locked 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 stage 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
29
|
|
|
30
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
|
|
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.
|
|
31
|
+
**After:** This is a big change, so I will build it in two slices and review each slice, 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 fix rounds. Is that right?
|
|
@@ -8,7 +8,7 @@ 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
|
|
11
|
+
Before your first message to the user, read `{{LW_HOME}}/prompts/user-messages.md` and `{{LW_HOME}}/prompts/glossary.md` unless you already read them in this conversation, and write every message to the user by them, using one term for each idea.
|
|
12
12
|
|
|
13
13
|
1. Run every loopwright command from the worktree root: `cd "$(git rev-parse --show-toplevel)"`.
|
|
14
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.
|
|
@@ -19,17 +19,17 @@ Before your first message to the user, read `{{LW_HOME}}/prompts/user-messages.m
|
|
|
19
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.
|
|
20
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
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.
|
|
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
|
|
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 with `node "{{LW_HOME}}/hooks/lw.mjs" add decision --tag asked <<'LW_TEXT'`, the decision on the next line, then `LW_TEXT`.
|
|
23
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.
|
|
24
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.
|
|
25
|
-
- Pulled → run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD && node "{{LW_HOME}}/hooks/lw.mjs" stage build` as one call,
|
|
25
|
+
- Pulled → run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD && node "{{LW_HOME}}/hooks/lw.mjs" stage build` as one call, then run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --restart --reason "<the decision in words>"`.
|
|
26
26
|
- 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` (step 7), and tell the user the pulled commits stay in the review, because the base cannot move past the task's own commits.
|
|
27
|
-
6. Upstream check. Skip this check on a fix round (called with Review findings). Otherwise run `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; failure, e.g. offline or no auth → skip). List `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. For `large`, check before each slice's first Build. If the new commits touch the task's files or feature, or a sibling repo the task touches, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "upstream changed"`, show them to the user and ask whether to pull first or stop (someone may already have done this work) before spawning the implementer. Before asking, run `brief` and note whether `ownCommits` is present (the task already has commits since its base, answered as its own or only local). After the answer, run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and record it
|
|
27
|
+
6. Upstream check. Skip this check on a fix round (called with Review findings). Otherwise run `GIT_TERMINAL_PROMPT=0 git fetch --quiet` (never prompts for credentials; failure, e.g. offline or no auth → skip). List `git log --oneline HEAD..@{u}`; with no upstream, use `HEAD..origin/HEAD`; with neither, skip. For `large`, check before each slice's first Build. If the new commits touch the task's files or feature, or a sibling repo the task touches, run `node "{{LW_HOME}}/hooks/lw.mjs" await-user "upstream changed"`, show them to the user and ask whether to pull first or stop (someone may already have done this work) before spawning the implementer. Before asking, run `brief` and note whether `ownCommits` is present (the task already has commits since its base, answered as its own or only local). After the answer, run `node "{{LW_HOME}}/hooks/lw.mjs" resume` and record it the way step 5 does. If the user pulled and `ownCommits` was present, the base stays: run `node "{{LW_HOME}}/hooks/lw.mjs" keep-base --pulled --reason "<the pull decision in words>"` instead of the restart below, tell the user the pulled commits stay in the review (the base cannot move past the task's own commits), and go to step 7. If it pulled and `ownCommits` was absent, rebase the review scope so pulled commits are not judged as this task's change: run `node "{{LW_HOME}}/hooks/lw.mjs" start <task> --force --base HEAD && node "{{LW_HOME}}/hooks/lw.mjs" stage build` as one call (`start` keeps locks and history, updates the base commit line and resets the stage to plan; `stage build` sets it back), then run `node "{{LW_HOME}}/hooks/lw.mjs" accept-locks --restart --reason "<the pull decision in words>"` (the pull is the approved restart, so it is not raised again in Review). Otherwise continue.
|
|
28
28
|
7. After a pull (step 5 or 6), run `brief` again, as in step 2. `pulledLocks` present (a pulled commit changed those locked tests) → before the implementer runs, 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 Steps.
|
|
29
29
|
|
|
30
30
|
## Steps
|
|
31
31
|
|
|
32
|
-
1. `node "{{LW_HOME}}/hooks/lw.mjs" stage build` (it updates the task file header `stage:` line; if it prints `"header": false`,
|
|
32
|
+
1. `node "{{LW_HOME}}/hooks/lw.mjs" stage build` (it updates the task file header `stage:` line; if it prints `"header": false`, run `node "{{LW_HOME}}/hooks/lw.mjs" set stage build`).
|
|
33
33
|
2. Now spawn the `loopwright-implementer` subagent and wait for its result. On Claude Code pass `effort` = the `effort` from `brief` on the spawn; if `brief` has no `effort` (it warns on stderr) or the spawn rejects `effort`, spawn without it (the agent file's effort applies). The prompt contains only:
|
|
34
34
|
- the absolute task file path (`<lw>/<task>`);
|
|
35
35
|
- large tier: "Implement slice S<n> only.";
|
|
@@ -37,8 +37,8 @@ Before your first message to the user, read `{{LW_HOME}}/prompts/user-messages.m
|
|
|
37
37
|
- fix round: the findings to fix, verbatim from Review (location, expectation, proof).
|
|
38
38
|
Never paste chat history, your own summary of the decisions, or design ideas; the task file is the source.
|
|
39
39
|
3. Keep the implementer report verbatim in this conversation; a two-pass review needs it.
|
|
40
|
-
Fix task: write the report's `Root cause:` line to `## Root cause`
|
|
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 (
|
|
40
|
+
Fix task: write the report's `Root cause:` line to `## Root cause` (`node "{{LW_HOME}}/hooks/lw.mjs" section "Root cause" --set`, the text on stdin through a quoted heredoc). A root cause that differs from the plan's hypothesis is a `Deviation`, handled in step 4.
|
|
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 (record it as a decision the way Going back does, below), 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`, run `set stage <plan|test>` and, for plan, `set plan draft`), record the decision with `node "{{LW_HOME}}/hooks/lw.mjs" add decision --tag asked <<'LW_TEXT'`, the decision on the next line, then `LW_TEXT`, and continue with `/loopwright-plan` or `/loopwright-test` as the target says.
|
|
42
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.
|
|
43
43
|
|
|
44
44
|
## Rules
|