next-issue 6.6.21 → 6.6.22

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
@@ -74,6 +74,10 @@ the run handles one issue. For each issue:
74
74
  hook stops a commit, the agent that made the change gets the hook output,
75
75
  fixes it, and the harness commits again. A `commit:` line in the reply of
76
76
  the agent replaces the subject, so a hook that rejects the subject can pass.
77
+ The harness drops each GitHub closing keyword (`close`, `closes`, `closed`,
78
+ `fix`, `fixes`, `fixed`, `resolve`, `resolves`, `resolved`) that names an
79
+ issue from the subject, so a push to the base never closes an issue: the
80
+ issue closes only after its checks pass.
77
81
  The budget is `maxCommitFixes`. Any other git failure in the commit stops
78
82
  the run with an error. An implementer that makes no change hands the issue
79
83
  to a person, unless the branch is already ahead of the base, for example
@@ -82,7 +86,10 @@ the run handles one issue. For each issue:
82
86
  5. Let the reviewer agent judge the diff, at most `diffMaxChars` of it. The
83
87
  reviewer reads files and runs commands in the worktree, so it can prove a
84
88
  finding with the tests or the type check. The harness then throws away every
85
- change that the reviewer left, so no such change can reach a later commit.
89
+ change that the reviewer left in the worktree, so no such change can reach a
90
+ later commit. When the reviewer left another branch or a detached `HEAD`
91
+ checked out, the harness checks out the issue branch again at its commit
92
+ from before the review.
86
93
  The first reviewer also gets the reply of the implementer, and raises a
87
94
  finding when a behaviour change has no failing run of its test. A later
88
95
  reviewer gets the reply of the last review fixer instead, who quotes the
@@ -248,8 +255,9 @@ in a process group of their own, so a press reaches only the harness.
248
255
  The harness runs all git and `gh` commands itself. The commit holds all the
249
256
  changes in the worktree, so a setup command that writes a file that git does
250
257
  not ignore puts that file in the commit. The reviewer is the one agent whose
251
- changes never get that far: the harness discards them, and undoes any commit
252
- that the reviewer made, before it reads the verdict.
258
+ changes never get that far: the harness discards them, undoes any commit
259
+ that the reviewer made on the issue branch and checks that branch out again,
260
+ before it reads the verdict.
253
261
 
254
262
  ## Safety
255
263
 
@@ -10,6 +10,16 @@ export function parseResolved(text) {
10
10
  const note = lastMatch(text, /^resolved:[^\S\r\n]*(.+)$/gim);
11
11
  return note === undefined || PLACEHOLDERS.has(note.toLowerCase()) ? undefined : note;
12
12
  }
13
+ const CLOSING_REFERENCE = /(\s*[,;]?\s*(?:and\s+)?)\b(close[sd]?|fix(?:e[sd])?|resolve[sd]?)(\s*:\s*|\s+)(?:[\w.-]+\/[\w.-]+#\d+|#\d+|https?:\/\/\S+\/(?:issues|pull)\/\d+)/gi;
14
+ export function withoutClosingReferences(subject, fallback) {
15
+ const cleaned = subject
16
+ .replace(CLOSING_REFERENCE, (_match, _lead, keyword, separator, offset) => offset === 0 && separator.includes(':') ? `${keyword}: ` : '')
17
+ .replace(/\(\s*\)|\[\s*\]/g, '')
18
+ .replace(/\s+/g, ' ')
19
+ .replace(/[\s,;:]+$/, '')
20
+ .trim();
21
+ return cleaned || fallback;
22
+ }
13
23
  export function parseCommitSubject(text, fallback) {
14
24
  const subject = lastMatch(text, /^commit:\s*(.+)$/gim)
15
25
  ?.replace(/^`+|`+$/g, '')
package/dist/fix.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { parseCommitSubject, parseResolved, parseUnrelated } from './agent-reply.mjs';
1
+ import { parseCommitSubject, parseResolved, parseUnrelated, withoutClosingReferences, } 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';
5
5
  import { HookError } from './git-commit.mjs';
6
6
  import { escalateAndFinish } from './handover.mjs';
7
- import { runRole } from './job.mjs';
7
+ import { fallbackTitle, runRole } from './job.mjs';
8
8
  import { fixPrompt, hookPrompt } from './prompts.mjs';
9
9
  import { writeState } from './state.mjs';
10
10
  import { keepTail } from './text.mjs';
@@ -65,6 +65,7 @@ export async function commitWork(job, before, subject, role, commit) {
65
65
  const { ports } = context;
66
66
  const commitChanges = commit ?? ports.commitAll;
67
67
  for (;;) {
68
+ subject = withoutClosingReferences(subject, fallbackTitle(issue));
68
69
  try {
69
70
  if (await commitChanges(worktree, `${subject}\n\nRefs #${issue.number}`)) {
70
71
  log.event('commit', { subject });
package/dist/git.mjs CHANGED
@@ -37,10 +37,14 @@ export async function isDirty(cwd) {
37
37
  export async function diff(cwd, base, remote) {
38
38
  return git(cwd, ['diff', `${remoteRef(remote, base)}...HEAD`]);
39
39
  }
40
- export async function discardChanges(cwd, target) {
41
- if (!(await isDirty(cwd)) && (await revision(cwd)) === target) {
40
+ export async function discardChanges(cwd, target, branch) {
41
+ const moved = branch !== undefined && (await currentBranch(cwd)) !== branch;
42
+ if (!moved && !(await isDirty(cwd)) && (await revision(cwd)) === target) {
42
43
  return false;
43
44
  }
45
+ if (moved) {
46
+ await git(cwd, ['checkout', '--force', '-B', branch, target]);
47
+ }
44
48
  await resetHard(cwd, target);
45
49
  return true;
46
50
  }
package/dist/prompts.mjs CHANGED
@@ -90,7 +90,7 @@ export function reviewPrompt(issue, comments, diff, earlier, reply) {
90
90
  `## Reply of the ${role}\n${reply ?? '(no reply)'}`,
91
91
  '## Rules',
92
92
  'Read files and run commands to prove what you say: the tests, the type check or the linter.',
93
- 'The worktree is ready to use. Do not change a file. Do not write with git or gh.',
93
+ 'The worktree is ready to use. Do not change a file. Do not write with git or gh, and do not check out another commit or branch.',
94
94
  'The harness discards each change that you make, so a change is only lost work.',
95
95
  reviewScope(earlier),
96
96
  'Mark a finding blocking only for a wrong result, a missing part of the issue, a regression or a broken convention.',
package/dist/review.mjs CHANGED
@@ -62,7 +62,7 @@ async function runReviewer(job, earlier) {
62
62
  };
63
63
  const before = await ports.revision(worktree);
64
64
  const review = await log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier, earlier.length === 0 ? state.implementerReply : state.fixerReply), REVIEWING));
65
- if (await ports.discardChanges(worktree, before)) {
65
+ if (await ports.discardChanges(worktree, before, job.branch)) {
66
66
  log.event('review.discard', { round: state.reviewRounds }, 'quiet');
67
67
  }
68
68
  return review.text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.21",
3
+ "version": "6.6.22",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",