opencode-synced 0.1.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.
- package/LICENSE +21 -0
- package/README.md +184 -0
- package/dist/command/sync-enable-secrets.md +5 -0
- package/dist/command/sync-init.md +11 -0
- package/dist/command/sync-pull.md +5 -0
- package/dist/command/sync-push.md +4 -0
- package/dist/command/sync-resolve.md +5 -0
- package/dist/command/sync-status.md +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13734 -0
- package/dist/sync/apply.d.ts +3 -0
- package/dist/sync/commit.d.ts +9 -0
- package/dist/sync/config.d.ts +35 -0
- package/dist/sync/config.test.d.ts +1 -0
- package/dist/sync/errors.d.ts +19 -0
- package/dist/sync/paths.d.ts +47 -0
- package/dist/sync/paths.test.d.ts +1 -0
- package/dist/sync/repo.d.ts +25 -0
- package/dist/sync/repo.test.d.ts +1 -0
- package/dist/sync/service.d.ts +27 -0
- package/dist/sync/utils.d.ts +9 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ian Hildebrand (hildy.io)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# opencode-synced
|
|
2
|
+
|
|
3
|
+
Sync global OpenCode configuration across machines via a GitHub repo, with optional secrets support for private repos.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Syncs global OpenCode config (`~/.config/opencode`) and related directories
|
|
8
|
+
- Optional secrets sync when the repo is private
|
|
9
|
+
- Optional session sync to share conversation history across machines
|
|
10
|
+
- Optional prompt stash sync to share stashed prompts and history across machines
|
|
11
|
+
- Startup auto-sync with restart toast
|
|
12
|
+
- Per-machine overrides via `opencode-synced.overrides.jsonc`
|
|
13
|
+
- Custom `/sync-*` commands and `opencode_sync` tool
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- GitHub CLI (`gh`) installed and authenticated (`gh auth login`)
|
|
18
|
+
- Git installed and available on PATH
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
Enable the plugin in your global OpenCode config (OpenCode will install it on next run):
|
|
23
|
+
|
|
24
|
+
```jsonc
|
|
25
|
+
{
|
|
26
|
+
"$schema": "https://opencode.ai/config.json",
|
|
27
|
+
"plugin": ["opencode-synced"],
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
OpenCode does not auto-update plugins. To update, remove the cached plugin and restart OpenCode:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
rm -rf ~/.cache/opencode/node_modules/opencode-synced
|
|
35
|
+
opencode
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configure
|
|
39
|
+
|
|
40
|
+
Run `/sync-init` to get started. This will:
|
|
41
|
+
|
|
42
|
+
1. Detect your GitHub username from the CLI
|
|
43
|
+
2. Create a private repo (`my-opencode-config` by default) if it doesn't exist
|
|
44
|
+
3. Clone the repo and set up sync
|
|
45
|
+
|
|
46
|
+
That's it! Your config will now sync automatically on startup.
|
|
47
|
+
|
|
48
|
+
### Custom repo name or org
|
|
49
|
+
|
|
50
|
+
You can specify a custom repo name or use an organization:
|
|
51
|
+
|
|
52
|
+
- `/sync-init` - Uses `{your-username}/my-opencode-config`
|
|
53
|
+
- `/sync-init my-config` - Uses `{your-username}/my-config`
|
|
54
|
+
- `/sync-init my-org/team-config` - Uses `my-org/team-config`
|
|
55
|
+
|
|
56
|
+
<details>
|
|
57
|
+
<summary>Manual configuration</summary>
|
|
58
|
+
|
|
59
|
+
Create `~/.config/opencode/opencode-synced.jsonc`:
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
{
|
|
63
|
+
"repo": {
|
|
64
|
+
"owner": "your-org",
|
|
65
|
+
"name": "opencode-config",
|
|
66
|
+
"branch": "main",
|
|
67
|
+
},
|
|
68
|
+
"includeSecrets": false,
|
|
69
|
+
"includeSessions": false,
|
|
70
|
+
"includePromptStash": false,
|
|
71
|
+
"extraSecretPaths": [],
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
</details>
|
|
76
|
+
|
|
77
|
+
### Synced paths (default)
|
|
78
|
+
|
|
79
|
+
- `~/.config/opencode/opencode.json` and `opencode.jsonc`
|
|
80
|
+
- `~/.config/opencode/AGENTS.md`
|
|
81
|
+
- `~/.config/opencode/agent/`, `command/`, `mode/`, `tool/`, `themes/`, `plugin/`
|
|
82
|
+
|
|
83
|
+
### Secrets (private repos only)
|
|
84
|
+
|
|
85
|
+
Enable secrets with `/sync-enable-secrets` or set `"includeSecrets": true`:
|
|
86
|
+
|
|
87
|
+
- `~/.local/share/opencode/auth.json`
|
|
88
|
+
- `~/.local/share/opencode/mcp-auth.json`
|
|
89
|
+
- Any extra paths in `extraSecretPaths` (allowlist)
|
|
90
|
+
|
|
91
|
+
### Sessions (private repos only)
|
|
92
|
+
|
|
93
|
+
Sync your OpenCode sessions (conversation history from `/sessions`) across machines by setting `"includeSessions": true`. This requires `includeSecrets` to also be enabled since sessions may contain sensitive data.
|
|
94
|
+
|
|
95
|
+
```jsonc
|
|
96
|
+
{
|
|
97
|
+
"repo": { ... },
|
|
98
|
+
"includeSecrets": true,
|
|
99
|
+
"includeSessions": true
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Synced session data:
|
|
104
|
+
|
|
105
|
+
- `~/.local/share/opencode/storage/session/` - Session files
|
|
106
|
+
- `~/.local/share/opencode/storage/message/` - Message history
|
|
107
|
+
- `~/.local/share/opencode/storage/part/` - Message parts
|
|
108
|
+
- `~/.local/share/opencode/storage/session_diff/` - Session diffs
|
|
109
|
+
|
|
110
|
+
### Prompt Stash (private repos only)
|
|
111
|
+
|
|
112
|
+
Sync your stashed prompts and prompt history across machines by setting `"includePromptStash": true`. This requires `includeSecrets` to also be enabled since prompts may contain sensitive data.
|
|
113
|
+
|
|
114
|
+
```jsonc
|
|
115
|
+
{
|
|
116
|
+
"repo": { ... },
|
|
117
|
+
"includeSecrets": true,
|
|
118
|
+
"includePromptStash": true
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Synced prompt data:
|
|
123
|
+
|
|
124
|
+
- `~/.local/state/opencode/prompt-stash.jsonl` - Stashed prompts
|
|
125
|
+
- `~/.local/state/opencode/prompt-history.jsonl` - Prompt history
|
|
126
|
+
|
|
127
|
+
## Overrides
|
|
128
|
+
|
|
129
|
+
Create a local-only overrides file at:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
~/.config/opencode/opencode-synced.overrides.jsonc
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Overrides are merged into the runtime config and re-applied to `opencode.json(c)` after pull.
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
- `/sync-init` to set up sync (creates repo if needed)
|
|
140
|
+
- `/sync-status` for repo status and last sync
|
|
141
|
+
- `/sync-pull` to fetch and apply remote config
|
|
142
|
+
- `/sync-push` to commit and push local changes
|
|
143
|
+
- `/sync-enable-secrets` to opt in to secrets sync
|
|
144
|
+
- `/sync-resolve` to automatically resolve uncommitted changes using AI
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary>Manual sync (without slash commands)</summary>
|
|
148
|
+
|
|
149
|
+
### Trigger a sync
|
|
150
|
+
|
|
151
|
+
Restart OpenCode to run the startup sync flow (pull remote, apply if changed, push local changes if needed).
|
|
152
|
+
|
|
153
|
+
### Check status
|
|
154
|
+
|
|
155
|
+
Inspect the local repo directly:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
cd ~/.local/share/opencode/opencode-synced/repo
|
|
159
|
+
git status
|
|
160
|
+
git log --oneline -5
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
</details>
|
|
164
|
+
|
|
165
|
+
## Recovery
|
|
166
|
+
|
|
167
|
+
If the sync repo has uncommitted changes, you can:
|
|
168
|
+
|
|
169
|
+
1. **Auto-resolve using AI**: Run `/sync-resolve` to let AI analyze and decide whether to commit or discard the changes
|
|
170
|
+
2. **Manual resolution**: Navigate to the repo and resolve manually:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
cd ~/.local/share/opencode/opencode-synced/repo
|
|
174
|
+
git status
|
|
175
|
+
git pull --rebase
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Then re-run `/sync-pull` or `/sync-push`.
|
|
179
|
+
|
|
180
|
+
## Development
|
|
181
|
+
|
|
182
|
+
- `bun run build`
|
|
183
|
+
- `bun run test`
|
|
184
|
+
- `bun run lint`
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Initialize opencode-synced configuration
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Use the opencode_sync tool with command "init".
|
|
6
|
+
The repo will be created automatically if it doesn't exist (private by default).
|
|
7
|
+
Default repo name is "my-opencode-config" with owner auto-detected from GitHub CLI.
|
|
8
|
+
If the user wants a custom repo name, pass name="custom-name".
|
|
9
|
+
If the user wants an org-owned repo, pass owner="org-name".
|
|
10
|
+
If the user wants a public repo, pass private=false.
|
|
11
|
+
Include includeSecrets if the user explicitly opts in.
|
package/dist/index.d.ts
ADDED