next-issue 14.9.0 → 16.0.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
@@ -36,7 +36,7 @@ Run the harness inside a git repository:
36
36
  npx -y next-issue@latest start
37
37
  ```
38
38
 
39
- Give an issue the `status:todo` label to have it picked up. See [Issue format](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#issue-format) for how to write one. Press `Ctrl-C` to stop the run, see [Stop a run](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#stop-a-run).
39
+ Give an issue the `status:todo` label to have it picked up. See [Issue format](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#issue-format) for how to write one. `start` exits once the run has started in the worker. Follow the run with `npx -y next-issue@latest logs` and stop it with `npx -y next-issue@latest stop`, see [Stop a run](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#stop-a-run).
40
40
 
41
41
  ### Skills for Claude Code
42
42
 
@@ -90,7 +90,6 @@ A field that is not in the file keeps its default. See [Configuration](https://g
90
90
  | `start` | Start a run: claim issues, fix them and push them to the base branch |
91
91
  | `watch on\|off` | Switch watching of the going run |
92
92
  | `hunt on\|off` | Switch hunting of the going run |
93
- | `refresh` | Ask the going run to check for new issues now |
94
93
  | `init` | Write the config file with the defaults |
95
94
  | `serve` | Run the worker of this repository that the clients talk to |
96
95
  | `stop` | Stop the going run after its current issues |
@@ -1,156 +1,25 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { NOTES, onPresses } from '../shared/interrupt.mjs';
3
- import { isNewer, } from '../shared/protocol.mjs';
4
- import { formatSummary } from '../shared/summary.mjs';
2
+ import { isNewer } from '../shared/protocol.mjs';
5
3
  import { packageVersion } from '../shared/version.mjs';
6
- import { CLOSED, going, reachWorker, rejoinRun, } from '../shared/worker-client.mjs';
4
+ import { going, reachWorker, startedRun } from '../shared/worker-client.mjs';
7
5
  const RUN_GOING = 'a run is going in this repository already';
8
- function output() {
9
- let queue = Promise.resolve();
10
- return {
11
- print: (stream, text) => {
12
- queue = queue.then(() => new Promise((resolve) => stream.write(text, () => resolve())));
13
- },
14
- flushed: () => queue,
15
- };
16
- }
17
- function firstNote(message) {
18
- if (!message.waiting) {
19
- return NOTES.issue;
20
- }
21
- return message.hunting ? NOTES.hunt : NOTES.wait;
22
- }
23
- export async function startInWorker(root, args, argv) {
6
+ const STARTED = 'next-issue: the run started in the worker; follow it with next-issue logs and stop it with next-issue stop\n';
7
+ export async function startInWorker(root, argv) {
24
8
  const version = await packageVersion();
25
9
  const connection = await reachWorker(root, version);
26
- if (going(connection.runs[root])) {
10
+ try {
11
+ if (going(connection.runs[root])) {
12
+ throw new Error(isNewer(version, connection.version)
13
+ ? `${RUN_GOING}; the worker updates to ${version} after the running issues`
14
+ : RUN_GOING);
15
+ }
16
+ const id = randomUUID();
17
+ const accepted = startedRun(connection, root, id);
18
+ connection.send({ type: 'start', root, args: argv, id });
19
+ await accepted;
20
+ return STARTED;
21
+ }
22
+ finally {
27
23
  connection.close();
28
- throw new Error(isNewer(version, connection.version)
29
- ? `${RUN_GOING}; the worker updates to ${version} after the running issues`
30
- : RUN_GOING);
31
24
  }
32
- const out = output();
33
- const code = await follow(connection, root, args, argv, out);
34
- await out.flushed();
35
- return code;
36
- }
37
- function follow(first, root, args, argv, out) {
38
- const id = randomUUID();
39
- const stopId = randomUUID();
40
- let connection = first;
41
- let latest;
42
- let upgradeEnd;
43
- let earlierCode = 0;
44
- const held = [];
45
- const send = (message) => {
46
- if (upgradeEnd === undefined) {
47
- connection.send(message);
48
- }
49
- else {
50
- held.push(message);
51
- }
52
- };
53
- return new Promise((resolve) => {
54
- const stopListening = onPresses((presses) => {
55
- if (presses === 1) {
56
- send({ type: 'stop', root, after: 'issue', id: stopId });
57
- }
58
- else if (presses === 2) {
59
- out.print(process.stderr, `${NOTES.round}\n`);
60
- send({ type: 'stop', root, after: 'round' });
61
- }
62
- else {
63
- send({ type: 'stop', root, after: 'now' });
64
- }
65
- });
66
- let settled = false;
67
- const settle = (code) => {
68
- if (!settled) {
69
- settled = true;
70
- stopListening();
71
- connection.close();
72
- resolve(Math.max(code, earlierCode));
73
- }
74
- };
75
- const fail = (text) => {
76
- if (!settled) {
77
- out.print(process.stderr, `next-issue failed: ${text}\n`);
78
- }
79
- settle(1);
80
- };
81
- const onMessage = (message) => {
82
- if (message.type === 'runs') {
83
- latest = message.runs[root];
84
- }
85
- if (!('root' in message) || message.root !== root) {
86
- return;
87
- }
88
- if (message.type === 'output') {
89
- out.print(process.stderr, message.text);
90
- }
91
- else if (message.type === 'pass') {
92
- out.print(process.stdout, formatSummary(message.summary));
93
- }
94
- else if (message.type === 'stopping' && message.id === stopId) {
95
- out.print(process.stderr, `${firstNote(message)}\n`);
96
- }
97
- else if (message.type === 'error' && message.id === id) {
98
- fail(message.message);
99
- }
100
- else if (message.type === 'end' && message.error !== undefined) {
101
- fail(message.error);
102
- }
103
- else if (message.type === 'end') {
104
- if (!args.watch && message.summary !== undefined) {
105
- out.print(process.stdout, formatSummary(message.summary));
106
- }
107
- if (latest?.upgrade === undefined) {
108
- settle(message.code);
109
- }
110
- else {
111
- upgradeEnd = message.code;
112
- }
113
- }
114
- };
115
- const rejoin = async (upgrade) => {
116
- const found = await rejoinRun(root).catch(() => undefined);
117
- if (found === undefined) {
118
- fail(`${CLOSED}, and the run did not go on in the newer worker`);
119
- return;
120
- }
121
- if (settled) {
122
- found.close();
123
- return;
124
- }
125
- out.print(process.stderr, `next-issue: the worker was updated from ${upgrade.from} to ${upgrade.to}\n`);
126
- earlierCode = Math.max(earlierCode, upgradeEnd ?? 0);
127
- upgradeEnd = undefined;
128
- latest = found.runs[root];
129
- follows(found);
130
- for (const message of held.splice(0)) {
131
- found.send(message);
132
- }
133
- };
134
- const closed = () => {
135
- if (upgradeEnd === undefined) {
136
- fail(CLOSED);
137
- }
138
- else if (latest?.error !== undefined) {
139
- fail(latest.error);
140
- }
141
- else if (latest?.upgrade === undefined) {
142
- settle(upgradeEnd);
143
- }
144
- else {
145
- void rejoin(latest.upgrade);
146
- }
147
- };
148
- const follows = (next) => {
149
- connection = next;
150
- next.listen(onMessage);
151
- void next.closed.then(closed);
152
- };
153
- follows(first);
154
- first.send({ type: 'start', root, args: argv, id });
155
- });
156
25
  }
@@ -16,25 +16,6 @@ export function switchInWorker(root, name, on) {
16
16
  return `next-issue: watching ${onOffText(progress.watching)}, hunting ${onOffText(progress.hunting)}\n`;
17
17
  });
18
18
  }
19
- export function refreshInWorker(root) {
20
- return inWorker(root, async (connection, progress) => {
21
- if (isNewer(await packageVersion(), connection.version)) {
22
- throw new Error('the worker of the going run is older than next-issue, so it cannot refresh. Stop the run, then start it again');
23
- }
24
- if (progress.status === 'stopping' && progress.upgrade !== undefined) {
25
- return 'next-issue: the run is stopping for an upgrade, so nothing was asked; it starts again on the newer worker and picks up new issues then\n';
26
- }
27
- if (progress.status === 'stopping') {
28
- return 'next-issue: the run is stopping, so nothing was asked\n';
29
- }
30
- if (progress.watching === false) {
31
- return 'next-issue: the run does not watch for new issues, so nothing was asked\n';
32
- }
33
- connection.send({ type: 'refresh', root });
34
- await connection.end();
35
- return 'next-issue: asked the run to check for new issues now\n';
36
- });
37
- }
38
19
  async function inWorker(root, act) {
39
20
  const connection = await findWorker(root);
40
21
  if (connection === undefined) {
package/dist/cli.mjs CHANGED
@@ -9,7 +9,7 @@ import { followLog, newestRunLog } from './cli/logs.mjs';
9
9
  import { serve } from './worker/serve.mjs';
10
10
  import { startInWorker } from './cli/start.mjs';
11
11
  import { STATE_DIR } from './shared/state.mjs';
12
- import { refreshInWorker, stopInWorker, switchInWorker } from './cli/switch-run.mjs';
12
+ import { stopInWorker, switchInWorker } from './cli/switch-run.mjs';
13
13
  import { chooseScope, installSkills } from './cli/update.mjs';
14
14
  import { WORKTREE_DIR } from './shared/worktree.mjs';
15
15
  function write(stream, text) {
@@ -44,10 +44,6 @@ async function main() {
44
44
  await write(process.stdout, await switchInWorker(root, args.command, args.on));
45
45
  return 0;
46
46
  }
47
- if (args.command === 'refresh') {
48
- await write(process.stdout, await refreshInWorker(root));
49
- return 0;
50
- }
51
47
  if (args.command === 'logs') {
52
48
  return logs(root);
53
49
  }
@@ -55,11 +51,8 @@ async function main() {
55
51
  if (args.command === 'serve') {
56
52
  return serve(root);
57
53
  }
58
- return run(root, args, argv);
59
- }
60
- function run(root, args, argv) {
61
- process.stderr.on('error', () => { });
62
- return startInWorker(root, args, argv.slice(1));
54
+ await write(process.stderr, await startInWorker(root, argv.slice(1)));
55
+ return 0;
63
56
  }
64
57
  async function logs(root) {
65
58
  const file = await newestRunLog(root);
@@ -7,17 +7,7 @@ const RUN_FLAGS = new Map([
7
7
  ['--watch', 'watch'],
8
8
  ['--hunt', 'hunt'],
9
9
  ]);
10
- const COMMANDS = [
11
- 'start',
12
- 'init',
13
- 'serve',
14
- 'stop',
15
- 'logs',
16
- 'watch',
17
- 'hunt',
18
- 'refresh',
19
- 'update',
20
- ];
10
+ const COMMANDS = ['start', 'init', 'serve', 'stop', 'logs', 'watch', 'hunt', 'update'];
21
11
  export const USAGE = `next-issue <command> [options]
22
12
 
23
13
  start start a run: claim issues, fix them and push them to the base branch
@@ -25,7 +15,6 @@ export const USAGE = `next-issue <command> [options]
25
15
  --hunt on|off hunt the repository for bugs and file issues alongside the issues, needs watching (default off)
26
16
  watch on|off switch watching of the going run; off also turns hunting off
27
17
  hunt on|off switch hunting of the going run; on also turns watching on
28
- refresh ask the going run to check for new issues now
29
18
  init write ${CONFIG_FILE} with the defaults and add .next-issue/ and .worktrees/ to info/exclude
30
19
  serve run the worker of this repository that the clients talk to
31
20
  stop stop the going run after its current issues
@@ -24,22 +24,22 @@ export function deadline(ms, onExpire) {
24
24
  export function elapsedMs(started) {
25
25
  return Date.now() - started;
26
26
  }
27
- // Resolves false when woken, or when `refreshed` aborts.
28
- export function wakeableSleep(sleeper, ms, stopped, refreshed) {
27
+ // Resolves false when woken, or when `woken` aborts.
28
+ export function wakeableSleep(sleeper, ms, stopped, woken) {
29
29
  return new Promise((resolve) => {
30
- if (stopped || refreshed?.aborted === true) {
30
+ if (stopped || woken?.aborted === true) {
31
31
  resolve(false);
32
32
  return;
33
33
  }
34
34
  const settle = (slept) => {
35
35
  clearTimeout(timer);
36
- refreshed?.removeEventListener('abort', onRefresh);
36
+ woken?.removeEventListener('abort', onWoken);
37
37
  sleeper.wake = undefined;
38
38
  resolve(slept);
39
39
  };
40
- const onRefresh = () => settle(false);
40
+ const onWoken = () => settle(false);
41
41
  const timer = setTimeout(() => settle(true), timerMs(ms));
42
42
  sleeper.wake = () => settle(false);
43
- refreshed?.addEventListener('abort', onRefresh, { once: true });
43
+ woken?.addEventListener('abort', onWoken, { once: true });
44
44
  });
45
45
  }
@@ -1,28 +1 @@
1
- export const NOTES = {
2
- hunt: 'Stopping after the current hunt. Press Ctrl-C twice more to stop now.',
3
- wait: 'Stopping now.',
4
- issue: 'Stopping after the running issues. Press Ctrl-C again to stop after the current round.',
5
- round: 'Stopping after the current round. Press Ctrl-C again to stop now.',
6
- };
7
- export function onPresses(handle) {
8
- let presses = 0;
9
- let lastPress = -Infinity;
10
- let ending;
11
- const press = () => {
12
- const now = performance.now();
13
- if (now - lastPress < 100) {
14
- return;
15
- }
16
- lastPress = now;
17
- presses += 1;
18
- if (presses >= 3) {
19
- ending = setTimeout(() => process.off('SIGINT', press), 100).unref();
20
- }
21
- handle(presses);
22
- };
23
- process.on('SIGINT', press);
24
- return () => {
25
- clearTimeout(ending);
26
- process.off('SIGINT', press);
27
- };
28
- }
1
+ export {};
@@ -10,97 +10,64 @@ export async function runIssues(loop, seen = new Set()) {
10
10
  let stopped = false;
11
11
  let unclaimed = true;
12
12
  let recount = false;
13
- const ended = new AbortController();
14
- let refresh = refreshes(loop, ended.signal);
15
13
  const tried = { ended: new Set(), labels: new Map(), blocked: new Set() };
16
- try {
17
- for (;;) {
18
- if (stopped && !loop.stop()) {
19
- stopped = false;
20
- stoppedAt = undefined;
21
- claiming = true;
22
- }
23
- if (claiming && (recount || (unclaimed && slots.open()))) {
24
- recount = false;
25
- refresh = refreshes(loop, ended.signal, refresh);
26
- try {
27
- ({ claiming, unclaimed } = await claimIssues(loop, seen, tried, { running, slots }));
28
- }
29
- catch (failure) {
30
- error = failure;
31
- claiming = false;
32
- }
33
- }
34
- if (running.size === 0) {
35
- break;
36
- }
37
- const settled = await Promise.race([...running.values(), slots.freed(), refresh.asked]);
38
- if (settled === 'refresh') {
39
- recount = true;
40
- refresh = refreshes(loop, ended.signal, refresh);
41
- continue;
42
- }
43
- if (settled === undefined) {
44
- continue;
45
- }
46
- const { issue, slot, report, failure } = settled;
47
- running.delete(issue);
48
- slot.free();
49
- unclaimed = true;
50
- recount = true;
51
- if (report === undefined) {
52
- crash ??= { failure };
53
- claiming = false;
54
- stopped = false;
55
- continue;
56
- }
57
- reports.push(report);
58
- if (retryable(report)) {
59
- tried.ended.add(issue);
60
- }
61
- if (report.blocked === true) {
62
- tried.blocked.add(issue);
63
- }
64
- if (report.outcome === 'done') {
65
- readmitBlocked(seen, tried);
14
+ for (;;) {
15
+ if (stopped && !loop.stop()) {
16
+ stopped = false;
17
+ stoppedAt = undefined;
18
+ claiming = true;
19
+ }
20
+ if (claiming && (recount || (unclaimed && slots.open()))) {
21
+ recount = false;
22
+ try {
23
+ ({ claiming, unclaimed } = await claimIssues(loop, seen, tried, { running, slots }));
66
24
  }
67
- if (claiming && (loop.stop() || report.halt === true)) {
68
- stoppedAt = issue;
25
+ catch (failure) {
26
+ error = failure;
69
27
  claiming = false;
70
- stopped = true;
71
- }
72
- if (report.halt === true) {
73
- stopped = false;
74
- }
75
- if (report.outcome === 'done' && !claiming) {
76
- await loop.issues().catch(() => undefined);
77
28
  }
78
29
  }
30
+ if (running.size === 0) {
31
+ break;
32
+ }
33
+ const settled = await Promise.race([...running.values(), slots.freed()]);
34
+ if (settled === undefined) {
35
+ continue;
36
+ }
37
+ const { issue, slot, report, failure } = settled;
38
+ running.delete(issue);
39
+ slot.free();
40
+ unclaimed = true;
41
+ recount = true;
42
+ if (report === undefined) {
43
+ crash ??= { failure };
44
+ claiming = false;
45
+ stopped = false;
46
+ continue;
47
+ }
48
+ reports.push(report);
49
+ if (retryable(report)) {
50
+ tried.ended.add(issue);
51
+ }
52
+ if (report.blocked === true) {
53
+ tried.blocked.add(issue);
54
+ }
55
+ if (report.outcome === 'done') {
56
+ readmitBlocked(seen, tried);
57
+ }
58
+ if (claiming && (loop.stop() || report.halt === true)) {
59
+ stoppedAt = issue;
60
+ claiming = false;
61
+ stopped = true;
62
+ }
63
+ if (report.halt === true) {
64
+ stopped = false;
65
+ }
66
+ if (report.outcome === 'done' && !claiming) {
67
+ await loop.issues().catch(() => undefined);
68
+ }
79
69
  }
80
- finally {
81
- ended.abort();
82
- }
83
- return { ...loopResult(reports, stoppedAt, error, crash), ...refreshedOf(refresh) };
84
- }
85
- function refreshedOf(refresh) {
86
- return refresh.signal === undefined ? {} : { refreshed: refresh.signal };
87
- }
88
- function refreshes(loop, ended, previous) {
89
- const signal = loop.refreshed?.();
90
- if (previous !== undefined && previous.signal === signal) {
91
- return previous;
92
- }
93
- return {
94
- signal,
95
- asked: new Promise((resolve) => {
96
- if (signal?.aborted === true) {
97
- resolve('refresh');
98
- }
99
- else {
100
- signal?.addEventListener('abort', () => resolve('refresh'), { once: true, signal: ended });
101
- }
102
- }),
103
- };
70
+ return loopResult(reports, stoppedAt, error, crash);
104
71
  }
105
72
  function loopResult(reports, stoppedAt, error, crash) {
106
73
  return {
@@ -7,7 +7,7 @@ export async function watchIssues(watch) {
7
7
  const ended = new AbortController();
8
8
  const hunting = watch.hunter === undefined
9
9
  ? undefined
10
- : huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, watch.issues, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
10
+ : huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, watch.issues, () => ended.signal.aborted || watch.stop(), ended.signal);
11
11
  try {
12
12
  return await watchPasses(failed, {
13
13
  ...watch,
@@ -39,7 +39,7 @@ function aborted(signal) {
39
39
  }
40
40
  });
41
41
  }
42
- async function huntIssues(hunter, hunting, running, failed, issues, refreshes, stopped, signal) {
42
+ async function huntIssues(hunter, hunting, running, failed, issues, stopped, signal) {
43
43
  let step = 0;
44
44
  while (!stopped()) {
45
45
  if (!hunting.on()) {
@@ -62,9 +62,8 @@ async function huntIssues(hunter, hunting, running, failed, issues, refreshes, s
62
62
  continue;
63
63
  }
64
64
  const changed = hunting.changed();
65
- const refreshed = refreshes?.() ?? new AbortController().signal;
66
- await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, changed, refreshed]));
67
- if (changed.aborted || refreshed.aborted) {
65
+ await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, changed]));
66
+ if (changed.aborted) {
68
67
  step = 0;
69
68
  }
70
69
  else {
@@ -79,9 +78,8 @@ async function watchPasses(failed, watch) {
79
78
  for (;;) {
80
79
  const pass = await runIssues(watch, new Set(failed));
81
80
  addReports(reports, pass.reports);
82
- const { refreshed, ...result } = pass;
83
81
  if (pass.crash !== undefined) {
84
- return { ...result, reports };
82
+ return { ...pass, reports };
85
83
  }
86
84
  recordFailures(failed, pass.reports);
87
85
  if (handled(pass.reports) > 0) {
@@ -89,15 +87,14 @@ async function watchPasses(failed, watch) {
89
87
  step = 0;
90
88
  }
91
89
  if (pass.error !== undefined || pass.stoppedAt !== undefined) {
92
- return { ...result, reports };
90
+ return { ...pass, reports };
93
91
  }
94
92
  if (watch.stop() || !watching()) {
95
93
  return { reports };
96
94
  }
97
95
  const minutes = backOffMinutes(step);
98
96
  step += 1;
99
- const signals = [refreshed ?? watch.refreshed?.(), watch.watching?.changed()].filter((signal) => signal !== undefined);
100
- const woken = signals.length === 0 ? undefined : AbortSignal.any(signals);
97
+ const woken = watch.watching?.changed();
101
98
  if (!(await watch.wait(minutes, woken))) {
102
99
  if (woken?.aborted !== true || watch.stop() || !watching()) {
103
100
  return { reports };
@@ -161,9 +161,9 @@ export async function reachWorker(root, version) {
161
161
  found.close();
162
162
  }
163
163
  }
164
- function startedRun(found, root) {
164
+ export function startedRun(found, root, id) {
165
165
  return new Promise((resolve, reject) => {
166
- const timer = setTimeout(() => reject(new Error('the newer worker did not start the run')), ANSWER_TIMEOUT_MS);
166
+ const timer = setTimeout(() => reject(new Error('the worker did not start the run')), ANSWER_TIMEOUT_MS);
167
167
  const settle = (error) => {
168
168
  clearTimeout(timer);
169
169
  if (error === undefined) {
@@ -177,7 +177,7 @@ function startedRun(found, root) {
177
177
  if (message.type === 'runs' && going(message.runs[root])) {
178
178
  settle();
179
179
  }
180
- else if (message.type === 'error' && message.root === root) {
180
+ else if (message.type === 'error' && message.root === root && message.id === id) {
181
181
  settle(new Error(message.message));
182
182
  }
183
183
  });
@@ -197,20 +197,6 @@ export async function resumeOnSuccessor(root, how, args) {
197
197
  found.close();
198
198
  }
199
199
  }
200
- export async function rejoinRun(root) {
201
- const { socketPath } = workerPaths(root);
202
- const deadline = Date.now() + START_TIMEOUT_MS;
203
- while (Date.now() < deadline) {
204
- const found = await tryOpen(socketPath);
205
- if (found?.runs[root] !== undefined) {
206
- found.send({ type: 'rejoin', root });
207
- return found;
208
- }
209
- found?.close();
210
- await delay(POLL_MS);
211
- }
212
- return undefined;
213
- }
214
200
  export function findWorker(root) {
215
201
  const { socketPath } = workerPaths(root);
216
202
  checkSocketPath(socketPath);
@@ -74,16 +74,15 @@ export function watchRun(args, loop, context, controls, print) {
74
74
  const hunt = hunter(context);
75
75
  return watchIssues({
76
76
  ...loop,
77
- wait: (minutes, refreshed) => {
77
+ wait: (minutes, woken) => {
78
78
  recorder.event('watch.wait', { minutes });
79
79
  passStart = recorder.summary();
80
- return interrupts.sleep(minutesToMs(minutes), () => hunt.busy(), refreshed);
80
+ return interrupts.sleep(minutesToMs(minutes), () => hunt.busy(), woken);
81
81
  },
82
82
  passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
83
83
  hunter: hunt,
84
84
  hunting: controls.hunting ?? onOff(args.hunt),
85
85
  watching: controls.watching,
86
- refreshed: controls.refreshed,
87
86
  });
88
87
  }
89
88
  function recordLoopEnd(recorder, stoppedAt, stopped, error) {
@@ -14,7 +14,7 @@ import { resumeOnSuccessor } from '../shared/worker-client.mjs';
14
14
  import { latestVersion, NPM_LATEST, npxLaunch } from './latest-version.mjs';
15
15
  import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
16
16
  import { checkSocketPath, workerPaths } from '../shared/worker-paths.mjs';
17
- import { active, dropUpgrade, endStatus, newRun, requestRefresh, requestStop, requestUpgrade, runControls, runsMessage, setHunting, setWatching, startRefusal, stoppingMessage, stopPoint, switchRefusal, } from './worker-run.mjs';
17
+ import { active, dropUpgrade, endStatus, newRun, requestStop, requestUpgrade, runControls, runsMessage, setHunting, setWatching, startRefusal, stoppingMessage, stopPoint, switchRefusal, } from './worker-run.mjs';
18
18
  import { broadcast, closer, fileId, isLaunch, listen, parseMessage, removeOwned, send, sendAll, sendAllSent, shutdown, stopListening, } from './worker-server.mjs';
19
19
  const LOCK_WAIT_MS = 5_000;
20
20
  const IDLE_MS = 30_000;
@@ -165,6 +165,7 @@ export async function startWorker(options) {
165
165
  ...(summary === undefined ? {} : { summary }),
166
166
  });
167
167
  }, (error) => {
168
+ process.stderr.write(`next-issue failed: ${message(error)}\n`);
168
169
  update({ ...run.progress, status: 'failed', error: message(error) });
169
170
  return ended({ type: 'end', root, code: 1, error: message(error) });
170
171
  })
@@ -229,9 +230,6 @@ export async function startWorker(options) {
229
230
  else if (value.type === 'watch') {
230
231
  toggle(refuse, value.root, value.on, setWatching);
231
232
  }
232
- else if (value.type === 'refresh') {
233
- requestRefresh(runs.get(value.root));
234
- }
235
233
  else if (value.type === 'rejoin') {
236
234
  followed = true;
237
235
  if (lateEnd !== undefined) {
@@ -3,14 +3,12 @@ import { wakeableSleep } from '../shared/durations.mjs';
3
3
  import { onOff } from '../shared/switch.mjs';
4
4
  import { applyEvent } from './progress.mjs';
5
5
  import { STOP_POINTS, } from '../shared/protocol.mjs';
6
- import { refresher } from './refresh.mjs';
7
6
  export function newRun(progress) {
8
7
  return {
9
8
  progress,
10
9
  children: runChildren(),
11
10
  watching: onOff(progress.watching === true),
12
11
  hunting: onOff(progress.hunting),
13
- refresher: refresher(),
14
12
  };
15
13
  }
16
14
  export function active(run) {
@@ -89,14 +87,6 @@ export function switchRefusal(run, on) {
89
87
  }
90
88
  return on && run.stoppedByPerson === true ? 'the run is stopping' : undefined;
91
89
  }
92
- // Only a running watch run refreshes: it wakes the wait between passes, or reads the open issues again during a pass.
93
- export function requestRefresh(run) {
94
- if (run?.progress.status !== 'running' || !run.watching.on() || run.stop !== undefined) {
95
- return false;
96
- }
97
- run.refresher.refresh();
98
- return true;
99
- }
100
90
  export function setHunting(run, on) {
101
91
  if (on) {
102
92
  run.watching.set(true);
@@ -119,9 +109,9 @@ function runInterrupts(run) {
119
109
  return {
120
110
  afterIssue: () => run.stop !== undefined,
121
111
  afterRound: () => run.stop === 'round' || run.stop === 'now',
122
- sleep: (ms, hunting, refreshed) => {
112
+ sleep: (ms, hunting, woken) => {
123
113
  run.huntBusy = hunting;
124
- return wakeableSleep(run, ms, run.stop !== undefined, refreshed);
114
+ return wakeableSleep(run, ms, run.stop !== undefined, woken);
125
115
  },
126
116
  };
127
117
  }
@@ -130,7 +120,6 @@ export function runControls(run, update) {
130
120
  interrupts: runInterrupts(run),
131
121
  hunting: run.hunting,
132
122
  watching: run.watching,
133
- refreshed: run.refresher.refreshed,
134
123
  onEvent: (record) => update(applyEvent(run.progress, record)),
135
124
  };
136
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "14.9.0",
3
+ "version": "16.0.0",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",
@@ -96,12 +96,6 @@ Help the user understand why the worker handed an issue over, then answer the ha
96
96
  gh issue edit --repo <repo> <number> --remove-label "<needs-human>" --add-label "<skip>"
97
97
  ```
98
98
 
99
- 10. After a retry, with or without guidance, run `next-issue refresh`, with no question first. When `next-issue` is not on the `PATH`, run `npx -y next-issue@latest` in its place, here and below. When it prints `asked the run to check for new issues now`, tell the user that the going run was asked to check for issues now. Ask no question.
100
-
101
- When it prints `no run is going in this repository`, ask only whether to start a run. On yes, run `next-issue start` in the background, such as with the `run_in_background` option of the Bash tool, since it goes on until the run ends, and tell the user that the run started. The run watches for new issues. On no, do nothing.
102
-
103
- When it prints `the run is stopping, so nothing was asked`, tell the user that the stopping run will not claim the issue. When it prints `the run is stopping for an upgrade`, tell the user that the run starts again on the newer worker and claims the issue then. Ask no question.
104
-
105
- When it prints `the run does not watch for new issues`, ask only whether to turn watching on. On yes, run `next-issue watch on`, then `next-issue refresh`, and tell the user what they print. On no, do nothing.
99
+ 10. After a retry, with or without guidance, tell the user what you did. Run no next-issue command and ask nothing about a run.
106
100
 
107
101
  11. Ask whether to answer another waiting issue. On yes, go back to step 3.
@@ -42,28 +42,21 @@ Turn the problem of the user into one GitHub issue, or a split of linked issues
42
42
 
43
43
  For a confirmed split, repeat steps 5 to 7 for each issue of the split, in order. Create each one with `--blocked-by` the issues of the split it depends on, so it is linked before you add its ready label.
44
44
 
45
- 8. Once the issue exists, or the last issue of a split, run `next-issue refresh`, with no question first. When `next-issue` is not on the `PATH`, run `npx -y next-issue@latest` in its place, here and below.
46
- 9. When it prints `asked the run to check for new issues now`, give the user the issue url, or each url of a split, and say that the going run was asked to check for new issues now. Ask no question.
45
+ 8. Once the issue exists, or the last issue of a split, give the user the issue url, or each url of a split, and stop. Run no next-issue command and ask nothing about a run.
47
46
 
48
- When it prints `no run is going in this repository`, give the user the url or urls and ask only whether to start a run. On yes, run `next-issue start` in the background, such as with the `run_in_background` option of the Bash tool, since it goes on until the run ends, and tell the user that the run started. The run watches for new issues. On no, do nothing.
47
+ 9. When the user asks for a change to the issue, make the change on GitHub. Write the new body into the temporary file and run:
49
48
 
50
- When it prints `the run is stopping, so nothing was asked`, give the user the url or urls and say that the stopping run will not claim the issue. When it prints `the run is stopping for an upgrade`, give the user the url or urls and say that the run starts again on the newer worker and claims the issue then. Ask no question.
51
-
52
- When it prints `the run does not watch for new issues`, give the user the url or urls and ask only whether to turn watching on. On yes, run `next-issue watch on`, then `next-issue refresh`, and tell the user what they print. On no, do nothing.
53
-
54
- 10. When the user asks for a change to the issue, make the change on GitHub. Write the new body into the temporary file and run:
55
-
56
- ```bash
57
- gh issue edit --repo <repo> <number> --body-file <file>
58
- ```
49
+ ```bash
50
+ gh issue edit --repo <repo> <number> --body-file <file>
51
+ ```
59
52
 
60
- To change the title, run:
53
+ To change the title, run:
61
54
 
62
- ```bash
63
- gh issue edit --repo <repo> <number> --title "<title>"
64
- ```
55
+ ```bash
56
+ gh issue edit --repo <repo> <number> --title "<title>"
57
+ ```
65
58
 
66
- Once the issue exists, do not implement it in this session. The next-issue worker does the work. Once the user answers whether to start a run, do not ask about a run again.
59
+ Once the issue exists, do not implement it in this session. The next-issue worker does the work.
67
60
 
68
61
  ## Sections
69
62
 
@@ -1,10 +0,0 @@
1
- export function refresher() {
2
- let controller = new AbortController();
3
- return {
4
- refreshed: () => controller.signal,
5
- refresh: () => {
6
- controller.abort();
7
- controller = new AbortController();
8
- },
9
- };
10
- }