next-issue 6.5.1 → 6.6.1

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
@@ -522,7 +522,7 @@ The watch stops:
522
522
 
523
523
  ## Hunt for bugs
524
524
 
525
- With `--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, have no open blocker and are not running. 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, back to 1 minute after a hunt that files an issue. 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:
525
+ With `--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. 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. 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, back to 1 minute after a hunt that files an issue. 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:
526
526
 
527
527
  - works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
528
528
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
package/dist/git-land.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { fetchBase, git, remoteRef, revision, succeeds } from './git.mjs';
1
+ import { fetchBase, git, oneFetchAtATime, remoteRef, revision, succeeds } from './git.mjs';
2
2
  import { commitEverything } from './git-commit.mjs';
3
3
  export const PUSH_TRIES = 3;
4
4
  export async function squashOnto(cwd, base, remote, message) {
@@ -18,7 +18,7 @@ export async function squashOnto(cwd, base, remote, message) {
18
18
  return true;
19
19
  }
20
20
  export async function pushToBase(cwd, remote, base) {
21
- return succeeds(cwd, ['push', remote, `HEAD:refs/heads/${base}`]);
21
+ return oneFetchAtATime(() => succeeds(cwd, ['push', remote, `HEAD:refs/heads/${base}`]));
22
22
  }
23
23
  export async function revertOnBase(cwd, revert) {
24
24
  const { branch } = revert;
package/dist/git.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { must, optionalFlag, run, succeeded } from './exec.mjs';
2
+ import { oneAtATime } from './lock.mjs';
2
3
  import { lines } from './text.mjs';
3
4
  const REMOTE_PATTERNS = [
4
5
  /^git@[^:]+:(?<owner>[^/]+)\/(?<name>[^/]+?)(?:\.git)?$/,
@@ -64,12 +65,18 @@ export async function disputeBranches(repo, branch) {
64
65
  return lines(list);
65
66
  }
66
67
  export async function push(cwd, remote, branch, force = false) {
67
- await git(cwd, ['push', '-u', ...optionalFlag(force, '--force'), remote, branch]);
68
+ await oneFetchAtATime(() => git(cwd, ['push', '-u', ...optionalFlag(force, '--force'), remote, branch]));
68
69
  }
69
70
  export async function fetchBase(cwd, base, remote) {
70
- await git(cwd, ['fetch', remote, base]);
71
+ await gitFetch(cwd, [remote, base]);
71
72
  return remoteRef(remote, base);
72
73
  }
74
+ export function oneFetchAtATime(work) {
75
+ return oneAtATime('git fetch', work);
76
+ }
77
+ export function gitFetch(cwd, args) {
78
+ return oneFetchAtATime(() => git(cwd, ['fetch', ...args]));
79
+ }
73
80
  export async function resetToBase(cwd, base, remote) {
74
81
  const target = await fetchBase(cwd, base, remote);
75
82
  await git(cwd, ['reset', '--hard', target]);
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 { git, remoteRef, resetHard } from './git.mjs';
7
+ import { git, gitFetch, remoteRef, resetHard } from './git.mjs';
8
8
  import { oneAtATime } from './lock.mjs';
9
9
  import { huntPrompt } from './prompts.mjs';
10
10
  import { skipReason } from './skip.mjs';
@@ -14,7 +14,7 @@ const FILED = /^issue:\s*(\S+)\s*$/gm;
14
14
  export async function huntWorktree(repo, base, remote) {
15
15
  const path = join(repo.root, WORKTREE_DIR, 'hunt');
16
16
  const target = remoteRef(remote, base);
17
- await git(repo.root, ['fetch', remote]);
17
+ await gitFetch(repo.root, [remote]);
18
18
  await git(repo.root, ['worktree', 'prune']);
19
19
  if (existsSync(join(path, '.git'))) {
20
20
  await resetHard(path, target);
@@ -53,10 +53,14 @@ export function hunter(context) {
53
53
  let hunting = false;
54
54
  return {
55
55
  cap: config.huntCap,
56
- ready: async () => {
56
+ ready: async (running) => {
57
57
  const open = (await ports.openIssues(repo, config.issueLimit, labels)).filter((issue) => skipReason(issue, config, false) === undefined);
58
+ const claimable = new Set(open.map((issue) => issue.number));
58
59
  const blockers = await Promise.all(open.map((issue) => ports.openBlockers(repo, issue.number)));
59
- return open.filter((_issue, index) => blockers[index].length === 0);
60
+ return open.filter((_issue, index) => blockers[index].every((blocker) => {
61
+ const number = Number(/^#(\d+)$/.exec(blocker)?.[1]);
62
+ return running.has(number) || claimable.has(number);
63
+ }));
60
64
  },
61
65
  hunt: async (count) => {
62
66
  hunting = true;
package/dist/watch.mjs CHANGED
@@ -49,7 +49,7 @@ function claimAlarm() {
49
49
  async function huntIssues(hunter, running, claims, stopped, signal) {
50
50
  let step = 0;
51
51
  while (!stopped()) {
52
- const ready = await hunter.ready().catch(() => undefined);
52
+ const ready = await hunter.ready(running).catch(() => undefined);
53
53
  claims.take();
54
54
  const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
55
55
  if (waiting !== undefined && waiting < hunter.cap) {
package/dist/worktree.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { join } from 'node:path';
2
- import { currentBranch, discardChanges, git, isAncestor, remoteRef, succeeds, } from './git.mjs';
2
+ import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, succeeds, } from './git.mjs';
3
3
  export const WORKTREE_DIR = '.worktrees';
4
4
  function worktreePath(repo, issue) {
5
5
  return join(repo.root, WORKTREE_DIR, String(issue));
@@ -39,7 +39,7 @@ async function hasBranch(repo, name, ...flags) {
39
39
  return list.length > 0;
40
40
  }
41
41
  export async function fastForwardBase(repo, base, remote) {
42
- await git(repo.root, ['fetch', remote]);
42
+ await gitFetch(repo.root, [remote]);
43
43
  return updateBase(repo, base, remote);
44
44
  }
45
45
  async function updateBase(repo, base, remote) {
@@ -47,7 +47,7 @@ async function updateBase(repo, base, remote) {
47
47
  const args = (await currentBranch(repo.root)) === base
48
48
  ? ['merge', '--ff-only', remoteBase]
49
49
  : ['fetch', '.', `${remoteBase}:${base}`];
50
- return succeeds(repo.root, args);
50
+ return oneFetchAtATime(() => succeeds(repo.root, args));
51
51
  }
52
52
  export async function findWorktree(repo, branch) {
53
53
  const list = await git(repo.root, ['worktree', 'list', '--porcelain']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.5.1",
3
+ "version": "6.6.1",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",