next-issue 6.6.14 → 6.6.16

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
@@ -534,7 +534,7 @@ The watch stops:
534
534
 
535
535
  ## Hunt for bugs
536
536
 
537
- 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:
537
+ 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:
538
538
 
539
539
  - works in its own worktree at `.worktrees/hunt`, at the remote base branch, which the harness fetches and resets before each hunt;
540
540
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
package/dist/gate.mjs CHANGED
@@ -5,7 +5,7 @@ import { asError, message } from './errors.mjs';
5
5
  import { escalateCheckFix, fixRound } from './fix.mjs';
6
6
  import { escalateAndFinish } from './handover.mjs';
7
7
  import { GATE_FIXED, GATE_PASSED } from './job.mjs';
8
- import { revert } from './revert.mjs';
8
+ import { revertOrReport, sentence } from './revert.mjs';
9
9
  import { writeState } from './state.mjs';
10
10
  export async function checkGate(job, sha) {
11
11
  const { base } = job.context;
@@ -82,18 +82,3 @@ export async function escalateError(job, error, note, reason) {
82
82
  const reverted = await revertOrReport(job);
83
83
  return escalateAndFinish(job, `${note}: ${sentence(message(error))}${reverted}`, reason);
84
84
  }
85
- async function revertOrReport(job) {
86
- try {
87
- return await revert(job);
88
- }
89
- catch (error) {
90
- if (runStopped()) {
91
- throw error;
92
- }
93
- job.repairing = false;
94
- return ` The revert of the change on ${job.context.base} failed: ${sentence(message(error))} The landed commits stay on ${job.context.base}.`;
95
- }
96
- }
97
- function sentence(text) {
98
- return text.endsWith('.') ? text : `${text}.`;
99
- }
package/dist/hunt.mjs CHANGED
@@ -53,8 +53,8 @@ export function hunter(context) {
53
53
  let hunting = false;
54
54
  return {
55
55
  cap: config.huntCap,
56
- ready: async (running) => {
57
- const open = (await ports.openIssues(repo, config.issueLimit, labels)).filter((issue) => skipReason(issue, config, false) === undefined);
56
+ ready: async (running, failed) => {
57
+ const open = (await ports.openIssues(repo, config.issueLimit, labels)).filter((issue) => !failed.has(issue.number) && skipReason(issue, config, false) === undefined);
58
58
  const claimable = new Set(open.map((issue) => issue.number));
59
59
  const blockers = await Promise.all(open.map((issue) => ports.openBlockers(repo, issue.number)));
60
60
  return open.filter((_issue, index) => blockers[index].every((blocker) => {
package/dist/revert.mjs CHANGED
@@ -1,10 +1,27 @@
1
+ import { runStopped } from './children.mjs';
2
+ import { message } from './errors.mjs';
1
3
  import { writeState } from './state.mjs';
2
4
  export async function revertFailedFix(job) {
3
5
  if (!job.repairing || (job.state.landed ?? []).length === 0) {
4
6
  return '';
5
7
  }
6
8
  job.repairing = false;
7
- return revert(job);
9
+ return revertOrReport(job);
10
+ }
11
+ export async function revertOrReport(job) {
12
+ try {
13
+ return await revert(job);
14
+ }
15
+ catch (error) {
16
+ if (runStopped()) {
17
+ throw error;
18
+ }
19
+ job.repairing = false;
20
+ return ` The revert of the change on ${job.context.base} failed: ${sentence(message(error))} The landed commits stay on ${job.context.base}.`;
21
+ }
22
+ }
23
+ export function sentence(text) {
24
+ return text.endsWith('.') ? text : `${text}.`;
8
25
  }
9
26
  export async function revert(job) {
10
27
  const { context, issue, log, state, branch, worktree } = job;
package/dist/watch.mjs CHANGED
@@ -2,13 +2,14 @@ import { handled, runIssues } from './loop.mjs';
2
2
  const BACK_OFF_MINUTES = [1, 2, 3, 5, 10];
3
3
  export async function watchIssues(args, watch) {
4
4
  const running = new Set();
5
+ const failed = new Set();
5
6
  const ended = new AbortController();
6
7
  const claims = claimAlarm();
7
8
  const hunting = watch.hunter === undefined
8
9
  ? undefined
9
- : huntIssues(watch.hunter, running, claims, () => ended.signal.aborted || watch.stop(), ended.signal);
10
+ : huntIssues(watch.hunter, running, failed, claims, () => ended.signal.aborted || watch.stop(), ended.signal);
10
11
  try {
11
- return await watchPasses(args, {
12
+ return await watchPasses(args, failed, {
12
13
  ...watch,
13
14
  process: async (issue) => {
14
15
  running.add(issue.number);
@@ -45,10 +46,10 @@ function claimAlarm() {
45
46
  },
46
47
  };
47
48
  }
48
- async function huntIssues(hunter, running, claims, stopped, signal) {
49
+ async function huntIssues(hunter, running, failed, claims, stopped, signal) {
49
50
  let step = 0;
50
51
  while (!stopped()) {
51
- const ready = await hunter.ready(running).catch(() => undefined);
52
+ const ready = await hunter.ready(running, failed).catch(() => undefined);
52
53
  claims.take();
53
54
  const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
54
55
  if (waiting !== undefined && waiting < hunter.cap) {
@@ -66,10 +67,9 @@ async function huntIssues(hunter, running, claims, stopped, signal) {
66
67
  }
67
68
  }
68
69
  }
69
- async function watchPasses(args, watch) {
70
+ async function watchPasses(args, failed, watch) {
70
71
  const limit = args.once ? 1 : args.max;
71
72
  const reports = [];
72
- const failed = new Set();
73
73
  let step = 0;
74
74
  for (;;) {
75
75
  const pass = await runIssues({ once: false, max: limit === undefined ? undefined : limit - handled(reports) }, watch, new Set(failed));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.14",
3
+ "version": "6.6.16",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",