next-issue 14.8.0 → 15.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
@@ -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 |
@@ -100,14 +100,16 @@ function follow(first, root, args, argv, out) {
100
100
  else if (message.type === 'end' && message.error !== undefined) {
101
101
  fail(message.error);
102
102
  }
103
- else if (message.type === 'end' && latest?.upgrade !== undefined) {
104
- upgradeEnd = message.code;
105
- }
106
103
  else if (message.type === 'end') {
107
104
  if (!args.watch && message.summary !== undefined) {
108
105
  out.print(process.stdout, formatSummary(message.summary));
109
106
  }
110
- settle(message.code);
107
+ if (latest?.upgrade === undefined) {
108
+ settle(message.code);
109
+ }
110
+ else {
111
+ upgradeEnd = message.code;
112
+ }
111
113
  }
112
114
  };
113
115
  const rejoin = async (upgrade) => {
@@ -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
  }
@@ -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
  }
@@ -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 {
@@ -123,6 +90,10 @@ async function claimIssues(loop, seen, tried, pool) {
123
90
  if (!pool.slots.open()) {
124
91
  return { claiming: true, unclaimed: true };
125
92
  }
93
+ await loop.beforeClaim?.();
94
+ if (loop.stop()) {
95
+ return { claiming: false, unclaimed: false };
96
+ }
126
97
  seen.add(issue.number);
127
98
  const slot = pool.slots.claim();
128
99
  pool.running.set(issue.number, loop.process(issue, slot).then((report) => ({ issue: issue.number, slot, report }), (failure) => ({ issue: issue.number, slot, failure })));
@@ -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 };
@@ -202,7 +202,8 @@ export async function rejoinRun(root) {
202
202
  const deadline = Date.now() + START_TIMEOUT_MS;
203
203
  while (Date.now() < deadline) {
204
204
  const found = await tryOpen(socketPath);
205
- if (found !== undefined && going(found.runs[root])) {
205
+ if (found?.runs[root] !== undefined) {
206
+ found.send({ type: 'rejoin', root });
206
207
  return found;
207
208
  }
208
209
  found?.close();
@@ -0,0 +1,18 @@
1
+ export const NPM_LATEST = 'https://registry.npmjs.org/next-issue/latest';
2
+ const LATEST_TIMEOUT_MS = 3_000;
3
+ export async function latestVersion(registry) {
4
+ try {
5
+ const response = await fetch(registry, { signal: AbortSignal.timeout(LATEST_TIMEOUT_MS) });
6
+ if (!response.ok) {
7
+ return undefined;
8
+ }
9
+ const { version } = (await response.json());
10
+ return typeof version === 'string' ? version : undefined;
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ export function npxLaunch(version) {
17
+ return { command: 'npx', args: ['-y', `next-issue@${version}`, 'serve'] };
18
+ }
@@ -49,6 +49,7 @@ async function handle(args, config, repo, recorder, controls) {
49
49
  issues: () => pendingIssues(context),
50
50
  process: (issue, slot) => processIssue(context, issue, slot),
51
51
  stop: interrupts.afterIssue,
52
+ beforeClaim: controls.beforeClaim,
52
53
  concurrency: config.concurrency,
53
54
  };
54
55
  const print = controls.print ?? (async () => undefined);
@@ -73,16 +74,15 @@ export function watchRun(args, loop, context, controls, print) {
73
74
  const hunt = hunter(context);
74
75
  return watchIssues({
75
76
  ...loop,
76
- wait: (minutes, refreshed) => {
77
+ wait: (minutes, woken) => {
77
78
  recorder.event('watch.wait', { minutes });
78
79
  passStart = recorder.summary();
79
- return interrupts.sleep(minutesToMs(minutes), () => hunt.busy(), refreshed);
80
+ return interrupts.sleep(minutesToMs(minutes), () => hunt.busy(), woken);
80
81
  },
81
82
  passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
82
83
  hunter: hunt,
83
84
  hunting: controls.hunting ?? onOff(args.hunt),
84
85
  watching: controls.watching,
85
- refreshed: controls.refreshed,
86
86
  });
87
87
  }
88
88
  function recordLoopEnd(recorder, stoppedAt, stopped, error) {
@@ -7,16 +7,18 @@ import { stopChildren, withRunChildren } from '../shared/children.mjs';
7
7
  import { message } from '../shared/errors.mjs';
8
8
  import { lock } from '../shared/lock.mjs';
9
9
  import { startProgress } from './progress.mjs';
10
- import { isNewer } from '../shared/protocol.mjs';
10
+ import { isNewer, } from '../shared/protocol.mjs';
11
11
  import { runRepo } from './run.mjs';
12
12
  import { packageVersion } from '../shared/version.mjs';
13
13
  import { resumeOnSuccessor } from '../shared/worker-client.mjs';
14
+ import { latestVersion, NPM_LATEST, npxLaunch } from './latest-version.mjs';
14
15
  import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
15
16
  import { checkSocketPath, workerPaths } from '../shared/worker-paths.mjs';
16
- 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';
17
18
  import { broadcast, closer, fileId, isLaunch, listen, parseMessage, removeOwned, send, sendAll, sendAllSent, shutdown, stopListening, } from './worker-server.mjs';
18
19
  const LOCK_WAIT_MS = 5_000;
19
20
  const IDLE_MS = 30_000;
21
+ const REJOIN_GRACE_MS = 5_000;
20
22
  export async function startWorker(options) {
21
23
  checkSocketPath(options.socketPath);
22
24
  await mkdir(dirname(options.lockPath), { recursive: true });
@@ -36,6 +38,23 @@ export async function startWorker(options) {
36
38
  const server = createServer();
37
39
  const sockets = new WebSocketServer({ server });
38
40
  const busy = () => [...runs.values()].some(active);
41
+ let followed = false;
42
+ let lateEnd;
43
+ const awaitRejoin = (end) => {
44
+ if (followed) {
45
+ return Promise.resolve();
46
+ }
47
+ return new Promise((resolve) => {
48
+ const timer = setTimeout(resolve, REJOIN_GRACE_MS);
49
+ lateEnd = {
50
+ end,
51
+ sent: () => {
52
+ clearTimeout(timer);
53
+ resolve();
54
+ },
55
+ };
56
+ });
57
+ };
39
58
  let idleTimer;
40
59
  const idleMs = options.idleMs ?? IDLE_MS;
41
60
  const handOver = async (how, run) => {
@@ -63,11 +82,11 @@ export async function startWorker(options) {
63
82
  }
64
83
  });
65
84
  const closeWhenIdle = () => {
66
- if ((restart !== undefined || sockets.clients.size === 0) && !busy()) {
85
+ if ((restart !== undefined || sockets.clients.size === 0) && !busy() && lateEnd === undefined) {
67
86
  void close();
68
87
  }
69
88
  };
70
- const upgradeBetweenIssues = (run) => {
89
+ const upgradeBetweenIssues = (run, everyRun = false) => {
71
90
  if (restart === undefined) {
72
91
  return;
73
92
  }
@@ -76,12 +95,25 @@ export async function startWorker(options) {
76
95
  to: restart,
77
96
  ...(successor === undefined ? {} : { resumes: true }),
78
97
  };
79
- if (requestUpgrade(run, upgrade)) {
98
+ if (requestUpgrade(run, upgrade, everyRun)) {
80
99
  broadcast(sockets, runs);
81
100
  }
82
101
  };
102
+ const upgradeToLatest = async (run) => {
103
+ const latest = await latestVersion(options.registry ?? NPM_LATEST);
104
+ if (latest === undefined || !isNewer(latest, options.version)) {
105
+ return;
106
+ }
107
+ if (restart === undefined) {
108
+ restart = latest;
109
+ successor = (options.successorLaunch ?? npxLaunch)(latest);
110
+ }
111
+ upgradeBetweenIssues(run, true);
112
+ };
83
113
  const start = (refuse, root, argv, resume) => {
84
- const refusal = startRefusal(runs.get(root), restart !== undefined);
114
+ const refusal = lateEnd === undefined
115
+ ? startRefusal(runs.get(root), restart !== undefined)
116
+ : 'the worker is closing, try again soon';
85
117
  if (refusal !== undefined) {
86
118
  if (!resume) {
87
119
  refuse(refusal);
@@ -104,8 +136,15 @@ export async function startWorker(options) {
104
136
  };
105
137
  broadcast(sockets, runs);
106
138
  let summary;
139
+ const ended = async (end) => {
140
+ await sendAllSent(sockets, end);
141
+ if (resume) {
142
+ await awaitRejoin(end);
143
+ }
144
+ };
107
145
  withRunChildren(run.children, () => options.runRepo(root, args, {
108
146
  ...runControls(run, update),
147
+ beforeClaim: () => upgradeToLatest(run),
109
148
  print: args.watch
110
149
  ? async (pass) => sendAll(sockets, { type: 'pass', root, summary: pass })
111
150
  : undefined,
@@ -119,7 +158,7 @@ export async function startWorker(options) {
119
158
  }))
120
159
  .then((code) => {
121
160
  update({ ...run.progress, status: endStatus(run) });
122
- return sendAllSent(sockets, {
161
+ return ended({
123
162
  type: 'end',
124
163
  root,
125
164
  code,
@@ -127,7 +166,7 @@ export async function startWorker(options) {
127
166
  });
128
167
  }, (error) => {
129
168
  update({ ...run.progress, status: 'failed', error: message(error) });
130
- return sendAllSent(sockets, { type: 'end', root, code: 1, error: message(error) });
169
+ return ended({ type: 'end', root, code: 1, error: message(error) });
131
170
  })
132
171
  .finally(() => void close());
133
172
  };
@@ -171,7 +210,7 @@ export async function startWorker(options) {
171
210
  restart = value.version;
172
211
  successor = value.launch;
173
212
  }
174
- runs.forEach(upgradeBetweenIssues);
213
+ runs.forEach((run) => upgradeBetweenIssues(run));
175
214
  closeWhenIdle();
176
215
  }
177
216
  }
@@ -190,8 +229,12 @@ export async function startWorker(options) {
190
229
  else if (value.type === 'watch') {
191
230
  toggle(refuse, value.root, value.on, setWatching);
192
231
  }
193
- else if (value.type === 'refresh') {
194
- requestRefresh(runs.get(value.root));
232
+ else if (value.type === 'rejoin') {
233
+ followed = true;
234
+ if (lateEnd !== undefined) {
235
+ const { end, sent } = lateEnd;
236
+ socket.send(JSON.stringify(end), () => sent());
237
+ }
195
238
  }
196
239
  };
197
240
  sockets.on('connection', (socket) => {
@@ -229,7 +272,12 @@ function upgradedRun(run) {
229
272
  return run.progress.upgrade !== undefined && run.progress.status === 'stopped';
230
273
  }
231
274
  function resumeArgs(run) {
232
- return ['--watch', 'on', '--hunt', run.progress.hunting ? 'on' : 'off'];
275
+ return [
276
+ '--watch',
277
+ run.progress.watching === true ? 'on' : 'off',
278
+ '--hunt',
279
+ run.progress.hunting ? 'on' : 'off',
280
+ ];
233
281
  }
234
282
  function refuser(socket, value, served) {
235
283
  const root = value.type === 'hello' ? served : value.root;
@@ -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) {
@@ -65,9 +63,9 @@ export function stoppingMessage(root, run, id) {
65
63
  ...(id === undefined ? {} : { id }),
66
64
  };
67
65
  }
68
- export function requestUpgrade(run, upgrade) {
66
+ export function requestUpgrade(run, upgrade, everyRun = false) {
69
67
  if (!active(run) ||
70
- !run.watching.on() ||
68
+ (!everyRun && !run.watching.on()) ||
71
69
  run.stoppedByPerson === true ||
72
70
  run.progress.upgrade !== undefined) {
73
71
  return false;
@@ -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.8.0",
3
+ "version": "15.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
- }