diff --git a/agents/shared.ts b/agents/shared.ts index 7769a90..d813ec5 100644 --- a/agents/shared.ts +++ b/agents/shared.ts @@ -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 `; diff --git a/fixtures/basic.txt b/fixtures/basic.txt index 5364edc..a023012 100644 --- a/fixtures/basic.txt +++ b/fixtures/basic.txt @@ -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 diff --git a/mcp/prInfo.ts b/mcp/prInfo.ts index 7c94128..63c3607 100644 --- a/mcp/prInfo.ts +++ b/mcp/prInfo.ts @@ -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, }; }), });