next-issue 12.4.1 → 12.4.3
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/github.mjs +9 -6
- package/dist/hunt.mjs +2 -4
- package/dist/loop.mjs +3 -0
- package/dist/pending.mjs +9 -3
- package/dist/skip.mjs +13 -0
- package/dist/upcoming.mjs +2 -3
- package/dist/watch.mjs +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Only one worker goes at a time in a repository. It holds the lock `.next-issue/w
|
|
|
40
40
|
|
|
41
41
|
Every command uses the main worktree of the repository as its root, the first one that `git worktree list` shows, even when it runs in a linked worktree. So `.next-issue/`, with the config, the locks, the worker socket, the saved state and the notes, and `.worktrees/` are always in the main worktree, and a run or worker started from a linked worktree gets the same refusal as one started from the main worktree.
|
|
42
42
|
|
|
43
|
-
A run works on up to `concurrency` issues with an agent at the same time, 1 by default. Each claimed issue takes a slot. An approved issue frees its slot while it waits to land, while it lands and while it waits for the checks on the base, so the next issue's agents never wait for CI. When such an issue needs an agent again, for example the fixer for a conflict or for failed checks, it waits for a free slot, takes it before any new issue is claimed and frees it once the agent ends. So no more than `concurrency` agents run at once. When a slot frees up, the run claims the oldest unseen issue for it, and fetches the open issues again only when the last fetch left an unseen issue unclaimed or an issue has ended since. When an issue ends while every slot is taken, the run still reads the open issues again, so the open-issue count stays current, but claims nothing until a slot frees up. The run ends only once every issue has ended, including those waiting to land. Each issue has its own worktree and branch. Step 3 below and the removal of a worktree or branch run for one issue at a time, so two issues never change the git refs or worktrees of the repository at once. An issue skipped as blocked is tried again in that run once another issue is done, so an issue blocked by one that waits to land is claimed once its blocker closes. For each issue:
|
|
43
|
+
A run works on up to `concurrency` issues with an agent at the same time, 1 by default. Each claimed issue takes a slot. An approved issue frees its slot while it waits to land, while it lands and while it waits for the checks on the base, so the next issue's agents never wait for CI. When such an issue needs an agent again, for example the fixer for a conflict or for failed checks, it waits for a free slot, takes it before any new issue is claimed and frees it once the agent ends. So no more than `concurrency` agents run at once. When a slot frees up, the run claims the oldest unseen issue for it, and fetches the open issues again only when the last fetch left an unseen issue unclaimed or an issue has ended since. When an issue ends while every slot is taken, the run still reads the open issues again, so the open-issue count stays current, but claims nothing until a slot frees up. When an issue ends `done` after the run has stopped claiming, because of a stop or a halt, the run reads the open issues again too, so the count shows the closed issue. The run ends only once every issue has ended, including those waiting to land. Each issue has its own worktree and branch. Step 3 below and the removal of a worktree or branch run for one issue at a time, so two issues never change the git refs or worktrees of the repository at once. An issue skipped as blocked is tried again in that run once another issue is done, so an issue blocked by one that waits to land is claimed once its blocker closes. For each issue:
|
|
44
44
|
|
|
45
45
|
1. Claim the issue only when it holds the `status:todo` label and holds no `status:in-progress` or `status:in-review` label. A `status:done`, `status:needs-human` or `status:blocked` label always stops the claim, a resume too, except a `status:needs-human` issue with an answer to its hand-over that the run made, and except an issue whose finish a stop cut short and that was not handed over (see step 7 below). An issue that GitHub lists as blocked by an open issue waits, because its blocker closes only when the change of the blocker lands. An issue with saved state under `.next-issue/` resumes instead, whatever its other labels and blockers.
|
|
46
46
|
2. Add `status:in-progress` to the issue.
|
|
@@ -231,7 +231,7 @@ With no file, every field keeps its default. A field that is not in the file kee
|
|
|
231
231
|
| `diffMaxChars` | `60000` | The maximum length of the diff that the reviewer reads |
|
|
232
232
|
| `huntCap` | `1` | With `--hunt on`, the hunter hunts only while fewer ready issues than this wait besides the running ones |
|
|
233
233
|
| `ignoredChecks` | `[]` | Names of GitHub Actions jobs, check runs and commit statuses, such as `release`, that the checks on the base branch do not wait for and whose failure does not count, unless GitHub cancels or skips another job of its run |
|
|
234
|
-
| `issueLimit` | `100` | The
|
|
234
|
+
| `issueLimit` | `100` | The most open issues to read, oldest first. With `labels.ready` set, only ready, in-progress or in-review issues with no needs-human or skip label count; ready issues that wait for a person are read apart |
|
|
235
235
|
| `keepRunDays` | `7` | The number of days to keep the run files; `0` keeps them all |
|
|
236
236
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
|
237
237
|
| `logMaxChars` | `20000` | The maximum length of the failed job logs, shared between the failed GitHub Actions runs (failed external checks are listed by name and link only) |
|
|
@@ -337,7 +337,7 @@ The watch stops:
|
|
|
337
337
|
|
|
338
338
|
## Hunt for bugs
|
|
339
339
|
|
|
340
|
-
With `next-issue start --hunt on`, which needs watching on, 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, and reads them one issue at a time, so it runs one `gh` call at a time. 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. After a hunt that files an issue,
|
|
340
|
+
With `next-issue start --hunt on`, which needs watching on, 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, and reads them one issue at a time, so it runs one `gh` call at a time. 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. After a hunt that files an issue, the harness reads the open issues again, so the open-issue count is current, and the hunter waits 1 minute before it checks the count again, even when the count is still less than `huntCap`. 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:
|
|
341
341
|
|
|
342
342
|
- 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;
|
|
343
343
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
package/dist/github.mjs
CHANGED
|
@@ -15,19 +15,22 @@ function toIssue(item) {
|
|
|
15
15
|
labels: names(item.labels),
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
-
? ''
|
|
21
|
-
: ` label:${labels.map((label) => `"${label.replace(/[\\"]/g, '\\$&')}"`).join(',')}`;
|
|
18
|
+
function quoted(label) {
|
|
19
|
+
return `"${label.replace(/[\\"]/g, '\\$&')}"`;
|
|
22
20
|
}
|
|
23
|
-
|
|
21
|
+
function labelFilter(labels, without, every) {
|
|
22
|
+
const any = labels.length === 0 ? '' : ` label:${labels.map(quoted).join(',')}`;
|
|
23
|
+
const all = every.map((label) => ` label:${quoted(label)}`).join('');
|
|
24
|
+
return any + all + without.map((label) => ` -label:${quoted(label)}`).join('');
|
|
25
|
+
}
|
|
26
|
+
export async function openIssues(repo, limit, labels, without = [], every = []) {
|
|
24
27
|
const parsed = await ghJson(repo, [
|
|
25
28
|
'issue',
|
|
26
29
|
'list',
|
|
27
30
|
'--state',
|
|
28
31
|
'open',
|
|
29
32
|
'--search',
|
|
30
|
-
`sort:created-asc${labelFilter(labels)}`,
|
|
33
|
+
`sort:created-asc${labelFilter(labels, without, every)}`,
|
|
31
34
|
'--limit',
|
|
32
35
|
String(limit),
|
|
33
36
|
'--json',
|
package/dist/hunt.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { git, gitFetch, remoteRef } from './git.mjs';
|
|
|
9
9
|
import { withNotes } from './job.mjs';
|
|
10
10
|
import { oneAtATime } from './lock.mjs';
|
|
11
11
|
import { huntPrompt } from './prompts.mjs';
|
|
12
|
-
import { skipReason } from './skip.mjs';
|
|
12
|
+
import { listedIssues, skipReason } from './skip.mjs';
|
|
13
13
|
import { huntPath } from './worktree.mjs';
|
|
14
14
|
export const HUNT_FILE = 'next-issue.hunt.md';
|
|
15
15
|
const FILED = /^issue:[^\S\r\n]*(\S+)[^\S\r\n]*$/gm;
|
|
@@ -71,13 +71,11 @@ export async function hunt(context, count) {
|
|
|
71
71
|
}
|
|
72
72
|
export function hunter(context) {
|
|
73
73
|
const { repo, config, recorder, ports } = context;
|
|
74
|
-
const { ready } = config.labels;
|
|
75
|
-
const labels = ready.length === 0 ? [] : [ready];
|
|
76
74
|
let hunting = false;
|
|
77
75
|
return {
|
|
78
76
|
cap: config.huntCap,
|
|
79
77
|
ready: async (running, failed) => {
|
|
80
|
-
const open = (await ports
|
|
78
|
+
const open = (await listedIssues(ports, repo, config, [])).filter((issue) => !failed.has(issue.number) && skipReason(issue, config, false) === undefined);
|
|
81
79
|
const claimable = new Set(open.map((issue) => issue.number));
|
|
82
80
|
const blockers = [];
|
|
83
81
|
for (const issue of open) {
|
package/dist/loop.mjs
CHANGED
package/dist/pending.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { errorMatches, message } from './errors.mjs';
|
|
2
|
+
import { listedIssues, waitingIssues } from './skip.mjs';
|
|
2
3
|
import { readState, savedIssues, writeState } from './state.mjs';
|
|
3
4
|
import { blocksLanding, heldOnBase } from './unsettled.mjs';
|
|
4
5
|
/**
|
|
@@ -8,10 +9,15 @@ import { blocksLanding, heldOnBase } from './unsettled.mjs';
|
|
|
8
9
|
const ISSUE_GONE = /Could not resolve to an issue or pull request|HTTP 404/;
|
|
9
10
|
export async function pendingIssues(context) {
|
|
10
11
|
const { repo, config, ports } = context;
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
13
|
-
const issues = await ports.openIssues(repo, config.issueLimit, labels);
|
|
12
|
+
const { inProgress, inReview } = config.labels;
|
|
13
|
+
const issues = await listedIssues(ports, repo, config, [inProgress, inReview]);
|
|
14
14
|
const listed = new Set(issues.map((issue) => issue.number));
|
|
15
|
+
for (const issue of await waitingIssues(ports, repo, config)) {
|
|
16
|
+
if (!listed.has(issue.number)) {
|
|
17
|
+
listed.add(issue.number);
|
|
18
|
+
issues.push(issue);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
let openCount = issues.length;
|
|
16
22
|
const saved = await savedIssues(repo);
|
|
17
23
|
for (const number of saved) {
|
package/dist/skip.mjs
CHANGED
|
@@ -6,6 +6,19 @@ import { stopNow } from './handover.mjs';
|
|
|
6
6
|
import { hasLabel } from './labels.mjs';
|
|
7
7
|
import { heldByPerson, writeState } from './state.mjs';
|
|
8
8
|
import { heldOnBase } from './unsettled.mjs';
|
|
9
|
+
export function listedIssues(ports, repo, config, labels) {
|
|
10
|
+
const { ready, needsHuman, skip } = config.labels;
|
|
11
|
+
return ready.length === 0
|
|
12
|
+
? ports.openIssues(repo, config.issueLimit, [])
|
|
13
|
+
: ports.openIssues(repo, config.issueLimit, [ready, ...labels], [needsHuman, skip]);
|
|
14
|
+
}
|
|
15
|
+
export function waitingIssues(ports, repo, config) {
|
|
16
|
+
const { ready, needsHuman, skip } = config.labels;
|
|
17
|
+
if (ready.length === 0) {
|
|
18
|
+
return Promise.resolve([]);
|
|
19
|
+
}
|
|
20
|
+
return ports.openIssues(repo, config.issueLimit, [needsHuman], [skip], [ready]);
|
|
21
|
+
}
|
|
9
22
|
export function skipReason(issue, config, resuming, answered = false) {
|
|
10
23
|
const has = (name) => hasLabel(issue.labels, name);
|
|
11
24
|
const names = config.labels;
|
package/dist/upcoming.mjs
CHANGED
|
@@ -3,12 +3,11 @@ import { message } from './errors.mjs';
|
|
|
3
3
|
import { detectRepo } from './git.mjs';
|
|
4
4
|
import { PORTS } from './ports.mjs';
|
|
5
5
|
import { send } from './questions.mjs';
|
|
6
|
-
import { skipReason } from './skip.mjs';
|
|
6
|
+
import { listedIssues, skipReason } from './skip.mjs';
|
|
7
7
|
import { savedIssues } from './state.mjs';
|
|
8
8
|
/** The fresh issues the worker would claim, oldest first as it claims them; issues with saved state resume instead. */
|
|
9
9
|
export async function upcomingIssues(repo, config, ports) {
|
|
10
|
-
const
|
|
11
|
-
const issues = await ports.openIssues(repo, config.issueLimit, ready.length === 0 ? [] : [ready]);
|
|
10
|
+
const issues = await listedIssues(ports, repo, config, []);
|
|
12
11
|
const saved = new Set(await savedIssues(repo));
|
|
13
12
|
const upcoming = { claimable: [], blocked: [] };
|
|
14
13
|
for (const issue of issues) {
|
package/dist/watch.mjs
CHANGED
|
@@ -8,7 +8,7 @@ export async function watchIssues(watch) {
|
|
|
8
8
|
const claims = claimAlarm();
|
|
9
9
|
const hunting = watch.hunter === undefined
|
|
10
10
|
? undefined
|
|
11
|
-
: huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, claims, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
11
|
+
: huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, claims, watch.issues, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
12
12
|
try {
|
|
13
13
|
return await watchPasses(failed, {
|
|
14
14
|
...watch,
|
|
@@ -57,7 +57,7 @@ function aborted(signal) {
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
async function huntIssues(hunter, hunting, running, failed, claims, refreshes, stopped, signal) {
|
|
60
|
+
async function huntIssues(hunter, hunting, running, failed, claims, issues, refreshes, stopped, signal) {
|
|
61
61
|
let step = 0;
|
|
62
62
|
while (!stopped()) {
|
|
63
63
|
if (!hunting.on()) {
|
|
@@ -74,6 +74,7 @@ async function huntIssues(hunter, hunting, running, failed, claims, refreshes, s
|
|
|
74
74
|
if (waiting !== undefined && waiting < hunter.cap && hunting.on()) {
|
|
75
75
|
if (await hunter.hunt(hunter.cap - waiting)) {
|
|
76
76
|
step = 0;
|
|
77
|
+
await issues().catch(() => undefined);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
if (claims.take() || stopped() || !hunting.on()) {
|