diff --git a/.gemini/ci/pr-review/PROMPT.md b/.gemini/ci/pr-review/PROMPT.md deleted file mode 100644 index f601f28..0000000 --- a/.gemini/ci/pr-review/PROMPT.md +++ /dev/null @@ -1,70 +0,0 @@ - - **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. -To ensure high-quality, clean, and non-spammy feedback, you MUST strictly adhere to the following rules: - -## 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 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. 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/.gemini/commands/pr-code-review.toml.template b/.gemini/commands/pr-code-review.toml.template new file mode 100644 index 0000000..3a3d39f --- /dev/null +++ b/.gemini/commands/pr-code-review.toml.template @@ -0,0 +1,32 @@ +description = "Reviews the code changes in your pull request" +prompt = """ + + **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. + + +# Pull Request Review Guidelines + +You are performing an automated Pull Request review for this repository. +To ensure high-quality, clean, and non-spammy feedback, you MUST strictly adhere to the following rules: + +## 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 use these exact literal values: + - `repository`: "${REPOSITORY}" + - `pull_request_number`: ${PULL_REQUEST_NUMBER} (as a literal numeric integer. 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. 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. +""" diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index a12a531..9258d98 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -41,15 +41,15 @@ jobs: run: | python3 -c ' import os - content = open("PROMPT.md").read() + content = open("../../commands/pr-code-review.toml.template").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) + open("../../commands/pr-code-review.toml", "w").write(content) ' - echo "=== DEBUG: PROMPT_RESOLVED.md ===" - cat PROMPT_RESOLVED.md + echo "=== DEBUG: pr-code-review.toml ===" + cat ../../commands/pr-code-review.toml echo "==================================" { @@ -59,8 +59,7 @@ jobs: echo "EOF" echo "prompt<