next-issue 6.6.21 → 6.6.23
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 +12 -4
- package/dist/agent-reply.mjs +10 -0
- package/dist/fix.mjs +3 -2
- package/dist/git.mjs +6 -2
- package/dist/hunt.mjs +5 -4
- package/dist/prompts.mjs +1 -1
- package/dist/review.mjs +1 -1
- package/dist/worktree.mjs +19 -0
- package/package.json +1 -1
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
|
|
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,
|
|
252
|
-
that the reviewer made
|
|
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
|
|
|
@@ -544,7 +552,7 @@ The watch stops:
|
|
|
544
552
|
|
|
545
553
|
With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the same time as the issues. Before each hunt it reads the open issues with the `labels.ready` label and counts those that are ready to claim and are not running. An issue that failed earlier in the run does not count, since the watch does not try it again. It counts a blocked issue only when each of its open blockers is in the same repository and is running or ready to claim, since those blockers can land and close; a blocker that cannot move, such as one with `labels.needsHuman`, `labels.skip` or `labels.done`, one without `labels.ready`, or one in another repository, leaves it out. It looks only at the direct blockers. It hunts only while that count is less than `huntCap`, 1 by default. Otherwise it waits and checks again, with the same back-off as the watch: 1, 2, 3, 5, 10, then 10 minutes, back to 1 minute after a hunt that files an issue. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing backs off like a failed one. When the harness claims an issue, the hunter wakes: it ends its wait at once, or skips the wait after a hunt that is going, and checks the count again. A wake keeps the back-off where it was. The hunter:
|
|
546
554
|
|
|
547
|
-
- works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and
|
|
555
|
+
- works in its own worktree at `.worktrees/hunt`, on a detached `HEAD` at the remote base branch, which the harness fetches and checks out before each hunt. A branch that the hunter checks out keeps its commits, and an issue that resumes never uses the hunt worktree as its own;
|
|
548
556
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
549
557
|
- files up to `huntCap` less that count, worked out just before the hunt, its most serious findings first, each with the `labels.ready` label, the `labels.hunt` label and the sections of the [issue format](#issue-format), after a search for duplicates. The `labels.hunt` label, `source:hunt` by default, marks the issue as one the hunter filed, and the harness creates it before the hunt when it is missing. It files nothing when it finds no real problem or a duplicate exists;
|
|
550
558
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
package/dist/agent-reply.mjs
CHANGED
|
@@ -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
|
-
|
|
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/hunt.mjs
CHANGED
|
@@ -4,20 +4,21 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
4
4
|
import { REVIEWING } from './agents.mjs';
|
|
5
5
|
import { minutesToMs } from './durations.mjs';
|
|
6
6
|
import { readTextIfPresent } from './files.mjs';
|
|
7
|
-
import { git, gitFetch, remoteRef
|
|
7
|
+
import { git, gitFetch, remoteRef } from './git.mjs';
|
|
8
8
|
import { oneAtATime } from './lock.mjs';
|
|
9
9
|
import { huntPrompt } from './prompts.mjs';
|
|
10
10
|
import { skipReason } from './skip.mjs';
|
|
11
|
-
import {
|
|
11
|
+
import { huntPath } from './worktree.mjs';
|
|
12
12
|
export const HUNT_FILE = 'next-issue.hunt.md';
|
|
13
13
|
const FILED = /^issue:\s*(\S+)\s*$/gm;
|
|
14
14
|
export async function huntWorktree(repo, base, remote) {
|
|
15
|
-
const path =
|
|
15
|
+
const path = huntPath(repo);
|
|
16
16
|
const target = remoteRef(remote, base);
|
|
17
17
|
await gitFetch(repo.root, [remote]);
|
|
18
18
|
await git(repo.root, ['worktree', 'prune']);
|
|
19
19
|
if (existsSync(join(path, '.git'))) {
|
|
20
|
-
await
|
|
20
|
+
await git(path, ['checkout', '--force', '--detach', target]);
|
|
21
|
+
await git(path, ['clean', '-fd']);
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
23
24
|
await git(repo.root, ['worktree', 'add', '--detach', path, target]);
|
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/dist/worktree.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { realpath } from 'node:fs/promises';
|
|
1
2
|
import { join } from 'node:path';
|
|
2
3
|
import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, succeeds, } from './git.mjs';
|
|
3
4
|
export const WORKTREE_DIR = '.worktrees';
|
|
5
|
+
export function huntPath(repo) {
|
|
6
|
+
return join(repo.root, WORKTREE_DIR, 'hunt');
|
|
7
|
+
}
|
|
4
8
|
function worktreePath(repo, issue) {
|
|
5
9
|
return join(repo.root, WORKTREE_DIR, String(issue));
|
|
6
10
|
}
|
|
@@ -9,6 +13,7 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
9
13
|
const remoteBase = remoteRef(remote, base);
|
|
10
14
|
const baseUpdated = await fastForwardBase(repo, base, remote);
|
|
11
15
|
await git(repo.root, ['worktree', 'prune']);
|
|
16
|
+
await releaseFromHunt(repo, branch);
|
|
12
17
|
const pushed = await hasBranch(repo, upstream, '--remotes');
|
|
13
18
|
const existing = await findWorktree(repo, branch);
|
|
14
19
|
const path = existing ?? worktreePath(repo, issue);
|
|
@@ -50,6 +55,20 @@ async function updateBase(repo, base, remote) {
|
|
|
50
55
|
return oneFetchAtATime(() => succeeds(repo.root, args));
|
|
51
56
|
}
|
|
52
57
|
export async function findWorktree(repo, branch) {
|
|
58
|
+
const path = await holder(repo, branch);
|
|
59
|
+
return path !== undefined && (await isHunt(repo, path)) ? undefined : path;
|
|
60
|
+
}
|
|
61
|
+
async function releaseFromHunt(repo, branch) {
|
|
62
|
+
const path = await holder(repo, branch);
|
|
63
|
+
if (path !== undefined && (await isHunt(repo, path))) {
|
|
64
|
+
await git(path, ['checkout', '--detach']);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function isHunt(repo, path) {
|
|
68
|
+
const real = (target) => realpath(target).catch(() => target);
|
|
69
|
+
return (await real(path)) === (await real(huntPath(repo)));
|
|
70
|
+
}
|
|
71
|
+
async function holder(repo, branch) {
|
|
53
72
|
const list = await git(repo.root, ['worktree', 'list', '--porcelain']);
|
|
54
73
|
const entry = list
|
|
55
74
|
.split('\n\n')
|