next-issue 6.6.39 → 6.6.40
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 +25 -25
- package/dist/conflict.mjs +7 -5
- package/dist/git-merge.mjs +2 -2
- package/dist/github.mjs +11 -3
- package/dist/hunt.mjs +7 -2
- package/dist/pending.mjs +1 -1
- package/dist/prompts.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,29 +120,29 @@ the run handles one issue. For each issue:
|
|
|
120
120
|
reports conflicted files, the fixer gets the list from the check budget,
|
|
121
121
|
`maxCiFixes`, removes the conflict markers, and the harness commits the
|
|
122
122
|
merge. A merge that the fixer commits itself counts only when the branch
|
|
123
|
-
then holds the base and the listed files hold no
|
|
124
|
-
budget used up, or when the fixer leaves a
|
|
125
|
-
unresolved, aborts the merge, or fails, the
|
|
126
|
-
hands the issue to a person with the reason
|
|
127
|
-
harness then pushes the commit to the base branch,
|
|
128
|
-
that the remote refuses, for example because the
|
|
129
|
-
rebase again, three times at most. When the push
|
|
130
|
-
fetches the base first, and treats the push as landed
|
|
131
|
-
the commit, for example after a timeout. When that
|
|
132
|
-
harness hands the issue to a person with the reason
|
|
133
|
-
halts, even when the hand-over fails. The state file
|
|
134
|
-
during the push, so a run stopped meanwhile, or the
|
|
135
|
-
hand-over, checks the base on resume and waits for
|
|
136
|
-
commit when it landed. The harness then waits for the
|
|
137
|
-
pushed commit on the base branch: its GitHub Actions
|
|
138
|
-
commit statuses and the check runs of every other
|
|
139
|
-
from another CI service count too. It leaves out
|
|
140
|
-
GitHub Actions app, since it judges GitHub Actions
|
|
141
|
-
failed or errored commit status, or a check run
|
|
142
|
-
`failure`, `timed_out` or `action_required`, fails the
|
|
143
|
-
ends `cancelled`, for example because a later
|
|
144
|
-
run, that check never finished, even when
|
|
145
|
-
workflow) ends `success`: the harness
|
|
123
|
+
then holds the base commit that was merged and the listed files hold no
|
|
124
|
+
conflict marker. With the budget used up, or when the fixer leaves a
|
|
125
|
+
conflict marker or the merge unresolved, aborts the merge, or fails, the
|
|
126
|
+
harness undoes the merge and hands the issue to a person with the reason
|
|
127
|
+
`merge conflict`. The harness then pushes the commit to the base branch,
|
|
128
|
+
without force. A push that the remote refuses, for example because the
|
|
129
|
+
base moved, starts the rebase again, three times at most. When the push
|
|
130
|
+
fails, the harness fetches the base first, and treats the push as landed
|
|
131
|
+
when the base holds the commit, for example after a timeout. When that
|
|
132
|
+
fetch fails too, the harness hands the issue to a person with the reason
|
|
133
|
+
`push unknown` and halts, even when the hand-over fails. The state file
|
|
134
|
+
holds the commit during the push, so a run stopped meanwhile, or the
|
|
135
|
+
next run after that hand-over, checks the base on resume and waits for
|
|
136
|
+
the checks of the commit when it landed. The harness then waits for the
|
|
137
|
+
checks of the pushed commit on the base branch: its GitHub Actions
|
|
138
|
+
workflow runs, its commit statuses and the check runs of every other
|
|
139
|
+
GitHub App, so checks from another CI service count too. It leaves out
|
|
140
|
+
the check runs of the GitHub Actions app, since it judges GitHub Actions
|
|
141
|
+
by its workflow runs. A failed or errored commit status, or a check run
|
|
142
|
+
that ends with `failure`, `timed_out` or `action_required`, fails the
|
|
143
|
+
checks. When any check ends `cancelled`, for example because a later
|
|
144
|
+
push cancelled the workflow run, that check never finished, even when
|
|
145
|
+
another check (such as a release workflow) ends `success`: the harness
|
|
146
146
|
hands the issue to a person with the reason `main checks cancelled` and
|
|
147
147
|
halts, and the issue stays open. A repository
|
|
148
148
|
that reports no check keeps asking for `checkGraceSeconds`. A pending state
|
|
@@ -578,10 +578,10 @@ With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the
|
|
|
578
578
|
|
|
579
579
|
- 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;
|
|
580
580
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
581
|
-
- 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. The harness creates the `labels.ready` and `labels.hunt` labels before the hunt when they are missing. It files nothing when it finds no real problem or a duplicate exists;
|
|
581
|
+
- 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. It files and searches with `gh --repo <owner>/<name>` of the configured `remote`, so another GitHub remote, such as `upstream` in a fork, never gets its issues. The `labels.hunt` label, `source:hunt` by default, marks the issue as one the hunter filed. The harness creates the `labels.ready` and `labels.hunt` labels before the hunt when they are missing. It files nothing when it finds no real problem or a duplicate exists;
|
|
582
582
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
|
583
583
|
|
|
584
|
-
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.
|
|
584
|
+
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; a url that is not an issue of the repository of `remote` does not count as filed, 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.
|
|
585
585
|
|
|
586
586
|
## Worker
|
|
587
587
|
|
package/dist/conflict.mjs
CHANGED
|
@@ -11,7 +11,7 @@ export async function rebase(job) {
|
|
|
11
11
|
const { target, files } = await log.step('rebase', { base }, () => ports.startMerge(worktree, base, config.remote));
|
|
12
12
|
if (files !== undefined) {
|
|
13
13
|
log.event('rebase.conflicts', { files }, 'quiet');
|
|
14
|
-
const merged = await mergeBase(job, before, files);
|
|
14
|
+
const merged = await mergeBase(job, { before, target, files });
|
|
15
15
|
if (merged !== undefined) {
|
|
16
16
|
return merged;
|
|
17
17
|
}
|
|
@@ -24,7 +24,8 @@ export async function rebase(job) {
|
|
|
24
24
|
}
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
|
-
async function mergeBase(job,
|
|
27
|
+
async function mergeBase(job, merge) {
|
|
28
|
+
const { before, files } = merge;
|
|
28
29
|
const { context, worktree } = job;
|
|
29
30
|
const { config, ports, base } = context;
|
|
30
31
|
if (files.length > 0) {
|
|
@@ -33,7 +34,7 @@ async function mergeBase(job, before, files) {
|
|
|
33
34
|
return exhausted;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
if (!(await resolve(job,
|
|
37
|
+
if (!(await resolve(job, merge))) {
|
|
37
38
|
await ports.abortMerge(worktree, before);
|
|
38
39
|
return escalateAndFinish(job, `The fixer left the conflict with ${base} unresolved.`, 'merge conflict');
|
|
39
40
|
}
|
|
@@ -43,13 +44,14 @@ function fixConflict(job, files) {
|
|
|
43
44
|
const reason = `The change conflicts with ${job.context.base}.`;
|
|
44
45
|
return runFixer(job, reason, files.join('\n'), [], 'conflict');
|
|
45
46
|
}
|
|
46
|
-
async function resolve(job,
|
|
47
|
+
async function resolve(job, merge) {
|
|
47
48
|
const { context, worktree } = job;
|
|
49
|
+
const { before, files } = merge;
|
|
48
50
|
const { config, ports } = context;
|
|
49
51
|
try {
|
|
50
52
|
const text = files.length > 0 ? await fixConflict(job, files) : '';
|
|
51
53
|
const subject = parseCommitSubject(text, `chore: merge ${config.remote}/${context.base}`);
|
|
52
|
-
return await commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd,
|
|
54
|
+
return await commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd, merge, message));
|
|
53
55
|
}
|
|
54
56
|
catch (error) {
|
|
55
57
|
await ports.abortMerge(worktree, before);
|
package/dist/git-merge.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { run, succeeded } from './exec.mjs';
|
|
3
3
|
import { readTextOrEmpty } from './files.mjs';
|
|
4
4
|
import { commitEverything } from './git-commit.mjs';
|
|
5
|
-
import { fetchBase, git, isAncestor,
|
|
5
|
+
import { fetchBase, git, isAncestor, resetHard, succeeds } from './git.mjs';
|
|
6
6
|
import { lines } from './text.mjs';
|
|
7
7
|
export async function startMerge(cwd, base, remote) {
|
|
8
8
|
const target = await git(cwd, ['rev-parse', await fetchBase(cwd, base, remote)]);
|
|
@@ -33,7 +33,7 @@ export async function commitMerge(cwd, merge, message) {
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
async function refuseUnmerged(cwd, merge) {
|
|
36
|
-
const holdsBase = await isAncestor(cwd,
|
|
36
|
+
const holdsBase = await isAncestor(cwd, merge.target, 'HEAD');
|
|
37
37
|
if (!holdsBase || (await hasConflictMarkers(cwd, merge.files))) {
|
|
38
38
|
await resetHard(cwd, merge.before);
|
|
39
39
|
}
|
package/dist/github.mjs
CHANGED
|
@@ -61,10 +61,18 @@ export async function canWrite(repo, login) {
|
|
|
61
61
|
throw error;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
const REPOSITORY_SLUG = '(.repository_url | split("/") | .[-2:] | join("/"))';
|
|
64
65
|
export async function openBlockers(repo, issue) {
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const raw = await ghApi(repo, `issues/${issue}/dependencies/blocked_by`, `.[] | select(.state == "open") | ${REPOSITORY_SLUG} + "#" + (.number | tostring)`, { paginate: true });
|
|
67
|
+
const refs = lines(raw);
|
|
68
|
+
const prefixes = [`${slug(repo)}#`.toLowerCase()];
|
|
69
|
+
if (refs.some((ref) => !ref.toLowerCase().startsWith(prefixes[0]))) {
|
|
70
|
+
prefixes.push(`${await ghApi(repo, `issues/${issue}`, REPOSITORY_SLUG)}#`.toLowerCase());
|
|
71
|
+
}
|
|
72
|
+
return refs.map((ref) => {
|
|
73
|
+
const prefix = prefixes.find((candidate) => ref.toLowerCase().startsWith(candidate));
|
|
74
|
+
return prefix === undefined ? ref : ref.slice(prefix.length - 1);
|
|
75
|
+
});
|
|
68
76
|
}
|
|
69
77
|
export async function reopenIssue(repo, issue) {
|
|
70
78
|
await gh(repo, ['issue', 'reopen', String(issue)]);
|
package/dist/hunt.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
4
4
|
import { REVIEWING } from './agents.mjs';
|
|
5
5
|
import { minutesToMs } from './durations.mjs';
|
|
6
6
|
import { readTextIfPresent } from './files.mjs';
|
|
7
|
+
import { slug } from './gh.mjs';
|
|
7
8
|
import { git, gitFetch, remoteRef } from './git.mjs';
|
|
8
9
|
import { oneAtATime } from './lock.mjs';
|
|
9
10
|
import { huntPrompt } from './prompts.mjs';
|
|
@@ -25,6 +26,10 @@ export async function huntWorktree(repo, base, remote) {
|
|
|
25
26
|
}
|
|
26
27
|
return path;
|
|
27
28
|
}
|
|
29
|
+
function isIssueOf(repo, url) {
|
|
30
|
+
const issue = /^https:\/\/github\.com\/([^/]+\/[^/]+)\/issues\/\d+\/?$/i.exec(url);
|
|
31
|
+
return issue?.[1]?.toLowerCase() === slug(repo).toLowerCase();
|
|
32
|
+
}
|
|
28
33
|
export async function hunt(context, count) {
|
|
29
34
|
const { repo, config, base, recorder, ports } = context;
|
|
30
35
|
return recorder.step('hunt', {}, async () => {
|
|
@@ -38,13 +43,13 @@ export async function hunt(context, count) {
|
|
|
38
43
|
const result = await ports.runAgent(recorder, {
|
|
39
44
|
name: 'hunter',
|
|
40
45
|
cwd,
|
|
41
|
-
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt, count),
|
|
46
|
+
prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt, count, slug(repo)),
|
|
42
47
|
profile: REVIEWING,
|
|
43
48
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
44
49
|
});
|
|
45
50
|
const urls = [...result.text.matchAll(FILED)]
|
|
46
51
|
.map((match) => match[1])
|
|
47
|
-
.filter((url) =>
|
|
52
|
+
.filter((url) => isIssueOf(repo, url));
|
|
48
53
|
for (const url of urls.length === 0 ? ['none'] : urls) {
|
|
49
54
|
recorder.event('hunt.issue', { url }, 'quiet');
|
|
50
55
|
}
|
package/dist/pending.mjs
CHANGED
|
@@ -38,7 +38,7 @@ async function savedIssue(context, number) {
|
|
|
38
38
|
catch (error) {
|
|
39
39
|
context.recorder
|
|
40
40
|
.scope({ issue: number })
|
|
41
|
-
.event('issue.
|
|
41
|
+
.event('issue.unreadable', { error: message(error) }, 'quiet');
|
|
42
42
|
return { open: false };
|
|
43
43
|
}
|
|
44
44
|
}
|
package/dist/prompts.mjs
CHANGED
|
@@ -164,7 +164,7 @@ const HUNT_DEFAULT = [
|
|
|
164
164
|
'Read the whole repository and look for bugs: wrong results, unhandled errors, races, security holes and documentation that contradicts the code.',
|
|
165
165
|
'Prove each finding from the code. A guess is not a finding.',
|
|
166
166
|
].join('\n');
|
|
167
|
-
export function huntPrompt(instructions, ready, source, count) {
|
|
167
|
+
export function huntPrompt(instructions, ready, source, count, repository) {
|
|
168
168
|
const issues = count === 1 ? '1 issue' : `${count} issues`;
|
|
169
169
|
const kept = instructions?.trim() ?? '';
|
|
170
170
|
const label = [ready, source]
|
|
@@ -178,8 +178,8 @@ export function huntPrompt(instructions, ready, source, count) {
|
|
|
178
178
|
[
|
|
179
179
|
'Run no test suite and no build. Change no file. Do not commit or push.',
|
|
180
180
|
`File up to ${issues}, your most serious findings first. File nothing when you find no real problem.`,
|
|
181
|
-
|
|
182
|
-
`File each issue with \`gh issue create${label} --title "<conventional commit subject>" --body-file -\`.`,
|
|
181
|
+
`Before you file an issue, search the open and closed issues for a duplicate, for example with \`gh issue list --repo ${repository} --state all --search "<words>"\`. Do not file a finding when a duplicate exists.`,
|
|
182
|
+
`File each issue with \`gh issue create --repo ${repository}${label} --title "<conventional commit subject>" --body-file -\`.`,
|
|
183
183
|
`The body holds these sections as \`##\` headings, in this order: ${ISSUE_SECTIONS.map((section) => `\`## ${section}\``).join(', ')}.`,
|
|
184
184
|
'Give the file and line of each piece of evidence. Leave the Open questions section empty.',
|
|
185
185
|
'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.',
|