next-issue 6.8.0 → 6.10.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 +29 -7
- package/dist/config-fields.mjs +7 -0
- package/dist/config.mjs +13 -2
- package/dist/fix.mjs +3 -2
- package/dist/land.mjs +12 -2
- package/dist/local-checks.mjs +68 -0
- package/dist/ports.mjs +6 -0
- package/dist/prompts.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -143,13 +143,29 @@ the run handles one issue. For each issue:
|
|
|
143
143
|
conflict marker. With the budget used up, or when the fixer leaves a
|
|
144
144
|
conflict marker or the merge unresolved, aborts the merge, or fails, the
|
|
145
145
|
harness undoes the merge and hands the issue to a person with the reason
|
|
146
|
-
`merge conflict`.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
`
|
|
146
|
+
`merge conflict`. When `checks` lists commands, the harness then runs
|
|
147
|
+
each one in the worktree, in order, with `bash -c` and stderr merged
|
|
148
|
+
into stdout, each for at most `checksTimeoutMinutes`. Their output goes
|
|
149
|
+
to the run log (`check.output`, and `check.fail` for a failure). A
|
|
150
|
+
command that fails or does not finish stops the landing before the push:
|
|
151
|
+
the fixer gets the command and the tail of its output (at most
|
|
152
|
+
`logMaxChars`) from the check budget, `maxCiFixes`, and its fix is
|
|
153
|
+
squashed into the change, which keeps its subject. The harness then
|
|
154
|
+
merges the base again and runs every command again, so nothing lands
|
|
155
|
+
until all pass. When the budget runs out, the harness hands the issue to
|
|
156
|
+
a person with the reason `local checks failed: <command>` and the tail
|
|
157
|
+
of the output in the comment; a fixer that adds no commit or calls the
|
|
158
|
+
failure unrelated hands it over too, as for the checks on the base.
|
|
159
|
+
Nothing of the change reaches the base. A run that stops while a
|
|
160
|
+
command runs keeps the budget, and the next run merges and runs every
|
|
161
|
+
command again before any push. The harness then pushes the commit to
|
|
162
|
+
the base branch, without force. A push that the remote refuses, for
|
|
163
|
+
example because the base moved, starts the rebase again, three times at
|
|
164
|
+
most. When the push fails, the harness fetches the base first, and
|
|
165
|
+
treats the push as landed when the base holds the commit, for example
|
|
166
|
+
after a timeout. When that fetch fails too, the harness hands the issue
|
|
167
|
+
to a person with the reason `push unknown` and halts, even when the
|
|
168
|
+
hand-over fails. The state file
|
|
153
169
|
holds the commit during the push, so a run stopped meanwhile, or the
|
|
154
170
|
resume after that hand-over (once a person answers or takes the label
|
|
155
171
|
off), checks the base and waits for the checks of the commit when it
|
|
@@ -295,6 +311,8 @@ and comments the reason on the issue, when:
|
|
|
295
311
|
none of the change. Neither lands. The `<n>-dispute-<commit>` branches go
|
|
296
312
|
away with the `<n>` branch when the issue is done;
|
|
297
313
|
- the reviewer gives no verdict, or the checks do not finish in time;
|
|
314
|
+
- a command in `checks` still fails before the push when the check budget
|
|
315
|
+
runs out; nothing of the change is pushed;
|
|
298
316
|
- the push to the base branch fails three times;
|
|
299
317
|
- the checks on the base branch fail and the fixer cannot fix them, an error
|
|
300
318
|
stops the fix, or they do not finish in time. The base branch is then
|
|
@@ -564,6 +582,8 @@ because no pull request is opened.
|
|
|
564
582
|
"logMaxChars": 20000,
|
|
565
583
|
"diffMaxChars": 60000,
|
|
566
584
|
"keepRunDays": 7,
|
|
585
|
+
"checks": [],
|
|
586
|
+
"checksTimeoutMinutes": 30,
|
|
567
587
|
"models": {
|
|
568
588
|
"implementer": null,
|
|
569
589
|
"reviewer": null,
|
|
@@ -599,6 +619,8 @@ because no pull request is opened.
|
|
|
599
619
|
| `logMaxChars` | `20000` | The maximum length of the failed job logs, shared between the failed GitHub Actions runs (failed external checks are listed by name and link only) |
|
|
600
620
|
| `diffMaxChars` | `60000` | The maximum length of the diff that the reviewer reads |
|
|
601
621
|
| `keepRunDays` | `7` | The number of days to keep the run files; `0` keeps them all |
|
|
622
|
+
| `checks` | `[]` | Shell commands that must pass in the worktree, in order, before an approved change is pushed; a failure goes to the fixer |
|
|
623
|
+
| `checksTimeoutMinutes` | `30` | The limit for one command in `checks`, at most `35791` |
|
|
602
624
|
| `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer |
|
|
603
625
|
| `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
|
|
604
626
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
package/dist/config-fields.mjs
CHANGED
|
@@ -31,3 +31,10 @@ export function text(value, field, allowEmpty) {
|
|
|
31
31
|
}
|
|
32
32
|
return value;
|
|
33
33
|
}
|
|
34
|
+
export function commands(value, field) {
|
|
35
|
+
if (!Array.isArray(value) ||
|
|
36
|
+
!value.every((entry) => typeof entry === 'string' && entry.trim().length > 0)) {
|
|
37
|
+
throw new Error(`${CONFIG_FILE}: ${field} must be a list of commands that are not empty.`);
|
|
38
|
+
}
|
|
39
|
+
return [...value];
|
|
40
|
+
}
|
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, OLD_CONFIG_FILE, record, rejectUnknown, text, whole, } from './config-fields.mjs';
|
|
3
|
+
import { CONFIG_FILE, 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';
|
|
@@ -21,6 +21,8 @@ const DEFAULTS = {
|
|
|
21
21
|
logMaxChars: 20000,
|
|
22
22
|
diffMaxChars: 60000,
|
|
23
23
|
keepRunDays: 7,
|
|
24
|
+
checks: [],
|
|
25
|
+
checksTimeoutMinutes: 30,
|
|
24
26
|
models: {},
|
|
25
27
|
labels: {
|
|
26
28
|
ready: 'status:todo',
|
|
@@ -33,7 +35,12 @@ const DEFAULTS = {
|
|
|
33
35
|
},
|
|
34
36
|
};
|
|
35
37
|
function defaults() {
|
|
36
|
-
return {
|
|
38
|
+
return {
|
|
39
|
+
...DEFAULTS,
|
|
40
|
+
checks: [...DEFAULTS.checks],
|
|
41
|
+
models: { ...DEFAULTS.models },
|
|
42
|
+
labels: { ...DEFAULTS.labels },
|
|
43
|
+
};
|
|
37
44
|
}
|
|
38
45
|
const FIELDS = [...Object.keys(DEFAULTS), 'setupCommand'];
|
|
39
46
|
const MAX_MINUTES = Math.floor(MAX_TIMER_MS / 60_000);
|
|
@@ -54,6 +61,7 @@ const WHOLE_FIELDS = [
|
|
|
54
61
|
['logMaxChars', 1],
|
|
55
62
|
['diffMaxChars', 1],
|
|
56
63
|
['keepRunDays', 0],
|
|
64
|
+
['checksTimeoutMinutes', 1, MAX_MINUTES],
|
|
57
65
|
];
|
|
58
66
|
const MODEL_ROLES = ['implementer', 'reviewer', 'fixer'];
|
|
59
67
|
const LABEL_NAMES = [
|
|
@@ -138,6 +146,9 @@ function parseConfig(value) {
|
|
|
138
146
|
if (file.setupCommand !== undefined) {
|
|
139
147
|
config.setupCommand = text(file.setupCommand, 'setupCommand', false);
|
|
140
148
|
}
|
|
149
|
+
if (file.checks !== undefined) {
|
|
150
|
+
config.checks = commands(file.checks, 'checks');
|
|
151
|
+
}
|
|
141
152
|
if (file.models !== undefined) {
|
|
142
153
|
config.models = parseModels(file.models);
|
|
143
154
|
}
|
package/dist/fix.mjs
CHANGED
|
@@ -42,7 +42,8 @@ export async function fixRound(job, reason, detail, earlier, kind) {
|
|
|
42
42
|
job.state.changeTitle ??= title;
|
|
43
43
|
}
|
|
44
44
|
const committed = await commitWork(job, before, subject, 'fixer');
|
|
45
|
-
|
|
45
|
+
// A review or local check fix is squashed into the change, which keeps its title.
|
|
46
|
+
if (kind === 'review' || kind === 'local') {
|
|
46
47
|
job.state.title = title;
|
|
47
48
|
}
|
|
48
49
|
if (!committed) {
|
|
@@ -63,7 +64,7 @@ async function disputedFix(job, before, reason, note, kind) {
|
|
|
63
64
|
const { context, issue, log, worktree, branch } = job;
|
|
64
65
|
const { ports } = context;
|
|
65
66
|
// A retry or the revert after a failed check cleans this worktree, so edits left there would be lost.
|
|
66
|
-
const saved = await ports.saveEdits(worktree, `fix: edits left by the ${kind === '
|
|
67
|
+
const saved = await ports.saveEdits(worktree, `fix: edits left by the ${kind === 'review' ? 'review' : 'check'} fixer\n\nRefs #${issue.number}`);
|
|
67
68
|
const disputed = await ports.revision(worktree);
|
|
68
69
|
if (disputed === before) {
|
|
69
70
|
return disputedNote(job, reason, note, { stray: false });
|
package/dist/land.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { runStopped } from './children.mjs';
|
|
|
2
2
|
import { rebase } from './conflict.mjs';
|
|
3
3
|
import { checkGate, escalateError } from './gate.mjs';
|
|
4
4
|
import { PUSH_TRIES } from './git-land.mjs';
|
|
5
|
+
import { localChecks } from './local-checks.mjs';
|
|
5
6
|
import { escalateAndFinish, finishDone, stop } from './handover.mjs';
|
|
6
7
|
import { oneAtATime } from './lock.mjs';
|
|
7
8
|
import { revertFailedFix } from './revert.mjs';
|
|
@@ -106,11 +107,19 @@ async function landLoop(job) {
|
|
|
106
107
|
async function pushChange(job) {
|
|
107
108
|
const { context, log, state, worktree } = job;
|
|
108
109
|
const { repo, config, ports, base } = context;
|
|
109
|
-
for (let attempt = 1;;
|
|
110
|
+
for (let attempt = 1;;) {
|
|
110
111
|
const rebased = await rebase(job);
|
|
111
112
|
if (rebased !== undefined) {
|
|
112
113
|
return rebased;
|
|
113
114
|
}
|
|
115
|
+
const checked = await localChecks(job);
|
|
116
|
+
if (checked === false) {
|
|
117
|
+
// The fixer committed: merge the base again and run every check on the result.
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (checked !== true) {
|
|
121
|
+
return checked;
|
|
122
|
+
}
|
|
114
123
|
const sha = await ports.revision(worktree);
|
|
115
124
|
// A halt saved before nothing of this issue was left on the base must not block once this push lands.
|
|
116
125
|
releaseSettled(state);
|
|
@@ -137,7 +146,8 @@ async function pushChange(job) {
|
|
|
137
146
|
job.repairing = false;
|
|
138
147
|
return sha;
|
|
139
148
|
}
|
|
140
|
-
|
|
149
|
+
attempt += 1;
|
|
150
|
+
if (attempt > PUSH_TRIES) {
|
|
141
151
|
return escalateAndFinish(job, `The push to ${base} failed ${PUSH_TRIES} times.`, 'push failed');
|
|
142
152
|
}
|
|
143
153
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { budgetUse, refundBudget, refundOnKill } from './budget.mjs';
|
|
2
|
+
import { refuseWhenStopped, runStopped } from './children.mjs';
|
|
3
|
+
import { minutesToMs } from './durations.mjs';
|
|
4
|
+
import { succeeded } from './exec.mjs';
|
|
5
|
+
import { escalateCheckFix, fixRound } from './fix.mjs';
|
|
6
|
+
import { escalateAndFinish } from './handover.mjs';
|
|
7
|
+
import { writeState } from './state.mjs';
|
|
8
|
+
import { keepTail } from './text.mjs';
|
|
9
|
+
const COMMENT_OUTPUT_CHARS = 3000;
|
|
10
|
+
/**
|
|
11
|
+
* Runs the configured check commands in the worktree before a push.
|
|
12
|
+
* Gives `true` when every command passed, `false` when the fixer committed a fix (merge and check again),
|
|
13
|
+
* or the finished hand-over.
|
|
14
|
+
*/
|
|
15
|
+
export async function localChecks(job) {
|
|
16
|
+
const { context, log, worktree } = job;
|
|
17
|
+
const { config, ports } = context;
|
|
18
|
+
for (const command of config.checks) {
|
|
19
|
+
const result = await log.step('check', { cmd: command }, () => ports.runCheck(command, worktree, minutesToMs(config.checksTimeoutMinutes), config.logMaxChars));
|
|
20
|
+
// A stop kills the command, so its failure is no finding: the next run checks again.
|
|
21
|
+
refuseWhenStopped();
|
|
22
|
+
log.event('check.output', { cmd: command, code: result.code, timedOut: result.timedOut, output: result.output }, 'verbose');
|
|
23
|
+
if (!succeeded(result) || result.timedOut) {
|
|
24
|
+
return failedCheck(job, command, result);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function failure(job, command, result) {
|
|
30
|
+
return result.timedOut
|
|
31
|
+
? `The local check \`${command}\` did not finish in ${job.context.config.checksTimeoutMinutes} minutes.`
|
|
32
|
+
: `The local check \`${command}\` failed with code ${result.code}.`;
|
|
33
|
+
}
|
|
34
|
+
function outputBlock(output) {
|
|
35
|
+
const kept = keepTail(output.trim(), COMMENT_OUTPUT_CHARS);
|
|
36
|
+
if (kept === '') {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
const longest = Math.max(2, ...(kept.match(/`+/g) ?? []).map((run) => run.length));
|
|
40
|
+
const fence = '`'.repeat(longest + 1);
|
|
41
|
+
return `\n\n${fence}\n${kept}\n${fence}`;
|
|
42
|
+
}
|
|
43
|
+
async function failedCheck(job, command, result) {
|
|
44
|
+
const { context, log, state } = job;
|
|
45
|
+
const { repo, base } = context;
|
|
46
|
+
const note = failure(job, command, result);
|
|
47
|
+
log.event('check.fail', { cmd: command, code: result.code, timedOut: result.timedOut }, 'quiet');
|
|
48
|
+
const { round, limit } = budgetUse(job, 'ciFixes');
|
|
49
|
+
if (round >= limit) {
|
|
50
|
+
return escalateAndFinish(job, `${note} The limit of ${limit} check fixes was reached, so the harness did not push the change to ${base}.${outputBlock(result.output)}`, `local checks failed: ${command}`);
|
|
51
|
+
}
|
|
52
|
+
state.ciFixes += 1;
|
|
53
|
+
await writeState(repo, state);
|
|
54
|
+
let fix;
|
|
55
|
+
try {
|
|
56
|
+
fix = await refundOnKill(job, 'ciFixes', () => fixRound(job, `${note} The harness runs it before the push to ${base}.`, result.output, [], 'local'));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (runStopped()) {
|
|
60
|
+
await refundBudget(job, 'ciFixes');
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
if (!fix.committed) {
|
|
65
|
+
return escalateCheckFix(job, fix.unrelated, `local checks (\`${command}\`)`, '', fix.aside);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
package/dist/ports.mjs
CHANGED
|
@@ -13,6 +13,11 @@ import { addWorktree, fastForwardBase, findWorktree, removeWorktree } from './wo
|
|
|
13
13
|
async function runSetup(command, cwd, timeoutMs) {
|
|
14
14
|
return run('bash', ['-lc', command], { cwd, timeoutMs });
|
|
15
15
|
}
|
|
16
|
+
/** Runs a check command with its stderr in its stdout, so the output keeps the order it was written in. */
|
|
17
|
+
async function runCheck(command, cwd, timeoutMs, tailChars) {
|
|
18
|
+
const result = await run('bash', ['-c', `exec 2>&1\n${command}`], { cwd, timeoutMs, tailChars });
|
|
19
|
+
return { code: result.code, output: result.stdout, timedOut: result.timedOut };
|
|
20
|
+
}
|
|
16
21
|
export const PORTS = {
|
|
17
22
|
abortMerge,
|
|
18
23
|
addWorktree,
|
|
@@ -49,6 +54,7 @@ export const PORTS = {
|
|
|
49
54
|
revertOnBase,
|
|
50
55
|
revision,
|
|
51
56
|
runAgent,
|
|
57
|
+
runCheck,
|
|
52
58
|
runSetup,
|
|
53
59
|
saveEdits,
|
|
54
60
|
setAside,
|
package/dist/prompts.mjs
CHANGED
|
@@ -120,6 +120,7 @@ const CONFLICT_RULE = [
|
|
|
120
120
|
].join('\n');
|
|
121
121
|
const KIND_RULES = {
|
|
122
122
|
checks: UNRELATED_RULE,
|
|
123
|
+
local: UNRELATED_RULE,
|
|
123
124
|
review: [
|
|
124
125
|
DISPUTE_RULE,
|
|
125
126
|
'For a behaviour change, run its test before the change and quote its failing output in your final message.',
|