wangchuan 4.1.0 → 4.1.1

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/README.md CHANGED
@@ -2,187 +2,104 @@
2
2
 
3
3
  [中文文档](README.zh-CN.md)
4
4
 
5
- > In Chinese mythology, Wangchuan (忘川) is the River of Oblivion in the underworld — souls crossing it forget all memories of past lives.
6
- > **Wangchuan** ensures your AI agent memories are never lost across environments.
7
-
8
- Encrypted backup and cross-environment migration for AI agent configs and memories. Supports **7 agents**: OpenClaw, Claude, Gemini, CodeBuddy, WorkBuddy, Cursor, and Codex.
9
-
10
5
  [![npm version](https://img.shields.io/npm/v/wangchuan)](https://www.npmjs.com/package/wangchuan)
11
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D18.19.0-brightgreen)](https://nodejs.org)
12
7
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
13
8
 
14
- ---
15
-
16
- ## Features
17
-
18
- - **AES-256-GCM encryption** — keys stored locally, never committed to Git
19
- - **7 agents** — OpenClaw, Claude, Gemini, CodeBuddy, WorkBuddy, Cursor, Codex
20
- - **Cross-agent sharing** — skills and MCP configs auto-distributed across all agents
21
- - **JSON field-level sync** — extract specific fields (e.g. `mcpServers` from `.claude.json`)
22
- - **Delete propagation** — items deleted from all agents are pruned from repo
23
- - **One-click restore** — `init + pull` fully restores all agent configs on a new server
24
- - **Conflict resolution** — interactive overwrite/skip choices on pull
25
- - **Auto-rollback** — failed operations don't pollute repo history
26
- - **i18n** — full English and Chinese CLI support via `wangchuan lang zh|en`
27
- - **Plaintext token scanning** — auto-detect leaked secrets before push
28
- - **Config migration** — automatic v1→v2 migration with backup and rollback
29
-
30
- ---
31
-
32
- ## Commands
9
+ > Encrypted sync for AI agent configs and memories — across machines, across agents, never lost.
33
10
 
34
- | Command | Description |
35
- |---------|-------------|
36
- | `init` | Initialize system, generate AES-256-GCM key, clone private repo |
37
- | `pull` | Pull and decrypt configs from repo, restore to local workspace |
38
- | `push` | Encrypt and push local configs to repo |
39
- | `sync` | Two-way sync (pull then push) |
40
- | `status` | Show repo status, workspace diff and file inventory |
41
- | `diff` | Line-level diff per file (auto-decrypt) |
42
- | `list` | List all managed files with local/repo presence |
43
- | `dump` | Generate plaintext snapshot to temp dir for inspection |
44
- | `lang` | Switch CLI display language (zh/en) |
45
- | `watch` | Watch for file changes and auto-sync |
46
- | `env` | Manage sync environments (create/switch/list/delete) |
47
- | `agent` | Manage agents (list/enable/disable/set-path/info) |
48
- | `key` | Key management (export/import/rotate) |
49
- | `report` | Generate sync report |
50
- | `doctor` | Diagnose and fix common issues |
51
- | `history` | Show sync operation history |
52
- | `snapshot` | Create/restore/list point-in-time snapshots |
53
- | `summary` | Show sync summary statistics |
54
- | `setup` | Guided interactive setup wizard |
55
- | `health` | System health check |
56
- | `search` | Search across synced files |
57
- | `config` | Config export/import management |
58
- | `changelog` | Show sync changelog |
59
- | `tag` | Memory tagging system |
60
- | `cleanup` | Clean up expired memory entries |
61
- | `template` | Apply pre-built sync config templates |
62
- | `batch` | Run multiple commands in sequence |
63
- | `completions` | Generate shell completion scripts (bash/zsh) |
64
-
65
- All commands support `--agent <name>` filtering (except `lang`).
66
-
67
- ---
68
-
69
- ## Installation
70
-
71
- ```bash
72
- npm install -g wangchuan
73
- ```
74
-
75
- Or from source:
76
-
77
- ```bash
78
- git clone https://github.com/nicepkg/wangchuan.git
79
- cd wangchuan
80
- npm install
81
- npm run build
82
- npm link
83
- ```
11
+ Wangchuan encrypts and syncs your AI agent configurations, memories, and skills through a private Git repo. One command to sync, one daemon to keep everything up to date.
84
12
 
85
13
  ---
86
14
 
87
15
  ## Quick Start
88
16
 
89
- ### 1. Initialize
90
-
91
17
  ```bash
92
- wangchuan init --repo git@github.com:yourname/your-brain.git
93
- ```
94
-
95
- This creates:
96
- - `~/.wangchuan/config.json` — system configuration
97
- - `~/.wangchuan/master.key` — master encryption key (**back this up!**)
98
- - `~/.wangchuan/repo` — local clone of your sync repo
99
-
100
- ### 2. Push local configs
18
+ npm install -g wangchuan
101
19
 
102
- ```bash
103
- wangchuan push -m "initial sync"
104
- ```
20
+ # 1. Initialize (interactive wizard)
21
+ wangchuan init
105
22
 
106
- ### 3. Pull on a new machine
23
+ # 2. Sync everything
24
+ wangchuan sync
107
25
 
108
- ```bash
109
- wangchuan init --repo git@github.com:yourname/your-brain.git --key /path/to/master.key
110
- wangchuan pull
26
+ # 3. Start background daemon
27
+ wangchuan watch
111
28
  ```
112
29
 
113
- ### 4. Check status
30
+ On a new machine:
114
31
 
115
32
  ```bash
116
- wangchuan status
33
+ wangchuan init --repo git@github.com:you/brain.git --key /path/to/master.key
34
+ wangchuan sync
117
35
  ```
118
36
 
119
- ### 5. Switch language
120
-
121
- ```bash
122
- wangchuan lang en # English
123
- wangchuan lang zh # Chinese
124
- WANGCHUAN_LANG=en wangchuan status # env override
125
- ```
37
+ ---
126
38
 
127
- ### 6. Filter by agent
39
+ ## Commands
128
40
 
129
- ```bash
130
- wangchuan push --agent claude -m "update Claude config"
131
- wangchuan pull --agent openclaw
132
- wangchuan diff --agent gemini
133
- ```
41
+ | Command | Aliases | Description | Key Flags |
42
+ |---------|---------|-------------|-----------|
43
+ | `init` | — | One-time setup (interactive if no `--repo`) | `--repo`, `--key`, `--force` |
44
+ | `sync` | `s` | Smart bidirectional sync — THE daily command | `-a, --agent`, `-n, --dry-run` |
45
+ | `status` | `st` | One-screen summary + health score | `-v, --verbose` |
46
+ | `watch` | — | Background daemon for continuous sync | `-i, --interval <min>` |
47
+ | `doctor` | — | Diagnose + auto-fix everything | `--key-export`, `--key-rotate`, `--setup` |
48
+ | `memory` | — | Browse/copy memories between agents | `list`, `show`, `copy`, `broadcast` |
49
+ | `env` | — | Multi-environment management | `list`, `create`, `switch`, `current`, `delete` |
50
+ | `lang` | — | Switch display language | `zh`, `en` |
134
51
 
135
52
  ---
136
53
 
137
54
  ## Supported Agents
138
55
 
139
- | Agent | Default Path | Sync Files | JSON Fields |
140
- |-------|-------------|------------|-------------|
141
- | **OpenClaw** | `~/.openclaw/workspace/` | MEMORY.md (enc), AGENTS.md, SOUL.md | |
142
- | **Claude** | `~/.claude/` | CLAUDE.md, settings.json (enc) | `.claude.json` → `mcpServers` (enc) |
143
- | **Gemini** | `~/.gemini/` | — | `settings.internal.json` → `security`, `model` |
144
- | **CodeBuddy** | `~/.codebuddy/` | MEMORY.md (enc), CODEBUDDY.md | `mcp.json``mcpServers` (enc) |
145
- | **WorkBuddy** | `~/.workbuddy/` | MEMORY.md (enc), IDENTITY.md, SOUL.md, USER.md (enc) | `mcp.json``mcpServers` (enc) |
146
- | **Cursor** | `~/.cursor/` | rules/ (dir) | `mcp.json``mcpServers` (enc), `cli-config.json` → fields (enc) |
147
- | **Codex** | `~/.codex/` | MEMORY.md (enc), instructions.md | — |
148
-
149
- Each agent's `workspacePath` can be customized in `~/.wangchuan/config.json`.
150
-
151
- ---
152
-
153
- ## Repo Structure (v2)
56
+ | Agent | Default Path | Synced Content |
57
+ |-------|-------------|----------------|
58
+ | **OpenClaw** | `~/.openclaw/workspace/` | MEMORY.md (enc), AGENTS.md, SOUL.md, IDENTITY.md, USER.md (enc), memory/ (enc) |
59
+ | **Claude** | `~/.claude/` | CLAUDE.md, settings.json (enc), `.claude.json` → mcpServers (enc) |
60
+ | **Gemini** | `~/.gemini/` | `settings.internal.json` → security + model + general (enc) |
61
+ | **CodeBuddy** | `~/.codebuddy/` | MEMORY.md (enc), CODEBUDDY.md, mcp.json → mcpServers (enc), settings.json → enabledPlugins (enc) |
62
+ | **WorkBuddy** | `~/.workbuddy/` | MEMORY.md (enc), IDENTITY.md, SOUL.md, USER.md (enc), mcp.json → mcpServers (enc) |
63
+ | **Cursor** | `~/.cursor/` | rules/ (dir), mcp.json → mcpServers (enc), cli-config.json → fields (enc) |
64
+ | **Codex** | `~/.codex/` | AGENTS.md, instructions.md |
154
65
 
155
- ```
156
- repo/
157
- ├── shared/ Cross-agent shared tier
158
- │ ├── skills/ Merged skills from all agents
159
- │ ├── mcp/ Extracted MCP configs
160
- │ └── memory/SHARED.md.enc Shared memory (encrypted)
161
- ├── agents/
162
- │ ├── openclaw/
163
- │ │ ├── MEMORY.md.enc Long-term memory (encrypted)
164
- │ │ ├── AGENTS.md Agent behavior rules
165
- │ │ └── SOUL.md Agent persona
166
- │ ├── claude/
167
- │ │ ├── CLAUDE.md Global instructions
168
- │ │ ├── settings.json.enc Permissions/plugins/model (encrypted)
169
- │ │ └── mcpServers.json.enc Extracted from .claude.json (encrypted)
170
- │ ├── gemini/
171
- │ │ └── settings-sync.json Extracted security + model fields
172
- │ ├── codebuddy/
173
- │ ├── workbuddy/
174
- │ ├── cursor/
175
- │ └── codex/
176
- ```
66
+ Agent paths are customizable in `~/.wangchuan/config.json`.
177
67
 
178
68
  ---
179
69
 
180
- ## Encryption
70
+ ## Features
181
71
 
182
- - **Algorithm**: AES-256-GCM (authenticated encryption, tamper-proof)
183
- - **Key**: `~/.wangchuan/master.key` (32 bytes, hex-encoded)
184
- - **Ciphertext format**: `IV(12B) + AuthTag(16B) + CipherText` Base64 → `.enc` file
185
- - ⚠️ **Losing `master.key` means losing access to all encrypted history — back it up!**
72
+ ### Encryption
73
+ - **AES-256-GCM** authenticated encryption tamper-proof
74
+ - Key stored locally at `~/.wangchuan/master.key` (never committed)
75
+ - Ciphertext: `IV(12B) + AuthTag(16B) + CipherText` Base64 `.enc`
76
+ - Auto-scan for leaked tokens before every sync
77
+
78
+ ### Cross-Agent Sharing
79
+ - Skills and MCP configs auto-distributed to all agents
80
+ - Delete propagation — removed from all agents → pruned from repo
81
+ - Existing entries preserved (no overwrite)
82
+
83
+ ### Multi-Environment
84
+ - Create isolated environments: `wangchuan env create work`
85
+ - Switch instantly: `wangchuan env switch work`
86
+ - Each environment has its own agent configs
87
+
88
+ ### Watch Daemon
89
+ - `wangchuan watch` runs continuous background sync
90
+ - Configurable interval: `wangchuan watch -i 10`
91
+ - PID singleton — only one instance per machine
92
+
93
+ ### Memory Browsing
94
+ - `wangchuan memory list` — overview of all agent memories
95
+ - `wangchuan memory copy openclaw claude` — transfer memories
96
+ - `wangchuan memory broadcast claude` — share to all agents
97
+
98
+ ### Doctor
99
+ - Auto-discovers installed agents
100
+ - Detects stale/phantom files
101
+ - `--key-export` / `--key-rotate` for key management
102
+ - `--setup` generates a migration one-liner for new machines
186
103
 
187
104
  ---
188
105
 
@@ -192,23 +109,22 @@ Config at `~/.wangchuan/config.json`:
192
109
 
193
110
  ```jsonc
194
111
  {
195
- "repo": "git@github.com:yourname/your-brain.git",
112
+ "repo": "git@github.com:you/brain.git",
196
113
  "branch": "main",
197
114
  "localRepoPath": "~/.wangchuan/repo",
198
115
  "keyPath": "~/.wangchuan/master.key",
199
116
  "version": 2,
200
117
  "profiles": {
201
118
  "default": {
202
- "openclaw": { "enabled": true, "workspacePath": "~/.openclaw/workspace", ... },
203
- "claude": { "enabled": true, "workspacePath": "~/.claude", ... },
204
- "gemini": { "enabled": true, "workspacePath": "~/.gemini", ... },
205
- "codex": { "enabled": true, "workspacePath": "~/.codex", ... }
119
+ "openclaw": { "enabled": true, "workspacePath": "~/.openclaw/workspace" },
120
+ "claude": { "enabled": true, "workspacePath": "~/.claude" },
121
+ "gemini": { "enabled": true, "workspacePath": "~/.gemini" }
206
122
  }
207
123
  },
208
124
  "shared": {
209
- "skills": { "sources": [{ "agent": "claude", "dir": "skills/" }, ...] },
210
- "mcp": { "sources": [{ "agent": "claude", "src": ".claude.json", "field": "mcpServers" }, ...] },
211
- "syncFiles": [...]
125
+ "skills": { "sources": [{ "agent": "claude", "dir": "skills/" }] },
126
+ "mcp": { "sources": [{ "agent": "claude", "src": ".claude.json", "field": "mcpServers" }] },
127
+ "syncFiles": []
212
128
  }
213
129
  }
214
130
  ```
@@ -218,35 +134,27 @@ Config at `~/.wangchuan/config.json`:
218
134
  ## Security
219
135
 
220
136
  1. `master.key` is in `.gitignore` — never accidentally committed
221
- 2. Auto-scan for plaintext tokens (`api_key`, `sk-xxx`, `password`, etc.) before push
222
- 3. Transfer keys via encrypted channels only (never plaintext email/IM)
137
+ 2. Auto-scan for plaintext tokens (`api_key`, `sk-xxx`, `password`) before sync
138
+ 3. Transfer keys via encrypted channels only
139
+ 4. ⚠️ **Losing `master.key` means losing access to all encrypted history — back it up!**
223
140
 
224
141
  ---
225
142
 
226
- ## Project Structure
143
+ ## Installation
227
144
 
145
+ ```bash
146
+ npm install -g wangchuan
228
147
  ```
229
- wangchuan/
230
- ├── bin/wangchuan.ts CLI entry
231
- ├── src/
232
- │ ├── core/
233
- │ │ ├── sync.ts Sync engine (distribute, prune, 3-way ops)
234
- │ │ ├── json-field.ts JSON field extraction & merge
235
- │ │ ├── crypto.ts AES-256-GCM encrypt/decrypt
236
- │ │ ├── git.ts simple-git wrapper
237
- │ │ ├── config.ts Config management (v2 profiles + shared)
238
- │ │ └── migrate.ts v1→v2 migration (backup + lock + rollback)
239
- │ ├── agents/ Agent definitions (one file per agent)
240
- │ ├── commands/ 28 CLI commands
241
- │ ├── utils/ Logger, validator, line diff, prompt
242
- │ ├── i18n.ts i18n message dictionary & t() helper
243
- │ └── types.ts Global type definitions
244
- ├── skill/ OpenClaw Skill wrapper
245
- ├── test/ Unit tests (crypto, json-field, sync engine)
246
- └── .wangchuan/
247
- └── config.example.json Config example (v2)
148
+
149
+ From source:
150
+
151
+ ```bash
152
+ git clone https://github.com/nicepkg/wangchuan.git
153
+ cd wangchuan && npm install && npm run build && npm link
248
154
  ```
249
155
 
156
+ Requires Node.js ≥ 18.19.0.
157
+
250
158
  ---
251
159
 
252
160
  ## License
package/README.zh-CN.md CHANGED
@@ -2,213 +2,129 @@
2
2
 
3
3
  [English](README.md)
4
4
 
5
- > 忘川是中国神话中冥界的遗忘之河,亡魂渡河饮水即忘前世一切记忆。
6
- > 而 **忘川** 让你的 AI 智能体记忆在环境切换时永不遗失。
7
-
8
- AI 记忆同步系统 — 加密备份与跨环境迁移。支持 **7 种智能体**:OpenClaw、Claude、Gemini、CodeBuddy、WorkBuddy、Cursor、Codex。
9
-
10
5
  [![npm version](https://img.shields.io/npm/v/wangchuan)](https://www.npmjs.com/package/wangchuan)
11
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D18.19.0-brightgreen)](https://nodejs.org)
12
7
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
13
8
 
14
- ---
15
-
16
- ## 功能特性
17
-
18
- - **AES-256-GCM 加密** — 密钥本地存储,永不提交 Git
19
- - **7 种智能体** — OpenClaw、Claude、Gemini、CodeBuddy、WorkBuddy、Cursor、Codex
20
- - **跨 agent 共享** — Skills 和 MCP 配置自动在所有 agent 间分发
21
- - **JSON 字段级同步** — 提取指定字段(如从 `.claude.json` 只同步 `mcpServers`)
22
- - **删除传播** — 所有 agent 都删除的 skill/MCP 自动从仓库清理
23
- - **一键还原** — 新服务器 `init + pull` 即可完整恢复所有 agent 配置
24
- - **冲突解决** — 拉取时交互式选择覆盖/跳过
25
- - **自动回滚** — 失败自动回滚,不污染仓库历史
26
- - **多语言** — 完整中英文 CLI 支持,通过 `wangchuan lang zh|en` 切换
27
- - **明文扫描** — 推送前自动检测泄露的 token/密钥
28
- - **配置迁移** — 自动 v1→v2 迁移,含备份和回滚保护
29
-
30
- ---
31
-
32
- ## 命令列表
9
+ > AI 记忆加密同步 — 跨机器、跨智能体,永不遗失。
33
10
 
34
- | 命令 | 描述 |
35
- |------|------|
36
- | `init` | 初始化系统、生成 AES-256-GCM 密钥、克隆私有仓库 |
37
- | `pull` | 从仓库拉取并解密配置,还原到本地工作区 |
38
- | `push` | 将本地配置加密推送到仓库 |
39
- | `sync` | 双向同步(先拉取再推送) |
40
- | `status` | 查看仓库状态、工作区差异与文件清单 |
41
- | `diff` | 逐文件显示本地与仓库的行级差异(自动解密) |
42
- | `list` | 列出所有托管文件,显示本地/仓库存在状态 |
43
- | `dump` | 生成明文快照到临时目录,方便检查同步内容 |
44
- | `lang` | 切换 CLI 显示语言(zh/en) |
45
- | `watch` | 监听文件变化并自动同步 |
46
- | `env` | 管理同步环境(创建/切换/列出/删除) |
47
- | `agent` | 管理智能体(列出/启用/禁用/设置路径/详情) |
48
- | `key` | 密钥管理(导出/导入/轮换) |
49
- | `report` | 生成同步报告 |
50
- | `doctor` | 诊断并修复常见问题 |
51
- | `history` | 查看同步操作历史 |
52
- | `snapshot` | 创建/恢复/列出时间点快照 |
53
- | `summary` | 显示同步统计摘要 |
54
- | `setup` | 引导式交互初始化向导 |
55
- | `health` | 系统健康检查 |
56
- | `search` | 搜索已同步的文件 |
57
- | `config` | 配置导出/导入管理 |
58
- | `changelog` | 查看同步变更日志 |
59
- | `tag` | 记忆标签系统 |
60
- | `cleanup` | 清理过期记忆条目 |
61
- | `template` | 应用预设同步配置模板 |
62
- | `batch` | 批量执行多个命令 |
63
- | `completions` | 生成 shell 自动补全脚本(bash/zsh) |
64
-
65
- 所有命令支持 `--agent <name>` 过滤(`lang` 除外)。
66
-
67
- ---
68
-
69
- ## 安装
70
-
71
- ```bash
72
- npm install -g wangchuan
73
- ```
74
-
75
- 或从源码安装:
76
-
77
- ```bash
78
- git clone https://github.com/nicepkg/wangchuan.git
79
- cd wangchuan
80
- npm install
81
- npm run build
82
- npm link
83
- ```
11
+ 忘川通过私有 Git 仓库加密同步你的 AI 智能体配置、记忆和技能。一条命令同步,一个守护进程保持全局最新。
84
12
 
85
13
  ---
86
14
 
87
15
  ## 快速开始
88
16
 
89
- ### 1. 初始化
90
-
91
17
  ```bash
92
- wangchuan init --repo git@github.com:yourname/your-brain.git
93
- ```
94
-
95
- 执行后创建:
96
- - `~/.wangchuan/config.json` — 系统配置
97
- - `~/.wangchuan/master.key` — 主密钥(**请妥善保管**)
98
- - `~/.wangchuan/repo` — 本地仓库克隆
99
-
100
- ### 2. 推送本地配置
18
+ npm install -g wangchuan
101
19
 
102
- ```bash
103
- wangchuan push -m "初始化配置"
104
- ```
20
+ # 1. 初始化(交互式向导)
21
+ wangchuan init
105
22
 
106
- ### 3. 在新环境拉取记忆
23
+ # 2. 同步全部
24
+ wangchuan sync
107
25
 
108
- ```bash
109
- wangchuan init --repo git@github.com:yourname/your-brain.git --key /path/to/master.key
110
- wangchuan pull
26
+ # 3. 启动后台守护进程
27
+ wangchuan watch
111
28
  ```
112
29
 
113
- ### 4. 查看同步状态
30
+ 在新机器上:
114
31
 
115
32
  ```bash
116
- wangchuan status
33
+ wangchuan init --repo git@github.com:you/brain.git --key /path/to/master.key
34
+ wangchuan sync
117
35
  ```
118
36
 
119
- ### 5. 切换显示语言
120
-
121
- ```bash
122
- wangchuan lang en # 切换到英文
123
- wangchuan lang zh # 切换到中文
124
- WANGCHUAN_LANG=en wangchuan status # 环境变量覆盖
125
- ```
37
+ ---
126
38
 
127
- ### 6. 只操作指定智能体
39
+ ## 命令列表
128
40
 
129
- ```bash
130
- wangchuan push --agent claude -m "更新 Claude 配置"
131
- wangchuan pull --agent openclaw
132
- wangchuan diff --agent gemini
133
- ```
41
+ | 命令 | 别名 | 描述 | 主要参数 |
42
+ |------|------|------|----------|
43
+ | `init` | — | 首次初始化(无 `--repo` 时进入交互向导) | `--repo`、`--key`、`--force` |
44
+ | `sync` | `s` | 智能双向同步 — 日常唯一命令 | `-a, --agent`、`-n, --dry-run` |
45
+ | `status` | `st` | 一屏总览 + 健康评分 | `-v, --verbose` |
46
+ | `watch` | — | 后台守护进程,持续自动同步 | `-i, --interval <分钟>` |
47
+ | `doctor` | — | 诊断 + 自动修复所有问题 | `--key-export`、`--key-rotate`、`--setup` |
48
+ | `memory` | — | 浏览/复制智能体记忆 | `list`、`show`、`copy`、`broadcast` |
49
+ | `env` | — | 多环境管理 | `list`、`create`、`switch`、`current`、`delete` |
50
+ | `lang` | — | 切换显示语言 | `zh`、`en` |
134
51
 
135
52
  ---
136
53
 
137
54
  ## 支持的智能体
138
55
 
139
- | 智能体 | 默认路径 | 同步文件 | JSON 字段 |
140
- |--------|---------|---------|-----------|
141
- | **OpenClaw** | `~/.openclaw/workspace/` | MEMORY.md(加密)、AGENTS.md、SOUL.md | — |
142
- | **Claude** | `~/.claude/` | CLAUDE.md、settings.json(加密) | `.claude.json` → `mcpServers`(加密) |
143
- | **Gemini** | `~/.gemini/` | — | `settings.internal.json` → `security`、`model` |
144
- | **CodeBuddy** | `~/.codebuddy/` | MEMORY.md(加密)、CODEBUDDY.md | `mcp.json``mcpServers`(加密) |
145
- | **WorkBuddy** | `~/.workbuddy/` | MEMORY.md(加密)、IDENTITY.md、SOUL.md、USER.md(加密) | `mcp.json``mcpServers`(加密) |
146
- | **Cursor** | `~/.cursor/` | rules/(目录) | `mcp.json``mcpServers`(加密)、`cli-config.json` → 字段(加密) |
147
- | **Codex** | `~/.codex/` | MEMORY.md(加密)、instructions.md | — |
148
-
149
- 每个智能体的 `workspacePath` 均可在 `~/.wangchuan/config.json` 中自定义。
150
-
151
- ---
152
-
153
- ## 仓库结构 (v2)
56
+ | 智能体 | 默认路径 | 同步内容 |
57
+ |--------|---------|----------|
58
+ | **OpenClaw** | `~/.openclaw/workspace/` | MEMORY.md(加密)、AGENTS.md、SOUL.md、IDENTITY.md、USER.md(加密)、memory/(加密) |
59
+ | **Claude** | `~/.claude/` | CLAUDE.md、settings.json(加密)、`.claude.json` → mcpServers(加密) |
60
+ | **Gemini** | `~/.gemini/` | `settings.internal.json` → security + model + general(加密) |
61
+ | **CodeBuddy** | `~/.codebuddy/` | MEMORY.md(加密)、CODEBUDDY.mdmcp.json → mcpServers(加密)、settings.json → enabledPlugins(加密) |
62
+ | **WorkBuddy** | `~/.workbuddy/` | MEMORY.md(加密)、IDENTITY.md、SOUL.md、USER.md(加密)、mcp.json → mcpServers(加密) |
63
+ | **Cursor** | `~/.cursor/` | rules/(目录)、mcp.json → mcpServers(加密)、cli-config.json → 字段(加密) |
64
+ | **Codex** | `~/.codex/` | AGENTS.mdinstructions.md |
154
65
 
155
- ```
156
- repo/
157
- ├── shared/ 跨 agent 共享层
158
- │ ├── skills/ 所有 agent 的 skills 合并
159
- │ ├── mcp/ 各 agent 的 MCP 配置提取
160
- │ └── memory/SHARED.md.enc 跨 agent 共享记忆(加密)
161
- ├── agents/
162
- │ ├── openclaw/
163
- │ │ ├── MEMORY.md.enc 永久记忆(加密)
164
- │ │ ├── AGENTS.md Agent 行为准则
165
- │ │ └── SOUL.md Agent 人格设定
166
- │ ├── claude/
167
- │ │ ├── CLAUDE.md 全局指令
168
- │ │ ├── settings.json.enc 权限/插件/模型(加密)
169
- │ │ └── mcpServers.json.enc 从 .claude.json 提取(加密)
170
- │ ├── gemini/
171
- │ │ └── settings-sync.json 提取的 security + model 字段
172
- │ ├── codebuddy/
173
- │ ├── workbuddy/
174
- │ ├── cursor/
175
- │ └── codex/
176
- ```
66
+ 各智能体的 `workspacePath` 均可在 `~/.wangchuan/config.json` 中自定义。
177
67
 
178
68
  ---
179
69
 
180
- ## 加密说明
70
+ ## 功能特性
181
71
 
182
- - **算法**:AES-256-GCM(认证加密,防篡改)
183
- - **密钥**:`~/.wangchuan/master.key`(32 字节,十六进制存储)
184
- - **密文格式**:`IV(12B) + AuthTag(16B) + CipherText` → Base64 编码 → `.enc` 文件
185
- - ⚠️ **master.key 丢失将无法解密历史配置,请做好备份!**
72
+ ### 加密
73
+ - **AES-256-GCM** 认证加密 — 防篡改
74
+ - 密钥存储在本地 `~/.wangchuan/master.key`(永不提交)
75
+ - 密文格式:`IV(12B) + AuthTag(16B) + CipherText` → Base64 → `.enc`
76
+ - 每次同步前自动扫描泄露的 token
77
+
78
+ ### 跨智能体共享
79
+ - Skills 和 MCP 配置自动分发到所有智能体
80
+ - 删除传播 — 所有智能体都删除后自动从仓库清理
81
+ - 已有条目不会被覆盖
82
+
83
+ ### 多环境管理
84
+ - 创建隔离环境:`wangchuan env create work`
85
+ - 即时切换:`wangchuan env switch work`
86
+ - 每个环境拥有独立的智能体配置
87
+
88
+ ### Watch 守护进程
89
+ - `wangchuan watch` 持续后台同步
90
+ - 可配置间隔:`wangchuan watch -i 10`
91
+ - PID 单例 — 每台机器只运行一个实例
92
+
93
+ ### 记忆浏览
94
+ - `wangchuan memory list` — 查看所有智能体记忆概览
95
+ - `wangchuan memory copy openclaw claude` — 在智能体间传输记忆
96
+ - `wangchuan memory broadcast claude` — 将记忆广播到所有智能体
97
+
98
+ ### 诊断修复
99
+ - 自动发现已安装的智能体
100
+ - 检测残留/幻影文件
101
+ - `--key-export` / `--key-rotate` 密钥管理
102
+ - `--setup` 生成新机器迁移命令
186
103
 
187
104
  ---
188
105
 
189
106
  ## 配置文件
190
107
 
191
- 配置位于 `~/.wangchuan/config.json`:
108
+ 位于 `~/.wangchuan/config.json`:
192
109
 
193
110
  ```jsonc
194
111
  {
195
- "repo": "git@github.com:yourname/your-brain.git",
112
+ "repo": "git@github.com:you/brain.git",
196
113
  "branch": "main",
197
114
  "localRepoPath": "~/.wangchuan/repo",
198
115
  "keyPath": "~/.wangchuan/master.key",
199
116
  "version": 2,
200
117
  "profiles": {
201
118
  "default": {
202
- "openclaw": { "enabled": true, "workspacePath": "~/.openclaw/workspace", ... },
203
- "claude": { "enabled": true, "workspacePath": "~/.claude", ... },
204
- "gemini": { "enabled": true, "workspacePath": "~/.gemini", ... },
205
- "codex": { "enabled": true, "workspacePath": "~/.codex", ... }
119
+ "openclaw": { "enabled": true, "workspacePath": "~/.openclaw/workspace" },
120
+ "claude": { "enabled": true, "workspacePath": "~/.claude" },
121
+ "gemini": { "enabled": true, "workspacePath": "~/.gemini" }
206
122
  }
207
123
  },
208
124
  "shared": {
209
- "skills": { "sources": [{ "agent": "claude", "dir": "skills/" }, ...] },
210
- "mcp": { "sources": [{ "agent": "claude", "src": ".claude.json", "field": "mcpServers" }, ...] },
211
- "syncFiles": [...]
125
+ "skills": { "sources": [{ "agent": "claude", "dir": "skills/" }] },
126
+ "mcp": { "sources": [{ "agent": "claude", "src": ".claude.json", "field": "mcpServers" }] },
127
+ "syncFiles": []
212
128
  }
213
129
  }
214
130
  ```
@@ -218,35 +134,27 @@ repo/
218
134
  ## 安全规范
219
135
 
220
136
  1. `master.key` 已加入 `.gitignore`,不会意外提交
221
- 2. 推送前自动扫描明文 token(`api_key`、`sk-xxx`、`password` 等)
222
- 3. 迁移密钥请用加密方式传输(不要通过明文邮件/IM)
137
+ 2. 同步前自动扫描明文 token(`api_key`、`sk-xxx`、`password` 等)
138
+ 3. 迁移密钥请用加密方式传输
139
+ 4. ⚠️ **master.key 丢失将无法解密历史配置,请做好备份!**
223
140
 
224
141
  ---
225
142
 
226
- ## 项目结构
143
+ ## 安装
227
144
 
145
+ ```bash
146
+ npm install -g wangchuan
228
147
  ```
229
- wangchuan/
230
- ├── bin/wangchuan.ts CLI 入口
231
- ├── src/
232
- │ ├── core/
233
- │ │ ├── sync.ts 同步引擎(分发、清理、三向操作)
234
- │ │ ├── json-field.ts JSON 字段级提取与合并
235
- │ │ ├── crypto.ts AES-256-GCM 加解密
236
- │ │ ├── git.ts simple-git 封装
237
- │ │ ├── config.ts 配置管理(v2 profiles + shared)
238
- │ │ └── migrate.ts v1→v2 迁移(备份 + 锁 + 回滚)
239
- │ ├── agents/ 智能体定义(每个 agent 一个文件)
240
- │ ├── commands/ 28 个 CLI 命令
241
- │ ├── utils/ 日志、校验、行级差异、交互提示
242
- │ ├── i18n.ts 国际化消息字典
243
- │ └── types.ts 全局类型定义
244
- ├── skill/ OpenClaw Skill 封装
245
- ├── test/ 单元测试(加密、JSON 字段、同步引擎)
246
- └── .wangchuan/
247
- └── config.example.json 配置示例(v2)
148
+
149
+ 从源码安装:
150
+
151
+ ```bash
152
+ git clone https://github.com/nicepkg/wangchuan.git
153
+ cd wangchuan && npm install && npm run build && npm link
248
154
  ```
249
155
 
156
+ 需要 Node.js ≥ 18.19.0。
157
+
250
158
  ---
251
159
 
252
160
  ## 许可证
@@ -35,7 +35,7 @@ const program = new Command();
35
35
  program
36
36
  .name('wangchuan')
37
37
  .description(t('cli.description'))
38
- .version('4.1.0');
38
+ .version('4.1.1');
39
39
  // ── init ────────────────────────────────────────────────────────
40
40
  program
41
41
  .command('init')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wangchuan",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "忘川 · AI 记忆同步系统 — 智能体记忆永不遗失",
5
5
  "bin": {
6
6
  "wangchuan": "./dist/bin/wangchuan.js"
package/skill/SKILL.md CHANGED
@@ -7,14 +7,18 @@ OpenClaw Skill wrapper for the Wangchuan AI memory sync system. Invoke directly
7
7
  ## Command Reference
8
8
 
9
9
  ```
10
- wangchuan sync [--agent <name>] [-n] Smart bidirectional sync (the ONE daily command)
11
- wangchuan status [--agent <name>] [-v] Show sync state at a glance (-v for full detail)
12
- wangchuan doctor [--key-export|--key-rotate|--setup] Diagnose + auto-fix issues
13
- wangchuan env list|create|switch|current|delete Multi-environment management
14
- wangchuan lang [zh|en] Switch CLI display language
15
- wangchuan init --repo <git-url> First-time init (one-time)
10
+ wangchuan init [--repo <url>] [--key <path>] One-time setup (interactive if no --repo)
11
+ wangchuan sync [-a, --agent <name>] [-n, --dry-run] Smart bidirectional sync (THE daily command)
12
+ wangchuan status [-v, --verbose] One-screen summary + health score
13
+ wangchuan watch [-i, --interval <min>] Background daemon for continuous sync
14
+ wangchuan doctor [--key-export|--key-rotate|--setup] Diagnose + auto-fix everything
15
+ wangchuan memory list|show|copy|broadcast Browse/copy memories between agents
16
+ wangchuan env list|create|switch|current|delete Multi-environment management
17
+ wangchuan lang [zh|en] Switch CLI display language
16
18
  ```
17
19
 
20
+ Aliases: `sync` → `s`, `status` → `st`
21
+
18
22
  ## Invocation Examples
19
23
 
20
24
  > Sync my AI memories
@@ -35,6 +39,14 @@ wangchuan init --repo <git-url> First-time init (one-time)
35
39
 
36
40
  > Switch to work environment
37
41
 
42
+ > Start continuous background sync
43
+
44
+ > List memories from all agents
45
+
46
+ > Copy openclaw memory to claude
47
+
48
+ > Broadcast a memory to all agents
49
+
38
50
  > Switch to English output
39
51
 
40
52
  ## Output Guide
@@ -56,6 +68,11 @@ wangchuan init --repo <git-url> First-time init (one-time)
56
68
  - Pulls remote changes if any, then pushes local changes
57
69
  - Shows compact summary with files synced count
58
70
 
71
+ ### watch
72
+ - Runs as a background daemon with configurable interval
73
+ - Auto-syncs on detected file changes
74
+ - PID file at `~/.wangchuan/watch.pid`
75
+
59
76
  ### doctor
60
77
  - Auto-fixes all common issues (no --fix needed)
61
78
  - Auto-discovers installed agents and enables them
@@ -63,9 +80,15 @@ wangchuan init --repo <git-url> First-time init (one-time)
63
80
  - `--key-export` / `--key-rotate` for key management
64
81
  - `--setup` generates migration one-liner
65
82
 
83
+ ### memory
84
+ - `list` — show all agent memories with summaries
85
+ - `show <agent>` — display full memory content
86
+ - `copy <from> <to>` — copy memory between agents
87
+ - `broadcast <agent>` — distribute memory to all agents
88
+
66
89
  ## --agent Filter
67
90
 
68
- All commands support `--agent` to filter by agent.
91
+ Supported by: `sync`, `status`, `watch`, `memory`.
69
92
 
70
93
  | Value | Description |
71
94
  |-------|-------------|
@@ -55,21 +55,31 @@ DO update for:
55
55
  - New tool integrations or workflow automations
56
56
  - Corrections to existing memory/skills (fixing outdated info)
57
57
 
58
- ## Commands — Just 6
58
+ ## Commands — All 8
59
59
 
60
60
  ```bash
61
61
  # The ONE daily command — smart bidirectional sync
62
- wangchuan sync
62
+ wangchuan sync # alias: s
63
63
 
64
64
  # Check sync state at a glance
65
- wangchuan status
65
+ wangchuan status # alias: st
66
66
 
67
67
  # Full detail (file list, diff, history, health)
68
68
  wangchuan status -v
69
69
 
70
+ # Background daemon for continuous sync
71
+ wangchuan watch
72
+ wangchuan watch -i 10 # custom interval in minutes
73
+
70
74
  # Diagnose + auto-fix everything
71
75
  wangchuan doctor
72
76
 
77
+ # Browse and copy memories between agents
78
+ wangchuan memory list
79
+ wangchuan memory show openclaw
80
+ wangchuan memory copy openclaw claude
81
+ wangchuan memory broadcast claude
82
+
73
83
  # Filter to specific agent
74
84
  wangchuan sync --agent claude
75
85
 
@@ -77,6 +87,9 @@ wangchuan sync --agent claude
77
87
  wangchuan env list
78
88
  wangchuan env create work
79
89
  wangchuan env switch work
90
+
91
+ # Switch display language
92
+ wangchuan lang zh
80
93
  ```
81
94
 
82
95
  ## Current Sync Status