From b7146040277a8461200e3bd5b926e86c5b4da468 Mon Sep 17 00:00:00 2001 From: Martins6 Date: Sat, 22 Aug 2026 21:57:51 -0300 Subject: [PATCH 1/3] feat(ci): add OpenCode GitHub workflows for slash-command and auto PR review Adds two GitHub Actions workflows that wire the OpenCode `build` agent into the repo via the official `anomalyco/opencode/github` action: - .github/workflows/opencode.yml: triggered when `/opencode` or `/oc` appears in an issue or PR review comment. Read-only permissions + OIDC id-token. - .github/workflows/opencode-review.yml: automatically reviews every non-draft PR on open, on each new commit (synchronize), on reopen, and when moved out of draft. Same prompt re-runs on every push. Both pin `agent: build`, model `minimax-coding-plan/MiniMax-M3`, and read the API key from `${{ secrets.MINIMAX_API_KEY }}` (verify the env var name against `opencode auth login` / models.dev). README gains a "GitHub Workflow" subsection under Development covering app install, secret naming, slash-command usage, and auto-review behavior. --- .github/workflows/opencode-review.yml | 38 +++++++++++++++++++++++++++ .github/workflows/opencode.yml | 36 +++++++++++++++++++++++++ README.md | 17 ++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 .github/workflows/opencode-review.yml create mode 100644 .github/workflows/opencode.yml diff --git a/.github/workflows/opencode-review.yml b/.github/workflows/opencode-review.yml new file mode 100644 index 0000000..4389202 --- /dev/null +++ b/.github/workflows/opencode-review.yml @@ -0,0 +1,38 @@ +name: opencode-review + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + review: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + pull-requests: read + issues: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + persist-credentials: false + + - name: Run OpenCode review + uses: anomalyco/opencode/github@latest + env: + # NOTE: confirm the env var name against `opencode auth login` output + # or models.dev for the `minimax-coding-plan` provider and adjust + # the secret name in repo Settings → Secrets and variables → Actions. + MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }} + with: + model: minimax-coding-plan/MiniMax-M3 + agent: build + prompt: | + Review this pull request: + - Check for code quality issues and Go idiom violations. + - Look for potential bugs, race conditions, or error-handling gaps. + - Suggest concrete improvements with file/line references. + - Flag any security concerns (secret leakage, unsafe parsing, etc.). diff --git a/.github/workflows/opencode.yml b/.github/workflows/opencode.yml new file mode 100644 index 0000000..f53b5b3 --- /dev/null +++ b/.github/workflows/opencode.yml @@ -0,0 +1,36 @@ +name: opencode + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + +jobs: + opencode: + if: | + contains(github.event.comment.body, '/oc') || + contains(github.event.comment.body, '/opencode') + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + pull-requests: read + issues: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + persist-credentials: false + + - name: Run OpenCode + uses: anomalyco/opencode/github@latest + env: + # NOTE: confirm the env var name against `opencode auth login` output + # or models.dev for the `minimax-coding-plan` provider and adjust + # the secret name in repo Settings → Secrets and variables → Actions. + MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }} + with: + model: minimax-coding-plan/MiniMax-M3 + agent: build diff --git a/README.md b/README.md index b0418aa..782a1b6 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,23 @@ For system-wide installs (`/usr/local/bin`) the replace may hit a read-only file - `github.com/spf13/viper` - Configuration - `github.com/google/uuid` - UUID generation +### GitHub Workflow + +Two GitHub Actions workflows wire the OpenCode `build` agent into this repo using the official [`anomalyco/opencode/github`](https://opencode.ai/docs/github/) action: + +- `.github/workflows/opencode.yml` — triggered when `/opencode` or `/oc` appears in an issue or PR review comment. +- `.github/workflows/opencode-review.yml` — automatically reviews every non-draft PR on open, on each new commit (`synchronize`), on reopen, and when moved out of draft. + +To enable them: + +1. Install the [OpenCode GitHub App](https://github.com/apps/opencode-agent) on this repository. +2. Add the provider's API key under *Settings → Secrets and variables → Actions*. The workflows reference it as `MINIMAX_API_KEY` — confirm the exact env var name against `opencode auth login` output or [models.dev](https://models.dev/) for the `minimax-coding-plan` provider, and adjust both `opencode.yml` and `opencode-review.yml` if it differs. + +Usage: + +- Comment `/opencode ` (or `/oc`) on any issue or PR to invoke the agent. +- Open a PR to get an automatic code review; every new push re-runs the review on the latest diff. + ## License MIT From 6b2b14b864c2b31766c76f129fe3851f4ccd0532 Mon Sep 17 00:00:00 2001 From: Martins6 Date: Sat, 22 Aug 2026 21:57:53 -0300 Subject: [PATCH 2/3] docs(features): document OpenCode GitHub workflow integration Adds feat-opencode-github-workflow.md covering both workflow files, the slash-command trigger, the auto-review on PR open / synchronize / reopen / ready_for_review, the draft-skip guard, the OIDC auth path, and the MINIMAX_API_KEY secret caveat. OVERVIEW.md and LOG-FEATS.md updated to list the new feature. --- docs/features/LOG-FEATS.md | 1 + docs/features/OVERVIEW.md | 3 ++- .../features/feat-opencode-github-workflow.md | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 docs/features/feat-opencode-github-workflow.md diff --git a/docs/features/LOG-FEATS.md b/docs/features/LOG-FEATS.md index 67aadba..11a0360 100644 --- a/docs/features/LOG-FEATS.md +++ b/docs/features/LOG-FEATS.md @@ -20,3 +20,4 @@ 2026-07-07-10-26 | Renamed project from `opencode-telegram` to `acolyte` (GitHub repo, local folder, Go module path, binary name, workspace dir, OpenCode agent name, install scripts, CI, embedded workspace templates, docs). Clean break, no data migration. 2026-07-07-10-26 | Added timestamped filenames for downloaded Telegram media - new `GenerateTimestampedFilename(dir, ext)` helper in `internal/media/downloader.go` produces UTC-stamped names (`20060102_150405.jpg`) with `_1`/`_2` collision suffixes; `GetFilePath` now takes an extension instead of a filename; removed obsolete `FilenameFromTelegramPath` helper and its test. 2026-07-07-12-11 | Added self-update feature - `acolyte update`/`version` subcommands with SHA256-verified GitHub Releases replacement of the running binary, optional in-process restart, ad-hoc codesign on macOS, and a non-blocking 5s startup outdated-check in `acolyte start` that drops a row into the notifications table. Also extends `.github/workflows/release.yml` to publish a `checksums.txt`. +2026-08-22-21-57 | Added OpenCode GitHub workflow integration - two `.github/workflows/opencode*.yml` files wire the `build` agent into issues/PRs (slash-command trigger on `/opencode` or `/oc`) and trigger automatic code review on PR open and every new commit, using the OpenCode GitHub App + OIDC and `minimax-coding-plan/MiniMax-M3`. README "GitHub Workflow" subsection added. diff --git a/docs/features/OVERVIEW.md b/docs/features/OVERVIEW.md index 3572559..e3ab0e9 100644 --- a/docs/features/OVERVIEW.md +++ b/docs/features/OVERVIEW.md @@ -11,4 +11,5 @@ Telegram bot gateway that allows users to interact with an OpenCode AI agent dir - feat-telegram-agent.md - Custom telegram-agent in opencode.json configuration - feat-default-prompts.md - Improved default prompts for workspace template files - feat-notify-mail-cron.md - SQLite-based notification and mail system with scheduler, timezone gating, and runtime config hot-reload -- feat-self-update.md - In-app self-update via GitHub releases with `acolyte update`/`version` and non-blocking startup outdated-check \ No newline at end of file +- feat-self-update.md - In-app self-update via GitHub releases with `acolyte update`/`version` and non-blocking startup outdated-check +- feat-opencode-github-workflow.md - GitHub Actions workflows wiring the OpenCode `build` agent into issues/PRs via `/opencode` slash commands and automatic PR review on open and every new commit \ No newline at end of file diff --git a/docs/features/feat-opencode-github-workflow.md b/docs/features/feat-opencode-github-workflow.md new file mode 100644 index 0000000..791a763 --- /dev/null +++ b/docs/features/feat-opencode-github-workflow.md @@ -0,0 +1,19 @@ +# Overview + +Adds two GitHub Actions workflows that wire the OpenCode `build` agent into the repository using the official `anomalyco/opencode/github` action: a slash-command trigger on `/opencode` or `/oc` in issue/PR comments, and an automatic code review that fires on PR open and every new commit. + +# Details + +- Adds `.github/workflows/opencode.yml` triggered by `issue_comment` (type `created`) and `pull_request_review_comment` (type `created`); only runs when the comment body contains `/oc` or `/opencode` +- Job uses `ubuntu-latest`, read-only permissions (`contents: read`, `pull-requests: read`, `issues: read`) plus `id-token: write` for OpenCode GitHub App OIDC, and explicitly pins `agent: build` with model `minimax-coding-plan/MiniMax-M3` +- Adds `.github/workflows/opencode-review.yml` triggered by `pull_request` types `[opened, synchronize, reopened, ready_for_review]`; skips drafts via `if: github.event.pull_request.draft == false` so `synchronize` re-runs the same review on every new commit +- Review job uses the same read-only permission set, the same model/agent, and a code-review-focused `prompt` covering code quality, Go idiom violations, bugs/race conditions/error-handling gaps, and security concerns (secret leakage, unsafe parsing) +- Auth uses the OpenCode GitHub App via OIDC; the API key is supplied via `${{ secrets.MINIMAX_API_KEY }}` — the secret name is written for `minimax-coding-plan` and must be verified against `opencode auth login` / models.dev +- README.md gains a "GitHub Workflow" subsection under Development covering app install, secret naming, slash-command usage, and auto-review behavior +- Workflow files mirror the official opencode docs pattern (`actions/checkout@v4` with `fetch-depth: 1` and `persist-credentials: false`, then `anomalyco/opencode/github@latest`) + +# File Paths + +- .github/workflows/opencode.yml +- .github/workflows/opencode-review.yml +- README.md From fbae126edd330ca0196e9f4653a260cf037fcaaa Mon Sep 17 00:00:00 2001 From: Martins6 Date: Sun, 23 Aug 2026 08:34:12 -0300 Subject: [PATCH 3/3] fix(ci): pin minimax-coding-plan/MiniMax-M3 via project opencode.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-review workflow run on this branch failed with `Model not found: minimax-coding-plan/MiniMax-M3. Did you mean: MiniMax-M3?` even though the catalog (models.dev) lists that exact provider/model and the env var (MINIMAX_API_KEY) was set. The catalog suggestion proved the catalog lookup found the model, but the opencode server's runtime provider registry didn't include it — same root cause as opencode#7958. The GitHub runner has no local auth/config to fall back on, so the runtime registry stays empty for any provider whose catalog merge didn't populate. Adding a project-level opencode.json that explicitly registers the provider/model forces it into the runtime registry regardless of the catalog fetch. Files: - opencode.json: new, pins minimax-coding-plan provider and MiniMax-M3 - README.md: note about the config under "GitHub Workflow" - docs/features/feat-opencode-github-workflow.md: mention the config --- README.md | 4 +++- docs/features/feat-opencode-github-workflow.md | 2 ++ opencode.json | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 opencode.json diff --git a/README.md b/README.md index 782a1b6..49c11e3 100644 --- a/README.md +++ b/README.md @@ -285,10 +285,12 @@ Two GitHub Actions workflows wire the OpenCode `build` agent into this repo usin - `.github/workflows/opencode.yml` — triggered when `/opencode` or `/oc` appears in an issue or PR review comment. - `.github/workflows/opencode-review.yml` — automatically reviews every non-draft PR on open, on each new commit (`synchronize`), on reopen, and when moved out of draft. +A project-level [`opencode.json`](./opencode.json) pins the `minimax-coding-plan` provider and `MiniMax-M3` model so the opencode server started by the action resolves the model reliably (the GitHub runner has no local auth/config to fall back on). + To enable them: 1. Install the [OpenCode GitHub App](https://github.com/apps/opencode-agent) on this repository. -2. Add the provider's API key under *Settings → Secrets and variables → Actions*. The workflows reference it as `MINIMAX_API_KEY` — confirm the exact env var name against `opencode auth login` output or [models.dev](https://models.dev/) for the `minimax-coding-plan` provider, and adjust both `opencode.yml` and `opencode-review.yml` if it differs. +2. Add the provider's API key under *Settings → Secrets and variables → Actions* as `MINIMAX_API_KEY` — that env var name matches the `minimax-coding-plan` provider in [models.dev](https://models.dev/). Usage: diff --git a/docs/features/feat-opencode-github-workflow.md b/docs/features/feat-opencode-github-workflow.md index 791a763..ebc1f28 100644 --- a/docs/features/feat-opencode-github-workflow.md +++ b/docs/features/feat-opencode-github-workflow.md @@ -9,6 +9,7 @@ Adds two GitHub Actions workflows that wire the OpenCode `build` agent into the - Adds `.github/workflows/opencode-review.yml` triggered by `pull_request` types `[opened, synchronize, reopened, ready_for_review]`; skips drafts via `if: github.event.pull_request.draft == false` so `synchronize` re-runs the same review on every new commit - Review job uses the same read-only permission set, the same model/agent, and a code-review-focused `prompt` covering code quality, Go idiom violations, bugs/race conditions/error-handling gaps, and security concerns (secret leakage, unsafe parsing) - Auth uses the OpenCode GitHub App via OIDC; the API key is supplied via `${{ secrets.MINIMAX_API_KEY }}` — the secret name is written for `minimax-coding-plan` and must be verified against `opencode auth login` / models.dev +- Project-level `opencode.json` at the repo root pins the `minimax-coding-plan` provider and `MiniMax-M3` model so the opencode server started by the action resolves the model reliably in the runner (which has no local auth/config to fall back on); this is the same pattern that resolved [opencode#7958](https://github.com/anomalyco/opencode/issues/7958) - README.md gains a "GitHub Workflow" subsection under Development covering app install, secret naming, slash-command usage, and auto-review behavior - Workflow files mirror the official opencode docs pattern (`actions/checkout@v4` with `fetch-depth: 1` and `persist-credentials: false`, then `anomalyco/opencode/github@latest`) @@ -16,4 +17,5 @@ Adds two GitHub Actions workflows that wire the OpenCode `build` agent into the - .github/workflows/opencode.yml - .github/workflows/opencode-review.yml +- opencode.json - README.md diff --git a/opencode.json b/opencode.json new file mode 100644 index 0000000..6988380 --- /dev/null +++ b/opencode.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "minimax-coding-plan": { + "name": "MiniMax Coding Plan", + "models": { + "MiniMax-M3": {} + } + } + } +} \ No newline at end of file