@@ -21,65 +21,212 @@ reused if publication needs a retry.
2121The package is installed from source; publishing to npm is unnecessary.
2222` private: true ` prevents accidental publication while still allowing ` npm pack ` .
2323
24- ## Global installation: configure projects later
24+ ## 1. Install the plugin globally
2525
26- On macOS or Linux with Bash, clone and build the plugin:
26+ Run these steps on the machine that will run OpenCode 2. You do not need a target
27+ project yet. ` $HOME ` expands to your user's absolute home directory.
28+
29+ 1 . Clone and build the plugin:
30+
31+ ``` bash
32+ git clone https://github.com/d3cker/opencode2-github-automation.git " $HOME /opencode2-github-automation"
33+ cd " $HOME /opencode2-github-automation"
34+ npm ci && npm run build
35+ ```
36+
37+ 2 . Register the plugin and its terminal UI:
38+
39+ ``` bash
40+ mkdir -p " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot"
41+ printf ' export { default } from "%s";\n' " $HOME /opencode2-github-automation/dist/index.js" > " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/index.js"
42+ printf ' export { default } from "%s";\n' " $HOME /opencode2-github-automation/dist/tui.js" > " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/tui.js"
43+ ```
44+
45+ Run this registration once; do not overwrite customized loaders.
46+
47+ 3 . Restart the service when sessions are idle, then reopen your OpenCode client:
48+
49+ ``` bash
50+ opencode2 service restart
51+ ```
52+
53+ Installed. No project is automated yet. Keep the plugin source directory:
54+ OpenCode loads the compiled code from its ` dist ` folder.
55+
56+ ## 2. Configure a project
57+
58+ Use an existing Git checkout with a GitHub ` origin ` . Replace
59+ ` /absolute/path/to/your-project ` with its actual absolute path.
60+ Authenticate first with ` gh auth login ` and ` gh auth setup-git ` if needed.
61+
62+ 1 . Enter the target repository and start the wizard:
63+
64+ ``` bash
65+ cd /absolute/path/to/your-project
66+ node " $HOME /opencode2-github-automation/dist/setup.js" init
67+ ```
68+
69+ Enter your OpenCode 2 model (` provider/model ` ). If asked for tests, enter the
70+ project's test command or press Enter to skip. Do not add ` --local ` .
71+
72+ 2 . Review ` /absolute/path/to/your-project/.opencode/automation.json ` .
73+ To allow a colleague to request work, add their GitHub login to ` authors ` :
74+
75+ ``` json
76+ {
77+ "model" : " local/deepseek" ,
78+ "signature" : " d3cker[OpenCode2]" ,
79+ "authors" : [" d3cker" , " COLLEAGUE_LOGIN" ],
80+ "autoMerge" : {
81+ "enabled" : true ,
82+ "method" : " squash"
83+ },
84+ "check" : false
85+ }
86+ ```
87+
88+ Use your actual model and usernames. Without ` authors ` , only the authenticated
89+ GitHub user can request work. Auto-merge also requires the approving user to
90+ have repository write access.
91+
92+ 3 . Restart the idle service and open the target project:
93+
94+ ``` bash
95+ opencode2 service restart
96+ opencode2 /absolute/path/to/your-project
97+ ```
98+
99+ Create an issue containing ` @d3ckerbot ` . The bot checks once a minute; ` /bot `
100+ shows progress. Existing matching issues may also be picked up.
101+
102+ ** Code is global; configuration is per project.** Only repositories containing
103+ ` .opencode/automation.json ` are activated. Run the wizard in another checkout to
104+ add another project. Existing configuration files are never overwritten by ` init ` .
105+
106+ ## 3. Update an existing installation
107+
108+ Run this on the machine with the global installation. Wait for active bot work
109+ to finish first.
110+
111+ 1 . Download updates for the branch you currently use:
112+
113+ ``` bash
114+ cd " $HOME /opencode2-github-automation"
115+ git pull --ff-only
116+ ```
117+
118+ 2 . Install dependencies and rebuild:
119+
120+ ``` bash
121+ npm ci && npm run build
122+ ```
123+
124+ 3 . Reload the service:
125+
126+ ``` bash
127+ opencode2 service restart
128+ ```
129+
130+ Reopen the terminal client if the update changes the UI. Project configuration
131+ and queues remain in place. Do not repeat global registration or run ` init ` again.
132+
133+ ### Switch to the feature branch for testing
134+
135+ Replace update step 1 with:
27136
28137``` bash
29- git clone https://github.com/d3cker/opencode2-github-automation.git " $HOME /opencode2-github-automation"
30138cd " $HOME /opencode2-github-automation"
31- npm ci
32- npm run build
139+ git fetch origin
140+ git switch codex/pr-approval-merge-signatures
141+ git pull --ff-only
33142```
34143
35- Add the server and terminal UI entrypoints to OpenCode's global plugin directory:
144+ Then complete update steps 2 and 3. The approval and signature features described
145+ below are available on this branch (` 0.4.0-beta.1 ` ).
36146
37- ``` bash
38- mkdir -p " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot"
39- printf ' export { default } from "%s";\n' " $HOME /opencode2-github-automation/dist/index.js" > " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/index.js"
40- printf ' export { default } from "%s";\n' " $HOME /opencode2-github-automation/dist/tui.js" > " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/tui.js"
41- ```
147+ ## 4. Remove automation from one project
42148
43- These commands create loader files; do not overwrite them if you have customized
44- existing loaders at those paths. Keep the source directory in place: the global
45- installation imports its compiled files directly.
149+ This disables the project configured through ` init ` ; the global plugin remains
150+ available for other projects. Wait for bot sessions to finish first.
46151
47- If OpenCode 's service is running, restart it when sessions are idle :
152+ 1 . Remove that project 's configuration (confirm the deletion when prompted) :
48153
49- ``` bash
50- opencode2 service restart
51- ```
154+ ``` bash
155+ rm -i /absolute/path/to/your-project/.opencode/automation.json
156+ ```
52157
53- Reopen the terminal client to load the UI component. The scheduler remains
54- inactive in projects without ` .opencode/automation.json ` .
158+ 2 . Restart the service:
55159
56- ## Configure a project after global installation
160+ ``` bash
161+ opencode2 service restart
162+ ```
57163
58- Run the wizard from the root of the repository the bot should work on.
59- Replace the example target path with your checkout's absolute path:
164+ 3 . Reopen the client. The bot no longer scans, starts work, or merges PRs for
165+ this project. Other configured projects continue working.
60166
61- ``` bash
62- cd /absolute/path/to/your-project
63- node " $HOME /opencode2-github-automation/dist/setup.js" init
64- ```
167+ Removing the file alone does not stop an already-loaded worker; the restart
168+ applies the change. Queue data, worktrees, branches, and GitHub issues/PRs are
169+ preserved. Running ` init ` again re-enables the project and may resume its saved
170+ queue. If configuration was instead supplied through plugin options in
171+ ` opencode.json ` , remove those options or disable that plugin entry as well.
65172
66- Use ` init ` without ` --local ` for the global installation. The wizard asks for
67- an OpenCode 2 model identifier (` provider/model ` ), detects the GitHub repository,
68- default branch, authenticated account, and supported project test command.
69- If it asks for a test command, press Enter to skip tests.
173+ ## 5. Uninstall the global plugin
70174
71- The wizard creates ` .opencode/automation.json ` and never overwrites an existing
72- configuration. After configuration, restart an already-running service when it
73- is idle and reopen the project:
175+ For the global installation described above, wait for active work to finish.
74176
75- ``` bash
76- opencode2 service restart
77- opencode2 /absolute/path/to/your-project
78- ```
177+ 1 . Remove only this plugin's two global loaders:
178+
179+ ``` bash
180+ rm -i " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/index.js" " ${XDG_CONFIG_HOME:- $HOME / .config} /opencode/plugins/d3ckerbot/tui.js"
181+ ```
182+
183+ 2 . Restart the service:
184+
185+ ``` bash
186+ opencode2 service restart
187+ ```
188+
189+ 3 . Close and reopen OpenCode clients to unload the terminal UI.
190+
191+ The source checkout, project settings, and saved work remain on disk. Separate
192+ project-local installations are unaffected; their loaders live under each
193+ project's ` .opencode/plugins/automation/ ` directory.
194+
195+ ## Configuration files and Git branches
196+
197+ - ` .opencode/automation.json ` is a ** file in the target checkout** , not in the
198+ plugin's source repository. Creating it does not automatically upload it.
199+ - With the global installation, ` init ` does ** not** add a Git ignore rule.
200+ An ordinary ` git add . ` can therefore stage it unless your repository already
201+ ignores it. The alternative ` install-local.sh ` installer does add local
202+ exclusions automatically.
203+ - Keep machine-specific configuration untracked. From the target checkout,
204+ add a local ignore rule that is not itself committed:
205+
206+ ``` bash
207+ cd /absolute/path/to/your-project
208+ printf ' \n/.opencode/automation.json\n' >> " $( git rev-parse --git-path info/exclude) "
209+ ```
210+
211+ - Check whether Git already tracks it:
212+
213+ ``` bash
214+ git ls-files -- .opencode/automation.json
215+ ```
79216
80- Create an issue containing ` @d3ckerbot ` . Polling runs once a minute and also
81- considers existing matching issues. By default, only the authenticated GitHub
82- user can request work.
217+ No output means it is untracked. If the path appears, ignoring it is not
218+ enough: use ` git rm --cached -- .opencode/automation.json ` and commit that
219+ removal to stop versioning it on the current branch. The local file stays.
220+ - An untracked, ignored file normally stays in place during branch switches.
221+ If another branch tracks that same path, Git can replace it; keep a backup
222+ before switching to such branches. A tracked file follows branch contents
223+ and can change or disappear when you switch. OpenCode does not restore it.
224+ ` git clean -fdx ` also deletes ignored files.
225+ - A separate clone or worktree does not automatically inherit an untracked
226+ configuration. The scheduler only activates in the primary checkout.
227+ Bot-created worktrees are used for implementation, without starting another
228+ scheduler. Queue data lives under the shared Git directory in
229+ ` opencode2-automation/ ` and is not uploaded by Git push.
83230
84231## Configuration
85232
@@ -98,7 +245,9 @@ Use a model available in your own OpenCode 2 installation. Optional fields:
98245| ` trigger ` | Mention that starts work; defaults to ` @d3ckerbot ` . |
99246| ` everySeconds ` | Polling interval; defaults to 60 seconds. |
100247| ` check ` | Test command as an argument array, such as ` ["npm", "test"] ` ; ` false ` skips tests. |
101- | ` authors ` | GitHub usernames allowed to request work. |
248+ | ` authors ` | GitHub usernames allowed to request work and authorize merging (merge also requires repository write access). |
249+ | ` signature ` | Signature appended to every posted comment and PR description; defaults to ` your-github-login[OpenCode2] ` . |
250+ | ` autoMerge ` | Automatic merge settings: ` enabled ` (default ` true ` ), ` method ` (default ` squash ` ), and exact approval ` comments ` . |
102251
103252When tests are skipped, the PR explicitly reports that automated tests were not
104253run. Git consistency checks and the requirement for an actual change remain.
@@ -111,6 +260,49 @@ cd /absolute/path/to/your-project
111260node " $HOME /opencode2-github-automation/dist/setup.js" init --model provider/model --skip-tests
112261```
113262
263+ ## Automatic merge and message signatures
264+
265+ Example project configuration:
266+
267+ ``` json
268+ {
269+ "model" : " provider/model" ,
270+ "check" : false ,
271+ "signature" : " d3cker[OpenCode2]" ,
272+ "autoMerge" : {
273+ "enabled" : true ,
274+ "method" : " squash" ,
275+ "comments" : [" /merge" , " lgtm, merge" , " jest git, możesz mergować" , " jest git, można mergować" ]
276+ }
277+ }
278+ ```
279+
280+ For a PR created by this bot, either approve the current published commit using
281+ GitHub's ** Approve** review, or post one of the configured full-message phrases
282+ in the PR conversation. Matching ignores case, repeated whitespace, and final
283+ periods/exclamation marks. Arbitrary positive prose, quoted commands, negations,
284+ and inline code review comments are not interpreted as merge instructions.
285+
286+ The approving account must be in ` authors ` (by default, the authenticated user)
287+ and have write, maintain, or admin permission on the repository. GitHub does not
288+ allow authors to approve their own PRs; use a configured comment in that case.
289+ Outstanding change requests block merge. The PR must be open, non-draft, and
290+ reported as clean and mergeable by GitHub. The merge request includes the exact
291+ verified head SHA; a changed branch cannot be merged using an older approval.
292+ The bot does not request a protection bypass. Configure required checks and review
293+ rules on GitHub for your repository's policy.
294+
295+ Approvals must be newer than the bot's latest publication. On upgrade, old tasks
296+ start watching for new approvals; historical approvals do not cause a merge.
297+ Pending issue feedback is processed before attempting a merge. Merge failures
298+ are retried at intervals of at least 60 seconds and appear as ` mergeError ` in
299+ ` status ` and in ` /bot ` . Successful merges receive a signed PR comment.
300+
301+ Signatures are appended to issue comments, PR descriptions, and merge
302+ acknowledgements. They identify the message in its text; GitHub still attributes
303+ posts to the account authenticated by your token. Existing posts are not rewritten.
304+ Set ` "autoMerge": { "enabled": false } ` to disable automatic merging.
305+
114306## Follow progress and continue work
115307
116308Starting a session shows a notification and opens a background tab when tabs
@@ -151,18 +343,6 @@ It prompts for configuration on first installation and preserves existing settin
151343on upgrades. It does not restart OpenCode. Use either global or project-local
152344installation; do not enable both for the same project.
153345
154- ## Updating a global installation
155-
156- ``` bash
157- git -C " $HOME /opencode2-github-automation" pull --ff-only
158- cd " $HOME /opencode2-github-automation"
159- npm ci
160- npm run build
161- ```
162-
163- Restart the service while idle. Reopen terminal clients after UI changes.
164- Project settings and queues are preserved.
165-
166346## Development
167347
168348``` bash
@@ -176,5 +356,6 @@ installation archive. Build artifacts, dependencies, and local credentials are
176356excluded from the source repository.
177357
178358Additional documentation (currently in Polish):
359+
179360- [ Moving the source and installing on another machine] ( docs/installation.md )
180361- [ Advanced configuration, retries, permissions, and separate plugins] ( docs/advanced.md )
0 commit comments