opencode-magi 0.0.0-dev-20261027230846 → 0.0.0-dev-20261104100346
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Validate review findings for pull request #{pr} in {owner}/{repo}.
|
|
2
2
|
Use the existing review session context.
|
|
3
3
|
Vote on whether each listed finding is a valid reason to request changes.
|
|
4
|
+
Vote DISAGREE when a finding duplicates an issue already raised in any review thread in the existing review session context.
|
|
4
5
|
Each finding's `body` contains the proposed review comment text.
|
|
5
6
|
|
|
6
7
|
Findings to validate are provided in `<findings>`.
|
|
@@ -9,6 +9,9 @@ Request changes if a closing issue requirement is missing, only documented, only
|
|
|
9
9
|
Do not approve solely because the PR improves the codebase if it claims to close an issue that remains incomplete.
|
|
10
10
|
For referenced non-closing issues, use them as context only unless the PR body explicitly claims to complete them.
|
|
11
11
|
|
|
12
|
+
All review threads are provided in `<review>` for context.
|
|
13
|
+
Do not duplicate an issue already raised in any review thread as a finding. Use findings only for separate new issues.
|
|
14
|
+
Leave existing issues in their original threads for their owners to follow up. If you have no separate new findings and no reason to close the PR, return APPROVED.
|
|
12
15
|
Every finding must target a valid right-side line in the PR diff.
|
|
13
16
|
If the problem itself does not have an exact changed line, choose the nearest changed line that represents the cause, responsibility, missing implementation, or affected behavior. This includes but is not limited to missing validation, missing wiring, missing requirements, missing tests, missing documentation, affected configuration, or relevant call sites.
|
|
14
17
|
Do not omit line. Do not create file-level or body-only findings.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import picomatch from "picomatch";
|
|
2
2
|
import { MagiError } from "@/magi";
|
|
3
3
|
import { Prompt } from "@/prompts";
|
|
4
|
-
import { command, filterEmpty, isBoolean, isNumber, omitNullish, quote, retry, Worker, } from "@/utils";
|
|
4
|
+
import { command, filterEmpty, isBoolean, isNumber, omitNullish, quote, retry, wait, Worker, } from "@/utils";
|
|
5
5
|
const ci = {
|
|
6
6
|
isExcluded(exclude, { name }) {
|
|
7
7
|
return exclude.some((pattern) => {
|
|
@@ -220,15 +220,12 @@ export async function rerunChecks() {
|
|
|
220
220
|
this.context.signal.throwIfAborted();
|
|
221
221
|
if (!this.state.pr?.checks)
|
|
222
222
|
throw new MagiError("blocked", "PR checks not found.");
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
passed: this.state.pr.checks.passed,
|
|
226
|
-
};
|
|
223
|
+
const previousChecks = this.state.pr.checks;
|
|
224
|
+
let checks = { ...previousChecks };
|
|
227
225
|
const failedChecks = checks.failed.filter(({ scope }) => !scope);
|
|
228
226
|
if (!failedChecks.length)
|
|
229
227
|
return;
|
|
230
228
|
await this.updateEvent(`Rerunning CI checks.`);
|
|
231
|
-
let label = failedChecks.map(({ name }) => name).join(", ");
|
|
232
229
|
if (this.state.dryRun) {
|
|
233
230
|
checks.passed = [
|
|
234
231
|
...checks.passed,
|
|
@@ -237,31 +234,39 @@ export async function rerunChecks() {
|
|
|
237
234
|
checks.failed = checks.failed.filter(({ scope }) => scope);
|
|
238
235
|
}
|
|
239
236
|
else {
|
|
240
|
-
|
|
237
|
+
for (let count = 1; count <= this.config.review.checks.retryFailedJobs; count++) {
|
|
238
|
+
const targets = checks.failed.filter(({ scope }) => !scope);
|
|
239
|
+
const label = targets.map(({ name }) => name).join(", ");
|
|
241
240
|
await this.updateEvent(`Rerunning checks ${label}.`);
|
|
242
|
-
|
|
243
|
-
.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
241
|
+
for (const target of targets) {
|
|
242
|
+
const check = checks.failed.find(({ name, workflow }) => name === target.name && workflow === target.workflow);
|
|
243
|
+
if (!check)
|
|
244
|
+
continue;
|
|
245
|
+
await rerunCheck.call(this, check.id);
|
|
246
|
+
for (;;) {
|
|
247
|
+
await watchChecks.call(this);
|
|
248
|
+
const next = await getChecks.call(this, false);
|
|
249
|
+
const result = [...next.failed, ...next.passed].find(({ name, workflow }) => name === check.name && workflow === check.workflow);
|
|
250
|
+
if (!next.pending.length && result && result.id !== check.id) {
|
|
251
|
+
await Promise.all(next.failed.map(async (check) => {
|
|
252
|
+
check.log = await getCheckLog.call(this, check.id);
|
|
253
|
+
}));
|
|
254
|
+
for (const key of ["failed", "passed"])
|
|
255
|
+
next[key] = next[key].map((check) => {
|
|
256
|
+
const { classifieds, scope } = previousChecks.failed.find(({ name, workflow }) => check.name === name && check.workflow === workflow) ?? {};
|
|
257
|
+
return omitNullish({ ...check, classifieds, scope });
|
|
258
|
+
});
|
|
259
|
+
checks = next;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
await wait(1_000, this.context.signal);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const remaining = checks.failed.filter(({ scope }) => !scope);
|
|
266
|
+
if (!remaining.length)
|
|
267
|
+
break;
|
|
268
|
+
await this.updateEvent(`Attempt ${count} failed to rerun checks ${remaining.map(({ name }) => name).join(", ")}.${count < this.config.review.checks.retryFailedJobs ? " Retrying..." : ""}`);
|
|
269
|
+
}
|
|
265
270
|
}
|
|
266
271
|
const passedChecksAfterRerun = checks.passed.filter((check) => "scope" in check && !check.scope);
|
|
267
272
|
const failedChecksAfterRerun = checks.failed.filter(({ scope }) => !scope);
|
|
@@ -296,7 +301,7 @@ export async function getMetadata() {
|
|
|
296
301
|
metadata: data,
|
|
297
302
|
};
|
|
298
303
|
}
|
|
299
|
-
async function getChecks() {
|
|
304
|
+
async function getChecks(includeLogs = true) {
|
|
300
305
|
const fields = "name,state,bucket,link,workflow";
|
|
301
306
|
const checks = {
|
|
302
307
|
excluded: [],
|
|
@@ -313,8 +318,10 @@ async function getChecks() {
|
|
|
313
318
|
checks.excluded.push(check);
|
|
314
319
|
}
|
|
315
320
|
else if (ci.isFailed(check)) {
|
|
316
|
-
const log =
|
|
317
|
-
|
|
321
|
+
const log = includeLogs
|
|
322
|
+
? await getCheckLog.call(this, check.id)
|
|
323
|
+
: undefined;
|
|
324
|
+
checks.failed.push(omitNullish({ ...check, log }));
|
|
318
325
|
}
|
|
319
326
|
else if (ci.isPassed(check)) {
|
|
320
327
|
checks.passed.push(check);
|
|
@@ -332,12 +339,38 @@ async function getChecks() {
|
|
|
332
339
|
}
|
|
333
340
|
async function getCheckLog(id) {
|
|
334
341
|
const log = await this.exec(command("gh", "run", "view", "--repo", this.state.repo, "--job", quote(id), "--log-failed"), { signal: this.context.signal });
|
|
335
|
-
|
|
342
|
+
const lines = log
|
|
336
343
|
// oxlint-disable-next-line no-control-regex
|
|
337
344
|
.replaceAll(/\u001B\[[0-9;]*m/g, "")
|
|
338
345
|
.split("\n")
|
|
339
|
-
.filter((line) => line.trim())
|
|
340
|
-
|
|
346
|
+
.filter((line) => line.trim());
|
|
347
|
+
const unknownStep = /^[^\t]*\tUNKNOWN STEP\t\s*(\S+)/;
|
|
348
|
+
if (!lines.some((line) => unknownStep.test(line)))
|
|
349
|
+
return lines.join("\n");
|
|
350
|
+
const raw = await this.exec(command("gh", "api", quote(`repos/${this.config.github.owner}/${this.config.github.repo}/actions/jobs/${id}`)), { signal: this.context.signal });
|
|
351
|
+
const { steps = [] } = JSON.parse(raw);
|
|
352
|
+
const ranges = steps.flatMap(({ completed_at, conclusion, started_at }) => {
|
|
353
|
+
if (conclusion !== "failure" || !started_at || !completed_at)
|
|
354
|
+
return [];
|
|
355
|
+
return [
|
|
356
|
+
{
|
|
357
|
+
// GitHub step timestamps have second precision, so include the final second.
|
|
358
|
+
end: Date.parse(completed_at) + 1_000,
|
|
359
|
+
start: Date.parse(started_at),
|
|
360
|
+
},
|
|
361
|
+
];
|
|
362
|
+
});
|
|
363
|
+
if (!ranges.length)
|
|
364
|
+
return lines.join("\n");
|
|
365
|
+
const filtered = lines.filter((line) => {
|
|
366
|
+
const match = line.match(unknownStep);
|
|
367
|
+
if (!match)
|
|
368
|
+
return true;
|
|
369
|
+
const time = Date.parse(match[1]);
|
|
370
|
+
return (Number.isNaN(time) ||
|
|
371
|
+
ranges.some(({ end, start }) => start <= time && time < end));
|
|
372
|
+
});
|
|
373
|
+
return (filtered.length ? filtered : lines).join("\n");
|
|
341
374
|
}
|
|
342
375
|
async function rerunCheck(id) {
|
|
343
376
|
await this.exec(command("gh", "run", "rerun", "--repo", this.state.repo, "--job", quote(id)), { signal: this.context.signal });
|
|
@@ -22,18 +22,23 @@ export async function checkExistingReviews() {
|
|
|
22
22
|
if (review.user.login !== this.config.account)
|
|
23
23
|
return;
|
|
24
24
|
const markers = marker.parse(review.body);
|
|
25
|
-
const { body, reviewer, verdict } = markers.find(({ reviewer }) => reviewer === id) ?? {};
|
|
25
|
+
const { body, command, reviewer, verdict } = markers.find(({ reviewer }) => reviewer === id) ?? {};
|
|
26
26
|
if (reviewer !== id || !verdict)
|
|
27
27
|
return;
|
|
28
|
+
if (review.state === "DISMISSED" &&
|
|
29
|
+
(command !== "review" ||
|
|
30
|
+
!["APPROVED", "CHANGES_REQUESTED", "CLOSED"].includes(verdict)))
|
|
31
|
+
return;
|
|
32
|
+
const state = review.state === "DISMISSED" ? review.state : verdict;
|
|
28
33
|
try {
|
|
29
34
|
return {
|
|
30
35
|
...review,
|
|
31
36
|
body: body ? decodeURIComponent(body) : "",
|
|
32
|
-
state
|
|
37
|
+
state,
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
catch {
|
|
36
|
-
return { ...review, body: "", state
|
|
41
|
+
return { ...review, body: "", state };
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
else {
|
|
@@ -43,10 +48,17 @@ export async function checkExistingReviews() {
|
|
|
43
48
|
return review;
|
|
44
49
|
if (review.state === "CHANGES_REQUESTED")
|
|
45
50
|
return review;
|
|
46
|
-
if (review.state !== "COMMENTED")
|
|
51
|
+
if (review.state !== "COMMENTED" && review.state !== "DISMISSED")
|
|
47
52
|
return;
|
|
48
53
|
const markers = marker.parse(review.body);
|
|
49
|
-
const { reviewer, verdict } = markers[0] ?? {};
|
|
54
|
+
const { command, reviewer, verdict } = markers[0] ?? {};
|
|
55
|
+
if (review.state === "DISMISSED") {
|
|
56
|
+
if (command !== "review" ||
|
|
57
|
+
reviewer !== id ||
|
|
58
|
+
(verdict !== "APPROVED" && verdict !== "CHANGES_REQUESTED"))
|
|
59
|
+
return;
|
|
60
|
+
return review;
|
|
61
|
+
}
|
|
50
62
|
if (reviewer !== id || verdict !== "CLOSED")
|
|
51
63
|
return;
|
|
52
64
|
return { ...review, state: "CLOSED" };
|
|
@@ -60,7 +72,7 @@ export async function checkExistingReviews() {
|
|
|
60
72
|
submitted_at &&
|
|
61
73
|
submitted_at.localeCompare(latestNonMergeCommit.commit.author.date) >= 0);
|
|
62
74
|
const review = targetReviews.at(-1);
|
|
63
|
-
if (latestReviews.length)
|
|
75
|
+
if (latestReviews.length && review?.state !== "DISMISSED")
|
|
64
76
|
return [id, { account, review, status: "skip" }];
|
|
65
77
|
else
|
|
66
78
|
return [id, { account, review, status: "rereview" }];
|
|
@@ -369,20 +369,25 @@ function transformState(reviewer, id, accepted) {
|
|
|
369
369
|
const prevOutput = outputs[outputs.length - 1];
|
|
370
370
|
if (prevOutput?.verdict !== "CHANGES_REQUESTED")
|
|
371
371
|
return reviewer;
|
|
372
|
+
const prevFindings = prevOutput.findings ?? prevOutput.newFindings;
|
|
373
|
+
if (!prevFindings?.length)
|
|
374
|
+
return reviewer;
|
|
372
375
|
const nextOutput = { ...prevOutput };
|
|
373
|
-
const findings = (
|
|
374
|
-
prevOutput.newFindings ??
|
|
375
|
-
[]).map((finding, index) => ({
|
|
376
|
+
const findings = prevFindings.map((finding, index) => ({
|
|
376
377
|
...finding,
|
|
377
378
|
state: accepted.has(`${id}:${index}`) ? "accepted" : "discarded",
|
|
378
379
|
}));
|
|
379
380
|
if (prevOutput.findings)
|
|
380
381
|
nextOutput.findings = findings;
|
|
381
|
-
else
|
|
382
|
+
else
|
|
382
383
|
nextOutput.newFindings = findings;
|
|
383
384
|
outputs[outputs.length - 1] = nextOutput;
|
|
384
|
-
if (!findings.some(({ state }) => state === "accepted")
|
|
385
|
-
|
|
385
|
+
if (!findings.some(({ state }) => state === "accepted") &&
|
|
386
|
+
!prevOutput.followUps?.length)
|
|
387
|
+
outputs.push(omitNullish({
|
|
388
|
+
resolves: prevOutput.resolves,
|
|
389
|
+
verdict: "APPROVED",
|
|
390
|
+
}));
|
|
386
391
|
return { ...reviewer, outputs };
|
|
387
392
|
}
|
|
388
393
|
async function notifyVerdictChanges(prev, next, reason) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-magi",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20261104100346",
|
|
4
4
|
"description": "Multi-agent PR review and merge orchestration plugin for OpenCode.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
|