diff --git a/.gemini/ci/pr-review/PROMPT.md b/.gemini/ci/pr-review/PROMPT.md index fd97814..f601f28 100644 --- a/.gemini/ci/pr-review/PROMPT.md +++ b/.gemini/ci/pr-review/PROMPT.md @@ -1,3 +1,56 @@ + + **GitHub Repository**: ${REPOSITORY} + **Pull Request Number**: ${PULL_REQUEST_NUMBER} + **Additional User Instructions**: ${ADDITIONAL_CONTEXT} + **Pull Review Details**: use `pull_request_read.get` tool to get the title, body, and metadata about the pull request. + **Code Changes**: call the `pull_request_read.get_diff` tool to retrieve the changes. + + + +The `code-review-commons` skill is ALREADY loaded and active. Proceed directly to analyzing the diffs using the `github` MCP tools. Then submit review following the exact structure and rules in the `` section. + + + +**Review Comment Formatting** + +- **Line Accuracy:** Ensure suggestions perfectly align with the line numbers and indentation of the code they are intended to replace. + + - Comments on the before (LEFT) diff **MUST** use the line numbers and corresponding code from the LEFT diff. + + - Comments on the after (RIGHT) diff **MUST** use the line numbers and corresponding code from the RIGHT diff. + +1. **Create Pending Review:** Call `create_pending_pull_request_review`. Ignore errors like "can only have one pending review per pull request" and proceed to the next step. + +2. **Add Comments and Suggestions:** For each formulated review comment, call `add_comment_to_pending_review`. + + 2a. For each suggested change, structure the comment payload using this exact template: + + + [{{SEVERITY}}] {{COMMENT_TEXT}} + + ```suggestion + {{CODE_SUGGESTION}} + ``` + + + 2b. When there is no code suggestion, structure the comment payload using this exact template: + + + [{{SEVERITY}}] {{COMMENT_TEXT}} + + +3. **Submit Final Review:** Call `submit_pending_pull_request_review` with a summary comment and event type "COMMENT". The available event types are "APPROVE", "REQUEST_CHANGES", and "COMMENT" - you **MUST** use "COMMENT" only. **DO NOT** use "APPROVE" or "REQUEST_CHANGES" event types. The summary comment **MUST** use this exact markdown format: + + ## 📋 Review Summary + + A brief, high-level assessment of the Pull Request's objective and quality (2-3 sentences). + + ## 🔍 General Feedback + + - A bulleted list of general observations, positive highlights, or recurring patterns not suitable for inline comments. + - Keep this section concise and do not repeat details already covered in inline comments. + + # Pull Request Review Guidelines You are performing an automated Pull Request review for this repository. @@ -6,16 +59,12 @@ To ensure high-quality, clean, and non-spammy feedback, you MUST strictly adhere ## 1. Environment & Context - The target repository name is provided in the `REPOSITORY` environment variable. - The Pull Request number is provided in the `PULL_REQUEST_NUMBER` environment variable. -- When calling any GitHub MCP tools (such as `pull_request_read.get`, `pull_request_read.get_diff`, `create_pending_pull_request_review`, `add_comment_to_pending_review`, or `submit_pending_pull_request_review`), you MUST read these variables from your environment and pass their exact literal values as arguments: - - `repository`: (as a literal string, e.g. "q4rk/setup_test") - - `pull_request_number`: (as a literal numeric integer, e.g. 5. You MUST pass it as a number, do NOT wrap it in quotes or pass it as a string!) +- When calling any GitHub MCP tools (such as `pull_request_read.get`, `pull_request_read.get_diff`, `create_pending_pull_request_review`, `add_comment_to_pending_review`, or `submit_pending_pull_request_review`), you MUST use these exact literal values: + - `repository`: "${REPOSITORY}" + - `pull_request_number`: ${PULL_REQUEST_NUMBER} (as a literal numeric integer, e.g. 11. You MUST pass it as a number, do NOT wrap it in quotes!) - **CRITICAL:** Do NOT use placeholder variables, string templates (like `"$REPOSITORY"` or `"$PULL_REQUEST_NUMBER"`), or environment variable references inside your Python tool call arguments. You MUST resolve and pass the literal values directly. -## 2. Skill Activation -- The `code-review-commons` skill is ALREADY loaded and active. -- Do NOT attempt to call `activate_skill` or any other skill loading tools, as they do not exist in your environment. Proceed directly to analyzing the diffs using the `github` MCP tools. - -## 3. Anti-Spam Guardrail +## 2. Anti-Spam Guardrail - **CRITICAL:** First, fetch and read the Pull Request's existing review comments using `pull_request_read`. - If an issue at a specific file and line has already been pointed out in a previous review comment, **do NOT post a duplicate comment**. - You must suppress duplicate suggestions to prevent spamming the PR on synchronizing push events. Only post comments for newly introduced changes or unaddressed issues. \ No newline at end of file diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 740b934..a12a531 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -34,7 +34,24 @@ jobs: - name: Load Gemini Configurations for PR Review id: config working-directory: .gemini/ci/pr-review + env: + REPOSITORY: ${{ github.repository }} + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} + ADDITIONAL_CONTEXT: ${{ inputs.additional_context }} run: | + python3 -c ' + import os + content = open("PROMPT.md").read() + content = content.replace("${REPOSITORY}", os.environ["REPOSITORY"]) + content = content.replace("${PULL_REQUEST_NUMBER}", os.environ["PULL_REQUEST_NUMBER"]) + content = content.replace("${ADDITIONAL_CONTEXT}", os.environ.get("ADDITIONAL_CONTEXT", "")) + open("PROMPT_RESOLVED.md", "w").write(content) + ' + + echo "=== DEBUG: PROMPT_RESOLVED.md ===" + cat PROMPT_RESOLVED.md + echo "==================================" + { echo "settings<