next-issue 10.0.0 → 10.1.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 +4 -4
- package/dist/hand-over-comments.mjs +16 -4
- package/dist/handover.mjs +1 -2
- package/dist/implement.mjs +2 -1
- package/dist/review.mjs +2 -2
- package/dist/text.mjs +4 -0
- package/dist/verdict.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ A run handles up to `concurrency` issues at the same time, 1 by default. When an
|
|
|
43
43
|
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.
|
|
44
44
|
2. Add `status:in-progress` to the issue.
|
|
45
45
|
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.
|
|
46
|
-
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 `###
|
|
46
|
+
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.
|
|
47
47
|
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.
|
|
48
48
|
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.
|
|
49
49
|
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 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. 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.
|
|
@@ -97,7 +97,7 @@ A halt that leaves a commit on the base, or a push or revert that may be on it,
|
|
|
97
97
|
|
|
98
98
|
The fixer sees the findings of all earlier rounds, not only the last one, with its own disputes next to them. From round two, the reviewer judges only the earlier findings and any regression.
|
|
99
99
|
|
|
100
|
-
Each
|
|
100
|
+
Each comment that the worker posts on the issue starts with one heading line of the form `### next-issue · <Agent>: <outcome>`, with the details below it: `### next-issue · Review: approved`, `### next-issue · Review: changes requested`, `### next-issue · Fixer: no change`, `### next-issue · Fixer: settled with no change`, `### next-issue · Worker: already done` and `### next-issue · Hand-over: needs help`. The account is the same for all of them, so the heading, not the author, tells them apart. A comment longer than 65536 characters is cut to fit and ends with the line "This comment was too long for GitHub and was cut." The agents get no comment that starts with `### next-issue ·` or with a heading of older versions (`next-issue needs help:`, `### Review:`, `### Fixer:` and `### Already done`), so a comment of an agent never returns to a prompt: the dispute of the fixer reaches the reviewer through the state file. The one exception is the answer to a hand-over, see [Retry an issue that waits for a person](#retry-an-issue-that-waits-for-a-person).
|
|
101
101
|
|
|
102
102
|
## Stop a run
|
|
103
103
|
|
|
@@ -281,11 +281,11 @@ Every agent also reads each `AGENTS.md` that pi finds, such as the one in your h
|
|
|
281
281
|
|
|
282
282
|
## Retry an issue that waits for a person
|
|
283
283
|
|
|
284
|
-
When the implementer makes no change, the hand-over comment holds its full reply after the note, so its reasons and questions can be answered on the issue. When it asks questions on `question:` lines, the comment lists them instead. Every hand-over comment is cut to fit a GitHub comment, whatever the reason, so a long reply or a long run error does not lose it. A cut comment ends with
|
|
284
|
+
When the implementer makes no change, the hand-over comment holds its full reply after the note, so its reasons and questions can be answered on the issue. When it asks questions on `question:` lines, the comment lists them instead. Every hand-over comment is cut to fit a GitHub comment, whatever the reason, so a long reply or a long run error does not lose it. The reason goes in the body under the `### next-issue · Hand-over: needs help` heading. A cut comment ends with the line "This comment was too long for GitHub and was cut."
|
|
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 needs help:` comment
|
|
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.
|
|
289
289
|
|
|
290
290
|
The `--reset` flag does the same for any issue that the run handles, whether or not it was handed over. It touches only an issue that the run handles, so the state of an issue that a label still holds back stays as it was.
|
|
291
291
|
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { repoArg } from './gh.mjs';
|
|
2
2
|
import { heldByPerson, readState } from './state.mjs';
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
import { AGENT_PREFIX, agentHeading } from './text.mjs';
|
|
4
|
+
export const HAND_OVER = agentHeading('Hand-over', 'needs help');
|
|
5
|
+
const OLD_HAND_OVER = 'next-issue needs help:';
|
|
6
|
+
const HARNESS_HEADINGS = [
|
|
7
|
+
AGENT_PREFIX,
|
|
8
|
+
OLD_HAND_OVER,
|
|
9
|
+
'### Review:',
|
|
10
|
+
'### Fixer:',
|
|
11
|
+
'### Already done',
|
|
12
|
+
];
|
|
13
|
+
function handOverReason(comment) {
|
|
14
|
+
const heading = [HAND_OVER, OLD_HAND_OVER].find((item) => comment.body.startsWith(item));
|
|
15
|
+
return heading === undefined ? undefined : comment.body.slice(heading.length).trim();
|
|
16
|
+
}
|
|
5
17
|
function fromHarness(comment) {
|
|
6
18
|
return HARNESS_HEADINGS.some((heading) => comment.body.startsWith(heading));
|
|
7
19
|
}
|
|
@@ -32,7 +44,7 @@ async function writerQuotes(comments, writer, skip = () => { }) {
|
|
|
32
44
|
async function lastHandOver(comments, writer) {
|
|
33
45
|
for (let index = comments.length - 1; index >= 0; index -= 1) {
|
|
34
46
|
const comment = comments[index];
|
|
35
|
-
if (comment
|
|
47
|
+
if (handOverReason(comment) !== undefined && (await writer(comment.author))) {
|
|
36
48
|
return index;
|
|
37
49
|
}
|
|
38
50
|
}
|
|
@@ -89,7 +101,7 @@ async function waitingQuestion(repo, config, ports, writer, issue) {
|
|
|
89
101
|
return {
|
|
90
102
|
issue: issue.number,
|
|
91
103
|
title: issue.title,
|
|
92
|
-
reason: comment
|
|
104
|
+
reason: (comment && handOverReason(comment)) ?? pending?.reason ?? '',
|
|
93
105
|
url: comment?.url ?? '',
|
|
94
106
|
repo: repoArg(repo),
|
|
95
107
|
labels: {
|
package/dist/handover.mjs
CHANGED
|
@@ -188,9 +188,8 @@ function handOverReason(error, reason) {
|
|
|
188
188
|
const unsettled = error instanceof UnsettledBase ? error.note : '';
|
|
189
189
|
return `The run failed: ${reason}${unsettled}`;
|
|
190
190
|
}
|
|
191
|
-
const CUT = '\n\nThe reason was too long for a GitHub comment and was cut.';
|
|
192
191
|
function handOverComment(reason) {
|
|
193
|
-
return fitComment(`${HAND_OVER}
|
|
192
|
+
return fitComment(`${HAND_OVER}\n\n${reason}`, COMMENT_CUT);
|
|
194
193
|
}
|
|
195
194
|
export async function claimedError(context, log, issue, state, error, started) {
|
|
196
195
|
const reason = message(error);
|
package/dist/implement.mjs
CHANGED
|
@@ -7,6 +7,7 @@ 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
9
|
import { writeState } from './state.mjs';
|
|
10
|
+
import { agentHeading } from './text.mjs';
|
|
10
11
|
import { blockingFindings, formatFindings, parseVerdict } from './verdict.mjs';
|
|
11
12
|
export async function implement(job) {
|
|
12
13
|
const { context, issue, log, state, worktree, comments, reply } = job;
|
|
@@ -79,5 +80,5 @@ async function closeIfDone(job, evidence) {
|
|
|
79
80
|
: `The reviewer disagreed:\n\n${formatFindings(blocking)}`;
|
|
80
81
|
return escalateAndFinish(job, `The implementer produced no change and said the issue is already done: ${evidence}\n\n${findings}`, 'already done disputed');
|
|
81
82
|
}
|
|
82
|
-
return finishDone(job,
|
|
83
|
+
return finishDone(job, `${agentHeading('Worker', 'already done')}\n\n${evidence}\n\nReview: ${verdict.summary}`);
|
|
83
84
|
}
|
package/dist/review.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { ROUND_CONTINUE, runRole, setStatus } from './job.mjs';
|
|
|
8
8
|
import { landApproved } from './land.mjs';
|
|
9
9
|
import { capDiff, history, reviewPrompt } from './prompts.mjs';
|
|
10
10
|
import { writeState } from './state.mjs';
|
|
11
|
-
import { COMMENT_CUT, fitComment } from './text.mjs';
|
|
11
|
+
import { agentHeading, COMMENT_CUT, fitComment } from './text.mjs';
|
|
12
12
|
import { blockingFindings, formatFindings, formatVerdict, openFindings, parseVerdict, } from './verdict.mjs';
|
|
13
13
|
export async function reviewRound(job) {
|
|
14
14
|
const { context, issue, state } = job;
|
|
@@ -145,6 +145,6 @@ async function unfixedRound(job, fix) {
|
|
|
145
145
|
}
|
|
146
146
|
await writeState(repo, state);
|
|
147
147
|
const heading = fix.unrelated === undefined ? 'settled with no change' : 'no change';
|
|
148
|
-
await ports.commentOnIssue(repo, issue.number, fitComment(
|
|
148
|
+
await ports.commentOnIssue(repo, issue.number, fitComment(`${agentHeading('Fixer', heading)}\n\n${note}`, COMMENT_CUT));
|
|
149
149
|
return ROUND_CONTINUE;
|
|
150
150
|
}
|
package/dist/text.mjs
CHANGED
|
@@ -14,6 +14,10 @@ export function keepTail(text, limit) {
|
|
|
14
14
|
return limit !== undefined && text.length > limit ? text.slice(-limit) : text;
|
|
15
15
|
}
|
|
16
16
|
const COMMENT_LIMIT = 65536;
|
|
17
|
+
export const AGENT_PREFIX = '### next-issue ·';
|
|
18
|
+
export function agentHeading(agent, outcome) {
|
|
19
|
+
return `${AGENT_PREFIX} ${agent}: ${outcome}`;
|
|
20
|
+
}
|
|
17
21
|
export const COMMENT_CUT = '\n\nThis comment was too long for GitHub and was cut.';
|
|
18
22
|
export function fitComment(comment, cut) {
|
|
19
23
|
if (comment.length <= COMMENT_LIMIT) {
|
package/dist/verdict.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRecord } from './records.mjs';
|
|
2
|
-
import { paragraphs } from './text.mjs';
|
|
2
|
+
import { agentHeading, paragraphs } from './text.mjs';
|
|
3
3
|
function isSeverity(value) {
|
|
4
4
|
return value === 'blocking' || value === 'minor';
|
|
5
5
|
}
|
|
@@ -80,10 +80,10 @@ export function openFindings(verdict, lastRound) {
|
|
|
80
80
|
const LEFT = 'The findings above stay as they are: no blocking finding is open and the review budget is spent.';
|
|
81
81
|
export function formatVerdict(verdict, open) {
|
|
82
82
|
const approved = open.length === 0;
|
|
83
|
-
const head = approved ? '
|
|
83
|
+
const head = agentHeading('Review', approved ? 'approved' : 'changes requested');
|
|
84
84
|
const lines = verdict.findings.map((finding) => `- **${finding.severity}** ${finding.detail}`);
|
|
85
85
|
const note = approved && verdict.findings.length > 0 ? LEFT : '';
|
|
86
|
-
return paragraphs([
|
|
86
|
+
return paragraphs([head, verdict.summary, lines.join('\n'), note]);
|
|
87
87
|
}
|
|
88
88
|
export function formatFindings(findings) {
|
|
89
89
|
return findings.map((finding) => `- ${finding.detail}`).join('\n');
|