next-issue 6.3.3 → 6.3.5

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,14 +522,14 @@ 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 succeeds. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing does not stop the next one. 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, 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. 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;
529
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;
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 that repeats waits 1, 2, 3, 5, 10, then 10 minutes, and the back-off goes back to 1 minute after a hunt that succeeds. 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
+ 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.
533
533
 
534
534
  ## Worker
535
535
 
package/dist/hunt.mjs CHANGED
@@ -26,7 +26,7 @@ export async function huntWorktree(repo, base, remote) {
26
26
  }
27
27
  export async function hunt(context) {
28
28
  const { repo, config, base, recorder, ports } = context;
29
- await recorder.step('hunt', {}, async () => {
29
+ return recorder.step('hunt', {}, async () => {
30
30
  const cwd = await oneAtATime(repo.root, () => ports.huntWorktree(repo, base, config.remote));
31
31
  await ports.ensureLabel(repo, config.labels.hunt);
32
32
  const instructions = await readTextIfPresent(join(repo.root, HUNT_FILE));
@@ -37,7 +37,9 @@ export async function hunt(context) {
37
37
  profile: REVIEWING,
38
38
  timeoutMs: minutesToMs(config.agentTimeoutMinutes),
39
39
  });
40
- recorder.event('hunt.issue', { url: FILED.exec(result.text)?.[1] ?? 'none' }, 'quiet');
40
+ const url = FILED.exec(result.text)?.[1] ?? 'none';
41
+ recorder.event('hunt.issue', { url }, 'quiet');
42
+ return /^https?:\/\//.test(url);
41
43
  });
42
44
  }
43
45
  export function hunter(context) {
@@ -55,8 +57,7 @@ export function hunter(context) {
55
57
  hunt: async () => {
56
58
  hunting = true;
57
59
  try {
58
- await hunt(context);
59
- return true;
60
+ return await hunt(context);
60
61
  }
61
62
  catch {
62
63
  return false;
package/dist/serve.mjs CHANGED
@@ -105,9 +105,19 @@ export async function startWorker(options) {
105
105
  socket.on('close', closeWhenIdle);
106
106
  socket.on('message', (data) => {
107
107
  const value = parseMessage(String(data));
108
- if (value !== undefined) {
108
+ if (value === undefined) {
109
+ return;
110
+ }
111
+ try {
109
112
  receive(socket, value);
110
113
  }
114
+ catch (error) {
115
+ send(socket, {
116
+ type: 'error',
117
+ root: value.type === 'hello' ? options.root : value.root,
118
+ message: message(error),
119
+ });
120
+ }
111
121
  });
112
122
  });
113
123
  await listen(server, options.socketPath);
@@ -1,13 +1,36 @@
1
1
  import { rm } from 'node:fs/promises';
2
2
  import { send } from './questions.mjs';
3
3
  import { runsMessage } from './worker-run.mjs';
4
+ function isRecord(value) {
5
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ }
7
+ function isStringArray(value) {
8
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
9
+ }
10
+ function isClientMessage(value) {
11
+ if (!isRecord(value) || typeof value['type'] !== 'string') {
12
+ return false;
13
+ }
14
+ if (value['type'] === 'hello') {
15
+ return true;
16
+ }
17
+ if (typeof value['root'] !== 'string') {
18
+ return false;
19
+ }
20
+ if (value['type'] === 'questions') {
21
+ return value['id'] === undefined || typeof value['id'] === 'string';
22
+ }
23
+ return value['type'] !== 'start' || value['args'] === undefined || isStringArray(value['args']);
24
+ }
4
25
  export function parseMessage(text) {
26
+ let value;
5
27
  try {
6
- return JSON.parse(text);
28
+ value = JSON.parse(text);
7
29
  }
8
30
  catch {
9
31
  return undefined;
10
32
  }
33
+ return isClientMessage(value) ? value : undefined;
11
34
  }
12
35
  export function broadcast(sockets, runs) {
13
36
  const value = runsMessage(runs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.3.3",
3
+ "version": "6.3.5",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",