next-issue 8.5.1 → 8.7.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 +20 -13
- package/dist/run.mjs +4 -3
- package/dist/serve.mjs +9 -6
- package/dist/{hunt-switch.mjs → switch.mjs} +1 -1
- package/dist/watch.mjs +8 -6
- package/dist/worker-run.mjs +19 -14
- package/dist/worker-server.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -941,7 +941,7 @@ With `next-issue start --hunt`, which turns on `--watch`, the harness runs a hun
|
|
|
941
941
|
|
|
942
942
|
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; a url that is not an issue of the repository of `remote` does not count as filed. When the `remote` url holds an old owner or name that GitHub redirects after a rename or transfer, the harness asks GitHub for the new one, so an issue url with the new name counts too. 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.
|
|
943
943
|
|
|
944
|
-
In a run of the `serve` worker, a client can switch hunting on or off while the run goes on, with no restart, for example with `/next-issue hunt on` in the pi extension, see [Worker](#worker). This works only for runs of the worker, not for a command-line run.
|
|
944
|
+
In a run of the `serve` worker, a client can switch hunting and watching on or off while the run goes on, with no restart, for example with `/next-issue hunt on` or `/next-issue watch on` in the pi extension, see [Worker](#worker). This works only for runs of the worker, not for a command-line run.
|
|
945
945
|
|
|
946
946
|
## Worker
|
|
947
947
|
|
|
@@ -970,12 +970,13 @@ affect another. The worker:
|
|
|
970
970
|
with `another worker is running`. A worker that stops removes the lock file
|
|
971
971
|
only while it still holds the lock, and the socket file only while it is
|
|
972
972
|
still the socket it bound;
|
|
973
|
-
- refuses a `start`, `stop`, `hunt` or `questions` message whose `root` is not
|
|
973
|
+
- refuses a `start`, `stop`, `watch`, `hunt` or `questions` message whose `root` is not
|
|
974
974
|
the exact path of its repository with an `error` message, and starts or
|
|
975
975
|
stops nothing;
|
|
976
976
|
- runs at most one run at a time. A client starts it with
|
|
977
977
|
`{ "type": "start", "root": "<path>", "args": [...] }`. Each run is like
|
|
978
|
-
`next-issue start` with those args, or with none when `args` is left out
|
|
978
|
+
`next-issue start` with those args, or with none when `args` is left out
|
|
979
|
+
(the pi extension sends none). It takes
|
|
979
980
|
`--max <n>`, `--watch`, `--hunt`, `--reset`, `--verbose` and
|
|
980
981
|
`--quiet`, and refuses a command (`start` too), `--json`, `--force`, `--help` or an
|
|
981
982
|
unknown argument with an `error` message;
|
|
@@ -1010,18 +1011,24 @@ affect another. The worker:
|
|
|
1010
1011
|
issue ends as `stopped` with its state and labels kept; the worker keeps
|
|
1011
1012
|
running. A later point than one already asked for changes nothing, and an
|
|
1012
1013
|
earlier one replaces it. An unknown `after` gets an `error` message;
|
|
1014
|
+
- switches watching of a run on or off when a client sends
|
|
1015
|
+
`{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps
|
|
1016
|
+
its issues, worktrees and progress, and nothing restarts. A run started with
|
|
1017
|
+
`--watch` or `--hunt` starts with watching on, and any other run with it
|
|
1018
|
+
off. On keeps the run going after the current pass, as with `--watch`. Off
|
|
1019
|
+
ends the run after the current pass, or at once when it waits between
|
|
1020
|
+
passes, and also turns hunting off. With no run going, the message gets an
|
|
1021
|
+
`error` and starts nothing;
|
|
1013
1022
|
- switches hunting of a run on or off when a client sends
|
|
1014
1023
|
`{ "type": "hunt", "root": "<path>", "on": true | false }`. The run keeps its
|
|
1015
|
-
issues, worktrees and progress, and nothing restarts. Every
|
|
1016
|
-
a hunter: a run started with `--hunt` starts with hunting on, and
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
takes it from its own flags. Only runs of the worker can switch; a
|
|
1024
|
-
command-line run keeps what `--hunt` gave it. The progress of each run
|
|
1024
|
+
issues, worktrees and progress, and nothing restarts. Every run of the
|
|
1025
|
+
worker has a hunter: a run started with `--hunt` starts with hunting on, and
|
|
1026
|
+
any other run with it off. Off lets a hunt that is going finish, so the
|
|
1027
|
+
issues it files stay, and starts no new hunt. On wakes the hunter at once,
|
|
1028
|
+
with no back-off wait, and also turns watching on. With no run going, the message gets
|
|
1029
|
+
an `error` and starts nothing. The settings last for the run only: a new run
|
|
1030
|
+
takes them from its own flags. Only runs of the worker can switch; a
|
|
1031
|
+
command-line run keeps what `--watch` and `--hunt` gave it. The progress of each run
|
|
1025
1032
|
carries `hunting`, `true` while hunting is on, and `watching`, `true` when
|
|
1026
1033
|
the run watches for issues;
|
|
1027
1034
|
- asks a watching run to check for new issues now when a client sends
|
package/dist/run.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { detectRepo } from './git.mjs';
|
|
|
11
11
|
import { checkGitVersion } from './git-version.mjs';
|
|
12
12
|
import { defaultBranch } from './github.mjs';
|
|
13
13
|
import { hunter } from './hunt.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { onOff } from './switch.mjs';
|
|
15
15
|
import { lock, lockHolder } from './lock.mjs';
|
|
16
16
|
import { exitCode, runIssues } from './loop.mjs';
|
|
17
17
|
import { Recorder } from './observe.mjs';
|
|
@@ -69,7 +69,7 @@ async function handle(args, config, repo, recorder, controls) {
|
|
|
69
69
|
concurrency: config.concurrency,
|
|
70
70
|
};
|
|
71
71
|
const print = controls.print ?? (async () => undefined);
|
|
72
|
-
const { reports, stoppedAt, error } = args.watch
|
|
72
|
+
const { reports, stoppedAt, error } = args.watch || controls.watching !== undefined
|
|
73
73
|
? await watchRun(args, loop, context, controls, print)
|
|
74
74
|
: await runIssues(args, loop);
|
|
75
75
|
recordLoopEnd(recorder, stoppedAt, error);
|
|
@@ -93,7 +93,8 @@ export function watchRun(args, loop, context, controls, print) {
|
|
|
93
93
|
},
|
|
94
94
|
passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
|
|
95
95
|
hunter: hunt,
|
|
96
|
-
hunting: controls.hunting ??
|
|
96
|
+
hunting: controls.hunting ?? onOff(args.hunt),
|
|
97
|
+
watching: controls.watching,
|
|
97
98
|
refreshed: controls.refreshed,
|
|
98
99
|
});
|
|
99
100
|
}
|
package/dist/serve.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { runRepo } from './run.mjs';
|
|
|
14
14
|
import { packageVersion } from './version.mjs';
|
|
15
15
|
import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
|
|
16
16
|
import { checkSocketPath, workerPaths } from './worker-paths.mjs';
|
|
17
|
-
import { active, endStatus,
|
|
17
|
+
import { active, endStatus, newRun, requestRefresh, requestStop, runControls, runsMessage, setHunting, setWatching, startRefusal, stopPoint, switchRefusal, } from './worker-run.mjs';
|
|
18
18
|
import { broadcast, closer, fileId, listen, parseMessage, removeOwned, shutdown, } from './worker-server.mjs';
|
|
19
19
|
const LOCK_WAIT_MS = 5_000;
|
|
20
20
|
const IDLE_MS = 30_000;
|
|
@@ -64,7 +64,7 @@ export async function startWorker(options) {
|
|
|
64
64
|
send(socket, { type: 'error', root, message: message(error) });
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
const run = newRun({ ...startProgress(args.hunt), watching: args.watch }
|
|
67
|
+
const run = newRun({ ...startProgress(args.hunt), watching: args.watch });
|
|
68
68
|
runs.set(root, run);
|
|
69
69
|
const update = (next) => {
|
|
70
70
|
run.progress = next;
|
|
@@ -84,14 +84,14 @@ export async function startWorker(options) {
|
|
|
84
84
|
broadcast(sockets, runs);
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
const
|
|
87
|
+
const toggle = (socket, root, on, set) => {
|
|
88
88
|
const run = runs.get(root);
|
|
89
|
-
const refusal =
|
|
89
|
+
const refusal = switchRefusal(run);
|
|
90
90
|
if (refusal !== undefined) {
|
|
91
91
|
send(socket, { type: 'error', root, message: refusal });
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
set(run, on);
|
|
95
95
|
broadcast(sockets, runs);
|
|
96
96
|
};
|
|
97
97
|
const receive = (socket, value) => {
|
|
@@ -118,7 +118,10 @@ export async function startWorker(options) {
|
|
|
118
118
|
stop(socket, value.root, value.after);
|
|
119
119
|
}
|
|
120
120
|
else if (value.type === 'hunt') {
|
|
121
|
-
|
|
121
|
+
toggle(socket, value.root, value.on, setHunting);
|
|
122
|
+
}
|
|
123
|
+
else if (value.type === 'watch') {
|
|
124
|
+
toggle(socket, value.root, value.on, setWatching);
|
|
122
125
|
}
|
|
123
126
|
else if (value.type === 'refresh') {
|
|
124
127
|
requestRefresh(runs.get(value.root));
|
package/dist/watch.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { onOff } from './switch.mjs';
|
|
2
2
|
import { handled, runIssues } from './loop.mjs';
|
|
3
3
|
const BACK_OFF_MINUTES = [1, 2, 3, 5, 10];
|
|
4
4
|
export async function watchIssues(args, watch) {
|
|
@@ -8,7 +8,7 @@ export async function watchIssues(args, watch) {
|
|
|
8
8
|
const claims = claimAlarm();
|
|
9
9
|
const hunting = watch.hunter === undefined
|
|
10
10
|
? undefined
|
|
11
|
-
: huntIssues(watch.hunter, watch.hunting ??
|
|
11
|
+
: huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, claims, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
|
|
12
12
|
try {
|
|
13
13
|
return await watchPasses(args, failed, {
|
|
14
14
|
...watch,
|
|
@@ -94,6 +94,7 @@ async function watchPasses(args, failed, watch) {
|
|
|
94
94
|
const limit = args.max;
|
|
95
95
|
const reports = [];
|
|
96
96
|
let step = 0;
|
|
97
|
+
const watching = () => watch.watching?.on() ?? true;
|
|
97
98
|
for (;;) {
|
|
98
99
|
const pass = await runIssues({ max: limit === undefined ? undefined : limit - handled(reports) }, watch, new Set(failed));
|
|
99
100
|
addReports(reports, pass.reports);
|
|
@@ -105,14 +106,15 @@ async function watchPasses(args, failed, watch) {
|
|
|
105
106
|
if (pass.error !== undefined || pass.stoppedAt !== undefined) {
|
|
106
107
|
return { ...pass, reports };
|
|
107
108
|
}
|
|
108
|
-
if ((limit !== undefined && handled(reports) >= limit) || watch.stop()) {
|
|
109
|
+
if ((limit !== undefined && handled(reports) >= limit) || watch.stop() || !watching()) {
|
|
109
110
|
return { reports };
|
|
110
111
|
}
|
|
111
112
|
const minutes = backOffMinutes(step);
|
|
112
113
|
step += 1;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const signals = [watch.refreshed?.(), watch.watching?.changed()].filter((signal) => signal !== undefined);
|
|
115
|
+
const woken = signals.length === 0 ? undefined : AbortSignal.any(signals);
|
|
116
|
+
if (!(await watch.wait(minutes, woken))) {
|
|
117
|
+
if (woken?.aborted !== true || watch.stop() || !watching()) {
|
|
116
118
|
return { reports };
|
|
117
119
|
}
|
|
118
120
|
step = 0;
|
package/dist/worker-run.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { runChildren, stopRunChildren } from './children.mjs';
|
|
2
2
|
import { wakeableSleep } from './durations.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { onOff } from './switch.mjs';
|
|
4
4
|
import { applyEvent } from './progress.mjs';
|
|
5
5
|
import { STOP_POINTS } from './protocol.mjs';
|
|
6
6
|
import { refresher } from './refresh.mjs';
|
|
7
|
-
export function newRun(progress
|
|
7
|
+
export function newRun(progress) {
|
|
8
8
|
return {
|
|
9
9
|
progress,
|
|
10
10
|
children: runChildren(),
|
|
11
|
-
watching,
|
|
12
|
-
hunting:
|
|
11
|
+
watching: onOff(progress.watching === true),
|
|
12
|
+
hunting: onOff(progress.hunting),
|
|
13
13
|
refresher: refresher(),
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -58,26 +58,30 @@ export function requestStop(run, after) {
|
|
|
58
58
|
run.progress = { ...run.progress, status: 'stopping' };
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
|
-
export function
|
|
62
|
-
|
|
63
|
-
return 'no run is going in this repository';
|
|
64
|
-
}
|
|
65
|
-
if (on && !run.watching) {
|
|
66
|
-
return 'the run does not watch for issues, so it cannot hunt: start a run with --watch or --hunt';
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
61
|
+
export function switchRefusal(run) {
|
|
62
|
+
return active(run) ? undefined : 'no run is going in this repository';
|
|
69
63
|
}
|
|
70
64
|
// Only a running watch run refreshes; a pass that is going or a stop is left alone.
|
|
71
65
|
export function requestRefresh(run) {
|
|
72
|
-
if (run?.progress.status !== 'running' || !run.watching || run.stop !== undefined) {
|
|
66
|
+
if (run?.progress.status !== 'running' || !run.watching.on() || run.stop !== undefined) {
|
|
73
67
|
return false;
|
|
74
68
|
}
|
|
75
69
|
run.refresher.refresh();
|
|
76
70
|
return true;
|
|
77
71
|
}
|
|
78
72
|
export function setHunting(run, on) {
|
|
73
|
+
if (on) {
|
|
74
|
+
run.watching.set(true);
|
|
75
|
+
}
|
|
79
76
|
run.hunting.set(on);
|
|
80
|
-
run.progress = { ...run.progress, hunting: on };
|
|
77
|
+
run.progress = { ...run.progress, hunting: on, watching: run.watching.on() };
|
|
78
|
+
}
|
|
79
|
+
export function setWatching(run, on) {
|
|
80
|
+
if (!on) {
|
|
81
|
+
run.hunting.set(false);
|
|
82
|
+
}
|
|
83
|
+
run.watching.set(on);
|
|
84
|
+
run.progress = { ...run.progress, watching: on, hunting: run.hunting.on() };
|
|
81
85
|
}
|
|
82
86
|
function runInterrupts(run) {
|
|
83
87
|
return {
|
|
@@ -90,6 +94,7 @@ export function runControls(run, update, issueEnded) {
|
|
|
90
94
|
return {
|
|
91
95
|
interrupts: runInterrupts(run),
|
|
92
96
|
hunting: run.hunting,
|
|
97
|
+
watching: run.watching,
|
|
93
98
|
refreshed: run.refresher.refreshed,
|
|
94
99
|
onEvent: (record) => {
|
|
95
100
|
update(applyEvent(run.progress, record));
|
package/dist/worker-server.mjs
CHANGED
|
@@ -17,7 +17,7 @@ function isClientMessage(value) {
|
|
|
17
17
|
if (typeof value['root'] !== 'string') {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
if (value['type'] === 'hunt') {
|
|
20
|
+
if (value['type'] === 'hunt' || value['type'] === 'watch') {
|
|
21
21
|
return typeof value['on'] === 'boolean';
|
|
22
22
|
}
|
|
23
23
|
if (value['type'] === 'questions') {
|