next-issue 7.2.0 → 7.3.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 +13 -1
- package/dist/gate.mjs +34 -2
- package/dist/git.mjs +21 -0
- package/dist/ports.mjs +2 -1
- package/dist/prompts.mjs +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -312,7 +312,11 @@ and comments the reason on the issue, when:
|
|
|
312
312
|
not stay there: its edits are committed with no hooks on top of any commit
|
|
313
313
|
of its own, that commit moves to a new local `<n>-dispute-<commit>` branch,
|
|
314
314
|
and the hand-over comment names that branch. The branch goes away with the
|
|
315
|
-
`<n>` branch when the issue is done
|
|
315
|
+
`<n>` branch when the issue is done. For the checks on the base, a failure
|
|
316
|
+
in a file that the change added or changed is never unrelated: when the
|
|
317
|
+
failed logs name such a file (by its path, or by a tail of its path that
|
|
318
|
+
keeps a folder), the harness refuses the claim and gives the fixer another
|
|
319
|
+
round from `maxCiFixes`, with a note that names the file;
|
|
316
320
|
- a fixer disputes or settles the findings and leaves a change behind, either
|
|
317
321
|
in the worktree or in a commit of its own. A dispute carries a reason, not a
|
|
318
322
|
diff, and a retry of the issue cleans the worktree before the next review,
|
|
@@ -695,6 +699,14 @@ issue to the next. The implementer and the fixer may add a short note to it, and
|
|
|
695
699
|
the prompt asks them to keep only what still holds. The reviewer and the hunter
|
|
696
700
|
only read it.
|
|
697
701
|
|
|
702
|
+
Every agent also reads each `AGENTS.md` that pi finds, such as the one in your
|
|
703
|
+
home folder and the one in the repository. The other rules there, such as code
|
|
704
|
+
conventions and test style, still apply. But the harness owns the issue, the
|
|
705
|
+
worktree, the branch, git, the commit, the push and the checks, and the prompt
|
|
706
|
+
says so: a workflow rule in `AGENTS.md` about these, such as "push to main" or
|
|
707
|
+
"watch ci", does not apply to the agent. The hunter still files its issues with
|
|
708
|
+
`gh issue create`.
|
|
709
|
+
|
|
698
710
|
## Retry an issue that waits for a person
|
|
699
711
|
|
|
700
712
|
When the implementer makes no change, the hand-over comment holds its full
|
package/dist/gate.mjs
CHANGED
|
@@ -87,7 +87,7 @@ async function rerunFailed(job, sha) {
|
|
|
87
87
|
}
|
|
88
88
|
return restarted;
|
|
89
89
|
}
|
|
90
|
-
async function failedChecksFix(job, sha) {
|
|
90
|
+
async function failedChecksFix(job, sha, refused) {
|
|
91
91
|
const { context, log, state } = job;
|
|
92
92
|
const { repo, config, ports, base } = context;
|
|
93
93
|
const { round, limit } = budgetUse(job, 'ciFixes');
|
|
@@ -108,12 +108,26 @@ async function failedChecksFix(job, sha) {
|
|
|
108
108
|
log.event('main-checks.logs', { chars: logs.length });
|
|
109
109
|
let fix;
|
|
110
110
|
try {
|
|
111
|
-
fix = await refundOnKill(job, 'ciFixes', () => fixRound(job, `The checks on ${base} failed after the change landed there
|
|
111
|
+
fix = await refundOnKill(job, 'ciFixes', () => fixRound(job, `The checks on ${base} failed after the change landed there.${refusedNote(refused)}`, logs, [], 'checks'));
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
await refundStopped(job);
|
|
115
115
|
return escalateError(job, error, `The fixer for the failed checks on ${base} failed`, 'fixer error');
|
|
116
116
|
}
|
|
117
|
+
if (!fix.committed && fix.unrelated !== undefined) {
|
|
118
|
+
let files;
|
|
119
|
+
try {
|
|
120
|
+
files = await ports.changedFiles(job.worktree, state.landed ?? []);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return escalateError(job, error, 'The read of the files of the change failed', 'files error');
|
|
124
|
+
}
|
|
125
|
+
const named = namedFile(logs, files);
|
|
126
|
+
if (named !== undefined) {
|
|
127
|
+
log.event('fix.refused', { file: named }, 'quiet');
|
|
128
|
+
return failedChecksFix(job, sha, named);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
117
131
|
if (!fix.committed) {
|
|
118
132
|
const reverted = await revertOrReport(job);
|
|
119
133
|
return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted, fix.aside);
|
|
@@ -121,6 +135,24 @@ async function failedChecksFix(job, sha) {
|
|
|
121
135
|
job.repairing = true;
|
|
122
136
|
return GATE_FIXED;
|
|
123
137
|
}
|
|
138
|
+
function refusedNote(refused) {
|
|
139
|
+
return refused === undefined
|
|
140
|
+
? ''
|
|
141
|
+
: ` The last fixer called the failure unrelated, but the failed logs name \`${refused}\`, a file of this change, so the failure is not unrelated.`;
|
|
142
|
+
}
|
|
143
|
+
/** The first file of the change that the logs name, by its path or by a tail of its path that keeps a folder. */
|
|
144
|
+
function namedFile(logs, files) {
|
|
145
|
+
return files.find((file) => {
|
|
146
|
+
const parts = file.split('/');
|
|
147
|
+
const tails = parts.length === 1
|
|
148
|
+
? [file]
|
|
149
|
+
: parts.slice(0, -1).map((_, index) => parts.slice(index).join('/'));
|
|
150
|
+
return tails.some((tail) => new RegExp(`(?<![\\w.-])${escapeRegExp(tail)}(?![\\w.-])`).test(logs));
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function escapeRegExp(text) {
|
|
154
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
155
|
+
}
|
|
124
156
|
async function refundStopped(job) {
|
|
125
157
|
if (runStopped()) {
|
|
126
158
|
await refundBudget(job, 'ciFixes');
|
package/dist/git.mjs
CHANGED
|
@@ -59,6 +59,27 @@ export async function isDirty(cwd) {
|
|
|
59
59
|
export async function diff(cwd, base, remote) {
|
|
60
60
|
return git(cwd, ['diff', `${remoteRef(remote, base)}...HEAD`]);
|
|
61
61
|
}
|
|
62
|
+
/** The files that the commits added or changed, as paths from the repository root. */
|
|
63
|
+
export async function changedFiles(cwd, shas) {
|
|
64
|
+
if (shas.length === 0) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const output = await git(cwd, [
|
|
68
|
+
'show',
|
|
69
|
+
'--no-renames',
|
|
70
|
+
'--diff-filter=d',
|
|
71
|
+
'--name-only',
|
|
72
|
+
'-z',
|
|
73
|
+
'--format=',
|
|
74
|
+
...shas,
|
|
75
|
+
]);
|
|
76
|
+
return [
|
|
77
|
+
...new Set(output
|
|
78
|
+
.split('\0')
|
|
79
|
+
.map((path) => path.trim())
|
|
80
|
+
.filter(Boolean)),
|
|
81
|
+
];
|
|
82
|
+
}
|
|
62
83
|
export async function discardChanges(cwd, target, branch) {
|
|
63
84
|
const moved = branch !== undefined && (await currentBranch(cwd)) !== branch;
|
|
64
85
|
if (!moved &&
|
package/dist/ports.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { run } from './exec.mjs';
|
|
|
4
4
|
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
|
-
import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
|
|
7
|
+
import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
|
|
8
8
|
import { canWrite, closeIssue, commentOnIssue, 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';
|
|
@@ -22,6 +22,7 @@ export const PORTS = {
|
|
|
22
22
|
abortMerge,
|
|
23
23
|
addWorktree,
|
|
24
24
|
canWrite,
|
|
25
|
+
changedFiles,
|
|
25
26
|
closeIssue,
|
|
26
27
|
commentOnIssue,
|
|
27
28
|
commitAll,
|
package/dist/prompts.mjs
CHANGED
|
@@ -7,7 +7,13 @@ const ENGINEERING_RULES = [
|
|
|
7
7
|
'Reuse existing code and patterns, stay consistent with the repository and pick the simpler option.',
|
|
8
8
|
'Check an API, a command or a url in the repository or its dependencies before you use it. Do not invent one.',
|
|
9
9
|
].join('\n');
|
|
10
|
+
const OTHER_RULES = 'The other rules of `AGENTS.md`, such as code conventions and test style, still apply.';
|
|
11
|
+
const HARNESS_RULES = [
|
|
12
|
+
'The harness owns the issue, the worktree, the branch, git, the commit, the push and the checks. The workflow rules of `AGENTS.md` about these do not apply to you.',
|
|
13
|
+
OTHER_RULES,
|
|
14
|
+
].join('\n');
|
|
10
15
|
const COMMIT_RULES = [
|
|
16
|
+
HARNESS_RULES,
|
|
11
17
|
'Do not run git, gh or any push command. The harness commits for you.',
|
|
12
18
|
'End your final message with one line in the form `commit: <conventional commit subject>`.',
|
|
13
19
|
].join('\n');
|
|
@@ -104,6 +110,7 @@ export function reviewPrompt(issue, comments, diff, earlier, reply) {
|
|
|
104
110
|
'Read files and run commands to prove what you say: the tests, the type check or the linter.',
|
|
105
111
|
'The worktree is ready to use. Do not change a file. Do not write with git or gh, and do not check out another commit or branch.',
|
|
106
112
|
'The harness discards each change that you make, so a change is only lost work.',
|
|
113
|
+
HARNESS_RULES,
|
|
107
114
|
reviewScope(earlier),
|
|
108
115
|
'Give the file and line, or the command output, that supports each finding. A guess is not a finding.',
|
|
109
116
|
'Mark a finding blocking only for a wrong result, a missing part of the issue, a regression or a broken convention.',
|
|
@@ -132,7 +139,10 @@ const CONFLICT_RULE = [
|
|
|
132
139
|
'Leave the merge in progress. The harness commits the merge and pushes it.',
|
|
133
140
|
].join('\n');
|
|
134
141
|
const KIND_RULES = {
|
|
135
|
-
checks:
|
|
142
|
+
checks: [
|
|
143
|
+
UNRELATED_RULE,
|
|
144
|
+
'A failure in a file that this change added or changed is never unrelated. When the failed logs name such a file, the harness refuses an `unrelated` line and gives you another round.',
|
|
145
|
+
].join('\n'),
|
|
136
146
|
local: UNRELATED_RULE,
|
|
137
147
|
review: [
|
|
138
148
|
DISPUTE_RULE,
|
|
@@ -192,6 +202,8 @@ export function huntPrompt(instructions, ready, source, count, repository) {
|
|
|
192
202
|
'## Rules',
|
|
193
203
|
[
|
|
194
204
|
'Run no test suite and no build. Change no file. Do not commit or push.',
|
|
205
|
+
'The harness owns the worktree, git and the checks. The workflow rules of `AGENTS.md` about these do not apply to you.',
|
|
206
|
+
OTHER_RULES,
|
|
195
207
|
`File up to ${issues}, your most serious findings first. File nothing when you find no real problem.`,
|
|
196
208
|
`Before you file an issue, search the open and closed issues for a duplicate, for example with \`gh issue list --repo ${repository} --state all --search "<words>"\`. Do not file a finding when a duplicate exists.`,
|
|
197
209
|
`File each issue with \`gh issue create --repo ${repository}${label} --title "<conventional commit subject>" --body-file -\`.`,
|