next-issue 6.3.0 → 6.3.2

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
@@ -126,7 +126,9 @@ the run handles one issue. For each issue:
126
126
  fail again, the fixer gets their logs from the check budget, and its fix lands
127
127
  the same way. When the fixer cannot fix them, its fix cannot land, or the
128
128
  budget runs out, the harness reverts every commit of the change on the
129
- base branch, pushes the revert and hands the issue to a person. A resume
129
+ base branch, pushes the revert and hands the issue to a person. A revert
130
+ push that the remote refuses, for example because the base moved, makes
131
+ the revert again on the new base, three times at most. A resume
130
132
  that stopped while the checks of a landed commit ran waits for them
131
133
  again, even when more commits landed on the base since, and a fix that
132
134
  was committed but not landed lands first. A problem that the reviewer
@@ -137,7 +139,11 @@ the run handles one issue. For each issue:
137
139
  and into the next round, where it answers every finding of its own
138
140
  round, so the reviewer withdraws them all or repeats them all. With only
139
141
  some findings wrong, the fixer fixes the correct ones, and the next round
140
- holds the rest.
142
+ holds the rest. A fixer that settles every finding with no code change,
143
+ for example by showing a failing test run, changes nothing and ends with a
144
+ `resolved:` line instead. The note goes on the issue and into the next
145
+ round in the same way, and a change it leaves behind is handled as for a
146
+ dispute.
141
147
 
142
148
  ## Issue format
143
149
 
@@ -157,23 +163,24 @@ The harness hands the issue to a person, with the `status:needs-human` label,
157
163
  and comments the reason on the issue, when:
158
164
 
159
165
  - the check budget or the review budget runs out. A finding that the reviewer
160
- repeats, even one that the fixer disputed, goes back to the fixer until the
161
- review budget runs out;
166
+ repeats, even one that the fixer disputed or settled, goes back to the fixer
167
+ until the review budget runs out;
162
168
  - a fixer round adds no commit and gives no reason, so there is no progress;
163
169
  - the fixer reports that the checks fail for a reason the change did not cause,
164
170
  such as a test already broken on the base branch or one that fails only under
165
171
  load. It changes nothing and the reason reaches the issue, rather than
166
172
  the fixer spending its whole budget on a failure it cannot fix. A commit it
167
173
  makes anyway moves aside, as for a dispute of the findings;
168
- - a fixer disputes the findings and leaves a change behind, either in the
169
- worktree or in a commit of its own. A dispute carries a reason, not a diff,
170
- so the harness throws none of it away: an unclean worktree stays on the
171
- disk, and a commit of the fixer moves to a new local
172
- `<n>-dispute-<commit>` branch, so the `<n>` branch keeps only what will land. The worktree drops the change of that commit, unless the fixer
173
- edited the worktree after the commit: then the worktree keeps both and stays
174
- on the disk. Neither lands. The issue holds the reason of the dispute, and the change is on the machine that ran
175
- the harness. The `<n>-dispute-<commit>` branches go away with the `<n>`
176
- branch when the issue is done;
174
+ - a fixer disputes or settles the findings and leaves a change behind, either
175
+ in the worktree or in a commit of its own. A dispute carries a reason, not a
176
+ diff, so the harness throws none of it away: an unclean worktree stays on
177
+ the disk, and a commit of the fixer moves to a new local
178
+ `<n>-dispute-<commit>` branch, so the `<n>` branch keeps only what will
179
+ land. The worktree drops the change of that commit, unless the fixer edited
180
+ the worktree after the commit: then the worktree keeps both and stays on the
181
+ disk. Neither lands. The issue holds the reason of the dispute, and the
182
+ change is on the machine that ran the harness. The `<n>-dispute-<commit>`
183
+ branches go away with the `<n>` branch when the issue is done;
177
184
  - the reviewer gives no verdict, or the checks do not finish in time;
178
185
  - the push to the base branch fails three times;
179
186
  - the checks on the base branch fail and the fixer cannot fix them, or they
@@ -191,13 +198,13 @@ its own disputes next to them. From round two, the reviewer judges only the
191
198
  earlier findings and any regression.
192
199
 
193
200
  Each agent that writes to the issue names itself in the first line of the
194
- comment: `### Review: approved`, `### Review: changes requested` and
195
- `### Fixer: no change`. The account is the same for all of them, so the heading,
196
- not the author, tells them apart. The agents get no comment that starts with
197
- one of these headings or with `next-issue needs help:`, so a comment of an
198
- agent never returns to a prompt: the dispute of the fixer reaches the reviewer
199
- through the state file. The one
200
- exception is the answer to a hand-over, see
201
+ comment: `### Review: approved`, `### Review: changes requested`,
202
+ `### Fixer: no change` and `### Fixer: settled with no change`. The account is
203
+ the same for all of them, so the heading, not the author, tells them apart.
204
+ The agents get no comment that starts with one of these headings or with
205
+ `next-issue needs help:`, so a comment of an agent never returns to a
206
+ prompt: the dispute of the fixer reaches the reviewer through the state file.
207
+ The one exception is the answer to a hand-over, see
201
208
  [Retry an issue that waits for a person](#retry-an-issue-that-waits-for-a-person).
202
209
 
203
210
  ## Stop a run
@@ -1,8 +1,13 @@
1
1
  function lastMatch(text, pattern) {
2
2
  return [...text.matchAll(pattern)].at(-1)?.[1]?.trim();
3
3
  }
4
+ const PLACEHOLDERS = new Set(['', 'none', 'n/a', '-']);
4
5
  export function parseUnrelated(text) {
5
6
  const note = lastMatch(text, /^unrelated:\s*(.+)$/gim);
7
+ return note === undefined || PLACEHOLDERS.has(note.toLowerCase()) ? undefined : note;
8
+ }
9
+ export function parseResolved(text) {
10
+ const note = lastMatch(text, /^resolved:\s*(.+)$/gim);
6
11
  return note === '' ? undefined : note;
7
12
  }
8
13
  export function parseCommitSubject(text, fallback) {
package/dist/fix.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { parseCommitSubject, parseUnrelated } from './agent-reply.mjs';
1
+ import { parseCommitSubject, parseResolved, parseUnrelated } from './agent-reply.mjs';
2
2
  import { CODING } from './agents.mjs';
3
3
  import { budgetUse } from './budget.mjs';
4
4
  import { message } from './errors.mjs';
@@ -24,7 +24,11 @@ export async function fixRound(job, reason, detail, earlier, kind) {
24
24
  }
25
25
  const unrelated = parseUnrelated(text);
26
26
  if (unrelated !== undefined) {
27
- return disputedFix(job, before, reason, unrelated);
27
+ return disputedFix(job, before, reason, { unrelated });
28
+ }
29
+ const resolved = kind === 'review' ? parseResolved(text) : undefined;
30
+ if (resolved !== undefined) {
31
+ return disputedFix(job, before, reason, { resolved });
28
32
  }
29
33
  const subject = parseCommitSubject(text, `fix: address feedback on issue #${issue.number}`);
30
34
  if (!(await commitWork(job, before, subject, 'fixer'))) {
@@ -41,7 +45,7 @@ export async function runFixer(job, reason, detail, earlier, kind) {
41
45
  function fixBudget(job, kind) {
42
46
  return budgetUse(job, kind === 'review' ? 'reviewRounds' : 'ciFixes');
43
47
  }
44
- async function disputedFix(job, before, reason, unrelated) {
48
+ async function disputedFix(job, before, reason, note) {
45
49
  const { context, log, worktree, branch } = job;
46
50
  const { ports } = context;
47
51
  const disputed = await ports.revision(worktree);
@@ -52,8 +56,9 @@ async function disputedFix(job, before, reason, unrelated) {
52
56
  log.event('fix.aside', { branch: aside }, 'quiet');
53
57
  }
54
58
  const stray = moved || (await ports.isDirty(worktree));
55
- log.event('fix.unrelated', { reason, note: unrelated, stray }, 'quiet');
56
- return { committed: false, unrelated, stray };
59
+ const event = 'unrelated' in note ? 'fix.unrelated' : 'fix.resolved';
60
+ log.event(event, { reason, note: Object.values(note)[0], stray }, 'quiet');
61
+ return { committed: false, ...note, stray };
57
62
  }
58
63
  export async function commitWork(job, before, subject, role, commit) {
59
64
  const { context, issue, log, state, worktree } = job;
package/dist/git-land.mjs CHANGED
@@ -1,30 +1,55 @@
1
1
  import { fetchBase, git, remoteRef, revision, succeeds } from './git.mjs';
2
2
  import { commitEverything } from './git-commit.mjs';
3
+ export const PUSH_TRIES = 3;
3
4
  export async function squashOnto(cwd, base, remote, message) {
4
5
  const target = remoteRef(remote, base);
5
6
  if (await succeeds(cwd, ['diff', '--quiet', target])) {
6
7
  return false;
7
8
  }
9
+ const head = await revision(cwd);
8
10
  await git(cwd, ['reset', '--soft', target]);
9
- await commitEverything(cwd, message);
11
+ try {
12
+ await commitEverything(cwd, message);
13
+ }
14
+ catch (error) {
15
+ await git(cwd, ['reset', '--soft', head]);
16
+ throw error;
17
+ }
10
18
  return true;
11
19
  }
12
20
  export async function pushToBase(cwd, remote, base) {
13
21
  return succeeds(cwd, ['push', remote, `HEAD:refs/heads/${base}`]);
14
22
  }
15
23
  export async function revertOnBase(cwd, revert) {
24
+ const { branch } = revert;
25
+ let moved = false;
26
+ try {
27
+ moved = await pushRevert(cwd, revert);
28
+ return moved;
29
+ }
30
+ finally {
31
+ if (!moved) {
32
+ await succeeds(cwd, ['revert', '--abort']);
33
+ await git(cwd, ['checkout', '--force', branch]);
34
+ }
35
+ }
36
+ }
37
+ async function pushRevert(cwd, revert) {
16
38
  const { base, remote, branch, shas, message, reapply } = revert;
17
- const target = await fetchBase(cwd, base, remote);
18
- await git(cwd, ['checkout', '--force', '--detach', target]);
19
- await git(cwd, ['clean', '-fd']);
20
- await git(cwd, ['revert', '--no-commit', ...shas.toReversed()]);
21
- await git(cwd, ['commit', '--no-verify', '-m', message]);
22
- if (!(await pushToBase(cwd, remote, base))) {
23
- await git(cwd, ['checkout', '--force', branch]);
24
- return false;
39
+ for (let attempt = 1; attempt <= PUSH_TRIES; attempt += 1) {
40
+ const target = await fetchBase(cwd, base, remote);
41
+ await git(cwd, ['checkout', '--force', '--detach', target]);
42
+ await git(cwd, ['clean', '-fd']);
43
+ if (!(await succeeds(cwd, ['revert', '--no-commit', ...shas.toReversed()]))) {
44
+ return false;
45
+ }
46
+ await git(cwd, ['commit', '--no-verify', '-m', message]);
47
+ if (await pushToBase(cwd, remote, base)) {
48
+ await git(cwd, ['revert', '--no-commit', await revision(cwd)]);
49
+ await git(cwd, ['commit', '--no-verify', '-m', reapply]);
50
+ await git(cwd, ['checkout', '-B', branch]);
51
+ return true;
52
+ }
25
53
  }
26
- await git(cwd, ['revert', '--no-commit', await revision(cwd)]);
27
- await git(cwd, ['commit', '--no-verify', '-m', reapply]);
28
- await git(cwd, ['checkout', '-B', branch]);
29
- return true;
54
+ return false;
30
55
  }
package/dist/land.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { rebase } from './conflict.mjs';
2
2
  import { checkGate } from './gate.mjs';
3
+ import { PUSH_TRIES } from './git-land.mjs';
3
4
  import { escalateAndFinish, finishDone } from './handover.mjs';
4
5
  import { oneAtATime } from './lock.mjs';
5
6
  import { revertFailedFix } from './revert.mjs';
6
7
  import { writeState } from './state.mjs';
7
- const PUSH_TRIES = 3;
8
8
  export function landApproved(job) {
9
9
  return landing(job, () => landLoop(job));
10
10
  }
package/dist/prompts.mjs CHANGED
@@ -73,6 +73,8 @@ function reviewScope(earlier) {
73
73
  'Do not raise a new point of taste. Do not repeat a finding that is fixed.',
74
74
  'A `The fixer disputed every finding of this round` line answers all of the findings of that round, not one of them.',
75
75
  'Withdraw every finding of that round if the dispute is correct. Repeat them all if the dispute is wrong.',
76
+ 'A `The fixer settled every finding of this round with no code change` line also answers all of the findings of that round.',
77
+ 'Withdraw every finding of that round if they are settled. Repeat them all if they are not.',
76
78
  `## Earlier findings\n${earlier.join('\n')}`,
77
79
  ].join('\n');
78
80
  }
@@ -99,12 +101,16 @@ export function reviewPrompt(issue, comments, diff, earlier, reply) {
99
101
  const UNRELATED_RULE = [
100
102
  'The checks can fail for a reason this change did not cause: a test that is already broken on the base branch, one that exercises code the diff does not touch, or one that fails only under load.',
101
103
  'Establish that before you fix anything. If the failure is not yours, change nothing and end your final message with one line in the form `unrelated: <one sentence on what fails and why it is not this change>`.',
104
+ 'If you fix the cause, write no `unrelated` line.',
102
105
  'A person then reads it. Do not weaken, skip or re-record a test to make the checks pass.',
103
106
  ].join('\n');
104
107
  const DISPUTE_RULE = [
105
108
  'A finding can be wrong: it can miss a convention of this repository, ask for work that the issue does not want, or describe behaviour that the code does not have.',
106
109
  'Establish that before you change anything. If every finding is wrong, change nothing and end your final message with one line in the form `unrelated: <one sentence on why the findings are wrong>`.',
110
+ 'If you fix the findings, write no `unrelated` line.',
107
111
  'If only some of the findings are wrong, fix the correct ones and change nothing for the wrong ones. Write no `unrelated` line in that round. The next round holds only the findings that are left, and you can dispute them there.',
112
+ 'A finding can also be right and need no code change, for example when it asks for proof such as a failing test run.',
113
+ 'If every finding is settled with no code change, change nothing and end your final message with one line in the form `resolved: <how the findings were settled>`.',
108
114
  'The reviewer reads that line in the next round. Do not make a change that you hold to be wrong only to end the round.',
109
115
  ].join('\n');
110
116
  const CONFLICT_RULE = [
@@ -145,9 +151,12 @@ export function fixPrompt(issue, reason, detail, earlier, kind, reply = []) {
145
151
  export function history(rounds) {
146
152
  return rounds.map((round) => {
147
153
  const head = `Round ${round.round}:\n${round.findings}`;
148
- return round.dispute === undefined
154
+ if (round.dispute !== undefined) {
155
+ return `${head}\nThe fixer disputed every finding of this round: ${round.dispute}`;
156
+ }
157
+ return round.settled === undefined
149
158
  ? head
150
- : `${head}\nThe fixer disputed every finding of this round: ${round.dispute}`;
159
+ : `${head}\nThe fixer settled every finding of this round with no code change: ${round.settled}`;
151
160
  });
152
161
  }
153
162
  const HUNT_DEFAULT = [
package/dist/review.mjs CHANGED
@@ -70,15 +70,22 @@ async function runReviewer(job, earlier) {
70
70
  async function unfixedRound(job, fix) {
71
71
  const { context, issue, state } = job;
72
72
  const { repo, ports } = context;
73
- const note = fix.unrelated;
73
+ const note = fix.unrelated ?? fix.resolved;
74
74
  if (note === undefined) {
75
75
  return escalateAndFinish(job, 'The fixer added no commit for the review findings.', 'no fix commit');
76
76
  }
77
77
  if (fix.stray === true) {
78
- return escalateAndFinish(job, `The fixer disputed the findings and left a change behind: ${note}`, 'dispute with changes');
78
+ return escalateAndFinish(job, `The fixer ${fix.unrelated === undefined ? 'settled' : 'disputed'} the findings and left a change behind: ${note}`, 'dispute with changes');
79
+ }
80
+ const round = state.reviewLog.at(-1);
81
+ if (fix.unrelated === undefined) {
82
+ round.settled = note;
83
+ }
84
+ else {
85
+ round.dispute = note;
79
86
  }
80
- state.reviewLog.at(-1).dispute = note;
81
87
  await writeState(repo, state);
82
- await ports.commentOnIssue(repo, issue.number, `### Fixer: no change\n\n${note}`);
88
+ const heading = fix.unrelated === undefined ? 'settled with no change' : 'no change';
89
+ await ports.commentOnIssue(repo, issue.number, `### Fixer: ${heading}\n\n${note}`);
83
90
  return ROUND_CONTINUE;
84
91
  }
package/dist/state.mjs CHANGED
@@ -42,7 +42,8 @@ function isReviewRound(value) {
42
42
  return (isRecord(value) &&
43
43
  typeof value.round === 'number' &&
44
44
  typeof value.findings === 'string' &&
45
- isOptional(value.dispute, 'string'));
45
+ isOptional(value.dispute, 'string') &&
46
+ isOptional(value.settled, 'string'));
46
47
  }
47
48
  function isState(value) {
48
49
  return (isRecord(value) &&
package/dist/worktree.mjs CHANGED
@@ -14,6 +14,7 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
14
14
  const path = existing ?? worktreePath(repo, issue);
15
15
  const target = pushed ? upstream : remoteBase;
16
16
  if (existing === undefined) {
17
+ await succeeds(repo.root, ['worktree', 'remove', '--force', path]);
17
18
  const args = !start && (await hasWork(repo, branch, pushed, remoteBase))
18
19
  ? ['worktree', 'add', path, branch]
19
20
  : ['worktree', 'add', '-B', branch, path, target];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.3.0",
3
+ "version": "6.3.2",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",
@@ -42,16 +42,16 @@
42
42
  "prepublishOnly": "npm run typecheck && npm test"
43
43
  },
44
44
  "devDependencies": {
45
- "@earendil-works/pi-ai": "^1.5.0",
45
+ "@earendil-works/pi-ai": "^1.5.2",
46
46
  "@types/node": "^26.6.6",
47
47
  "@types/ws": "^8.18.2",
48
- "oxfmt": "^0.74.0",
49
- "oxlint": "^1.89.0",
48
+ "oxfmt": "^0.78.0",
49
+ "oxlint": "^1.93.0",
50
50
  "typescript": "^7.0.2"
51
51
  },
52
52
  "dependencies": {
53
- "@earendil-works/pi-coding-agent": "^1.5.0",
54
- "typebox": "^1.4.3",
55
- "ws": "^8.22.1"
53
+ "@earendil-works/pi-coding-agent": "^1.5.2",
54
+ "typebox": "^1.4.7",
55
+ "ws": "^8.23.0"
56
56
  }
57
57
  }