next-issue 5.5.0 → 5.6.1
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 +29 -20
- package/dist/args.mjs +1 -1
- package/dist/config.mjs +13 -2
- package/dist/hunt.mjs +32 -1
- package/dist/interrupt.mjs +14 -2
- package/dist/labels.mjs +6 -0
- package/dist/ports.mjs +2 -1
- package/dist/prompts.mjs +5 -2
- package/dist/run.mjs +4 -3
- package/dist/watch.mjs +39 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,6 +210,9 @@ Press `Ctrl-C` to stop the run step by step:
|
|
|
210
210
|
issue, but the issue keeps `status:in-progress` and the run writes no
|
|
211
211
|
summary.
|
|
212
212
|
|
|
213
|
+
Signals that arrive within 100 ms of the last counted one count as one press,
|
|
214
|
+
because `npx` and `npm exec` pass on a press as a second signal.
|
|
215
|
+
|
|
213
216
|
Each of the first two presses prints a line that says what happens next. The
|
|
214
217
|
agents run inside the harness, and their commands and the harness commands run
|
|
215
218
|
in a process group of their own, so a press reaches only the harness.
|
|
@@ -325,6 +328,7 @@ because no pull request is opened.
|
|
|
325
328
|
"remote": "origin",
|
|
326
329
|
"issueLimit": 100,
|
|
327
330
|
"concurrency": 1,
|
|
331
|
+
"huntCap": 1,
|
|
328
332
|
"maxCiFixes": 5,
|
|
329
333
|
"maxCommitFixes": 10,
|
|
330
334
|
"maxReviewRounds": 5,
|
|
@@ -348,7 +352,8 @@ because no pull request is opened.
|
|
|
348
352
|
"inReview": "status:in-review",
|
|
349
353
|
"done": "status:done",
|
|
350
354
|
"needsHuman": "status:needs-human",
|
|
351
|
-
"skip": "status:blocked"
|
|
355
|
+
"skip": "status:blocked",
|
|
356
|
+
"hunt": "source:hunt"
|
|
352
357
|
}
|
|
353
358
|
}
|
|
354
359
|
```
|
|
@@ -358,6 +363,7 @@ because no pull request is opened.
|
|
|
358
363
|
| `remote` | `origin` | The git remote for the repository and the branches |
|
|
359
364
|
| `issueLimit` | `100` | The maximum number of open issues to read. With `labels.ready` set, only issues with the ready, in-progress or in-review label count |
|
|
360
365
|
| `concurrency` | `1` | The most issues that a run handles at the same time |
|
|
366
|
+
| `huntCap` | `1` | With `--hunt`, the hunter hunts only while fewer ready issues than this wait besides the running ones |
|
|
361
367
|
| `maxCiFixes` | `5` | The budget for check fixes per issue |
|
|
362
368
|
| `maxCommitFixes` | `10` | The budget for fixes of a commit that a git hook stopped, per issue |
|
|
363
369
|
| `maxReviewRounds` | `5` | The budget for review rounds per issue |
|
|
@@ -374,6 +380,9 @@ because no pull request is opened.
|
|
|
374
380
|
| `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
|
|
375
381
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
|
376
382
|
|
|
383
|
+
The hunter adds `labels.hunt` to each issue it files, so you can tell those
|
|
384
|
+
issues apart from your own and filter them.
|
|
385
|
+
|
|
377
386
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
378
387
|
claims every open issue that no other label holds back.
|
|
379
388
|
|
|
@@ -443,22 +452,22 @@ state of an issue that a label still holds back stays as it was.
|
|
|
443
452
|
|
|
444
453
|
## Commands and options
|
|
445
454
|
|
|
446
|
-
| Argument | Effect
|
|
447
|
-
| ----------- |
|
|
448
|
-
| `init` | Write the config file with the defaults
|
|
449
|
-
| `serve` | Run the worker of this repository that pi extensions talk to, see [Worker](#worker)
|
|
450
|
-
| `stop` | Stop the worker of this repository, see [Worker](#worker)
|
|
451
|
-
| `logs` | Show the latest run log and follow it, see [Observability](#observability)
|
|
452
|
-
| `--force` | Replace an existing config file, with `init`
|
|
453
|
-
| `--once` | Stop after the first handled issue
|
|
454
|
-
| `--max <n>` | Handle at most n issues
|
|
455
|
-
| `--watch` | Keep running, and read the open issues again after each pass
|
|
456
|
-
| `--hunt` | Hunt the repository for
|
|
457
|
-
| `--reset` | Drop the saved budgets and findings, and keep the rest of the state
|
|
458
|
-
| `--json` | Print the machine summary instead of the text one, or the raw JSON lines with `logs`
|
|
459
|
-
| `--verbose` | Show every command and all agent output
|
|
460
|
-
| `--quiet` | Show only the milestones and the summary
|
|
461
|
-
| `--help` | Show the option list
|
|
455
|
+
| Argument | Effect |
|
|
456
|
+
| ----------- | -------------------------------------------------------------------------------------- |
|
|
457
|
+
| `init` | Write the config file with the defaults |
|
|
458
|
+
| `serve` | Run the worker of this repository that pi extensions talk to, see [Worker](#worker) |
|
|
459
|
+
| `stop` | Stop the worker of this repository, see [Worker](#worker) |
|
|
460
|
+
| `logs` | Show the latest run log and follow it, see [Observability](#observability) |
|
|
461
|
+
| `--force` | Replace an existing config file, with `init` |
|
|
462
|
+
| `--once` | Stop after the first handled issue |
|
|
463
|
+
| `--max <n>` | Handle at most n issues |
|
|
464
|
+
| `--watch` | Keep running, and read the open issues again after each pass |
|
|
465
|
+
| `--hunt` | Hunt the repository for bugs alongside the issues, see [Hunt for bugs](#hunt-for-bugs) |
|
|
466
|
+
| `--reset` | Drop the saved budgets and findings, and keep the rest of the state |
|
|
467
|
+
| `--json` | Print the machine summary instead of the text one, or the raw JSON lines with `logs` |
|
|
468
|
+
| `--verbose` | Show every command and all agent output |
|
|
469
|
+
| `--quiet` | Show only the milestones and the summary |
|
|
470
|
+
| `--help` | Show the option list |
|
|
462
471
|
|
|
463
472
|
The exit code is 1 when an issue needs a person or failed, and 0 when it does
|
|
464
473
|
not, so a cron job or a CI step can read the result of the run.
|
|
@@ -493,14 +502,14 @@ The watch stops:
|
|
|
493
502
|
|
|
494
503
|
## Hunt for bugs
|
|
495
504
|
|
|
496
|
-
With `--hunt`, which turns on `--watch`, the harness runs a hunter agent
|
|
505
|
+
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. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing does not stop the next one. The hunter:
|
|
497
506
|
|
|
498
507
|
- works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
|
|
499
508
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
500
|
-
- 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;
|
|
509
|
+
- 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;
|
|
501
510
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
|
502
511
|
|
|
503
|
-
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.
|
|
512
|
+
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.
|
|
504
513
|
|
|
505
514
|
## Worker
|
|
506
515
|
|
package/dist/args.mjs
CHANGED
|
@@ -22,7 +22,7 @@ export const USAGE = `next-issue [command] [options]
|
|
|
22
22
|
--once stop after the first handled issue
|
|
23
23
|
--max <n> handle at most n issues
|
|
24
24
|
--watch keep running and read the issues again after each pass
|
|
25
|
-
--hunt hunt the repository for
|
|
25
|
+
--hunt hunt the repository for bugs and file issues alongside the issues, turns on --watch
|
|
26
26
|
--reset drop the saved budgets and findings first
|
|
27
27
|
--json print the machine summary instead of the text one, or raw lines with logs
|
|
28
28
|
--force replace an existing config file, with init
|
package/dist/config.mjs
CHANGED
|
@@ -6,6 +6,7 @@ const DEFAULTS = {
|
|
|
6
6
|
remote: 'origin',
|
|
7
7
|
issueLimit: 100,
|
|
8
8
|
concurrency: 1,
|
|
9
|
+
huntCap: 1,
|
|
9
10
|
maxCiFixes: 5,
|
|
10
11
|
maxCommitFixes: 10,
|
|
11
12
|
maxReviewRounds: 5,
|
|
@@ -26,6 +27,7 @@ const DEFAULTS = {
|
|
|
26
27
|
done: 'status:done',
|
|
27
28
|
needsHuman: 'status:needs-human',
|
|
28
29
|
skip: 'status:blocked',
|
|
30
|
+
hunt: 'source:hunt',
|
|
29
31
|
},
|
|
30
32
|
};
|
|
31
33
|
function defaults() {
|
|
@@ -35,6 +37,7 @@ const FIELDS = [...Object.keys(DEFAULTS), 'setupCommand'];
|
|
|
35
37
|
const WHOLE_FIELDS = [
|
|
36
38
|
['issueLimit', 1],
|
|
37
39
|
['concurrency', 1],
|
|
40
|
+
['huntCap', 1],
|
|
38
41
|
['maxCiFixes', 0],
|
|
39
42
|
['maxCommitFixes', 0],
|
|
40
43
|
['maxReviewRounds', 1],
|
|
@@ -49,7 +52,15 @@ const WHOLE_FIELDS = [
|
|
|
49
52
|
['keepRunDays', 0],
|
|
50
53
|
];
|
|
51
54
|
const MODEL_ROLES = ['implementer', 'reviewer', 'fixer'];
|
|
52
|
-
const LABEL_NAMES = [
|
|
55
|
+
const LABEL_NAMES = [
|
|
56
|
+
'ready',
|
|
57
|
+
'inProgress',
|
|
58
|
+
'inReview',
|
|
59
|
+
'done',
|
|
60
|
+
'needsHuman',
|
|
61
|
+
'skip',
|
|
62
|
+
'hunt',
|
|
63
|
+
];
|
|
53
64
|
const FILE_DEFAULTS = {
|
|
54
65
|
...defaults(),
|
|
55
66
|
models: Object.fromEntries(MODEL_ROLES.map((role) => [role, null])),
|
|
@@ -132,5 +143,5 @@ function parseLabels(value, defaultLabels) {
|
|
|
132
143
|
return parsed;
|
|
133
144
|
}
|
|
134
145
|
export function managedLabels(config) {
|
|
135
|
-
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]);
|
|
136
147
|
}
|
package/dist/hunt.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
4
|
import { REVIEWING } from './agents.mjs';
|
|
4
5
|
import { minutesToMs } from './durations.mjs';
|
|
5
6
|
import { readTextIfPresent } from './files.mjs';
|
|
6
7
|
import { git, remoteRef, resetHard } from './git.mjs';
|
|
7
8
|
import { oneAtATime } from './lock.mjs';
|
|
8
9
|
import { huntPrompt } from './prompts.mjs';
|
|
10
|
+
import { skipReason } from './skip.mjs';
|
|
9
11
|
import { WORKTREE_DIR } from './worktree.mjs';
|
|
10
12
|
export const HUNT_FILE = 'next-issue.hunt.md';
|
|
11
13
|
const FILED = /^issue:\s*(\S+)\s*$/m;
|
|
@@ -26,14 +28,43 @@ export async function hunt(context) {
|
|
|
26
28
|
const { repo, config, base, recorder, ports } = context;
|
|
27
29
|
await recorder.step('hunt', {}, async () => {
|
|
28
30
|
const cwd = await oneAtATime(repo.root, () => ports.huntWorktree(repo, base, config.remote));
|
|
31
|
+
await ports.ensureLabel(repo, config.labels.hunt);
|
|
29
32
|
const instructions = await readTextIfPresent(join(repo.root, HUNT_FILE));
|
|
30
33
|
const result = await ports.runAgent(recorder, {
|
|
31
34
|
name: 'hunter',
|
|
32
35
|
cwd,
|
|
33
|
-
prompt: huntPrompt(instructions, config.labels.ready),
|
|
36
|
+
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt),
|
|
34
37
|
profile: REVIEWING,
|
|
35
38
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
36
39
|
});
|
|
37
40
|
recorder.event('hunt.issue', { url: FILED.exec(result.text)?.[1] ?? 'none' }, 'quiet');
|
|
38
41
|
});
|
|
39
42
|
}
|
|
43
|
+
export function hunter(context) {
|
|
44
|
+
const { repo, config, recorder, ports } = context;
|
|
45
|
+
const { ready } = config.labels;
|
|
46
|
+
const labels = ready.length === 0 ? [] : [ready];
|
|
47
|
+
let hunting = false;
|
|
48
|
+
return {
|
|
49
|
+
cap: config.huntCap,
|
|
50
|
+
ready: async () => {
|
|
51
|
+
const open = (await ports.openIssues(repo, config.issueLimit, labels)).filter((issue) => skipReason(issue, config, false) === undefined);
|
|
52
|
+
const blockers = await Promise.all(open.map((issue) => ports.openBlockers(repo, issue.number)));
|
|
53
|
+
return open.filter((_issue, index) => blockers[index].length === 0);
|
|
54
|
+
},
|
|
55
|
+
hunt: async () => {
|
|
56
|
+
hunting = true;
|
|
57
|
+
try {
|
|
58
|
+
await hunt(context).catch(() => undefined);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
hunting = false;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
wait: (minutes, signal) => {
|
|
65
|
+
recorder.event('hunt.wait', { minutes });
|
|
66
|
+
return delay(minutesToMs(minutes), undefined, { signal }).catch(() => undefined);
|
|
67
|
+
},
|
|
68
|
+
busy: () => hunting,
|
|
69
|
+
};
|
|
70
|
+
}
|
package/dist/interrupt.mjs
CHANGED
|
@@ -2,11 +2,20 @@ 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 = {};
|
|
7
|
+
let hunting = () => false;
|
|
6
8
|
const press = () => {
|
|
9
|
+
const now = performance.now();
|
|
10
|
+
if (now - lastPress < 100) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
lastPress = now;
|
|
7
14
|
presses += 1;
|
|
8
15
|
if (presses === 1 && sleeper.wake !== undefined) {
|
|
9
|
-
say(
|
|
16
|
+
say(hunting()
|
|
17
|
+
? 'Stopping after the current hunt. Press Ctrl-C twice more to stop now.'
|
|
18
|
+
: 'Stopping now.');
|
|
10
19
|
sleeper.wake();
|
|
11
20
|
}
|
|
12
21
|
else if (presses === 1) {
|
|
@@ -24,6 +33,9 @@ export function listenForInterrupts(say) {
|
|
|
24
33
|
return {
|
|
25
34
|
afterIssue: () => presses >= 1,
|
|
26
35
|
afterRound: () => presses >= 2,
|
|
27
|
-
sleep: (ms
|
|
36
|
+
sleep: (ms, busy = () => false) => {
|
|
37
|
+
hunting = busy;
|
|
38
|
+
return wakeableSleep(sleeper, ms, presses >= 1);
|
|
39
|
+
},
|
|
28
40
|
};
|
|
29
41
|
}
|
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,7 +7,7 @@ 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
12
|
import { addWorktree, findWorktree, removeWorktree } from './worktree.mjs';
|
|
13
13
|
async function runSetup(command, cwd, timeoutMs) {
|
|
@@ -26,6 +26,7 @@ export const PORTS = {
|
|
|
26
26
|
diff,
|
|
27
27
|
discardChanges,
|
|
28
28
|
disputeBranches,
|
|
29
|
+
ensureLabel,
|
|
29
30
|
failedBaseLogs,
|
|
30
31
|
findWorktree,
|
|
31
32
|
huntWorktree,
|
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/run.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { writeJson } from './files.mjs';
|
|
|
7
7
|
import { slug } from './gh.mjs';
|
|
8
8
|
import { detectRepo } from './git.mjs';
|
|
9
9
|
import { defaultBranch } from './github.mjs';
|
|
10
|
-
import {
|
|
10
|
+
import { hunter } from './hunt.mjs';
|
|
11
11
|
import { exitCode, runIssues } from './loop.mjs';
|
|
12
12
|
import { Recorder } from './observe.mjs';
|
|
13
13
|
import { pendingIssues } from './pending.mjs';
|
|
@@ -58,15 +58,16 @@ async function handle(args, config, repo, recorder, controls) {
|
|
|
58
58
|
function watchRun(args, loop, context, interrupts, print) {
|
|
59
59
|
const { recorder } = context;
|
|
60
60
|
let passStart = recorder.summary();
|
|
61
|
+
const hunting = args.hunt ? hunter(context) : undefined;
|
|
61
62
|
return watchIssues(args, {
|
|
62
63
|
...loop,
|
|
63
64
|
wait: (minutes) => {
|
|
64
65
|
recorder.event('watch.wait', { minutes }, 'quiet');
|
|
65
66
|
passStart = recorder.summary();
|
|
66
|
-
return interrupts.sleep(minutesToMs(minutes));
|
|
67
|
+
return interrupts.sleep(minutesToMs(minutes), () => hunting?.busy() === true);
|
|
67
68
|
},
|
|
68
69
|
passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
|
|
69
|
-
...(
|
|
70
|
+
...(hunting === undefined ? {} : { hunter: hunting }),
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
73
|
function recordLoopEnd(recorder, stoppedAt, error) {
|
package/dist/watch.mjs
CHANGED
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
import { handled, runIssues } from './loop.mjs';
|
|
2
2
|
const BACK_OFF_MINUTES = [1, 2, 3, 5, 10];
|
|
3
3
|
export async function watchIssues(args, watch) {
|
|
4
|
+
const running = new Set();
|
|
5
|
+
const ended = new AbortController();
|
|
6
|
+
const hunting = watch.hunter === undefined
|
|
7
|
+
? undefined
|
|
8
|
+
: huntIssues(watch.hunter, running, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
9
|
+
try {
|
|
10
|
+
return await watchPasses(args, {
|
|
11
|
+
...watch,
|
|
12
|
+
process: async (issue) => {
|
|
13
|
+
running.add(issue.number);
|
|
14
|
+
try {
|
|
15
|
+
return await watch.process(issue);
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
running.delete(issue.number);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
ended.abort();
|
|
25
|
+
await hunting;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function huntIssues(hunter, running, stopped, signal) {
|
|
29
|
+
let step = 0;
|
|
30
|
+
while (!stopped()) {
|
|
31
|
+
const ready = await hunter.ready().catch(() => undefined);
|
|
32
|
+
const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
|
|
33
|
+
if (waiting !== undefined && waiting < hunter.cap) {
|
|
34
|
+
step = 0;
|
|
35
|
+
await hunter.hunt();
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
await hunter.wait(backOffMinutes(step), signal);
|
|
39
|
+
step += 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function watchPasses(args, watch) {
|
|
4
43
|
const limit = args.once ? 1 : args.max;
|
|
5
44
|
const reports = [];
|
|
6
45
|
const failed = new Set();
|
|
7
46
|
let step = 0;
|
|
8
|
-
let hunting = true;
|
|
9
47
|
for (;;) {
|
|
10
48
|
const pass = await runIssues({ once: false, max: limit === undefined ? undefined : limit - handled(reports) }, watch, new Set(failed));
|
|
11
49
|
reports.push(...pass.reports);
|
|
@@ -13,7 +51,6 @@ export async function watchIssues(args, watch) {
|
|
|
13
51
|
if (handled(pass.reports) > 0) {
|
|
14
52
|
await watch.passEnd(pass.reports);
|
|
15
53
|
step = 0;
|
|
16
|
-
hunting = true;
|
|
17
54
|
}
|
|
18
55
|
if (pass.error !== undefined || pass.stoppedAt !== undefined) {
|
|
19
56
|
return { ...pass, reports };
|
|
@@ -21,10 +58,6 @@ export async function watchIssues(args, watch) {
|
|
|
21
58
|
if ((limit !== undefined && handled(reports) >= limit) || watch.stop()) {
|
|
22
59
|
return { reports };
|
|
23
60
|
}
|
|
24
|
-
if (hunting) {
|
|
25
|
-
hunting = false;
|
|
26
|
-
await watch.hunt?.();
|
|
27
|
-
}
|
|
28
61
|
const minutes = backOffMinutes(step);
|
|
29
62
|
step += 1;
|
|
30
63
|
if (!(await watch.wait(minutes))) {
|