Make review tool more robust

This commit is contained in:
Colin McDonnell
2026-01-19 17:32:08 +00:00
committed by pullfrog[bot]
parent 485c76457f
commit e1b017f6e2
2 changed files with 22 additions and 24 deletions
+10 -11
View File
@@ -119110,18 +119110,18 @@ var CreatePullRequestReview = type({
comments: type({ comments: type({
path: type.string.describe("The file path to comment on (relative to repo root)"), path: type.string.describe("The file path to comment on (relative to repo root)"),
line: type.number.describe( line: type.number.describe(
"End line of the comment range (or the only line if no start_line). From diff format 'OLD | NEW | TYPE | CODE', use the NEW column." "End line of the comment range. For single-line comments, set equal to 'start_line'. Use NEW column from diff format."
), ),
side: type.enumerated("LEFT", "RIGHT").describe( side: type.enumerated("LEFT", "RIGHT").describe(
"Side of the diff: LEFT (old code, lines starting with -) or RIGHT (new code, lines starting with + or unchanged). Defaults to RIGHT." "Side of the diff: LEFT (old code, lines starting with -) or RIGHT (new code, lines starting with + or unchanged). Defaults to RIGHT."
).optional(), ).optional(),
body: type.string.describe("Explanatory comment text (optional if suggestion is provided)").optional(), body: type.string.describe("Explanatory comment text (optional if suggestion is provided)").optional(),
suggestion: type.string.describe( suggestion: type.string.describe(
"Full replacement code for the line range. Replaces the commented lines entirely - can be more, fewer, or same number of lines." "Full replacement code for the line range [start_line, line]. MUST preserve the exact indentation of the original code."
).optional(), ).optional(),
start_line: type.number.describe( start_line: type.number.describe(
"Start line for multi-line comments/suggestions. The range [start_line, line] defines which lines get replaced." "Start line of the comment range. For single-line comments, set equal to 'line'. The range [start_line, line] defines which lines a suggestion replaces."
).optional() )
}).array().describe( }).array().describe(
"Inline comments on lines within diff hunks. Feedback about code outside the diff goes in 'body' instead." "Inline comments on lines within diff hunks. Feedback about code outside the diff goes in 'body' instead."
).optional() ).optional()
@@ -119129,7 +119129,7 @@ var CreatePullRequestReview = type({
function CreatePullRequestReviewTool(ctx) { function CreatePullRequestReviewTool(ctx) {
return tool({ return tool({
name: "create_pull_request_review", name: "create_pull_request_review",
description: "Submit a review for an existing pull request. IMPORTANT: 95%+ of feedback should be in 'comments' array with file paths and line numbers. Only use 'body' for a 1-2 sentence summary with urgency and critical callouts. Use 'suggestion' field to suggest a FULL REPLACEMENT of the associated line range. This will show up for users as a one-click apply suggestion. It doesn't need to be the same length as the original range, but the suggested code must work when applied.", description: `Submit a review for an existing pull request. IMPORTANT: 95%+ of feedback should be in 'comments' array with file paths and line numbers. Only use 'body' for a 1-2 sentence summary with urgency and critical callouts. Use 'suggestion' to propose replacement code - MUST preserve exact indentation of original code. Example replacing lines 42-44 (3 lines) with 5 lines: { path: 'src/api.ts', start_line: 42, line: 44, suggestion: ' const result = await fetch(url);\\n if (!result.ok) {\\n log.error(result.status);\\n throw new Error("request failed");\\n }' }`,
parameters: CreatePullRequestReview, parameters: CreatePullRequestReview,
execute: execute(async ({ pull_number, body, commit_id, comments = [] }) => { execute: execute(async ({ pull_number, body, commit_id, comments = [] }) => {
ctx.toolState.prNumber = pull_number; ctx.toolState.prNumber = pull_number;
@@ -119157,16 +119157,15 @@ function CreatePullRequestReviewTool(ctx) {
const suggestionBlock = "```suggestion\n" + comment.suggestion + "\n```"; const suggestionBlock = "```suggestion\n" + comment.suggestion + "\n```";
commentBody = commentBody ? commentBody + "\n\n" + suggestionBlock : suggestionBlock; commentBody = commentBody ? commentBody + "\n\n" + suggestionBlock : suggestionBlock;
} }
const side = comment.side || "RIGHT";
const reviewComment = { const reviewComment = {
path: comment.path, path: comment.path,
line: comment.line, line: comment.line,
body: commentBody body: commentBody,
side,
start_line: comment.start_line,
start_side: side
}; };
reviewComment.side = comment.side || "RIGHT";
if (comment.start_line) {
reviewComment.start_line = comment.start_line;
reviewComment.start_side = comment.side || "RIGHT";
}
return reviewComment; return reviewComment;
}); });
} }
+12 -13
View File
@@ -20,7 +20,7 @@ export const CreatePullRequestReview = type({
comments: type({ comments: type({
path: type.string.describe("The file path to comment on (relative to repo root)"), path: type.string.describe("The file path to comment on (relative to repo root)"),
line: type.number.describe( line: type.number.describe(
"End line of the comment range (or the only line if no start_line). From diff format 'OLD | NEW | TYPE | CODE', use the NEW column." "End line of the comment range. For single-line comments, set equal to 'start_line'. Use NEW column from diff format."
), ),
side: type side: type
.enumerated("LEFT", "RIGHT") .enumerated("LEFT", "RIGHT")
@@ -33,14 +33,12 @@ export const CreatePullRequestReview = type({
.optional(), .optional(),
suggestion: type.string suggestion: type.string
.describe( .describe(
"Full replacement code for the line range. Replaces the commented lines entirely - can be more, fewer, or same number of lines." "Full replacement code for the line range [start_line, line]. MUST preserve the exact indentation of the original code."
)
.optional(),
start_line: type.number
.describe(
"Start line for multi-line comments/suggestions. The range [start_line, line] defines which lines get replaced."
) )
.optional(), .optional(),
start_line: type.number.describe(
"Start line of the comment range. For single-line comments, set equal to 'line'. The range [start_line, line] defines which lines a suggestion replaces."
),
}) })
.array() .array()
.describe( .describe(
@@ -56,7 +54,9 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
"Submit a review for an existing pull request. " + "Submit a review for an existing pull request. " +
"IMPORTANT: 95%+ of feedback should be in 'comments' array with file paths and line numbers. " + "IMPORTANT: 95%+ of feedback should be in 'comments' array with file paths and line numbers. " +
"Only use 'body' for a 1-2 sentence summary with urgency and critical callouts. " + "Only use 'body' for a 1-2 sentence summary with urgency and critical callouts. " +
"Use 'suggestion' field to suggest a FULL REPLACEMENT of the associated line range. This will show up for users as a one-click apply suggestion. It doesn't need to be the same length as the original range, but the suggested code must work when applied.", "Use 'suggestion' to propose replacement code - MUST preserve exact indentation of original code. " +
"Example replacing lines 42-44 (3 lines) with 5 lines: " +
`{ path: 'src/api.ts', start_line: 42, line: 44, suggestion: ' const result = await fetch(url);\\n if (!result.ok) {\\n log.error(result.status);\\n throw new Error("request failed");\\n }' }`,
parameters: CreatePullRequestReview, parameters: CreatePullRequestReview,
execute: execute(async ({ pull_number, body, commit_id, comments = [] }) => { execute: execute(async ({ pull_number, body, commit_id, comments = [] }) => {
// set PR context // set PR context
@@ -92,16 +92,15 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
commentBody = commentBody ? commentBody + "\n\n" + suggestionBlock : suggestionBlock; commentBody = commentBody ? commentBody + "\n\n" + suggestionBlock : suggestionBlock;
} }
const side = comment.side || "RIGHT";
const reviewComment: ReviewComment = { const reviewComment: ReviewComment = {
path: comment.path, path: comment.path,
line: comment.line, line: comment.line,
body: commentBody, body: commentBody,
side,
start_line: comment.start_line,
start_side: side,
}; };
reviewComment.side = comment.side || "RIGHT";
if (comment.start_line) {
reviewComment.start_line = comment.start_line;
reviewComment.start_side = comment.side || "RIGHT";
}
return reviewComment; return reviewComment;
}); });
} }