opencode-github-sync 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +535 -220
  2. package/README.zh-CN.md +387 -197
  3. package/dist/cli/app.d.ts +39 -0
  4. package/dist/cli/app.d.ts.map +1 -0
  5. package/dist/cli/app.js +179 -0
  6. package/dist/cli/app.js.map +1 -0
  7. package/dist/cli/args.d.ts +10 -0
  8. package/dist/cli/args.d.ts.map +1 -0
  9. package/dist/cli/args.js +39 -0
  10. package/dist/cli/args.js.map +1 -0
  11. package/dist/cli/i18n.d.ts +378 -0
  12. package/dist/cli/i18n.d.ts.map +1 -0
  13. package/dist/cli/i18n.js +793 -0
  14. package/dist/cli/i18n.js.map +1 -0
  15. package/dist/cli/index.js +362 -115
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/cli/menu.d.ts +52 -0
  18. package/dist/cli/menu.d.ts.map +1 -0
  19. package/dist/cli/menu.js +1126 -0
  20. package/dist/cli/menu.js.map +1 -0
  21. package/dist/cli/render.d.ts +3 -0
  22. package/dist/cli/render.d.ts.map +1 -1
  23. package/dist/cli/render.js +6 -1
  24. package/dist/cli/render.js.map +1 -1
  25. package/dist/cli/ui.d.ts +62 -0
  26. package/dist/cli/ui.d.ts.map +1 -0
  27. package/dist/cli/ui.js +383 -0
  28. package/dist/cli/ui.js.map +1 -0
  29. package/dist/core/autosync.d.ts +136 -0
  30. package/dist/core/autosync.d.ts.map +1 -0
  31. package/dist/core/autosync.js +516 -0
  32. package/dist/core/autosync.js.map +1 -0
  33. package/dist/core/bundle.d.ts +11 -0
  34. package/dist/core/bundle.d.ts.map +1 -0
  35. package/dist/core/bundle.js +87 -0
  36. package/dist/core/bundle.js.map +1 -0
  37. package/dist/core/categories.d.ts +37 -0
  38. package/dist/core/categories.d.ts.map +1 -0
  39. package/dist/core/categories.js +115 -0
  40. package/dist/core/categories.js.map +1 -0
  41. package/dist/core/compare.d.ts +21 -0
  42. package/dist/core/compare.d.ts.map +1 -0
  43. package/dist/core/compare.js +124 -0
  44. package/dist/core/compare.js.map +1 -0
  45. package/dist/core/credentials.d.ts +40 -0
  46. package/dist/core/credentials.d.ts.map +1 -0
  47. package/dist/core/credentials.js +364 -0
  48. package/dist/core/credentials.js.map +1 -0
  49. package/dist/core/env.d.ts +16 -0
  50. package/dist/core/env.d.ts.map +1 -0
  51. package/dist/core/env.js +47 -0
  52. package/dist/core/env.js.map +1 -0
  53. package/dist/core/fsx.d.ts +2 -0
  54. package/dist/core/fsx.d.ts.map +1 -1
  55. package/dist/core/fsx.js +6 -0
  56. package/dist/core/fsx.js.map +1 -1
  57. package/dist/core/git.d.ts +6 -0
  58. package/dist/core/git.d.ts.map +1 -1
  59. package/dist/core/git.js +44 -4
  60. package/dist/core/git.js.map +1 -1
  61. package/dist/core/guard.d.ts +36 -0
  62. package/dist/core/guard.d.ts.map +1 -0
  63. package/dist/core/guard.js +65 -0
  64. package/dist/core/guard.js.map +1 -0
  65. package/dist/core/history.d.ts +38 -0
  66. package/dist/core/history.d.ts.map +1 -0
  67. package/dist/core/history.js +98 -0
  68. package/dist/core/history.js.map +1 -0
  69. package/dist/core/index.d.ts +11 -0
  70. package/dist/core/index.d.ts.map +1 -1
  71. package/dist/core/index.js +11 -0
  72. package/dist/core/index.js.map +1 -1
  73. package/dist/core/lease.d.ts +52 -0
  74. package/dist/core/lease.d.ts.map +1 -0
  75. package/dist/core/lease.js +235 -0
  76. package/dist/core/lease.js.map +1 -0
  77. package/dist/core/notify.d.ts +9 -0
  78. package/dist/core/notify.d.ts.map +1 -0
  79. package/dist/core/notify.js +69 -0
  80. package/dist/core/notify.js.map +1 -0
  81. package/dist/core/projects.d.ts +79 -0
  82. package/dist/core/projects.d.ts.map +1 -0
  83. package/dist/core/projects.js +192 -0
  84. package/dist/core/projects.js.map +1 -0
  85. package/dist/core/recovery.d.ts +26 -0
  86. package/dist/core/recovery.d.ts.map +1 -0
  87. package/dist/core/recovery.js +56 -0
  88. package/dist/core/recovery.js.map +1 -0
  89. package/dist/core/repair.d.ts +44 -0
  90. package/dist/core/repair.d.ts.map +1 -0
  91. package/dist/core/repair.js +81 -0
  92. package/dist/core/repair.js.map +1 -0
  93. package/dist/core/repo.d.ts +34 -2
  94. package/dist/core/repo.d.ts.map +1 -1
  95. package/dist/core/repo.js +87 -5
  96. package/dist/core/repo.js.map +1 -1
  97. package/dist/core/rows.d.ts +36 -0
  98. package/dist/core/rows.d.ts.map +1 -0
  99. package/dist/core/rows.js +75 -0
  100. package/dist/core/rows.js.map +1 -0
  101. package/dist/core/scheduler.d.ts +138 -0
  102. package/dist/core/scheduler.d.ts.map +1 -0
  103. package/dist/core/scheduler.js +531 -0
  104. package/dist/core/scheduler.js.map +1 -0
  105. package/dist/core/sessions.d.ts +32 -4
  106. package/dist/core/sessions.d.ts.map +1 -1
  107. package/dist/core/sessions.js +316 -104
  108. package/dist/core/sessions.js.map +1 -1
  109. package/dist/core/settings.d.ts +67 -0
  110. package/dist/core/settings.d.ts.map +1 -1
  111. package/dist/core/settings.js +45 -2
  112. package/dist/core/settings.js.map +1 -1
  113. package/dist/core/setup.d.ts +20 -0
  114. package/dist/core/setup.d.ts.map +1 -1
  115. package/dist/core/setup.js +87 -4
  116. package/dist/core/setup.js.map +1 -1
  117. package/dist/core/sqlite.d.ts +2 -0
  118. package/dist/core/sqlite.d.ts.map +1 -1
  119. package/dist/core/sqlite.js +14 -0
  120. package/dist/core/sqlite.js.map +1 -1
  121. package/dist/core/stage.d.ts +18 -0
  122. package/dist/core/stage.d.ts.map +1 -1
  123. package/dist/core/stage.js +133 -4
  124. package/dist/core/stage.js.map +1 -1
  125. package/dist/core/sync.d.ts +25 -0
  126. package/dist/core/sync.d.ts.map +1 -1
  127. package/dist/core/sync.js +283 -43
  128. package/dist/core/sync.js.map +1 -1
  129. package/dist/core/update.d.ts +21 -0
  130. package/dist/core/update.d.ts.map +1 -0
  131. package/dist/core/update.js +75 -0
  132. package/dist/core/update.js.map +1 -0
  133. package/dist/plugin/index.d.ts.map +1 -1
  134. package/dist/plugin/index.js +6 -5
  135. package/dist/plugin/index.js.map +1 -1
  136. package/package.json +4 -4
package/README.md CHANGED
@@ -1,175 +1,277 @@
1
1
  <p align="center">
2
- <img src="docs/banner.svg" alt="opencode-github-sync" width="820">
2
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/images/en/01-hero.png" alt="opencode-github-sync: one config, every machine" width="880">
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
6
  <a href="https://www.npmjs.com/package/opencode-github-sync"><img alt="npm" src="https://img.shields.io/npm/v/opencode-github-sync?style=flat-square&color=7aa2f7&labelColor=1a1e2b"></a>
7
- <a href="https://github.com/doomsday616/opencode-github-sync/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/doomsday616/opencode-github-sync/ci.yml?style=flat-square&color=9ece6a&labelColor=1a1e2b&label=ci"></a>
8
- <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-bb9af7?style=flat-square&labelColor=1a1e2b"></a>
7
+ <a href="https://github.com/lazyalex616/opencode-github-sync/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/lazyalex616/opencode-github-sync/ci.yml?style=flat-square&color=9ece6a&labelColor=1a1e2b&label=ci"></a>
8
+ <a href="https://github.com/lazyalex616/opencode-github-sync/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-bb9af7?style=flat-square&labelColor=1a1e2b"></a>
9
9
  <img alt="platform" src="https://img.shields.io/badge/macOS%20·%20Windows%20·%20Linux-9ece6a?style=flat-square&labelColor=1a1e2b&label=runs%20on">
10
+ <img alt="OpenCode" src="https://img.shields.io/badge/OpenCode-1.x%20·%202.x-e0af68?style=flat-square&labelColor=1a1e2b">
10
11
  </p>
11
12
 
12
13
  <p align="center">
13
- <a href="./README.zh-CN.md">简体中文</a>
14
+ <a href="https://github.com/lazyalex616/opencode-github-sync/blob/main/README.zh-CN.md">简体中文</a>
14
15
  &nbsp;·&nbsp;
15
- <a href="#quick-start">Quick start</a>
16
+ <a href="#install">Install</a>
16
17
  &nbsp;·&nbsp;
17
- <a href="#per-machine-overrides">Overrides</a>
18
+ <a href="#opencode-2">OpenCode 2</a>
18
19
  &nbsp;·&nbsp;
19
- <a href="#session-sync">Sessions</a>
20
+ <a href="#autosync">Autosync</a>
20
21
  &nbsp;·&nbsp;
21
- <a href="#command-reference">Commands</a>
22
+ <a href="#commands">Commands</a>
23
+ &nbsp;·&nbsp;
24
+ <a href="#troubleshooting">Troubleshooting</a>
22
25
  </p>
23
26
 
24
27
  ---
25
28
 
26
- You use OpenCode on more than one machine. Your config, agents, commands, skills
27
- and MCP servers live on whichever one you touched last.
28
-
29
- **opencode-github-sync** keeps them all in step through a private GitHub
30
- repository — as an OpenCode plugin, as a CLI, or both.
31
-
32
- ```bash
33
- npm install -g opencode-github-sync
34
- opencode-sync init # creates the private repo and configures this machine
35
- opencode-sync push
36
- ```
37
-
38
- <p align="center">
39
- <img src="docs/demo.svg" alt="opencode-sync push" width="760">
40
- </p>
29
+ You use OpenCode on more than one computer, and every machine drifts: a new
30
+ agent here, an MCP server there, a skill you installed on the laptop and forgot
31
+ on the desktop.
32
+
33
+ **opencode-github-sync** keeps all of them on one setup through a private
34
+ GitHub repository. Run it by hand when you want, or let your everyday machines
35
+ sync themselves in the background. It works with OpenCode 1 and OpenCode 2,
36
+ and both can share the same repository.
37
+
38
+ **What you get**
39
+
40
+ - Config, instruction files, agents, commands, plugins, themes and skills on
41
+ every machine.
42
+ - Optionally your logins and your recent conversations, too.
43
+ - Settings that belong to one machine stay on that machine.
44
+ - Nothing is overwritten without a copy kept first, and a broken sync can be
45
+ repaired from the command line even when OpenCode will not start.
46
+
47
+ ## Contents
48
+
49
+ - [Install](#install)
50
+ - [First run](#first-run)
51
+ - [What gets synced](#what-gets-synced)
52
+ - [OpenCode 2](#opencode-2)
53
+ - [Autosync](#autosync)
54
+ - [Per-machine overrides](#per-machine-overrides)
55
+ - [Sessions](#sessions)
56
+ - [Credentials](#credentials)
57
+ - [Safety](#safety)
58
+ - [The menu](#the-menu)
59
+ - [OpenCode plugin](#opencode-plugin)
60
+ - [Commands](#commands)
61
+ - [Settings file](#settings-file)
62
+ - [Troubleshooting](#troubleshooting)
63
+ - [Upgrading](#upgrading)
64
+ - [Development](#development)
41
65
 
42
66
  ---
43
67
 
44
- ## Why another sync tool
45
-
46
- Most config-sync tools stop being safe the moment real use hits them. These are
47
- the three places that happens, and what this one does instead.
68
+ ## Install
48
69
 
49
- | | Typical approach | Here |
50
- | ------------------ | ----------------------------------------------- | -------------------------------------------------------------------------- |
51
- | **Machine differences** | Every machine forced identical | [Per-machine overrides](#per-machine-overrides) that sync can never overwrite |
52
- | **Sessions** | Commit `opencode.db` — gigabytes, unmergeable | [Selective per-session shards](#session-sync), a few MB, conflict-free |
53
- | **When it breaks** | Plugin-only: bad config means no way back | The CLI runs outside OpenCode and can always recover you |
70
+ **macOS / Linux**
54
71
 
55
- Plus the boring things that turn out to matter:
72
+ ```bash
73
+ curl -fsSL https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/install.sh | sh
74
+ ```
56
75
 
57
- - **Symlinks are refused, not followed.** No copying files out of the machine by accident, no junction turning a delete into the wrong delete.
58
- - **Every replacement is atomic.** A crash mid-sync cannot leave a half-written config that stops OpenCode from starting.
59
- - **A push is verified against the remote.** `git push` can exit `0` without the remote moving; that is checked, not assumed.
60
- - **Nothing runs twice at once.** A cross-process lock covers the plugin, the CLI and every OpenCode window.
61
- - **Credentials are opt-in** and refused outright on a public repository.
62
- - **Your hostname never leaves the machine.** Commits are signed with a stable pseudonym, so a corporate asset tag never lands in a repo that might not stay private.
76
+ **Windows** (PowerShell 5.1 or 7)
63
77
 
64
- ---
78
+ ```powershell
79
+ irm https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/install.ps1 | iex
80
+ ```
65
81
 
66
- ## Install
82
+ The installer checks for Node.js 18+ and git. If one is missing it shows the
83
+ command that would install it and asks before running anything. Then it runs
84
+ `npm install -g opencode-github-sync@latest` and opens the menu.
67
85
 
68
- ### As an OpenCode plugin
86
+ Already have Node.js? This does the same:
69
87
 
70
- ```jsonc
71
- // ~/.config/opencode/opencode.json
72
- {
73
- "$schema": "https://opencode.ai/config.json",
74
- "plugin": ["opencode-github-sync"]
75
- }
88
+ ```bash
89
+ npm install -g opencode-github-sync
90
+ opencode-sync
76
91
  ```
77
92
 
78
- This `"plugin"` form works on both OpenCode 1.x (1.3.4 and later) and
79
- OpenCode 2.x: 1.x reads only `"plugin"`, and 2.x still accepts it alongside its
80
- native `"plugins"` key. If you run only OpenCode 2, you can list it under
81
- `"plugins"` instead. Do not list the plugin under both keys — OpenCode 2 loads
82
- entries from both lists.
93
+ **Requirements**
83
94
 
84
- OpenCode 1.0–1.3.3 cannot load 3.1.0 and later; stay on
85
- `opencode-github-sync@3.0.1` there.
95
+ | | Needed for |
96
+ | --- | --- |
97
+ | Node.js 18 or newer | everything |
98
+ | Node.js 22.5 or newer | sessions, and credentials on OpenCode 2 (they use Node's built-in SQLite) |
99
+ | git | everything |
100
+ | GitHub CLI (`gh`), signed in | only `init`, which creates the repository for you |
101
+ | OpenCode 1.3.4+ or 2.x | the optional plugin |
86
102
 
87
- OpenCode installs it on the next start. The plugin adds a pull on startup, an
88
- optional push when a session goes idle, and an `opencode_sync` tool so you can
89
- just ask for a sync in plain language.
103
+ ### Set up a machine in one line
90
104
 
91
- ### As a CLI
105
+ Pass options to skip every question, for example when preparing a new
106
+ machine:
92
107
 
93
108
  ```bash
94
- npm install -g opencode-github-sync
109
+ curl -fsSL https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/install.sh | sh -s -- --mode auto --repo you/my-opencode-config
95
110
  ```
96
111
 
97
- Keep the CLI even if you use the plugin. A plugin cannot fix the configuration
98
- that stops OpenCode from loading the plugin.
112
+ ```powershell
113
+ & ([scriptblock]::Create((irm https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/install.ps1))) -Mode auto -Repo you/my-opencode-config
114
+ ```
99
115
 
100
- **Requirements** — git, and [`gh`](https://cli.github.com) for automatic setup.
101
- Node 18+ for config sync; Node 22.5+ or Bun for [session sync](#session-sync).
116
+ | Option | Meaning |
117
+ | --- | --- |
118
+ | `--mode cli` | Install the command only |
119
+ | `--mode link` | Link `--repo` and sync once |
120
+ | `--mode auto` | Link, sync once and turn on autosync |
121
+ | `--repo owner/name` | The repository (a git URL works too); created as private if it does not exist |
122
+ | `--interval N` | Autosync every N minutes (minimum 2, default 5) |
123
+ | `--lang en` / `zh-CN` | Interface language |
124
+ | `--proxy URL` | Proxy for npm and git, during install and for later syncs |
125
+ | `--yes` | Install a missing Node.js or git without asking |
126
+ | `--package SPEC` | npm package spec to install (default `opencode-github-sync@latest`) |
127
+ | `--dry-run` | Print what would run, change nothing |
128
+
129
+ On Windows each option is the same word with one leading dash: `-Mode`,
130
+ `-Repo`, `-Interval`, `-Lang`, `-Proxy`, `-Yes`, `-Package`, `-DryRun`.
102
131
 
103
132
  ---
104
133
 
105
- ## Quick start
106
-
107
- ### First machine
134
+ ## First run
108
135
 
109
- ```bash
110
- opencode-sync init # → <you>/my-opencode-config
111
- opencode-sync init team-config # custom name
112
- opencode-sync init my-org/shared # inside an organisation
113
- opencode-sync push
114
- ```
136
+ <p align="center">
137
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/images/en/03-pick-your-setup.png" alt="Command only, or primary device with autosync" width="760">
138
+ </p>
115
139
 
116
- `init` creates a **private** repository, writes
117
- `~/.config/opencode/opencode-sync.jsonc`, and leaves an empty overrides file
118
- ready for you.
140
+ The first time you run `opencode-sync` it asks how this machine should work:
119
141
 
120
- ### Every other machine
142
+ | | Command only | Primary device + autosync |
143
+ | --- | --- | --- |
144
+ | How it syncs | You run `opencode-sync push` / `pull`, or the plugin pulls when OpenCode starts | The operating system syncs every few minutes, even while OpenCode is closed |
145
+ | Good for | A machine you use now and then, a shared or locked-down machine | The machines you work on every day |
146
+ | Background job | None | Task Scheduler, launchd or a systemd timer |
121
147
 
122
- ```bash
123
- opencode-sync link doomsday616/my-opencode-config
124
- opencode-sync pull
125
- ```
148
+ Then it links a repository:
126
149
 
127
- Then restart OpenCode.
150
+ - **No repository yet?** It creates a private one with `gh` (or run
151
+ `opencode-sync init`).
152
+ - **Already have one?** Pick it from the list, or give `owner/name` or any git
153
+ URL (or run `opencode-sync link owner/name`).
128
154
 
129
- ### Day to day
155
+ If the repository already has content and this machine has its own files, the
156
+ menu shows the differences and lets you pick a side. The losing side's files
157
+ are copied to the [recovery folder](#safety) first.
130
158
 
131
- ```bash
132
- opencode-sync push # share what changed here
133
- opencode-sync pull # take what changed elsewhere
134
- opencode-sync status # what is in sync, what is not
135
- ```
159
+ You can change your mind any time under **Autosync**. Autosync is per machine:
160
+ turning it on here never turns it on anywhere else.
136
161
 
137
162
  ---
138
163
 
139
164
  ## What gets synced
140
165
 
141
166
  <p align="center">
142
- <img src="docs/architecture.svg" alt="Architecture" width="880">
167
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/images/en/02-how-it-works.png" alt="Each machine pushes and pulls through one private repository" width="760">
143
168
  </p>
144
169
 
145
- | Source | In the repo | Contents |
146
- | -------------------------- | ----------- | -------------------------------------------- |
147
- | `~/.config/opencode/` | repo root | config, agents, commands, skills, themes, MCP |
148
- | `~/.local/share/opencode/` | `_data/` | project metadata, optional credentials |
149
- | `~/.local/state/opencode/` | `_state/` | frecency, model cache, prompt history |
150
- | `~/.agents/skills/` | `_agents/` | skills installed by the `skills` CLI |
151
- | selected sessions | `_sessions/`| one gzipped shard per session |
170
+ Your `~/.config/opencode` folder becomes a working copy of the repository.
171
+ Everything that lives elsewhere is mirrored into a folder inside it.
172
+
173
+ | On your machine | In the repository | What it holds |
174
+ | --- | --- | --- |
175
+ | `~/.config/opencode/` | the root | `opencode.json(c)`, `tui.json(c)`, OpenCode 2's `cli.json`, agents, commands, plugins, themes, instruction files |
176
+ | `~/.local/share/opencode/` | `_data/` | project metadata; logins if you [opt in](#credentials) |
177
+ | `~/.local/state/opencode/` | `_state/` | model cache and other interface state |
178
+ | `~/.agents/skills/` | `_agents/` | skills installed with the `skills` CLI |
179
+ | selected sessions | `_sessions/` | one small compressed file per session, if you [opt in](#sessions) |
180
+ | your extra paths | `_extra/` | any other file or folder you add, such as `.config/gh/config.yml` |
181
+
182
+ Each part can be switched off under **What to sync**. A part you switch off
183
+ stays local in both directions: your edits are not sent, and other machines'
184
+ versions do not replace yours.
185
+
186
+ **Never synced**
187
+
188
+ - The `opencode.db` database itself, tool output, snapshots and logs. Sessions
189
+ travel as separate small files instead.
190
+ - `node_modules` and other generated folders.
191
+ - opencode-sync's own settings and overrides files.
192
+ - Anything that describes one machine rather than your setup: OpenCode 2's
193
+ `service.json` (one in the config folder and one in the state folder; each
194
+ holds the local background service's password), lock files, prompt history,
195
+ recent-file lists, and `cli.json` plugin entries that point into this
196
+ machine's home folder.
152
197
 
153
- **Never synced:** `opencode.db` and its journals, tool output, snapshots, logs,
154
- and your local settings and overrides files.
198
+ ---
155
199
 
156
- Add anything else with `extraPaths`:
200
+ ## OpenCode 2
157
201
 
158
- ```jsonc
159
- {
160
- "extraPaths": [".tavily", ".config/gh/config.yml"]
161
- }
162
- ```
202
+ opencode-github-sync 3.3.0 and later support OpenCode 2 (`@opencode/cli`) fully.
203
+ Machines on OpenCode 1 and OpenCode 2 can use one repository side by side.
204
+
205
+ What is different on OpenCode 2, and what this tool does about it:
206
+
207
+ | OpenCode 2 changed | What opencode-sync does |
208
+ | --- | --- |
209
+ | Sessions live in new tables, and a fresh OpenCode 2 database has no old ones | Reads and writes OpenCode 2's own tables. OpenCode 1 machines keep their own format; each side imports only its own kind and leaves the other's in place |
210
+ | `/session` lists only the sessions of the current folder's project | Each imported session is placed in the project OpenCode 2 uses for that folder on the receiving machine, so it appears in `/session` |
211
+ | Sessions migrated from 1.x can vanish from `/session` | `opencode-sync repair-sessions` moves them back where `/session` looks |
212
+ | Logins live in the database, and `auth.json` is read at most once | With credential sync on, logins are copied between the two around every sync |
213
+ | Interface preferences moved to `cli.json` | Shared as part of the main config, without this machine's plugin paths |
214
+ | A `service.json` with a password sits in the config folder | Never committed, and removed from repositories an older version wrote it into |
215
+ | Configuration reloads by itself | The "restart OpenCode" hint only appears where a restart is still needed: OpenCode 1, or a changed plugin |
216
+
217
+ To move a machine from OpenCode 1 to 2, see [Upgrading to OpenCode 2](#upgrading-to-opencode-2).
163
218
 
164
219
  ---
165
220
 
166
- ## Per-machine overrides
221
+ ## Autosync
167
222
 
168
- A synced repository makes every machine identical. That is exactly wrong for the
169
- settings that are genuinely machine-specific: a corporate proxy, a local
170
- toolchain path, an MCP server that only exists on one box.
223
+ <p align="center">
224
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/images/en/04-autosync.png" alt="Each machine syncs on its own schedule, waits while you edit, and backs off on errors" width="760">
225
+ </p>
226
+
227
+ When autosync is on, the operating system starts `opencode-sync autosync run`
228
+ every few minutes and at sign-in (on Windows also when you unlock the screen or
229
+ reconnect over Remote Desktop). Each run makes one decision:
230
+
231
+ 1. **Is it quiet?** If a file in your config or skills folders changed in the
232
+ last minute, something is still being written. Sending now could publish a
233
+ half-saved file, so the push waits.
234
+ 2. **Can it at least receive?** While you are busy it still takes other
235
+ machines' changes, but only when this machine has nothing of its own
236
+ waiting. Otherwise everything waits for the next run.
237
+ 3. **Push and receive.** Your changes go up and other machines' changes come
238
+ down in one step.
239
+
240
+ The rules that keep it safe:
241
+
242
+ - **Machines take turns.** Each machine waits a few seconds, fixed per machine,
243
+ so two machines on the same schedule do not collide every time. If another
244
+ machine still gets there first, this one takes the new commit and tries
245
+ again; that does not count as an error.
246
+ - **It backs off but never gives up.** After three failures in a row (usually
247
+ no network) it waits 30 minutes, then an hour between attempts. The first
248
+ success puts it back on schedule.
249
+ - **It interrupts you twice at most.** One notification when it starts backing
250
+ off, one when it recovers. Ordinary syncs are silent.
251
+ - **It never runs twice at once.** One lock is shared by the scheduled job, the
252
+ command, the menu and every OpenCode window; whoever finds it busy skips.
253
+ - **It never approves a large change by itself.** Anything that trips the
254
+ [large-change guard](#safety) is held back and you get a notification.
255
+ - **It renews a shared ChatGPT login.** See [Credentials](#credentials).
256
+
257
+ | Platform | Scheduler | Notes |
258
+ | --- | --- | --- |
259
+ | Windows | Task Scheduler | Runs hidden. To run while signed out, turn it on in the menu and install from an administrator terminal |
260
+ | macOS | launchd agent | `~/Library/LaunchAgents/com.opencode-github-sync.autosync.plist` |
261
+ | Linux | systemd user timer | Falls back to a crontab line. On a server, run `loginctl enable-linger` so it runs while you are logged out |
262
+
263
+ `opencode-sync autosync status` shows the last run, the last error and the next
264
+ attempt. With autosync on, the plugin stops pushing on idle so the two never
265
+ compete; it still pulls when OpenCode starts.
171
266
 
172
- Put those in `~/.config/opencode/opencode-sync.overrides.jsonc`:
267
+ ---
268
+
269
+ ## Per-machine overrides
270
+
271
+ Some settings belong to one machine only: a work proxy, a local tool path, an
272
+ MCP server that only exists on one box. Put them in
273
+ `~/.config/opencode/opencode-sync.overrides.jsonc`, or use **This machine's
274
+ overrides** in the menu:
173
275
 
174
276
  ```jsonc
175
277
  {
@@ -181,185 +283,398 @@ Put those in `~/.config/opencode/opencode-sync.overrides.jsonc`:
181
283
  ```
182
284
 
183
285
  ```
184
- repo opencode.jsonc shared baseline, committed
286
+ repo opencode.jsonc shared, committed
185
287
  + overrides.jsonc this machine only, never committed
186
- ───────────────────────── deep merge
187
- = effective opencode.jsonc what OpenCode actually reads
288
+ ───────────────────────── merged
289
+ = effective opencode.jsonc what OpenCode reads
188
290
  ```
189
291
 
190
- Merge rules: objects merge key by key, arrays and scalars replace, `null`
191
- deletes a key.
192
-
193
- The half that other tools get wrong is **push**. Because the effective file is
194
- what sits on disk, a naive push uploads your overrides to everyone. Here, any
195
- key the overrides file claims is restored to the value the repository already
196
- had before committing — so an overridden key is invisible to sync in both
197
- directions, and your machine keeps its own settings the whole time.
198
-
199
- > With no overrides file the config is copied byte for byte and your comments
200
- > and formatting are untouched. The structural rewrite only happens once you
201
- > actually opt in.
292
+ Objects merge key by key, lists and plain values replace, and `null` removes a
293
+ key. Before every push, each key the overrides file claims is put back to the
294
+ repository's value, so your machine-only values never reach other machines.
295
+ Without an overrides file the config is copied exactly as written, comments
296
+ and all.
202
297
 
203
298
  ---
204
299
 
205
- ## Session sync
300
+ ## Sessions
206
301
 
207
- Off by default. Turn it on only for a private repository — conversations are
208
- private data.
302
+ Off by default. Turn it on only for a private repository: conversations are
303
+ private.
209
304
 
210
305
  ```bash
211
306
  opencode-sync sessions enable
212
307
  opencode-sync sessions list
213
- opencode-sync sessions include ses_065cad1caffeN3lf1RgLZno30 # pin one forever
308
+ opencode-sync sessions include ses_065cad1caffeN3lf1RgLZno30 # always sync this one
214
309
  opencode-sync sessions exclude ses_0ba19b4e7ffeMbSmWYi3Nj6xfZ # never sync this one
215
310
  ```
216
311
 
217
- ### Why not just commit the database
312
+ Sessions are not synced by committing the database. A real OpenCode database
313
+ grows to several gigabytes, mostly tool output, and git cannot merge it.
314
+ Instead each session is exported on its own as a small compressed file:
315
+
316
+ - **Small.** Only recent sessions travel (7 days and 50 sessions by default),
317
+ and any single session over 5 MB is skipped.
318
+ - **Conflicts are rare and resolved.** Two machines working on different
319
+ sessions touch different files. When one session changed on two machines, the
320
+ newer copy wins; on OpenCode 2 the replaced local copy is saved to the
321
+ recovery folder first if it had messages the newer one lacks.
322
+ - **Never disturbs a running conversation.** A session that is busy on this
323
+ machine is not replaced, and runtime state (busy, compacting, retry counters)
324
+ is never carried over, so a receiving machine never resumes a conversation on
325
+ its own.
326
+ - **Lands in the right place.** On OpenCode 2 an imported session is placed in
327
+ the project OpenCode 2 uses for its folder here. A folder under the other
328
+ machine's home is matched to the same folder under yours; a folder this
329
+ machine does not have puts the session in your home folder's project.
330
+ - **Safe to import.** Each session is imported in one transaction, so a failure
331
+ leaves your database as it was.
332
+
333
+ Window, count and size limits are under **What to sync → Session settings**.
334
+ Sessions need Node.js 22.5 or newer.
335
+
336
+ **Sessions missing from `/session` after upgrading to OpenCode 2?** OpenCode's
337
+ own migration leaves some of them in a project `/session` never shows. Their
338
+ content is intact:
339
+
340
+ ```bash
341
+ opencode-sync repair-sessions # preview: what would move where
342
+ opencode-sync repair-sessions --apply # move them
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Credentials
348
+
349
+ Off by default, and refused outright when the repository is public. Turn it on
350
+ under **What to sync → Credentials** or with `"includeCredentials": true`.
351
+
352
+ On OpenCode 1, `auth.json` is synced as a file. On OpenCode 2, which keeps
353
+ logins in its database, opencode-sync also copies between the database and
354
+ `auth.json` around every sync:
355
+
356
+ - The account you pick in OpenCode (for example after `/connect` or switching
357
+ accounts) is what the other machines receive. A running OpenCode picks up an
358
+ incoming account on its next request, without a restart.
359
+ - A renewed login updates the existing account instead of adding a copy. When
360
+ both sides changed, the one that expires later wins.
361
+ - An account missing from an incoming copy never logs this machine out.
362
+ Logging out on a machine removes that account from the shared copy.
363
+ - A broken or half-written `auth.json` is never overwritten.
364
+ - To tell which side changed, only hashes of the last synced values are kept,
365
+ in `opencode-sync-credentials.json` next to the database. Never the secrets.
366
+
367
+ **Shared ChatGPT login.** Renewing an OpenAI login invalidates the previous
368
+ one, so machines that each renew the same login log each other out. With
369
+ credential sync on, only one machine renews it: the scheduled job claims a
370
+ lease in the sync repository (an atomic operation on GitHub's side), renews
371
+ three days before the login expires, and the next sync hands the new login to
372
+ every other machine. A claim older than 15 minutes is considered abandoned and
373
+ can be taken over. Set `"openaiRefreshLease": false` to turn this off.
374
+
375
+ ---
376
+
377
+ ## Safety
218
378
 
219
- A real OpenCode database reaches several gigabytes, almost all of it tool output
220
- inside `part.data`. Git cannot delta-compress it, GitHub's LFS free tier is one
221
- gigabyte, and copying a live database alongside its write-ahead log can capture
222
- a torn state that only shows up much later.
379
+ <p align="center">
380
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/images/en/05-safety-net.png" alt="One sync at a time, all-or-nothing writes, restore earlier versions, large-change guard" width="760">
381
+ </p>
223
382
 
224
- So sessions are exported **one at a time**. Each becomes an independent gzipped
225
- JSON shard holding its own rows plus the project and workspace rows it needs:
383
+ - **All-or-nothing writes.** Files are written beside their target and then
384
+ swapped in, so a crash mid-sync cannot leave a half-written config that stops
385
+ OpenCode from starting.
386
+ - **Push verification.** After pushing, the remote is read back. `git push`
387
+ can report success without the remote changing; that is checked, not
388
+ assumed.
389
+ - **One sync at a time.** A lock shared by the plugin, the command, the menu
390
+ and the scheduled job.
391
+ - **Large-change guard.** A push that adds more than 300 files, more than
392
+ 10 MB in total, or any single file over 2 MB stops and asks. The limits are
393
+ adjustable. Generated folders such as `node_modules`, `.venv`, `venv`,
394
+ `__pycache__`, `dist` and `.cache` are never sent.
395
+ - **Recovery folder.** Before a forced pull, a "repository wins" first link, a
396
+ restore from history, or replacing a session that was continued on both
397
+ machines, what is about to be replaced is copied to
398
+ `~/.local/share/opencode/opencode-sync-recovery/<time>-<reason>/`.
399
+ - **Machine secrets stay home.** OpenCode 2's `service.json`, lock files and
400
+ per-machine histories are never committed.
401
+ - **Your hostname stays private.** Commits name the machine by a stable
402
+ pseudonym (or a name you choose), never by its real hostname.
403
+ - **Symlinks are refused, not followed**, so a sync cannot copy files from
404
+ outside the folders it owns.
226
405
 
227
- - **No large files.** Shards are small and compress well.
228
- - **Conflicts isolate themselves.** Two machines working on different sessions
229
- touch different files, so git merges them with no special handling. The only
230
- real conflict is one session edited in two places, and there the newer
231
- `time_updated` wins — an in-progress conversation is never clobbered by a
232
- stale copy.
233
- - **You choose what travels.** A time window, an explicit include list, a
234
- project filter and a per-session size cap. Ancient sessions stay where they
235
- are.
406
+ ---
236
407
 
237
- Import is an upsert inside a transaction, so a failure leaves your database
238
- exactly as it was.
408
+ ## The menu
409
+
410
+ Run `opencode-sync` with no arguments.
411
+
412
+ <p align="center">
413
+ <img src="https://raw.githubusercontent.com/lazyalex616/opencode-github-sync/main/docs/menu.svg" alt="The opencode-sync menu" width="760">
414
+ </p>
415
+
416
+ Arrow keys or the shown hotkey pick an item, space ticks a checkbox, Enter
417
+ confirms and Esc goes back. When the input is not a terminal (a pipe, a script,
418
+ CI) every prompt becomes a numbered question, so the menu can be driven from a
419
+ file.
420
+
421
+ | Item | What you can do there |
422
+ | --- | --- |
423
+ | **Sync now** | Push and receive, receive only, push only, or preview first |
424
+ | **What to sync** | Tick main config, instruction files, agents, commands, plugins, skills, credentials, sessions; set session limits; add extra paths |
425
+ | **Autosync** | On or off; every 5/10/15/30/60 minutes or your own interval; pause; run while signed out (Windows); notifications |
426
+ | **Update** | Check npm for a newer version, upgrade, or update automatically once a day |
427
+ | **This machine's overrides** | Open the overrides file in your editor and see what it changes |
428
+ | **Diagnostics** | git, node, gh, repository access, the scheduled job, the last log lines; export a support bundle |
429
+ | **Danger zone** | Make this machine match the repository, or the other way round (type `overwrite` to confirm) |
430
+ | **Uninstall** | Remove the scheduled job, optionally unlink and remove the command. Your configuration is never deleted |
431
+ | **Network proxy** | A proxy for git, gh and npm, used only by opencode-sync |
432
+ | **Restore a file from history** | Pick a file, pick a version, put it back |
433
+ | **Devices** | Every machine that has synced and when; rename this one |
434
+ | **Large-change guard** | The limits that make a big push stop and ask |
435
+ | **Language** | English, 简体中文 or automatic |
436
+
437
+ ---
438
+
439
+ ## OpenCode plugin
440
+
441
+ The plugin is optional. It pulls when OpenCode starts, can push when a session
442
+ goes idle, and adds an `opencode_sync` tool so you can ask for a sync in plain
443
+ language.
239
444
 
240
445
  ```jsonc
446
+ // ~/.config/opencode/opencode.json
241
447
  {
242
- "sessions": {
243
- "enabled": true,
244
- "days": 7, // only sessions touched this recently
245
- "maxSessions": 50, // hard cap per push, newest first
246
- "maxSessionBytes": 5242880, // skip any single runaway session
247
- "include": [], // always sync these, whatever the window says
248
- "exclude": [], // never sync these
249
- "directories": [] // only sessions under these project directories
250
- }
448
+ "$schema": "https://opencode.ai/config.json",
449
+ "plugin": ["opencode-github-sync"]
251
450
  }
252
451
  ```
253
452
 
254
- > The internal `event` log is deliberately excluded. It is the largest table by
255
- > row count and nothing about resuming a conversation depends on it.
453
+ The `"plugin"` key works on OpenCode 1.x (1.3.4 and later) and 2.x. If you run
454
+ only OpenCode 2 you can use its native `"plugins"` key instead, but do not list
455
+ the plugin under both: OpenCode 2 loads entries from both lists. OpenCode
456
+ 1.0–1.3.3 cannot load 3.1.0 and later; stay on `opencode-github-sync@3.0.1`
457
+ there.
458
+
459
+ Keep the command installed even if you use the plugin. A plugin cannot repair
460
+ a configuration that stops OpenCode from loading it; `opencode-sync pull
461
+ --force` can.
256
462
 
257
463
  ---
258
464
 
259
- ## Command reference
260
-
261
- | Command | What it does |
262
- | ---------------------------------- | ------------------------------------------------ |
263
- | `opencode-sync init [name]` | Create a private sync repository |
264
- | `opencode-sync link <owner/repo>` | Point this machine at an existing one |
265
- | `opencode-sync push` | Share this machine's configuration |
266
- | `opencode-sync pull` | Apply the shared configuration |
267
- | `opencode-sync status` | Show what is in sync and what is not |
268
- | `opencode-sync sessions list` | Recent sessions and their ids |
269
- | `opencode-sync sessions enable` | Turn selective session sync on |
270
- | `opencode-sync sessions include` | Pin a session, ignoring the time window |
271
- | `opencode-sync overrides` | Create/locate the per-machine patch |
272
- | `opencode-sync config` | Print the current settings |
273
-
274
- | Flag | Effect |
275
- | ----------- | ----------------------------------------------- |
276
- | `--force` | Overwrite the other side on conflict (confirmed) |
277
- | `--dry-run` | Report what would change, write nothing |
278
-
279
- | Environment variable | Effect |
280
- | ---------------------------- | ---------------------------------------- |
281
- | `OPENCODE_SYNC_HOST_ALIAS` | Name this machine in commit messages |
282
- | `OPENCODE_SYNC_VERBOSE=1` | Full file list and stack traces |
283
- | `NO_COLOR` | Disable colour |
284
- | `SYNC_REMOTE_URL` | Override the repository URL |
465
+ ## Commands
466
+
467
+ | Command | What it does |
468
+ | --- | --- |
469
+ | `opencode-sync` | Open the menu (same as `opencode-sync menu`) |
470
+ | `opencode-sync init [name]` | Create a private sync repository with `gh` |
471
+ | `opencode-sync link <owner/repo or URL>` | Use an existing repository |
472
+ | `opencode-sync setup --mode cli\|link\|auto` | Non-interactive setup, used by the installers |
473
+ | `opencode-sync push` | Send this machine's changes |
474
+ | `opencode-sync pull` | Take the shared configuration |
475
+ | `opencode-sync status` | What is in sync and what is not |
476
+ | `opencode-sync autosync enable` / `disable` | Turn autosync on or off for this machine |
477
+ | `opencode-sync autosync install` / `uninstall` | Register or remove the scheduled job only |
478
+ | `opencode-sync autosync status` | Last run, last error, next attempt |
479
+ | `opencode-sync autosync run` | One scheduled pass, now |
480
+ | `opencode-sync autosync pause <hours>\|tomorrow` / `resume` | Pause or resume |
481
+ | `opencode-sync autosync reset` | Clear the failure counter |
482
+ | `opencode-sync sessions list\|enable\|disable` | Session sync |
483
+ | `opencode-sync sessions include\|exclude <id>` | Always or never sync one session |
484
+ | `opencode-sync repair-sessions [--apply]` | OpenCode 2: move sessions missing from `/session` into their project (preview without `--apply`) |
485
+ | `opencode-sync overrides` | Create or locate the overrides file |
486
+ | `opencode-sync config` | Print the settings |
487
+
488
+ | Flag | Effect |
489
+ | --- | --- |
490
+ | `--force` | Overwrite the other side (asks you to type `yes`; `--yes` skips) |
491
+ | `--dry-run` | Show what would change, change nothing |
492
+ | `--allow-large` | Push even when the large-change guard objects |
493
+ | `--lang en\|zh-CN` | Interface language for this run |
494
+
495
+ | Environment variable | Effect |
496
+ | --- | --- |
497
+ | `OPENCODE_SYNC_LANG` | Interface language |
498
+ | `OPENCODE_SYNC_HOST_ALIAS` | Machine name used in commits |
499
+ | `OPENCODE_SYNC_PROXY` | Proxy for git, gh and npm |
500
+ | `OPENCODE_SYNC_VERBOSE=1` | Full file lists and stack traces |
501
+ | `SYNC_REMOTE_URL` | Override the repository URL |
502
+ | `NO_COLOR` | Plain output |
285
503
 
286
504
  ---
287
505
 
288
- ## Settings
506
+ ## Settings file
289
507
 
290
- `~/.config/opencode/opencode-sync.jsonc` — never committed.
508
+ `~/.config/opencode/opencode-sync.jsonc` stays on this machine and is never
509
+ committed. The menu edits it for you; every key is optional.
291
510
 
292
511
  ```jsonc
293
512
  {
294
513
  "repo": { "owner": "you", "name": "my-opencode-config", "branch": "main" },
295
-
296
- "machineAlias": "laptop", // optional; otherwise a stable pseudonym
297
-
298
- "includeCredentials": false, // auth.json / account.json — private repos only
514
+ "machineAlias": "laptop",
515
+ "includeCredentials": false,
516
+ "openaiRefreshLease": true,
299
517
  "includeSkills": true,
300
518
  "includeState": true,
301
- "extraPaths": [],
302
-
303
- "sessions": { "enabled": false },
304
-
305
- "autoPullOnStartup": true, // plugin only
306
- "autoPushOnIdle": false // plugin only
519
+ "extraPaths": [".config/gh/config.yml"],
520
+ "categories": { "config": true, "instructions": true, "agents": true, "commands": true, "plugins": true },
521
+ "sessions": { "enabled": false, "days": 7, "maxSessions": 50, "maxSessionBytes": 5242880 },
522
+ "autosync": { "enabled": false, "intervalMinutes": 5, "settleSeconds": 60, "runWhenLoggedOff": false, "autoUpdate": false },
523
+ "guard": { "maxFiles": 300, "maxBytes": 10485760, "maxFileBytes": 2097152 },
524
+ "proxy": "",
525
+ "language": "",
526
+ "notifications": true,
527
+ "autoPullOnStartup": true,
528
+ "autoPushOnIdle": false
307
529
  }
308
530
  ```
309
531
 
532
+ | Key | Meaning |
533
+ | --- | --- |
534
+ | `machineAlias` | Name for this machine in commits; unset means a stable pseudonym |
535
+ | `includeCredentials` | Sync logins ([Credentials](#credentials)); private repositories only |
536
+ | `openaiRefreshLease` | With credentials on, let one machine at a time renew a shared ChatGPT login |
537
+ | `includeSkills` / `includeState` | Sync `~/.agents/skills` / `~/.local/state/opencode` |
538
+ | `extraPaths` | Extra files or folders, relative to your home folder |
539
+ | `categories` | Which parts of the config folder are shared |
540
+ | `sessions` | [Session](#sessions) window, count and size limits |
541
+ | `autosync` | [Autosync](#autosync) interval, quiet period, run while signed out, daily self-update |
542
+ | `guard` | [Large-change guard](#safety) limits |
543
+ | `autoPullOnStartup` / `autoPushOnIdle` | What the [plugin](#opencode-plugin) does |
544
+
310
545
  ---
311
546
 
312
- ## When something goes wrong
547
+ ## Troubleshooting
548
+
549
+ **I am behind a proxy.** Pass `--proxy http://host:port` (or `-Proxy` on
550
+ Windows) to the installer. It is used for npm and git during the install and
551
+ saved for later syncs, including the ChatGPT login renewal. Change it any time
552
+ under **Network proxy**.
553
+
554
+ **`curl | sh` does not ask me anything.** The script itself arrives through the
555
+ pipe, so it reads your answers from the terminal instead. Where there is no
556
+ terminal (CI, a Dockerfile) nobody can answer: pass `--mode` and `--repo`, plus
557
+ `--yes` if Node.js or git may need installing.
558
+
559
+ **Windows says running scripts is disabled.** `irm ... | iex` does not run a
560
+ script file, so the execution policy does not apply. To run a downloaded
561
+ `install.ps1` as a file, use `powershell -ExecutionPolicy Bypass -File install.ps1`.
562
+
563
+ **`opencode-sync` is not found after installing.** npm installed it into a
564
+ folder that is not on your `PATH`. `npm prefix -g` shows the folder; add its
565
+ `bin` (or the folder itself on Windows) to `PATH`.
566
+
567
+ **Autosync is on but nothing happens.** Run `opencode-sync autosync status`. It
568
+ shows whether it is paused, backing off after errors, or waiting because files
569
+ are still changing. **Diagnostics** in the menu shows whether the scheduled job
570
+ is registered.
571
+
572
+ **A synced session does not show up in `/session` (OpenCode 2).** Open
573
+ OpenCode in the session's folder; `/session` lists only that folder's project.
574
+ Sessions from before your upgrade to OpenCode 2: run
575
+ `opencode-sync repair-sessions --apply`.
576
+
577
+ **Sessions are not synced at all.** Check `opencode-sync status` shows session
578
+ sync as on, and that `node --version` is 22.5 or newer.
579
+
580
+ **A login did not arrive on another machine (OpenCode 2).** Credentials must be
581
+ on for both machines. Run a sync on the machine where you logged in, then on
582
+ the other one. If two accounts of one provider are both marked active, nothing
583
+ is changed for that provider; switch accounts once in OpenCode to settle it.
584
+
585
+ **A pull conflicted with my local edits.** Your edits are kept in a git stash
586
+ and the exact commands to get them back are printed. Nothing is lost.
587
+
588
+ **"This machine has N commits that were never pushed."** Pulling would throw
589
+ them away, so it stops. Run `opencode-sync push`, or `pull --force` to discard
590
+ them.
591
+
592
+ **Authentication failed.** Run `gh auth login -h github.com`. Private
593
+ repositories need the `repo` scope.
313
594
 
314
- **A pull conflicted with local edits.** The worktree is rolled back to a clean
315
- state and your changes stay in the stash. The exact recovery commands are
316
- printed. Nothing is lost.
595
+ **OpenCode will not start after a sync.** This is what the command is for:
317
596
 
318
597
  ```bash
319
- cd ~/.config/opencode
320
- git stash list
321
- git stash show -p stash@{0}
598
+ opencode-sync pull --force
322
599
  ```
323
600
 
324
- **"This machine has N commits that were never pushed."** Deliberate — pulling
325
- would destroy them. Run `opencode-sync push`, or `pull --force` to discard.
601
+ The files it replaces go to the recovery folder first.
602
+
603
+ ---
604
+
605
+ ## Upgrading
606
+
607
+ ### Upgrading to OpenCode 2
608
+
609
+ Upgrade opencode-github-sync to 3.3.0 or later on every machine first. 3.2.x
610
+ cannot read OpenCode 2 sessions, and it commits OpenCode 2's `service.json`.
611
+
612
+ 1. Install OpenCode 2. With npm 12 its install scripts must be allowed, or the
613
+ `opencode` command is only a placeholder:
326
614
 
327
- **Authentication failed.** `gh auth login -h github.com`. The token needs the
328
- `repo` scope for private repositories.
615
+ ```bash
616
+ npm install -g @opencode/cli --allow-scripts=@opencode/cli
617
+ ```
329
618
 
330
- **Session sync says no SQLite driver.** Node 22.5+ or Bun. Config sync is
331
- unaffected.
619
+ 2. Optionally stop OpenCode 2 from updating itself in the background; an
620
+ unattended self-update through npm 12 can break the install:
332
621
 
333
- **Everything is broken and OpenCode will not start.** This is why the CLI
334
- exists:
622
+ ```bash
623
+ opencode service set env OPENCODE_DISABLE_AUTOUPDATE 1
624
+ ```
625
+
626
+ 3. Start OpenCode 2 once so it migrates your 1.x data, then bring back the
627
+ sessions `/session` no longer shows:
628
+
629
+ ```bash
630
+ opencode-sync repair-sessions # preview
631
+ opencode-sync repair-sessions --apply
632
+ ```
633
+
634
+ **If you synced with 3.2.x on OpenCode 2**, your repository may contain
635
+ `service.json` and `_state/service.json`. 3.3.0 removes them on its next push,
636
+ but they stay in the repository's history. The password in them only opens the
637
+ local background service of that machine. To remove them from history as well,
638
+ delete the repository and push again from one machine.
639
+
640
+ ### Upgrading from 3.1.x or 3.2.x
335
641
 
336
642
  ```bash
337
- opencode-sync pull --force
643
+ npm install -g opencode-github-sync@latest
338
644
  ```
339
645
 
646
+ Nothing else is required: settings, overrides and the repository keep working,
647
+ and autosync stays off until you turn it on. If you sync on a timer with a
648
+ script of your own, remove it before turning autosync on so the two do not
649
+ compete. If you used `autoPushOnIdle` in the plugin, autosync replaces it on
650
+ machines where you turn it on. The [changelog](./CHANGELOG.md) lists every
651
+ change.
652
+
340
653
  ---
341
654
 
342
655
  ## Development
343
656
 
344
657
  ```bash
345
658
  npm install
346
- npm run check # lint + typecheck + tests
659
+ npm run check # lint, typecheck and tests
347
660
  npm run build
348
661
  ```
349
662
 
350
- The test suite runs against a real bare git repository on disk and simulates two
351
- separate machines, so push, pull, force, rebase, stashing and the override
352
- round-trip are all exercised end to end.
663
+ The tests run against real git repositories on disk and simulate several
664
+ machines, so pushing, pulling, rebasing, autosync scheduling and the menu are
665
+ exercised end to end. Session and credential tests use the schema of a real
666
+ OpenCode 2.2.5 database and fake tokens only. Real scheduled jobs are only ever
667
+ registered on disposable CI runners.
353
668
 
354
669
  ---
355
670
 
356
671
  ## Star history
357
672
 
358
- <a href="https://star-history.com/#doomsday616/opencode-github-sync&Date">
673
+ <a href="https://star-history.com/#lazyalex616/opencode-github-sync&Date">
359
674
  <picture>
360
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=doomsday616/opencode-github-sync&type=Date&theme=dark">
361
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=doomsday616/opencode-github-sync&type=Date">
362
- <img alt="Star history chart" src="https://api.star-history.com/svg?repos=doomsday616/opencode-github-sync&type=Date" width="640">
675
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=lazyalex616/opencode-github-sync&type=Date&theme=dark">
676
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=lazyalex616/opencode-github-sync&type=Date">
677
+ <img alt="Star history chart" src="https://api.star-history.com/svg?repos=lazyalex616/opencode-github-sync&type=Date" width="640">
363
678
  </picture>
364
679
  </a>
365
680
 
@@ -367,7 +682,7 @@ round-trip are all exercised end to end.
367
682
 
368
683
  ## License
369
684
 
370
- [MIT](./LICENSE)
685
+ [MIT](https://github.com/lazyalex616/opencode-github-sync/blob/main/LICENSE)
371
686
 
372
687
  <p align="center">
373
688
  <sub>If this saved you some time, a ⭐ is appreciated.</sub>