Skip to content

[FEAT] add gh_pr_review tool to fetch PR review comments #12

Description

@four-bytes-robby

Goal

Add a new tool gh_pr_review that fetches and displays review comments on a GitHub pull request, including approval state and review bodies. Mirrors the existing gh_pr_status / gh_pr_comment patterns.

Background

Currently the supertools plugin can add a PR comment (gh_pr_comment) and check PR status (gh_pr_status), but cannot fetch existing review comments. Code-reviewer subagents and humans need to inspect bot findings (e.g. copilot, codereviewer) without scraping gh pr view via bash — saves ~90% tokens.

Acceptance Criteria

  • New file src/tools/gh-pr-review.ts exports ghPrReviewTool
  • Tool signature: { pr: number, repo?: string }
  • Returns formatted output with: issue-level comments (with author, body, timestamp) + reviews (with author, state, body)
  • Filters out empty review bodies (approvals with no comment)
  • Truncates long bodies (500 chars for reviews, 300 for comments)
  • Handles empty case: "No review comments on PR #N."
  • Logs start/success/error via logDebugEvent
  • Registered in src/four-opencode-supertools.ts as gh_pr_review
  • Build passes: bun run build
  • Repo has no other side-effects

Implementation Notes

  • Use gh pr view <N> --json comments,reviews — confirmed both fields exist in CLI
  • Note: comments field contains issue-level (timeline) comments only; path/line are NOT present (those are inline review comments, separate GraphQL query — out of scope for v1)
  • Follow existing pattern from gh-pr-comment.ts: runGh + resolveRepo from ../lib/gh-utils
  • Use positional resolveRepo(repo, ctx.directory) — matches the existing call signature in gh-pr-comment.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions