A Forgejo Action that runs [opencode](https://opencode.ai) against a Nomyo (or any OpenAI-compatible) backend, triggered by comments on issues and merge requests.
Mention `/opencode` or `/oc` in a comment and opencode reads the thread, executes the requested task, and replies. For "fix" tasks it opens a merge request; for MR comments it commits to the same MR.
- A runner that can run Docker containers (the example below uses `docker-amd64` with `node:lts-bookworm`).
- A Forgejo PAT (see scopes below) and a Nomyo API key.
### Forgejo PAT scopes
Generate the token at *Settings → Applications → Manage Access Tokens* with these scopes:
| Scope | Used for |
|---|---|
| `read:repository` | Clone, fetch repo info |
| `write:repository` | Push commits and branches |
| `read:issue` | Read issue/MR comments and metadata |
| `write:issue` | Create + update comments, open MRs |
| `read:user` | Resolve actor info (optional) |
### Secrets
In *Repo Settings → Actions → Secrets* add:
| Secret | Value |
|---|---|
| `FORGEJO_TOKEN` | The PAT from above |
| `NOMYO_API_KEY` | Your Nomyo API key |
### Workflow file
Add `.forgejo/workflows/opencode.yml` to the repo where you want opencode to respond. This example targets a Forgejo instance hosted under a subpath (`bitfreedom.net/code/`); adjust URLs and `runs-on` to match your setup.
`act_runner`'s `uses:` parser expects `https://<host>/<owner>/<repo>` — it does not handle a Forgejo instance hosted under a subpath (e.g. `bitfreedom.net/code/`). For subpath instances, clone the action source into `./.opencode-action` and reference it as a local action (`uses: ./.opencode-action`). If your Forgejo lives at a domain root, you can replace those two steps with `uses: <your-host>/nomyo-ai/actions@v1` directly.
| `model` | Yes | — | Model in the form `provider/model`. The provider name becomes a custom opencode provider; the action registers it as an `@ai-sdk/openai-compatible` provider pointing at `nomyo_api_url`. |
| `nomyo_api_key` | Yes | — | API key for the OpenAI-compatible backend. |
| `nomyo_api_url` | No | `https://chat.nomyo.ai/api` | Base URL of the OpenAI-compatible endpoint. The adapter calls `${baseURL}/chat/completions`. |
| `forgejo_api_url` | No | `https://bitfreedom.net/code/` | Forgejo instance base URL. |
| `forgejo_token` | No | — | Forgejo PAT (see scopes above). |
| `agent` | No | — | Primary agent name to use. |
| `share` | No | auto | Share the opencode session (`true`/`false`). Defaults to `true` for public repos. |
2. Runs [`bun install`](package.json) inside the action source.
3. Registers `${MODEL%/*}` as a custom opencode provider via `OPENCODE_CONFIG_CONTENT` and the API key via `OPENCODE_AUTH_CONTENT`.
4. Spawns `opencode serve` locally and talks to it over HTTP (`/session/{id}/message`).
5. Resolves the event, builds a prompt with thread/diff context, sends it to opencode, and posts the response as a comment (and, for "fix" intents, opens an MR).