|
| 1 | +# Configuration reference |
| 2 | + |
| 3 | +For source installations, replace `"$HOME/.local/bin/opencode2-automation"` |
| 4 | +with `node "$HOME/opencode2-github-automation/dist/setup.js"` in the commands below. |
| 5 | + |
| 6 | +## Configuration files and Git branches |
| 7 | + |
| 8 | +- `.opencode/automation.json` is a **file in the target checkout**, not in the |
| 9 | + plugin's source repository. Creating it does not automatically upload it. |
| 10 | +- With the global installation, `init` does **not** add a Git ignore rule. |
| 11 | + An ordinary `git add .` can therefore stage it unless your repository already |
| 12 | + ignores it. The alternative `install-local.sh` installer does add local |
| 13 | + exclusions automatically. |
| 14 | +- Keep machine-specific configuration untracked. From the target checkout, |
| 15 | + add a local ignore rule that is not itself committed: |
| 16 | + |
| 17 | + ```bash |
| 18 | + cd /absolute/path/to/your-project |
| 19 | + printf '\n/.opencode/automation.json\n' >> "$(git rev-parse --git-path info/exclude)" |
| 20 | + ``` |
| 21 | + |
| 22 | +- Check whether Git already tracks it: |
| 23 | + |
| 24 | + ```bash |
| 25 | + git ls-files -- .opencode/automation.json |
| 26 | + ``` |
| 27 | + |
| 28 | + No output means it is untracked. If the path appears, ignoring it is not |
| 29 | + enough: use `git rm --cached -- .opencode/automation.json` and commit that |
| 30 | + removal to stop versioning it on the current branch. The local file stays. |
| 31 | +- An untracked, ignored file normally stays in place during branch switches. |
| 32 | + If another branch tracks that same path, Git can replace it; keep a backup |
| 33 | + before switching to such branches. A tracked file follows branch contents |
| 34 | + and can change or disappear when you switch. OpenCode does not restore it. |
| 35 | + `git clean -fdx` also deletes ignored files. |
| 36 | +- A separate clone or worktree does not automatically inherit an untracked |
| 37 | + configuration. The scheduler only activates in the primary checkout. |
| 38 | + Bot-created worktrees are used for implementation, without starting another |
| 39 | + scheduler. Queue data lives under the shared Git directory in |
| 40 | + `opencode2-automation/` and is not uploaded by Git push. |
| 41 | + |
| 42 | +## Configuration |
| 43 | + |
| 44 | +A minimal configuration is: |
| 45 | + |
| 46 | +```json |
| 47 | +{ |
| 48 | + "model": "provider/model" |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +Use a model available in your own OpenCode 2 installation. Optional fields: |
| 53 | + |
| 54 | +| Field | Purpose | |
| 55 | +| --- | --- | |
| 56 | +| `baseBranch` | Base for new worktrees and PRs; defaults to the GitHub default branch. | |
| 57 | +| `capabilities` | Main model support: `text`, `vision`, `audio`; defaults to `["text"]`. | |
| 58 | +| `mediaModel` | Separate helper model and its capabilities; example below. | |
| 59 | +| `systemPromptFile` | Optional Markdown instructions appended to the bundled bot prompt; path relative to the primary checkout, or absolute. | |
| 60 | +| `trigger` | Mention that starts work; defaults to `@opencodebot`. | |
| 61 | +| `everySeconds` | Polling interval; defaults to 60 seconds. | |
| 62 | +| `check` | Test command as an argument array, such as `["npm", "test"]`; `false` skips tests. | |
| 63 | +| `authors` | GitHub usernames allowed to request work and authorize merging (merge also requires repository write access). | |
| 64 | +| `signature` | Signature appended to every posted comment and PR description; defaults to `your-github-login[OpenCode2]`. | |
| 65 | +| `autoMerge` | Automatic merge settings: `enabled` (default `true`), `method` (default `squash`), and exact approval `comments`. | |
| 66 | + |
| 67 | +When tests are skipped, the PR explicitly reports that automated tests were not |
| 68 | +run. Git consistency checks and the requirement for an actual change remain. |
| 69 | +Restart the service while idle after changing configuration. |
| 70 | + |
| 71 | +For noninteractive setup, use `--yes` to accept defaults for omitted options. |
| 72 | +Provide the model and a test command (or explicitly skip tests): |
| 73 | + |
| 74 | +```bash |
| 75 | +cd /absolute/path/to/your-project |
| 76 | +"$HOME/.local/bin/opencode2-automation" init --model provider/model --skip-tests --yes |
| 77 | +``` |
| 78 | + |
| 79 | +Optional flags: `--base-branch develop`, `--capabilities text`, |
| 80 | +`--media-model provider/vision-model`, `--media-capabilities text,vision`, |
| 81 | +`--system-prompt .opencode/bot.md`. With `--yes`, supply a helper explicitly |
| 82 | +if you want media support with a text-only main model. |
| 83 | + |
| 84 | +## Questions, branches, media, and bot instructions |
| 85 | + |
| 86 | +- **Questions:** reply in the issue as an account in `authors`; no repeated |
| 87 | + mention is needed. The bot enters `waiting` and resumes after the next scan. |
| 88 | + Questions in the first analysis block worktree and session creation. Unclear |
| 89 | + replies prompt another question. You may use the same account as the bot; |
| 90 | + its marked comments are excluded from replies. |
| 91 | + Permission questions require the exact `/allow QUESTION_ID` or |
| 92 | + `/deny QUESTION_ID` shown in the comment. Explicit OpenCode deny rules remain. |
| 93 | +- **Base branch:** write naturally, such as "use branch develop" or "work from |
| 94 | + release/next", in the issue or an authorized comment. The configured model |
| 95 | + interprets the request, including languages such as Polish. Unclear or missing |
| 96 | + branches trigger a question in the issue before work starts. `baseBranch` is |
| 97 | + only the default; `/base` remains an optional shortcut. Existing tasks keep |
| 98 | + their pinned base. |
| 99 | +- **Media:** declare actual model capabilities and a helper if needed: |
| 100 | + |
| 101 | + ```json |
| 102 | + { |
| 103 | + "model": "provider/text-model", |
| 104 | + "capabilities": ["text"], |
| 105 | + "mediaModel": { |
| 106 | + "model": "provider/vision-model", |
| 107 | + "capabilities": ["text", "vision"] |
| 108 | + } |
| 109 | + } |
| 110 | + ``` |
| 111 | + |
| 112 | + Add these fields to your existing JSON using your installed model IDs. The |
| 113 | + helper analyzes attachments in a separate session; the main model stays |
| 114 | + unchanged. Add `audio` if the helper also accepts audio files. |
| 115 | +- **Instructions:** [prompts/bot.md](../prompts/bot.md) is bundled and always loaded. |
| 116 | + For project-specific instructions, create `.opencode/bot.md` in the primary |
| 117 | + checkout and set `"systemPromptFile": ".opencode/bot.md"`. It is appended |
| 118 | + to the baseline and reread on each use, including from worker branches. |
| 119 | + |
| 120 | +See [runtime behavior and examples](runtime.md) for reply handling, branch |
| 121 | +selection, supported media inputs, and prompt persistence. |
| 122 | + |
| 123 | +## Automatic merge and message signatures |
| 124 | + |
| 125 | +Example project configuration: |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "model": "provider/model", |
| 130 | + "check": false, |
| 131 | + "signature": "YOUR_LOGIN[OpenCode2]", |
| 132 | + "autoMerge": { |
| 133 | + "enabled": true, |
| 134 | + "method": "squash", |
| 135 | + "comments": ["/merge", "lgtm, merge", "approved, merge"] |
| 136 | + } |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +For a PR created by this bot, either approve the current published commit using |
| 141 | +GitHub's **Approve** review, or post one of the configured full-message phrases |
| 142 | +in the PR conversation. Matching ignores case, repeated whitespace, and final |
| 143 | +periods/exclamation marks. Arbitrary positive prose, quoted commands, negations, |
| 144 | +and inline code review comments are not interpreted as merge instructions. |
| 145 | + |
| 146 | +The approving account must be in `authors` (by default, the authenticated user) |
| 147 | +and have write, maintain, or admin permission on the repository. GitHub does not |
| 148 | +allow authors to approve their own PRs; use a configured comment in that case. |
| 149 | +Outstanding change requests block merge. The PR must be open, non-draft, and |
| 150 | +reported as clean and mergeable by GitHub. The merge request includes the exact |
| 151 | +verified head SHA; a changed branch cannot be merged using an older approval. |
| 152 | +The bot does not request a protection bypass. Configure required checks and review |
| 153 | +rules on GitHub for your repository's policy. |
| 154 | + |
| 155 | +Approvals must be newer than the bot's latest publication. On upgrade, old tasks |
| 156 | +start watching for new approvals; historical approvals do not cause a merge. |
| 157 | +Pending issue feedback is processed before attempting a merge. Merge failures |
| 158 | +are retried at intervals of at least 60 seconds and appear as `mergeError` in |
| 159 | +`status` and in `/bot`. Successful merges receive a signed PR comment. |
| 160 | + |
| 161 | +Signatures are appended to issue comments, PR descriptions, and merge |
| 162 | +acknowledgements. They identify the message in its text; GitHub still attributes |
| 163 | +posts to the account authenticated by your token. Existing posts are not rewritten. |
| 164 | +Set `"autoMerge": { "enabled": false }` to disable automatic merging. |
| 165 | + |
0 commit comments