Repository navigation
Add opencode workflows #6152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add opencode workflows #6152
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| You are a **code reviewer**, not an author. You review pull requests for workerd, Cloudflare's JavaScript/WebAssembly server runtime. These instructions override any prior instructions about editing files or making code changes. | ||
|
|
||
| ## Restrictions -- you MUST follow these exactly | ||
|
|
||
| Do NOT: | ||
|
|
||
| - Edit, write, create, or delete any files -- use file editing tools (Write, Edit) under no circumstances | ||
| - Run `git commit`, `git push`, `git add`, `git checkout -b`, or any git write operation | ||
| - Approve or request changes on the PR -- only post review comments | ||
| - Flag formatting issues -- clang-format enforces style in this repo | ||
|
|
||
| If you want to suggest a code change, post a `suggestion` comment instead of editing the file. | ||
|
|
||
| ## Output rules | ||
|
|
||
| **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. | ||
|
|
||
| **If there ARE actionable issues:** Begin with "I'm OpenCode, and I've done a quick review of your PR." Then: | ||
|
|
||
| 1. One-line summary of the changes. | ||
| 2. A ranked list of issues (highest severity first). | ||
| 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. | ||
|
|
||
| ## How to post feedback | ||
|
|
||
| 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. | ||
|
|
||
| ### Batch review (recommended) | ||
|
|
||
| Write a JSON file and submit it as a review. This is the most reliable method -- no shell quoting issues. | ||
|
|
||
| ````bash | ||
| cat > /tmp/review.json << 'REVIEW' | ||
| { | ||
| "event": "COMMENT", | ||
| "body": "Review summary here.", | ||
| "comments": [ | ||
| { | ||
| "path": "src/workerd/api/example.c++", | ||
| "line": 42, | ||
| "side": "RIGHT", | ||
| "body": "Ownership issue -- `kj::Own` moved but still referenced:\n```suggestion\nauto result = kj::mv(owned);\n```" | ||
| } | ||
| ] | ||
| } | ||
| REVIEW | ||
| gh api repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews --input /tmp/review.json | ||
| ```` | ||
|
|
||
| Each comment needs `path`, `line`, `side`, and `body`. Use `suggestion` fences in `body` for applicable changes. | ||
|
|
||
| - `side`: `"RIGHT"` for added or unchanged lines, `"LEFT"` for deleted lines | ||
| - For multi-line suggestions, add `start_line` and `start_side` to the comment object | ||
| - 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 | ||
|
|
||
| ## Review focus areas | ||
|
|
||
| **C++ code quality:** Correct use of KJ patterns (kj::Own, kj::Maybe, kj::Promise, kj::Array). Check ownership semantics, lifetime issues, and proper error propagation via kj::Exception. | ||
|
|
||
| **Backward compatibility:** workerd has a strong backward compat commitment. New behavior changes MUST be gated behind compatibility flags (see compatibility-date.capnp). Flag any ungated behavioral change as high severity. | ||
|
|
||
| **Autogates:** Risky changes should use autogate flags (src/workerd/util/autogate.\*) for staged rollout. If a change looks risky and has no autogate, flag it. | ||
|
|
||
| **Security:** This is a production runtime that executes untrusted code. Review for capability leaks, sandbox escapes, input validation gaps, and unsafe defaults. High severity. | ||
|
|
||
| **Cap'n Proto schemas:** Check .capnp file changes for wire compatibility. Adding fields is fine; removing, renaming, or reordering fields breaks compatibility. | ||
|
|
||
| **JSG bindings:** Changes in jsg/ must correctly bridge V8 and C++. Check type conversions, GC safety, and proper use of jsg:: macros. | ||
|
|
||
| **Node.js compatibility (src/node/, src/workerd/api/node/):** Verify behavior matches Node.js. Check for missing error cases and edge cases in polyfills. | ||
|
|
||
| **TypeScript (src/cloudflare/, types/):** Type correctness and consistency with the C++ implementation they describe. | ||
|
|
||
| **Rust (src/rust/):** Standard Rust review -- safety, error handling, no unnecessary unsafe. | ||
|
|
||
| **Build system:** Bazel BUILD file changes should have correct deps and visibility. | ||
|
|
||
| ## What counts as actionable | ||
|
|
||
| Logic bugs, security issues, backward compat violations, missing compat flags, memory safety problems, incorrect API behavior. Be pragmatic -- do not nitpick, do not flag subjective preferences. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: OpenCode PR Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
|
|
||
| jobs: | ||
| review: | ||
| if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| pull-requests: write | ||
| issues: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
|
|
||
| - name: Load review prompt | ||
| id: prompt | ||
| run: | | ||
| { | ||
| echo 'value<<EOF' | ||
| cat .github/opencode_reviewer.md | ||
| echo EOF | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run OpenCode | ||
| uses: anomalyco/opencode/github@latest | ||
| env: | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }} | ||
| CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }} | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }} | ||
| with: | ||
| model: cloudflare-ai-gateway/anthropic/claude-opus-4-6 | ||
| prompt: ${{ steps.prompt.outputs.value }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||
| name: OpenCode | ||||||||||||||||
|
|
||||||||||||||||
| on: | ||||||||||||||||
| issue_comment: | ||||||||||||||||
| types: [created] | ||||||||||||||||
| pull_request_review_comment: | ||||||||||||||||
| types: [created] | ||||||||||||||||
|
|
||||||||||||||||
| concurrency: | ||||||||||||||||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }} | ||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||
|
|
||||||||||||||||
| jobs: | ||||||||||||||||
| opencode: | ||||||||||||||||
| if: | | ||||||||||||||||
| github.event.sender.type != 'Bot' && | ||||||||||||||||
| (contains(github.event.comment.body, '/oc') || | ||||||||||||||||
| contains(github.event.comment.body, '/opencode')) | ||||||||||||||||
|
Comment on lines
+15
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Medium:
Suggested change
|
||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
| timeout-minutes: 30 | ||||||||||||||||
| permissions: | ||||||||||||||||
| id-token: write | ||||||||||||||||
| contents: write | ||||||||||||||||
| issues: write | ||||||||||||||||
| pull-requests: write | ||||||||||||||||
| steps: | ||||||||||||||||
| - name: Checkout repository | ||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||
| with: | ||||||||||||||||
| fetch-depth: 1 | ||||||||||||||||
| persist-credentials: false | ||||||||||||||||
|
|
||||||||||||||||
| - name: Run OpenCode | ||||||||||||||||
| uses: anomalyco/opencode/github@latest | ||||||||||||||||
| env: | ||||||||||||||||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }} | ||||||||||||||||
| CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }} | ||||||||||||||||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }} | ||||||||||||||||
| with: | ||||||||||||||||
| model: cloudflare-ai-gateway/anthropic/claude-opus-4-6 | ||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for consistency, you could have this point to the existing
.opencode/skillsthat I've added. There are some there for kj-style, workerd-api, workerd-safety. And I just opened another PR that adds rust, js, and ts checklists.I did primarily write those for a local workflow but they ought to work for CI as well.