next-issue 6.3.7 → 6.5.0
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 +3 -3
- package/dist/hunt.mjs +12 -8
- package/dist/prompts.mjs +7 -6
- package/dist/watch.mjs +32 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -522,14 +522,14 @@ The watch stops:
|
|
|
522
522
|
|
|
523
523
|
## Hunt for bugs
|
|
524
524
|
|
|
525
|
-
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, have no open blocker and are not running. 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. The hunter:
|
|
525
|
+
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, have no open blocker and are not running. 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:
|
|
526
526
|
|
|
527
527
|
- works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
|
|
528
528
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
529
|
-
- files
|
|
529
|
+
- 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;
|
|
530
530
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
|
531
531
|
|
|
532
|
-
The hunter ends its reply with
|
|
532
|
+
With `huntCap` at 1 and no ready issue, a hunt files at most one issue. The hunter ends its reply with one `issue:` line for each issue it filed, or one `issue: none` line, and the run log holds one `hunt.issue` event with the `url` for each, or one with `none`. A hunt that fails writes a `hunt.error` event and the watch goes on. The hunter then waits before the next hunt, with a `hunt.wait` event and the same back-off, so a failure, or a hunt that files nothing, that repeats waits 1, 2, 3, 5, 10, then 10 minutes, and the back-off goes back to 1 minute after a hunt that files at least one issue. The next pass claims the new issues 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.
|
|
533
533
|
|
|
534
534
|
## Worker
|
|
535
535
|
|
package/dist/hunt.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { huntPrompt } from './prompts.mjs';
|
|
|
10
10
|
import { skipReason } from './skip.mjs';
|
|
11
11
|
import { WORKTREE_DIR } from './worktree.mjs';
|
|
12
12
|
export const HUNT_FILE = 'next-issue.hunt.md';
|
|
13
|
-
const FILED = /^issue:\s*(\S+)\s*$/
|
|
13
|
+
const FILED = /^issue:\s*(\S+)\s*$/gm;
|
|
14
14
|
export async function huntWorktree(repo, base, remote) {
|
|
15
15
|
const path = join(repo.root, WORKTREE_DIR, 'hunt');
|
|
16
16
|
const target = remoteRef(remote, base);
|
|
@@ -24,7 +24,7 @@ export async function huntWorktree(repo, base, remote) {
|
|
|
24
24
|
}
|
|
25
25
|
return path;
|
|
26
26
|
}
|
|
27
|
-
export async function hunt(context) {
|
|
27
|
+
export async function hunt(context, count) {
|
|
28
28
|
const { repo, config, base, recorder, ports } = context;
|
|
29
29
|
return recorder.step('hunt', {}, async () => {
|
|
30
30
|
const cwd = await oneAtATime(repo.root, () => ports.huntWorktree(repo, base, config.remote));
|
|
@@ -33,13 +33,17 @@ export async function hunt(context) {
|
|
|
33
33
|
const result = await ports.runAgent(recorder, {
|
|
34
34
|
name: 'hunter',
|
|
35
35
|
cwd,
|
|
36
|
-
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt),
|
|
36
|
+
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt, count),
|
|
37
37
|
profile: REVIEWING,
|
|
38
38
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
39
39
|
});
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const urls = [...result.text.matchAll(FILED)]
|
|
41
|
+
.map((match) => match[1])
|
|
42
|
+
.filter((url) => /^https?:\/\//.test(url));
|
|
43
|
+
for (const url of urls.length === 0 ? ['none'] : urls) {
|
|
44
|
+
recorder.event('hunt.issue', { url }, 'quiet');
|
|
45
|
+
}
|
|
46
|
+
return urls.length > 0;
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
49
|
export function hunter(context) {
|
|
@@ -54,10 +58,10 @@ export function hunter(context) {
|
|
|
54
58
|
const blockers = await Promise.all(open.map((issue) => ports.openBlockers(repo, issue.number)));
|
|
55
59
|
return open.filter((_issue, index) => blockers[index].length === 0);
|
|
56
60
|
},
|
|
57
|
-
hunt: async () => {
|
|
61
|
+
hunt: async (count) => {
|
|
58
62
|
hunting = true;
|
|
59
63
|
try {
|
|
60
|
-
return await hunt(context);
|
|
64
|
+
return await hunt(context, count);
|
|
61
65
|
}
|
|
62
66
|
catch {
|
|
63
67
|
return false;
|
package/dist/prompts.mjs
CHANGED
|
@@ -163,24 +163,25 @@ const HUNT_DEFAULT = [
|
|
|
163
163
|
'Read the whole repository and look for bugs: wrong results, unhandled errors, races, security holes and documentation that contradicts the code.',
|
|
164
164
|
'Prove each finding from the code. A guess is not a finding.',
|
|
165
165
|
].join('\n');
|
|
166
|
-
export function huntPrompt(instructions, ready, source) {
|
|
166
|
+
export function huntPrompt(instructions, ready, source, count) {
|
|
167
|
+
const issues = count === 1 ? '1 issue' : `${count} issues`;
|
|
167
168
|
const kept = instructions?.trim() ?? '';
|
|
168
169
|
const label = [ready, source]
|
|
169
170
|
.filter((name) => name !== '')
|
|
170
171
|
.map((name) => ` --label "${name}"`)
|
|
171
172
|
.join('');
|
|
172
173
|
return paragraphs([
|
|
173
|
-
|
|
174
|
+
`You are the hunter. Find the most serious problems in this repository and file up to ${issues} for them.`,
|
|
174
175
|
`## Instructions\n${kept === '' ? HUNT_DEFAULT : kept}`,
|
|
175
176
|
'## Rules',
|
|
176
177
|
[
|
|
177
178
|
'Run no test suite and no build. Change no file. Do not commit or push.',
|
|
178
|
-
|
|
179
|
-
'Before you file
|
|
180
|
-
`File
|
|
179
|
+
`File up to ${issues}, your most serious findings first. File nothing when you find no real problem.`,
|
|
180
|
+
'Before you file an issue, search the open and closed issues for a duplicate, for example with `gh issue list --state all --search "<words>"`. Do not file a finding when a duplicate exists.',
|
|
181
|
+
`File each issue with \`gh issue create${label} --title "<conventional commit subject>" --body-file -\`.`,
|
|
181
182
|
`The body holds these sections as \`##\` headings, in this order: ${ISSUE_SECTIONS.map((section) => `\`## ${section}\``).join(', ')}.`,
|
|
182
183
|
'Give the file and line of each piece of evidence. Leave the Open questions section empty.',
|
|
183
|
-
'End your final message with one line in the form `issue: <url
|
|
184
|
+
'End your final message with one line in the form `issue: <url>` for each issue you filed, or one `issue: none` line when you filed nothing.',
|
|
184
185
|
].join('\n'),
|
|
185
186
|
]);
|
|
186
187
|
}
|
package/dist/watch.mjs
CHANGED
|
@@ -3,14 +3,16 @@ const BACK_OFF_MINUTES = [1, 2, 3, 5, 10];
|
|
|
3
3
|
export async function watchIssues(args, watch) {
|
|
4
4
|
const running = new Set();
|
|
5
5
|
const ended = new AbortController();
|
|
6
|
+
const claims = claimAlarm();
|
|
6
7
|
const hunting = watch.hunter === undefined
|
|
7
8
|
? undefined
|
|
8
|
-
: huntIssues(watch.hunter, running, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
9
|
+
: huntIssues(watch.hunter, running, claims, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
9
10
|
try {
|
|
10
11
|
return await watchPasses(args, {
|
|
11
12
|
...watch,
|
|
12
13
|
process: async (issue) => {
|
|
13
14
|
running.add(issue.number);
|
|
15
|
+
claims.ring();
|
|
14
16
|
try {
|
|
15
17
|
return await watch.process(issue);
|
|
16
18
|
}
|
|
@@ -25,19 +27,44 @@ export async function watchIssues(args, watch) {
|
|
|
25
27
|
await hunting;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
function claimAlarm() {
|
|
31
|
+
let rung = false;
|
|
32
|
+
let controller = new AbortController();
|
|
33
|
+
return {
|
|
34
|
+
ring: () => {
|
|
35
|
+
rung = true;
|
|
36
|
+
controller.abort();
|
|
37
|
+
},
|
|
38
|
+
take: () => {
|
|
39
|
+
const was = rung;
|
|
40
|
+
rung = false;
|
|
41
|
+
return was;
|
|
42
|
+
},
|
|
43
|
+
signal: () => {
|
|
44
|
+
controller = new AbortController();
|
|
45
|
+
return controller.signal;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function huntIssues(hunter, running, claims, stopped, signal) {
|
|
29
50
|
let step = 0;
|
|
30
51
|
while (!stopped()) {
|
|
31
52
|
const ready = await hunter.ready().catch(() => undefined);
|
|
53
|
+
claims.take();
|
|
32
54
|
const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
|
|
33
55
|
if (waiting !== undefined && waiting < hunter.cap) {
|
|
34
|
-
if (await hunter.hunt()) {
|
|
56
|
+
if (await hunter.hunt(hunter.cap - waiting)) {
|
|
35
57
|
step = 0;
|
|
36
58
|
continue;
|
|
37
59
|
}
|
|
38
60
|
}
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
if (claims.take() || stopped()) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, claims.signal()]));
|
|
65
|
+
if (!claims.take()) {
|
|
66
|
+
step += 1;
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
}
|
|
43
70
|
async function watchPasses(args, watch) {
|