next-issue 5.6.0 → 5.6.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 +19 -8
- package/dist/config.mjs +11 -2
- package/dist/handover.mjs +9 -0
- package/dist/hunt.mjs +2 -1
- package/dist/interrupt.mjs +6 -0
- package/dist/labels.mjs +6 -0
- package/dist/ports.mjs +4 -2
- package/dist/prompts.mjs +5 -2
- package/dist/worktree.mjs +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,12 +114,16 @@ the run handles one issue. For each issue:
|
|
|
114
114
|
of the pushed commit on the base branch. A repository that reports no
|
|
115
115
|
check keeps asking for `checkGraceSeconds`. A pending state waits again,
|
|
116
116
|
up to `checkTimeoutMinutes`. A read that fails is tried three times. When
|
|
117
|
-
the checks pass, the harness closes the issue and sets `status:done`,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
the checks pass, the harness closes the issue and sets `status:done`,
|
|
118
|
+
fetches the remote and fast-forwards the local base branch to the landed
|
|
119
|
+
commit when that is safe, and the worktree, the local branch and the state
|
|
120
|
+
file go away. A fetch that fails or a fast-forward that is not safe leaves
|
|
121
|
+
the local base branch as it is and writes a `base.behind` event, and the
|
|
122
|
+
issue is still done. When the checks fail, the harness reruns the failed
|
|
123
|
+
jobs once with `gh run rerun <id> --failed`, records a
|
|
124
|
+
`main-checks.rerun` event, saves the rerun in the state file and waits
|
|
125
|
+
again once the runs restart. When the rerun cannot start, or the checks
|
|
126
|
+
fail again, the fixer gets their logs from the check budget, and its fix lands
|
|
123
127
|
the same way. When the fixer cannot fix them, its fix cannot land, or the
|
|
124
128
|
budget runs out, the harness reverts every commit of the change on the
|
|
125
129
|
base branch, pushes the revert and hands the issue to a person. A resume
|
|
@@ -210,6 +214,9 @@ Press `Ctrl-C` to stop the run step by step:
|
|
|
210
214
|
issue, but the issue keeps `status:in-progress` and the run writes no
|
|
211
215
|
summary.
|
|
212
216
|
|
|
217
|
+
Signals that arrive within 100 ms of the last counted one count as one press,
|
|
218
|
+
because `npx` and `npm exec` pass on a press as a second signal.
|
|
219
|
+
|
|
213
220
|
Each of the first two presses prints a line that says what happens next. The
|
|
214
221
|
agents run inside the harness, and their commands and the harness commands run
|
|
215
222
|
in a process group of their own, so a press reaches only the harness.
|
|
@@ -349,7 +356,8 @@ because no pull request is opened.
|
|
|
349
356
|
"inReview": "status:in-review",
|
|
350
357
|
"done": "status:done",
|
|
351
358
|
"needsHuman": "status:needs-human",
|
|
352
|
-
"skip": "status:blocked"
|
|
359
|
+
"skip": "status:blocked",
|
|
360
|
+
"hunt": "source:hunt"
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
```
|
|
@@ -376,6 +384,9 @@ because no pull request is opened.
|
|
|
376
384
|
| `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
|
|
377
385
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
|
378
386
|
|
|
387
|
+
The hunter adds `labels.hunt` to each issue it files, so you can tell those
|
|
388
|
+
issues apart from your own and filter them.
|
|
389
|
+
|
|
379
390
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
380
391
|
claims every open issue that no other label holds back.
|
|
381
392
|
|
|
@@ -499,7 +510,7 @@ With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the
|
|
|
499
510
|
|
|
500
511
|
- works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
|
|
501
512
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
502
|
-
- files one issue, for its most serious finding, with the `labels.ready` label and the sections of the [issue format](#issue-format), after a search for duplicates. It files nothing when it finds no real problem or a duplicate exists;
|
|
513
|
+
- files one issue, for its most serious finding, 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;
|
|
503
514
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
|
504
515
|
|
|
505
516
|
The hunter ends its reply with an `issue:` line, and the run log holds it as a `hunt.issue` event with the `url`, or `none`. A hunt that fails writes a `hunt.error` event and the watch goes on. The next pass claims the new issue like any other. At the first `Ctrl-C` the hunter stops after its current hunt, and the watch ends once the hunt and the running issues end. A first `Ctrl-C` during the watch wait tells you so while a hunt runs, and the third press stops the hunter at once. The hunter stops too when the watch ends for another reason.
|
package/dist/config.mjs
CHANGED
|
@@ -27,6 +27,7 @@ const DEFAULTS = {
|
|
|
27
27
|
done: 'status:done',
|
|
28
28
|
needsHuman: 'status:needs-human',
|
|
29
29
|
skip: 'status:blocked',
|
|
30
|
+
hunt: 'source:hunt',
|
|
30
31
|
},
|
|
31
32
|
};
|
|
32
33
|
function defaults() {
|
|
@@ -51,7 +52,15 @@ const WHOLE_FIELDS = [
|
|
|
51
52
|
['keepRunDays', 0],
|
|
52
53
|
];
|
|
53
54
|
const MODEL_ROLES = ['implementer', 'reviewer', 'fixer'];
|
|
54
|
-
const LABEL_NAMES = [
|
|
55
|
+
const LABEL_NAMES = [
|
|
56
|
+
'ready',
|
|
57
|
+
'inProgress',
|
|
58
|
+
'inReview',
|
|
59
|
+
'done',
|
|
60
|
+
'needsHuman',
|
|
61
|
+
'skip',
|
|
62
|
+
'hunt',
|
|
63
|
+
];
|
|
55
64
|
const FILE_DEFAULTS = {
|
|
56
65
|
...defaults(),
|
|
57
66
|
models: Object.fromEntries(MODEL_ROLES.map((role) => [role, null])),
|
|
@@ -134,5 +143,5 @@ function parseLabels(value, defaultLabels) {
|
|
|
134
143
|
return parsed;
|
|
135
144
|
}
|
|
136
145
|
export function managedLabels(config) {
|
|
137
|
-
return LABEL_NAMES.filter((name) => name !== 'skip').map((name) => config.labels[name]);
|
|
146
|
+
return LABEL_NAMES.filter((name) => name !== 'skip' && name !== 'hunt').map((name) => config.labels[name]);
|
|
138
147
|
}
|
package/dist/handover.mjs
CHANGED
|
@@ -15,8 +15,17 @@ export async function finishDone(job) {
|
|
|
15
15
|
const { context, issue } = job;
|
|
16
16
|
await setStatus(context, issue.number, context.config.labels.done);
|
|
17
17
|
await context.ports.closeIssue(context.repo, issue.number);
|
|
18
|
+
await updateLocalBase(job);
|
|
18
19
|
return { done: true, report: await finish(job, 'done') };
|
|
19
20
|
}
|
|
21
|
+
async function updateLocalBase(job) {
|
|
22
|
+
const { context, log } = job;
|
|
23
|
+
const { repo, ports, config, base } = context;
|
|
24
|
+
const updated = await oneAtATime(repo.root, () => ports.fastForwardBase(repo, base, config.remote)).catch(() => false);
|
|
25
|
+
if (!updated) {
|
|
26
|
+
log.event('base.behind', { base }, 'quiet');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
export function stop(job) {
|
|
21
30
|
job.log.event('issue.stop', { phase: job.state.phase }, 'quiet');
|
|
22
31
|
return jobReport(job, 'stopped');
|
package/dist/hunt.mjs
CHANGED
|
@@ -28,11 +28,12 @@ export async function hunt(context) {
|
|
|
28
28
|
const { repo, config, base, recorder, ports } = context;
|
|
29
29
|
await recorder.step('hunt', {}, async () => {
|
|
30
30
|
const cwd = await oneAtATime(repo.root, () => ports.huntWorktree(repo, base, config.remote));
|
|
31
|
+
await ports.ensureLabel(repo, config.labels.hunt);
|
|
31
32
|
const instructions = await readTextIfPresent(join(repo.root, HUNT_FILE));
|
|
32
33
|
const result = await ports.runAgent(recorder, {
|
|
33
34
|
name: 'hunter',
|
|
34
35
|
cwd,
|
|
35
|
-
prompt: huntPrompt(instructions, config.labels.ready),
|
|
36
|
+
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt),
|
|
36
37
|
profile: REVIEWING,
|
|
37
38
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
38
39
|
});
|
package/dist/interrupt.mjs
CHANGED
|
@@ -2,9 +2,15 @@ import { stopChildren } from './children.mjs';
|
|
|
2
2
|
import { wakeableSleep } from './durations.mjs';
|
|
3
3
|
export function listenForInterrupts(say) {
|
|
4
4
|
let presses = 0;
|
|
5
|
+
let lastPress = -Infinity;
|
|
5
6
|
const sleeper = {};
|
|
6
7
|
let hunting = () => false;
|
|
7
8
|
const press = () => {
|
|
9
|
+
const now = performance.now();
|
|
10
|
+
if (now - lastPress < 100) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
lastPress = now;
|
|
8
14
|
presses += 1;
|
|
9
15
|
if (presses === 1 && sleeper.wake !== undefined) {
|
|
10
16
|
say(hunting()
|
package/dist/labels.mjs
CHANGED
|
@@ -20,6 +20,12 @@ export async function setLabel(repo, kind, number, add, remove) {
|
|
|
20
20
|
await retryWithLabel(repo, args, add, error);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
export async function ensureLabel(repo, label) {
|
|
24
|
+
const created = await createUnknownLabel(repo, label);
|
|
25
|
+
if (created instanceof Error) {
|
|
26
|
+
throw created;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
23
29
|
async function retryWithLabel(repo, args, label, error) {
|
|
24
30
|
KNOWN_LABELS.delete(slug(repo));
|
|
25
31
|
const created = await createUnknownLabel(repo, label);
|
package/dist/ports.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
|
|
|
7
7
|
import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, latestSubject, push, resetToBase, revision, setAside, } from './git.mjs';
|
|
8
8
|
import { canWrite, closeIssue, commentOnIssue, issueComments, openBlockers, openIssues, reopenIssue, threadComments, viewIssue, } from './github.mjs';
|
|
9
9
|
import { huntWorktree } from './hunt.mjs';
|
|
10
|
-
import { setLabel } from './labels.mjs';
|
|
10
|
+
import { ensureLabel, setLabel } from './labels.mjs';
|
|
11
11
|
import { detectSetupCommand } from './setup.mjs';
|
|
12
|
-
import { addWorktree, findWorktree, removeWorktree } from './worktree.mjs';
|
|
12
|
+
import { addWorktree, fastForwardBase, findWorktree, removeWorktree } from './worktree.mjs';
|
|
13
13
|
async function runSetup(command, cwd, timeoutMs) {
|
|
14
14
|
return run('bash', ['-lc', command], { cwd, timeoutMs });
|
|
15
15
|
}
|
|
@@ -26,7 +26,9 @@ export const PORTS = {
|
|
|
26
26
|
diff,
|
|
27
27
|
discardChanges,
|
|
28
28
|
disputeBranches,
|
|
29
|
+
ensureLabel,
|
|
29
30
|
failedBaseLogs,
|
|
31
|
+
fastForwardBase,
|
|
30
32
|
findWorktree,
|
|
31
33
|
huntWorktree,
|
|
32
34
|
isDirty,
|
package/dist/prompts.mjs
CHANGED
|
@@ -154,9 +154,12 @@ const HUNT_DEFAULT = [
|
|
|
154
154
|
'Read the whole repository and look for bugs: wrong results, unhandled errors, races, security holes and documentation that contradicts the code.',
|
|
155
155
|
'Prove each finding from the code. A guess is not a finding.',
|
|
156
156
|
].join('\n');
|
|
157
|
-
export function huntPrompt(instructions, ready) {
|
|
157
|
+
export function huntPrompt(instructions, ready, source) {
|
|
158
158
|
const kept = instructions?.trim() ?? '';
|
|
159
|
-
const label = ready
|
|
159
|
+
const label = [ready, source]
|
|
160
|
+
.filter((name) => name !== '')
|
|
161
|
+
.map((name) => ` --label "${name}"`)
|
|
162
|
+
.join('');
|
|
160
163
|
return paragraphs([
|
|
161
164
|
'You are the hunter. Find the most serious problem in this repository and file one issue for it.',
|
|
162
165
|
`## Instructions\n${kept === '' ? HUNT_DEFAULT : kept}`,
|
package/dist/worktree.mjs
CHANGED
|
@@ -7,8 +7,7 @@ function worktreePath(repo, issue) {
|
|
|
7
7
|
export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
8
8
|
const upstream = remoteRef(remote, branch);
|
|
9
9
|
const remoteBase = remoteRef(remote, base);
|
|
10
|
-
await
|
|
11
|
-
const baseUpdated = await updateBase(repo, base, remote);
|
|
10
|
+
const baseUpdated = await fastForwardBase(repo, base, remote);
|
|
12
11
|
await git(repo.root, ['worktree', 'prune']);
|
|
13
12
|
const pushed = await hasBranch(repo, upstream, '--remotes');
|
|
14
13
|
const existing = await findWorktree(repo, branch);
|
|
@@ -38,6 +37,10 @@ async function hasBranch(repo, name, ...flags) {
|
|
|
38
37
|
const list = await git(repo.root, ['branch', '--list', ...flags, name]);
|
|
39
38
|
return list.length > 0;
|
|
40
39
|
}
|
|
40
|
+
export async function fastForwardBase(repo, base, remote) {
|
|
41
|
+
await git(repo.root, ['fetch', remote]);
|
|
42
|
+
return updateBase(repo, base, remote);
|
|
43
|
+
}
|
|
41
44
|
async function updateBase(repo, base, remote) {
|
|
42
45
|
const remoteBase = remoteRef(remote, base);
|
|
43
46
|
const args = (await currentBranch(repo.root)) === base
|