From a831f0d797555d66d3c5fc70ee03d4ef8ff42f5c Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Mon, 29 Dec 2025 13:00:03 -0500 Subject: [PATCH 1/4] Add Review workflow --- .github/workflows/bonk-review.yml | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/bonk-review.yml diff --git a/.github/workflows/bonk-review.yml b/.github/workflows/bonk-review.yml new file mode 100644 index 000000000000000..3a5eacfe1496426 --- /dev/null +++ b/.github/workflows/bonk-review.yml @@ -0,0 +1,77 @@ +name: Review + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + +jobs: + review: + if: github.event.sender.type != 'Bot' + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + issues: write + pull-requests: write + steps: + - name: Get PR number + id: pr-number + run: | + if [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then + echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + else + echo "number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT + fi + + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Get PR details + id: pr-details + run: | + gh api /repos/${{ github.repository }}/pulls/${{ steps.pr-number.outputs.number }} > /tmp/pr_data.json + echo "title=$(jq -r .title /tmp/pr_data.json)" >> $GITHUB_OUTPUT + echo "sha=$(jq -r .head.sha /tmp/pr_data.json)" >> $GITHUB_OUTPUT + { + echo 'body<> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Bonk + uses: ask-bonk/ask-bonk/github@main + env: + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} + with: + model: opencode/claude-opus-4-5 + mentions: '/review' + permissions: write + agent: reviewer + prompt: | + Review the following pull request (title: ${{ steps.pr-details.outputs.title }}) against the below review guidelines: + + Please check all the code changes in this pull request against the style guide, also look for any bugs if they exist. Diffs are important but make sure you read the entire file to get proper context. Make it clear the suggestions are merely suggestions and the human can decide what to do. + + Refer to AGENTS.md and any additional instructions for our style guide, conventions and repo-wide rules. + + 1. Focus on actual violations and bugs. Where possible, comment on the exact line number to help guide the reviewer. + 2. Break up "needs fixing" (real logic bugs, poor error handling, security issues) vs. "suggestions" (nested logic, unused code, code structure/maintenance guidance) when responding so that a human has clear, actionable feedback. + 3. Use the gh cli to create comments on the files (or line numbers) where relevant. Use suggestions to suggest fixes, especially where you have high-confidence in the fix. Ensure fixes are valid code and take into account the surrounding code (opening/closing braces, indentation, comments). ALWAYS leave the final "review" comment empty. + 4. Your summary will be posted as a comment for you by OpenCode. + + In general, aim to provide actionable comments > code suggestions. + + + ${{ steps.pr-number.outputs.number }} + + + ${{ steps.pr-details.outputs.body }} + + + If the PR looks good, respond with only "LGTM!". No need to pad your response if the PR passes review. From d03bfa6e155c03ccdc82228ec541792decd810e5 Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Mon, 29 Dec 2025 13:15:33 -0500 Subject: [PATCH 2/4] Rewrite review prompt for docs review --- .github/workflows/bonk-review.yml | 42 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/bonk-review.yml b/.github/workflows/bonk-review.yml index 3a5eacfe1496426..6f5853d3e6e58d0 100644 --- a/.github/workflows/bonk-review.yml +++ b/.github/workflows/bonk-review.yml @@ -51,27 +51,35 @@ jobs: with: model: opencode/claude-opus-4-5 mentions: '/review' - permissions: write - agent: reviewer + permissions: CODEOWNERS + agent: docs prompt: | - Review the following pull request (title: ${{ steps.pr-details.outputs.title }}) against the below review guidelines: + Review PR #${{ steps.pr-number.outputs.number }} (title: ${{ steps.pr-details.outputs.title }}) for documentation quality. - Please check all the code changes in this pull request against the style guide, also look for any bugs if they exist. Diffs are important but make sure you read the entire file to get proper context. Make it clear the suggestions are merely suggestions and the human can decide what to do. + + ${{ steps.pr-details.outputs.body }} + - Refer to AGENTS.md and any additional instructions for our style guide, conventions and repo-wide rules. + ## Review focus - 1. Focus on actual violations and bugs. Where possible, comment on the exact line number to help guide the reviewer. - 2. Break up "needs fixing" (real logic bugs, poor error handling, security issues) vs. "suggestions" (nested logic, unused code, code structure/maintenance guidance) when responding so that a human has clear, actionable feedback. - 3. Use the gh cli to create comments on the files (or line numbers) where relevant. Use suggestions to suggest fixes, especially where you have high-confidence in the fix. Ensure fixes are valid code and take into account the surrounding code (opening/closing braces, indentation, comments). ALWAYS leave the final "review" comment empty. - 4. Your summary will be posted as a comment for you by OpenCode. + 1. **Structure & navigation**: Is content logically organized? Are headings clear and hierarchical? Is information easy to find? - In general, aim to provide actionable comments > code suggestions. + 2. **Style guide compliance**: Check against https://developers.cloudflare.com/style-guide/ and .windsurf/rules/general-rules.md. Watch for: contractions, product name capitalization, link formatting (relative paths with trailing slashes), correct component usage. - - ${{ steps.pr-number.outputs.number }} - - - ${{ steps.pr-details.outputs.body }} - + 3. **Cross-linking**: Are related docs linked where helpful? Use meaningful link text (not "click here"). Link to relevant concepts, guides, and API references. + + 4. **Code examples**: For each code block, verify: + - Syntactically correct + - Focused on the problem being explained + - Comments explain "why" not "what" + - Uses correct components (TypeScriptExample, WranglerConfig, APIRequest, PackageManagers) + + ## Output format + + Separate findings into: + - **Needs fixing**: Broken syntax, incorrect information, missing required elements + - **Suggestions**: Style improvements, better organization, enhanced clarity + + Use `gh` CLI to comment on specific lines. Use code suggestions for high-confidence fixes. Leave the final review comment empty. - If the PR looks good, respond with only "LGTM!". No need to pad your response if the PR passes review. + If the PR looks good, respond with only "LGTM!". From fdde46baa938584a6c9dd142353121262dfe44ab Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Mon, 29 Dec 2025 13:24:09 -0500 Subject: [PATCH 3/4] Update bonk-review.yml --- .github/workflows/bonk-review.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bonk-review.yml b/.github/workflows/bonk-review.yml index 6f5853d3e6e58d0..b894ede3ce70314 100644 --- a/.github/workflows/bonk-review.yml +++ b/.github/workflows/bonk-review.yml @@ -47,12 +47,12 @@ jobs: - name: Run Bonk uses: ask-bonk/ask-bonk/github@main env: - OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} with: - model: opencode/claude-opus-4-5 + model: anthropic/claude-opus-4-5 mentions: '/review' permissions: CODEOWNERS - agent: docs + agent: docs # use the Docs agent for reviews prompt: | Review PR #${{ steps.pr-number.outputs.number }} (title: ${{ steps.pr-details.outputs.title }}) for documentation quality. @@ -64,7 +64,7 @@ jobs: 1. **Structure & navigation**: Is content logically organized? Are headings clear and hierarchical? Is information easy to find? - 2. **Style guide compliance**: Check against https://developers.cloudflare.com/style-guide/ and .windsurf/rules/general-rules.md. Watch for: contractions, product name capitalization, link formatting (relative paths with trailing slashes), correct component usage. + 2. **Style guide compliance**: Check against https://developers.cloudflare.com/style-guide/ per the Docs agent. Watch for: contractions, product name capitalization, link formatting (relative paths with trailing slashes), correct component usage. 3. **Cross-linking**: Are related docs linked where helpful? Use meaningful link text (not "click here"). Link to relevant concepts, guides, and API references. From 6ec90b952fd2cf40d5c3ef759ec500dd03c2dfbb Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Wed, 31 Dec 2025 12:49:47 -0500 Subject: [PATCH 4/4] /review on PRs only --- .github/workflows/bonk-review.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bonk-review.yml b/.github/workflows/bonk-review.yml index b894ede3ce70314..6a8cad2979e477e 100644 --- a/.github/workflows/bonk-review.yml +++ b/.github/workflows/bonk-review.yml @@ -1,8 +1,6 @@ name: Review on: - issue_comment: - types: [created] pull_request_review_comment: types: [created] @@ -19,18 +17,36 @@ jobs: - name: Get PR number id: pr-number run: | - if [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then - echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + + - name: Verify PR exists + id: verify-pr + run: | + if gh api /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > /dev/null 2>&1; then + echo "exists=true" >> $GITHUB_OUTPUT else - echo "number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT + echo "exists=false" >> $GITHUB_OUTPUT + echo "::warning::PR #${{ github.event.pull_request.number }} not found, skipping review" fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout repository + if: steps.verify-pr.outputs.exists == 'true' uses: actions/checkout@v4 with: fetch-depth: 1 + - name: Setup Bun + if: steps.verify-pr.outputs.exists == 'true' + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + if: steps.verify-pr.outputs.exists == 'true' + run: bun install --frozen-lockfile + - name: Get PR details + if: steps.verify-pr.outputs.exists == 'true' id: pr-details run: | gh api /repos/${{ github.repository }}/pulls/${{ steps.pr-number.outputs.number }} > /tmp/pr_data.json