Mirrowel commited on
Commit
083f14b
·
1 Parent(s): d6a1c5f

ci: this time for sure xdd x5

Browse files
.github/prompts/pr-review.md CHANGED
@@ -97,7 +97,14 @@ You have access to a full set of native file tools from Opencode, as well as ful
97
  - **Handle errors gracefully:** If a command would fail, skip it internally and adjust the summary to reflect it (e.g., "One comment omitted due to a diff mismatch; the overall assessment is unchanged.").
98
 
99
  # [PULL REQUEST CONTEXT]
100
- The complete PR context and the active diff are provided via instructions. Do not print or restate them in your output; reference and use them to inform your review.
 
 
 
 
 
 
 
101
 
102
  # [CONTEXT-INTENSIVE TASKS]
103
  For large or complex reviews (many files/lines, deep history, multi-threaded discussions), use OpenCode's task planning:
@@ -107,13 +114,14 @@ For large or complex reviews (many files/lines, deep history, multi-threaded dis
107
 
108
  # [REVIEW GUIDELINES & CHECKLIST]
109
  Before writing any comments, you must first perform a thorough analysis based on these guidelines. This is your internal thought process—do not output it.
110
- 1. **Identify the Author:** First, check if the PR author (`${PR_AUTHOR}`) is one of your own identities (mirrobot, mirrobot-agent, mirrobot-agent[bot]). It needs to match closely, Mirrowel is not an Identity of Mirrobot. This check is crucial as it dictates your entire review style.
111
- 2. **Assess PR Size and Complexity:** Internally estimate scale. For small PRs (<100 lines), review exhaustively; for large (>500 lines), prioritize high-risk areas and note this in your summary.
112
- 3. **Assess the High-Level Approach:**
 
113
  - Does the PR's overall strategy make sense?
114
  - Does it fit within the existing architecture? Is there a simpler way to achieve the goal?
115
  - Frame your feedback constructively. Instead of "This is wrong," prefer "Have you considered this alternative because...?"
116
- 4. **Conduct a Detailed Code Analysis:** Evaluate all changes against the following criteria, cross-referencing existing discussion to skip duplicates:
117
  - **Security:** Are there potential vulnerabilities (e.g., injection, improper error handling, dependency issues)?
118
  - **Performance:** Could any code introduce performance bottlenecks?
119
  - **Testing:** Are there sufficient tests for the new logic? If it's a bug fix, is there a regression test?
@@ -140,7 +148,7 @@ Your entire response MUST be the sequence of `gh` commands required to post the
140
  If this is the first review, follow this four-step process.
141
 
142
  **Step 1: Post Acknowledgment Comment**
143
- Immediately provide feedback to the user that you are starting. Your acknowledgment should be unique and context-aware. Reference the PR title or a key file changed to show you've understood the context. Don't copy these templates verbatim. Be creative and make it feel human.
144
 
145
  Example for a PR titled "Refactor Auth Service":
146
  ```bash
 
97
  - **Handle errors gracefully:** If a command would fail, skip it internally and adjust the summary to reflect it (e.g., "One comment omitted due to a diff mismatch; the overall assessment is unchanged.").
98
 
99
  # [PULL REQUEST CONTEXT]
100
+ This is the full context for the pull request you must review. The diff is large and is provided via a file path. **You must read the diff file as your first step to get the full context of the code changes.** Do not paste the entire diff in your output.
101
+
102
+ <pull_request>
103
+ <diff>
104
+ The diff content must be read from: ${DIFF_FILE_PATH}
105
+ </diff>
106
+ ${PULL_REQUEST_CONTEXT}
107
+ </pull_request>
108
 
109
  # [CONTEXT-INTENSIVE TASKS]
110
  For large or complex reviews (many files/lines, deep history, multi-threaded discussions), use OpenCode's task planning:
 
114
 
115
  # [REVIEW GUIDELINES & CHECKLIST]
116
  Before writing any comments, you must first perform a thorough analysis based on these guidelines. This is your internal thought process—do not output it.
117
+ 1. **Read the Diff First:** Your absolute first step is to read the full diff content from the file at `${DIFF_FILE_PATH}`. This is mandatory to understand the scope and details of the changes before any analysis can begin.
118
+ 2. **Identify the Author:** Next, check if the PR author (`${PR_AUTHOR}`) is one of your own identities (mirrobot, mirrobot-agent, mirrobot-agent[bot]). It needs to match closely, Mirrowel is not an Identity of Mirrobot. This check is crucial as it dictates your entire review style.
119
+ 3. **Assess PR Size and Complexity:** Internally estimate scale. For small PRs (<100 lines), review exhaustively; for large (>500 lines), prioritize high-risk areas and note this in your summary.
120
+ 4. **Assess the High-Level Approach:**
121
  - Does the PR's overall strategy make sense?
122
  - Does it fit within the existing architecture? Is there a simpler way to achieve the goal?
123
  - Frame your feedback constructively. Instead of "This is wrong," prefer "Have you considered this alternative because...?"
124
+ 5. **Conduct a Detailed Code Analysis:** Evaluate all changes against the following criteria, cross-referencing existing discussion to skip duplicates:
125
  - **Security:** Are there potential vulnerabilities (e.g., injection, improper error handling, dependency issues)?
126
  - **Performance:** Could any code introduce performance bottlenecks?
127
  - **Testing:** Are there sufficient tests for the new logic? If it's a bug fix, is there a regression test?
 
148
  If this is the first review, follow this four-step process.
149
 
150
  **Step 1: Post Acknowledgment Comment**
151
+ After reading the diff file to get context, immediately provide feedback to the user that you are starting. Your acknowledgment should be unique and context-aware. Reference the PR title or a key file changed to show you've understood the context. Don't copy these templates verbatim. Be creative and make it feel human.
152
 
153
  Example for a PR titled "Refactor Auth Service":
154
  ```bash
.github/workflows/pr-review.yml CHANGED
@@ -15,11 +15,6 @@ on:
15
  description: 'The number of the PR to review manually'
16
  required: true
17
  type: string
18
- skipRun:
19
- description: 'TEMP DEBUG: skip opencode run (REMOVE WHEN STABLE)'
20
- required: false
21
- type: boolean
22
- default: false
23
 
24
  jobs:
25
  review-pr:
@@ -476,11 +471,6 @@ jobs:
476
  echo "$DIFF_CONTENT" > "$TMP_DIR/first_review_diff.txt"
477
  fi
478
 
479
- # Use a delimiter for multiline diff content
480
- DELIMITER="FIRST_REVIEW_DIFF_DELIMITER_$(openssl rand -hex 8)"
481
- echo "diff_content<<$DELIMITER" >> "$GITHUB_OUTPUT"
482
- echo "$DIFF_CONTENT" >> "$GITHUB_OUTPUT"
483
- echo "$DELIMITER" >> "$GITHUB_OUTPUT"
484
  env:
485
  BASE_BRANCH: ${{ env.BASE_BRANCH }}
486
 
@@ -522,102 +512,11 @@ jobs:
522
  echo "" > "$TMP_DIR/incremental_diff.txt"
523
  fi
524
 
525
- # Use a delimiter for multiline diff content, even if it's empty
526
- DELIMITER="INCREMENTAL_DIFF_DELIMITER_$(openssl rand -hex 8)"
527
- echo "diff_content<<$DELIMITER" >> "$GITHUB_OUTPUT"
528
- echo "$DIFF_CONTENT" >> "$GITHUB_OUTPUT"
529
- echo "$DELIMITER" >> "$GITHUB_OUTPUT"
530
-
531
- - name: Prepare Diff Files (ensure exist)
532
- run: |
533
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
534
  [ -f "$TMP_DIR/first_review_diff.txt" ] || touch "$TMP_DIR/first_review_diff.txt"
535
  [ -f "$TMP_DIR/incremental_diff.txt" ] || touch "$TMP_DIR/incremental_diff.txt"
536
 
537
- - name: Write OpenCode Instruction Files (Context + Diff)
538
- run: |
539
- set -e
540
- mkdir -p "$HOME/.config/opencode"
541
- # Write full PR context to opencode home; wrap exactly as the prompt would embed it
542
- {
543
- echo "# [PULL REQUEST CONTEXT]";
544
- echo "This is the full context for the pull request you must review.";
545
- echo "<pull_request_context>";
546
- printf "%s" "${PULL_REQUEST_CONTEXT}";
547
- echo;
548
- echo "</pull_request_context>";
549
- } > "$HOME/.config/opencode/pr-context.txt"
550
-
551
- # Unify diff into a single file in opencode home, wrapped in tags
552
- TMP_DIR="${RUNNER_TEMP:-/tmp}"
553
- {
554
- echo "# [Diff CONTEXT]";
555
- if [ "${{ steps.review_type.outputs.is_first_review }}" = "true" ]; then
556
- echo "Diff Type: FULL_PR_DIFF";
557
- else
558
- echo "Diff Type: INCREMENTAL_DIFF";
559
- fi;
560
- echo "<diff>";
561
- if [ "${{ steps.review_type.outputs.is_first_review }}" = "true" ]; then
562
- cat "$TMP_DIR/first_review_diff.txt";
563
- else
564
- cat "$TMP_DIR/incremental_diff.txt";
565
- fi;
566
- echo "</diff>";
567
- } > "$HOME/.config/opencode/pr-diff.txt"
568
- env:
569
- PULL_REQUEST_CONTEXT: ${{ env.PULL_REQUEST_CONTEXT }}
570
-
571
- - name: Clear Large Env Variables
572
- run: |
573
- # Remove large context from environment to avoid oversized process env
574
- echo "PULL_REQUEST_CONTEXT=" >> "$GITHUB_ENV"
575
- # Also clear any diff-related env vars if present
576
- echo "DIFF_CONTENT=" >> "$GITHUB_ENV"
577
-
578
- - name: Patch OpenCode Config Instructions (bare filenames)
579
- run: |
580
- set -e
581
- CONFIG_PATH="$HOME/.config/opencode/opencode.json"
582
- TMP_CONFIG="$CONFIG_PATH.tmp"
583
- if [ -f "$CONFIG_PATH" ]; then
584
- jq '.instructions = ((.instructions // []) + ["pr-context.txt","pr-diff.txt"]) | .instructions |= unique' \
585
- "$CONFIG_PATH" > "$TMP_CONFIG"
586
- mv "$TMP_CONFIG" "$CONFIG_PATH"
587
- else
588
- echo "::warning::OpenCode config not found at $CONFIG_PATH; skipping instructions patch."
589
- fi
590
-
591
- - name: Copy Instruction Files to Workspace and Log Locations (TEMP verify)
592
- run: |
593
- set -e
594
- CONFIG_PATH="$HOME/.config/opencode/opencode.json"
595
- SRC_DIR="$HOME/.config/opencode"
596
- DST_DIR="$GITHUB_WORKSPACE"
597
- echo "CONFIG_PATH=$CONFIG_PATH"
598
- echo "SRC_DIR=$SRC_DIR"
599
- echo "DST_DIR=$DST_DIR"
600
- mkdir -p "$DST_DIR"
601
- # Copy instruction files to workspace root so opencode can resolve bare filenames
602
- cp "$SRC_DIR/pr-context.txt" "$DST_DIR/pr-context.txt" || true
603
- cp "$SRC_DIR/pr-diff.txt" "$DST_DIR/pr-diff.txt" || true
604
- # Log exact locations for verification
605
- echo "-- Source instruction files --"
606
- ls -l "$SRC_DIR"/pr-*.txt || true
607
- echo "-- Workspace instruction files --"
608
- ls -l "$DST_DIR"/pr-*.txt || true
609
- echo "-- Config file --"
610
- ls -l "$CONFIG_PATH" || true
611
- echo "-- Absolute paths --"
612
- (command -v realpath >/dev/null 2>&1 && {
613
- echo "Workspace pr-context: $(realpath "$DST_DIR/pr-context.txt" 2>/dev/null || true)";
614
- echo "Workspace pr-diff: $(realpath "$DST_DIR/pr-diff.txt" 2>/dev/null || true)";
615
- echo "Config path: $(realpath "$CONFIG_PATH" 2>/dev/null || true)";
616
- echo "Source pr-context: $(realpath "$SRC_DIR/pr-context.txt" 2>/dev/null || true)";
617
- echo "Source pr-diff: $(realpath "$SRC_DIR/pr-diff.txt" 2>/dev/null || true)";
618
- }) || true
619
- echo "PWD=$(pwd)"
620
-
621
 
622
  - name: Assemble Review Prompt
623
  env:
@@ -627,14 +526,27 @@ jobs:
627
  PR_NUMBER: ${{ env.PR_NUMBER }}
628
  GITHUB_REPOSITORY: ${{ github.repository }}
629
  PR_HEAD_SHA: ${{ env.PR_HEAD_SHA }}
 
630
  run: |
631
- # Keep envsubst minimal; context & diff now loaded via config instructions files
632
- VARS='${REVIEW_TYPE} ${PR_AUTHOR} ${IS_FIRST_REVIEW} ${PR_NUMBER} ${GITHUB_REPOSITORY} ${PR_HEAD_SHA}'
633
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
634
- envsubst "$VARS" < /tmp/pr-review.md > "$TMP_DIR/assembled_prompt.txt"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
 
636
  - name: Review PR with OpenCode
637
- if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.skipRun == 'true') }}
638
  env:
639
  GITHUB_TOKEN: ${{ steps.setup.outputs.token }}
640
  OPENCODE_PERMISSION: |
@@ -655,27 +567,3 @@ jobs:
655
  run: |
656
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
657
  opencode run --share - < "$TMP_DIR/assembled_prompt.txt"
658
-
659
- - name: DEBUG Skip Notice (TEMP REMOVE WHEN STABLE)
660
- if: ${{ github.event_name == 'workflow_dispatch' && inputs.skipRun == 'true' }}
661
- run: |
662
- echo "skipRun=true -> Skipping opencode execution. (REMOVE skipRun input + this step when stable)"
663
-
664
- - name: Stage Artifacts to Temp
665
- if: always()
666
- run: |
667
- set -e
668
- cp "$HOME/.config/opencode/pr-context.txt" "$RUNNER_TEMP/opencode-pr-context.txt" || true
669
- cp "$HOME/.config/opencode/pr-diff.txt" "$RUNNER_TEMP/opencode-pr-diff.txt" || true
670
- cp "$HOME/.config/opencode/opencode.json" "$RUNNER_TEMP/opencode-config.json" || true
671
-
672
- - name: Upload Artifacts
673
- if: always()
674
- uses: actions/upload-artifact@v4
675
- with:
676
- name: pr-review-prompt-and-files-${{ env.PR_NUMBER }}
677
- path: |
678
- ${{ runner.temp }}/assembled_prompt.txt
679
- ${{ runner.temp }}/opencode-pr-context.txt
680
- ${{ runner.temp }}/opencode-pr-diff.txt
681
- ${{ runner.temp }}/opencode-config.json
 
15
  description: 'The number of the PR to review manually'
16
  required: true
17
  type: string
 
 
 
 
 
18
 
19
  jobs:
20
  review-pr:
 
471
  echo "$DIFF_CONTENT" > "$TMP_DIR/first_review_diff.txt"
472
  fi
473
 
 
 
 
 
 
474
  env:
475
  BASE_BRANCH: ${{ env.BASE_BRANCH }}
476
 
 
512
  echo "" > "$TMP_DIR/incremental_diff.txt"
513
  fi
514
 
515
+ # Ensure files exist even on edge cases
 
 
 
 
 
 
 
516
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
517
  [ -f "$TMP_DIR/first_review_diff.txt" ] || touch "$TMP_DIR/first_review_diff.txt"
518
  [ -f "$TMP_DIR/incremental_diff.txt" ] || touch "$TMP_DIR/incremental_diff.txt"
519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
  - name: Assemble Review Prompt
522
  env:
 
526
  PR_NUMBER: ${{ env.PR_NUMBER }}
527
  GITHUB_REPOSITORY: ${{ github.repository }}
528
  PR_HEAD_SHA: ${{ env.PR_HEAD_SHA }}
529
+ PULL_REQUEST_CONTEXT: ${{ env.PULL_REQUEST_CONTEXT }}
530
  run: |
531
+ # Build DIFF_FILE_PATH pointing to the generated diff in RUNNER_TEMP
 
532
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
533
+ if [ "${{ steps.review_type.outputs.is_first_review }}" = "true" ]; then
534
+ DIFF_FILE_PATH="$TMP_DIR/first_review_diff.txt"
535
+ else
536
+ DIFF_FILE_PATH="$TMP_DIR/incremental_diff.txt"
537
+ fi
538
+ # Substitute variables, embedding PR context and diff file path; DIFF_FILE_PATH kept local to this process
539
+ VARS='${REVIEW_TYPE} ${PR_AUTHOR} ${IS_FIRST_REVIEW} ${PR_NUMBER} ${GITHUB_REPOSITORY} ${PR_HEAD_SHA} ${PULL_REQUEST_CONTEXT} ${DIFF_FILE_PATH}'
540
+ DIFF_FILE_PATH="$DIFF_FILE_PATH" envsubst "$VARS" < /tmp/pr-review.md > "$TMP_DIR/assembled_prompt.txt"
541
+ # Immediately clear large env after use
542
+ echo "PULL_REQUEST_CONTEXT=" >> "$GITHUB_ENV"
543
+ # Clear small, now-redundant flags included in the context summary
544
+ echo "EXCLUDED_REVIEWS=" >> "$GITHUB_ENV" || true
545
+ echo "EXCLUDED_COMMENTS=" >> "$GITHUB_ENV" || true
546
+ echo "FILTER_ERROR_REVIEWS=" >> "$GITHUB_ENV" || true
547
+ echo "FILTER_ERROR_COMMENTS=" >> "$GITHUB_ENV" || true
548
 
549
  - name: Review PR with OpenCode
 
550
  env:
551
  GITHUB_TOKEN: ${{ steps.setup.outputs.token }}
552
  OPENCODE_PERMISSION: |
 
567
  run: |
568
  TMP_DIR="${RUNNER_TEMP:-/tmp}"
569
  opencode run --share - < "$TMP_DIR/assembled_prompt.txt"