next-issue 12.5.0 → 12.5.2

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
@@ -285,7 +285,7 @@ When the implementer makes no change, the hand-over comment holds its full reply
285
285
 
286
286
  A hand-over marks the state file as handed over once its label and comment reach GitHub. When either fails, or the run stops during it, the state keeps its budgets and findings, and a later hand-over of the issue keeps the first reason. A handed-over issue carries the `status:needs-human` and `status:todo` labels, and the hand-over takes `status:in-progress` and `status:in-review` off. With an empty `labels.ready`, it carries only `status:needs-human`. The ready label lets a run find the issue again even when its state file is lost. To give the issue another try, take the `status:needs-human` label off, or answer the hand-over. The next run that claims the issue puts the budgets and the findings back to zero, clears the mark and keeps the branch and the step that the last run reached, so the work carries on where it stopped. After a revert, the branch holds the change again on top of the revert, so the change goes back to the review. An issue that still has the label is not claimed, unless it has an answer to the hand-over: then the run claims it and takes the label off. A label that a person adds to a stopped issue that is not handed over holds the issue, even when an earlier hand-over has an answer. When the label of a hand-over reaches GitHub but its comment does not, an answer to an earlier hand-over does not count: the issue waits, and the worker lists it, until a person takes the label off or a writer comments after that hand-over. Either way, the next run that claims it counts it as a hand-over: it puts the budgets and the findings back to zero and passes on the comments posted after it. When the label edit itself fails, the next run keeps the budgets and the findings.
287
287
 
288
- To give guidance, answer the hand-over with a comment on the issue. When the run resumes the issue, it reads the comments posted after its last `### next-issue · Hand-over: needs help` comment there, or its last `next-issue needs help:` comment, the one-line heading of older versions. Only comments from users with write access to the repository count, for the hand-over comment too. A comment that starts with one of the headings of the harness never counts as an answer. The implementer and every fixer of that run get them in their prompt, under the heading `Answer of a person to the hand-over`. When the questions of the implementer did not reach the issue body, the implementer also gets them under that heading, before the answer, or alone when no comment answers them. A short reply such as "ready, take it" is enough. With no such comment, the run resumes with no guidance.
288
+ To give guidance, answer the hand-over with a comment on the issue. When the run resumes the issue, it reads the comments posted after its last `### next-issue · Hand-over: needs help` comment there, or its last `next-issue needs help:` comment, the one-line heading of older versions. Only comments from users with write access to the repository count, for the hand-over comment too. A comment that starts with one of the headings of the harness never counts as an answer. The implementer and every fixer of that run get them in their prompt, under the heading `Answer of a person to the hand-over`. When the questions of the implementer did not reach the issue body, the implementer also gets them under that heading, before the answer, or alone when no comment answers them. A short reply such as "ready, take it" is enough. With no such comment, the run resumes with no guidance. A watching run picks up a comment-only answer at its next pass, not in the pass that is going. A label change, such as Retry in pi or the `answer-hand-over` skill, gets the issue picked up sooner, at the next read of the open issues.
289
289
 
290
290
  To drop an issue instead, close it. The next run that finds a saved state for an issue that a person closed removes that state file, the `<n>` branch, the `<n>-dispute-*` branches and the worktree of the issue. This holds for an issue that waits for a person and for one that a stop left behind. The run starts no agent and makes no push, revert, label change, close or comment, so a change that already landed stays on the base branch. A worktree or branch that cannot be removed stays, and the run log says so. The issue shows as `skipped` (`closed`) in the summary. A watching run does not claim an issue again once it ended in `error` in that run, so it leaves such an issue for the next run to clean up.
291
291
 
@@ -324,7 +324,7 @@ Version 11.0.0 dropped `--max <n>`, `--reset`, `--json`, `--verbose` and `--quie
324
324
 
325
325
  ## Watch for new issues
326
326
 
327
- A run with `--watch off` ends when no unseen issue is left. With `next-issue start`, or `next-issue start --watch on`, the harness then waits, reads the open issues again and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker closes. Each pass tries every open issue again, also one that an earlier pass skipped. An issue that failed with an error before the claim is not tried again until the next run. An issue that failed after the claim and was handed over with the needs-human label is tried again once a person answers the hand-over or takes the label off. Within a pass, the harness claims a tried issue again at the next read when its labels differ from those it had after its attempt, so an answered hand-over or an unblocked skipped issue does not wait for the next pass. An issue that is done, or that failed with an error and was not handed over, does not come back in the same pass. The hunter counts the same issues as ready.
327
+ A run with `--watch off` ends when no unseen issue is left. With `next-issue start`, or `next-issue start --watch on`, the harness then waits, reads the open issues again and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker closes. Each pass tries every open issue again, also one that an earlier pass skipped. An issue that failed with an error before the claim is not tried again until the next run. An issue that failed after the claim and was handed over with the needs-human label is tried again once a person answers the hand-over or takes the label off. Within a pass, only a change of labels gets a tried issue claimed again: the harness claims it at the next read when its labels differ from those it had after its attempt, so a hand-over answered with a label change or an unblocked skipped issue does not wait for the next pass. A hand-over answered by a comment alone keeps its labels, so it waits for the next pass. An issue that is done, or that failed with an error and was not handed over, does not come back in the same pass. The hunter counts the same issues as ready.
328
328
 
329
329
  The waits follow a fixed back-off in minutes: 1, 2, 3, 5, 10, then 10 from then on. A pass that handles an issue, with any outcome other than `skipped`, resets the back-off to 1 minute. A pass where every issue is skipped does not reset it. Each wait prints a line on standard error with the minutes until the next pass.
330
330
 
@@ -366,9 +366,9 @@ In a run of the `serve` worker, a client can switch hunting and watching on or o
366
366
  - sends every client a `questions` message for each repository: the open issues with the `needsHuman` label, each with its number, title, the reason of the hand-over, the url of the comment that holds it, the `owner/name` repository, and the `needsHuman`, `skip` and `ready` labels. It reads them from GitHub, so the list is the same after a restart. It sends them when a client connects, for its repository, after each issue of a run ends, and when a client sends `{ "type": "questions", "root": "<path>" }`. An issue that no longer has the label leaves the list, and so does an issue whose hand-over has an answer from a writer, the same answer that lets a run claim it. An issue that a person holds with the label stays in the list, even when an earlier hand-over has an answer. An issue with the label but no hand-over comment is in the list with an empty reason and url. The issues are read one at a time. A client never gets an older list after a newer one. When the client adds an `"id"` to its message, the list that answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets `{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
367
367
  - answers `{ "type": "upcoming", "root": "<path>" }` with `{ "type": "upcoming", "root": "<path>", "claimable": [...], "blocked": [...] }`: the open issues with the `ready` label that a run would claim, oldest first, each with its `issue` number and `title`, without issues that have saved state or a label that stops a claim. An issue blocked by open issues is in `blocked` with their references in `blockers`. When the list cannot be read, the client gets `{ "type": "upcoming-error", "root": "<path>", "message": "<text>" }`;
368
368
  - stops a run when a client sends `{ "type": "stop", "root": "<path>", "after": "issue" | "round" | "now" }`. With no `after`, it stops after `issue`. `issue` works like a first `Ctrl-C`: no new claim or hunt, and the held issues and a going hunt finish. `round` works like a second `Ctrl-C`: each running issue stops after its current round, with the state kept, and a going hunt ends first. `now` stops every agent, command and hunt of the run at once, and each running issue ends as `stopped` with its state and labels kept; the worker keeps running. A later point than one already asked for changes nothing, and an earlier one replaces it. An unknown `after` gets an `error` message. While a run is going, the client that sent the stop gets `{ "type": "stopping", "root": "<path>", "waiting": <bool>, "hunting": <bool> }`, with the `id` of the stop when it has one: `waiting` is `true` when the run waited between passes, and `hunting` is `true` when a hunt was going then. `next-issue start` picks its note from it;
369
- - switches watching of a run on or off when a client sends `{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. A run starts with watching on, unless it was started with `--watch off`. On keeps the run going after the current pass, as with `--watch on`. Off ends the run after the current pass, or at once when it waits between passes, and also turns hunting off. With no run going, the message gets an `error` and starts nothing;
370
- - switches hunting of a run on or off when a client sends `{ "type": "hunt", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. Every run of the worker has a hunter: a run started with `--hunt on` starts with hunting on, and any other run with it off. Off lets a hunt that is going finish, so the issues it files stay, and starts no new hunt. On wakes the hunter at once, with no back-off wait, and also turns watching on. With no run going, the message gets an `error` and starts nothing. The settings last for the run only: a new run takes them from its own flags. The progress of each run carries `hunting`, `true` while hunting is on, and `watching`, `true` when the run watches for issues;
371
- - asks a watching run to check for new issues now when a client sends `{ "type": "refresh", "root": "<path>" }`. A run that waits between passes starts a new pass at once, and its next wait starts again at 1 minute; a waiting hunter checks the ready count again. While a pass runs, the run reads the open issues again, so its open-issue count is current, and claims a new issue only when a slot is free. A refresh for a run that is stopping or does not watch, or with no run going, changes nothing and gets no answer;
369
+ - switches watching of a run on or off when a client sends `{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. A run starts with watching on, unless it was started with `--watch off`. On keeps the run going after the current pass, as with `--watch on`. On for a run that a person asked to stop gets an `error` (`the run is stopping`, with the `id` of the request) and changes nothing; on for a run that stops for an upgrade keeps the upgrade, so the run is still resumed. Off ends the run after the current pass, or at once when it waits between passes, and also turns hunting off. With no run going, the message gets an `error` and starts nothing;
370
+ - switches hunting of a run on or off when a client sends `{ "type": "hunt", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. Every run of the worker has a hunter: a run started with `--hunt on` starts with hunting on, and any other run with it off. Off lets a hunt that is going finish, so the issues it files stay, and starts no new hunt. On wakes the hunter at once, with no back-off wait, and also turns watching on. On for a run that a person asked to stop gets the same `error` as watch on. With no run going, the message gets an `error` and starts nothing. The settings last for the run only: a new run takes them from its own flags. The progress of each run carries `hunting`, `true` while hunting is on, and `watching`, `true` when the run watches for issues;
371
+ - asks a watching run to check for new issues now when a client sends `{ "type": "refresh", "root": "<path>" }`. A run that waits between passes starts a new pass at once, and its next wait starts again at 1 minute; a refresh during the last read of the open issues of a pass, or while the pass ends, also starts a new pass at once; a waiting hunter checks the ready count again. While a pass runs, the run reads the open issues again, so its open-issue count is current, and claims a new issue only when a slot is free. A refresh for a run that is stopping or does not watch, or with no run going, changes nothing and gets no answer;
372
372
  - exits, and removes its socket and lock files, when no run is going and no client is connected, or when no client connects in the 30 seconds after it starts;
373
373
  - waits up to 5 seconds for the lock when a worker that is closing still holds it;
374
374
  - closes once no run is going when a client with a newer version connects, so that the client can start the newer worker. The `hello` of a client can say how to start the worker of its version, as `"launch": { "command": "<command>", "args": ["<arg>", ...] }`: pi sends `npx -y next-issue@<version> serve`, and `next-issue start` its own `node <script> serve`. A run that watches is stopped between issues for that, as `stop` with `issue` does: it claims nothing new, and its running issues and its current hunt finish. Its progress then holds `"upgrade": { "from": "<worker version>", "to": "<client version>" }`, with `"resumes": true` when the first newer client gave a `launch`. A stop by a person, or turning watching off, drops that field, so the run does not start again. With `resumes`, once the run ends, the worker stops listening, runs that command in the repository with its output in `.next-issue/worker.log` (or uses a worker that already listens there), and asks the newer worker to start the run again with `--watch on` and the same `--hunt` setting, before it closes. This works with no client connected. When the newer worker does not start or does not start the run, the worker writes the reason to `.next-issue/worker.log`, and its clients see the run `failed` with an `error` that starts with `the worker could not start next-issue <version>`. Without `resumes`, a client starts the newer worker and the run again. A run that does not watch is left alone; a run that `next-issue start` started is not, and `start` follows it to the newer worker. Meanwhile the worker refuses every start with `the worker is restarting, try again soon`. A `start` with `"resume": true` gets no error when the worker refuses it;
package/dist/loop.mjs CHANGED
@@ -69,7 +69,10 @@ export async function runIssues(loop, seen = new Set()) {
69
69
  finally {
70
70
  ended.abort();
71
71
  }
72
- return loopResult(reports, stoppedAt, error, crash);
72
+ return { ...loopResult(reports, stoppedAt, error, crash), ...refreshedOf(refresh) };
73
+ }
74
+ function refreshedOf(refresh) {
75
+ return refresh.signal === undefined ? {} : { refreshed: refresh.signal };
73
76
  }
74
77
  function refreshes(loop, ended, previous) {
75
78
  const signal = loop.refreshed?.();
package/dist/serve.mjs CHANGED
@@ -145,6 +145,7 @@ export async function startWorker(options) {
145
145
  }
146
146
  const run = runs.get(root);
147
147
  if (run !== undefined && active(run)) {
148
+ run.stoppedByPerson = true;
148
149
  send(socket, stoppingMessage(root, run, id));
149
150
  }
150
151
  const dropped = dropUpgrade(run);
@@ -154,7 +155,7 @@ export async function startWorker(options) {
154
155
  };
155
156
  const toggle = (refuse, root, on, set) => {
156
157
  const run = runs.get(root);
157
- const refusal = switchRefusal(run);
158
+ const refusal = switchRefusal(run, on);
158
159
  if (refusal !== undefined) {
159
160
  refuse(refusal);
160
161
  return;
package/dist/watch.mjs CHANGED
@@ -98,8 +98,9 @@ async function watchPasses(failed, watch) {
98
98
  for (;;) {
99
99
  const pass = await runIssues(watch, new Set(failed));
100
100
  addReports(reports, pass.reports);
101
+ const { refreshed, ...result } = pass;
101
102
  if (pass.crash !== undefined) {
102
- return { ...pass, reports };
103
+ return { ...result, reports };
103
104
  }
104
105
  recordFailures(failed, pass.reports);
105
106
  if (handled(pass.reports) > 0) {
@@ -107,14 +108,14 @@ async function watchPasses(failed, watch) {
107
108
  step = 0;
108
109
  }
109
110
  if (pass.error !== undefined || pass.stoppedAt !== undefined) {
110
- return { ...pass, reports };
111
+ return { ...result, reports };
111
112
  }
112
113
  if (watch.stop() || !watching()) {
113
114
  return { reports };
114
115
  }
115
116
  const minutes = backOffMinutes(step);
116
117
  step += 1;
117
- const signals = [watch.refreshed?.(), watch.watching?.changed()].filter((signal) => signal !== undefined);
118
+ const signals = [refreshed ?? watch.refreshed?.(), watch.watching?.changed()].filter((signal) => signal !== undefined);
118
119
  const woken = signals.length === 0 ? undefined : AbortSignal.any(signals);
119
120
  if (!(await watch.wait(minutes, woken))) {
120
121
  if (woken?.aborted !== true || watch.stop() || !watching()) {
@@ -69,9 +69,13 @@ export function stoppingMessage(root, run, id) {
69
69
  };
70
70
  }
71
71
  export function requestUpgrade(run, upgrade) {
72
- if (!run.watching.on() || run.stop !== undefined || !requestStop(run, 'issue')) {
72
+ if (!active(run) ||
73
+ !run.watching.on() ||
74
+ run.stoppedByPerson === true ||
75
+ run.progress.upgrade !== undefined) {
73
76
  return false;
74
77
  }
78
+ requestStop(run, 'issue');
75
79
  run.progress = { ...run.progress, upgrade };
76
80
  return true;
77
81
  }
@@ -82,8 +86,11 @@ export function dropUpgrade(run) {
82
86
  run.progress = { ...run.progress, upgrade: undefined };
83
87
  return true;
84
88
  }
85
- export function switchRefusal(run) {
86
- return active(run) ? undefined : 'no run is going in this repository';
89
+ export function switchRefusal(run, on) {
90
+ if (!active(run)) {
91
+ return 'no run is going in this repository';
92
+ }
93
+ return on && run.stoppedByPerson === true ? 'the run is stopping' : undefined;
87
94
  }
88
95
  // Only a running watch run refreshes: it wakes the wait between passes, or reads the open issues again during a pass.
89
96
  export function requestRefresh(run) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "12.5.0",
3
+ "version": "12.5.2",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",