Skip to content

Commit e28cb69

Browse files
committed
Support OpenCode 2.0.6 service and session APIs
1 parent 0016e90 commit e28cb69

14 files changed

Lines changed: 246 additions & 145 deletions

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ include the full version, for example `## 0.7.0-beta.1`.
1818

1919
### Fixed
2020

21+
- Restore compatibility with OpenCode 2.0.6: update the pinned SDKs, discover
22+
services through `/api/info`, refresh owner activity with `session.update`,
23+
and interrupt sessions with `resume: false`. Replace the removed headless
24+
activation command with location-scoped `plugin.list` and document validation.
25+
2126
- Honor formal approvals for the exact verified PR commit even when publication
2227
or description recovery finishes later. Retain review revocation, authorization,
2328
and merge-readiness checks; keep timestamp gating for unbound merge comments.

‎README.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ titles, and can merge after an authorized approval. The TUI is optional.
1111

1212
## Requirements
1313

14-
- OpenCode **2** with a working model; tested with `0.0.0-beta-19398`.
14+
- OpenCode **2.0.6** with a working model; client/plugin SDK pinned to `2.0.6`.
1515
- Node.js 22+, npm, and Git on macOS/Linux.
1616
- GitHub authentication (`gh auth login` and `gh auth setup-git`, or a token in
1717
the service environment) and permission to comment, push, and create PRs.
@@ -113,13 +113,19 @@ Only the authenticated GitHub user is allowed by default; add colleagues to
113113
Run once for **each configured primary checkout**, with its absolute path:
114114

115115
```bash
116-
opencode2 api v2.plugin.awaitActivation --param 'location[directory]=/absolute/path/to/your-project'
116+
opencode2 api plugin.list --param 'location[directory]=/absolute/path/to/your-project'
117117
```
118118

119119
This starts the shared service if needed and loads the project's plugins. The
120-
command exits; the bot keeps running without a TUI or extra monitoring process.
120+
response lists the loaded plugins; confirm `automation` has `state.status` equal
121+
to `active`. The command exits; the bot keeps running without a TUI or extra monitoring process.
121122
**Repeat it after every service restart.**
122123

124+
OpenCode 2.0.6 uses operation names without the `v2.` prefix and no longer exposes
125+
`plugin.awaitActivation`. Upgrade the automation package together with OpenCode;
126+
older beta SDKs cannot discover its service correctly. See
127+
[upgrade compatibility](docs/installation.md#opencode-206-compatibility).
128+
123129
For automatic startup after a machine reboot, put one invocation per project in
124130
your operating system's startup mechanism, under the same user, after networking
125131
is available. Use absolute executable/repository paths (`command -v opencode2`

‎docs/advanced.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The [README](../README.md) covers the combined package and setup wizard. Use
44
`examples/advanced.opencode.jsonc` for custom schedules, multiple repositories,
55
or separately loaded scheduler and dispatcher components.
66

7-
Both components use only the OpenCode **2** SDK, pinned to `0.0.0-beta-19398`:
7+
Both components use only the OpenCode **2** SDK, pinned to `2.0.6`:
88

99
- `automation.scheduler`: invokes configured RPC methods on an interval.
1010
- `automation.github`: owns issue discovery, comments, isolated work, verification,

‎docs/architecture.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ In the shared background service, each scheduler/dispatcher component renews one
7272
empty maintenance session in the owner location at startup and every ten minutes.
7373
OpenCode counts durable session events as activity; polling plugin APIs alone
7474
does not prevent its hourly inactivity eviction. No model is prompted by keepalive.
75-
The service PID must match the plugin process before any maintenance session is
76-
created. Shutdown releases local SDK waits independently of adapter cancellation,
75+
The service is discovered through `/api/info`; `server.info` must report the plugin
76+
process PID before any maintenance session is created. `session.update` refreshes
77+
its title without prompting a model. Shutdown releases local SDK waits independently of adapter cancellation,
7778
settles state writes, bounds RPC disposal, and releases locks. A healthy worktree
7879
session continues and the replacement owner reconciles its saved identity.
7980

‎docs/bot-workflow.md‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ happen inside `running`; they are not additional persisted phases.
1616

1717
```mermaid
1818
flowchart TD
19-
Load[Load combined automation plugin] --> Owner{Primary Git checkout root?}
19+
Activate[Open TUI or call plugin.list for the owner location] --> Load[Load combined automation plugin]
20+
Load --> Owner{Primary Git checkout root?}
2021
Owner -->|No or outside Git| Inactive[Plugin stays inactive]
2122
Owner -->|Yes| Config[Use nonempty plugin options or read .opencode/automation.json]
2223
Config -->|No project config| Inactive
@@ -49,8 +50,9 @@ flowchart TD
4950
Merge --> Worker
5051
RPC -.-> Keepalive[Each component touches the same empty owner session every ten minutes]
5152
State -.-> Keepalive
52-
Keepalive --> PID{Registered service PID matches this process?}
53-
PID -->|Yes| Touch[Create or reuse maintenance session, then emit rename event]
53+
Keepalive --> Discover[Discover service through /api/info]
54+
Discover --> PID{server.info PID matches this process?}
55+
PID -->|Yes| Touch[Create or reuse maintenance session, then session.update its title]
5456
PID -->|No| Skip[Skip keepalive]
5557
Stop[Owner reload or shutdown] --> Cleanup[Stop timers, save stopped inventory snapshots, settle writes, dispose RPC, release locks]
5658
Cleanup --> Preserve[Preserve durable queue and healthy worktree execution]
@@ -90,7 +92,9 @@ flowchart TD
9092
- Each component renews one empty owner maintenance session at startup and every
9193
ten minutes. Durable session events refresh OpenCode's inactivity timer; listing
9294
plugins does not. No model is prompted. A PID check prevents touching a different
93-
service. Requests do not overlap and have a 15-second deadline. Pausing issue
95+
service, using `server.info` after discovery through `/api/info` in SDK 2.0.6.
96+
The title update uses `session.update`. Requests do not overlap and have a
97+
15-second deadline. Pausing issue
9498
scans does not pause keepalive. Standalone servers without a matching registered
9599
service skip it.
96100
- State is schema-validated and saved through a temporary file, file sync, and
@@ -309,13 +313,13 @@ sequenceDiagram
309313
alt Operator closes task
310314
U->>D: Confirm Stop and close task in bot menu
311315
D->>D: Persist closing and reject new checkpoints and prompts
312-
D->>S: Interrupt known task sessions and wait for idleness
316+
D->>S: Interrupt known task sessions with resume false and wait for idleness
313317
D->>D: Drain in-flight worker and persist closed
314318
Note over D,G: Preserve work and history, no GitHub closure request
315319
else Operator cancels the round
316320
U->>D: Confirm Cancel current round
317321
D->>D: Persist cancelling and reject new execution checkpoints
318-
D->>S: Interrupt saved sessions and wait for idleness
322+
D->>S: Interrupt saved sessions with resume false and wait for idleness
319323
D->>D: Drain worker and question posts, archive round, enter watching
320324
Note over D,G: Keep PR tracking and future feedback, preserve cancelled worktree
321325
else Owner is disposed
@@ -408,7 +412,7 @@ flowchart TD
408412
ID --> Session[Get saved helper or create only on explicit not-found]
409413
Session --> Prompt[Send deterministic attachment prompt, hooks disable all tools]
410414
Prompt --> Wait[Wait with session deadline]
411-
Wait -->|Timeout| Interrupt[Attempt helper interruption and return error]
415+
Wait -->|Timeout| Interrupt[Interrupt helper with resume false and return error]
412416
Wait -->|Other failure| Error
413417
Wait -->|Completed| Result{Succeeded outcome and non-error final assistant with finish stop?}
414418
Result -->|No| Error
@@ -724,7 +728,7 @@ flowchart TD
724728
Close[bot menu: Stop and close task] --> Flight{Publication or merge already in flight?}
725729
Flight -->|Yes| RejectClose[Reject closure, wait and try again]
726730
Flight -->|No| SaveClose[Persist closing before interruption]
727-
SaveClose --> Interrupt[Interrupt known sessions, missing sessions count as stopped]
731+
SaveClose --> Interrupt[Interrupt with resume false, missing sessions count as stopped]
728732
Interrupt --> Drain[Wait for current worker and pending question posts]
729733
Drain --> Again[Interrupt again to cover in-flight session creation]
730734
Again --> Closed[Persist closed, preserve history and all local work]
@@ -735,7 +739,7 @@ flowchart TD
735739
CancelRound[Cancel current round] --> Publish{Publication or merge in flight?}
736740
Publish -->|Yes| RejectClose
737741
Publish -->|No| SaveCancel[Persist cancelling, block prompts, hooks and checkpoints]
738-
SaveCancel --> DrainCancel[Interrupt sessions, drain worker and questions, interrupt again]
742+
SaveCancel --> DrainCancel[Interrupt with resume false, drain worker and questions, interrupt again]
739743
DrainCancel -->|Success| Watch[Archive round, clear live errors, enter watching]
740744
DrainCancel -->|Failure| RetryCancel[Keep cancelling and error, retry after 30 seconds or owner restart]
741745
RetryCancel --> DrainCancel

‎docs/installation.md‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ hook; remove the OpenCode loaders first as described in the README.
4444

4545
## Prerequisites
4646

47-
- OpenCode **2**, with a working model. Tested SDK version: `0.0.0-beta-19398`.
47+
- OpenCode **2.0.6**, with a working model. Client/plugin SDK version: `2.0.6`.
4848
- Node.js 22+, npm, Git, and Bash on macOS/Linux.
4949
- GitHub authentication and permission to comment, push, create PRs, and merge.
5050
- A target repository with issues enabled and at least one pushed commit.
@@ -113,6 +113,29 @@ entrypoints in an isolated Node installation without initializing a renderer.
113113

114114
## Testing and migration
115115

116+
### OpenCode 2.0.6 compatibility
117+
118+
This branch pins `@opencode/client`, `@opencode/plugin`, and the development theme
119+
package to `2.0.6`. Update the automation package when upgrading OpenCode from the
120+
older beta build. An old package can still appear active and scan GitHub while
121+
its management CLI and owner keepalive fail to discover the newer service.
122+
123+
Service discovery now probes `/api/info`. Owner keepalive verifies the service
124+
PID with `client.server.info()` and updates the same empty maintenance session
125+
through `session.update`. Session interruption uses `resume: false` to stop work
126+
without automatically resuming it. The package does not claim compatibility
127+
with the earlier beta API.
128+
129+
For headless startup, use `opencode2 api plugin.list --param
130+
'location[directory]=/absolute/path/to/project'` on one line. Confirm that
131+
`automation` is `active` in the response and repeat for each owner after a
132+
service restart. The old `v2.plugin.awaitActivation` operation is unavailable.
133+
`opencode2 api session.active` lists active execution before a planned restart.
134+
After upgrading, verify `opencode2-automation status` inside each owner checkout,
135+
fresh dispatcher/scheduler timestamps, and `/bot` in a reopened TUI.
136+
137+
### State preservation
138+
116139
Use a separate test repository when testing on another machine. Independent
117140
machines do not share queue ownership and can duplicate work on the same issues.
118141
This installation procedure does not migrate sessions, queues, or worktrees.

0 commit comments

Comments
 (0)