Skip to content

Commit 0c5614e

Browse files
committed
Split README into English + Chinese with language toggle
1 parent 88c323f commit 0c5614e

2 files changed

Lines changed: 126 additions & 99 deletions

File tree

README.md

Lines changed: 3 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# opencode-github-sync
22

3+
[中文文档](./README.zh-CN.md)
4+
35
Cross-device configuration and session sync for [OpenCode](https://opencode.ai) via a private GitHub repository.
46

57
Syncs four directories into one git repo:
@@ -118,102 +120,4 @@ node ~/.config/opencode/scripts/opencode-sync-core.js status
118120

119121
## License
120122

121-
MIT
122-
123-
---
124-
125-
# opencode-github-sync (中文)
126-
127-
通过私有 GitHub 仓库跨设备同步 [OpenCode](https://opencode.ai) 配置和会话数据。
128-
129-
将四个本地目录合并到一个 git 仓库:
130-
131-
| 本地目录 | 仓库路径 | 内容 |
132-
|---|---|---|
133-
| `~/.config/opencode/` | 仓库根目录 | 配置、技能、命令、MCP 设置 |
134-
| `~/.local/share/opencode/` | `_data/` | 认证、同步状态、SQLite 数据库 |
135-
| `~/.local/state/opencode/` | `_state/` | 使用频率、KV 存储、模型缓存 |
136-
| `~/.agents/skills/` | `_agents/` | Skills CLI 全局安装 + lock 文件 |
137-
138-
## 功能特点
139-
140-
- **配置同步** — 跨设备推送/拉取配置文件、技能和状态
141-
- **会话同步** — 推送/拉取 SQLite 数据库、存储和工具输出(在 OpenCode 外运行以避免数据库损坏)
142-
- **自动暂存** — 拉取时自动暂存本地变更
143-
- **强制模式**`--force` 在冲突时覆盖
144-
- **Git LFS** — 大型二进制文件(SQLite 数据库)通过 Git LFS 追踪
145-
- **Migration 自动修复** — 拉取较旧数据库时自动恢复迁移记录
146-
- **跨平台** — macOS 和 Windows (PowerShell 7)
147-
148-
## 前置条件
149-
150-
- **Node.js** (v18+)
151-
- **Git** + [Git LFS](https://git-lfs.github.com/)
152-
- **一个私有 GitHub 仓库** 用于存储同步数据
153-
- **SQLite3 CLI**(会话同步需要 — 数据库备份和完整性检查)
154-
155-
## 安装
156-
157-
### 1. 克隆此仓库
158-
159-
```bash
160-
git clone https://github.com/doomsday616/opencode-github-sync.git
161-
```
162-
163-
### 2. 复制脚本到 OpenCode 配置目录
164-
165-
```bash
166-
# macOS / Linux
167-
cp opencode-github-sync/scripts/*.js ~/.config/opencode/scripts/
168-
169-
# Windows (PowerShell)
170-
Copy-Item opencode-github-sync\scripts\*.js "$HOME\.config\opencode\scripts\"
171-
```
172-
173-
### 3. 安装 wrapper 命令
174-
175-
**macOS / Linux:**
176-
```bash
177-
cp opencode-github-sync/wrappers/mac/* ~/.local/bin/
178-
chmod +x ~/.local/bin/opencode-{pull,push,pull-force,push-force}
179-
```
180-
181-
**Windows:**
182-
```powershell
183-
Copy-Item opencode-github-sync\wrappers\windows\*.cmd "$HOME\.local\bin\"
184-
# 确保 ~/.local/bin 在 PATH 中
185-
```
186-
187-
### 4. 设置远端 URL
188-
189-
`SYNC_REMOTE_URL` 环境变量设为你的私有 GitHub 仓库:
190-
191-
**macOS / Linux**(添加到 `~/.zshrc``~/.bashrc`):
192-
```bash
193-
export SYNC_REMOTE_URL="https://github.com/你的用户名/你的仓库.git"
194-
```
195-
196-
**Windows**(PowerShell profile 或系统环境变量):
197-
```powershell
198-
[System.Environment]::SetEnvironmentVariable("SYNC_REMOTE_URL", "https://github.com/你的用户名/你的仓库.git", "User")
199-
```
200-
201-
## 使用方法
202-
203-
```bash
204-
opencode-pull # 拉取 — 选择配置/会话/全部
205-
opencode-push # 推送 — 选择配置/会话/全部
206-
opencode-pull-force # 强制拉取(丢弃本地变更)
207-
opencode-push-force # 强制推送(冲突时覆盖远端)
208-
```
209-
210-
## 环境变量
211-
212-
| 变量 | 必需 | 说明 |
213-
|---|---|---|
214-
| `SYNC_REMOTE_URL` | **** | GitHub 仓库 URL |
215-
| `SYNC_CONFIG_ROOT` || 覆盖配置目录(默认 `~/.config/opencode`|
216-
| `SYNC_DATA_ROOT` || 覆盖数据目录(默认 `~/.local/share/opencode`|
217-
| `SYNC_STATE_ROOT` || 覆盖状态目录(默认 `~/.local/state/opencode`|
218-
| `SYNC_AGENTS_ROOT` || 覆盖 agents/skills 目录(默认 `~/.agents/skills`|
219-
| `SYNC_SKIP_LFS` || 设为 `1` 跳过 Git LFS 设置 |
123+
[MIT](./LICENSE)

README.zh-CN.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# opencode-github-sync
2+
3+
[English](./README.md)
4+
5+
通过私有 GitHub 仓库跨设备同步 [OpenCode](https://opencode.ai) 配置和会话数据。
6+
7+
将四个本地目录合并到一个 git 仓库:
8+
9+
| 本地目录 | 仓库路径 | 内容 |
10+
|---|---|---|
11+
| `~/.config/opencode/` | 仓库根目录 | 配置、技能、命令、MCP 设置 |
12+
| `~/.local/share/opencode/` | `_data/` | 认证、同步状态、SQLite 数据库 |
13+
| `~/.local/state/opencode/` | `_state/` | 使用频率、KV 存储、模型缓存 |
14+
| `~/.agents/skills/` | `_agents/` | Skills CLI 全局安装 + lock 文件 |
15+
16+
## 功能特点
17+
18+
- **配置同步** — 跨设备推送/拉取配置文件、技能和状态
19+
- **会话同步** — 推送/拉取 SQLite 数据库、存储和工具输出(在 OpenCode 外运行以避免数据库损坏)
20+
- **自动暂存** — 拉取时自动暂存本地变更
21+
- **强制模式**`--force` 在冲突时覆盖
22+
- **Git LFS** — 大型二进制文件(SQLite 数据库)通过 Git LFS 追踪
23+
- **Migration 自动修复** — 拉取较旧数据库时自动恢复迁移记录
24+
- **跨平台** — macOS 和 Windows (PowerShell 7)
25+
26+
## 前置条件
27+
28+
- **Node.js** (v18+)
29+
- **Git** + [Git LFS](https://git-lfs.github.com/)
30+
- **一个私有 GitHub 仓库** 用于存储同步数据
31+
- **SQLite3 CLI**(会话同步需要 — 数据库备份和完整性检查)
32+
33+
## 安装
34+
35+
### 1. 克隆此仓库
36+
37+
```bash
38+
git clone https://github.com/doomsday616/opencode-github-sync.git
39+
```
40+
41+
### 2. 复制脚本到 OpenCode 配置目录
42+
43+
```bash
44+
# macOS / Linux
45+
cp opencode-github-sync/scripts/*.js ~/.config/opencode/scripts/
46+
47+
# Windows (PowerShell)
48+
Copy-Item opencode-github-sync\scripts\*.js "$HOME\.config\opencode\scripts\"
49+
```
50+
51+
### 3. 安装 wrapper 命令
52+
53+
**macOS / Linux:**
54+
```bash
55+
cp opencode-github-sync/wrappers/mac/* ~/.local/bin/
56+
chmod +x ~/.local/bin/opencode-{pull,push,pull-force,push-force}
57+
```
58+
59+
**Windows:**
60+
```powershell
61+
Copy-Item opencode-github-sync\wrappers\windows\*.cmd "$HOME\.local\bin\"
62+
# 确保 ~/.local/bin 在 PATH 中
63+
```
64+
65+
### 4. 设置远端 URL
66+
67+
`SYNC_REMOTE_URL` 环境变量设为你的私有 GitHub 仓库:
68+
69+
**macOS / Linux**(添加到 `~/.zshrc``~/.bashrc`):
70+
```bash
71+
export SYNC_REMOTE_URL="https://github.com/YOUR_USER/YOUR_REPO.git"
72+
```
73+
74+
**Windows**(PowerShell profile 或系统环境变量):
75+
```powershell
76+
[System.Environment]::SetEnvironmentVariable("SYNC_REMOTE_URL", "https://github.com/YOUR_USER/YOUR_REPO.git", "User")
77+
```
78+
79+
## 使用方法
80+
81+
### 交互模式
82+
83+
```bash
84+
opencode-pull # 拉取 — 选择配置/会话/全部
85+
opencode-push # 推送 — 选择配置/会话/全部
86+
```
87+
88+
### 强制模式
89+
90+
```bash
91+
opencode-pull-force # 强制拉取(丢弃本地变更)
92+
opencode-push-force # 强制推送(冲突时覆盖远端)
93+
```
94+
95+
### 直接调用脚本
96+
97+
```bash
98+
node ~/.config/opencode/scripts/opencode-sync-core.js pull
99+
node ~/.config/opencode/scripts/opencode-sync-core.js push --force
100+
node ~/.config/opencode/scripts/opencode-sync-core.js status
101+
```
102+
103+
## 注意事项
104+
105+
- **会话同步必须在 OpenCode 外运行** — 脚本会终止运行中的 OpenCode 进程以安全复制 SQLite 数据库
106+
- **配置同步可以在 OpenCode 内运行** — 但之后需要重启会话使变更生效
107+
- Git 仓库会在首次 push/pull 时自动初始化
108+
- `.gitignore``.gitattributes` 会在同步仓库中自动生成
109+
110+
## 环境变量
111+
112+
| 变量 | 必需 | 说明 |
113+
|---|---|---|
114+
| `SYNC_REMOTE_URL` | **** | GitHub 仓库 URL(例如 `https://github.com/user/repo.git`|
115+
| `SYNC_CONFIG_ROOT` || 覆盖配置目录(默认 `~/.config/opencode`|
116+
| `SYNC_DATA_ROOT` || 覆盖数据目录(默认 `~/.local/share/opencode`|
117+
| `SYNC_STATE_ROOT` || 覆盖状态目录(默认 `~/.local/state/opencode`|
118+
| `SYNC_AGENTS_ROOT` || 覆盖 agents/skills 目录(默认 `~/.agents/skills`|
119+
| `SYNC_SKIP_LFS` || 设为 `1` 跳过 Git LFS 设置 |
120+
121+
## 许可证
122+
123+
[MIT](./LICENSE)

0 commit comments

Comments
 (0)