next-issue 6.6.22 → 6.6.24

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
@@ -552,7 +552,7 @@ The watch stops:
552
552
 
553
553
  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. 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. 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:
554
554
 
555
- - works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
555
+ - 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;
556
556
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
557
557
  - 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, and the harness creates it before the hunt when it is missing. It files nothing when it finds no real problem or a duplicate exists;
558
558
  - runs no test suite and changes no file. It gets the tools of the reviewer.
@@ -670,13 +670,18 @@ major. Any other type releases nothing.
670
670
  The workflow then gives `next-issue` and `@ravshansbox/pi-next-issue` the same
671
671
  new version and publishes both packages to npm with a
672
672
  [trusted publish](https://docs.npmjs.com/trusted-publishers), so no token is
673
- stored. Only after the publish does it push the tag and make the GitHub release,
674
- so a failed publish leaves no half-release behind. npm makes a new version
675
- live a few minutes after the publish, and not always in the order it got them,
676
- so before it publishes, the job waits until npm serves both packages at the
677
- version of the last tag, for up to 10 minutes. Thus a new version never goes
678
- live before the one that came before it. A manual run of the workflow checks
679
- out the last tag and publishes that commit under the tag version, and
680
- changes nothing else. This repairs a release that reached GitHub but not npm.
673
+ stored. It pushes the tag before the publish and makes the GitHub release after
674
+ it, so the next release always counts from the new tag and never tries to
675
+ publish a version that npm already holds. npm makes a new version live a few
676
+ minutes after the publish, and not always in the order it got them, so before
677
+ it publishes, the job waits until npm serves both packages at the version of the
678
+ last tag, for up to 10 minutes. Thus a new version never goes live before the
679
+ one that came before it. Every run first repairs the last tag: from a checkout
680
+ of that tag it publishes each package that npm does not serve at the tag
681
+ version, and makes the GitHub release if it is missing. A package that npm
682
+ refuses as a version it already holds, but does not serve yet, counts as
683
+ published. So when a step fails after the tag push, the next run finishes that
684
+ release before it makes a new one. To repair a release without a new commit,
685
+ run the workflow by hand; a manual run does nothing else.
681
686
  The release job stays on a GitHub runner, because npm takes provenance only
682
687
  from a GitHub runner.
package/dist/hunt.mjs CHANGED
@@ -4,20 +4,21 @@ 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, gitFetch, remoteRef, resetHard } from './git.mjs';
7
+ import { git, gitFetch, remoteRef } from './git.mjs';
8
8
  import { oneAtATime } from './lock.mjs';
9
9
  import { huntPrompt } from './prompts.mjs';
10
10
  import { skipReason } from './skip.mjs';
11
- import { WORKTREE_DIR } from './worktree.mjs';
11
+ import { huntPath } from './worktree.mjs';
12
12
  export const HUNT_FILE = 'next-issue.hunt.md';
13
13
  const FILED = /^issue:\s*(\S+)\s*$/gm;
14
14
  export async function huntWorktree(repo, base, remote) {
15
- const path = join(repo.root, WORKTREE_DIR, 'hunt');
15
+ const path = huntPath(repo);
16
16
  const target = remoteRef(remote, base);
17
17
  await gitFetch(repo.root, [remote]);
18
18
  await git(repo.root, ['worktree', 'prune']);
19
19
  if (existsSync(join(path, '.git'))) {
20
- await resetHard(path, target);
20
+ await git(path, ['checkout', '--force', '--detach', target]);
21
+ await git(path, ['clean', '-fd']);
21
22
  }
22
23
  else {
23
24
  await git(repo.root, ['worktree', 'add', '--detach', path, target]);
package/dist/worktree.mjs CHANGED
@@ -1,6 +1,10 @@
1
+ import { realpath } from 'node:fs/promises';
1
2
  import { join } from 'node:path';
2
3
  import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, succeeds, } from './git.mjs';
3
4
  export const WORKTREE_DIR = '.worktrees';
5
+ export function huntPath(repo) {
6
+ return join(repo.root, WORKTREE_DIR, 'hunt');
7
+ }
4
8
  function worktreePath(repo, issue) {
5
9
  return join(repo.root, WORKTREE_DIR, String(issue));
6
10
  }
@@ -9,6 +13,7 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
9
13
  const remoteBase = remoteRef(remote, base);
10
14
  const baseUpdated = await fastForwardBase(repo, base, remote);
11
15
  await git(repo.root, ['worktree', 'prune']);
16
+ await releaseFromHunt(repo, branch);
12
17
  const pushed = await hasBranch(repo, upstream, '--remotes');
13
18
  const existing = await findWorktree(repo, branch);
14
19
  const path = existing ?? worktreePath(repo, issue);
@@ -50,6 +55,20 @@ async function updateBase(repo, base, remote) {
50
55
  return oneFetchAtATime(() => succeeds(repo.root, args));
51
56
  }
52
57
  export async function findWorktree(repo, branch) {
58
+ const path = await holder(repo, branch);
59
+ return path !== undefined && (await isHunt(repo, path)) ? undefined : path;
60
+ }
61
+ async function releaseFromHunt(repo, branch) {
62
+ const path = await holder(repo, branch);
63
+ if (path !== undefined && (await isHunt(repo, path))) {
64
+ await git(path, ['checkout', '--detach']);
65
+ }
66
+ }
67
+ async function isHunt(repo, path) {
68
+ const real = (target) => realpath(target).catch(() => target);
69
+ return (await real(path)) === (await real(huntPath(repo)));
70
+ }
71
+ async function holder(repo, branch) {
53
72
  const list = await git(repo.root, ['worktree', 'list', '--porcelain']);
54
73
  const entry = list
55
74
  .split('\n\n')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.22",
3
+ "version": "6.6.24",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",