|
1 | | -# OpenCode 2 Automation |
| 1 | +# OpenCode 2 GitHub Automation |
2 | 2 |
|
3 | | -Jedna paczka: scheduler + GitHub dispatcher. |
| 3 | +A scheduler and GitHub dispatcher in one package, built for **OpenCode 2**. |
4 | 4 |
|
5 | | -`@d3ckerbot` w issue → komentarz z planem → poprawka → testy → PR. |
| 5 | +`@d3ckerbot` in an issue → acknowledgement and plan → implementation → verification → pull request. |
6 | 6 |
|
7 | | -## Instalacja z repozytorium |
| 7 | +The model chooses each new PR title from the issue and completed-work summary. |
| 8 | +There is no fixed `Fix` prefix. The chosen title is saved before publication and |
| 9 | +reused if publication needs a retry. |
8 | 10 |
|
9 | | -**OpenCode 2**, Node.js 22+, npm i Git. Sprawdzona wersja OpenCode: |
10 | | -`0.0.0-beta-19398`. Model i dostęp do GitHuba muszą działać na danej maszynie. |
| 11 | +## Requirements |
11 | 12 |
|
12 | | -Po sklonowaniu źródeł i docelowego projektu wystarczy: |
| 13 | +- OpenCode 2 with a working model. Tested with `0.0.0-beta-19398`. |
| 14 | +- Node.js 22+, npm, and Git. |
| 15 | +- GitHub authentication through `gh auth login`, or `GITHUB_TOKEN`/`GH_TOKEN` |
| 16 | + in the server environment. |
| 17 | +- Permission to comment, push branches, and create PRs in the target repository. |
| 18 | +- A target repository with a GitHub `origin`, an existing default-branch commit, |
| 19 | + and issues enabled. |
| 20 | + |
| 21 | +The package is installed from source; publishing to npm is unnecessary. |
| 22 | +`private: true` prevents accidental publication while still allowing `npm pack`. |
| 23 | + |
| 24 | +## Global installation: configure projects later |
| 25 | + |
| 26 | +On macOS or Linux with Bash, clone and build the plugin: |
13 | 27 |
|
14 | 28 | ```bash |
15 | | -bash /absolute/path/to/opencode2-plugin/scripts/install-local.sh /absolute/path/to/project |
| 29 | +git clone https://github.com/d3cker/opencode2-github-automation.git "$HOME/opencode2-github-automation" |
| 30 | +cd "$HOME/opencode2-github-automation" |
| 31 | +npm ci |
| 32 | +npm run build |
16 | 33 | ``` |
17 | 34 |
|
18 | | -Instalator buduje lokalną paczkę i dodaje plugin serwera oraz interfejsu do |
19 | | -projektu. Pyta o model; Enter przy pytaniu o testy pozwala je pominąć. |
20 | | -Przy aktualizacji zachowuje istniejącą konfigurację. Nie restartuje serwisu. |
| 35 | +Add the server and terminal UI entrypoints to OpenCode's global plugin directory: |
21 | 36 |
|
22 | | -**[Pełna instrukcja: wypchnięcie źródeł i instalacja na drugiej maszynie](docs/installation.md)** |
| 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 | +``` |
23 | 42 |
|
24 | | -Nie trzeba publikować paczki w npm. Repozytorium zawiera źródła i lockfile; |
25 | | -archiwum instalacyjne powstaje lokalnie. `private: true` blokuje `npm publish`. |
| 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. |
26 | 46 |
|
27 | | -Tytuł każdego nowego PR-a dobiera model po zakończeniu pracy, na podstawie |
28 | | -zgłoszenia i podsumowania wykonanej zmiany. Nie ma stałego prefiksu `Fix`. |
29 | | -Tytuł jest zapisywany przed publikacją i zachowywany przy ponowieniu próby. |
| 47 | +If OpenCode's service is running, restart it when sessions are idle: |
30 | 48 |
|
31 | | -## Podgląd pracy i kolejne komentarze |
| 49 | +```bash |
| 50 | +opencode2 service restart |
| 51 | +``` |
32 | 52 |
|
33 | | -Gdy sesja startuje, w otwartym OpenCode 2 pojawia się powiadomienie i karta |
34 | | -w tle. Komenda `/bot` pokazuje zadania i pozwala otworzyć sesję. Jeśli karty |
35 | | -są wyłączone, sesję nadal otworzysz przez `/bot`. |
| 53 | +Reopen the terminal client to load the UI component. The scheduler remains |
| 54 | +inactive in projects without `.opencode/automation.json`. |
36 | 55 |
|
37 | | -Nowy komentarz uprawnionego autora w obsługiwanym issue uruchamia kolejną |
38 | | -rundę: odpowiedź z planem, poprawka i push do tego samego otwartego PR-a. |
39 | | -Nie trzeba ponawiać wzmianki. Komentarze podczas pracy czekają na następną |
40 | | -rundę. Wzmianka w komentarzu może też rozpocząć obsługę nowego issue. |
41 | | -Edycje komentarzy i komentarze w review PR-a nie są obsługiwane. |
42 | | -Zamknięty lub scalony PR blokuje dalszą rundę. |
| 56 | +## Configure a project after global installation |
43 | 57 |
|
44 | | -Przy aktualizacji starszej lokalnej instalacji zainstaluj nową paczkę i wykonaj: |
| 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: |
45 | 60 |
|
46 | | -```sh |
47 | | -./.opencode/node_modules/.bin/opencode2-automation upgrade |
| 61 | +```bash |
| 62 | +cd /absolute/path/to/your-project |
| 63 | +node "$HOME/opencode2-github-automation/dist/setup.js" init |
| 64 | +``` |
| 65 | + |
| 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. |
| 70 | + |
| 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: |
| 74 | + |
| 75 | +```bash |
48 | 76 | opencode2 service restart |
| 77 | +opencode2 /absolute/path/to/your-project |
| 78 | +``` |
| 79 | + |
| 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. |
| 83 | + |
| 84 | +## Configuration |
| 85 | + |
| 86 | +A minimal configuration is: |
| 87 | + |
| 88 | +```json |
| 89 | +{ |
| 90 | + "model": "provider/model" |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +Use a model available in your own OpenCode 2 installation. Optional fields: |
| 95 | + |
| 96 | +| Field | Purpose | |
| 97 | +| --- | --- | |
| 98 | +| `trigger` | Mention that starts work; defaults to `@d3ckerbot`. | |
| 99 | +| `everySeconds` | Polling interval; defaults to 60 seconds. | |
| 100 | +| `check` | Test command as an argument array, such as `["npm", "test"]`; `false` skips tests. | |
| 101 | +| `authors` | GitHub usernames allowed to request work. | |
| 102 | + |
| 103 | +When tests are skipped, the PR explicitly reports that automated tests were not |
| 104 | +run. Git consistency checks and the requirement for an actual change remain. |
| 105 | +Restart the service while idle after changing configuration. |
| 106 | + |
| 107 | +For noninteractive setup: |
| 108 | + |
| 109 | +```bash |
| 110 | +cd /absolute/path/to/your-project |
| 111 | +node "$HOME/opencode2-github-automation/dist/setup.js" init --model provider/model --skip-tests |
49 | 112 | ``` |
50 | 113 |
|
51 | | -`upgrade` dodaje interfejs i zachowuje konfigurację. Otwórz ponownie klienta |
52 | | -OpenCode 2, aby załadować nowy komponent interfejsu. |
| 114 | +## Follow progress and continue work |
53 | 115 |
|
54 | | -## Inny projekt lub model |
| 116 | +Starting a session shows a notification and opens a background tab when tabs |
| 117 | +are enabled. Use `/bot` to list tasks and open a session. |
55 | 118 |
|
56 | | -Jeśli nie można wykryć testów, konfigurator zapyta o komendę. **Enter pomija |
57 | | -testy** i zapisuje `check: false`. Możesz też przekazać `--skip-tests`, aby |
58 | | -pominąć pytanie. PR wyraźnie informuje wtedy, że testy nie zostały uruchomione; |
59 | | -sprawdzenia spójności Git i wymaganie rzeczywistej poprawki pozostają aktywne. |
60 | | -Możesz również |
61 | | -skonfigurować projekt bez pytań: |
| 119 | +A new comment from an authorized author on a tracked issue starts another round: |
| 120 | +acknowledgement, implementation, and a push to the same open PR. The mention does |
| 121 | +not need to be repeated. Comments received during execution wait for the next |
| 122 | +round. A mention in an authorized comment can also start work on an untracked issue. |
62 | 123 |
|
63 | | -```sh |
64 | | -opencode2-automation init --model provider/model --check pytest |
| 124 | +Edits to existing comments and PR review comments are not supported. Closing the |
| 125 | +issue or closing/merging the PR blocks further rounds. |
| 126 | + |
| 127 | +Management commands run from the target repository: |
| 128 | + |
| 129 | +```bash |
| 130 | +cd /absolute/path/to/your-project |
| 131 | +node "$HOME/opencode2-github-automation/dist/setup.js" status |
| 132 | +node "$HOME/opencode2-github-automation/dist/setup.js" scan |
| 133 | +node "$HOME/opencode2-github-automation/dist/setup.js" pause |
| 134 | +node "$HOME/opencode2-github-automation/dist/setup.js" resume |
65 | 135 | ``` |
66 | 136 |
|
67 | | -Opcjonalne ustawienia w `.opencode/automation.json`: `trigger`, `everySeconds`, |
68 | | -`check` (tablica argumentów komendy) i `authors` (loginy GitHuba). |
69 | | -Domyślny znacznik to `@d3ckerbot`. Zmienisz go, dodając np. |
70 | | -`"trigger": "@mojbot"` do tego pliku i restartując serwis. |
71 | | -Konfigurator nie nadpisuje istniejącego pliku. |
| 137 | +Pausing stops scheduled scans; it does not cancel accepted tasks or active sessions. |
| 138 | +Do not run independent bots on two machines against the same issues: they do not |
| 139 | +share queue ownership across machines. |
72 | 140 |
|
73 | | -Po instalacji dostępne są także `opencode2-automation status`, `scan`, `pause` |
74 | | -i `resume`, uruchamiane w katalogu repozytorium. Pauza zatrzymuje nowe skany; |
75 | | -przyjęte już zadania pozostają w kolejce. |
| 141 | +## Alternative: install only in one project |
76 | 142 |
|
77 | | -Szczegóły kolejki, retry, uprawnień, ograniczeń i osobnego użycia obu pluginów: |
78 | | -[dokumentacja zaawansowana](docs/advanced.md). |
| 143 | +If you have not installed the plugin globally, the local installer builds, |
| 144 | +packs, and installs it inside a target checkout: |
79 | 145 |
|
80 | | -## Dla autora paczki |
| 146 | +```bash |
| 147 | +bash "$HOME/opencode2-github-automation/scripts/install-local.sh" /absolute/path/to/your-project |
| 148 | +``` |
81 | 149 |
|
82 | | -```sh |
| 150 | +It prompts for configuration on first installation and preserves existing settings |
| 151 | +on upgrades. It does not restart OpenCode. Use either global or project-local |
| 152 | +installation; do not enable both for the same project. |
| 153 | + |
| 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 | + |
| 166 | +## Development |
| 167 | + |
| 168 | +```bash |
83 | 169 | npm ci |
84 | 170 | npm run check |
85 | 171 | npm pack |
86 | 172 | ``` |
87 | 173 |
|
88 | | -`npm pack` kompiluje źródła i tworzy archiwum instalacyjne. Publikacja do npm |
89 | | -jest zablokowana przez `private: true`. Plugin używa wyłącznie SDK OpenCode 2; wymaga Node.js 22+. |
| 174 | +`npm run check` runs type checking, tests, and a build. `npm pack` produces a local |
| 175 | +installation archive. Build artifacts, dependencies, and local credentials are |
| 176 | +excluded from the source repository. |
| 177 | + |
| 178 | +Additional documentation (currently in Polish): |
| 179 | +- [Moving the source and installing on another machine](docs/installation.md) |
| 180 | +- [Advanced configuration, retries, permissions, and separate plugins](docs/advanced.md) |
0 commit comments