next-issue 6.5.0 → 6.6.0

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
@@ -290,7 +290,7 @@ jq -r 'select(.kind=="usage") | [.issue,.role,.turns,.total] | @tsv' \
290
290
  then prints new events as the run adds them, until `Ctrl-C`. In a terminal it
291
291
  starts with the last events that fit the screen; in a pipe it starts with all
292
292
  of them. It stops when the reader of the pipe closes it; on Linux it notices
293
- this only at the next event. With `--json` it prints the raw JSON lines. This also shows a run of
293
+ this only at the next event. When the worker restarts and starts a new run log, `logs` prints the rest of the old one, then a line `— new run: <file name> —`, then every event of the new one. With `--json` it prints the raw JSON lines and no such line. This also shows a run of
294
294
  the worker, whose progress goes to no terminal.
295
295
 
296
296
  Three levels of console output:
@@ -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/cli.mjs CHANGED
@@ -63,7 +63,7 @@ async function logs(root, json) {
63
63
  return 1;
64
64
  }
65
65
  const tail = process.stdout.isTTY ? Math.max(1, (process.stdout.rows || 24) - 1) : undefined;
66
- return followLog(file, { json, tail }, (text) => write(process.stdout, text));
66
+ return followLog(root, file, { json, tail }, (text) => write(process.stdout, text));
67
67
  }
68
68
  async function init(root, force) {
69
69
  const exclude = await excludeFile(root);
package/dist/hunt.mjs CHANGED
@@ -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/logs.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { writeSync } from 'node:fs';
2
2
  import { open } from 'node:fs/promises';
3
- import { join } from 'node:path';
3
+ import { basename, join } from 'node:path';
4
4
  import { StringDecoder } from 'node:string_decoder';
5
5
  import { wakeableSleep } from './durations.mjs';
6
6
  import { hasCode } from './errors.mjs';
@@ -79,16 +79,18 @@ function listenForStop(stop) {
79
79
  process.stdout.off('error', stop);
80
80
  };
81
81
  }
82
- export async function followLog(file, options, print) {
83
- const handle = await open(file, 'r');
82
+ export async function followLog(root, start, options, print) {
83
+ let file = start;
84
+ let handle = await open(file, 'r');
84
85
  const control = stopper();
85
86
  const unlisten = listenForStop(control.stop);
86
- const decoder = new StringDecoder('utf8');
87
+ let decoder = new StringDecoder('utf8');
87
88
  let position = 0;
88
89
  let rest = '';
89
90
  let first = true;
90
91
  try {
91
92
  while (!control.stopped) {
93
+ const newest = await newestRunLog(root);
92
94
  const chunk = await readChunk(handle, position, decoder);
93
95
  position += chunk.bytesRead;
94
96
  rest += chunk.text;
@@ -105,6 +107,19 @@ export async function followLog(file, options, print) {
105
107
  if (control.stopped) {
106
108
  break;
107
109
  }
110
+ if (newest !== undefined && newest > file) {
111
+ const next = await open(newest, 'r');
112
+ await handle.close();
113
+ handle = next;
114
+ file = newest;
115
+ decoder = new StringDecoder('utf8');
116
+ position = 0;
117
+ rest = '';
118
+ if (!options.json) {
119
+ await print(`— new run: ${basename(file)} —\n`);
120
+ }
121
+ continue;
122
+ }
108
123
  await control.pause();
109
124
  }
110
125
  }
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",