next-issue 6.6.64 → 6.6.66
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 +17 -4
- package/dist/conflict.mjs +5 -1
- package/dist/gh.mjs +12 -1
- package/dist/git-merge.mjs +8 -2
- package/dist/git.mjs +20 -6
- package/dist/github.mjs +3 -3
- package/dist/hand-over-comments.mjs +2 -2
- package/dist/hunt.mjs +6 -5
- package/dist/labels.mjs +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,8 +88,11 @@ the run handles one issue. For each issue:
|
|
|
88
88
|
The budget is `maxCommitFixes`. Any other git failure in the commit stops
|
|
89
89
|
the run with an error. An implementer that makes no change hands the issue
|
|
90
90
|
to a person, unless the branch is already ahead of the base, for example
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
when an issue resumes from saved state in phase `claimed`, or when the remote
|
|
92
|
+
holds branch `<n>`: the run then carries on with the commits on the branch,
|
|
93
|
+
and the newest of them gives the subject of the landed commit. A lost state
|
|
94
|
+
file does not count, since an issue with no saved state resets its local
|
|
95
|
+
branch (step 3).
|
|
93
96
|
5. Let the reviewer agent judge the diff, at most `diffMaxChars` of it. The
|
|
94
97
|
reviewer reads files and runs commands in the worktree, so it can prove a
|
|
95
98
|
finding with the tests or the type check. The harness then throws away every
|
|
@@ -125,7 +128,12 @@ the run handles one issue. For each issue:
|
|
|
125
128
|
implementer's commit replaces it, and a fix for failed checks after the
|
|
126
129
|
landing lands under the fixer's own subject. The reapply commit after a
|
|
127
130
|
revert uses the subject of the change. When git merges the base cleanly,
|
|
128
|
-
no agent runs. When
|
|
131
|
+
no agent runs. When a conflicted file holds no conflict marker, for
|
|
132
|
+
example a file that one side deletes and the other changes, a renamed
|
|
133
|
+
file or a binary file that both sides change, no agent runs: the
|
|
134
|
+
harness undoes the merge and hands the issue to a person with the
|
|
135
|
+
reason `merge conflict`, since git leaves only one side in the file.
|
|
136
|
+
When git reports conflicted files, the fixer gets the
|
|
129
137
|
list from the check budget, `maxCiFixes`, removes the conflict markers,
|
|
130
138
|
and the harness commits the merge. A merge that the fixer commits itself
|
|
131
139
|
counts only when the branch then holds the base commit that was merged
|
|
@@ -382,6 +390,11 @@ Three levels of console output:
|
|
|
382
390
|
|
|
383
391
|
- Node 24 or later
|
|
384
392
|
- `gh`, authenticated with write access to the repository
|
|
393
|
+
- a `remote` on GitHub: `github.com`, or a GitHub Enterprise host. Every `gh`
|
|
394
|
+
call names the host of the remote url (`--repo <host>/<owner>/<name>`,
|
|
395
|
+
`gh api --hostname <host>`) when it is not `github.com`, so `gh` must be
|
|
396
|
+
logged in to that host. For an ssh url the harness reads the real host of an
|
|
397
|
+
ssh alias with `ssh -G`. Other hosts, such as GitLab, are not supported.
|
|
385
398
|
- pi, logged in to a model provider. The agents use the model, the thinking
|
|
386
399
|
level, the extensions and the skills from your pi settings, except the
|
|
387
400
|
extension and the skills of `pi-next-issue`. The implementer and the fixer
|
|
@@ -616,7 +629,7 @@ With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the
|
|
|
616
629
|
|
|
617
630
|
- 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;
|
|
618
631
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
619
|
-
- 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 compares label names without case, as GitHub does, so a label that exists in another case, such as `Source:Hunt`, counts as there and keeps its name. When the create fails, it reads the labels again, so a label that someone else created meanwhile counts as there too. It files nothing when it finds no real problem or a duplicate exists;
|
|
632
|
+
- 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`, with the host in front when it is not `github.com`, 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 compares label names without case, as GitHub does, so a label that exists in another case, such as `Source:Hunt`, counts as there and keeps its name. When the create fails, it reads the labels again, so a label that someone else created meanwhile counts as there too. It files nothing when it finds no real problem or a duplicate exists;
|
|
620
633
|
- runs no test suite and changes no file. It gets the tools of the reviewer.
|
|
621
634
|
|
|
622
635
|
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. When the `remote` url holds an old owner or name that GitHub redirects after a rename or transfer, the harness asks GitHub for the new one, so an issue url with the new name counts too. 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.
|
package/dist/conflict.mjs
CHANGED
|
@@ -8,9 +8,13 @@ export async function rebase(job) {
|
|
|
8
8
|
const { config, ports, base } = context;
|
|
9
9
|
const title = state.title ?? fallbackTitle(issue);
|
|
10
10
|
const before = await ports.revision(worktree);
|
|
11
|
-
const { target, files } = await log.step('rebase', { base }, () => ports.startMerge(worktree, base, config.remote));
|
|
11
|
+
const { target, files, unmarked } = 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
|
+
if (unmarked.length > 0) {
|
|
15
|
+
await ports.abortMerge(worktree, before);
|
|
16
|
+
return escalateAndFinish(job, `The change conflicts with ${base} in files that hold no conflict marker, such as a deleted, renamed or binary file: ${unmarked.join(', ')}.`, 'merge conflict');
|
|
17
|
+
}
|
|
14
18
|
const merged = await mergeBase(job, { before, target, files });
|
|
15
19
|
if (merged !== undefined) {
|
|
16
20
|
return merged;
|
package/dist/gh.mjs
CHANGED
|
@@ -4,9 +4,19 @@ import { errorMatches } from './errors.mjs';
|
|
|
4
4
|
import { must, optionalFlag, run } from './exec.mjs';
|
|
5
5
|
const NETWORK_TRIES = 3;
|
|
6
6
|
const NETWORK_FAULT = /unexpected EOF|connection reset|connection refused|i\/o timeout|TLS handshake timeout|HTTP 50[234]/i;
|
|
7
|
+
export const GITHUB_HOST = 'github.com';
|
|
7
8
|
export function slug(repo) {
|
|
8
9
|
return `${repo.owner}/${repo.name}`;
|
|
9
10
|
}
|
|
11
|
+
export function hostOf(repo) {
|
|
12
|
+
return repo.host ?? GITHUB_HOST;
|
|
13
|
+
}
|
|
14
|
+
export function repoArg(repo) {
|
|
15
|
+
return hostOf(repo) === GITHUB_HOST ? slug(repo) : `${hostOf(repo)}/${slug(repo)}`;
|
|
16
|
+
}
|
|
17
|
+
export function hostname(repo) {
|
|
18
|
+
return hostOf(repo) === GITHUB_HOST ? [] : ['--hostname', hostOf(repo)];
|
|
19
|
+
}
|
|
10
20
|
export async function repeatable(repo, args) {
|
|
11
21
|
for (let attempt = 1;; attempt += 1) {
|
|
12
22
|
try {
|
|
@@ -21,7 +31,7 @@ export async function repeatable(repo, args) {
|
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
33
|
function withRepo(repo, args) {
|
|
24
|
-
return [...args, '--repo',
|
|
34
|
+
return [...args, '--repo', repoArg(repo)];
|
|
25
35
|
}
|
|
26
36
|
export async function gh(repo, args) {
|
|
27
37
|
return repeatable(repo, withRepo(repo, args));
|
|
@@ -41,6 +51,7 @@ export async function ghRun(repo, args, options = {}) {
|
|
|
41
51
|
export async function ghApi(repo, path, jq, { paginate = false } = {}) {
|
|
42
52
|
return repeatable(repo, [
|
|
43
53
|
'api',
|
|
54
|
+
...hostname(repo),
|
|
44
55
|
...optionalFlag(paginate, '--paginate'),
|
|
45
56
|
`repos/${slug(repo)}/${path}`,
|
|
46
57
|
'--jq',
|
package/dist/git-merge.mjs
CHANGED
|
@@ -8,14 +8,20 @@ export async function startMerge(cwd, base, remote) {
|
|
|
8
8
|
const target = await git(cwd, ['rev-parse', await fetchBase(cwd, base, remote)]);
|
|
9
9
|
const result = await run('git', ['merge', '--no-ff', '--no-commit', target], { cwd });
|
|
10
10
|
if (succeeded(result)) {
|
|
11
|
-
return { target, files: (await merging(cwd)) ? [] : undefined };
|
|
11
|
+
return { target, files: (await merging(cwd)) ? [] : undefined, unmarked: [] };
|
|
12
12
|
}
|
|
13
13
|
const listed = await git(cwd, ['diff', '--name-only', '--diff-filter=U']);
|
|
14
14
|
const files = lines(listed);
|
|
15
15
|
if (files.length === 0) {
|
|
16
16
|
throw new Error(`git merge ${target} failed: ${result.stderr.trim()}`);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const unmarked = [];
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
if (!(await hasConflictMarkers(cwd, [file]))) {
|
|
21
|
+
unmarked.push(file);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { target, files, unmarked };
|
|
19
25
|
}
|
|
20
26
|
async function merging(cwd) {
|
|
21
27
|
return succeeds(cwd, ['rev-parse', '--quiet', '--verify', 'MERGE_HEAD']);
|
package/dist/git.mjs
CHANGED
|
@@ -2,19 +2,33 @@ import { must, optionalFlag, run, succeeded } from './exec.mjs';
|
|
|
2
2
|
import { oneAtATime } from './lock.mjs';
|
|
3
3
|
import { lines } from './text.mjs';
|
|
4
4
|
const REMOTE_PATTERNS = [
|
|
5
|
-
/^
|
|
6
|
-
/^ssh:\/\/[
|
|
7
|
-
/^https?:\/\/[
|
|
5
|
+
/^(?:[^@/:]+@)?(?<host>[^@/:]+):(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?\/?$/,
|
|
6
|
+
/^ssh:\/\/(?:[^@/]+@)?(?<host>[^@/:]+)(?::\d+)?\/(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?\/?$/,
|
|
7
|
+
/^https?:\/\/(?:[^@/]+@)?(?<host>[^@/:]+)(?::\d+)?\/(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?\/?$/,
|
|
8
8
|
];
|
|
9
9
|
export function parseRemote(url) {
|
|
10
10
|
for (const pattern of REMOTE_PATTERNS) {
|
|
11
11
|
const match = pattern.exec(url.trim());
|
|
12
12
|
if (match?.groups) {
|
|
13
|
-
return {
|
|
13
|
+
return {
|
|
14
|
+
host: match.groups.host.toLowerCase(),
|
|
15
|
+
owner: match.groups.owner,
|
|
16
|
+
name: match.groups.name,
|
|
17
|
+
};
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
throw new Error(`Cannot parse the git remote URL: ${url}`);
|
|
17
21
|
}
|
|
22
|
+
async function sshHost(url, host) {
|
|
23
|
+
if (host === 'github.com' || /^https?:/.test(url.trim())) {
|
|
24
|
+
return host;
|
|
25
|
+
}
|
|
26
|
+
const result = await run('ssh', ['-G', host]).catch(() => undefined);
|
|
27
|
+
const resolved = /^hostname[^\S\r\n]+(\S+)$/m.exec(result?.stdout ?? '')?.[1];
|
|
28
|
+
return result !== undefined && succeeded(result) && resolved !== undefined
|
|
29
|
+
? resolved.toLowerCase()
|
|
30
|
+
: host;
|
|
31
|
+
}
|
|
18
32
|
export async function repoRoot(cwd) {
|
|
19
33
|
const top = await git(cwd, ['rev-parse', '--show-toplevel']);
|
|
20
34
|
const list = await git(cwd, ['worktree', 'list', '--porcelain']);
|
|
@@ -24,8 +38,8 @@ export async function repoRoot(cwd) {
|
|
|
24
38
|
export async function detectRepo(cwd, remote) {
|
|
25
39
|
const root = await repoRoot(cwd);
|
|
26
40
|
const url = await git(cwd, ['remote', 'get-url', remote]);
|
|
27
|
-
const { owner, name } = parseRemote(url);
|
|
28
|
-
return { owner, name, root };
|
|
41
|
+
const { host, owner, name } = parseRemote(url);
|
|
42
|
+
return { host: await sshHost(url, host), owner, name, root };
|
|
29
43
|
}
|
|
30
44
|
export function remoteRef(remote, branch) {
|
|
31
45
|
return `${remote}/${branch}`;
|
package/dist/github.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { errorMatches, parseJson } from './errors.mjs';
|
|
2
|
-
import { gh, ghApi, ghJson, ghOnce, names, repeatable, slug, viewJson, } from './gh.mjs';
|
|
2
|
+
import { gh, ghApi, ghJson, ghOnce, hostname, names, repeatable, repoArg, slug, viewJson, } from './gh.mjs';
|
|
3
3
|
import { lines } from './text.mjs';
|
|
4
4
|
export async function defaultBranch(repo) {
|
|
5
|
-
const raw = await repeatable(repo, ['repo', 'view',
|
|
5
|
+
const raw = await repeatable(repo, ['repo', 'view', repoArg(repo), '--json', 'defaultBranchRef']);
|
|
6
6
|
return JSON.parse(raw).defaultBranchRef.name;
|
|
7
7
|
}
|
|
8
8
|
const ISSUE_FIELDS = 'number,title,body,createdAt,labels';
|
|
@@ -75,7 +75,7 @@ export async function openBlockers(repo, issue) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
export async function repositorySlug(repo) {
|
|
78
|
-
return repeatable(repo, ['api', `repos/${slug(repo)}`, '--jq', '.full_name']);
|
|
78
|
+
return repeatable(repo, ['api', ...hostname(repo), `repos/${slug(repo)}`, '--jq', '.full_name']);
|
|
79
79
|
}
|
|
80
80
|
export async function reopenIssue(repo, issue) {
|
|
81
81
|
await gh(repo, ['issue', 'reopen', String(issue)]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { repoArg } from './gh.mjs';
|
|
2
2
|
export const HAND_OVER = 'next-issue needs help:';
|
|
3
3
|
const HARNESS_HEADINGS = [HAND_OVER, '### Review:', '### Fixer:'];
|
|
4
4
|
function fromHarness(comment) {
|
|
@@ -70,7 +70,7 @@ async function waitingQuestion(repo, config, ports, writer, issue) {
|
|
|
70
70
|
title: issue.title,
|
|
71
71
|
reason: comment?.body.slice(HAND_OVER.length).trim() ?? '',
|
|
72
72
|
url: comment?.url ?? '',
|
|
73
|
-
repo:
|
|
73
|
+
repo: repoArg(repo),
|
|
74
74
|
labels: { needsHuman: config.labels.needsHuman, skip: config.labels.skip },
|
|
75
75
|
};
|
|
76
76
|
}
|
package/dist/hunt.mjs
CHANGED
|
@@ -4,7 +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
|
+
import { hostOf, repoArg, slug } from './gh.mjs';
|
|
8
8
|
import { git, gitFetch, remoteRef } from './git.mjs';
|
|
9
9
|
import { withNotes } from './job.mjs';
|
|
10
10
|
import { oneAtATime } from './lock.mjs';
|
|
@@ -27,12 +27,13 @@ export async function huntWorktree(repo, base, remote) {
|
|
|
27
27
|
}
|
|
28
28
|
return path;
|
|
29
29
|
}
|
|
30
|
-
function issueSlug(url) {
|
|
31
|
-
|
|
30
|
+
function issueSlug(url, host) {
|
|
31
|
+
const match = /^https:\/\/([^/]+)\/([^/]+\/[^/]+)\/issues\/\d+\/?$/i.exec(url);
|
|
32
|
+
return match?.[1]?.toLowerCase() === host ? match[2].toLowerCase() : undefined;
|
|
32
33
|
}
|
|
33
34
|
async function issuesOf(context, urls) {
|
|
34
35
|
const found = urls.flatMap((url) => {
|
|
35
|
-
const repository = issueSlug(url);
|
|
36
|
+
const repository = issueSlug(url, hostOf(context.repo));
|
|
36
37
|
return repository === undefined ? [] : [{ url, repository }];
|
|
37
38
|
});
|
|
38
39
|
const slugs = [slug(context.repo).toLowerCase()];
|
|
@@ -57,7 +58,7 @@ export async function hunt(context, count) {
|
|
|
57
58
|
const result = await ports.runAgent(recorder, {
|
|
58
59
|
name: 'hunter',
|
|
59
60
|
cwd,
|
|
60
|
-
prompt: await withNotes(repo.root, huntPrompt(instructions, config.labels.ready, config.labels.hunt, count,
|
|
61
|
+
prompt: await withNotes(repo.root, huntPrompt(instructions, config.labels.ready, config.labels.hunt, count, repoArg(repo)), false),
|
|
61
62
|
profile: REVIEWING,
|
|
62
63
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
63
64
|
});
|
package/dist/labels.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asError } from './errors.mjs';
|
|
2
|
-
import { gh, ghJson, ghOnce, names,
|
|
2
|
+
import { gh, ghJson, ghOnce, names, repoArg, viewJson } from './gh.mjs';
|
|
3
3
|
const KNOWN_LABELS = new Map();
|
|
4
4
|
async function labelsOf(repo, kind, number) {
|
|
5
5
|
const parsed = await viewJson(repo, kind, number, 'labels');
|
|
@@ -26,14 +26,14 @@ export async function setLabel(repo, kind, number, add, remove) {
|
|
|
26
26
|
export async function ensureLabel(repo, label) {
|
|
27
27
|
const created = await createUnknownLabel(repo, label);
|
|
28
28
|
if (created instanceof Error) {
|
|
29
|
-
KNOWN_LABELS.delete(
|
|
29
|
+
KNOWN_LABELS.delete(repoArg(repo));
|
|
30
30
|
if (!(await knownLabels(repo)).has(label.toLowerCase())) {
|
|
31
31
|
throw created;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
async function retryWithLabel(repo, args, label, error) {
|
|
36
|
-
KNOWN_LABELS.delete(
|
|
36
|
+
KNOWN_LABELS.delete(repoArg(repo));
|
|
37
37
|
const created = await createUnknownLabel(repo, label);
|
|
38
38
|
if (created === 'known') {
|
|
39
39
|
throw error;
|
|
@@ -44,7 +44,7 @@ async function retryWithLabel(repo, args, label, error) {
|
|
|
44
44
|
await gh(repo, args);
|
|
45
45
|
}
|
|
46
46
|
async function knownLabels(repo) {
|
|
47
|
-
const repoSlug =
|
|
47
|
+
const repoSlug = repoArg(repo);
|
|
48
48
|
const cached = KNOWN_LABELS.get(repoSlug);
|
|
49
49
|
if (cached !== undefined) {
|
|
50
50
|
return cached;
|