Repository navigation
Commit b57fdc7
committed
OpenCode 2.x plugin support: dual v1/v2 adapter
Issue #15: opencode 2.0 rewrote the plugin system; the v1-shaped plugin fails to load on v2.
# Project
opencode v2 support (issue #15)
# Changes
Dual-shape plugin entry: a merged default export ({ id, setup, server }) loads on opencode 1.x (reads default.server) and 2.x (reads default.setup, validates the id, strips excess keys). Each host adapter (src/opencode/v1.ts, src/opencode/v2.ts) adapts its SDK to a shared HostCapabilities seam (src/capabilities.ts); all behavior lives in the shared runtime (src/runtime.ts), so both versions get identical features where the host API allows: tools, memory, nudges, chat, watchers, extraction pipeline, wrap-up commands.
V2-specific work: tool schemas pre-converted to JSON Schema (v2's zod detection fails on ours); nudges injected through the context hook (the generate hook never fires for normal prompts - probed live); plugin-state persistence (runtime_state table: extraction buffers, child bookkeeping, wrap-up arms, watcher definitions) rehydrated on same-process reload and pruned on restart except the resumed session; refcounted embedding-model pool shared across the daemon's location instances; chat poller re-hosts its journaled session set after a reload so pending mail wakes the session; child events forwarded by ID for below-root launches; wrap-up commands registered in code with $ARGUMENTS substitution and stale-file removal.
V2 degrades (documented in README + docs/dev/features/opencode-plugin.md): toasts, compaction trigger, app/tab exit (upstream anomalyco/opencode#50984), noReply deliveries, -c listing, extraction-child deletion.
Chat hardening from the same review effort: the reaper leaves name claims so a crash-resumed session reclaims its identity; the chat list CLI gained a session id column, active-only default, and --stale [N|all]; publish.yml runs the full CI gate across the dual-Bun matrix; CI gained a bare-named test summary job to satisfy the main-branch ruleset's required "test" status context.
The design/plan documents (docs/plans/opencode-v2-plugin.md, plugin-state-persistence.md) graduated into docs/dev/features/opencode-plugin.md and are removed per the plans convention; this squash commit is their git archive.1 parent 60ece01 commit b57fdc7
56 files changed
Lines changed: 4518 additions & 1470 deletions
File tree
- .github/workflows
- bin
- docs
- dev
- features
- plans
- user
- src
- opencode
- tests
- qa
- auto
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
16 | | - | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
16 | 34 | | |
| 35 | + | |
17 | 36 | | |
18 | 37 | | |
19 | 38 | | |
20 | 39 | | |
21 | 40 | | |
22 | 41 | | |
23 | 42 | | |
24 | | - | |
25 | 43 | | |
26 | 44 | | |
27 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 23 | | |
30 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
| |||
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
39 | 62 | | |
40 | 63 | | |
41 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
415 | 417 | | |
416 | 418 | | |
417 | 419 | | |
418 | | - | |
| 420 | + | |
419 | 421 | | |
420 | 422 | | |
421 | 423 | | |
| |||
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| 441 | + | |
439 | 442 | | |
440 | 443 | | |
441 | 444 | | |
| |||
447 | 450 | | |
448 | 451 | | |
449 | 452 | | |
450 | | - | |
| 453 | + | |
451 | 454 | | |
452 | 455 | | |
| 456 | + | |
453 | 457 | | |
454 | 458 | | |
455 | 459 | | |
| |||
491 | 495 | | |
492 | 496 | | |
493 | 497 | | |
494 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
495 | 505 | | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
500 | 510 | | |
501 | | - | |
| 511 | + | |
502 | 512 | | |
503 | | - | |
| 513 | + | |
| 514 | + | |
504 | 515 | | |
505 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
506 | 521 | | |
507 | 522 | | |
508 | | - | |
| 523 | + | |
509 | 524 | | |
510 | 525 | | |
511 | 526 | | |
| |||
0 commit comments