next-issue 9.5.0 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/agent-reply.mjs +4 -0
- package/dist/handover.mjs +5 -2
- package/dist/implement.mjs +26 -5
- package/dist/prompts.mjs +19 -0
- package/dist/review.mjs +3 -4
- package/dist/serve.mjs +4 -0
- package/dist/text.mjs +1 -0
- package/dist/upcoming.mjs +40 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,6 +103,19 @@ the run handles one issue. For each issue:
|
|
|
103
103
|
and the newest of them gives the subject of the landed commit. A lost state
|
|
104
104
|
file does not count, since an issue with no saved state resets its local
|
|
105
105
|
branch (step 3).
|
|
106
|
+
When the base already does all that the issue asks, the implementer makes
|
|
107
|
+
no change and ends its reply with a `done: <evidence>` line. If the branch
|
|
108
|
+
is not ahead of the base, a reviewer then checks that claim against the
|
|
109
|
+
base. When it raises no blocking finding, the harness comments
|
|
110
|
+
`### Already done` with the evidence and the summary of the reviewer, adds
|
|
111
|
+
`status:done` and closes the issue as completed, and the issue ends as
|
|
112
|
+
`done`. Otherwise it hands the issue to a person with the reason
|
|
113
|
+
`already done disputed`, and the comment holds the evidence and the
|
|
114
|
+
findings of the reviewer. A reply with a `question:` line asks the
|
|
115
|
+
questions instead. To close a parent issue once its sub-issues land, mark
|
|
116
|
+
it as blocked by each sub-issue and give it the `status:todo` label: it
|
|
117
|
+
waits while a sub-issue is open (step 1), then the implementer finds it
|
|
118
|
+
already done and the harness closes it.
|
|
106
119
|
The implementer checks the issue first. When the scope, the expected
|
|
107
120
|
behaviour or the acceptance criteria are ambiguous, it makes no change and
|
|
108
121
|
asks instead of guessing, with each question on its own
|
|
@@ -980,7 +993,7 @@ affect another. The worker:
|
|
|
980
993
|
with `another worker is running`. A worker that stops removes the lock file
|
|
981
994
|
only while it still holds the lock, and the socket file only while it is
|
|
982
995
|
still the socket it bound;
|
|
983
|
-
- refuses a `start`, `stop`, `watch`, `hunt` or `
|
|
996
|
+
- refuses a `start`, `stop`, `watch`, `hunt`, `questions` or `upcoming` message whose `root` is not
|
|
984
997
|
the exact path of its repository with an `error` message, and starts or
|
|
985
998
|
stops nothing;
|
|
986
999
|
- runs at most one run at a time. A client starts it with
|
|
@@ -1011,6 +1024,14 @@ affect another. The worker:
|
|
|
1011
1024
|
a newer one. When the client adds an `"id"` to its message, the list that
|
|
1012
1025
|
answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets
|
|
1013
1026
|
`{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
|
|
1027
|
+
- answers `{ "type": "upcoming", "root": "<path>" }` with
|
|
1028
|
+
`{ "type": "upcoming", "root": "<path>", "claimable": [...], "blocked": [...] }`:
|
|
1029
|
+
the open issues with the `ready` label that a run would claim, oldest first,
|
|
1030
|
+
each with its `issue` number and `title`, without issues that have saved
|
|
1031
|
+
state or a label that stops a claim. An issue blocked by open issues is in
|
|
1032
|
+
`blocked` with their references in `blockers`. When the list cannot be read,
|
|
1033
|
+
the client gets
|
|
1034
|
+
`{ "type": "upcoming-error", "root": "<path>", "message": "<text>" }`;
|
|
1014
1035
|
- stops a run when a client sends
|
|
1015
1036
|
`{ "type": "stop", "root": "<path>", "after": "issue" | "round" | "now" }`.
|
|
1016
1037
|
With no `after`, it stops after `issue`. `issue` works like a first
|
package/dist/agent-reply.mjs
CHANGED
|
@@ -10,6 +10,10 @@ export function parseResolved(text) {
|
|
|
10
10
|
const note = lastMatch(text, /^resolved:[^\S\r\n]*(.+)$/gim);
|
|
11
11
|
return note === undefined || PLACEHOLDERS.has(note.toLowerCase()) ? undefined : note;
|
|
12
12
|
}
|
|
13
|
+
export function parseDone(text) {
|
|
14
|
+
const note = lastMatch(text, /^done:[^\S\r\n]*(.+)$/gim);
|
|
15
|
+
return note === undefined || PLACEHOLDERS.has(note.toLowerCase()) ? undefined : note;
|
|
16
|
+
}
|
|
13
17
|
export function parseQuestions(text) {
|
|
14
18
|
return [...text.matchAll(/^question:[^\S\r\n]*(.+)$/gim)]
|
|
15
19
|
.map((match) => match[1].replace(/^\d+[.)]\s*/, '').trim())
|
package/dist/handover.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { oneAtATime } from './lock.mjs';
|
|
|
7
7
|
import { revertFailedFix } from './revert.mjs';
|
|
8
8
|
import { logIssueError } from './skip.mjs';
|
|
9
9
|
import { dropState, writeState } from './state.mjs';
|
|
10
|
-
import { fitComment } from './text.mjs';
|
|
10
|
+
import { COMMENT_CUT, fitComment } from './text.mjs';
|
|
11
11
|
import { UnsettledBase } from './unsettled.mjs';
|
|
12
12
|
export async function escalateAndFinish(job, note, reason) {
|
|
13
13
|
const reverted = await revertFailedFix(job);
|
|
@@ -36,11 +36,14 @@ function savedIn(asides) {
|
|
|
36
36
|
}
|
|
37
37
|
return ` The fixer left changes behind; they are saved in the branches ${branches.slice(0, -1).join(', ')} and ${branches.at(-1)}.`;
|
|
38
38
|
}
|
|
39
|
-
export async function finishDone(job) {
|
|
39
|
+
export async function finishDone(job, note) {
|
|
40
40
|
const { context, issue } = job;
|
|
41
41
|
if (issue.closed !== true) {
|
|
42
42
|
job.state.closing = true;
|
|
43
43
|
await writeState(context.repo, job.state);
|
|
44
|
+
if (note !== undefined) {
|
|
45
|
+
await context.ports.commentOnIssue(context.repo, issue.number, fitComment(note, COMMENT_CUT));
|
|
46
|
+
}
|
|
44
47
|
await setStatus(context, issue.number, context.config.labels.done);
|
|
45
48
|
await context.ports.closeIssue(context.repo, issue.number);
|
|
46
49
|
}
|
package/dist/implement.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { parseCommitSubject, parseQuestions } from './agent-reply.mjs';
|
|
2
|
-
import { CODING } from './agents.mjs';
|
|
1
|
+
import { parseCommitSubject, parseDone, parseQuestions } from './agent-reply.mjs';
|
|
2
|
+
import { CODING, REVIEWING } from './agents.mjs';
|
|
3
3
|
import { message } from './errors.mjs';
|
|
4
4
|
import { commitWork } from './fix.mjs';
|
|
5
|
-
import { escalateAndFinish } from './handover.mjs';
|
|
5
|
+
import { escalateAndFinish, finishDone } from './handover.mjs';
|
|
6
6
|
import { numbered, withOpenQuestions } from './issue-format.mjs';
|
|
7
|
-
import { fallbackTitle, ROUND_CONTINUE, runRole } from './job.mjs';
|
|
8
|
-
import { implementPrompt } from './prompts.mjs';
|
|
7
|
+
import { fallbackTitle, ROUND_CONTINUE, runRole, } from './job.mjs';
|
|
8
|
+
import { donePrompt, implementPrompt } from './prompts.mjs';
|
|
9
9
|
import { writeState } from './state.mjs';
|
|
10
|
+
import { blockingFindings, formatFindings, parseVerdict } from './verdict.mjs';
|
|
10
11
|
export async function implement(job) {
|
|
11
12
|
const { context, issue, log, state, worktree, comments, reply } = job;
|
|
12
13
|
const before = await context.ports.revision(worktree);
|
|
@@ -46,6 +47,10 @@ async function useEarlierCommit(job) {
|
|
|
46
47
|
const { context, log, state, worktree } = job;
|
|
47
48
|
const earlier = await context.ports.latestSubject(worktree, context.base, context.config.remote);
|
|
48
49
|
if (earlier === undefined) {
|
|
50
|
+
const evidence = parseDone(state.implementerReply ?? '');
|
|
51
|
+
if (evidence !== undefined) {
|
|
52
|
+
return closeIfDone(job, evidence);
|
|
53
|
+
}
|
|
49
54
|
return escalateAndFinish(job, noChangeNote(state.implementerReply ?? ''), 'no implementation commit');
|
|
50
55
|
}
|
|
51
56
|
log.event('implement.earlier', { subject: earlier }, 'quiet');
|
|
@@ -60,3 +65,19 @@ function noChangeNote(reply) {
|
|
|
60
65
|
}
|
|
61
66
|
return `${NO_CHANGE}\n\n${text}`;
|
|
62
67
|
}
|
|
68
|
+
async function closeIfDone(job, evidence) {
|
|
69
|
+
const { context, issue, log, worktree, comments, branch } = job;
|
|
70
|
+
const { ports } = context;
|
|
71
|
+
const before = await ports.revision(worktree);
|
|
72
|
+
const review = await log.step('review', { alreadyDone: true }, () => runRole(job, 'reviewer', donePrompt(issue, comments, evidence), REVIEWING));
|
|
73
|
+
await ports.discardChanges(worktree, before, branch);
|
|
74
|
+
const verdict = parseVerdict(review.text);
|
|
75
|
+
const blocking = verdict === undefined ? [] : blockingFindings(verdict);
|
|
76
|
+
if (verdict === undefined || blocking.length > 0) {
|
|
77
|
+
const findings = verdict === undefined
|
|
78
|
+
? 'The reviewer gave no verdict.'
|
|
79
|
+
: `The reviewer disagreed:\n\n${formatFindings(blocking)}`;
|
|
80
|
+
return escalateAndFinish(job, `The implementer produced no change and said the issue is already done: ${evidence}\n\n${findings}`, 'already done disputed');
|
|
81
|
+
}
|
|
82
|
+
return finishDone(job, `### Already done\n\n${evidence}\n\nReview: ${verdict.summary}`);
|
|
83
|
+
}
|
package/dist/prompts.mjs
CHANGED
|
@@ -22,6 +22,10 @@ const QUESTION_RULES = [
|
|
|
22
22
|
'Write each question on its own line in the form `question: <n>. <question>`, numbered from 1. In each question, label its options with letters and recommend one.',
|
|
23
23
|
'The harness then hands the issue to a person with your questions.',
|
|
24
24
|
].join('\n');
|
|
25
|
+
const DONE_RULE = [
|
|
26
|
+
'When the base branch already does all that the issue asks, make no change and end your final message with one line in the form `done: <evidence that the base already does it, with files and lines>`.',
|
|
27
|
+
'A reviewer checks that claim. When it agrees, the harness closes the issue as done.',
|
|
28
|
+
].join('\n');
|
|
25
29
|
function issueBlock(issue, comments) {
|
|
26
30
|
return paragraphs([
|
|
27
31
|
`# Issue #${issue.number}: ${issue.title}`,
|
|
@@ -52,6 +56,7 @@ export function implementPrompt(issue, comments, reply = [], questions = []) {
|
|
|
52
56
|
'## Rules',
|
|
53
57
|
'Read the repository conventions first. Keep the change minimal and focused on the issue.',
|
|
54
58
|
QUESTION_RULES,
|
|
59
|
+
DONE_RULE,
|
|
55
60
|
ENGINEERING_RULES,
|
|
56
61
|
'Add or update tests when the repository has a test suite.',
|
|
57
62
|
'For a behaviour change, write the test first and run it before the change. Then quote its failing output in your final message.',
|
|
@@ -130,6 +135,20 @@ export function reviewPrompt(issue, comments, diff, earlier, reply) {
|
|
|
130
135
|
'Give one entry per finding, and an empty list when nothing is wrong. The findings decide the outcome, so a problem that you leave out counts as no problem.',
|
|
131
136
|
].join('\n\n');
|
|
132
137
|
}
|
|
138
|
+
export function donePrompt(issue, comments, evidence) {
|
|
139
|
+
return paragraphs([
|
|
140
|
+
'You are the reviewer. The implementer made no change and says that the issue below is already done on the base branch. Judge whether that is true.',
|
|
141
|
+
issueBlock(issue, comments),
|
|
142
|
+
`## Evidence of the implementer\n${evidence}`,
|
|
143
|
+
'## Rules',
|
|
144
|
+
'The worktree holds the base branch. Check each part of the issue against it. Read files and run commands to prove what you say.',
|
|
145
|
+
'Do not change a file. Do not write with git or gh, and do not check out another commit or branch.',
|
|
146
|
+
HARNESS_RULES,
|
|
147
|
+
'Raise a blocking finding for each part of the issue that the base branch does not do. Give the file and line, or the command output, that supports each finding.',
|
|
148
|
+
'End your final message with the result as a json block in a ```json fence, in the form {"summary": "<short summary>", "findings": [{"severity": "blocking" or "minor", "detail": "<what is missing and where>"}]}.',
|
|
149
|
+
'Give an empty list when the issue is already done. A blocking finding keeps the issue open and hands it to a person.',
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
133
152
|
const UNRELATED_RULE = [
|
|
134
153
|
'The checks can fail for a reason this change did not cause: a test that is already broken on the base branch, one that exercises code the diff does not touch, or one that fails only under load.',
|
|
135
154
|
'Establish that before you fix anything. If the failure is not yours, change nothing and end your final message with one line in the form `unrelated: <one sentence on what fails and why it is not this change>`.',
|
package/dist/review.mjs
CHANGED
|
@@ -8,9 +8,8 @@ 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 { fitComment } from './text.mjs';
|
|
11
|
+
import { COMMENT_CUT, fitComment } from './text.mjs';
|
|
12
12
|
import { blockingFindings, formatFindings, formatVerdict, openFindings, parseVerdict, } from './verdict.mjs';
|
|
13
|
-
const CUT = '\n\nThis comment was too long for GitHub and was cut.';
|
|
14
13
|
export async function reviewRound(job) {
|
|
15
14
|
const { context, issue, state } = job;
|
|
16
15
|
const { repo, config, ports } = context;
|
|
@@ -39,7 +38,7 @@ export async function reviewRound(job) {
|
|
|
39
38
|
const { round, limit } = budgetUse(job, 'reviewRounds');
|
|
40
39
|
const open = openFindings(verdict, round >= limit);
|
|
41
40
|
recordVerdict(job, verdict, open);
|
|
42
|
-
await ports.commentOnIssue(repo, issue.number, fitComment(formatVerdict(verdict, open),
|
|
41
|
+
await ports.commentOnIssue(repo, issue.number, fitComment(formatVerdict(verdict, open), COMMENT_CUT));
|
|
43
42
|
if (open.length === 0) {
|
|
44
43
|
state.phase = 'approved';
|
|
45
44
|
await writeState(repo, state);
|
|
@@ -146,6 +145,6 @@ async function unfixedRound(job, fix) {
|
|
|
146
145
|
}
|
|
147
146
|
await writeState(repo, state);
|
|
148
147
|
const heading = fix.unrelated === undefined ? 'settled with no change' : 'no change';
|
|
149
|
-
await ports.commentOnIssue(repo, issue.number, fitComment(`### Fixer: ${heading}\n\n${note}`,
|
|
148
|
+
await ports.commentOnIssue(repo, issue.number, fitComment(`### Fixer: ${heading}\n\n${note}`, COMMENT_CUT));
|
|
150
149
|
return ROUND_CONTINUE;
|
|
151
150
|
}
|
package/dist/serve.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { startProgress } from './progress.mjs';
|
|
|
11
11
|
import { isNewer } from './protocol.mjs';
|
|
12
12
|
import { listQuestions, questionSender, send } from './questions.mjs';
|
|
13
13
|
import { runRepo } from './run.mjs';
|
|
14
|
+
import { listUpcoming, sendUpcoming } from './upcoming.mjs';
|
|
14
15
|
import { packageVersion } from './version.mjs';
|
|
15
16
|
import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
|
|
16
17
|
import { checkSocketPath, workerPaths } from './worker-paths.mjs';
|
|
@@ -141,6 +142,9 @@ export async function startWorker(options) {
|
|
|
141
142
|
else if (value.type === 'questions') {
|
|
142
143
|
void sendQuestions(value.root, () => [socket], value.id);
|
|
143
144
|
}
|
|
145
|
+
else if (value.type === 'upcoming') {
|
|
146
|
+
void sendUpcoming(options.upcoming ?? listUpcoming, socket, value.root);
|
|
147
|
+
}
|
|
144
148
|
};
|
|
145
149
|
sockets.on('connection', (socket) => {
|
|
146
150
|
send(socket, { type: 'hello', version: options.version });
|
package/dist/text.mjs
CHANGED
|
@@ -14,6 +14,7 @@ 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 COMMENT_CUT = '\n\nThis comment was too long for GitHub and was cut.';
|
|
17
18
|
export function fitComment(comment, cut) {
|
|
18
19
|
if (comment.length <= COMMENT_LIMIT) {
|
|
19
20
|
return comment;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { loadConfig } from './config.mjs';
|
|
2
|
+
import { message } from './errors.mjs';
|
|
3
|
+
import { detectRepo } from './git.mjs';
|
|
4
|
+
import { PORTS } from './ports.mjs';
|
|
5
|
+
import { send } from './questions.mjs';
|
|
6
|
+
import { skipReason } from './skip.mjs';
|
|
7
|
+
import { savedIssues } from './state.mjs';
|
|
8
|
+
/** The fresh issues the worker would claim, oldest first as it claims them; issues with saved state resume instead. */
|
|
9
|
+
export async function upcomingIssues(repo, config, ports) {
|
|
10
|
+
const { ready } = config.labels;
|
|
11
|
+
const issues = await ports.openIssues(repo, config.issueLimit, ready.length === 0 ? [] : [ready]);
|
|
12
|
+
const saved = new Set(await savedIssues(repo));
|
|
13
|
+
const upcoming = { claimable: [], blocked: [] };
|
|
14
|
+
for (const issue of issues) {
|
|
15
|
+
if (saved.has(issue.number) || skipReason(issue, config, false) !== undefined) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const blockers = await ports.openBlockers(repo, issue.number);
|
|
19
|
+
const item = { issue: issue.number, title: issue.title };
|
|
20
|
+
if (blockers.length > 0) {
|
|
21
|
+
upcoming.blocked.push({ ...item, blockers });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
upcoming.claimable.push(item);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return upcoming;
|
|
28
|
+
}
|
|
29
|
+
export async function listUpcoming(root) {
|
|
30
|
+
const config = await loadConfig(root);
|
|
31
|
+
return upcomingIssues(await detectRepo(root, config.remote), config, PORTS);
|
|
32
|
+
}
|
|
33
|
+
export async function sendUpcoming(list, socket, root) {
|
|
34
|
+
try {
|
|
35
|
+
send(socket, { type: 'upcoming', root, ...(await list(root)) });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
send(socket, { type: 'upcoming-error', root, message: message(error) });
|
|
39
|
+
}
|
|
40
|
+
}
|