Git-backed session sync for OpenCode V2.
Status: pre-alpha. The core sync engine, CLI, and OpenCode server plugin are implemented and covered by unit and end-to-end tests. Child-session transfer and deletion propagation are still pending.
ocsync keeps OpenCode sessions in sync across machines without a resident sync service. Sessions are exported through the official OpenCode V2 HTTP API, stored as encrypted immutable blobs in a private Git repository, and imported on the other machine when needed.
OpenCode stores sessions in a local SQLite database. That is excellent for a single machine, but it means a session created on a laptop is invisible on a desktop. ocsync is built for people who use the same project from more than one computer and want to continue a session where they left it.
It is intentionally not a real-time collaboration layer. For that, connect multiple clients to the same OpenCode server. ocsync solves the offline and multi-server case.
- Official API only. Sessions are transferred with
session.exportandsession.import. The OpenCode database is never modified directly. - No resident service. The sync engine runs on demand, either from the CLI or from the OpenCode server plugin.
- Conflict-preserving. Two divergent edits to the same session are never silently merged or overwritten. Both branches are preserved.
- Encrypted at rest. Session blobs are encrypted before they reach Git.
- No credential sync.
ocsyncsyncs sessions only. Provider credentials, auth files, and OpenCode configuration stay on each machine. - Boring transport. A private Git repository is the source of truth, so the data is versioned and auditable.
OpenCode server ──export/import──> ocsync core ──> private Git repository
▲ │
└──────── plugin trigger ────────┘
- The CLI performs
status,push,pull, andsync. - The server plugin watches session events and invokes the CLI with a debounce. It runs inside the OpenCode server that is already running, so there is no extra daemon.
- Every session revision is an immutable encrypted blob. A per-device index points at the current head. Revisions form a hash chain, which lets
ocsyncdistinguish a fast-forward from a real divergence.
See docs/architecture.md for the full design.
- OpenCode V2 (
>= 2.0.29) - Git
- Bun 1.4+ for development and for building from source
git clone https://github.com/alv67/ocsync.git
cd ocsync
bun install
bun run build
bun link
ocsync --helpThe npm package and prebuilt binaries are not published yet. The GitHub Project tracks the release work.
bun install
bun run check
bun run buildbun run check runs Biome, TypeScript, and the test suite.
With OpenCode V2 on PATH, run:
bash scripts/e2e.shThe script starts two isolated OpenCode servers, creates a temporary session, pushes it from one server, pulls it into the other, and verifies the transcript. Set KEEP_E2E=1 to keep the temporary directory for inspection.
The repository uses a two-branch model:
mainis release-only and protected.developis the integration branch.- Feature branches target
developthrough pull requests.
See CONTRIBUTING.md and docs/github-workflow.md.
Do not report security issues in public issues. See SECURITY.md.
MIT. See LICENSE.
ocsync is an independent community project and is not affiliated with the OpenCode maintainers.