next-issue 8.3.2 → 8.4.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 -5
- package/dist/editors.mjs +25 -0
- package/dist/github.mjs +44 -0
- package/dist/pipeline.mjs +5 -0
- package/dist/ports.mjs +2 -1
- package/dist/run.mjs +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -406,6 +406,8 @@ and comments the reason on the issue, when:
|
|
|
406
406
|
end. It halts this way even when the hand-over fails; the issue then ends
|
|
407
407
|
in error with both the reason and the hand-over error;
|
|
408
408
|
- the implementer asks questions about the issue (reason `questions`);
|
|
409
|
+
- a person without write access last changed the title or body of the issue
|
|
410
|
+
(reason `untrusted editor`, see [Safety](#safety));
|
|
409
411
|
- an agent does not finish in `agentTimeoutMinutes`;
|
|
410
412
|
- the setup command fails, or does not finish in `setupTimeoutMinutes`. On a
|
|
411
413
|
resume whose state holds a landed commit, or a push or revert that may have
|
|
@@ -547,9 +549,22 @@ admin access to the repository. The harness leaves out every other comment and
|
|
|
547
549
|
writes a `comment.skip` event with its author to the run log. If an access check
|
|
548
550
|
fails for a reason other than a 404, the issue stops with an error.
|
|
549
551
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
552
|
+
After the setup, and before any agent runs, the harness finds the last person to
|
|
553
|
+
change the body (the author when nobody edited it) and the last person to change
|
|
554
|
+
the title (the author when nobody renamed it). When either has no write or admin
|
|
555
|
+
access, no agent gets the issue: the harness hands it to a person with the
|
|
556
|
+
reason `untrusted editor`, and the comment names each such person. The agent
|
|
557
|
+
gets the title and body read in the same query as their editors, so an edit made
|
|
558
|
+
after the harness listed the issue is never sent unchecked. A writer who
|
|
559
|
+
checks the text and then changes the named title or body makes the issue go on
|
|
560
|
+
after the answer. This matters most on a public repository: anyone can open an
|
|
561
|
+
issue there, and its author can edit the body after a maintainer adds the ready
|
|
562
|
+
label, before the harness claims it. An issue opened by a person without write
|
|
563
|
+
access thus always waits for a writer to change it.
|
|
564
|
+
|
|
565
|
+
Thus a writer can still give an instruction to the agent, and the agent can
|
|
566
|
+
read other text, such as linked issues or files, by itself. Use the harness only
|
|
567
|
+
on a repository where you trust the writers, or run it in a container.
|
|
553
568
|
|
|
554
569
|
[ADR 0001](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0001-reviewer-isolation.md) records why the reviewer
|
|
555
570
|
keeps a full shell, and which other options were considered.
|
|
@@ -578,7 +593,7 @@ get the full summary object there instead, so the harness fits in a pipe. All
|
|
|
578
593
|
progress goes to standard error.
|
|
579
594
|
|
|
580
595
|
Recorded for each step: `claim`, `comments`, `reply`, `worktree`, `setup`,
|
|
581
|
-
`implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `main-checks`, `revert` and `hunt`, each with a
|
|
596
|
+
`editors`, `implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `main-checks`, `revert` and `hunt`, each with a
|
|
582
597
|
`.start`, `.end` or `.error` event and a duration in `ms`. Every `git` and `gh`
|
|
583
598
|
command is recorded with its exit code and duration. A `tool` event holds the
|
|
584
599
|
tool name, and for a `bash` tool the command too. Each agent call adds a `usage`
|
|
@@ -732,7 +747,8 @@ The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman`,
|
|
|
732
747
|
stop the run with an error that names both fields.
|
|
733
748
|
|
|
734
749
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
735
|
-
claims every open issue that no other label holds back.
|
|
750
|
+
claims every open issue that no other label holds back. A run then writes a
|
|
751
|
+
`labels.ready.empty` warning to the log at start.
|
|
736
752
|
|
|
737
753
|
The harness compares the labels on an issue with the configured names without
|
|
738
754
|
case, as GitHub does, so `Status:Todo` counts as `status:todo`.
|
package/dist/editors.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { escalateAndFinish } from './handover.mjs';
|
|
2
|
+
/** Hands the issue over when a person without write access last changed its title or body; otherwise gives the job the title and body checked. */
|
|
3
|
+
export async function untrustedEditors(job) {
|
|
4
|
+
const { context, issue, log } = job;
|
|
5
|
+
const { repo, ports } = context;
|
|
6
|
+
const { title, body, editors } = await log.step('editors', {}, () => ports.issueEditors(repo, issue.number));
|
|
7
|
+
const untrusted = [];
|
|
8
|
+
for (const [part, login] of [
|
|
9
|
+
['title', editors.title],
|
|
10
|
+
['body', editors.body],
|
|
11
|
+
]) {
|
|
12
|
+
if (!(await ports.canWrite(repo, login))) {
|
|
13
|
+
untrusted.push({ part, login });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (untrusted.length === 0) {
|
|
17
|
+
job.issue = { ...issue, title, body };
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const changed = untrusted
|
|
21
|
+
.map(({ part, login }) => `the ${part} was last changed by @${login}, who has no write access to the repository`)
|
|
22
|
+
.join('; ');
|
|
23
|
+
const parts = untrusted.map(({ part }) => `the ${part}`).join(' and ');
|
|
24
|
+
return escalateAndFinish(job, `The worker did not send the issue to an agent: ${changed}. A person with write access can check the issue, then change ${parts} to go on.`, 'untrusted editor');
|
|
25
|
+
}
|
package/dist/github.mjs
CHANGED
|
@@ -68,6 +68,50 @@ export async function canWrite(repo, login) {
|
|
|
68
68
|
throw error;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
const EDITORS_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
72
|
+
repository(owner: $owner, name: $name) {
|
|
73
|
+
issue(number: $number) {
|
|
74
|
+
title
|
|
75
|
+
body
|
|
76
|
+
author { login }
|
|
77
|
+
editor { login }
|
|
78
|
+
lastEditedAt
|
|
79
|
+
timelineItems(itemTypes: [RENAMED_TITLE_EVENT], last: 1) {
|
|
80
|
+
nodes { ... on RenamedTitleEvent { actor { login } } }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}`;
|
|
85
|
+
const GHOST = 'ghost';
|
|
86
|
+
/** The title and body of an issue with the last people to change them; the author when never changed, `ghost` for a deleted account. */
|
|
87
|
+
export async function issueEditors(repo, issue) {
|
|
88
|
+
const raw = await repeatable(repo, [
|
|
89
|
+
'api',
|
|
90
|
+
'graphql',
|
|
91
|
+
...hostname(repo),
|
|
92
|
+
'-f',
|
|
93
|
+
`query=${EDITORS_QUERY}`,
|
|
94
|
+
'-f',
|
|
95
|
+
`owner=${repo.owner}`,
|
|
96
|
+
'-f',
|
|
97
|
+
`name=${repo.name}`,
|
|
98
|
+
'-F',
|
|
99
|
+
`number=${issue}`,
|
|
100
|
+
'--jq',
|
|
101
|
+
'.data.repository.issue',
|
|
102
|
+
]);
|
|
103
|
+
const parsed = parseJson(raw, () => `gh gave editors of #${issue} that are not valid JSON: ${raw}`);
|
|
104
|
+
const author = parsed.author?.login ?? GHOST;
|
|
105
|
+
const renamed = parsed.timelineItems.nodes[0];
|
|
106
|
+
return {
|
|
107
|
+
title: parsed.title,
|
|
108
|
+
body: parsed.body,
|
|
109
|
+
editors: {
|
|
110
|
+
body: parsed.lastEditedAt === null ? author : (parsed.editor?.login ?? GHOST),
|
|
111
|
+
title: renamed === undefined ? author : (renamed.actor?.login ?? GHOST),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
71
115
|
const REPOSITORY_SLUG = '(.repository_url | split("/") | .[-2:] | join("/"))';
|
|
72
116
|
export async function openBlockers(repo, issue) {
|
|
73
117
|
const raw = await ghApi(repo, `issues/${issue}/dependencies/blocked_by`, `.[] | select(.state == "open") | ${REPOSITORY_SLUG} + "#" + (.number | tostring)`, { paginate: true });
|
package/dist/pipeline.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { untrustedEditors } from './editors.mjs';
|
|
1
2
|
import { enterReview, settleSquash } from './enter-review.mjs';
|
|
2
3
|
import { branchName } from './git.mjs';
|
|
3
4
|
import { runStopped } from './children.mjs';
|
|
@@ -78,6 +79,10 @@ async function work(context, issue, log, state, start, handedOver, pending) {
|
|
|
78
79
|
if (setup.done) {
|
|
79
80
|
return setup.report;
|
|
80
81
|
}
|
|
82
|
+
const untrusted = await untrustedEditors(job);
|
|
83
|
+
if (untrusted !== undefined) {
|
|
84
|
+
return untrusted.report;
|
|
85
|
+
}
|
|
81
86
|
if (state.phase === 'claimed') {
|
|
82
87
|
const implemented = await implement(job);
|
|
83
88
|
if (implemented.done) {
|
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, saveSetupOutput, setAside, } from './git.mjs';
|
|
8
|
-
import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
|
|
8
|
+
import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, issueEditors, 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';
|
|
@@ -42,6 +42,7 @@ export const PORTS = {
|
|
|
42
42
|
isLanded,
|
|
43
43
|
isOnBase,
|
|
44
44
|
issueComments,
|
|
45
|
+
issueEditors,
|
|
45
46
|
latestSubject,
|
|
46
47
|
openBlockers,
|
|
47
48
|
openIssues,
|
package/dist/run.mjs
CHANGED
|
@@ -113,6 +113,9 @@ async function startRun(args, config, repo, recorder, interrupts) {
|
|
|
113
113
|
base,
|
|
114
114
|
log: recorder.logFile,
|
|
115
115
|
}, 'quiet');
|
|
116
|
+
if (config.labels.ready.length === 0) {
|
|
117
|
+
recorder.event('labels.ready.empty', { note: 'labels.ready is empty, so every open issue can be claimed' }, 'quiet');
|
|
118
|
+
}
|
|
116
119
|
return {
|
|
117
120
|
repo,
|
|
118
121
|
config,
|