next-issue 7.6.0 → 7.8.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 +21 -2
- package/dist/agent-reply.mjs +5 -0
- package/dist/base-checks.mjs +52 -20
- package/dist/config-fields.mjs +6 -0
- package/dist/config.mjs +6 -1
- package/dist/gate.mjs +3 -3
- package/dist/github.mjs +3 -0
- package/dist/implement.mjs +14 -1
- package/dist/issue-format.mjs +19 -0
- package/dist/ports.mjs +2 -1
- package/dist/prompts.mjs +6 -0
- package/dist/run-logs.mjs +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,6 +95,16 @@ the run handles one issue. For each issue:
|
|
|
95
95
|
and the newest of them gives the subject of the landed commit. A lost state
|
|
96
96
|
file does not count, since an issue with no saved state resets its local
|
|
97
97
|
branch (step 3).
|
|
98
|
+
The implementer checks the issue first. When the scope, the expected
|
|
99
|
+
behaviour or the acceptance criteria are ambiguous, it makes no change and
|
|
100
|
+
asks instead of guessing, with each question on its own
|
|
101
|
+
`question: <n>. <question>` line, its options labelled by letters and one
|
|
102
|
+
option recommended. A reply with at least one `question:` line makes the
|
|
103
|
+
harness drop any change in the worktree, commit nothing and hand the issue
|
|
104
|
+
to a person with the reason `questions`. The hand-over comment lists the
|
|
105
|
+
questions in order, numbered by the harness. The harness reads the issue
|
|
106
|
+
again and adds the questions after any text under its `Open questions`
|
|
107
|
+
heading, or adds that heading at the end of the body when it has none.
|
|
98
108
|
5. Let the reviewer agent judge the diff, at most `diffMaxChars` of it. The
|
|
99
109
|
reviewer reads files and runs commands in the worktree, so it can prove a
|
|
100
110
|
finding with the tests or the type check. The harness then throws away every
|
|
@@ -180,8 +190,13 @@ the run handles one issue. For each issue:
|
|
|
180
190
|
`schedule`) started, since GitHub gives such a run the tip of the
|
|
181
191
|
default branch as its commit. It also leaves out the `push` runs that a
|
|
182
192
|
push of a tag or of another branch started on the same commit, such as
|
|
183
|
-
a release or a deploy.
|
|
184
|
-
|
|
193
|
+
a release or a deploy. It leaves out every GitHub Actions job, check run
|
|
194
|
+
and commit status whose name is in `ignoredChecks`: it does not wait for
|
|
195
|
+
it, its result does not fail the checks and its logs do not go to the
|
|
196
|
+
fixer. With `ignoredChecks` set, the harness judges each workflow run by
|
|
197
|
+
its other jobs, so a run whose only failed job is ignored passes. A
|
|
198
|
+
failed or errored commit status, or a workflow run or check run that
|
|
199
|
+
ends with `failure`, `timed_out` or
|
|
185
200
|
`action_required`, fails the checks. The harness does not rerun a
|
|
186
201
|
workflow run that ends `action_required`, since it waits for a person
|
|
187
202
|
to approve it. When any check ends `cancelled`, for example because
|
|
@@ -335,6 +350,7 @@ and comments the reason on the issue, when:
|
|
|
335
350
|
broken, so the run claims no new issue and ends once the running issues
|
|
336
351
|
end. It halts this way even when the hand-over fails; the issue then ends
|
|
337
352
|
in error with both the reason and the hand-over error;
|
|
353
|
+
- the implementer asks questions about the issue (reason `questions`);
|
|
338
354
|
- an agent does not finish in `agentTimeoutMinutes`;
|
|
339
355
|
- the setup command fails, or does not finish in `setupTimeoutMinutes`. On a
|
|
340
356
|
resume whose state holds a landed commit, or a push or revert that may have
|
|
@@ -600,6 +616,7 @@ because no pull request is opened.
|
|
|
600
616
|
"keepRunDays": 7,
|
|
601
617
|
"checks": [],
|
|
602
618
|
"checksTimeoutMinutes": 30,
|
|
619
|
+
"ignoredChecks": [],
|
|
603
620
|
"models": {
|
|
604
621
|
"implementer": null,
|
|
605
622
|
"reviewer": null,
|
|
@@ -637,6 +654,7 @@ because no pull request is opened.
|
|
|
637
654
|
| `keepRunDays` | `7` | The number of days to keep the run files; `0` keeps them all |
|
|
638
655
|
| `checks` | `[]` | Shell commands that must pass in the worktree, in order, before an approved change is pushed; a failure goes to the fixer |
|
|
639
656
|
| `checksTimeoutMinutes` | `30` | The limit for one command in `checks`, at most `35791` |
|
|
657
|
+
| `ignoredChecks` | `[]` | Names of GitHub Actions jobs, check runs and commit statuses, such as `release`, that the checks on the base branch do not wait for and whose failure does not count |
|
|
640
658
|
| `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer |
|
|
641
659
|
| `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
|
|
642
660
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
|
@@ -711,6 +729,7 @@ says so: a workflow rule in `AGENTS.md` about these, such as "push to main" or
|
|
|
711
729
|
|
|
712
730
|
When the implementer makes no change, the hand-over comment holds its full
|
|
713
731
|
reply after the note, so its reasons and questions can be answered on the issue.
|
|
732
|
+
When it asks questions on `question:` lines, the comment lists them instead.
|
|
714
733
|
Every hand-over comment is cut to fit a GitHub comment, whatever the reason, so a
|
|
715
734
|
long reply or a long run error does not lose it. A cut comment ends with a line
|
|
716
735
|
that says so.
|
package/dist/agent-reply.mjs
CHANGED
|
@@ -10,6 +10,11 @@ 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 parseQuestions(text) {
|
|
14
|
+
return [...text.matchAll(/^question:[^\S\r\n]*(.+)$/gim)]
|
|
15
|
+
.map((match) => match[1].replace(/^\d+[.)]\s*/, '').trim())
|
|
16
|
+
.filter((question) => !PLACEHOLDERS.has(question.toLowerCase()));
|
|
17
|
+
}
|
|
13
18
|
const CLOSING_REFERENCE = /(\s*[,;]?\s*(?:and\s+)?)\b(close[sd]?|fix(?:e[sd])?|resolve[sd]?)(\s*:\s*|\s+)(?:[\w.-]+\/[\w.-]+#\d+|#\d+|https?:\/\/\S+\/(?:issues|pull)\/\d+)/gi;
|
|
14
19
|
const BARE_TYPE = /^\w+(?:\([^)]*\))?!?$/;
|
|
15
20
|
export function withoutClosingReferences(subject, fallback) {
|
package/dist/base-checks.mjs
CHANGED
|
@@ -16,11 +16,40 @@ function jsonLines(raw) {
|
|
|
16
16
|
.filter((line) => line.trim() !== '')
|
|
17
17
|
.map((line) => JSON.parse(line));
|
|
18
18
|
}
|
|
19
|
-
async function baseRuns(repo, sha, branch) {
|
|
19
|
+
async function baseRuns(repo, sha, branch, ignored) {
|
|
20
20
|
const runs = await ghApi(repo, `actions/runs?head_sha=${sha}&per_page=100`, '.workflow_runs[] | {databaseId: .id, name, status, conclusion: (.conclusion // ""), attempt: .run_attempt, event, branch: (.head_branch // "")} | @json', { paginate: true });
|
|
21
|
-
|
|
21
|
+
const pushed = jsonLines(runs).filter((entry) => entry.event === 'push' && entry.branch === branch);
|
|
22
|
+
if (ignored.length === 0) {
|
|
23
|
+
return pushed;
|
|
24
|
+
}
|
|
25
|
+
const judged = await Promise.all(pushed.map((entry) => withoutIgnored(repo, entry, ignored)));
|
|
26
|
+
return judged.filter((entry) => entry !== undefined);
|
|
27
|
+
}
|
|
28
|
+
/** Judges a workflow run by its jobs outside the ignored checks; a run with no job yet, or a running one whose listed jobs all finished, keeps its own state, as a job not listed yet may follow. */
|
|
29
|
+
async function withoutIgnored(repo, run, ignored) {
|
|
30
|
+
const jobs = jsonLines(await ghApi(repo, `actions/runs/${run.databaseId}/jobs?filter=latest&per_page=100`, '.jobs[] | {databaseId: .id, name, status, conclusion: (.conclusion // "")} | @json', { paginate: true }));
|
|
31
|
+
if (jobs.length === 0 || (run.status !== 'completed' && jobs.every(completedJob))) {
|
|
32
|
+
return run;
|
|
33
|
+
}
|
|
34
|
+
const kept = jobs.filter((job) => !ignored.includes(job.name));
|
|
35
|
+
if (kept.length === 0) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
if (!kept.every(completedJob)) {
|
|
39
|
+
return { ...run, status: 'in_progress', conclusion: '', jobs: kept };
|
|
40
|
+
}
|
|
41
|
+
return { ...run, status: 'completed', conclusion: jobsConclusion(kept), jobs: kept };
|
|
42
|
+
}
|
|
43
|
+
function completedJob(job) {
|
|
44
|
+
return job.status === 'completed';
|
|
45
|
+
}
|
|
46
|
+
function jobsConclusion(jobs) {
|
|
47
|
+
if (jobs.some(failedRun)) {
|
|
48
|
+
return 'failure';
|
|
49
|
+
}
|
|
50
|
+
return jobs.some((job) => job.conclusion === 'cancelled') ? 'cancelled' : 'success';
|
|
22
51
|
}
|
|
23
|
-
async function externalChecks(repo, sha) {
|
|
52
|
+
async function externalChecks(repo, sha, ignored) {
|
|
24
53
|
const [runs, statuses] = await Promise.all([
|
|
25
54
|
ghApi(repo, `commits/${sha}/check-runs?per_page=100`, '.check_runs[] | {name, status, conclusion, app: .app.slug, url: .details_url} | @json', { paginate: true }),
|
|
26
55
|
ghApi(repo, `commits/${sha}/status?per_page=100`, '.statuses[] | {name: .context, state, url: .target_url} | @json', { paginate: true }),
|
|
@@ -39,12 +68,12 @@ async function externalChecks(repo, sha) {
|
|
|
39
68
|
conclusion: FAILED_STATES.has(entry.state) ? 'failure' : entry.state,
|
|
40
69
|
url: entry.url ?? '',
|
|
41
70
|
}));
|
|
42
|
-
return [...checkRuns, ...commitStatuses];
|
|
71
|
+
return [...checkRuns, ...commitStatuses].filter((entry) => !ignored.includes(entry.name));
|
|
43
72
|
}
|
|
44
|
-
async function baseChecks(repo, sha, branch, restarted) {
|
|
73
|
+
async function baseChecks(repo, sha, branch, restarted, ignored) {
|
|
45
74
|
const [runs, external] = await Promise.all([
|
|
46
|
-
baseRuns(repo, sha, branch),
|
|
47
|
-
externalChecks(repo, sha),
|
|
75
|
+
baseRuns(repo, sha, branch, ignored),
|
|
76
|
+
externalChecks(repo, sha, ignored),
|
|
48
77
|
]);
|
|
49
78
|
// A rerun run counts as running until a later attempt of it completes, so its old failure never ends the wait.
|
|
50
79
|
const rerunning = restarted.some((entry) => !runs.some((run) => run.databaseId === entry.id && run.attempt > entry.attempt && run.status === 'completed'));
|
|
@@ -71,7 +100,7 @@ function baseState(runs, external) {
|
|
|
71
100
|
}
|
|
72
101
|
return checks.some((entry) => entry.conclusion === 'cancelled') ? 'cancelled' : 'pass';
|
|
73
102
|
}
|
|
74
|
-
export function waitForBaseChecks(repo, sha, branch, options, restarted = []) {
|
|
103
|
+
export function waitForBaseChecks(repo, sha, branch, options, restarted = [], ignored = []) {
|
|
75
104
|
let read = {
|
|
76
105
|
runs: [],
|
|
77
106
|
external: [],
|
|
@@ -81,20 +110,20 @@ export function waitForBaseChecks(repo, sha, branch, options, restarted = []) {
|
|
|
81
110
|
head: async () => sha,
|
|
82
111
|
lags: async () => true,
|
|
83
112
|
list: async () => {
|
|
84
|
-
read = await baseChecks(repo, sha, branch, restarted);
|
|
113
|
+
read = await baseChecks(repo, sha, branch, restarted, ignored);
|
|
85
114
|
return read.runs.length + read.external.length === 0 && !read.rerunning ? 'none' : 'some';
|
|
86
115
|
},
|
|
87
116
|
watch: async () => (read.rerunning ? 'pending' : baseState(read.runs, read.external)),
|
|
88
117
|
}, options);
|
|
89
118
|
}
|
|
90
|
-
export async function rerunFailedBase(repo, sha, branch, started = () => { }) {
|
|
91
|
-
const failed = (await baseRuns(repo, sha, branch)).filter(rerunnable);
|
|
119
|
+
export async function rerunFailedBase(repo, sha, branch, started = () => { }, ignored = []) {
|
|
120
|
+
const failed = (await baseRuns(repo, sha, branch, ignored)).filter(rerunnable);
|
|
92
121
|
for (const entry of failed) {
|
|
93
122
|
await rerun(repo, entry.databaseId);
|
|
94
123
|
started({ id: entry.databaseId, attempt: entry.attempt });
|
|
95
124
|
}
|
|
96
125
|
if (failed.length > 0) {
|
|
97
|
-
await waitForRestart(repo, sha, branch, failed);
|
|
126
|
+
await waitForRestart(repo, sha, branch, failed, ignored);
|
|
98
127
|
}
|
|
99
128
|
return failed.map((entry) => String(entry.databaseId));
|
|
100
129
|
}
|
|
@@ -109,9 +138,9 @@ async function rerun(repo, id) {
|
|
|
109
138
|
}
|
|
110
139
|
}
|
|
111
140
|
}
|
|
112
|
-
async function waitForRestart(repo, sha, branch, failed) {
|
|
141
|
+
async function waitForRestart(repo, sha, branch, failed, ignored) {
|
|
113
142
|
for (let attempt = 1; attempt <= RESTART_TRIES; attempt += 1) {
|
|
114
|
-
const runs = await baseRuns(repo, sha, branch);
|
|
143
|
+
const runs = await baseRuns(repo, sha, branch, ignored);
|
|
115
144
|
const restarted = failed.every((entry) => runs.some((run) => run.databaseId === entry.databaseId && run.attempt > entry.attempt));
|
|
116
145
|
if (restarted) {
|
|
117
146
|
return;
|
|
@@ -119,13 +148,16 @@ async function waitForRestart(repo, sha, branch, failed) {
|
|
|
119
148
|
await delay(secondsToMs(1));
|
|
120
149
|
}
|
|
121
150
|
}
|
|
122
|
-
export async function failedBaseLogs(repo, sha, branch, maxChars) {
|
|
123
|
-
const failed = (await baseRuns(repo, sha, branch))
|
|
124
|
-
.
|
|
125
|
-
.map((
|
|
126
|
-
|
|
151
|
+
export async function failedBaseLogs(repo, sha, branch, maxChars, ignored = []) {
|
|
152
|
+
const failed = (await baseRuns(repo, sha, branch, ignored)).filter(failedRun).flatMap((entry) => entry.jobs === undefined
|
|
153
|
+
? [{ heading: `## ${entry.name}`, view: [String(entry.databaseId)] }]
|
|
154
|
+
: entry.jobs.filter(failedRun).map((job) => ({
|
|
155
|
+
heading: `## ${entry.name} / ${job.name}`,
|
|
156
|
+
view: ['--job', String(job.databaseId)],
|
|
157
|
+
})));
|
|
158
|
+
const external = (await externalChecks(repo, sha, ignored)).filter(failedRun).map((entry) => ({
|
|
127
159
|
heading: entry.url === '' ? `## ${entry.name}` : `## ${entry.name}\n${entry.url}`,
|
|
128
|
-
|
|
160
|
+
view: undefined,
|
|
129
161
|
}));
|
|
130
162
|
return runLogs(repo, [...failed, ...external], maxChars);
|
|
131
163
|
}
|
package/dist/config-fields.mjs
CHANGED
|
@@ -38,3 +38,9 @@ export function commands(value, field) {
|
|
|
38
38
|
}
|
|
39
39
|
return [...value];
|
|
40
40
|
}
|
|
41
|
+
export function checkNames(value, field) {
|
|
42
|
+
if (!Array.isArray(value) || !value.every((entry) => typeof entry === 'string' && entry !== '')) {
|
|
43
|
+
throw new Error(`${CONFIG_FILE}: ${field} must be a list of check names that are not empty.`);
|
|
44
|
+
}
|
|
45
|
+
return [...value];
|
|
46
|
+
}
|
package/dist/config.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, readFile, rename } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
-
import { CONFIG_FILE, commands, OLD_CONFIG_FILE, record, rejectUnknown, text, whole, } from './config-fields.mjs';
|
|
3
|
+
import { CONFIG_FILE, checkNames, commands, OLD_CONFIG_FILE, record, rejectUnknown, text, whole, } from './config-fields.mjs';
|
|
4
4
|
import { MAX_TIMER_MS } from './durations.mjs';
|
|
5
5
|
import { hasCode, message, parseJson } from './errors.mjs';
|
|
6
6
|
import { readTextIfPresent, unlessMissing, writeJson } from './files.mjs';
|
|
@@ -23,6 +23,7 @@ const DEFAULTS = {
|
|
|
23
23
|
keepRunDays: 7,
|
|
24
24
|
checks: [],
|
|
25
25
|
checksTimeoutMinutes: 30,
|
|
26
|
+
ignoredChecks: [],
|
|
26
27
|
models: {},
|
|
27
28
|
labels: {
|
|
28
29
|
ready: 'status:todo',
|
|
@@ -38,6 +39,7 @@ function defaults() {
|
|
|
38
39
|
return {
|
|
39
40
|
...DEFAULTS,
|
|
40
41
|
checks: [...DEFAULTS.checks],
|
|
42
|
+
ignoredChecks: [...DEFAULTS.ignoredChecks],
|
|
41
43
|
models: { ...DEFAULTS.models },
|
|
42
44
|
labels: { ...DEFAULTS.labels },
|
|
43
45
|
};
|
|
@@ -149,6 +151,9 @@ function parseConfig(value) {
|
|
|
149
151
|
if (file.checks !== undefined) {
|
|
150
152
|
config.checks = commands(file.checks, 'checks');
|
|
151
153
|
}
|
|
154
|
+
if (file.ignoredChecks !== undefined) {
|
|
155
|
+
config.ignoredChecks = checkNames(file.ignoredChecks, 'ignoredChecks');
|
|
156
|
+
}
|
|
152
157
|
if (file.models !== undefined) {
|
|
153
158
|
config.models = parseModels(file.models);
|
|
154
159
|
}
|
package/dist/gate.mjs
CHANGED
|
@@ -41,7 +41,7 @@ export async function checkGate(job, sha) {
|
|
|
41
41
|
async function waitForChecks(job, sha, fields = {}, restarted = []) {
|
|
42
42
|
const { context, log } = job;
|
|
43
43
|
const { repo, config, ports } = context;
|
|
44
|
-
const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true), restarted));
|
|
44
|
+
const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true), restarted, config.ignoredChecks));
|
|
45
45
|
log.event('main-checks.state', { state: checks, ...fields });
|
|
46
46
|
return checks;
|
|
47
47
|
}
|
|
@@ -66,7 +66,7 @@ async function rerunFailed(job, sha) {
|
|
|
66
66
|
try {
|
|
67
67
|
const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, (run) => {
|
|
68
68
|
restarted.push(run);
|
|
69
|
-
});
|
|
69
|
+
}, context.config.ignoredChecks);
|
|
70
70
|
// An empty list tells why the fixer starts with no rerun: no failed workflow run is left to rerun.
|
|
71
71
|
log.event('main-checks.rerun', { sha, runs });
|
|
72
72
|
}
|
|
@@ -99,7 +99,7 @@ async function failedChecksFix(job, sha, refused) {
|
|
|
99
99
|
await writeState(repo, state);
|
|
100
100
|
let logs;
|
|
101
101
|
try {
|
|
102
|
-
logs = await refundOnKill(job, 'ciFixes', () => ports.failedBaseLogs(repo, sha, base, config.logMaxChars));
|
|
102
|
+
logs = await refundOnKill(job, 'ciFixes', () => ports.failedBaseLogs(repo, sha, base, config.logMaxChars, config.ignoredChecks));
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
105
|
await refundStopped(job);
|
package/dist/github.mjs
CHANGED
|
@@ -94,3 +94,6 @@ async function comment(repo, kind, number, body) {
|
|
|
94
94
|
export async function commentOnIssue(repo, issue, body) {
|
|
95
95
|
await comment(repo, 'issue', issue, body);
|
|
96
96
|
}
|
|
97
|
+
export async function editIssueBody(repo, issue, body) {
|
|
98
|
+
await ghOnce(repo, ['issue', 'edit', String(issue), '--body-file', '-'], body);
|
|
99
|
+
}
|
package/dist/implement.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { parseCommitSubject } from './agent-reply.mjs';
|
|
1
|
+
import { parseCommitSubject, parseQuestions } from './agent-reply.mjs';
|
|
2
2
|
import { CODING } from './agents.mjs';
|
|
3
3
|
import { commitWork } from './fix.mjs';
|
|
4
4
|
import { escalateAndFinish } from './handover.mjs';
|
|
5
|
+
import { numbered, withOpenQuestions } from './issue-format.mjs';
|
|
5
6
|
import { fallbackTitle, ROUND_CONTINUE, runRole } from './job.mjs';
|
|
6
7
|
import { implementPrompt } from './prompts.mjs';
|
|
7
8
|
import { writeState } from './state.mjs';
|
|
@@ -10,6 +11,10 @@ export async function implement(job) {
|
|
|
10
11
|
const before = await context.ports.revision(worktree);
|
|
11
12
|
const result = await log.step('implement', {}, () => runRole(job, 'implementer', implementPrompt(issue, comments, reply), CODING));
|
|
12
13
|
state.implementerReply = result.text;
|
|
14
|
+
const questions = parseQuestions(result.text);
|
|
15
|
+
if (questions.length > 0) {
|
|
16
|
+
return askQuestions(job, before, questions);
|
|
17
|
+
}
|
|
13
18
|
const subject = parseCommitSubject(result.text, fallbackTitle(issue));
|
|
14
19
|
if (!(await commitWork(job, before, subject, 'implementer'))) {
|
|
15
20
|
const escalated = await useEarlierCommit(job);
|
|
@@ -21,6 +26,14 @@ export async function implement(job) {
|
|
|
21
26
|
await writeState(context.repo, state);
|
|
22
27
|
return ROUND_CONTINUE;
|
|
23
28
|
}
|
|
29
|
+
async function askQuestions(job, before, questions) {
|
|
30
|
+
const { context, issue, worktree, branch } = job;
|
|
31
|
+
const { repo, ports } = context;
|
|
32
|
+
await ports.discardChanges(worktree, before, branch);
|
|
33
|
+
const fresh = await ports.viewIssue(repo, issue.number);
|
|
34
|
+
await ports.editIssueBody(repo, issue.number, withOpenQuestions(fresh.body, questions));
|
|
35
|
+
return escalateAndFinish(job, `The implementer has questions about the issue.\n\n${numbered(questions)}`, 'questions');
|
|
36
|
+
}
|
|
24
37
|
async function useEarlierCommit(job) {
|
|
25
38
|
const { context, log, state, worktree } = job;
|
|
26
39
|
const earlier = await context.ports.latestSubject(worktree, context.base, context.config.remote);
|
package/dist/issue-format.mjs
CHANGED
|
@@ -5,3 +5,22 @@ export const ISSUE_SECTIONS = [
|
|
|
5
5
|
'Out of scope',
|
|
6
6
|
'Open questions',
|
|
7
7
|
];
|
|
8
|
+
const OPEN_QUESTIONS = /^(#{1,6})[^\S\r\n]+Open questions[^\S\r\n]*$/im;
|
|
9
|
+
export function numbered(items) {
|
|
10
|
+
return items.map((item, index) => `${index + 1}. ${item}`).join('\n');
|
|
11
|
+
}
|
|
12
|
+
export function withOpenQuestions(body, questions) {
|
|
13
|
+
const list = numbered(questions);
|
|
14
|
+
const heading = OPEN_QUESTIONS.exec(body);
|
|
15
|
+
if (heading === null) {
|
|
16
|
+
const kept = body.trimEnd();
|
|
17
|
+
return `${kept === '' ? '' : `${kept}\n\n`}## Open questions\n\n${list}`;
|
|
18
|
+
}
|
|
19
|
+
const start = heading.index + heading[0].length;
|
|
20
|
+
const level = heading[1].length;
|
|
21
|
+
const next = new RegExp(`^#{1,${level}}[^\\S\\r\\n]`, 'm').exec(body.slice(start));
|
|
22
|
+
const end = next === null ? body.length : start + next.index;
|
|
23
|
+
const section = body.slice(start, end).trimEnd();
|
|
24
|
+
const rest = body.slice(end);
|
|
25
|
+
return `${body.slice(0, start)}${section}\n\n${list}${rest === '' ? '' : `\n\n${rest}`}`;
|
|
26
|
+
}
|
package/dist/ports.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { commitAll } from './git-commit.mjs';
|
|
|
5
5
|
import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
|
|
6
6
|
import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
|
|
7
7
|
import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
|
|
8
|
-
import { canWrite, closeIssue, commentOnIssue, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
|
|
8
|
+
import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
|
|
9
9
|
import { huntWorktree } from './hunt.mjs';
|
|
10
10
|
import { ensureLabel, setLabel } from './labels.mjs';
|
|
11
11
|
import { detectSetupCommand } from './setup.mjs';
|
|
@@ -32,6 +32,7 @@ export const PORTS = {
|
|
|
32
32
|
diff,
|
|
33
33
|
discardChanges,
|
|
34
34
|
disputeBranches,
|
|
35
|
+
editIssueBody,
|
|
35
36
|
ensureLabel,
|
|
36
37
|
failedBaseLogs,
|
|
37
38
|
fastForwardBase,
|
package/dist/prompts.mjs
CHANGED
|
@@ -17,6 +17,11 @@ const COMMIT_RULES = [
|
|
|
17
17
|
'Do not run git, gh or any push command. The harness commits for you.',
|
|
18
18
|
'End your final message with one line in the form `commit: <conventional commit subject>`.',
|
|
19
19
|
].join('\n');
|
|
20
|
+
const QUESTION_RULES = [
|
|
21
|
+
'Check the issue first. When the scope, the expected behaviour or the acceptance criteria are ambiguous, make no change and ask instead of guessing.',
|
|
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
|
+
'The harness then hands the issue to a person with your questions.',
|
|
24
|
+
].join('\n');
|
|
20
25
|
function issueBlock(issue, comments) {
|
|
21
26
|
return paragraphs([
|
|
22
27
|
`# Issue #${issue.number}: ${issue.title}`,
|
|
@@ -40,6 +45,7 @@ export function implementPrompt(issue, comments, reply = []) {
|
|
|
40
45
|
replyBlock(reply),
|
|
41
46
|
'## Rules',
|
|
42
47
|
'Read the repository conventions first. Keep the change minimal and focused on the issue.',
|
|
48
|
+
QUESTION_RULES,
|
|
43
49
|
ENGINEERING_RULES,
|
|
44
50
|
'Add or update tests when the repository has a test suite.',
|
|
45
51
|
'For a behaviour change, write the test first and run it before the change. Then quote its failing output in your final message.',
|
package/dist/run-logs.mjs
CHANGED
|
@@ -2,20 +2,20 @@ import { succeeded } from './exec.mjs';
|
|
|
2
2
|
import { ghRun } from './gh.mjs';
|
|
3
3
|
import { joinFilled } from './text.mjs';
|
|
4
4
|
export async function runLogs(repo, failed, maxChars) {
|
|
5
|
-
const withLog = failed.filter(({
|
|
5
|
+
const withLog = failed.filter(({ view }) => view !== undefined).length;
|
|
6
6
|
const share = Math.max(1, Math.floor(maxChars / Math.max(1, withLog)));
|
|
7
7
|
const parts = [];
|
|
8
|
-
for (const { heading,
|
|
8
|
+
for (const { heading, view } of failed) {
|
|
9
9
|
parts.push(heading);
|
|
10
|
-
if (
|
|
10
|
+
if (view === undefined) {
|
|
11
11
|
continue;
|
|
12
12
|
}
|
|
13
|
-
parts.push(await runLog(repo,
|
|
13
|
+
parts.push(await runLog(repo, view, share));
|
|
14
14
|
}
|
|
15
15
|
return parts.join('\n\n');
|
|
16
16
|
}
|
|
17
|
-
async function runLog(repo,
|
|
18
|
-
const logs = await ghRun(repo, ['run', 'view',
|
|
17
|
+
async function runLog(repo, view, share) {
|
|
18
|
+
const logs = await ghRun(repo, ['run', 'view', ...view, '--log-failed'], { tailChars: share });
|
|
19
19
|
if (succeeded(logs)) {
|
|
20
20
|
return logs.stdout;
|
|
21
21
|
}
|