Skip to content

ci: add an opencode v2 agent triggered by owner comments - #1129

Merged
blafourcade merged 6 commits into
nextfrom
chore/opencode-agent-workflow
Nov 2, 2026
Merged

blafourcade merged 6 commits into
nextfrom
chore/opencode-agent-workflow

Conversation

@alexsoyes

@alexsoyes alexsoyes commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🎯 What & why

Lets the repository owner hand work to OpenCode v2 from a comment (/oc or /opencode) on an issue, a pull request or a line review, on the free opencode-go/beam-free model. Nobody else can trigger it.

🛠️ How it works

OpenCode v2 has no GitHub integration anymore (no github run command, and the anomalyco/opencode/github action is no longer published), so this workflow is the integration:

  1. Guard: opencode.yml:35 checks comment.user.id, not the login, which can be renamed and reclaimed. The repo is public: without it any comment would spend the subscription and feed text to the agent.
  2. Target: on a PR, its head branch (fork PRs and main/next heads refused). On an issue, chore/opencode-issue-<n> from next, reused by later requests on the same issue.
  3. Prompt: built with jq from the event payload into a file: issue or PR text, the review hunk if any, then the request. No comment text is interpolated into a shell command.
  4. Agent: opencode.yml:146 opencode run --standalone --format json with the latest @opencode/cli, no --auto. Per OpenCode's guidance for unattended runs, opencode.yml:119 writes explicit rules to the user config (outside the checkout, never committed): shell denied except read-only git, so CI tests the pushed commit; no access outside the checkout, which keeps OPENCODE_API_KEY out of reach; subagents denied, because the shipped explore agent re-allows shell and outside paths and agent rules outrank config. Anything left at ask is rejected. The step holds no GitHub credential.
  5. Publish: opencode.yml:149 mints an aidd-bot token downscoped to contents, pull requests and issues (same app the release workflows use, so its pushes trigger CI, which GITHUB_TOKEN pushes would not). Commits, pushes, opens a PR to next for issues, and replies with the agent's last message. On failure it replies with the run link.

GITHUB_TOKEN stays contents: read + pull-requests: read. Runner ubuntu-slim, Node lts/*, actions pinned by SHA, permissions: {} at the top.

🧪 How to verify

  • After merge to main (issue_comment workflows only run from the default branch): /oc fix the typo in README on a test issue. Expect a reply with a link to a new PR.
  • /oc on a PR from a branch of this repo: expect a commit on that branch and a reply.
  • Same comment from another account: job skipped.

⚠️ Heads-up

  • Never run end to end: it can only fire once on main. The prompt builder and reply extraction were dry-run locally on sample payloads; the v2 run flags were read from the 2.2.1 source.
  • @opencode/cli@latest is a deliberate exception to the global-install pin rule, declared in workflows-pin-global-installs.test.js with its reason. It floats on a CLI that ships several releases a week: a flag change breaks the run, and each release runs unreviewed. Pin a version to trade freshness back.
  • beam-free is free for a limited time; when it ends, change MODEL.
  • Issue text written by others reaches the prompt; the guard limits who triggers, not what the issue says. The permission rules bound what such text can make the agent do: edit files in the checkout, nothing else.
  • No shell means the agent cannot run tests itself; CI runs them on the commit it pushes.
  • ubuntu-slim stops jobs at 15 minutes, install included.
  • The OpenCode Agent GitHub App installed on this repo is no longer used and can be uninstalled.

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL


Generated by Claude Code

Runs OpenCode on a /oc or /opencode comment in an issue, a pull request or a
line review, using OpenCode Go models. Only the repository owner's account id
can trigger it, so other comments neither spend the subscription nor reach an
agent holding a write token.

The CLI is pinned to opencode-ai 1.19.5 instead of using anomalyco/opencode/github:
that action is no longer published, installs the latest OpenCode at run time, and
OpenCode v2 has no `github run` command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL
@alexsoyes
alexsoyes requested a review from a team as a code owner October 29, 2026 06:25
…a free model

Follows the newest v1 CLI (opencode-ai@1) instead of a fixed version, uses the
latest Node LTS, runs on the one-vCPU ubuntu-slim runner with its 15-minute
ceiling made explicit, and switches to the free opencode-go/beam-free model.
Names the owner behind the trigger's user id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL
OpenCode v2 dropped its GitHub integration, so the workflow now does that part
itself: it runs `opencode run` headless with the latest @opencode/cli, then
commits, pushes and replies with the repository bot's token, downscoped to
contents, pull requests and issues. The agent step holds no GitHub credential.
Fork pull requests and pull requests from main or next are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL
@alexsoyes alexsoyes changed the title ci: add opencode agent triggered by owner comments ci: add an opencode v2 agent triggered by owner comments Oct 29, 2026
The global-install pin rule rejected `@opencode/cli@latest`. The agent is meant
to follow the newest OpenCode v2, so the workflow joins the rule's allowlist with
that reason, the same way the claude-code probe does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL
…runs

OpenCode v2 recommends explicit rules for CI, where nothing can answer a prompt.
The agent now runs without --auto under a user-level config: shell denied except
read-only git, no access outside the checkout, no subagents (the shipped explore
agent re-allows shell and outside paths, and agent rules outrank config).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177LJQehsL7Fm3PciLfDcFL
@alexsoyes
alexsoyes enabled auto-merge November 2, 2026 01:26
@blafourcade
blafourcade disabled auto-merge November 2, 2026 03:38
@blafourcade
blafourcade merged commit 7ab0496 into next Nov 2, 2026
31 checks passed
@blafourcade
blafourcade deleted the chore/opencode-agent-workflow branch November 2, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants