c0fd69560f
* Add "Fix it" link for body-only PR reviews When a PR review has only body-level feedback (no inline comments), the footer now includes a "Fix it" link that triggers the fix flow. Also fetches the review body in the fix action's prompt so the agent can address body-level feedback even when there are no inline comments. * Move review body fetching into `get_review_comments` tool Instead of fetching the review body in the trigger page and appending it to the prompt, the `get_review_comments` MCP tool now fetches the review body via the GitHub API and includes it in its markdown output under a "Review Body" section. This keeps the trigger page simple and lets the tool provide all review context in one place. * fetch body early * get reviewer from a better place * cleanup structure to reuse more in test * simplify * simplify * typecheck * fetch review body via REST API; skip listFiles for body-only reviews * update snapshot * formatting * cleanup * fix line counting with `countNewlines` utility using `indexOf` loop * rename `countNewlines` to `countLines` with 1-based line counting * suppress biome lint warning for assignment in while condition * remove unused `body` field from GraphQL review query and type * add `approved` parameter to `create_pull_request_review` and skip fix links for approvals * vibe instructions * tighten up prompting --------- Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com> Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { Octokit } from "@octokit/rest";
|
|
import { describe, expect, it } from "vitest";
|
|
import { acquireNewToken } from "../utils/github.ts";
|
|
import { getReviewData } from "./reviewComments.ts";
|
|
|
|
async function getToken(): Promise<string> {
|
|
if (process.env.GH_TOKEN) return process.env.GH_TOKEN;
|
|
return await acquireNewToken();
|
|
}
|
|
|
|
describe("getFormattedReviewThreads", () => {
|
|
it("formats thread blocks with TOC and correct line numbers", { timeout: 30000 }, async () => {
|
|
const token = await getToken();
|
|
const octokit = new Octokit({ auth: token });
|
|
|
|
const { formatted } = (await getReviewData({
|
|
octokit,
|
|
owner: "pullfrog",
|
|
name: "scratch",
|
|
pullNumber: 49,
|
|
reviewId: 3485940013,
|
|
}))!;
|
|
|
|
expect(formatted.toc).toMatchSnapshot("toc");
|
|
expect(formatted.content).toMatchSnapshot("content");
|
|
});
|
|
|
|
it("formats body-only review", { timeout: 30000 }, async () => {
|
|
const token = await getToken();
|
|
const octokit = new Octokit({ auth: token });
|
|
|
|
const { formatted } = (await getReviewData({
|
|
octokit,
|
|
owner: "pullfrog",
|
|
name: "scratch",
|
|
pullNumber: 64,
|
|
reviewId: 3531000326,
|
|
}))!;
|
|
|
|
expect(formatted.toc).toMatchSnapshot("toc");
|
|
expect(formatted.content).toMatchSnapshot("content");
|
|
});
|
|
});
|