improve pr approach

This commit is contained in:
David Blass
2025-10-30 14:16:44 -04:00
parent 05fb2065b2
commit b2badf6d16
3 changed files with 36 additions and 13 deletions
+2
View File
@@ -5,4 +5,6 @@ export const instructions = `- use the ${mcpServerName} MCP server to interact w
- do not under any circumstances use the gh cli
- if prompted by a comment to respond to create a new issue, pr or anything else, after succeeding,
also respond to the original comment with a very brief message containing a link to it
- if prompted for to review a pr, use the diff_hint returned by mcp__${mcpServerName}__get_pull_request to get the diff
and analyze the diff to determine the review type and body
`;
+1 -1
View File
@@ -1 +1 @@
add a github review for the following PR: https://github.com/pullfrogai/scratch/pull/14
add a github review for the following PR: https://github.com/pullfrogai/scratch/pull/16
+33 -12
View File
@@ -7,7 +7,7 @@ export const PullRequestInfo = type({
export const PullRequestInfoTool = tool({
name: "get_pull_request",
description: "Retrieve detailed information and diff for a specific pull request by number.",
description: "Retrieve detailed information for a specific pull request by number, with a suggested local diff command.",
parameters: PullRequestInfo,
execute: contextualize(async ({ pull_number }, ctx) => {
const pr = await ctx.octokit.rest.pulls.get({
@@ -16,19 +16,40 @@ export const PullRequestInfoTool = tool({
pull_number,
});
// Fetch diff using raw request
const diff = await ctx.octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
owner: ctx.owner,
repo: ctx.name,
pull_number,
headers: {
Accept: 'application/vnd.github.v3.diff',
},
});
const data = pr.data;
const baseBranch = data.base?.ref;
const headBranch = data.head?.ref;
const headSha = data.head?.sha;
// Suggest a local diff command similar to claude-code-action
// Consumers can run this in a repo checkout to view the diff without API diff access
const diff_hint = baseBranch
? `git fetch origin ${baseBranch} --depth=20 && git diff origin/${baseBranch}...${headSha || "HEAD"}`
: undefined;
return {
...pr.data,
diff: diff.data,
number: data.number,
url: data.html_url,
title: data.title,
state: data.state,
draft: data.draft,
merged: data.merged,
mergeable: data.mergeable,
user: data.user?.login,
created_at: data.created_at,
updated_at: data.updated_at,
head: headBranch,
head_sha: headSha,
base: baseBranch,
base_sha: data.base?.sha,
additions: data.additions,
deletions: data.deletions,
changed_files: data.changed_files,
labels: (data.labels || []).map((l) => (typeof l === "string" ? l : l.name)).filter(Boolean),
requested_reviewers: (data.requested_reviewers || []).map((u) => u.login),
requested_teams: (data.requested_teams || []).map((t) => t.slug),
diff_hint,
};
}),
});