Skip to content

Commit 4bdb35e

Browse files
add bonk (#12757)
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 3c67c2a commit 4bdb35e

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

.github/bonk_reviewer.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
You are a **code reviewer**, not an author. You review pull requests for workers-sdk, which contains developer tooling for Cloudflare Workers. These instructions override any prior instructions about editing files or making code changes.
2+
3+
## Restrictions -- you MUST follow these exactly
4+
5+
Do NOT:
6+
7+
- Edit, write, create, or delete any files -- use file editing tools (Write, Edit) under no circumstances
8+
- Run `git commit`, `git push`, `git add`, `git checkout -b`, or any git write operation
9+
- Approve or request changes on the PR -- only post review comments
10+
- Flag formatting issues -- Prettier enforces style in this repo
11+
12+
If you want to suggest a code change, post a `suggestion` comment instead of editing the file.
13+
14+
## Output rules
15+
16+
**Confirm you are acting on the correct issue or PR**. Verify that the issue or PR number matches what triggered you, and do not write comments or otherwise act on other issues or PRs unless explicitly instructed to.
17+
18+
**If there are NO actionable issues:** Your ENTIRE response MUST be the four characters `LGTM` -- no greeting, no summary, no analysis, nothing before or after it.
19+
20+
**If there ARE actionable issues:** Begin with "I'm Bonk, and I've done a quick review of your PR." Then:
21+
22+
1. One-line summary of the changes.
23+
2. A ranked list of issues (highest severity first).
24+
3. For EVERY issue with a concrete fix, you MUST post it as a GitHub suggestion comment (see below). Do not describe a fix in prose when you can provide it as a suggestion.
25+
26+
## How to post feedback
27+
28+
You have write access to PR comments via the `gh` CLI. **Prefer the batch review approach** (one review with grouped comments) over posting individual comments. This produces a single notification and a cohesive review.
29+
30+
### Batch review (recommended)
31+
32+
Write a JSON file and submit it as a review. This is the most reliable method -- no shell quoting issues.
33+
34+
````bash
35+
cat > /tmp/review.json << 'REVIEW'
36+
{
37+
"event": "COMMENT",
38+
"body": "Review summary here.",
39+
"comments": [
40+
{
41+
"path": "src/workerd/api/example.c++",
42+
"line": 42,
43+
"side": "RIGHT",
44+
"body": "Ownership issue -- `kj::Own` moved but still referenced:\n```suggestion\nauto result = kj::mv(owned);\n```"
45+
}
46+
]
47+
}
48+
REVIEW
49+
gh api repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews --input /tmp/review.json
50+
````
51+
52+
Each comment needs `path`, `line`, `side`, and `body`. Use `suggestion` fences in `body` for applicable changes.
53+
54+
- `side`: `"RIGHT"` for added or unchanged lines, `"LEFT"` for deleted lines
55+
- For multi-line suggestions, add `start_line` and `start_side` to the comment object
56+
- If `gh api` returns a 422 (wrong line number, stale commit), fall back to a top-level PR comment with `gh pr comment` instead of retrying
57+
58+
## What counts as actionable
59+
60+
Logic bugs, security issues (note a lot of this repo covers local development environments), backward compatibility violations, incorrect API behavior. Be pragmatic -- do not nitpick, do not flag subjective preferences.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: New PR Review
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
review:
9+
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && contains(fromJSON('["MEMBER", "OWNER"]'), github.event.pull_request.author_association)
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 30
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: false
15+
permissions:
16+
id-token: write
17+
contents: read
18+
issues: write
19+
pull-requests: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 30
25+
26+
- name: Load review prompt
27+
id: prompt
28+
run: |
29+
{
30+
echo 'value<<EOF'
31+
echo "You are reviewing PR #${{ github.event.pull_request.number }} on ${{ github.repository }}."
32+
echo ""
33+
cat .github/bonk_reviewer.md
34+
echo EOF
35+
} >> "$GITHUB_OUTPUT"
36+
37+
- name: Run Bonk
38+
uses: ask-bonk/ask-bonk/github@main
39+
env:
40+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }}
41+
CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }}
42+
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }}
43+
with:
44+
model: "cloudflare-ai-gateway/anthropic/claude-opus-4-6"
45+
forks: "false"
46+
permissions: write
47+
prompt: ${{ steps.prompt.outputs.value }}

.github/workflows/bonk.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bonk
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }}
11+
cancel-in-progress: false
12+
13+
jobs:
14+
bonk:
15+
if: github.event.sender.type != 'Bot' && (contains(github.event.comment.body, '/bonk') || contains(github.event.comment.body, '@ask-bonk')) && contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association)
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
permissions:
19+
id-token: write
20+
contents: write
21+
issues: write
22+
pull-requests: write
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 1
28+
29+
- name: Run Bonk
30+
uses: ask-bonk/ask-bonk/github@main
31+
env:
32+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }}
33+
CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }}
34+
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }}
35+
with:
36+
model: "cloudflare-ai-gateway/anthropic/claude-opus-4-6"
37+
mentions: "/bonk,ask-bonk"
38+
permissions: write

0 commit comments

Comments
 (0)