介绍
# Clawdbot Sync 🔄
通过 Tailscale/SSH 在多个 Clawdbot 实例之间同步记忆、偏好设置和技能。
## 功能
- Clawdbot 实例之间的**双向同步** - **智能冲突解决**(最新的生效,或对日志进行合并) - **选择性同步** — 选择要同步的内容 - 通过 Tailscale 进行**对等发现** - 用于预览的**试运行模式**
## 命令
| 命令 | 动作 | |---------|--------| | `/sync` | 显示状态和已配置的对等节点 | | `/sync status` | 检查所有对等节点的连接 | | `/sync now [peer]` | 与对等节点同步(或全部) | | `/sync push [peer]` | 将本地更改推送到对等节点 | | `/sync pull [peer]` | 从对等节点拉取更改 | | `/sync add <name> <host> [user] [path]` | 添加对等节点 | | `/sync remove <name>` | 移除对等节点 | | `/sync diff [peer]` | 显示将要更改的内容 | | `/sync history` | 显示同步历史 |
## 设置
### 1. 配置对等节点
```bash handler.sh add mac-mini 100.95.193.55 clawdbot /Users/clawdbot/clawd $WORKSPACE handler.sh add server 100.89.48.26 clawdbot /home/clawdbot/clawd $WORKSPACE ```
### 2. 确保 SSH 访问
两台机器都需要 SSH 密钥认证: ```bash ssh-copy-id [email protected] ```
### 3. 测试连接
```bash handler.sh status $WORKSPACE ```
## 同步内容
| 项目 | 默认 | 备注 | |------|---------|-------| | `memory/` | ✅ 是 | 所有记忆文件和技能数据 | | `MEMORY.md` | ✅ 是 | 主记忆文件 | | `USER.md` | ✅ 是 | 用户资料 | | `IDENTITY.md` | ❌ 否 | 每个实例都有自己的身份 | | `skills/` | ⚙️ 可选 | 已安装的技能 | | `config/` | ❌ 否 | 实例特定的配置 |
## 处理程序命令
```bash handler.sh status $WORKSPACE # Check peers and connection handler.sh sync <peer> $WORKSPACE # Bi-directional sync handler.sh push <peer> $WORKSPACE # Push to peer handler.sh pull <peer> $WORKSPACE # Pull from peer handler.sh diff <peer> $WORKSPACE # Show differences handler.sh add <name> <host> <user> <path> $WS # Add peer handler.sh remove <name> $WORKSPACE # Remove peer handler.sh history $WORKSPACE # Sync history handler.sh auto <on|off> $WORKSPACE # Auto-sync on heartbeat ```
## 冲突解决
1. **基于时间戳**:较新的文件胜出 2. **日志合并**:仅追加文件会被合并 3. **跳过冲突**:可选择跳过冲突文件 4. **手动解决**:标记以供审查
## 数据文件
存储在 `$WORKSPACE/memory/clawdbot-sync/` 中:
| 文件 | 用途 | |------|---------| | `peers.json` | 已配置的对等节点 | | `history.json` | 同步历史日志 | | `config.json` | 同步偏好设置 | | `conflicts/` | 待审查的冲突文件 |
## 示例会话
``` User: /sync now mac-mini Bot: 🔄 Syncing with mac-mini (100.95.193.55)...
📤 Pushing: 3 files changed • memory/streaming-buddy/preferences.json • memory/2026-01-26.md • MEMORY.md 📥 Pulling: 1 file changed • memory/2026-01-25.md ✅ Sync complete! 4 files synchronized. ```
## 要求
- `rsync`(用于高效的文件同步) - `ssh`(用于安全传输) - 对等节点之间有 Tailscale 或直接网络访问 - 已配置 SSH 密钥认证
## 安全性
- 所有传输均使用 SSH(加密) - 不存储密码(仅基于密钥的认证) - 同步路径限制在工作区内 - 从不同步系统文件