pr-review → review にリネームし、gather が入力テキストからモードを自動判定する。 ブランチ名の判定を git branch -a で確認する方式に強化、直近Nコミット指定に対応、 output contract にコミット履歴セクションを追加。
2.1 KiB
2.1 KiB
Gather information about the review target and produce a report for reviewers to reference.
Auto-detect review mode
Analyze the task text and determine which mode to use.
Mode 1: PR mode
Trigger: Task contains PR references like #42, PR #42, pull/42, or a URL with /pull/
Steps:
- Extract the PR number
- Run
gh pr view {number}to get title, description, labels - Run
gh pr diff {number}to get the diff - Compile the changed files list
- Extract purpose and requirements from the PR description
- If linked Issues exist, retrieve them with
gh issue view {number}- Extract Issue numbers from "Closes #N", "Fixes #N", "Resolves #N"
- Collect Issue title, description, labels, and comments
Mode 2: Branch mode
Trigger: Task text matches a branch name found in git branch -a. This includes names with / (e.g., feature/auth) as well as simple names (e.g., develop, release-v2, hotfix-login). When unsure, verify with git branch -a | grep {text}.
Steps:
- Determine the base branch (default:
main, fallback:master) - Run
git log {base}..{branch} --onelineto get commit history - Run
git diff {base}...{branch}to get the diff - Compile the changed files list
- Extract purpose from commit messages
- If a PR exists for the branch, fetch it with
gh pr list --head {branch}
Mode 3: Current diff mode
Trigger: Task does not match Mode 1 or Mode 2 (e.g., "review current changes", "last 3 commits", "current diff") Steps:
- If the task specifies a count (e.g., "last N commits"), extract N. Otherwise default to N=1
- Run
git difffor unstaged changes andgit diff --stagedfor staged changes - If both are empty, run
git diff HEAD~{N}to get the diff for the last N commits - Run
git log --oneline -{N+10}for commit context - Compile the changed files list
- Extract purpose from recent commit messages
Report requirements
- Regardless of mode, the output report must follow the same format
- Fill in what is available; mark unavailable sections as "N/A"
- Always include: review target overview, purpose, changed files, and the diff