Changesets · Branches · Tags · Compare
| Changeset | 5a3a0786c879ba00b2c786cf58e161e5273e7477f82838ee09c1c14788914a0f |
|---|---|
| Author | Brian Douglas <bdougie@users.noreply.github.com> · 2025-09-26 09:42 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-26 09:42 -07:00 |
| Parents | 9a2b24e8b9a1 |
9 files changed
modified .github/pull_request_template.md +1 −1
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | ## AI Code Review |
| 6 | 6 | |
| 7 | 7 | - **Team members only**: AI review runs automatically when PR is opened or marked ready for review |
| 8 | -- Team members can also trigger a review by commenting `@continue-general-review` or `@continue-detailed-review` | |
| 8 | +- Team members can also trigger a review by commenting `@continue-review` | |
| 9 | 9 | |
| 10 | 10 | ## Checklist |
| 11 | 11 |
deleted .github/workflows/continue-detailed-review.yaml +0 −25
| @@ -1,25 +0,0 @@ | ||
| 1 | -name: Continue Detailed Review | |
| 2 | - | |
| 3 | -on: | |
| 4 | - pull_request: | |
| 5 | - types: [opened, ready_for_review] | |
| 6 | - issue_comment: | |
| 7 | - types: [created] | |
| 8 | - | |
| 9 | -permissions: | |
| 10 | - contents: read | |
| 11 | - pull-requests: write | |
| 12 | - issues: write | |
| 13 | - | |
| 14 | -jobs: | |
| 15 | - detailed-code-review: | |
| 16 | - name: Continue Detailed Review | |
| 17 | - runs-on: ubuntu-latest | |
| 18 | - timeout-minutes: 10 | |
| 19 | - steps: | |
| 20 | - - name: Run Detailed PR Review | |
| 21 | - uses: continuedev/continue/actions/detailed-review@main | |
| 22 | - with: | |
| 23 | - continue-api-key: ${{ secrets.CONTINUE_API_KEY }} | |
| 24 | - continue-org: continuedev | |
| 25 | - continue-config: continuedev/review-bot |
modified .github/workflows/pr-checks.yaml +0 −26
| @@ -343,31 +343,6 @@ | ||
| 343 | 343 | |
| 344 | 344 | # GitHub does not have a way of requiring that all checks pass (you must manually select each job) |
| 345 | 345 | # This action at least lets us manage the list of required tests via source control |
| 346 | - pr-review-action-tests: | |
| 347 | - runs-on: ubuntu-latest | |
| 348 | - steps: | |
| 349 | - - uses: actions/checkout@v5 | |
| 350 | - - uses: actions/setup-node@v5 | |
| 351 | - with: | |
| 352 | - node-version: 20 | |
| 353 | - | |
| 354 | - - name: Cache PR review action node modules | |
| 355 | - uses: actions/cache@v4 | |
| 356 | - id: pr-review-cache | |
| 357 | - with: | |
| 358 | - path: actions/detailed-review/node_modules | |
| 359 | - key: ${{ runner.os }}-pr-review-action-${{ hashFiles('actions/detailed-review/package.json') }} | |
| 360 | - | |
| 361 | - - name: Install dependencies | |
| 362 | - if: steps.pr-review-cache.outputs.cache-hit != 'true' | |
| 363 | - run: | | |
| 364 | - cd actions/detailed-review | |
| 365 | - npm install | |
| 366 | - | |
| 367 | - - name: Run tests | |
| 368 | - run: | | |
| 369 | - cd actions/detailed-review | |
| 370 | - npm test | |
| 371 | 346 | |
| 372 | 347 | # so that creators of new jobs can add them to this list |
| 373 | 348 | require-all-checks-to-pass: |
| @@ -385,7 +360,6 @@ | ||
| 385 | 360 | - vscode-package-extension-linux |
| 386 | 361 | - vscode-e2e-tests |
| 387 | 362 | - jetbrains-tests |
| 388 | - - pr-review-action-tests | |
| 389 | 363 | |
| 390 | 364 | steps: |
| 391 | 365 | - name: Decide whether the needed jobs succeeded or failed |
modified actions/README.md +13 −116
| @@ -4,64 +4,19 @@ | ||
| 4 | 4 | |
| 5 | 5 | ## Available Actions |
| 6 | 6 | |
| 7 | -This repository provides two GitHub Actions for different review styles: | |
| 7 | +This repository provides a GitHub Action for automated PR reviews: | |
| 8 | 8 | |
| 9 | -### 1. General Review Action | |
| 9 | +### General Review Action | |
| 10 | 10 | |
| 11 | 11 | Provides high-level PR assessment with overall feedback and recommendations. |
| 12 | 12 | |
| 13 | -- **Path:** `continuedev/continue/actions/general-review@<commit-sha>` | |
| 14 | -- **Trigger:** `@continue-general-review` | |
| 13 | +- **Path:** `continuedev/continue/actions/general-review@main` | |
| 14 | +- **Trigger:** `@continue-review` | |
| 15 | 15 | - **Output:** Summary comment with strengths, issues, and recommendations |
| 16 | 16 | |
| 17 | -### 2. Detailed Review Action | |
| 18 | - | |
| 19 | -Provides line-by-line inline comments on specific code changes. | |
| 20 | - | |
| 21 | -- **Path:** `continuedev/continue/actions/detailed-review@<commit-sha>` | |
| 22 | -- **Trigger:** `@continue-detailed-review` | |
| 23 | -- **Output:** Inline review comments on specific lines of code | |
| 24 | - | |
| 25 | 17 | ## Quick Start |
| 26 | 18 | |
| 27 | -### Using Both Actions Together | |
| 28 | - | |
| 29 | -```yaml | |
| 30 | -name: PR Reviews | |
| 31 | -on: | |
| 32 | - pull_request: | |
| 33 | - types: [opened, ready_for_review] | |
| 34 | - issue_comment: | |
| 35 | - types: [created] | |
| 36 | - | |
| 37 | -permissions: | |
| 38 | - contents: read | |
| 39 | - pull-requests: write | |
| 40 | - issues: write | |
| 41 | - | |
| 42 | -jobs: | |
| 43 | - general-review: | |
| 44 | - runs-on: ubuntu-latest | |
| 45 | - timeout-minutes: 10 | |
| 46 | - steps: | |
| 47 | - - uses: continuedev/continue/actions/general-review@<commit-sha> | |
| 48 | - with: | |
| 49 | - continue-api-key: ${{ secrets.CONTINUE_API_KEY }} | |
| 50 | - continue-org: "your-org-name" | |
| 51 | - continue-config: "your-org-name/review-bot" | |
| 52 | - | |
| 53 | - detailed-review: | |
| 54 | - runs-on: ubuntu-latest | |
| 55 | - timeout-minutes: 10 | |
| 56 | - steps: | |
| 57 | - - uses: continuedev/continue/actions/detailed-review@<commit-sha> | |
| 58 | - with: | |
| 59 | - continue-api-key: ${{ secrets.CONTINUE_API_KEY }} | |
| 60 | - continue-org: "your-org-name" | |
| 61 | - continue-config: "your-org-name/review-bot" | |
| 62 | -``` | |
| 63 | - | |
| 64 | -### General Review Only | |
| 19 | +### Setting up General Review | |
| 65 | 20 | |
| 66 | 21 | ```yaml |
| 67 | 22 | name: PR General Review |
| @@ -81,34 +36,7 @@ | ||
| 81 | 36 | runs-on: ubuntu-latest |
| 82 | 37 | timeout-minutes: 10 |
| 83 | 38 | steps: |
| 84 | - - uses: continuedev/continue/actions/general-review@<commit-sha> | |
| 85 | - with: | |
| 86 | - continue-api-key: ${{ secrets.CONTINUE_API_KEY }} | |
| 87 | - continue-org: "your-org-name" | |
| 88 | - continue-config: "your-org-name/review-bot" | |
| 89 | -``` | |
| 90 | - | |
| 91 | -### Detailed Review Only | |
| 92 | - | |
| 93 | -```yaml | |
| 94 | -name: PR Detailed Review | |
| 95 | -on: | |
| 96 | - pull_request: | |
| 97 | - types: [opened, ready_for_review] | |
| 98 | - issue_comment: | |
| 99 | - types: [created] | |
| 100 | - | |
| 101 | -permissions: | |
| 102 | - contents: read | |
| 103 | - pull-requests: write | |
| 104 | - issues: write | |
| 105 | - | |
| 106 | -jobs: | |
| 107 | - review: | |
| 108 | - runs-on: ubuntu-latest | |
| 109 | - timeout-minutes: 10 | |
| 110 | - steps: | |
| 111 | - - uses: continuedev/continue/actions/detailed-review@<commit-sha> | |
| 39 | + - uses: continuedev/continue/actions/general-review@main | |
| 112 | 40 | with: |
| 113 | 41 | continue-api-key: ${{ secrets.CONTINUE_API_KEY }} |
| 114 | 42 | continue-org: "your-org-name" |
| @@ -117,7 +45,7 @@ | ||
| 117 | 45 | |
| 118 | 46 | ## Inputs |
| 119 | 47 | |
| 120 | -Both actions accept the same inputs: | |
| 48 | +The action accepts the following inputs: | |
| 121 | 49 | |
| 122 | 50 | | Input | Description | Required | |
| 123 | 51 | | ------------------ | -------------------------------------- | -------- | |
| @@ -155,7 +83,7 @@ | ||
| 155 | 83 | |
| 156 | 84 | ## Triggering Reviews |
| 157 | 85 | |
| 158 | -Both actions can be triggered in two ways: | |
| 86 | +The action can be triggered in two ways: | |
| 159 | 87 | |
| 160 | 88 | ### Automatic Triggers |
| 161 | 89 | |
| @@ -166,12 +94,9 @@ | ||
| 166 | 94 | |
| 167 | 95 | Team members can trigger reviews by commenting on any pull request: |
| 168 | 96 | |
| 169 | -- `@continue-general-review` - Triggers a general review | |
| 170 | -- `@continue-detailed-review` - Triggers a detailed inline review | |
| 171 | - | |
| 172 | -## Review Outputs | |
| 97 | +- `@continue-review` - Triggers a review | |
| 173 | 98 | |
| 174 | -### General Review Output | |
| 99 | +## Review Output | |
| 175 | 100 | |
| 176 | 101 | The general review provides a structured comment that includes: |
| 177 | 102 | |
| @@ -180,46 +105,24 @@ | ||
| 180 | 105 | - **Suggestions**: Improvement recommendations |
| 181 | 106 | - **Overall Assessment**: Final recommendation (APPROVE, REQUEST_CHANGES, or COMMENT) |
| 182 | 107 | |
| 183 | -### Detailed Review Output | |
| 184 | - | |
| 185 | -The detailed review provides: | |
| 186 | - | |
| 187 | -- **Inline Comments**: Specific feedback on individual lines of code | |
| 188 | -- **Position Markers**: Comments appear directly on the changed lines | |
| 189 | -- **Review Summary**: Overall assessment of the changes | |
| 190 | -- **Actionable Feedback**: Specific suggestions for each issue found | |
| 191 | - | |
| 192 | 108 | ## How It Works |
| 193 | 109 | |
| 194 | -### General Review Process | |
| 195 | - | |
| 196 | 110 | 1. Checks out repository code |
| 197 | 111 | 2. Fetches PR diff using GitHub CLI |
| 198 | 112 | 3. Generates a comprehensive review prompt |
| 199 | 113 | 4. Runs Continue CLI with specified configuration |
| 200 | 114 | 5. Posts review as a PR comment |
| 201 | 115 | |
| 202 | -### Detailed Review Process | |
| 203 | - | |
| 204 | -1. Checks out repository code | |
| 205 | -2. Fetches PR diff with GitHub API positions | |
| 206 | -3. Annotates diff with position markers | |
| 207 | -4. Generates inline review prompt | |
| 208 | -5. Runs Continue CLI for detailed analysis | |
| 209 | -6. Posts inline comments using GitHub's review API | |
| 210 | - | |
| 211 | 116 | ## Versioning |
| 212 | 117 | |
| 213 | -We recommend using a specific commit SHA for stability and predictability: | |
| 118 | +We recommend using the main branch: | |
| 214 | 119 | |
| 215 | -- `@<commit-sha>` - Pins to a specific commit for maximum stability (recommended) | |
| 216 | -- `@main` - Uses the latest code from the main branch (for bleeding edge) | |
| 217 | -- `@v1` - Uses a version tag when available | |
| 120 | +- `@main` - Uses the latest code from the main branch | |
| 218 | 121 | |
| 219 | 122 | Example: |
| 220 | 123 | |
| 221 | 124 | ```yaml |
| 222 | -uses: continuedev/continue/actions/general-review@64bda6b2b3dac1037e9895dbee4ce1d35565e1fe | |
| 125 | +uses: continuedev/continue/actions/general-review@main | |
| 223 | 126 | ``` |
| 224 | 127 | |
| 225 | 128 | ## Troubleshooting |
| @@ -236,12 +139,6 @@ | ||
| 236 | 139 | - Verify your Continue configuration is correct |
| 237 | 140 | - Ensure your Continue API key is valid |
| 238 | 141 | |
| 239 | -### Inline comments not appearing (Detailed Review) | |
| 240 | - | |
| 241 | -- Check that the PR has a valid diff | |
| 242 | -- Verify GitHub API permissions are correct | |
| 243 | -- Review action logs for position calculation errors | |
| 244 | - | |
| 245 | 142 | ## Support |
| 246 | 143 | |
| 247 | 144 | For issues or questions: |
deleted actions/detailed-review/action.yml +0 −434
| @@ -1,434 +0,0 @@ | ||
| 1 | -name: 'Continue Detailed PR Review' | |
| 2 | -description: 'Automated inline code review for pull requests using Continue CLI' | |
| 3 | -author: 'Continue Dev, Inc.' | |
| 4 | - | |
| 5 | -inputs: | |
| 6 | - continue-api-key: | |
| 7 | - description: 'API key for Continue service' | |
| 8 | - required: true | |
| 9 | - continue-org: | |
| 10 | - description: 'Organization for Continue config' | |
| 11 | - required: true | |
| 12 | - continue-config: | |
| 13 | - description: 'Config path to use (e.g., "myorg/review-bot")' | |
| 14 | - required: true | |
| 15 | - | |
| 16 | -runs: | |
| 17 | - using: 'composite' | |
| 18 | - steps: | |
| 19 | - - name: Checkout Repository | |
| 20 | - uses: actions/checkout@v4 | |
| 21 | - | |
| 22 | - - name: Check Authorization | |
| 23 | - shell: bash | |
| 24 | - env: | |
| 25 | - # Only move the dangerous check to env to prevent shell injection | |
| 26 | - HAS_TRIGGER_PHRASE: ${{ contains(github.event.comment.body, '@continue-detailed-review') }} | |
| 27 | - run: | | |
| 28 | - # Check if this action should run based on event type and user permissions | |
| 29 | - SHOULD_RUN="false" | |
| 30 | - | |
| 31 | - if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| 32 | - # Check if PR is a draft | |
| 33 | - if [ "${{ github.event.pull_request.draft }}" = "true" ]; then | |
| 34 | - echo "::notice::Skipping review - PR is a draft" | |
| 35 | - else | |
| 36 | - # Check PR author association | |
| 37 | - AUTHOR_ASSOC="${{ github.event.pull_request.author_association }}" | |
| 38 | - if [ "$AUTHOR_ASSOC" = "OWNER" ] || [ "$AUTHOR_ASSOC" = "MEMBER" ] || [ "$AUTHOR_ASSOC" = "COLLABORATOR" ]; then | |
| 39 | - SHOULD_RUN="true" | |
| 40 | - else | |
| 41 | - echo "::notice::Skipping review - PR author is not a team member (association: $AUTHOR_ASSOC)" | |
| 42 | - fi | |
| 43 | - fi | |
| 44 | - elif [ "${{ github.event_name }}" = "issue_comment" ]; then | |
| 45 | - # Check if it's a PR comment with the trigger phrase | |
| 46 | - if [ "${{ github.event.issue.pull_request }}" != "" ] && [ "$HAS_TRIGGER_PHRASE" = "true" ]; then | |
| 47 | - COMMENTER_ASSOC="${{ github.event.comment.author_association }}" | |
| 48 | - if [ "$COMMENTER_ASSOC" = "OWNER" ] || [ "$COMMENTER_ASSOC" = "MEMBER" ] || [ "$COMMENTER_ASSOC" = "COLLABORATOR" ]; then | |
| 49 | - SHOULD_RUN="true" | |
| 50 | - else | |
| 51 | - echo "::notice::Skipping review - Commenter is not a team member (association: $COMMENTER_ASSOC)" | |
| 52 | - fi | |
| 53 | - else | |
| 54 | - echo "::notice::Skipping review - Comment does not contain @continue-detailed-review trigger, or is not on a PR" | |
| 55 | - fi | |
| 56 | - else | |
| 57 | - echo "::notice::Skipping review - Event type ${{ github.event_name }} is not supported" | |
| 58 | - fi | |
| 59 | - | |
| 60 | - if [ "$SHOULD_RUN" != "true" ]; then | |
| 61 | - echo "SKIP_REVIEW=true" >> $GITHUB_ENV | |
| 62 | - exit 0 | |
| 63 | - fi | |
| 64 | - | |
| 65 | - echo "SKIP_REVIEW=false" >> $GITHUB_ENV | |
| 66 | - | |
| 67 | - - name: Setup Node.js | |
| 68 | - if: env.SKIP_REVIEW != 'true' | |
| 69 | - uses: actions/setup-node@v4 | |
| 70 | - with: | |
| 71 | - node-version: 20 | |
| 72 | - | |
| 73 | - - name: Install Continue CLI | |
| 74 | - if: env.SKIP_REVIEW != 'true' | |
| 75 | - shell: bash | |
| 76 | - run: npm install -g @continuedev/cli@1.4.30 | |
| 77 | - | |
| 78 | - - name: Build Inline Review Prompt | |
| 79 | - if: env.SKIP_REVIEW != 'true' | |
| 80 | - shell: bash | |
| 81 | - env: | |
| 82 | - GH_TOKEN: ${{ github.token }} | |
| 83 | - run: | | |
| 84 | - # Get PR number based on event type | |
| 85 | - if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| 86 | - PR_NUMBER="${{ github.event.number }}" | |
| 87 | - else | |
| 88 | - # For issue_comment event on a PR | |
| 89 | - PR_NUMBER="${{ github.event.issue.number }}" | |
| 90 | - fi | |
| 91 | - | |
| 92 | - # Get PR files with line numbers | |
| 93 | - gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/files > pr_files.json | |
| 94 | - | |
| 95 | - # Get PR diff with context | |
| 96 | - gh pr diff $PR_NUMBER --color=never > pr_diff.txt | |
| 97 | - | |
| 98 | - # Annotate diff with GitHub API positions | |
| 99 | - node ${{ github.action_path }}/annotate-diff.js pr_diff.txt > pr_diff_annotated.txt | |
| 100 | - | |
| 101 | - # Debug: Show sample of annotated diff | |
| 102 | - echo "=== SAMPLE OF ANNOTATED DIFF ===" | |
| 103 | - head -100 pr_diff_annotated.txt | grep -E "^\[POS:|^@@|^diff --git" || head -50 pr_diff_annotated.txt | |
| 104 | - echo "=== END SAMPLE ===" | |
| 105 | - | |
| 106 | - # Create review prompt for inline comments | |
| 107 | - cat > inline_review_prompt.txt << 'EOF' | |
| 108 | - You are conducting a detailed inline code review for a pull request. | |
| 109 | - | |
| 110 | - Your task is to analyze the code changes and generate specific, actionable review comments for individual lines or small sections of code. | |
| 111 | - | |
| 112 | - IMPORTANT: The diff below has been annotated with [POS:N] markers showing the exact position for each line. | |
| 113 | - | |
| 114 | - Example of how to use the position markers: | |
| 115 | - ``` | |
| 116 | - diff --git a/src/app.js b/src/app.js | |
| 117 | - index abc123..def456 100644 | |
| 118 | - --- a/src/app.js | |
| 119 | - +++ b/src/app.js | |
| 120 | - @@ -10,4 +10,6 @@ function example() { | |
| 121 | - [POS:1] console.log("context"); | |
| 122 | - [POS:2] - const old = "remove this"; | |
| 123 | - [POS:3] + const new = "add this"; | |
| 124 | - [POS:4] + const risky = eval(userInput); <-- To comment here, use position: 4 | |
| 125 | - [POS:5] return result; | |
| 126 | - [POS:6] + console.log("done"); | |
| 127 | - @@ -20,3 +22,4 @@ function another() { | |
| 128 | - [POS:1] let x = 1; | |
| 129 | - [POS:2] + let y = 2; <-- To comment here, use position: 2 | |
| 130 | - ``` | |
| 131 | - | |
| 132 | - To comment on a line, simply use the number from its [POS:N] marker as the position value. | |
| 133 | - For example: {"path": "src/app.js", "position": 4, "body": "Avoid using eval with user input"} | |
| 134 | - | |
| 135 | - Below is the annotated PR diff: | |
| 136 | - | |
| 137 | - EOF | |
| 138 | - | |
| 139 | - cat pr_diff_annotated.txt >> inline_review_prompt.txt | |
| 140 | - | |
| 141 | - cat >> inline_review_prompt.txt << 'EOF' | |
| 142 | - | |
| 143 | - Please analyze these changes and provide inline review comments in the following JSON format: | |
| 144 | - | |
| 145 | - { | |
| 146 | - "review_summary": "Overall assessment of the PR", | |
| 147 | - "comments": [ | |
| 148 | - { | |
| 149 | - "path": "path/to/file.js", | |
| 150 | - "position": 4, | |
| 151 | - "body": "Brief, specific comment about this line or section" | |
| 152 | - } | |
| 153 | - ] | |
| 154 | - } | |
| 155 | - | |
| 156 | - Focus on: | |
| 157 | - 1. **Critical Issues**: Security vulnerabilities, bugs that will break functionality | |
| 158 | - 2. **High Priority**: Performance problems, incorrect logic, missing error handling | |
| 159 | - 3. **Medium Priority**: Code style violations, potential edge cases, unclear code | |
| 160 | - 4. **Low Priority**: Suggestions for improvement, refactoring opportunities | |
| 161 | - | |
| 162 | - Guidelines for comments: | |
| 163 | - - Be specific and actionable | |
| 164 | - - Use the [POS:N] number shown in the diff as the position value | |
| 165 | - - Keep comments concise but informative | |
| 166 | - - Suggest concrete improvements when pointing out issues | |
| 167 | - - Only comment on actual problems or important improvements | |
| 168 | - | |
| 169 | - Important: | |
| 170 | - - Output ONLY valid JSON, no markdown code blocks or backticks | |
| 171 | - - Start your response with { and end with } | |
| 172 | - - Use the exact number from [POS:N] markers as the position | |
| 173 | - - Only comment on changed lines (lines with + or - prefix) | |
| 174 | - - Comment on the most important issues first | |
| 175 | - - Limit to maximum 20 most relevant comments | |
| 176 | - EOF | |
| 177 | - | |
| 178 | - - name: Run Continue CLI Inline Review | |
| 179 | - if: env.SKIP_REVIEW != 'true' | |
| 180 | - shell: bash | |
| 181 | - env: | |
| 182 | - CONTINUE_API_KEY: ${{ inputs.continue-api-key }} | |
| 183 | - run: | | |
| 184 | - echo "Running Continue CLI for inline review..." | |
| 185 | - | |
| 186 | - # Validate required inputs | |
| 187 | - if [ -z "${{ inputs.continue-org }}" ]; then | |
| 188 | - echo "Error: continue-org input is required" | |
| 189 | - exit 1 | |
| 190 | - fi | |
| 191 | - | |
| 192 | - if [ -z "${{ inputs.continue-config }}" ]; then | |
| 193 | - echo "Error: continue-config input is required" | |
| 194 | - exit 1 | |
| 195 | - fi | |
| 196 | - | |
| 197 | - # Validate API key | |
| 198 | - if [ -z "$CONTINUE_API_KEY" ]; then | |
| 199 | - echo "Warning: CONTINUE_API_KEY environment variable is not set" | |
| 200 | - # Create fallback review and continue | |
| 201 | - cat > inline_review.json << 'EOF' | |
| 202 | - { | |
| 203 | - "review_summary": "AI review skipped: CONTINUE_API_KEY not configured.", | |
| 204 | - "comments": [] | |
| 205 | - } | |
| 206 | - EOF | |
| 207 | - echo "SKIP_CLI=true" >> $GITHUB_ENV | |
| 208 | - else | |
| 209 | - echo "SKIP_CLI=false" >> $GITHUB_ENV | |
| 210 | - fi | |
| 211 | - | |
| 212 | - # Log the prompt for debugging | |
| 213 | - echo "===== START REVIEW PROMPT =====" | |
| 214 | - head -n 50 inline_review_prompt.txt | |
| 215 | - echo "... [diff content] ..." | |
| 216 | - tail -n 20 inline_review_prompt.txt | |
| 217 | - echo "===== END REVIEW PROMPT =====" | |
| 218 | - | |
| 219 | - # Test Continue CLI availability | |
| 220 | - if [ "$SKIP_CLI" != "true" ]; then | |
| 221 | - echo "Testing Continue CLI..." | |
| 222 | - if ! cn --version; then | |
| 223 | - echo "Warning: Continue CLI not found or not working" | |
| 224 | - cat > inline_review.json << 'EOF' | |
| 225 | - { | |
| 226 | - "review_summary": "AI review skipped: Continue CLI installation failed.", | |
| 227 | - "comments": [] | |
| 228 | - } | |
| 229 | - EOF | |
| 230 | - echo "SKIP_CLI=true" >> $GITHUB_ENV | |
| 231 | - else | |
| 232 | - echo "Continue CLI version: $(cn --version)" | |
| 233 | - fi | |
| 234 | - fi | |
| 235 | - | |
| 236 | - # Run the CLI and capture JSON output with error handling | |
| 237 | - if [ "$SKIP_CLI" != "true" ]; then | |
| 238 | - echo "Executing Continue CLI with config: ${{ inputs.continue-org }}/${{ inputs.continue-config }}" | |
| 239 | - | |
| 240 | - # Write prompt to temp file for better handling | |
| 241 | - PROMPT_FILE="/tmp/continue-prompt-$.txt" | |
| 242 | - cp inline_review_prompt.txt "$PROMPT_FILE" | |
| 243 | - | |
| 244 | - # Use timeout to prevent hanging (240 seconds = 4 minutes) | |
| 245 | - if ! timeout 240 cn --config "${{ inputs.continue-org }}/${{ inputs.continue-config }}" -p "@$PROMPT_FILE" --allow Bash --format json > inline_review_raw.json 2>cli_error.log; then | |
| 246 | - echo "Warning: Continue CLI command failed" | |
| 247 | - echo "CLI error log:" | |
| 248 | - cat cli_error.log | |
| 249 | - | |
| 250 | - # Create fallback review | |
| 251 | - cat > inline_review.json << 'EOF' | |
| 252 | - { | |
| 253 | - "review_summary": "AI review failed due to service initialization issues. Please check the Continue API key and configuration.", | |
| 254 | - "comments": [] | |
| 255 | - } | |
| 256 | - EOF | |
| 257 | - echo "Created fallback review due to CLI failure" | |
| 258 | - else | |
| 259 | - # Log the output for debugging | |
| 260 | - echo "Initial Continue CLI output:" | |
| 261 | - cat inline_review_raw.json | |
| 262 | - | |
| 263 | - # Validate JSON output and use it directly | |
| 264 | - if ! jq empty inline_review_raw.json 2>/dev/null; then | |
| 265 | - echo "Warning: Invalid JSON output from Continue CLI, using fallback" | |
| 266 | - cat > inline_review.json << 'EOF' | |
| 267 | - { | |
| 268 | - "review_summary": "AI review completed but failed to parse output correctly.", | |
| 269 | - "comments": [] | |
| 270 | - } | |
| 271 | - EOF | |
| 272 | - else | |
| 273 | - # Use the JSON output directly | |
| 274 | - cp inline_review_raw.json inline_review.json | |
| 275 | - echo "Review output:" | |
| 276 | - cat inline_review.json | |
| 277 | - fi | |
| 278 | - fi | |
| 279 | - fi | |
| 280 | - | |
| 281 | - - name: Post Inline Review Comments | |
| 282 | - if: env.SKIP_REVIEW != 'true' | |
| 283 | - uses: actions/github-script@v7 | |
| 284 | - with: | |
| 285 | - script: | | |
| 286 | - const fs = require('fs'); | |
| 287 | - | |
| 288 | - try { | |
| 289 | - // Read the review output | |
| 290 | - let reviewData; | |
| 291 | - try { | |
| 292 | - const reviewContent = fs.readFileSync('inline_review.json', 'utf8'); | |
| 293 | - reviewData = JSON.parse(reviewContent); | |
| 294 | - } catch (parseError) { | |
| 295 | - console.log('Failed to parse review JSON:', parseError); | |
| 296 | - reviewData = { | |
| 297 | - review_summary: 'AI review completed but failed to parse output', | |
| 298 | - comments: [] | |
| 299 | - }; | |
| 300 | - } | |
| 301 | - | |
| 302 | - // Get PR number | |
| 303 | - let prNumber; | |
| 304 | - if (context.eventName === 'pull_request') { | |
| 305 | - prNumber = context.payload.pull_request.number; | |
| 306 | - } else { | |
| 307 | - prNumber = context.payload.issue.number; | |
| 308 | - } | |
| 309 | - | |
| 310 | - // Get the latest commit SHA | |
| 311 | - const { data: pr } = await github.rest.pulls.get({ | |
| 312 | - owner: context.repo.owner, | |
| 313 | - repo: context.repo.repo, | |
| 314 | - pull_number: prNumber | |
| 315 | - }); | |
| 316 | - | |
| 317 | - const commitSha = pr.head.sha; | |
| 318 | - | |
| 319 | - // Prepare review comments - filter out comments without required fields | |
| 320 | - const allComments = reviewData.comments || []; | |
| 321 | - const validComments = allComments.filter(comment => | |
| 322 | - comment.position && | |
| 323 | - comment.path && | |
| 324 | - comment.body && | |
| 325 | - typeof comment.position === 'number' && | |
| 326 | - comment.position > 0 | |
| 327 | - ); | |
| 328 | - | |
| 329 | - if (validComments.length < allComments.length) { | |
| 330 | - console.log(`Filtered out ${allComments.length - validComments.length} comments due to missing/invalid position, path, or body`); | |
| 331 | - const invalidComments = allComments.filter(c => !validComments.includes(c)); | |
| 332 | - console.log('Invalid comments:', JSON.stringify(invalidComments, null, 2)); | |
| 333 | - } | |
| 334 | - | |
| 335 | - // Deduplicate comments based on path + position + body | |
| 336 | - const uniqueComments = []; | |
| 337 | - const seen = new Set(); | |
| 338 | - | |
| 339 | - for (const comment of validComments) { | |
| 340 | - const key = `${comment.path}:${comment.position}:${comment.body}`; | |
| 341 | - if (!seen.has(key)) { | |
| 342 | - seen.add(key); | |
| 343 | - uniqueComments.push(comment); | |
| 344 | - } | |
| 345 | - } | |
| 346 | - | |
| 347 | - if (uniqueComments.length < validComments.length) { | |
| 348 | - console.log(`Filtered out ${validComments.length - uniqueComments.length} duplicate comments (same path + position + body)`); | |
| 349 | - } | |
| 350 | - | |
| 351 | - const comments = uniqueComments.map(comment => ({ | |
| 352 | - path: comment.path, | |
| 353 | - position: comment.position, | |
| 354 | - body: comment.body | |
| 355 | - })); | |
| 356 | - | |
| 357 | - // Debug: Log the positions we're trying to use | |
| 358 | - console.log('Attempting to post comments with positions:'); | |
| 359 | - comments.forEach(c => { | |
| 360 | - console.log(` ${c.path}: position ${c.position}`); | |
| 361 | - }); | |
| 362 | - | |
| 363 | - // Create the review | |
| 364 | - if (comments.length > 0) { | |
| 365 | - try { | |
| 366 | - let reviewBody = `${reviewData.review_summary || 'AI Code Review'}\n\n---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`; | |
| 367 | - | |
| 368 | - // Add triggered by note if from comment | |
| 369 | - if (context.eventName === 'issue_comment') { | |
| 370 | - reviewBody = `*Triggered by @${context.payload.comment.user.login}'s request*\n\n${reviewBody}`; | |
| 371 | - } | |
| 372 | - | |
| 373 | - await github.rest.pulls.createReview({ | |
| 374 | - owner: context.repo.owner, | |
| 375 | - repo: context.repo.repo, | |
| 376 | - pull_number: prNumber, | |
| 377 | - commit_id: commitSha, | |
| 378 | - body: reviewBody, | |
| 379 | - event: 'COMMENT', | |
| 380 | - comments: comments | |
| 381 | - }); | |
| 382 | - console.log(`Successfully created review with ${comments.length} inline comments`); | |
| 383 | - } catch (reviewError) { | |
| 384 | - console.log('Failed to create review:', reviewError.message); | |
| 385 | - | |
| 386 | - // Fallback: post as a regular comment if review creation fails | |
| 387 | - const fallbackBody = `## AI Code Review\n\n${reviewData.review_summary}\n\n` + | |
| 388 | - `*Failed to post ${comments.length} inline comments. Please review the changes manually.*\n\n` + | |
| 389 | - `---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`; | |
| 390 | - | |
| 391 | - await github.rest.issues.createComment({ | |
| 392 | - issue_number: prNumber, | |
| 393 | - owner: context.repo.owner, | |
| 394 | - repo: context.repo.repo, | |
| 395 | - body: fallbackBody | |
| 396 | - }); | |
| 397 | - } | |
| 398 | - } else { | |
| 399 | - // No inline comments, just post the summary | |
| 400 | - let summaryBody = `## AI Code Review\n\n${reviewData.review_summary}\n\n*No specific line comments generated.*\n\n` + | |
| 401 | - `---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`; | |
| 402 | - | |
| 403 | - // Add triggered by note if from comment | |
| 404 | - if (context.eventName === 'issue_comment') { | |
| 405 | - summaryBody = `*Triggered by @${context.payload.comment.user.login}'s request*\n\n${summaryBody}`; | |
| 406 | - } | |
| 407 | - | |
| 408 | - await github.rest.issues.createComment({ | |
| 409 | - issue_number: prNumber, | |
| 410 | - owner: context.repo.owner, | |
| 411 | - repo: context.repo.repo, | |
| 412 | - body: summaryBody | |
| 413 | - }); | |
| 414 | - } | |
| 415 | - | |
| 416 | - } catch (error) { | |
| 417 | - console.log('Failed to post review:', error.message); | |
| 418 | - console.log('Error details:', error); | |
| 419 | - } | |
| 420 | - env: | |
| 421 | - GITHUB_TOKEN: ${{ github.token }} | |
| 422 | - | |
| 423 | - - name: Upload Review Artifacts | |
| 424 | - if: env.SKIP_REVIEW != 'true' && always() | |
| 425 | - uses: actions/upload-artifact@v4 | |
| 426 | - with: | |
| 427 | - name: inline-review-results | |
| 428 | - path: | | |
| 429 | - inline_review_raw.json | |
| 430 | - inline_review.json | |
| 431 | - inline_review_prompt.txt | |
| 432 | - pr_diff.txt | |
| 433 | - pr_diff_annotated.txt | |
| 434 | - retention-days: 7 | |
| No newline at the end of the file |
deleted actions/detailed-review/annotate-diff.js +0 −96
| @@ -1,96 +0,0 @@ | ||
| 1 | -#!/usr/bin/env node | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Annotates a git diff with GitHub API positions | |
| 5 | - * | |
| 6 | - * Takes a raw diff and adds [POS:N] markers with the correct | |
| 7 | - * GitHub API positions (cumulative, with +1 between hunks) | |
| 8 | - */ | |
| 9 | - | |
| 10 | -const fs = require("fs"); | |
| 11 | - | |
| 12 | -function annotateDiff(diffContent) { | |
| 13 | - const lines = diffContent.split("\n"); | |
| 14 | - const output = []; | |
| 15 | - let githubPos = 0; | |
| 16 | - let inHunk = false; | |
| 17 | - | |
| 18 | - for (const line of lines) { | |
| 19 | - // Handle new file - reset position counter | |
| 20 | - if (line.startsWith("diff --git")) { | |
| 21 | - githubPos = 0; | |
| 22 | - inHunk = false; | |
| 23 | - output.push(line); | |
| 24 | - continue; | |
| 25 | - } | |
| 26 | - | |
| 27 | - // Pass through other git headers unchanged | |
| 28 | - if ( | |
| 29 | - line.startsWith("index ") || | |
| 30 | - line.startsWith("---") || | |
| 31 | - line.startsWith("+++") || | |
| 32 | - line.startsWith("rename ") || | |
| 33 | - line.startsWith("similarity ") || | |
| 34 | - line.startsWith("new file") || | |
| 35 | - line.startsWith("deleted file") || | |
| 36 | - line.startsWith("old mode") || | |
| 37 | - line.startsWith("new mode") || | |
| 38 | - line.startsWith("Binary files") | |
| 39 | - ) { | |
| 40 | - output.push(line); | |
| 41 | - continue; | |
| 42 | - } | |
| 43 | - | |
| 44 | - // Handle hunk headers | |
| 45 | - if (line.startsWith("@@")) { | |
| 46 | - if (inHunk) { | |
| 47 | - githubPos++; // GitHub's +1 between hunks | |
| 48 | - } | |
| 49 | - inHunk = true; | |
| 50 | - output.push(line); | |
| 51 | - continue; | |
| 52 | - } | |
| 53 | - | |
| 54 | - // Handle "no newline" marker - it counts as a position but isn't annotated | |
| 55 | - if (line.startsWith("\\ No newline")) { | |
| 56 | - if (inHunk) { | |
| 57 | - githubPos++; // GitHub counts this as a position | |
| 58 | - } | |
| 59 | - output.push(line); // Don't annotate it | |
| 60 | - continue; | |
| 61 | - } | |
| 62 | - | |
| 63 | - // Annotate actual diff lines with GitHub positions | |
| 64 | - if (inHunk) { | |
| 65 | - githubPos++; | |
| 66 | - output.push(`[POS:${githubPos}] ${line}`); | |
| 67 | - } else { | |
| 68 | - output.push(line); | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - return output.join("\n"); | |
| 73 | -} | |
| 74 | - | |
| 75 | -// Main | |
| 76 | -function main() { | |
| 77 | - // Read diff from stdin or file | |
| 78 | - let input = ""; | |
| 79 | - | |
| 80 | - if (process.argv.length > 2) { | |
| 81 | - // Read from file | |
| 82 | - input = fs.readFileSync(process.argv[2], "utf8"); | |
| 83 | - } else { | |
| 84 | - // Read from stdin | |
| 85 | - input = fs.readFileSync(0, "utf8"); | |
| 86 | - } | |
| 87 | - | |
| 88 | - const annotated = annotateDiff(input); | |
| 89 | - console.log(annotated); | |
| 90 | -} | |
| 91 | - | |
| 92 | -if (require.main === module) { | |
| 93 | - main(); | |
| 94 | -} | |
| 95 | - | |
| 96 | -module.exports = { annotateDiff }; |
deleted actions/detailed-review/annotate-diff.test.js +0 −363
| @@ -1,363 +0,0 @@ | ||
| 1 | -const { annotateDiff } = require("./annotate-diff.js"); | |
| 2 | - | |
| 3 | -describe("annotateDiff", () => { | |
| 4 | - test("single file, single hunk", () => { | |
| 5 | - const diff = `diff --git a/file.js b/file.js | |
| 6 | -index abc123..def456 100644 | |
| 7 | ---- a/file.js | |
| 8 | -+++ b/file.js | |
| 9 | -@@ -1,3 +1,4 @@ | |
| 10 | - line1 | |
| 11 | - line2 | |
| 12 | -+added line | |
| 13 | - line3`; | |
| 14 | - | |
| 15 | - const result = annotateDiff(diff); | |
| 16 | - expect(result).toContain("[POS:1] line1"); | |
| 17 | - expect(result).toContain("[POS:2] line2"); | |
| 18 | - expect(result).toContain("[POS:3] +added line"); | |
| 19 | - expect(result).toContain("[POS:4] line3"); | |
| 20 | - }); | |
| 21 | - | |
| 22 | - test("single file, multiple hunks with +1 between", () => { | |
| 23 | - const diff = `diff --git a/file.js b/file.js | |
| 24 | -index abc123..def456 100644 | |
| 25 | ---- a/file.js | |
| 26 | -+++ b/file.js | |
| 27 | -@@ -1,3 +1,3 @@ | |
| 28 | - line1 | |
| 29 | --old line | |
| 30 | -+new line | |
| 31 | - line3 | |
| 32 | -@@ -10,3 +10,3 @@ | |
| 33 | - line10 | |
| 34 | --old line 11 | |
| 35 | -+new line 11 | |
| 36 | - line12`; | |
| 37 | - | |
| 38 | - const result = annotateDiff(diff); | |
| 39 | - | |
| 40 | - // First hunk | |
| 41 | - expect(result).toContain("[POS:1] line1"); | |
| 42 | - expect(result).toContain("[POS:2] -old line"); | |
| 43 | - expect(result).toContain("[POS:3] +new line"); | |
| 44 | - expect(result).toContain("[POS:4] line3"); | |
| 45 | - | |
| 46 | - // Second hunk (should start at 6, because 4 lines + 1 for between hunks) | |
| 47 | - expect(result).toContain("[POS:6] line10"); | |
| 48 | - expect(result).toContain("[POS:7] -old line 11"); | |
| 49 | - expect(result).toContain("[POS:8] +new line 11"); | |
| 50 | - expect(result).toContain("[POS:9] line12"); | |
| 51 | - }); | |
| 52 | - | |
| 53 | - test("multiple files reset position counter", () => { | |
| 54 | - const diff = `diff --git a/file1.js b/file1.js | |
| 55 | -index abc123..def456 100644 | |
| 56 | ---- a/file1.js | |
| 57 | -+++ b/file1.js | |
| 58 | -@@ -1,2 +1,2 @@ | |
| 59 | - line1 | |
| 60 | --old | |
| 61 | -+new | |
| 62 | -diff --git a/file2.js b/file2.js | |
| 63 | -index abc123..def456 100644 | |
| 64 | ---- a/file2.js | |
| 65 | -+++ b/file2.js | |
| 66 | -@@ -1,2 +1,2 @@ | |
| 67 | - first | |
| 68 | --old2 | |
| 69 | -+new2`; | |
| 70 | - | |
| 71 | - const result = annotateDiff(diff); | |
| 72 | - | |
| 73 | - // File 1 | |
| 74 | - expect(result).toContain("[POS:1] line1"); | |
| 75 | - expect(result).toContain("[POS:2] -old"); | |
| 76 | - expect(result).toContain("[POS:3] +new"); | |
| 77 | - | |
| 78 | - // File 2 - positions should reset | |
| 79 | - const file2Section = result.split("diff --git a/file2.js")[1]; | |
| 80 | - expect(file2Section).toContain("[POS:1] first"); | |
| 81 | - expect(file2Section).toContain("[POS:2] -old2"); | |
| 82 | - expect(file2Section).toContain("[POS:3] +new2"); | |
| 83 | - }); | |
| 84 | - | |
| 85 | - test("handles new file", () => { | |
| 86 | - const diff = `diff --git a/newfile.js b/newfile.js | |
| 87 | -new file mode 100644 | |
| 88 | -index 0000000..abc123 | |
| 89 | ---- /dev/null | |
| 90 | -+++ b/newfile.js | |
| 91 | -@@ -0,0 +1,3 @@ | |
| 92 | -+line1 | |
| 93 | -+line2 | |
| 94 | -+line3`; | |
| 95 | - | |
| 96 | - const result = annotateDiff(diff); | |
| 97 | - expect(result).toContain("new file mode 100644"); | |
| 98 | - expect(result).toContain("[POS:1] +line1"); | |
| 99 | - expect(result).toContain("[POS:2] +line2"); | |
| 100 | - expect(result).toContain("[POS:3] +line3"); | |
| 101 | - }); | |
| 102 | - | |
| 103 | - test("handles deleted file", () => { | |
| 104 | - const diff = `diff --git a/deleted.js b/deleted.js | |
| 105 | -deleted file mode 100644 | |
| 106 | -index abc123..0000000 | |
| 107 | ---- a/deleted.js | |
| 108 | -+++ /dev/null | |
| 109 | -@@ -1,3 +0,0 @@ | |
| 110 | --line1 | |
| 111 | --line2 | |
| 112 | --line3`; | |
| 113 | - | |
| 114 | - const result = annotateDiff(diff); | |
| 115 | - expect(result).toContain("deleted file mode 100644"); | |
| 116 | - expect(result).toContain("[POS:1] -line1"); | |
| 117 | - expect(result).toContain("[POS:2] -line2"); | |
| 118 | - expect(result).toContain("[POS:3] -line3"); | |
| 119 | - }); | |
| 120 | - | |
| 121 | - test("handles renamed file with changes", () => { | |
| 122 | - const diff = `diff --git a/old-name.js b/new-name.js | |
| 123 | -similarity index 95% | |
| 124 | -rename from old-name.js | |
| 125 | -rename to new-name.js | |
| 126 | -index abc123..def456 100644 | |
| 127 | ---- a/old-name.js | |
| 128 | -+++ b/new-name.js | |
| 129 | -@@ -1,3 +1,3 @@ | |
| 130 | - line1 | |
| 131 | --old line | |
| 132 | -+new line | |
| 133 | - line3`; | |
| 134 | - | |
| 135 | - const result = annotateDiff(diff); | |
| 136 | - expect(result).toContain("rename from old-name.js"); | |
| 137 | - expect(result).toContain("rename to new-name.js"); | |
| 138 | - expect(result).toContain("[POS:1] line1"); | |
| 139 | - expect(result).toContain("[POS:2] -old line"); | |
| 140 | - expect(result).toContain("[POS:3] +new line"); | |
| 141 | - }); | |
| 142 | - | |
| 143 | - test("handles no newline at end of file", () => { | |
| 144 | - const diff = `diff --git a/file.js b/file.js | |
| 145 | -index abc123..def456 100644 | |
| 146 | ---- a/file.js | |
| 147 | -+++ b/file.js | |
| 148 | -@@ -1,2 +1,2 @@ | |
| 149 | - line1 | |
| 150 | --old line | |
| 151 | -\\ No newline at end of file | |
| 152 | -+new line | |
| 153 | -\\ No newline at end of file`; | |
| 154 | - | |
| 155 | - const result = annotateDiff(diff); | |
| 156 | - expect(result).toContain("[POS:1] line1"); | |
| 157 | - expect(result).toContain("[POS:2] -old line"); | |
| 158 | - // Position 3 is the first "No newline" marker (not annotated but counted) | |
| 159 | - expect(result).toContain("\\ No newline at end of file"); | |
| 160 | - expect(result).toContain("[POS:4] +new line"); // Position 4 due to "No newline" at position 3 | |
| 161 | - // Position 5 is the second "No newline" marker (not annotated but counted) | |
| 162 | - expect(result).toContain("\\ No newline at end of file"); | |
| 163 | - // No newline markers should not get [POS:N] annotations | |
| 164 | - expect(result).not.toContain("[POS:3] \\"); | |
| 165 | - expect(result).not.toContain("[POS:5] \\"); | |
| 166 | - }); | |
| 167 | - | |
| 168 | - test("handles file mode changes", () => { | |
| 169 | - const diff = `diff --git a/script.sh b/script.sh | |
| 170 | -old mode 100644 | |
| 171 | -new mode 100755 | |
| 172 | -index abc123..def456 100644 | |
| 173 | ---- a/script.sh | |
| 174 | -+++ b/script.sh | |
| 175 | -@@ -1,2 +1,2 @@ | |
| 176 | - #!/bin/bash | |
| 177 | --echo "old" | |
| 178 | -+echo "new"`; | |
| 179 | - | |
| 180 | - const result = annotateDiff(diff); | |
| 181 | - expect(result).toContain("old mode 100644"); | |
| 182 | - expect(result).toContain("new mode 100755"); | |
| 183 | - expect(result).toContain("[POS:1] #!/bin/bash"); | |
| 184 | - expect(result).toContain('[POS:2] -echo "old"'); | |
| 185 | - expect(result).toContain('[POS:3] +echo "new"'); | |
| 186 | - }); | |
| 187 | - | |
| 188 | - test("empty diff returns empty", () => { | |
| 189 | - const diff = ""; | |
| 190 | - const result = annotateDiff(diff); | |
| 191 | - expect(result).toBe(""); | |
| 192 | - }); | |
| 193 | - | |
| 194 | - test("handles binary files - modified", () => { | |
| 195 | - const diff = `diff --git a/image.png b/image.png | |
| 196 | -index abc123..def456 100644 | |
| 197 | -Binary files a/image.png and b/image.png differ`; | |
| 198 | - | |
| 199 | - const result = annotateDiff(diff); | |
| 200 | - expect(result).toContain("diff --git a/image.png b/image.png"); | |
| 201 | - expect(result).toContain("Binary files a/image.png and b/image.png differ"); | |
| 202 | - // Binary files line should not be annotated | |
| 203 | - expect(result).not.toContain("[POS:"); | |
| 204 | - }); | |
| 205 | - | |
| 206 | - test("handles binary files - added", () => { | |
| 207 | - const diff = `diff --git a/newimage.png b/newimage.png | |
| 208 | -new file mode 100644 | |
| 209 | -index 0000000..abc123 | |
| 210 | -Binary files /dev/null and b/newimage.png differ`; | |
| 211 | - | |
| 212 | - const result = annotateDiff(diff); | |
| 213 | - expect(result).toContain("diff --git a/newimage.png b/newimage.png"); | |
| 214 | - expect(result).toContain("new file mode 100644"); | |
| 215 | - expect(result).toContain( | |
| 216 | - "Binary files /dev/null and b/newimage.png differ", | |
| 217 | - ); | |
| 218 | - // Binary files line should not be annotated | |
| 219 | - expect(result).not.toContain("[POS:"); | |
| 220 | - }); | |
| 221 | - | |
| 222 | - test("handles binary files - deleted", () => { | |
| 223 | - const diff = `diff --git a/oldimage.png b/oldimage.png | |
| 224 | -deleted file mode 100644 | |
| 225 | -index abc123..0000000 | |
| 226 | -Binary files a/oldimage.png and /dev/null differ`; | |
| 227 | - | |
| 228 | - const result = annotateDiff(diff); | |
| 229 | - expect(result).toContain("diff --git a/oldimage.png b/oldimage.png"); | |
| 230 | - expect(result).toContain("deleted file mode 100644"); | |
| 231 | - expect(result).toContain( | |
| 232 | - "Binary files a/oldimage.png and /dev/null differ", | |
| 233 | - ); | |
| 234 | - // Binary files line should not be annotated | |
| 235 | - expect(result).not.toContain("[POS:"); | |
| 236 | - }); | |
| 237 | - | |
| 238 | - test("handles mixed text and binary files", () => { | |
| 239 | - const diff = `diff --git a/text.js b/text.js | |
| 240 | -index abc123..def456 100644 | |
| 241 | ---- a/text.js | |
| 242 | -+++ b/text.js | |
| 243 | -@@ -1,2 +1,2 @@ | |
| 244 | - line1 | |
| 245 | --old | |
| 246 | -+new | |
| 247 | -diff --git a/image.png b/image.png | |
| 248 | -index 111111..222222 100644 | |
| 249 | -Binary files a/image.png and b/image.png differ | |
| 250 | -diff --git a/another.js b/another.js | |
| 251 | -index 333333..444444 100644 | |
| 252 | ---- a/another.js | |
| 253 | -+++ b/another.js | |
| 254 | -@@ -1,1 +1,1 @@ | |
| 255 | --foo | |
| 256 | -+bar`; | |
| 257 | - | |
| 258 | - const result = annotateDiff(diff); | |
| 259 | - | |
| 260 | - // First file (text) | |
| 261 | - expect(result).toContain("[POS:1] line1"); | |
| 262 | - expect(result).toContain("[POS:2] -old"); | |
| 263 | - expect(result).toContain("[POS:3] +new"); | |
| 264 | - | |
| 265 | - // Second file (binary) - no positions | |
| 266 | - expect(result).toContain("Binary files a/image.png and b/image.png differ"); | |
| 267 | - | |
| 268 | - // Third file (text) - positions reset | |
| 269 | - const lastFileSection = result.split("diff --git a/another.js")[1]; | |
| 270 | - expect(lastFileSection).toContain("[POS:1] -foo"); | |
| 271 | - expect(lastFileSection).toContain("[POS:2] +bar"); | |
| 272 | - }); | |
| 273 | - | |
| 274 | - test("multiple no newline markers accumulate positions", () => { | |
| 275 | - const diff = `diff --git a/file.js b/file.js | |
| 276 | -index abc123..def456 100644 | |
| 277 | ---- a/file.js | |
| 278 | -+++ b/file.js | |
| 279 | -@@ -1,3 +1,3 @@ | |
| 280 | - line1 | |
| 281 | --old1 | |
| 282 | -\\ No newline at end of file | |
| 283 | -+new1 | |
| 284 | -\\ No newline at end of file | |
| 285 | -@@ -10,3 +10,3 @@ | |
| 286 | - line10 | |
| 287 | --old2 | |
| 288 | -\\ No newline at end of file | |
| 289 | -+new2 | |
| 290 | -\\ No newline at end of file`; | |
| 291 | - | |
| 292 | - const result = annotateDiff(diff); | |
| 293 | - | |
| 294 | - // First hunk | |
| 295 | - expect(result).toContain("[POS:1] line1"); | |
| 296 | - expect(result).toContain("[POS:2] -old1"); | |
| 297 | - // Position 3 is the first "No newline" marker | |
| 298 | - expect(result).toContain("[POS:4] +new1"); | |
| 299 | - // Position 5 is the second "No newline" marker | |
| 300 | - | |
| 301 | - // Second hunk (starts at position 7 = 5 + 1 for between hunks + 1) | |
| 302 | - expect(result).toContain("[POS:7] line10"); | |
| 303 | - expect(result).toContain("[POS:8] -old2"); | |
| 304 | - // Position 9 is the third "No newline" marker | |
| 305 | - expect(result).toContain("[POS:10] +new2"); | |
| 306 | - // Position 11 is the fourth "No newline" marker | |
| 307 | - | |
| 308 | - // Verify "No newline" markers are not annotated | |
| 309 | - expect(result).not.toContain("[POS:3] \\"); | |
| 310 | - expect(result).not.toContain("[POS:5] \\"); | |
| 311 | - expect(result).not.toContain("[POS:9] \\"); | |
| 312 | - expect(result).not.toContain("[POS:11] \\"); | |
| 313 | - }); | |
| 314 | - | |
| 315 | - test("complex multi-file, multi-hunk diff", () => { | |
| 316 | - const diff = `diff --git a/src/app.js b/src/app.js | |
| 317 | -index abc123..def456 100644 | |
| 318 | ---- a/src/app.js | |
| 319 | -+++ b/src/app.js | |
| 320 | -@@ -10,4 +10,5 @@ function example() { | |
| 321 | - console.log("start"); | |
| 322 | - const x = 1; | |
| 323 | -- const y = 2; | |
| 324 | -+ const y = 3; | |
| 325 | -+ const z = 4; | |
| 326 | - return x + y; | |
| 327 | -@@ -20,3 +21,4 @@ function another() { | |
| 328 | - let a = 1; | |
| 329 | - let b = 2; | |
| 330 | -+ let c = 3; | |
| 331 | - return a + b; | |
| 332 | -diff --git a/src/util.js b/src/util.js | |
| 333 | -index 111111..222222 100644 | |
| 334 | ---- a/src/util.js | |
| 335 | -+++ b/src/util.js | |
| 336 | -@@ -1,2 +1,3 @@ | |
| 337 | -+import fs from 'fs'; | |
| 338 | - export function util() { | |
| 339 | - return true;`; | |
| 340 | - | |
| 341 | - const result = annotateDiff(diff); | |
| 342 | - | |
| 343 | - // src/app.js - first hunk | |
| 344 | - expect(result).toContain('[POS:1] console.log("start");'); | |
| 345 | - expect(result).toContain("[POS:2] const x = 1;"); | |
| 346 | - expect(result).toContain("[POS:3] - const y = 2;"); | |
| 347 | - expect(result).toContain("[POS:4] + const y = 3;"); | |
| 348 | - expect(result).toContain("[POS:5] + const z = 4;"); | |
| 349 | - expect(result).toContain("[POS:6] return x + y;"); | |
| 350 | - | |
| 351 | - // src/app.js - second hunk (7 = 6 + 1 for between hunks) | |
| 352 | - expect(result).toContain("[POS:8] let a = 1;"); | |
| 353 | - expect(result).toContain("[POS:9] let b = 2;"); | |
| 354 | - expect(result).toContain("[POS:10] + let c = 3;"); | |
| 355 | - expect(result).toContain("[POS:11] return a + b;"); | |
| 356 | - | |
| 357 | - // src/util.js - new file, positions reset | |
| 358 | - const utilSection = result.split("diff --git a/src/util.js")[1]; | |
| 359 | - expect(utilSection).toContain("[POS:1] +import fs from 'fs';"); | |
| 360 | - expect(utilSection).toContain("[POS:2] export function util() {"); | |
| 361 | - expect(utilSection).toContain("[POS:3] return true;"); | |
| 362 | - }); | |
| 363 | -}); |
deleted actions/detailed-review/package.json +0 −19
| @@ -1,19 +0,0 @@ | ||
| 1 | -{ | |
| 2 | - "name": "@continue/pr-review-scripts", | |
| 3 | - "version": "1.0.0", | |
| 4 | - "private": true, | |
| 5 | - "description": "Scripts for Continue PR Review Action", | |
| 6 | - "scripts": { | |
| 7 | - "test": "jest", | |
| 8 | - "test:watch": "jest --watch" | |
| 9 | - }, | |
| 10 | - "devDependencies": { | |
| 11 | - "jest": "^29.7.0" | |
| 12 | - }, | |
| 13 | - "jest": { | |
| 14 | - "testEnvironment": "node", | |
| 15 | - "testMatch": [ | |
| 16 | - "**/*.test.js" | |
| 17 | - ] | |
| 18 | - } | |
| 19 | -} |
modified actions/general-review/action.yml +316 −81
| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | shell: bash |
| 24 | 24 | env: |
| 25 | 25 | # Only move the dangerous check to env to prevent shell injection |
| 26 | - HAS_TRIGGER_PHRASE: ${{ contains(github.event.comment.body, '@continue-general-review') }} | |
| 26 | + HAS_TRIGGER_PHRASE: ${{ contains(github.event.comment.body, '@continue-review') }} | |
| 27 | 27 | run: | |
| 28 | 28 | # Check if this action should run based on event type and user permissions |
| 29 | 29 | SHOULD_RUN="false" |
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | echo "::notice::Skipping review - Commenter is not a team member (association: $COMMENTER_ASSOC)" |
| 52 | 52 | fi |
| 53 | 53 | else |
| 54 | - echo "::notice::Skipping review - Comment does not contain @continue-general-review trigger, or is not on a PR" | |
| 54 | + echo "::notice::Skipping review - Comment does not contain @continue-review trigger, or is not on a PR" | |
| 55 | 55 | fi |
| 56 | 56 | else |
| 57 | 57 | echo "::notice::Skipping review - Unsupported event type: ${{ github.event_name }}" |
| @@ -70,11 +70,97 @@ | ||
| 70 | 70 | shell: bash |
| 71 | 71 | run: npm install -g @continuedev/cli@1.4.30 |
| 72 | 72 | |
| 73 | + - name: Post Initial Comment | |
| 74 | + if: env.SHOULD_RUN == 'true' | |
| 75 | + id: initial-comment | |
| 76 | + uses: actions/github-script@v7 | |
| 77 | + with: | |
| 78 | + script: | | |
| 79 | + const marker = '<!-- continue-agent-review -->'; | |
| 80 | + | |
| 81 | + // Get PR number based on event type | |
| 82 | + let prNumber; | |
| 83 | + if (context.eventName === 'pull_request') { | |
| 84 | + prNumber = context.payload.pull_request.number; | |
| 85 | + } else { | |
| 86 | + // For issue_comment event | |
| 87 | + prNumber = context.payload.issue.number; | |
| 88 | + } | |
| 89 | + | |
| 90 | + // Check for existing comment | |
| 91 | + const { data: comments } = await github.rest.issues.listComments({ | |
| 92 | + owner: context.repo.owner, | |
| 93 | + repo: context.repo.repo, | |
| 94 | + issue_number: prNumber, | |
| 95 | + per_page: 100 | |
| 96 | + }); | |
| 97 | + | |
| 98 | + // Find existing Continue review comment | |
| 99 | + const existingComment = comments | |
| 100 | + .filter(c => c.body && c.body.includes(marker)) | |
| 101 | + .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0]; | |
| 102 | + | |
| 103 | + // Get workflow run URL | |
| 104 | + const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| 105 | + | |
| 106 | + // Create initial "review in progress" message | |
| 107 | + let initialMessage = `${marker}\n**🔄 Review In Progress**\n\n`; | |
| 108 | + | |
| 109 | + if (context.eventName === 'issue_comment') { | |
| 110 | + initialMessage = `${marker}\n**🔄 Review In Progress**\n\n*Triggered by @${context.payload.comment.user.login}'s request*\n\n`; | |
| 111 | + } | |
| 112 | + | |
| 113 | + initialMessage += `Continue AI is analyzing the code changes...\n\n`; | |
| 114 | + initialMessage += `📊 **Review Scope:**\n`; | |
| 115 | + initialMessage += `- Repository: ${context.repo.owner}/${context.repo.repo}\n`; | |
| 116 | + initialMessage += `- PR #${prNumber}\n\n`; | |
| 117 | + initialMessage += `⏱️ This typically takes 1-2 minutes.\n\n`; | |
| 118 | + initialMessage += `[View live progress →](${workflowRunUrl})\n\n`; | |
| 119 | + initialMessage += `---\n<!-- ${new Date().toISOString()} | Powered by Continue (https://continue.dev) -->`; | |
| 120 | + | |
| 121 | + if (existingComment) { | |
| 122 | + // Check if comment is less than 1 hour old | |
| 123 | + const commentAge = Date.now() - new Date(existingComment.created_at).getTime(); | |
| 124 | + const oneHour = 60 * 60 * 1000; | |
| 125 | + | |
| 126 | + if (commentAge < oneHour) { | |
| 127 | + // Update existing comment if less than 1 hour old | |
| 128 | + await github.rest.issues.updateComment({ | |
| 129 | + owner: context.repo.owner, | |
| 130 | + repo: context.repo.repo, | |
| 131 | + comment_id: existingComment.id, | |
| 132 | + body: initialMessage | |
| 133 | + }); | |
| 134 | + console.log(`Updated existing comment ${existingComment.id} to show review in progress`); | |
| 135 | + core.setOutput('comment_id', existingComment.id); | |
| 136 | + } else { | |
| 137 | + // Create new comment if older than 1 hour (preserve history) | |
| 138 | + const { data: comment } = await github.rest.issues.createComment({ | |
| 139 | + issue_number: prNumber, | |
| 140 | + owner: context.repo.owner, | |
| 141 | + repo: context.repo.repo, | |
| 142 | + body: initialMessage | |
| 143 | + }); | |
| 144 | + console.log(`Created new comment ${comment.id} showing review in progress`); | |
| 145 | + core.setOutput('comment_id', comment.id); | |
| 146 | + } | |
| 147 | + } else { | |
| 148 | + // Create new comment | |
| 149 | + const { data: comment } = await github.rest.issues.createComment({ | |
| 150 | + issue_number: prNumber, | |
| 151 | + owner: context.repo.owner, | |
| 152 | + repo: context.repo.repo, | |
| 153 | + body: initialMessage | |
| 154 | + }); | |
| 155 | + console.log(`Created new comment ${comment.id} on PR #${prNumber}`); | |
| 156 | + core.setOutput('comment_id', comment.id); | |
| 157 | + } | |
| 158 | + | |
| 73 | 159 | - name: Build PR Review Prompt |
| 74 | 160 | if: env.SHOULD_RUN == 'true' |
| 75 | 161 | shell: bash |
| 76 | 162 | env: |
| 77 | - GH_TOKEN: ${{ github.token }} | |
| 163 | + GITHUB_TOKEN: ${{ github.token }} | |
| 78 | 164 | run: | |
| 79 | 165 | # Get PR number based on event type |
| 80 | 166 | if [ "${{ github.event_name }}" = "pull_request" ]; then |
| @@ -87,60 +173,58 @@ | ||
| 87 | 173 | # Get PR diff |
| 88 | 174 | gh pr diff $PR_NUMBER > pr_diff.txt |
| 89 | 175 | |
| 176 | + # Get PR details | |
| 177 | + PR_TITLE=$(gh pr view $PR_NUMBER --json title -q .title) | |
| 178 | + PR_AUTHOR=$(gh pr view $PR_NUMBER --json author -q .author.login) | |
| 179 | + PR_BODY=$(gh pr view $PR_NUMBER --json body -q .body) | |
| 180 | + FILES_CHANGED=$(gh pr view $PR_NUMBER --json files -q '.files | length') | |
| 181 | + | |
| 90 | 182 | # Create review prompt |
| 91 | - cat > review_prompt.txt << 'EOF' | |
| 92 | - You are conducting a code review for a pull request. Below is the git diff showing all the changes: | |
| 93 | - | |
| 183 | + cat > review_prompt.txt << EOF | |
| 184 | + You are reviewing a pull request. Please provide helpful, context-aware feedback. | |
| 185 | + | |
| 186 | + CONTEXT: | |
| 187 | + - Repository: ${{ github.repository }} | |
| 188 | + - PR #$PR_NUMBER: $PR_TITLE | |
| 189 | + - Files Changed: $FILES_CHANGED | |
| 190 | + - Author: $PR_AUTHOR | |
| 191 | + | |
| 192 | + REVIEW APPROACH: | |
| 193 | + 1. First, understand what this PR is trying to accomplish | |
| 194 | + 2. Check if similar patterns exist elsewhere in the codebase | |
| 195 | + 3. Focus on actual issues that affect functionality | |
| 196 | + 4. Be constructive and suggest solutions when possible | |
| 197 | + | |
| 198 | + FOCUS ON: | |
| 199 | + - Bugs that will cause failures or incorrect behavior | |
| 200 | + - Security vulnerabilities (exposed secrets, injection risks) | |
| 201 | + - Breaking changes that affect other parts of the system | |
| 202 | + - Performance issues with real impact (memory leaks, O(n²) algorithms) | |
| 203 | + - Missing tests for new features or bug fixes | |
| 204 | + - Missing documentation for APIs or complex logic | |
| 205 | + | |
| 206 | + SKIP COMMENTING ON: | |
| 207 | + - Style and formatting (handled by linters) | |
| 208 | + - Alternative approaches unless current is broken | |
| 209 | + - Minor naming unless genuinely confusing | |
| 210 | + - Trivial documentation for self-explanatory code | |
| 211 | + | |
| 212 | + Be specific with line numbers and explain why something is an issue. | |
| 213 | + | |
| 214 | + PR Description: ${PR_BODY:-No description provided} | |
| 215 | + | |
| 216 | + Code Changes: | |
| 94 | 217 | EOF |
| 95 | 218 | |
| 96 | - echo "--- PR DIFF START ---" >> review_prompt.txt | |
| 219 | + # Add the diff | |
| 97 | 220 | cat pr_diff.txt >> review_prompt.txt |
| 98 | - echo "--- PR DIFF END ---" >> review_prompt.txt | |
| 99 | - | |
| 221 | + | |
| 100 | 222 | cat >> review_prompt.txt << 'EOF' |
| 101 | 223 | |
| 102 | - Please analyze these changes and provide a comprehensive code review. Consider: | |
| 103 | - | |
| 104 | - 1. **Code Quality**: Are there any bugs, performance issues, or code smells? | |
| 105 | - 2. **Best Practices**: Does the code follow established patterns and conventions? | |
| 106 | - 3. **Security**: Are there any potential security vulnerabilities? | |
| 107 | - 4. **Testing**: Are appropriate tests included or updated? | |
| 108 | - 5. **Documentation**: Is documentation adequate for the changes? | |
| 109 | - 6. **Architecture**: Do the changes fit well with the existing codebase structure? | |
| 110 | - | |
| 111 | - You can use the available tools to explore the codebase and understand context better. | |
| 112 | - | |
| 113 | - Format your response as a markdown code review with the following structure: | |
| 114 | - | |
| 115 | - ## Code Review Summary | |
| 116 | - | |
| 117 | - ### ✅ Strengths | |
| 118 | - - **[Aspect]**: [Description of what was done well] | |
| 119 | - | |
| 120 | - ### ⚠️ Issues Found | |
| 121 | - | |
| 122 | - Only include the severity subheaders below if you actually found issues at that level: | |
| 123 | - | |
| 124 | - #### Critical | |
| 125 | - - **[Issue Title]**: [Description of critical issues that must be fixed before merging] | |
| 126 | - | |
| 127 | - #### High | |
| 128 | - - **[Issue Title]**: [Description of high-priority issues that should be fixed] | |
| 129 | - | |
| 130 | - #### Medium | |
| 131 | - - **[Issue Title]**: [Description of issues that should be addressed] | |
| 132 | - | |
| 133 | - #### Low | |
| 134 | - - **[Issue Title]**: [Description of minor issues or nice-to-have improvements] | |
| 135 | - | |
| 136 | - | |
| 137 | - ### 💡 Suggestions | |
| 138 | - - **[Suggestion Title]**: [Description of improvement recommendations] | |
| 139 | - | |
| 140 | - ### 🚀 Overall Assessment | |
| 141 | - [Provide overall recommendation: APPROVE, REQUEST_CHANGES, or COMMENT] | |
| 142 | - | |
| 143 | - Only call the 'exit' tool if you find critical security vulnerabilities or bugs that would break production. | |
| 224 | + Your Review: | |
| 225 | + Please provide constructive feedback on the code changes. | |
| 226 | + Focus on issues that matter for functionality, security, and maintainability. | |
| 227 | + If the code looks good overall, acknowledge that while noting any minor suggestions. | |
| 144 | 228 | EOF |
| 145 | 229 | |
| 146 | 230 | - name: Run Continue CLI Review |
| @@ -150,10 +234,12 @@ | ||
| 150 | 234 | CONTINUE_API_KEY: ${{ inputs.continue-api-key }} |
| 151 | 235 | CONTINUE_ORG: ${{ inputs.continue-org }} |
| 152 | 236 | CONTINUE_CONFIG: ${{ inputs.continue-config }} |
| 237 | + GITHUB_TOKEN: ${{ github.token }} | |
| 153 | 238 | run: | |
| 154 | 239 | echo "Running Continue CLI with prompt:" |
| 155 | 240 | echo "==================================" |
| 156 | - cat review_prompt.txt | |
| 241 | + head -n 100 review_prompt.txt | |
| 242 | + echo "... [truncated] ..." | |
| 157 | 243 | echo "==================================" |
| 158 | 244 | echo "" |
| 159 | 245 | |
| @@ -189,7 +275,7 @@ | ||
| 189 | 275 | # Test Continue CLI availability |
| 190 | 276 | if [ "$SKIP_CLI" != "true" ]; then |
| 191 | 277 | echo "Testing Continue CLI..." |
| 192 | - if ! cn --version; then | |
| 278 | + if ! which cn > /dev/null 2>&1; then | |
| 193 | 279 | echo "Warning: Continue CLI not found or not working" |
| 194 | 280 | cat > code_review.md << 'EOF' |
| 195 | 281 | ## Code Review Summary |
| @@ -202,7 +288,8 @@ | ||
| 202 | 288 | EOF |
| 203 | 289 | echo "SKIP_CLI=true" >> $GITHUB_ENV |
| 204 | 290 | else |
| 205 | - echo "Continue CLI version: $(cn --version)" | |
| 291 | + echo "Continue CLI found at: $(which cn)" | |
| 292 | + echo "Continue CLI version: $(cn --version 2>/dev/null || echo 'version check failed')" | |
| 206 | 293 | fi |
| 207 | 294 | fi |
| 208 | 295 | |
| @@ -210,30 +297,78 @@ | ||
| 210 | 297 | if [ "$SKIP_CLI" != "true" ]; then |
| 211 | 298 | echo "Executing Continue CLI with config: $CONTINUE_ORG/$CONTINUE_CONFIG" |
| 212 | 299 | |
| 213 | - # Write prompt to temp file for better handling | |
| 214 | - PROMPT_FILE="/tmp/continue-prompt-$.txt" | |
| 300 | + # Write prompt to temp file for headless mode | |
| 301 | + PROMPT_FILE="/tmp/continue-review-$RANDOM.txt" | |
| 215 | 302 | cp review_prompt.txt "$PROMPT_FILE" |
| 303 | + echo "Prompt file: $PROMPT_FILE" | |
| 304 | + echo "Prompt length: $(wc -c < "$PROMPT_FILE") characters" | |
| 216 | 305 | |
| 217 | - # Use timeout to prevent hanging (240 seconds = 4 minutes) | |
| 218 | - if ! timeout 240 cn --config "$CONTINUE_ORG/$CONTINUE_CONFIG" -p "@$PROMPT_FILE" --allow Bash > code_review.md 2>cli_error.log; then | |
| 219 | - echo "Error: Continue CLI command failed" | |
| 220 | - echo "CLI error log:" | |
| 221 | - cat cli_error.log | |
| 306 | + # Use timeout to prevent hanging (360 seconds = 6 minutes) | |
| 307 | + echo "Executing command: cn --config $CONTINUE_ORG/$CONTINUE_CONFIG -p @$PROMPT_FILE --allow Bash" | |
| 222 | 308 | |
| 223 | - # Create fallback review | |
| 224 | - cat > code_review.md << 'EOF' | |
| 309 | + if timeout 360 cn --config "$CONTINUE_ORG/$CONTINUE_CONFIG" -p "@$PROMPT_FILE" --allow Bash > code_review_raw.md 2>cli_error.log; then | |
| 310 | + echo "Continue CLI completed successfully" | |
| 311 | + echo "Raw output length: $(wc -c < code_review_raw.md) characters" | |
| 312 | + | |
| 313 | + # Clean up ANSI codes if any | |
| 314 | + sed 's/\x1b\[[0-9;]*m//g' code_review_raw.md > code_review.md | |
| 315 | + | |
| 316 | + echo "Cleaned output length: $(wc -c < code_review.md) characters" | |
| 317 | + echo "First 500 chars of output:" | |
| 318 | + head -c 500 code_review.md | |
| 319 | + echo "" | |
| 320 | + | |
| 321 | + # Check if output is empty | |
| 322 | + if [ ! -s code_review.md ]; then | |
| 323 | + echo "Warning: Continue CLI returned empty output" | |
| 324 | + cat > code_review.md << 'EOF' | |
| 325 | + ## Code Review Summary | |
| 326 | + | |
| 327 | + ⚠️ Continue CLI returned an empty response. Please check the configuration. | |
| 328 | + EOF | |
| 329 | + fi | |
| 330 | + else | |
| 331 | + echo "Error: Continue CLI command failed with exit code $?" | |
| 332 | + echo "CLI error log:" | |
| 333 | + cat cli_error.log | |
| 334 | + | |
| 335 | + # Check for specific error patterns | |
| 336 | + if grep -q "not found\|ENOENT" cli_error.log 2>/dev/null; then | |
| 337 | + cat > code_review.md << 'EOF' | |
| 338 | + ## Code Review Summary | |
| 339 | + | |
| 340 | + ⚠️ Continue CLI is not properly installed. Please ensure @continuedev/cli is installed globally. | |
| 341 | + EOF | |
| 342 | + elif grep -q "config\|assistant" cli_error.log 2>/dev/null; then | |
| 343 | + cat > code_review.md << 'EOF' | |
| 344 | + ## Code Review Summary | |
| 345 | + | |
| 346 | + ⚠️ Continue configuration error. Please verify that the assistant exists in Continue Hub. | |
| 347 | + EOF | |
| 348 | + elif grep -q "api\|auth" cli_error.log 2>/dev/null; then | |
| 349 | + cat > code_review.md << 'EOF' | |
| 350 | + ## Code Review Summary | |
| 351 | + | |
| 352 | + ⚠️ Continue API authentication failed. Please check your CONTINUE_API_KEY. | |
| 353 | + EOF | |
| 354 | + else | |
| 355 | + cat > code_review.md << 'EOF' | |
| 225 | 356 | ## Code Review Summary |
| 226 | 357 | |
| 227 | - ⚠️ AI review failed due to service initialization issues. Please check the Continue API key and configuration. | |
| 358 | + ⚠️ AI review failed. Please check the Continue API key and configuration. | |
| 228 | 359 | |
| 229 | 360 | ### Troubleshooting |
| 230 | 361 | - Verify the CONTINUE_API_KEY secret is set correctly |
| 231 | 362 | - Check that the organization and config path are valid |
| 232 | 363 | - Ensure the Continue service is accessible |
| 233 | 364 | EOF |
| 365 | + fi | |
| 366 | + fi | |
| 367 | + | |
| 368 | + # Clean up temp file | |
| 369 | + rm -f "$PROMPT_FILE" | |
| 234 | 370 | else |
| 235 | - echo "Review generated successfully" | |
| 236 | - fi | |
| 371 | + echo "Review generation successfully completed" | |
| 237 | 372 | fi |
| 238 | 373 | |
| 239 | 374 | - name: Upload Review Results |
| @@ -247,7 +382,7 @@ | ||
| 247 | 382 | pr_diff.txt |
| 248 | 383 | retention-days: 30 |
| 249 | 384 | |
| 250 | - - name: Comment PR with Review | |
| 385 | + - name: Update Comment with Review | |
| 251 | 386 | if: env.SHOULD_RUN == 'true' && always() |
| 252 | 387 | uses: actions/github-script@v7 |
| 253 | 388 | with: |
| @@ -256,13 +391,15 @@ | ||
| 256 | 391 | |
| 257 | 392 | try { |
| 258 | 393 | let reviewContent = ''; |
| 259 | - | |
| 394 | + | |
| 260 | 395 | if (fs.existsSync('code_review.md') && fs.statSync('code_review.md').size > 0) { |
| 261 | 396 | reviewContent = fs.readFileSync('code_review.md', 'utf8'); |
| 262 | 397 | } else { |
| 263 | - reviewContent = '⚠️ AI review completed but no review output was generated. Check the action logs for details.'; | |
| 398 | + // Build direct link to workflow logs | |
| 399 | + const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| 400 | + reviewContent = `⚠️ AI review completed but no review output was generated.\n\n**Likely cause:** Expired CONTINUE_API_KEY or missing continuedev/review-bot assistant\n\n[📋 View workflow logs](${workflowRunUrl}) for details.`; | |
| 264 | 401 | } |
| 265 | - | |
| 402 | + | |
| 266 | 403 | // Get PR number based on event type |
| 267 | 404 | let prNumber; |
| 268 | 405 | if (context.eventName === 'pull_request') { |
| @@ -277,17 +414,115 @@ | ||
| 277 | 414 | reviewContent = `*Triggered by @${context.payload.comment.user.login}'s request*\n\n${reviewContent}`; |
| 278 | 415 | } |
| 279 | 416 | |
| 280 | - // Add instructions for re-review | |
| 281 | - reviewContent += '\n\n---\n*💡 To request a new review, comment `@continue-general-review`*'; | |
| 282 | - | |
| 283 | - // Create new comment | |
| 284 | - await github.rest.issues.createComment({ | |
| 285 | - issue_number: prNumber, | |
| 286 | - owner: context.repo.owner, | |
| 287 | - repo: context.repo.repo, | |
| 288 | - body: reviewContent | |
| 289 | - }); | |
| 290 | - console.log(`Successfully created new comment on PR #${prNumber}`); | |
| 417 | + // Add footer with timestamp and branding | |
| 418 | + const timestamp = new Date().toISOString(); | |
| 419 | + reviewContent += `\n\n---\n<!-- ${timestamp} | Powered by Continue (https://continue.dev) -->`; | |
| 420 | + | |
| 421 | + // Look for existing review comment to update (sticky comment) | |
| 422 | + const marker = '<!-- continue-agent-review -->'; | |
| 423 | + | |
| 424 | + // Try to get comment_id from the initial comment step | |
| 425 | + const initialCommentId = '${{ steps.initial-comment.outputs.comment_id }}'; | |
| 426 | + | |
| 427 | + if (initialCommentId && initialCommentId !== '') { | |
| 428 | + // We have the comment ID from the initial step, use it directly | |
| 429 | + reviewContent = `${marker}\n**✅ Review Complete**\n\n${reviewContent}`; | |
| 430 | + | |
| 431 | + try { | |
| 432 | + await github.rest.issues.updateComment({ | |
| 433 | + owner: context.repo.owner, | |
| 434 | + repo: context.repo.repo, | |
| 435 | + comment_id: parseInt(initialCommentId), | |
| 436 | + body: reviewContent | |
| 437 | + }); | |
| 438 | + console.log(`Updated comment ${initialCommentId} with review results`); | |
| 439 | + } catch (updateError) { | |
| 440 | + console.log(`Failed to update comment ${initialCommentId}, will search for it instead:`, updateError.message); | |
| 441 | + | |
| 442 | + // Fallback: search for the comment | |
| 443 | + const { data: comments } = await github.rest.issues.listComments({ | |
| 444 | + owner: context.repo.owner, | |
| 445 | + repo: context.repo.repo, | |
| 446 | + issue_number: prNumber, | |
| 447 | + per_page: 100 | |
| 448 | + }); | |
| 449 | + | |
| 450 | + // Find existing Continue review comment | |
| 451 | + const existingComment = comments | |
| 452 | + .filter(c => c.body && c.body.includes(marker)) | |
| 453 | + .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0]; | |
| 454 | + | |
| 455 | + if (existingComment) { | |
| 456 | + await github.rest.issues.updateComment({ | |
| 457 | + owner: context.repo.owner, | |
| 458 | + repo: context.repo.repo, | |
| 459 | + comment_id: existingComment.id, | |
| 460 | + body: reviewContent | |
| 461 | + }); | |
| 462 | + console.log(`Updated existing comment ${existingComment.id} via search`); | |
| 463 | + } else { | |
| 464 | + // Create new comment as last resort | |
| 465 | + await github.rest.issues.createComment({ | |
| 466 | + issue_number: prNumber, | |
| 467 | + owner: context.repo.owner, | |
| 468 | + repo: context.repo.repo, | |
| 469 | + body: reviewContent | |
| 470 | + }); | |
| 471 | + console.log(`Created new comment on PR #${prNumber} as fallback`); | |
| 472 | + } | |
| 473 | + } | |
| 474 | + } else { | |
| 475 | + // No initial comment ID, search for existing comment | |
| 476 | + const { data: comments } = await github.rest.issues.listComments({ | |
| 477 | + owner: context.repo.owner, | |
| 478 | + repo: context.repo.repo, | |
| 479 | + issue_number: prNumber, | |
| 480 | + per_page: 100 | |
| 481 | + }); | |
| 482 | + | |
| 483 | + // Find existing Continue review comment | |
| 484 | + const existingComment = comments | |
| 485 | + .filter(c => c.body && c.body.includes(marker)) | |
| 486 | + .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0]; | |
| 487 | + | |
| 488 | + // Add marker and review status | |
| 489 | + reviewContent = `${marker}\n**✅ Review Complete**\n\n${reviewContent}`; | |
| 490 | + | |
| 491 | + if (existingComment) { | |
| 492 | + // Check if comment is less than 1 hour old | |
| 493 | + const commentAge = Date.now() - new Date(existingComment.created_at).getTime(); | |
| 494 | + const oneHour = 60 * 60 * 1000; | |
| 495 | + | |
| 496 | + if (commentAge < oneHour) { | |
| 497 | + // Update existing comment if less than 1 hour old | |
| 498 | + await github.rest.issues.updateComment({ | |
| 499 | + owner: context.repo.owner, | |
| 500 | + repo: context.repo.repo, | |
| 501 | + comment_id: existingComment.id, | |
| 502 | + body: reviewContent | |
| 503 | + }); | |
| 504 | + console.log(`Updated existing comment ${existingComment.id} (${Math.round(commentAge / 1000 / 60)} minutes old)`); | |
| 505 | + } else { | |
| 506 | + // Create new comment if older than 1 hour (preserve history) | |
| 507 | + await github.rest.issues.createComment({ | |
| 508 | + issue_number: prNumber, | |
| 509 | + owner: context.repo.owner, | |
| 510 | + repo: context.repo.repo, | |
| 511 | + body: reviewContent | |
| 512 | + }); | |
| 513 | + console.log(`Created new comment (existing comment was ${Math.round(commentAge / 1000 / 60)} minutes old)`); | |
| 514 | + } | |
| 515 | + } else { | |
| 516 | + // Create new comment | |
| 517 | + await github.rest.issues.createComment({ | |
| 518 | + issue_number: prNumber, | |
| 519 | + owner: context.repo.owner, | |
| 520 | + repo: context.repo.repo, | |
| 521 | + body: reviewContent | |
| 522 | + }); | |
| 523 | + console.log(`Created new comment on PR #${prNumber}`); | |
| 524 | + } | |
| 525 | + } | |
| 291 | 526 | } catch (error) { |
| 292 | 527 | console.log('Failed to post comment:', error.message); |
| 293 | 528 | console.log('Error details:', error); |