Skip to content

3.3.0: OpenCode 2 support - #9

Merged
lazyalex616 merged 9 commits into
mainfrom
v2-support
Nov 4, 2026
Merged

lazyalex616 merged 9 commits into
mainfrom
v2-support

Conversation

@lazyalex616

Copy link
Copy Markdown
Owner

OpenCode 2 support (3.3.0).

  • Security: OpenCode 2's service.json (config and state folder, both hold a password) is never committed and is untracked from repositories 3.2.x wrote it into. Lock files and per-machine histories are machine-local.
  • Sessions read from and written to OpenCode 2's tables (session_v2 etc.); a fresh 2.x database has no session table, so 3.2.0 failed every push there. Imported sessions are placed in the project OpenCode 2 resolves, so they show in /session. OpenCode 1 and 2 machines can share a repository.
  • opencode-sync repair-sessions [--apply] for sessions OpenCode's own 1.x migration hid.
  • Credential bridge between auth.json and the OpenCode 2 credential table.
  • One machine at a time renews a shared ChatGPT login (refs/leases/openai, --force-with-lease).
  • cli.json shared without machine plugin paths; restart hints updated; URLs moved to lazyalex616.
  • README (en, zh-CN) rewritten; CHANGELOG 3.3.0.

Verified locally: npm run check (255 passed), and end to end with two isolated OpenCode 2.2.5 homes and a local bare remote (session visible via opencode session list on the other machine, account switch propagated, plugin loads without errors). All test values are fake.

…istories

OpenCode 2 writes service.json (with a plaintext password) into both the config and the state directory. The config directory is the repository worktree, so git add -A published it; includeState copied the state copy. Both are now ignored, untracked from repositories an older version wrote, and this machine's copy survives pulls of such commits.
…ject OpenCode 2 resolves

OpenCode 2 stores sessions in session_v2/session_message/session_part; a fresh 2.2.5 database has no session table, so 3.2.0 failed every push with 'no such table: session'. Databases are now detected per machine and v2 sessions travel as formatVersion 2 shards with their event sequence, instruction and attachment rows. Runtime flags are reset so a receiving machine never resumes a conversation by itself. On import a session is placed in the project OpenCode 2 resolves for its directory (creating the deterministic directory project, mapping the exporting machine's home, parking unknown directories in the home project), otherwise /session never lists it. Shards of the other major version are skipped and kept.
Sessions OpenCode 2 migrated from 1.x keep the synthetic global project or a stale project row of the same worktree, so /session never lists them. repair-sessions moves each one into the project OpenCode 2 resolves for its directory, parks global sessions without one in the home project, and is a dry run unless --apply is given.
OpenCode 2 keeps accounts in the credential table and reads auth.json at most once; a database created fresh by 2.x never reads it at all, so syncing auth.json did nothing. With includeCredentials on, the bridge copies the account OpenCode uses into auth.json before a push and applies incoming entries after a pull. Change detection uses per-integration fingerprints in a machine-local file (hashes only). Rotated OAuth tokens update in place, a later expiry wins a conflict, a missing incoming entry never logs a machine out, and a broken auth.json is left untouched.
With credential sync on, every machine holds the same ChatGPT OAuth login and a refresh invalidates the old refresh token, so machines refreshing independently log each other out. The scheduled job now claims refs/leases/openai with --force-with-lease (atomic on the server) before refreshing three days ahead of expiry; a claim older than 15 minutes may be taken over. The token request runs in a child process so the configured proxy applies, and the token travels on stdin. On by default with includeCredentials, off with openaiRefreshLease: false.
…to lazyalex616

cli.json (OpenCode 2 interface preferences) joins the config category; plugin entries pointing into this machine's global plugins folder are dropped before staging. OpenCode 2 reloads configuration by itself, so the restart hint now says when a restart is still needed. Repository URLs follow the account rename.
…ocal copy

Found in the two-home OpenCode 2.2.5 sandbox: after importing a session, the receiving machine re-exported it on its next push because its shard bytes differ (origin home, placement), so every received session bounced back as a change. An existing shard at least as new as the local session is now kept as it is.
Version bump, CHANGELOG (en, zh-CN) and README sections: what is never synced, OpenCode 2 sessions, credentials and the OpenAI lease, repair-sessions, Upgrading to OpenCode 2.
Restructured around what users do: install, first run, what gets synced, an OpenCode 2 overview, autosync, overrides, sessions, credentials, safety, menu, plugin, commands, settings reference, troubleshooting and upgrading. Adds requirements, the credential bridge and OpenAI lease, repair-sessions, and OpenCode 2 troubleshooting.
@lazyalex616
lazyalex616 merged commit c40f4f4 into main Nov 4, 2026
14 checks passed
@lazyalex616
lazyalex616 deleted the v2-support branch November 5, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant