next-issue 10.7.0 → 10.7.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
@@ -36,7 +36,7 @@ Before each issue, fetch the open issues again and take the oldest one not yet s
36
36
 
37
37
  `next-issue start` runs the work in the worker of the repository, see [Worker](#worker). It connects to the worker, or starts one in the background (`next-issue serve` of the same version, with its output in `.next-issue/worker.log`) when none answers, and then starts the run there with its flags. It prints the output of the run on standard error and the summary on standard output, and exits with the exit code of the run. When the terminal closes or the command ends some other way, the run keeps going in the worker, and pi and `next-issue logs` still show it. pi shows the run in `/next-issue` and the dashboard, and its Stop, Watch, Hunt and Refresh work on it. When the worker is older than `start` and no run is going, it closes and `start` starts a new one. When a run is going in the worker already, `start` exits with code 1 and the error `a run is going in this repository already`, and leaves that run alone: it does not tell an older worker its version, so the worker does not stop a watching run for an upgrade. `start` ignores `--force`, as before.
38
38
 
39
- Only one worker goes at a time in a repository. It holds the lock `.next-issue/worker.lock`, with the process id and the start time of that process, for its whole life. A run that the worker starts takes no lock of its own, since the worker runs at most one run at a time. When a process that does not take connections on the worker socket holds the lock, for example a command-line run of an older version, `start` claims no issue and exits with code 1 and the error `another next-issue worker or run (process id <n>) is going in this repository`. A lock whose process is gone, or started at another time, is stale and taken over.
39
+ Only one worker goes at a time in a repository. It holds the lock `.next-issue/worker.lock`, with the process id and the start time of that process, for its whole life. A run that the worker starts takes no lock of its own, since the worker runs at most one run at a time. When a process that does not take connections on the worker socket holds the lock for more than 2 seconds, `start` starts a worker anyway, which exits with `another worker is running`, so `start` claims no issue and exits with code 1 and the error `the next-issue worker exited before it listened: exit code 1 (see .next-issue/worker.log)`. A lock whose process is gone, or started at another time, is stale and taken over.
40
40
 
41
41
  Every command uses the main worktree of the repository as its root, the first one that `git worktree list` shows, even when it runs in a linked worktree. So `.next-issue/`, with the config, the locks, the worker socket, the saved state and the notes, and `.worktrees/` are always in the main worktree, and a run or worker started from a linked worktree gets the same refusal as one started from the main worktree.
42
42
 
@@ -45,7 +45,7 @@ A run works on up to `concurrency` issues with an agent at the same time, 1 by d
45
45
  1. Claim the issue only when it holds the `status:todo` label and holds no `status:in-progress` or `status:in-review` label. A `status:done`, `status:needs-human` or `status:blocked` label always stops the claim, a resume too, except a `status:needs-human` issue with an answer to its hand-over that the run made, and except an issue whose finish a stop cut short and that was not handed over (see step 7 below). An issue that GitHub lists as blocked by an open issue waits, because its blocker closes only when the change of the blocker lands. An issue with saved state under `.next-issue/` resumes instead, whatever its other labels and blockers.
46
46
  2. Add `status:in-progress` to the issue.
47
47
  3. Fetch the remote, fast-forward the local copy of the default branch when that is safe, then add a git worktree at `.worktrees/<n>` in the repository root on the `<n>` branch. An issue that resumes from saved state keeps the branch name that the state holds, and a worktree that holds that branch already stays in use. A branch that exists on the remote is the start, and a local branch that fell behind the remote is fast-forwarded; a local branch that cannot be fast-forwarded stays as it is and the harness writes a `branch.behind` event. The fetch prunes remote branches, so a remote branch that was deleted does not count. A local branch that the remote does not hold and that has no commits of its own starts again from the remote base. An issue with no saved state does not reuse a local `<n>` branch: it resets that branch, and any worktree that holds it, to the remote branch, or to the remote base when there is none. A worktree at `.worktrees/<n>` left on a detached HEAD, for example by a crash, is removed, but its uncommitted files are first committed on a `<n>-detached-<sha>` branch, so they are kept. The main worktree of the repository is never used, reset or cleaned: when it has the branch of the issue checked out, the issue fails and is handed over, and the reason asks you to check out another branch there. A fast-forward of the base that is not safe leaves the local base branch as it is and writes a `base.behind` event. A new branch then starts from the remote base.
48
- 4. Let the implementer agent do the work, then commit it. For a behaviour change, the implementer writes the test first and quotes its failing output in its reply. The harness keeps that reply in the state file for the reviewer. The branch is not pushed. When a git hook stops a commit, the agent that made the change gets the hook output, fixes it, and the harness commits again. A `commit:` line in the reply of the agent replaces the subject, so a hook that rejects the subject can pass. The harness drops each GitHub closing keyword (`close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, `resolve`, `resolves`, `resolved`) that names an issue from the subject, so a push to the base never closes an issue: the issue closes only after its checks pass. The budget is `maxCommitFixes`. Any other git failure in the commit stops the run with an error. An implementer that makes no change hands the issue to a person, unless the branch is already ahead of the base, for example when an issue resumes from saved state in phase `claimed`, or when the remote holds branch `<n>`: the run then carries on with the commits on the branch, and the newest of them gives the subject of the landed commit. A lost state file does not count, since an issue with no saved state resets its local branch (step 3). When the base already does all that the issue asks, the implementer makes no change and ends its reply with a `done: <evidence>` line. If the branch is not ahead of the base, a reviewer then checks that claim against the base. When it raises no blocking finding, the harness comments `### next-issue · Worker: already done` with the evidence and the summary of the reviewer, adds `status:done` and closes the issue as completed, and the issue ends as `done`. Otherwise it hands the issue to a person with the reason `already done disputed`, and the comment holds the evidence and the findings of the reviewer. A reply with a `question:` line asks the questions instead. To close a parent issue once its sub-issues land, mark it as blocked by each sub-issue and give it the `status:todo` label: it waits while a sub-issue is open (step 1), then the implementer finds it already done and the harness closes it. The implementer checks the issue first. When the scope, the expected behaviour or the acceptance criteria are ambiguous, it makes no change and asks instead of guessing, with each question on its own `question: <n>. <question>` line, its options labelled by letters and one option recommended. A reply with at least one `question:` line makes the harness drop any change in the worktree, commit nothing and hand the issue to a person with the reason `questions`. The hand-over comment lists the questions in order, numbered by the harness. The harness reads the issue again and adds the questions after any text under its `Open questions` heading, or adds that heading at the end of the body when it has none. When that read or body edit fails, the harness records a `questions.body-failed` event in the run log and still hands the issue over with the questions in the comment. It also keeps the questions in the state of the issue, so the implementer of the run that resumes the issue finds them next to the answer of a person, not in the issue body.
48
+ 4. Let the implementer agent do the work, then commit it. For a behaviour change, the implementer writes the test first and quotes its failing output in its reply. The harness keeps that reply in the state file for the reviewer. The branch is not pushed. When a git hook stops a commit, the agent that made the change gets the hook output, fixes it, and the harness commits again. A `commit:` line in the reply of the agent replaces the subject, so a hook that rejects the subject can pass. The harness drops each GitHub closing keyword (`close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, `resolve`, `resolves`, `resolved`) that names an issue from the subject, so a push to the base never closes an issue: the issue closes only after its checks pass. The budget is `maxCommitFixes`. Any other git failure in the commit stops the run with an error. An implementer that makes no change hands the issue to a person, unless the branch is already ahead of the base, for example when an issue resumes from saved state in phase `claimed`, or when the remote holds branch `<n>`: the run then carries on with the commits on the branch, and the newest of them gives the subject of the landed commit. A lost state file does not count, since an issue with no saved state resets its local branch (step 3). When the base already does all that the issue asks, the implementer makes no change and ends its reply with a `done: <evidence>` line. If the branch is not ahead of the base, a reviewer then checks that claim against the base. The harness puts the branch back after this reviewer as it does after the reviewer of step 5, also when it times out, fails or the run stops. When it raises no blocking finding, the harness comments `### next-issue · Worker: already done` with the evidence and the summary of the reviewer, adds `status:done` and closes the issue as completed, and the issue ends as `done`. Otherwise it hands the issue to a person with the reason `already done disputed`, and the comment holds the evidence and the findings of the reviewer. A reply with a `question:` line asks the questions instead. To close a parent issue once its sub-issues land, mark it as blocked by each sub-issue and give it the `status:todo` label: it waits while a sub-issue is open (step 1), then the implementer finds it already done and the harness closes it. The implementer checks the issue first. When the scope, the expected behaviour or the acceptance criteria are ambiguous, it makes no change and asks instead of guessing, with each question on its own `question: <n>. <question>` line, its options labelled by letters and one option recommended. A reply with at least one `question:` line makes the harness drop any change in the worktree, commit nothing and hand the issue to a person with the reason `questions`. The hand-over comment lists the questions in order, numbered by the harness. The harness reads the issue again and adds the questions after any text under its `Open questions` heading, or adds that heading at the end of the body when it has none. When that read or body edit fails, the harness records a `questions.body-failed` event in the run log and still hands the issue over with the questions in the comment. It also keeps the questions in the state of the issue, so the implementer of the run that resumes the issue finds them next to the answer of a person, not in the issue body.
49
49
  5. Let the reviewer agent judge the diff, at most `diffMaxChars` of it. The reviewer reads files and runs commands in the worktree, so it can prove a finding with the tests or the type check. The harness then throws away every change that the reviewer left in the worktree, so no such change can reach a later commit. When the reviewer left another branch or a detached `HEAD` checked out, the harness checks out the issue branch again at its commit from before the review. It does the same when the reviewer times out or fails. The state file keeps that commit while the reviewer runs, so when the run stops during the review, the next run that resumes the issue first puts the issue branch back at that commit, before the setup command, and the diff it reads holds no reviewer commit. A commit that a person adds to the branch after a hand-over stays on it. The first reviewer also gets the reply of the implementer, and raises a finding when a behaviour change has no failing run of its test. A later reviewer gets the reply of the last review fixer instead, who quotes the failing run of a test for a behaviour change. The reviewer ends its last message with its verdict as a json block: a summary and one entry per finding, each rated `blocking` or `minor`. A reply without a valid block hands the issue to a person. The findings are the only ground truth. The reviewer gives no approve or reject field, because such a field can contradict the findings. The harness puts the result on the issue. A result longer than a GitHub comment (65536 characters) is cut to fit, with a last line that says so.
50
50
  6. An open finding is any finding, blocking or minor, while a review round is left. In the last round, only a blocking finding stays open: a minor finding there goes on the issue but starts no fix, because a fix in the last round gets no review. Thus `maxReviewRounds` of `1` never fixes a minor finding.
51
51
  7. No open finding means approval: the change lands on the base branch. Approved changes land one at a time, so the next one waits, without a slot, until the checks of the last one end, and other issues go on meanwhile. The harness fetches the remote base, merges it into the branch and makes the change one commit on top of it, with the subject of the implementer's commit. A review fix keeps that subject, but a commit fix for the implementer's commit replaces it, and a fix for failed checks after the landing lands under the fixer's own subject. The reapply commit after a revert uses the subject of the change. When git merges the base cleanly, no agent runs. When a conflicted file holds no conflict marker, for example a file that one side deletes and the other changes, a renamed file or a binary file that both sides change, no agent runs: the harness undoes the merge and hands the issue to a person with the reason `merge conflict`, since git leaves only one side in the file. When git reports conflicted files, the fixer gets the list from the check budget, `maxCiFixes`, removes the conflict markers, and the harness commits the merge. A merge that the fixer commits itself counts only when the branch then holds the base commit that was merged and the listed files hold no conflict marker. With the budget used up, or when the fixer leaves a conflict marker or the merge unresolved, aborts the merge, or fails, the harness undoes the merge and hands the issue to a person with the reason `merge conflict`. When `checks` lists commands, the harness then runs the setup command again in the worktree, so the checks use the dependencies of the merged base. It runs the setup after it makes the change one commit, and commits what the setup writes, unless git ignores it, on top of that commit without hooks. Every check runs on that setup commit. After the checks, the harness puts the branch back at the change commit, so what this setup writes does not land on the base; after a stop or kill during the checks, the next run puts the branch back first. What the first setup writes, before the implementer, is part of the implementer's commit and lands. When this setup rewrites such a file, for example a lock file, the checks run on the rewritten file, but the base gets the file of the change. A change that the base already holds is an `empty change` before the setup runs. A setup that fails or does not finish in `setupTimeoutMinutes` keeps the merged commit, stops the landing before the push and hands the issue to a person with the reason `setup failed` or `setup timeout`. The harness then runs each command in `checks` in the worktree, in order, with `bash -c` and stderr merged into stdout, each for at most `checksTimeoutMinutes`. Their output goes to the run log (`check.output`, and `check.fail` for a failure). After each command, the harness resets the worktree to the commit it checked and removes untracked files that git does not ignore, so a file that a command writes never lands on the base. A command that fails or does not finish stops the landing before the push: the fixer gets the command and the tail of its output (at most `logMaxChars`) from the check budget, `maxCiFixes`, and its fix is squashed into the change, which keeps its subject. The harness then merges the base again and runs every command again, so nothing lands until all pass. When the budget runs out, the harness hands the issue to a person with the reason `local checks failed: <command>` and the tail of the output in the comment; a fixer that adds no commit or calls the failure unrelated hands it over too, as for the checks on the base. Nothing of the change reaches the base. A run that stops while a command runs keeps the budget, and the next run merges and runs every command again before any push. The state file keeps the merged commit from the squash until the push, so the next run that resumes the issue first puts the issue branch back at that commit, before the setup command. A commit that a person adds to the branch after a hand-over stays on it. The harness then pushes the commit to the base branch, without force. When the push fails, the harness fetches the base first, and treats the push as landed when the base holds the commit, for example after a timeout. When the base moved, for example because someone else pushed first, the harness starts the rebase again, three times at most. When the base did not move, for example on a missing permission or a branch protection rule, the harness hands the issue to a person at once with the reason `push failed`, without running the checks again. Each `push failed` comment holds the tail of the last error of git. When that fetch fails too, the harness hands the issue to a person with the reason `push unknown` and halts, even when the hand-over fails. The state file holds the commit during the push, so a run stopped meanwhile, or the resume after that hand-over (once a person answers or takes the label off), checks the base and waits for the checks of the commit when it landed. Until then, no run lands another change (see below). Once the commit lands, the harness fetches the remote and fast-forwards the local base branch to it when that is safe. A fetch that fails or a fast-forward that is not safe leaves the local base branch as it is and writes a `base.behind` event, and the landing goes on. The harness then waits for the checks of the pushed commit on the base branch: the GitHub Actions workflow runs that a `push` of the base branch started on it, its commit statuses and the check runs of every other GitHub App, so checks from another CI service count too. It leaves out the check runs of the GitHub Actions app, since it judges GitHub Actions by its workflow runs. It leaves out workflow runs that any other event (such as `issues`, `issue_comment` or `schedule`) started, since GitHub gives such a run the tip of the default branch as its commit. It also leaves out the `push` runs that a push of a tag or of another branch started on the same commit, such as a release or a deploy. It leaves out every GitHub Actions job, check run and commit status whose name is in `ignoredChecks`: it does not wait for it, its result does not fail the checks and its logs do not go to the fixer. With `ignoredChecks` set, the harness judges each workflow run by its other jobs, so a run whose only failed job is ignored passes when every other job passes. A run that GitHub concludes `success` passes as it is, so a failed job with `continue-on-error: true` does not fail the checks. When an ignored job fails and GitHub cancels another job of the same run, for example through the default `strategy.fail-fast` of a matrix, that job never finished: the harness hands the issue to a person with the reason `main checks cut short` and halts, and the issue stays open. Set `fail-fast: false` on a matrix with an ignored job to avoid this. The same goes when an ignored job fails and another job of the same run ends `skipped`, for example because it `needs` the ignored job; a skipped job in a run with no failed job still passes. A failed or errored commit status, or a workflow run or check run that ends with `failure`, `timed_out` or `action_required`, fails the checks. The harness does not rerun a workflow run that ends `action_required`, since it waits for a person to approve it. When any check ends `cancelled`, for example because a later push cancelled the workflow run, that check never finished, even when another check (such as a release workflow) ends `success`: the harness hands the issue to a person with the reason `main checks cancelled` and halts, and the issue stays open. A repository that reports no check keeps asking for `checkGraceSeconds`. When every check passes, the harness keeps asking until `checkGraceSeconds` have gone by since it first read the checks, since GitHub can add a check a few seconds after the others; a check that shows up in that time counts, and one that shows up later does not. A pending state waits again, up to `checkTimeoutMinutes`. A read that fails is tried three times. When the first read of the checks of a landed change still fails, for example on a rate limit or an expired token, the harness hands the issue to a person with the reason `checks error` and halts, before the next change lands. The comment holds the error and says that the landed commit is on the base and its checks were not awaited. The state file keeps the commit, so the resume after a person answers or takes the label off waits for its checks, and until then no run lands another change (see below). When the checks pass, the harness marks the state file as closing, sets `status:done` and closes the issue. When a run stops or dies before the close, the next run sees the mark, sets `status:done` and closes the issue, with no new push, revert or hand-over. A hand-over clears the mark, so an issue taken back after a failed label edit or close is resumed, not closed, by later runs. When a run stops or dies after the close, before the state file goes away, the next run finds the closed issue through its state file and removes the worktree, the local branches and the state file, with no new push, revert, label, close or hand-over. A label or close that fails for another reason hands the issue over, and it then waits for a person like any other hand-over. Then the worktree, the local branch and the state file go away. When the checks fail, the harness reruns the failed jobs of each failed GitHub Actions workflow run once with `gh run rerun <id> --failed`, records a `ci-checks.rerun` event and waits again once the runs restart. A failed run whose failed jobs were already rerun (its attempt on GitHub is above 1) is not rerun again, so a resumed run reruns only the runs not rerun yet. A failure that gets a rerun ends the wait at once; any other failure (a run that was rerun, a run that waits for approval, a check from another CI service) waits until every check has finished, so a workflow run that fails later, even after the first rerun started, still gets its own rerun before any fixer. A workflow run whose kept job failed while a job in `ignoredChecks` still runs gets its rerun only once the whole run has finished on GitHub, as GitHub refuses to rerun a running run. A rerun that GitHub refuses because the run is already running counts as started. When at least one run restarted and a later rerun or read fails, the event carries the error and the harness still waits for the checks again, counting each restarted run as running until a later attempt of it completes, so the fixer never runs while a rerun is queued or in progress. When the rerun cannot start (no run restarted, a `ci-checks.rerun-failed` event), or the checks fail again with no run left to rerun, the fixer gets their logs from the check budget (for a check from another CI service, only its name and link), and its fix lands the same way. When the fixer cannot fix them, its fix cannot land, an error stops the fix, or the budget runs out, the harness reverts every commit of the change on the base branch, pushes the revert and hands the issue to a person. When the push of the fix ends as `push unknown`, the harness does not revert: it hands the issue over and halts as for any other `push unknown`. A revert push that the remote refuses, for example because the base moved, makes the revert again on the new base, three times at most. A failed revert push that the base holds after a fetch counts as landed. Once the revert lands, the harness fast-forwards the local base branch to it, as after a landed commit. When that fetch fails too, the revert may be on the base with checks nobody awaited: the harness reports it so, saves the halt and blocks later landings. The state file holds the revert commit during the push, so a run stopped meanwhile checks the base on resume. When the base holds the revert, the harness puts the change back on the branch on top of the revert, as after a revert that completes (an unlanded fix commit is dropped), drops the landed commits from the state, waits for no checks, does not revert again, hands the issue to a person with the reason `revert stopped` and halts. A resume that stopped while the checks of a landed commit ran waits for them again, even when more commits landed on the base since, and a fix that was committed but not landed lands first. Before that, the resume drops any change left in the worktree, including a merge of the base that a stopped fix landing left in progress, so the fix merges the current base again from the start. A problem that the reviewer leaves out of the findings thus gets an approval: only the findings count.
@@ -353,7 +353,7 @@ In a run of the `serve` worker, a client can switch hunting and watching on or o
353
353
  `next-issue serve` runs one worker for the repository it is run in. The [`@ravshansbox/pi-next-issue`](../pi-next-issue) extension and `next-issue start` start it and talk to it. `serve` takes no flags apart from `--help` and refuses any other with an error, because runs start from a client, not from `serve`. Each repository has its own worker, so the runs, restarts and upgrades of one repository never affect another. The worker:
354
354
 
355
355
  - listens with WebSocket on the socket file `.next-issue/worker.sock` in the repository. Only your user can open the file. It works on macOS and Linux. When the path of the socket file is too long for the system, about 103 bytes on macOS and 107 on Linux, it exits with an error that says so;
356
- - holds `.next-issue/worker.lock` in the repository, with its process id and the start time of that process, so only one worker or command-line run goes per repository. A worker that starts while a command-line run holds the lock exits with `another worker is running`. A lock is stale, and is taken over, when no process has that id or the process with that id started at another time, for example because the system gave the id of a worker that was killed or lost in a reboot to another process. A lock without a start time, from an older version, is held while a process with that id is alive, and stale otherwise. A worker that cannot read its own start time exits with an error and takes no lock. When several workers start at once, one takes the lock and the others exit with `another worker is running`. A worker that stops removes the lock file only while it still holds the lock, and the socket file only while it is still the socket it bound;
356
+ - holds `.next-issue/worker.lock` in the repository, with its process id and the start time of that process, so only one worker goes per repository. A worker that starts while another process holds the lock exits with `another worker is running`. A lock is stale, and is taken over, when no process has that id or the process with that id started at another time, for example because the system gave the id of a worker that was killed or lost in a reboot to another process. A lock without a start time, from an older version, is held while a process with that id is alive, and stale otherwise. A worker that cannot read its own start time exits with an error and takes no lock. When several workers start at once, one takes the lock and the others exit with `another worker is running`. A worker that stops removes the lock file only while it still holds the lock, and the socket file only while it is still the socket it bound;
357
357
  - refuses a `start`, `stop`, `watch`, `hunt`, `questions` or `upcoming` message whose `root` is not the exact path of its repository with an `error` message, and starts or stops nothing;
358
358
  - sends each `error` as `{ "type": "error", "root": "<path>", "message": "<text>" }`. When a `start`, `stop`, `watch`, `hunt` or `refresh` message carries an `"id"`, the `error` that refuses it carries the same `id`;
359
359
  - runs at most one run at a time. A client starts it with `{ "type": "start", "root": "<path>", "args": [...] }`. Each run is like `next-issue start` with those args, or with none when `args` is left out (the pi extension sends none). It takes `--max <n>`, `--watch`, `--hunt`, `--reset`, `--verbose` and `--quiet`, and refuses a command (`start` too), `--json`, `--force`, `--help` or an unknown argument with an `error` message;
@@ -373,7 +373,7 @@ In a run of the `serve` worker, a client can switch hunting and watching on or o
373
373
  - stops every agent and command and exits on `SIGTERM`, `SIGHUP` or `SIGINT`, and removes its socket and lock files;
374
374
  - keeps `.next-issue/worker.log`, where the extension writes the output of the worker, within 10 MiB: when it starts and once a minute while it runs, it cuts a log of more than 10 MiB to its newest 5 MiB, from the start of a line. It skips the cut while a command that writes to the log runs. The run logs under `.next-issue/runs/` hold the same events.
375
375
 
376
- Stop the worker of a repository with `next-issue stop` in that repository. Workers of other repositories carry on. This sends `SIGTERM` to the process in the lock file when the lock is not stale and the worker socket file takes a connection, so the worker stops at once and a run that is going resumes from its saved state next time. When no worker is running, the command says so and exits with 0. When a command-line run of an older version holds the lock, the command sends no signal, says `no worker is running; a command-line run (process id <n>) is going, press Ctrl-C there to stop it` and exits with 0.
376
+ Stop the worker of a repository with `next-issue stop` in that repository. Workers of other repositories carry on. This sends `SIGTERM` to the process in the lock file when the lock is not stale, and for a lock without a start time only when the socket of the worker takes a connection, so the worker stops at once and a run that is going resumes from its saved state next time. When no worker is running, the command says so and exits with 0.
377
377
 
378
378
  Versions before one worker per repository ran one worker for the machine, with `next-issue.sock`, `next-issue.lock` and `next-issue.roots.json` in `~/.pi/agent`, or in the folder that `PI_CODING_AGENT_DIR` names. That worker does not stop by itself, `next-issue stop` does not reach it, and a run in it can claim issues alongside the new worker of the same repository. Stop it once after you upgrade:
379
379
 
package/dist/cli.mjs CHANGED
@@ -51,7 +51,6 @@ function run(root, args, argv) {
51
51
  }
52
52
  const STOPPED = {
53
53
  none: () => 'next-issue: no worker is running\n',
54
- run: (pid) => `next-issue: no worker is running; a command-line run (process id ${pid}) is going, press Ctrl-C there to stop it\n`,
55
54
  worker: (pid) => `next-issue: stopped the worker with process id ${pid}\n`,
56
55
  };
57
56
  async function stop(root) {
@@ -6,6 +6,7 @@ import { escalateAndFinish, finishDone } from './handover.mjs';
6
6
  import { numbered, withOpenQuestions } from './issue-format.mjs';
7
7
  import { fallbackTitle, ROUND_CONTINUE, runRole, } from './job.mjs';
8
8
  import { donePrompt, implementPrompt } from './prompts.mjs';
9
+ import { undoingReview } from './review.mjs';
9
10
  import { writeState } from './state.mjs';
10
11
  import { agentHeading } from './text.mjs';
11
12
  import { blockingFindings, formatFindings, parseVerdict } from './verdict.mjs';
@@ -67,11 +68,11 @@ function noChangeNote(reply) {
67
68
  return `${NO_CHANGE}\n\n${text}`;
68
69
  }
69
70
  async function closeIfDone(job, evidence) {
70
- const { context, issue, log, worktree, comments, branch } = job;
71
- const { ports } = context;
72
- const before = await ports.revision(worktree);
73
- const review = await log.step('review', { alreadyDone: true }, () => runRole(job, 'reviewer', donePrompt(issue, comments, evidence), REVIEWING));
74
- await ports.discardChanges(worktree, before, branch);
71
+ const { context, issue, log, state, worktree, comments } = job;
72
+ const before = await context.ports.revision(worktree);
73
+ state.reviewing = before;
74
+ await writeState(context.repo, state);
75
+ const review = await undoingReview(job, before, () => log.step('review', { alreadyDone: true }, () => runRole(job, 'reviewer', donePrompt(issue, comments, evidence), REVIEWING)));
75
76
  const verdict = parseVerdict(review.text);
76
77
  const blocking = verdict === undefined ? [] : blockingFindings(verdict);
77
78
  if (verdict === undefined || blocking.length > 0) {
package/dist/lock.mjs CHANGED
@@ -147,7 +147,7 @@ async function removeDeadDrafts(path) {
147
147
  }
148
148
  }
149
149
  }
150
- function listening(socketPath) {
150
+ function takesConnection(socketPath) {
151
151
  return new Promise((resolve) => {
152
152
  const socket = createConnection(socketPath);
153
153
  socket.once('connect', () => {
@@ -158,13 +158,12 @@ function listening(socketPath) {
158
158
  });
159
159
  }
160
160
  export async function stopWorker(paths) {
161
- const pid = await lockHolder(paths.lockPath);
162
- if (pid === undefined) {
161
+ const text = await readTextOrEmpty(paths.lockPath);
162
+ const pid = await holderOf(text);
163
+ const unverified = text.trim().split(' ').length === 1;
164
+ if (pid === undefined || (unverified && !(await takesConnection(paths.socketPath)))) {
163
165
  return { stopped: 'none' };
164
166
  }
165
- if (!(await listening(paths.socketPath))) {
166
- return { stopped: 'run', pid };
167
- }
168
167
  process.kill(pid, 'SIGTERM');
169
168
  return { stopped: 'worker', pid };
170
169
  }
package/dist/loop.mjs CHANGED
@@ -89,6 +89,7 @@ function readmitChanged(issues, seen, tried) {
89
89
  for (const [number, labels] of tried.labels) {
90
90
  if (listed.has(number) && listed.get(number) !== labels) {
91
91
  tried.labels.delete(number);
92
+ tried.blocked.delete(number);
92
93
  seen.delete(number);
93
94
  }
94
95
  }
package/dist/review.mjs CHANGED
@@ -96,14 +96,18 @@ async function runReviewer(job, earlier) {
96
96
  diffChars: full.length,
97
97
  cut: full.length > config.diffMaxChars,
98
98
  };
99
- let review;
99
+ const review = await undoingReview(job, before, () => log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier, earlier.length === 0 ? state.implementerReply : state.fixerReply), REVIEWING)));
100
+ return review.text;
101
+ }
102
+ export async function undoingReview(job, before, review) {
103
+ let result;
100
104
  try {
101
- review = await log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier, earlier.length === 0 ? state.implementerReply : state.fixerReply), REVIEWING));
105
+ result = await review();
102
106
  }
103
107
  catch (error) {
104
108
  if (!runStopped()) {
105
109
  await undoReview(job, before).catch((cleanup) => {
106
- log.event('review.discard.error', { error: message(cleanup) }, 'quiet');
110
+ job.log.event('review.discard.error', { error: message(cleanup) }, 'quiet');
107
111
  });
108
112
  }
109
113
  throw error;
@@ -111,7 +115,7 @@ async function runReviewer(job, earlier) {
111
115
  if (!runStopped()) {
112
116
  await undoReview(job, before);
113
117
  }
114
- return review.text;
118
+ return result;
115
119
  }
116
120
  export async function settleReview(job) {
117
121
  if (job.state.reviewing !== undefined) {
package/dist/run.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import { mkdir, rm } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
3
1
  import { recordCommands } from './command-records.mjs';
4
2
  import { loadConfig } from './config.mjs';
5
3
  import { minutesToMs } from './durations.mjs';
@@ -12,7 +10,6 @@ import { checkGitVersion } from './git-version.mjs';
12
10
  import { defaultBranch } from './github.mjs';
13
11
  import { hunter } from './hunt.mjs';
14
12
  import { onOff } from './switch.mjs';
15
- import { lock, lockHolder } from './lock.mjs';
16
13
  import { exitCode, runIssues } from './loop.mjs';
17
14
  import { Recorder } from './observe.mjs';
18
15
  import { pendingIssues } from './pending.mjs';
@@ -22,24 +19,6 @@ import { pruneRuns } from './prune-runs.mjs';
22
19
  import { count } from './summary.mjs';
23
20
  import { packageVersion } from './version.mjs';
24
21
  import { watchIssues } from './watch.mjs';
25
- import { workerPaths } from './worker-paths.mjs';
26
- export async function runLocked(root, args, controls) {
27
- const path = workerPaths(root).lockPath;
28
- await mkdir(dirname(path), { recursive: true });
29
- const held = await lock(path, 0);
30
- if (held === undefined) {
31
- const pid = await lockHolder(path);
32
- throw new Error(`another next-issue worker or run (process id ${pid ?? 'unknown'}) is going in this repository`);
33
- }
34
- try {
35
- return await runRepo(root, args, controls);
36
- }
37
- finally {
38
- if (held.owns()) {
39
- await rm(path, { force: true });
40
- }
41
- }
42
- }
43
22
  export async function runRepo(root, args, controls) {
44
23
  const config = await loadConfig(root, { sortFile: true });
45
24
  return withDefaultTimeout(minutesToMs(config.commandTimeoutMinutes), () => runWithConfig(root, args, controls, config));
@@ -21,9 +21,6 @@ class SilentWorker extends Error {
21
21
  export function going(progress) {
22
22
  return progress?.status === 'running' || progress?.status === 'stopping';
23
23
  }
24
- function runGoing(pid) {
25
- return new Error(`another next-issue worker or run (process id ${pid}) is going in this repository`);
26
- }
27
24
  function parse(text) {
28
25
  try {
29
26
  return JSON.parse(text);
@@ -105,13 +102,9 @@ async function tryOpen(socketPath, version) {
105
102
  async function waitForHolder(paths, version) {
106
103
  const deadline = Date.now() + HOLDER_GRACE_MS;
107
104
  for (;;) {
108
- const pid = await lockHolder(paths.lockPath);
109
- if (pid === undefined) {
105
+ if ((await lockHolder(paths.lockPath)) === undefined || Date.now() >= deadline) {
110
106
  return undefined;
111
107
  }
112
- if (Date.now() >= deadline) {
113
- throw runGoing(pid);
114
- }
115
108
  await delay(POLL_MS);
116
109
  const opened = await tryOpen(paths.socketPath, version);
117
110
  if (opened !== undefined) {
@@ -129,10 +122,7 @@ async function waitForStart(paths, version, exited) {
129
122
  return opened;
130
123
  }
131
124
  if (reason !== undefined) {
132
- const pid = await lockHolder(paths.lockPath);
133
- throw pid === undefined
134
- ? new Error(`the next-issue worker exited before it listened: ${reason}`)
135
- : runGoing(pid);
125
+ throw new Error(`the next-issue worker exited before it listened: ${reason}`);
136
126
  }
137
127
  if (Date.now() >= deadline) {
138
128
  throw new Error('the next-issue worker did not start (see .next-issue/worker.log)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "10.7.0",
3
+ "version": "10.7.2",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",