From 6a06ab56f6e3bc342cffbcedcd664239d016edd3 Mon Sep 17 00:00:00 2001 From: q4rk Date: Mon, 18 May 2026 23:16:00 +0000 Subject: [PATCH 1/3] Add poorly written code for testing --- poorly_written_code.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 poorly_written_code.py diff --git a/poorly_written_code.py b/poorly_written_code.py new file mode 100644 index 0000000..eb701ea --- /dev/null +++ b/poorly_written_code.py @@ -0,0 +1,23 @@ +import os +import sys + +def process(data): + r = [] + for i in range(len(data)): + for j in range(len(data)): + if i == j: + continue + if data[i] == data[j]: + if data[i] not in r: + r.append(data[i]) + + total = 0 + for x in r: + total += x + + average = total / len(r) + + return average, r + +print(process([1, 2, 3, 4, 5])) +print(process([1, 2, 2, 3, 4, 4, 5])) From 5b4603c4c695a7d0ed1765609b25423acdc08c39 Mon Sep 17 00:00:00 2001 From: q4rk Date: Mon, 18 May 2026 23:19:41 +0000 Subject: [PATCH 2/3] Fix PR number resolution in review workflow by bypassing broken extension command and passing resolved prompt --- .gemini/ci/pr-review/PROMPT.md | 65 +++++++++++++++++++++++++---- .github/workflows/gemini-review.yml | 17 ++++++-- 2 files changed, 71 insertions(+), 11 deletions(-) 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..2cd9437 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -34,7 +34,20 @@ 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 "settings< Date: Mon, 18 May 2026 23:21:55 +0000 Subject: [PATCH 3/3] Add debug print to workflow --- .github/workflows/gemini-review.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 2cd9437..a12a531 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -48,6 +48,10 @@ jobs: open("PROMPT_RESOLVED.md", "w").write(content) ' + echo "=== DEBUG: PROMPT_RESOLVED.md ===" + cat PROMPT_RESOLVED.md + echo "==================================" + { echo "settings<