pi-pr-review 1.10.3 → 1.10.4
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/lib/pr-review-publish.ts +16 -7
- package/package.json +1 -1
- package/prompts/pr-review.md +1 -1
- package/tests/pr-review-extension-lifecycle.test.ts +39 -1
- package/tests/pr-review-publish.test.ts +74 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.10.4](https://github.com/10ego/pi-pr-review/compare/v1.10.3...v1.10.4) (2026-07-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **publish:** summarize findings without diff patches ([#29](https://github.com/10ego/pi-pr-review/issues/29)) ([bdee1ff](https://github.com/10ego/pi-pr-review/commit/bdee1ff024863019a2f357b04cffe944006a5726))
|
|
9
|
+
|
|
3
10
|
## [1.10.3](https://github.com/10ego/pi-pr-review/compare/v1.10.2...v1.10.3) (2026-07-15)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -186,7 +186,7 @@ The extension—not the model—owns publishing. It creates one formal review wi
|
|
|
186
186
|
|
|
187
187
|
If the agent's final review is not valid exact-contract JSON, the extension logs the validation reason and automatically asks the same agent to correct its completed output once, with all tools disabled and without changing the captured posting authority. A valid correction is cached and publication is attempted under the original flags/config. If that single correction is also invalid or attempts to call a tool, publication stops and reports the error instead of looping. Overlapping input cancels the correction, remains unqueued, and must be retried after the agent settles.
|
|
188
188
|
|
|
189
|
-
Closed or merged PRs use a body-only review. Open PRs attach eligible P0–P3 findings as inline comments and keep nits or off-diff findings in the review body. When multiple findings target the same diff anchor, the first is attached inline and later findings remain in the review body so publication neither fails nor drops review content.
|
|
189
|
+
Closed or merged PRs use a body-only review. Open PRs attach eligible P0–P3 findings as inline comments and keep nits or off-diff findings in the review body. When GitHub omits patch metadata needed to validate an inline anchor, the affected finding remains in the review summary instead of blocking publication. When multiple findings target the same diff anchor, the first is attached inline and later findings remain in the review body so publication neither fails nor drops review content.
|
|
190
190
|
|
|
191
191
|
After a review completes, you can directly ask the agent to “post the inline review” or “post it as an inline review.” The extension handles that request directly before an agent turn, selecting the latest cached review for an unnumbered request or the named PR in “publish the review for PR #123.” Only fresh interactive/RPC input can trigger this path; extension-generated, queued, or steering input cannot. The extension publishes only validated cached content, never replacement model-authored text, and never starts or reruns review agents. A direct request permits stale publication.
|
|
192
192
|
|
package/lib/pr-review-publish.ts
CHANGED
|
@@ -837,6 +837,7 @@ function isInlineSeverity(finding: ReviewFindingLike): boolean {
|
|
|
837
837
|
export interface CommentValidationResult {
|
|
838
838
|
comments: PublishComment[];
|
|
839
839
|
errors: string[];
|
|
840
|
+
warnings?: string[];
|
|
840
841
|
}
|
|
841
842
|
|
|
842
843
|
export function validateInlineComments(
|
|
@@ -844,6 +845,7 @@ export function validateInlineComments(
|
|
|
844
845
|
changedFiles: ChangedFileLike[],
|
|
845
846
|
): CommentValidationResult {
|
|
846
847
|
const errors: string[] = [];
|
|
848
|
+
const warnings: string[] = [];
|
|
847
849
|
const comments: PublishComment[] = [];
|
|
848
850
|
const files = new Map<string, ChangedFileLike>();
|
|
849
851
|
for (const file of changedFiles) {
|
|
@@ -876,7 +878,9 @@ export function validateInlineComments(
|
|
|
876
878
|
continue;
|
|
877
879
|
}
|
|
878
880
|
if (!file.patch) {
|
|
879
|
-
|
|
881
|
+
// GitHub legitimately omits patch metadata for some large, binary, or transiently unavailable diffs.
|
|
882
|
+
// Keep the complete finding in the review summary rather than sending an unvalidated inline anchor.
|
|
883
|
+
warnings.push(`${label}: diff patch is unavailable; kept in the review summary`);
|
|
880
884
|
continue;
|
|
881
885
|
}
|
|
882
886
|
const sideKey = side === "LEFT" ? "left" : "right";
|
|
@@ -913,7 +917,7 @@ export function validateInlineComments(
|
|
|
913
917
|
if (comments.length > MAX_INLINE_COMMENTS) {
|
|
914
918
|
errors.push(`too many inline comments (${comments.length}; max ${MAX_INLINE_COMMENTS})`);
|
|
915
919
|
}
|
|
916
|
-
return { comments, errors };
|
|
920
|
+
return { comments, errors, warnings };
|
|
917
921
|
}
|
|
918
922
|
|
|
919
923
|
export function collectFoldedComments(review: ReviewLike): CommentValidationResult {
|
|
@@ -954,7 +958,7 @@ export function collectFoldedComments(review: ReviewLike): CommentValidationResu
|
|
|
954
958
|
...(Number(start) < Number(end) ? { start_line: Number(start), start_side: side } : {}),
|
|
955
959
|
});
|
|
956
960
|
}
|
|
957
|
-
return { comments, errors };
|
|
961
|
+
return { comments, errors, warnings: [] };
|
|
958
962
|
}
|
|
959
963
|
|
|
960
964
|
export function foldInlineComments(summary: string, comments: PublishComment[]): string {
|
|
@@ -1244,6 +1248,7 @@ export async function publishPullReview(input: {
|
|
|
1244
1248
|
if (!lifecycle.lifecycle) return { status: "failed", message: lifecycle.error ?? "invalid PR lifecycle" };
|
|
1245
1249
|
const isOpen = lifecycle.lifecycle === "open";
|
|
1246
1250
|
let comments: PublishComment[] = [];
|
|
1251
|
+
let inlineWarningCount = 0;
|
|
1247
1252
|
if (!isOpen) {
|
|
1248
1253
|
const candidates = collectFoldedComments(review);
|
|
1249
1254
|
if (candidates.errors.length > 0) {
|
|
@@ -1270,6 +1275,7 @@ export async function publishPullReview(input: {
|
|
|
1270
1275
|
return { status: "failed", message: `inline validation failed: ${validated.errors.join("; ")}` };
|
|
1271
1276
|
}
|
|
1272
1277
|
comments = validated.comments;
|
|
1278
|
+
inlineWarningCount = validated.warnings?.length ?? 0;
|
|
1273
1279
|
}
|
|
1274
1280
|
}
|
|
1275
1281
|
|
|
@@ -1316,6 +1322,10 @@ export async function publishPullReview(input: {
|
|
|
1316
1322
|
return { status: "failed", message: `final head check failed: ${String(error)}` };
|
|
1317
1323
|
}
|
|
1318
1324
|
|
|
1325
|
+
const inlineWarning = inlineWarningCount > 0
|
|
1326
|
+
? `; ${inlineWarningCount} inline finding${inlineWarningCount === 1 ? "" : "s"} kept in the summary because GitHub omitted diff patch metadata`
|
|
1327
|
+
: "";
|
|
1328
|
+
const degraded = !isOpen || headPlan.stale || inlineWarningCount > 0;
|
|
1319
1329
|
const post = await runGh(
|
|
1320
1330
|
githubApiArgs(hostname, "--method", "POST", `repos/${repository}/pulls/${prNumber}/reviews`, "--input", "-"),
|
|
1321
1331
|
cwd,
|
|
@@ -1328,13 +1338,12 @@ export async function publishPullReview(input: {
|
|
|
1328
1338
|
} catch {
|
|
1329
1339
|
/* accepted response without parseable metadata */
|
|
1330
1340
|
}
|
|
1331
|
-
const degraded = !isOpen || headPlan.stale;
|
|
1332
1341
|
return {
|
|
1333
1342
|
status: degraded ? "posted_degraded" : "posted",
|
|
1334
1343
|
message: headPlan.stale
|
|
1335
1344
|
? `body-only stale COMMENT review posted (${headPlan.reviewedHeadSha} -> ${headPlan.currentHeadSha})`
|
|
1336
1345
|
: isOpen
|
|
1337
|
-
?
|
|
1346
|
+
? `GitHub COMMENT review posted${inlineWarning}`
|
|
1338
1347
|
: "body-only COMMENT review posted for non-open PR",
|
|
1339
1348
|
reviewId: response.id,
|
|
1340
1349
|
url: response.html_url,
|
|
@@ -1344,8 +1353,8 @@ export async function publishPullReview(input: {
|
|
|
1344
1353
|
try {
|
|
1345
1354
|
if (await hasExistingMarker(cwd, hostname, repository, prNumber, identity, normalizedHeadSha)) {
|
|
1346
1355
|
return {
|
|
1347
|
-
status:
|
|
1348
|
-
message:
|
|
1356
|
+
status: degraded ? "posted_degraded" : "posted",
|
|
1357
|
+
message: `GitHub review found during failure reconciliation${inlineWarning}`,
|
|
1349
1358
|
reconciled: true,
|
|
1350
1359
|
};
|
|
1351
1360
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-pr-review",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.4",
|
|
4
4
|
"description": "Parallel AI code review for GitHub pull requests in the Pi coding agent, with model-agnostic tiered subagents, structured findings, optional verification, and safe COMMENT-only publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/prompts/pr-review.md
CHANGED
|
@@ -194,7 +194,7 @@ The orchestrator must never call `gh` to post comments or reviews. Always finish
|
|
|
194
194
|
- `--comment` → force publication for this run, but never bypass validation, stale-head checks, or duplicate checks
|
|
195
195
|
- `--no-comment` → suppress publication for this run
|
|
196
196
|
|
|
197
|
-
When enabled, the extension creates exactly one formal GitHub pull-request review. Its top-level body contains the overview, verification, strengths, suggested verdict, counts, nits, and findings that cannot be attached inline. Eligible P0–P3 diff-anchored findings are attached as inline comments within that same review and are omitted from the top-level issue list to avoid duplication. If multiple findings share one diff anchor, the first is attached inline and later findings remain in the top-level body instead of failing publication or dropping content. The API event is hardcoded to `COMMENT`: publication never sends `APPROVE` or `REQUEST_CHANGES`, even when the suggested verdict is `request_changes`. It appends the same-head marker, verifies the current head, validates every inline anchor against GitHub diff metadata, and refuses partial open-PR publication. For a known closed/merged PR it requires either trusted `--include-closed`/`--review-closed` invocation authority or the one-shot affirmative confirmation flow, then posts one body-only `COMMENT` review with each inline finding folded into the body exactly once. Unknown lifecycle states and unconfirmed non-open writes fail without posting or falling back to an issue comment.
|
|
197
|
+
When enabled, the extension creates exactly one formal GitHub pull-request review. Its top-level body contains the overview, verification, strengths, suggested verdict, counts, nits, and findings that cannot be attached inline. Eligible P0–P3 diff-anchored findings are attached as inline comments within that same review and are omitted from the top-level issue list to avoid duplication. If GitHub omits patch metadata needed to validate an anchor, that finding remains in the top-level body instead of blocking publication. If multiple findings share one diff anchor, the first is attached inline and later findings remain in the top-level body instead of failing publication or dropping content. The API event is hardcoded to `COMMENT`: publication never sends `APPROVE` or `REQUEST_CHANGES`, even when the suggested verdict is `request_changes`. It appends the same-head marker, verifies the current head, validates every attempted inline anchor against GitHub diff metadata, and refuses partial open-PR publication. For a known closed/merged PR it requires either trusted `--include-closed`/`--review-closed` invocation authority or the one-shot affirmative confirmation flow, then posts one body-only `COMMENT` review with each inline finding folded into the body exactly once. Unknown lifecycle states and unconfirmed non-open writes fail without posting or falling back to an issue comment.
|
|
198
198
|
|
|
199
199
|
The extension caches the latest valid completed review per repository and PR before publication preflight in the current Pi session. The session-backed cache survives extension reloads and session resumes but is bound to the originating session instance and repository. On a later turn, the extension intercepts that direct input before an agent turn, publishes only extension-cached content, permits stale publication, and cannot rerun review agents. Stale publication is also enabled by default through the invocation-captured `allowStalePublish` setting. Every stale review is body-only, displays a warning with the reviewed and preflight-observed commit hashes, and omits potentially invalid inline anchors. If the captured setting disabled stale publication, the user can still run `/pr-review-publish <PR-NUM> --allow-stale`. Never rerun the review merely to change posting intent, and never attempt a direct GitHub write yourself.
|
|
200
200
|
|
|
@@ -118,11 +118,12 @@ fi
|
|
|
118
118
|
return dir;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function installFakePublishingGh(currentHead = "a".repeat(40)): string {
|
|
121
|
+
function installFakePublishingGh(currentHead = "a".repeat(40), patchless = false): string {
|
|
122
122
|
const dir = mkdtempSync(join(tmpdir(), "pi-pr-review-publish-tool-"));
|
|
123
123
|
tempDirs.push(dir);
|
|
124
124
|
const gh = join(dir, "gh");
|
|
125
125
|
const payloadPath = join(dir, "payload.json");
|
|
126
|
+
const changedFiles = patchless ? '[[{"filename":"src/parser.ts","status":"modified"}]]' : "[[]]";
|
|
126
127
|
writeFileSync(
|
|
127
128
|
gh,
|
|
128
129
|
`#!/usr/bin/env bash
|
|
@@ -137,6 +138,8 @@ elif [[ "$args" == *"pulls/7/reviews?per_page=100"* || "$args" == *"issues/7/com
|
|
|
137
138
|
elif [[ "$args" == *"--method POST"* ]]; then
|
|
138
139
|
cat > '${payloadPath}'
|
|
139
140
|
echo '{"id":42,"html_url":"https://github.com/owner/repo/pull/7#pullrequestreview-42"}'
|
|
141
|
+
elif [[ "$args" == *"pulls/7/files?per_page=100"* ]]; then
|
|
142
|
+
echo '${changedFiles}'
|
|
140
143
|
elif [[ "$args" == *"repos/owner/repo/pulls/7"* ]]; then
|
|
141
144
|
printf '{"state":"open","draft":false,"merged_at":null,"head":{"sha":"%s"}}\n' '${currentHead}'
|
|
142
145
|
else
|
|
@@ -555,6 +558,41 @@ describe("completed review extension lifecycle", () => {
|
|
|
555
558
|
expect(payload.body).toContain(currentHead);
|
|
556
559
|
});
|
|
557
560
|
|
|
561
|
+
test("surfaces patchless inline fallback in the posted notification", async () => {
|
|
562
|
+
const patchlessReview: ReviewLike = {
|
|
563
|
+
...review,
|
|
564
|
+
findings: [
|
|
565
|
+
{
|
|
566
|
+
title: "[P2] Patchless finding",
|
|
567
|
+
severity: "P2",
|
|
568
|
+
blocking: false,
|
|
569
|
+
body: "This finding must remain visible in the summary.",
|
|
570
|
+
confidence_score: 0.9,
|
|
571
|
+
code_location: {
|
|
572
|
+
absolute_file_path: "src/parser.ts",
|
|
573
|
+
line_range: { start: 2, end: 2 },
|
|
574
|
+
side: "RIGHT",
|
|
575
|
+
commentable: true,
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
],
|
|
579
|
+
};
|
|
580
|
+
const cache = new CompletedReviewCache();
|
|
581
|
+
const record = cache.remember(patchlessReview, invocation, repository);
|
|
582
|
+
const persisted = cache.persist(record, session);
|
|
583
|
+
const cacheEntry = { type: "custom", id: "cache", customType: COMPLETED_REVIEW_ENTRY_TYPE, data: persisted };
|
|
584
|
+
const harness = createHarness([cacheEntry]);
|
|
585
|
+
await harness.emit("session_start", { reason: "reload" });
|
|
586
|
+
const payloadPath = installFakePublishingGh("a".repeat(40), true);
|
|
587
|
+
|
|
588
|
+
await harness.commands.get("pr-review-publish")!("7", harness.ctx);
|
|
589
|
+
|
|
590
|
+
expect(harness.notifications.some((message) => message.includes("1 inline finding kept in the summary"))).toBeTrue();
|
|
591
|
+
const payload = JSON.parse(readFileSync(payloadPath, "utf8"));
|
|
592
|
+
expect(payload.comments).toBeUndefined();
|
|
593
|
+
expect(payload.body).toContain("[P2] Patchless finding");
|
|
594
|
+
});
|
|
595
|
+
|
|
558
596
|
test("rejects extension-generated, queued, and steering publish requests", async () => {
|
|
559
597
|
const persisted = persistedInlineReview();
|
|
560
598
|
const cacheEntry = { type: "custom", id: "cache", customType: COMPLETED_REVIEW_ENTRY_TYPE, data: persisted };
|
|
@@ -536,6 +536,68 @@ fi
|
|
|
536
536
|
}
|
|
537
537
|
});
|
|
538
538
|
|
|
539
|
+
test("publishes a current review with patchless findings in the summary", async () => {
|
|
540
|
+
const dir = mkdtempSync(join(tmpdir(), "pi-pr-review-gh-"));
|
|
541
|
+
const gh = join(dir, "gh");
|
|
542
|
+
const payloadPath = join(dir, "payload.json");
|
|
543
|
+
writeFileSync(
|
|
544
|
+
gh,
|
|
545
|
+
`#!/usr/bin/env bash
|
|
546
|
+
set -euo pipefail
|
|
547
|
+
args="$*"
|
|
548
|
+
if [[ "$args" == "repo view --json nameWithOwner,url" ]]; then
|
|
549
|
+
echo '{"nameWithOwner":"owner/repo","url":"https://github.com/owner/repo"}'
|
|
550
|
+
elif [[ "$args" == *" user --jq .login"* ]]; then
|
|
551
|
+
echo 'reviewer'
|
|
552
|
+
elif [[ "$args" == *"--method POST"* ]]; then
|
|
553
|
+
cat > "$GH_FAKE_PAYLOAD"
|
|
554
|
+
echo '{"id":43,"html_url":"https://github.com/owner/repo/pull/7#pullrequestreview-43"}'
|
|
555
|
+
elif [[ "$args" == *"pulls/7/reviews?per_page=100"* || "$args" == *"issues/7/comments?per_page=100"* ]]; then
|
|
556
|
+
echo '[]'
|
|
557
|
+
elif [[ "$args" == *"pulls/7/files?per_page=100"* ]]; then
|
|
558
|
+
echo '[[{"filename":"src/parser.ts","status":"modified"}]]'
|
|
559
|
+
elif [[ "$args" == *"repos/owner/repo/pulls/7"* ]]; then
|
|
560
|
+
printf '{"state":"open","draft":false,"merged_at":null,"head":{"sha":"%s"}}\n' "$GH_FAKE_CURRENT"
|
|
561
|
+
else
|
|
562
|
+
echo "unexpected gh args: $args" >&2
|
|
563
|
+
exit 1
|
|
564
|
+
fi
|
|
565
|
+
`,
|
|
566
|
+
);
|
|
567
|
+
chmodSync(gh, 0o755);
|
|
568
|
+
const previousPath = process.env.PATH;
|
|
569
|
+
const previousPayload = process.env.GH_FAKE_PAYLOAD;
|
|
570
|
+
const previousCurrent = process.env.GH_FAKE_CURRENT;
|
|
571
|
+
const current = "a".repeat(40);
|
|
572
|
+
process.env.PATH = `${dir}:${previousPath ?? ""}`;
|
|
573
|
+
process.env.GH_FAKE_PAYLOAD = payloadPath;
|
|
574
|
+
process.env.GH_FAKE_CURRENT = current;
|
|
575
|
+
try {
|
|
576
|
+
const posted = await publishPullReview({
|
|
577
|
+
cwd: dir,
|
|
578
|
+
prNumber: 7,
|
|
579
|
+
headSha: current,
|
|
580
|
+
allowNonOpen: false,
|
|
581
|
+
expectedRepository: { hostname: "github.com", repository: "owner/repo" },
|
|
582
|
+
review,
|
|
583
|
+
});
|
|
584
|
+
expect(posted.status).toBe("posted_degraded");
|
|
585
|
+
expect(posted.message).toContain("1 inline finding kept in the summary");
|
|
586
|
+
const payload = JSON.parse(readFileSync(payloadPath, "utf8"));
|
|
587
|
+
expect(payload.comments).toBeUndefined();
|
|
588
|
+
expect(payload.body).toContain("[P2] Handle empty input");
|
|
589
|
+
expect(payload.body).toContain("Empty input currently returns the wrong value.");
|
|
590
|
+
} finally {
|
|
591
|
+
if (previousPath === undefined) delete process.env.PATH;
|
|
592
|
+
else process.env.PATH = previousPath;
|
|
593
|
+
if (previousPayload === undefined) delete process.env.GH_FAKE_PAYLOAD;
|
|
594
|
+
else process.env.GH_FAKE_PAYLOAD = previousPayload;
|
|
595
|
+
if (previousCurrent === undefined) delete process.env.GH_FAKE_CURRENT;
|
|
596
|
+
else process.env.GH_FAKE_CURRENT = previousCurrent;
|
|
597
|
+
rmSync(dir, { recursive: true, force: true });
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
539
601
|
test("preserves inline publication when the reviewed head is still current", () => {
|
|
540
602
|
const head = "a".repeat(40);
|
|
541
603
|
expect(planHeadPublication(head, head.toUpperCase(), false).plan).toMatchObject({
|
|
@@ -685,6 +747,18 @@ describe("atomic COMMENT review payload", () => {
|
|
|
685
747
|
expect(result.errors[0]).toContain("not inside one diff hunk");
|
|
686
748
|
});
|
|
687
749
|
|
|
750
|
+
test("keeps findings in the summary when GitHub omits patch metadata", () => {
|
|
751
|
+
const result = validateInlineComments(review, [{ filename: "src/parser.ts" }]);
|
|
752
|
+
expect(result.errors).toEqual([]);
|
|
753
|
+
expect(result.comments).toEqual([]);
|
|
754
|
+
expect(result.warnings).toEqual([
|
|
755
|
+
"finding 1: diff patch is unavailable; kept in the review summary",
|
|
756
|
+
]);
|
|
757
|
+
const summary = buildReviewSummary(review, result.comments);
|
|
758
|
+
expect(summary).toContain("2 total (0 inline, 2 summary-only)");
|
|
759
|
+
expect(summary).toContain("[P2] Handle empty input");
|
|
760
|
+
});
|
|
761
|
+
|
|
688
762
|
test("folds inline findings exactly once into a body-only non-open review", () => {
|
|
689
763
|
const folded = collectFoldedComments(review);
|
|
690
764
|
expect(folded.errors).toEqual([]);
|