next-issue 8.3.0 → 8.3.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 +30 -8
- package/dist/agents.mjs +29 -4
- package/dist/config.mjs +1 -1
- package/dist/git-land.mjs +2 -2
- package/dist/github.mjs +3 -1
- package/dist/open-job.mjs +3 -0
- package/dist/prompts.mjs +1 -1
- package/dist/run.mjs +4 -4
- package/dist/serve.mjs +4 -1
- package/dist/worker-log.mjs +13 -1
- package/dist/worktree.mjs +3 -5
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -66,8 +66,11 @@ the run handles one issue. For each issue:
|
|
|
66
66
|
state keeps the branch name that the state holds, and a worktree that
|
|
67
67
|
holds that branch already stays in use. A branch that exists on the
|
|
68
68
|
remote is the start, and a local branch that fell behind the remote is
|
|
69
|
-
fast-forwarded
|
|
70
|
-
|
|
69
|
+
fast-forwarded; a local branch that cannot be fast-forwarded stays as it
|
|
70
|
+
is and the harness writes a `branch.behind` event. The fetch prunes
|
|
71
|
+
remote branches, so a remote branch that was deleted does not count. A
|
|
72
|
+
local branch that the remote does not hold and that has no commits of
|
|
73
|
+
its own starts again from the remote base. An issue with no
|
|
71
74
|
saved state does not reuse a local `<n>` branch: it resets that branch,
|
|
72
75
|
and any worktree that holds it, to the remote branch, or to the remote
|
|
73
76
|
base when there is none. A worktree at `.worktrees/<n>` left on a
|
|
@@ -708,7 +711,7 @@ because no pull request is opened.
|
|
|
708
711
|
| `checkIntervalSeconds` | `15` | The time between two check states, at most `2147483` |
|
|
709
712
|
| `checkGraceSeconds` | `60` | The time to wait for the first check to show, and for more checks after they all pass; the grace ends at the `checkTimeoutMinutes` limit, where checks that all pass, or no checks, still count as a pass |
|
|
710
713
|
| `checkTimeoutMinutes` | `60` | The limit for one check wait, at most `35791` |
|
|
711
|
-
| `agentTimeoutMinutes` | `30` | The limit for one agent call, at most `35791`
|
|
714
|
+
| `agentTimeoutMinutes` | `30` | The limit for one agent call, opening its session included, at most `35791` |
|
|
712
715
|
| `setupTimeoutMinutes` | `15` | The limit for the setup command, at most `35791` |
|
|
713
716
|
| `commandTimeoutMinutes` | `10` | The limit for one `git` or `gh` command, at most `35791` |
|
|
714
717
|
| `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) |
|
|
@@ -724,9 +727,9 @@ because no pull request is opened.
|
|
|
724
727
|
The hunter adds `labels.hunt` to each issue it files, so you can tell those
|
|
725
728
|
issues apart from your own and filter them.
|
|
726
729
|
|
|
727
|
-
The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman
|
|
728
|
-
and `
|
|
729
|
-
the run with an error that names both fields.
|
|
730
|
+
The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman`,
|
|
731
|
+
`skip` and `hunt` must be distinct, also when case is ignored; two equal names
|
|
732
|
+
stop the run with an error that names both fields.
|
|
730
733
|
|
|
731
734
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
732
735
|
claims every open issue that no other label holds back.
|
|
@@ -909,7 +912,7 @@ The watch stops:
|
|
|
909
912
|
|
|
910
913
|
## Hunt for bugs
|
|
911
914
|
|
|
912
|
-
With `next-issue start --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, 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, it waits 1 minute before it checks the count again, even when the count is still less than `huntCap
|
|
915
|
+
With `next-issue start --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, 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, it 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:
|
|
913
916
|
|
|
914
917
|
- 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;
|
|
915
918
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
@@ -999,7 +1002,8 @@ affect another. The worker:
|
|
|
999
1002
|
an `error` and starts nothing. The setting lasts for the run only: a new run
|
|
1000
1003
|
takes it from its own flags. Only runs of the worker can switch; a
|
|
1001
1004
|
command-line run keeps what `--hunt` gave it. The progress of each run
|
|
1002
|
-
carries `hunting`, `true` while hunting is on
|
|
1005
|
+
carries `hunting`, `true` while hunting is on, and `watching`, `true` when
|
|
1006
|
+
the run watches for issues;
|
|
1003
1007
|
- asks a watching run to check for new issues now when a client sends
|
|
1004
1008
|
`{ "type": "refresh", "root": "<path>" }`. A run that waits between passes
|
|
1005
1009
|
starts a new pass at once, and its next wait starts again at 1 minute; a
|
|
@@ -1093,6 +1097,24 @@ earlier commit that runs after it does not, as it repairs the tag before its
|
|
|
1093
1097
|
own commit. To repair a release without a new commit,
|
|
1094
1098
|
run the `ci` workflow by hand; after the checks pass, the release job only
|
|
1095
1099
|
repairs and does nothing else.
|
|
1100
|
+
The publish runs no typecheck and no tests, as the `check` job has run them.
|
|
1101
|
+
So a failing test cannot stop a publish after the tag push. To publish by hand
|
|
1102
|
+
from a clone, run the checks of the `check` job first, then publish:
|
|
1103
|
+
|
|
1104
|
+
```bash
|
|
1105
|
+
npm ci
|
|
1106
|
+
npm run typecheck
|
|
1107
|
+
npm run lint
|
|
1108
|
+
npm run format:check
|
|
1109
|
+
npm test
|
|
1110
|
+
npm run build
|
|
1111
|
+
.github/scripts/release-bump.test.sh
|
|
1112
|
+
.github/scripts/repair-release.test.sh
|
|
1113
|
+
.github/scripts/check-npm.test.sh
|
|
1114
|
+
.github/scripts/release-notes.test.sh
|
|
1115
|
+
npm publish --workspaces
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1096
1118
|
The job uses the npm that comes with Node 24 and never installs another one.
|
|
1097
1119
|
Trusted publishing needs npm 11.5.1 or later, so the job stops with an error
|
|
1098
1120
|
before anything else when the bundled npm is older.
|
package/dist/agents.mjs
CHANGED
|
@@ -26,15 +26,30 @@ export async function runAgent(recorder, request) {
|
|
|
26
26
|
process.env.GIT_OPTIONAL_LOCKS = '0';
|
|
27
27
|
process.argv[1] = PI_CLI;
|
|
28
28
|
log.event('agent.start', { model: request.model, timeoutMs: request.timeoutMs });
|
|
29
|
-
const session = await openSession(recorder, log, request, agentDir);
|
|
30
29
|
// pi drops an abort that comes before its run starts (during bindExtensions or the prompt
|
|
31
30
|
// preflight), so remember it and abort again once the run is active, before its first turn.
|
|
31
|
+
let opened;
|
|
32
32
|
let ended = false;
|
|
33
|
+
let expire = () => undefined;
|
|
34
|
+
const expired = new Promise((resolve) => {
|
|
35
|
+
expire = () => resolve(undefined);
|
|
36
|
+
});
|
|
33
37
|
const end = () => {
|
|
34
38
|
ended = true;
|
|
35
|
-
void
|
|
39
|
+
void opened?.abort();
|
|
36
40
|
};
|
|
37
|
-
const timer = deadline(request.timeoutMs,
|
|
41
|
+
const timer = deadline(request.timeoutMs, () => {
|
|
42
|
+
expire();
|
|
43
|
+
end();
|
|
44
|
+
});
|
|
45
|
+
const session = await openWithin(openSession(recorder, log, request, agentDir), expired).catch((error) => {
|
|
46
|
+
timer.clear();
|
|
47
|
+
throw error;
|
|
48
|
+
});
|
|
49
|
+
if (session === undefined) {
|
|
50
|
+
throw timeoutError(request);
|
|
51
|
+
}
|
|
52
|
+
opened = session;
|
|
38
53
|
const unsubscribe = session.subscribe((event) => observe(log, event));
|
|
39
54
|
const release = onStop(end);
|
|
40
55
|
try {
|
|
@@ -59,7 +74,7 @@ export async function runAgent(recorder, request) {
|
|
|
59
74
|
}
|
|
60
75
|
refuseWhenStopped();
|
|
61
76
|
if (timer.timedOut()) {
|
|
62
|
-
throw
|
|
77
|
+
throw timeoutError(request);
|
|
63
78
|
}
|
|
64
79
|
const failure = lastFailure(session);
|
|
65
80
|
if (failure !== undefined) {
|
|
@@ -74,6 +89,16 @@ export async function runAgent(recorder, request) {
|
|
|
74
89
|
session.dispose();
|
|
75
90
|
}
|
|
76
91
|
}
|
|
92
|
+
async function openWithin(opening, expired) {
|
|
93
|
+
const session = await Promise.race([opening, expired]);
|
|
94
|
+
if (session === undefined) {
|
|
95
|
+
opening.then((late) => late.dispose(), () => undefined);
|
|
96
|
+
}
|
|
97
|
+
return session;
|
|
98
|
+
}
|
|
99
|
+
function timeoutError(request) {
|
|
100
|
+
return new Error(`The ${request.name} agent did not finish in ${request.timeoutMs} ms.`);
|
|
101
|
+
}
|
|
77
102
|
function lastFailure(session) {
|
|
78
103
|
const last = session.messages.findLast((message) => message.role === 'assistant');
|
|
79
104
|
if (last === undefined || !('stopReason' in last) || last.stopReason !== 'error') {
|
package/dist/config.mjs
CHANGED
|
@@ -190,7 +190,7 @@ function parseLabels(value, defaultLabels) {
|
|
|
190
190
|
function rejectSameLabels(labels) {
|
|
191
191
|
const seen = new Map();
|
|
192
192
|
for (const name of LABEL_NAMES) {
|
|
193
|
-
if (
|
|
193
|
+
if (labels[name] === '') {
|
|
194
194
|
continue;
|
|
195
195
|
}
|
|
196
196
|
const key = labels[name].toLowerCase();
|
package/dist/git-land.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { evenWhenStopped } from './children.mjs';
|
|
2
|
-
import { fetchBase, git, isAncestor, isLanded, isOnBase, oneFetchAtATime, revision, succeeds, } from './git.mjs';
|
|
2
|
+
import { fetchBase, git, isAncestor, isDirty, isLanded, isOnBase, oneFetchAtATime, revision, succeeds, } from './git.mjs';
|
|
3
3
|
import { commitEverything } from './git-commit.mjs';
|
|
4
4
|
export const PUSH_TRIES = 3;
|
|
5
5
|
export async function squashOnto(cwd, target, message) {
|
|
6
|
-
if (await succeeds(cwd, ['diff', '--quiet', target])) {
|
|
6
|
+
if ((await succeeds(cwd, ['diff', '--quiet', target])) && !(await isDirty(cwd))) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
const head = await revision(cwd);
|
package/dist/github.mjs
CHANGED
|
@@ -16,7 +16,9 @@ function toIssue(item) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function labelFilter(labels) {
|
|
19
|
-
return labels.length === 0
|
|
19
|
+
return labels.length === 0
|
|
20
|
+
? ''
|
|
21
|
+
: ` label:${labels.map((label) => `"${label.replace(/[\\"]/g, '\\$&')}"`).join(',')}`;
|
|
20
22
|
}
|
|
21
23
|
export async function openIssues(repo, limit, labels) {
|
|
22
24
|
const parsed = await ghJson(repo, [
|
package/dist/open-job.mjs
CHANGED
|
@@ -42,5 +42,8 @@ async function openWorktree(context, issue, log, branch, start) {
|
|
|
42
42
|
if (!added.baseUpdated) {
|
|
43
43
|
log.event('base.behind', { base: context.base }, 'quiet');
|
|
44
44
|
}
|
|
45
|
+
if (!added.branchUpdated) {
|
|
46
|
+
log.event('branch.behind', { branch }, 'quiet');
|
|
47
|
+
}
|
|
45
48
|
return added.path;
|
|
46
49
|
}
|
package/dist/prompts.mjs
CHANGED
|
@@ -206,7 +206,7 @@ export function huntPrompt(instructions, ready, source, count, repository) {
|
|
|
206
206
|
const kept = instructions?.trim() ?? '';
|
|
207
207
|
const label = [ready, source]
|
|
208
208
|
.filter((name) => name !== '')
|
|
209
|
-
.map((name) => ` --label "${name}"`)
|
|
209
|
+
.map((name) => ` --label "${name.replace(/[\\"$`]/g, '\\$&')}"`)
|
|
210
210
|
.join('');
|
|
211
211
|
return paragraphs([
|
|
212
212
|
`You are the hunter. Find the most serious problems in this repository and file up to ${issues} for them.`,
|
package/dist/run.mjs
CHANGED
|
@@ -48,11 +48,11 @@ async function runWithConfig(root, args, controls, config) {
|
|
|
48
48
|
await checkGitVersion();
|
|
49
49
|
const repo = await detectRepo(root, config.remote);
|
|
50
50
|
const recorder = await Recorder.create(repo.root, args.level, controls.onEvent);
|
|
51
|
-
const pruned = await pruneRuns(repo.root, config.keepRunDays);
|
|
52
|
-
if (pruned > 0) {
|
|
53
|
-
recorder.event('runs.pruned', { files: pruned, keepDays: config.keepRunDays }, 'verbose');
|
|
54
|
-
}
|
|
55
51
|
try {
|
|
52
|
+
const pruned = await pruneRuns(repo.root, config.keepRunDays);
|
|
53
|
+
if (pruned > 0) {
|
|
54
|
+
recorder.event('runs.pruned', { files: pruned, keepDays: config.keepRunDays }, 'verbose');
|
|
55
|
+
}
|
|
56
56
|
return await recordCommands(recorder, () => handle(args, config, repo, recorder, controls));
|
|
57
57
|
}
|
|
58
58
|
finally {
|
package/dist/serve.mjs
CHANGED
|
@@ -64,7 +64,7 @@ export async function startWorker(options) {
|
|
|
64
64
|
send(socket, { type: 'error', root, message: message(error) });
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
const run = newRun(startProgress(args.hunt), args.watch);
|
|
67
|
+
const run = newRun({ ...startProgress(args.hunt), watching: args.watch }, args.watch);
|
|
68
68
|
runs.set(root, run);
|
|
69
69
|
const update = (next) => {
|
|
70
70
|
run.progress = next;
|
|
@@ -96,6 +96,9 @@ export async function startWorker(options) {
|
|
|
96
96
|
};
|
|
97
97
|
const receive = (socket, value) => {
|
|
98
98
|
if (value.type === 'hello') {
|
|
99
|
+
if (typeof value.version !== 'string') {
|
|
100
|
+
throw new Error('a hello message needs its version as a string');
|
|
101
|
+
}
|
|
99
102
|
if (isNewer(value.version, options.version)) {
|
|
100
103
|
restart = true;
|
|
101
104
|
closeWhenIdle();
|
package/dist/worker-log.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export function trimLog(path) {
|
|
|
18
18
|
const read = readSync(file, tail, 0, LOG_KEEP_BYTES, size - LOG_KEEP_BYTES);
|
|
19
19
|
const kept = tail.subarray(tail.indexOf(10) + 1, read);
|
|
20
20
|
writeSync(file, kept, 0, kept.length, 0);
|
|
21
|
-
ftruncateSync(file, kept.length);
|
|
21
|
+
ftruncateSync(file, kept.length + copyAppended(file, size, kept.length));
|
|
22
22
|
}
|
|
23
23
|
finally {
|
|
24
24
|
closeSync(file);
|
|
@@ -28,6 +28,18 @@ export function trimLog(path) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
function copyAppended(file, from, to) {
|
|
32
|
+
let read = from;
|
|
33
|
+
let written = to;
|
|
34
|
+
for (let size = fstatSync(file).size; read < size; size = fstatSync(file).size) {
|
|
35
|
+
const appended = Buffer.alloc(size - read);
|
|
36
|
+
const length = readSync(file, appended, 0, appended.length, read);
|
|
37
|
+
writeSync(file, appended, 0, length, written);
|
|
38
|
+
read += length;
|
|
39
|
+
written += length;
|
|
40
|
+
}
|
|
41
|
+
return written - to;
|
|
42
|
+
}
|
|
31
43
|
export function keepLogTrimmed(path, checkMs) {
|
|
32
44
|
trimLog(path);
|
|
33
45
|
const timer = setInterval(() => trimLog(path), checkMs);
|
package/dist/worktree.mjs
CHANGED
|
@@ -31,10 +31,8 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
31
31
|
else if (start) {
|
|
32
32
|
await discardChanges(path, target);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return { path, baseUpdated };
|
|
34
|
+
const branchUpdated = !pushed || (await succeeds(path, ['merge', '--ff-only', upstream]));
|
|
35
|
+
return { path, baseUpdated, branchUpdated };
|
|
38
36
|
}
|
|
39
37
|
async function keepDetachedEdits(path, branch) {
|
|
40
38
|
if (!existsSync(join(path, '.git')) ||
|
|
@@ -55,7 +53,7 @@ async function hasBranch(repo, name, ...flags) {
|
|
|
55
53
|
return list.length > 0;
|
|
56
54
|
}
|
|
57
55
|
export async function fastForwardBase(repo, base, remote) {
|
|
58
|
-
await gitFetch(repo.root, [remote]);
|
|
56
|
+
await gitFetch(repo.root, ['--prune', remote]);
|
|
59
57
|
return updateBase(repo, base, remote);
|
|
60
58
|
}
|
|
61
59
|
async function updateBase(repo, base, remote) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-issue",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"description": "Autonomous issue harness driven by the pi SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"lint:fix": "oxlint --fix",
|
|
39
39
|
"format": "oxfmt",
|
|
40
40
|
"format:check": "oxfmt --check",
|
|
41
|
-
"prepack": "npm run build"
|
|
42
|
-
"prepublishOnly": "npm run typecheck && npm test"
|
|
41
|
+
"prepack": "npm run build"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@earendil-works/pi-ai": "^1.5.2",
|