next-issue 6.6.65 → 6.6.67

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 CHANGED
@@ -257,7 +257,12 @@ and comments the reason on the issue, when:
257
257
  end. It halts this way even when the hand-over fails; the issue then ends
258
258
  in error with both the reason and the hand-over error;
259
259
  - an agent does not finish in `agentTimeoutMinutes`;
260
- - the setup command fails, or does not finish in `setupTimeoutMinutes`;
260
+ - the setup command fails, or does not finish in `setupTimeoutMinutes`. On a
261
+ resume whose state holds a landed commit, or a push or revert that may have
262
+ reached the base, the setup runs before the harness checks the base, so it
263
+ then also halts the run, with the commits and state kept for the next run.
264
+ The comment says what may be on the base and that its checks were not
265
+ awaited;
261
266
  - a step of the run fails with an error. A `gh` call that is safe to repeat,
262
267
  such as a read or a label edit, is tried up to three times first when the
263
268
  network fails. A `gh issue comment` is
@@ -390,6 +395,11 @@ Three levels of console output:
390
395
 
391
396
  - Node 24 or later
392
397
  - `gh`, authenticated with write access to the repository
398
+ - a `remote` on GitHub: `github.com`, or a GitHub Enterprise host. Every `gh`
399
+ call names the host of the remote url (`--repo <host>/<owner>/<name>`,
400
+ `gh api --hostname <host>`) when it is not `github.com`, so `gh` must be
401
+ logged in to that host. For an ssh url the harness reads the real host of an
402
+ ssh alias with `ssh -G`. Other hosts, such as GitLab, are not supported.
393
403
  - pi, logged in to a model provider. The agents use the model, the thinking
394
404
  level, the extensions and the skills from your pi settings, except the
395
405
  extension and the skills of `pi-next-issue`. The implementer and the fixer
@@ -624,7 +634,7 @@ With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the
624
634
 
625
635
  - 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;
626
636
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
627
- - 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;
637
+ - 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;
628
638
  - runs no test suite and changes no file. It gets the tools of the reviewer.
629
639
 
630
640
  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/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', slug(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.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
- /^git@[^:]+:(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?$/,
6
- /^ssh:\/\/[^/]+\/(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?$/,
7
- /^https?:\/\/[^/]+\/(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?$/,
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 { owner: match.groups.owner, name: match.groups.name };
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', slug(repo), '--json', 'defaultBranchRef']);
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 { slug } from './gh.mjs';
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: slug(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
- return /^https:\/\/github\.com\/([^/]+\/[^/]+)\/issues\/\d+\/?$/i.exec(url)?.[1]?.toLowerCase();
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, slug(repo)), false),
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, slug, viewJson } from './gh.mjs';
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(slug(repo));
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(slug(repo));
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 = slug(repo);
47
+ const repoSlug = repoArg(repo);
48
48
  const cached = KNOWN_LABELS.get(repoSlug);
49
49
  if (cached !== undefined) {
50
50
  return cached;
@@ -21,7 +21,25 @@ export async function setUp(job) {
21
21
  async function setupFailed(job, setup) {
22
22
  const late = setup.timedOut === true;
23
23
  job.log.event('setup.fail', { code: setup.code, timedOut: late, stderr: keepTail(setup.stderr.trim(), 2000) }, 'quiet');
24
- return escalateAndFinish(job, late
24
+ const unsettled = unsettledBase(job);
25
+ if (unsettled !== '') {
26
+ job.mainBroken = true;
27
+ }
28
+ const note = late
25
29
  ? `The setup command did not finish in ${job.context.config.setupTimeoutMinutes} minutes.`
26
- : 'The setup command failed in the worktree.', late ? 'setup timeout' : 'setup failed');
30
+ : 'The setup command failed in the worktree.';
31
+ return escalateAndFinish(job, `${note}${unsettled}`, late ? 'setup timeout' : 'setup failed');
32
+ }
33
+ function unsettledBase(job) {
34
+ const { landed, pushing, reverting } = job.state;
35
+ const base = `\`${job.context.base}\``;
36
+ const held = [
37
+ (landed ?? []).length > 0 ? `a landed commit is on ${base}` : '',
38
+ pushing === undefined ? '' : `a push may be on ${base}`,
39
+ reverting === undefined ? '' : `a revert may be on ${base}`,
40
+ ].filter((part) => part !== '');
41
+ if (held.length === 0) {
42
+ return '';
43
+ }
44
+ return ` This resume ran the setup before it checked the base: ${held.join(', ')}, and its checks were not awaited. The run halts, and the next run checks the base again.`;
27
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.65",
3
+ "version": "6.6.67",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",