next-issue 6.4.0 → 6.5.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
@@ -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:
@@ -526,10 +526,10 @@ With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the
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;
529
- - files one issue, for its most serious finding, 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;
529
+ - 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;
530
530
  - runs no test suite and changes no file. It gets the tools of the reviewer.
531
531
 
532
- The hunter ends its reply with an `issue:` line, and the run log holds it as a `hunt.issue` event with the `url`, or `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 an issue. The next pass claims the new issue 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.
532
+ 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, and 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.
533
533
 
534
534
  ## Worker
535
535
 
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
@@ -10,7 +10,7 @@ import { huntPrompt } from './prompts.mjs';
10
10
  import { skipReason } from './skip.mjs';
11
11
  import { WORKTREE_DIR } from './worktree.mjs';
12
12
  export const HUNT_FILE = 'next-issue.hunt.md';
13
- const FILED = /^issue:\s*(\S+)\s*$/m;
13
+ 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);
@@ -24,7 +24,7 @@ export async function huntWorktree(repo, base, remote) {
24
24
  }
25
25
  return path;
26
26
  }
27
- export async function hunt(context) {
27
+ export async function hunt(context, count) {
28
28
  const { repo, config, base, recorder, ports } = context;
29
29
  return recorder.step('hunt', {}, async () => {
30
30
  const cwd = await oneAtATime(repo.root, () => ports.huntWorktree(repo, base, config.remote));
@@ -33,13 +33,17 @@ export async function hunt(context) {
33
33
  const result = await ports.runAgent(recorder, {
34
34
  name: 'hunter',
35
35
  cwd,
36
- prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt),
36
+ prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt, count),
37
37
  profile: REVIEWING,
38
38
  timeoutMs: minutesToMs(config.agentTimeoutMinutes),
39
39
  });
40
- const url = FILED.exec(result.text)?.[1] ?? 'none';
41
- recorder.event('hunt.issue', { url }, 'quiet');
42
- return /^https?:\/\//.test(url);
40
+ const urls = [...result.text.matchAll(FILED)]
41
+ .map((match) => match[1])
42
+ .filter((url) => /^https?:\/\//.test(url));
43
+ for (const url of urls.length === 0 ? ['none'] : urls) {
44
+ recorder.event('hunt.issue', { url }, 'quiet');
45
+ }
46
+ return urls.length > 0;
43
47
  });
44
48
  }
45
49
  export function hunter(context) {
@@ -54,10 +58,10 @@ export function hunter(context) {
54
58
  const blockers = await Promise.all(open.map((issue) => ports.openBlockers(repo, issue.number)));
55
59
  return open.filter((_issue, index) => blockers[index].length === 0);
56
60
  },
57
- hunt: async () => {
61
+ hunt: async (count) => {
58
62
  hunting = true;
59
63
  try {
60
- return await hunt(context);
64
+ return await hunt(context, count);
61
65
  }
62
66
  catch {
63
67
  return false;
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/prompts.mjs CHANGED
@@ -163,24 +163,25 @@ const HUNT_DEFAULT = [
163
163
  'Read the whole repository and look for bugs: wrong results, unhandled errors, races, security holes and documentation that contradicts the code.',
164
164
  'Prove each finding from the code. A guess is not a finding.',
165
165
  ].join('\n');
166
- export function huntPrompt(instructions, ready, source) {
166
+ export function huntPrompt(instructions, ready, source, count) {
167
+ const issues = count === 1 ? '1 issue' : `${count} issues`;
167
168
  const kept = instructions?.trim() ?? '';
168
169
  const label = [ready, source]
169
170
  .filter((name) => name !== '')
170
171
  .map((name) => ` --label "${name}"`)
171
172
  .join('');
172
173
  return paragraphs([
173
- 'You are the hunter. Find the most serious problem in this repository and file one issue for it.',
174
+ `You are the hunter. Find the most serious problems in this repository and file up to ${issues} for them.`,
174
175
  `## Instructions\n${kept === '' ? HUNT_DEFAULT : kept}`,
175
176
  '## Rules',
176
177
  [
177
178
  'Run no test suite and no build. Change no file. Do not commit or push.',
178
- 'File one issue only, for your most serious finding. File nothing when you find no real problem.',
179
- 'Before you file it, search the open and closed issues for a duplicate, for example with `gh issue list --state all --search "<words>"`. File nothing when a duplicate exists.',
180
- `File it with \`gh issue create${label} --title "<conventional commit subject>" --body-file -\`.`,
179
+ `File up to ${issues}, your most serious findings first. File nothing when you find no real problem.`,
180
+ 'Before you file an issue, search the open and closed issues for a duplicate, for example with `gh issue list --state all --search "<words>"`. Do not file a finding when a duplicate exists.',
181
+ `File each issue with \`gh issue create${label} --title "<conventional commit subject>" --body-file -\`.`,
181
182
  `The body holds these sections as \`##\` headings, in this order: ${ISSUE_SECTIONS.map((section) => `\`## ${section}\``).join(', ')}.`,
182
183
  'Give the file and line of each piece of evidence. Leave the Open questions section empty.',
183
- 'End your final message with one line in the form `issue: <url of the new issue>`, or `issue: none` when you filed nothing.',
184
+ 'End your final message with one line in the form `issue: <url>` for each issue you filed, or one `issue: none` line when you filed nothing.',
184
185
  ].join('\n'),
185
186
  ]);
186
187
  }
package/dist/watch.mjs CHANGED
@@ -53,7 +53,7 @@ async function huntIssues(hunter, running, claims, stopped, signal) {
53
53
  claims.take();
54
54
  const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
55
55
  if (waiting !== undefined && waiting < hunter.cap) {
56
- if (await hunter.hunt()) {
56
+ if (await hunter.hunt(hunter.cap - waiting)) {
57
57
  step = 0;
58
58
  continue;
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.4.0",
3
+ "version": "6.5.1",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",