wangchuan 2.1.0 → 2.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.
- package/LICENSE +21 -0
- package/README.md +121 -110
- package/dist/src/commands/push.js +2 -2
- package/dist/src/commands/push.js.map +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +50 -43
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SUpermin6u
|
|
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
CHANGED
|
@@ -2,84 +2,89 @@
|
|
|
2
2
|
|
|
3
3
|
> 忘川是中国神话中冥界的遗忘之河,亡魂渡河饮水即忘前世一切记忆。
|
|
4
4
|
> 而 **Wangchuan** 让你的 agent 记忆在环境切换时永不遗失。
|
|
5
|
+
>
|
|
6
|
+
> In Chinese mythology, Wangchuan (忘川) is the River of Oblivion in the underworld — souls crossing it forget all memories of past lives.
|
|
7
|
+
> **Wangchuan** ensures your AI agent memories are never lost across environments.
|
|
5
8
|
|
|
6
9
|
AI 记忆同步系统,支持 OpenClaw / Claude / Gemini 多种智能体记忆的加密备份与跨环境迁移。
|
|
7
10
|
|
|
11
|
+
AI memory sync system — encrypted backup and cross-environment migration for OpenClaw / Claude / Gemini agents.
|
|
12
|
+
|
|
8
13
|
---
|
|
9
14
|
|
|
10
|
-
## 功能特性
|
|
15
|
+
## 功能特性 / Features
|
|
11
16
|
|
|
12
|
-
| 命令 | 描述 |
|
|
17
|
+
| 命令 / Command | 描述 / Description |
|
|
13
18
|
|------|------|
|
|
14
|
-
| `init` | 初始化系统、生成 AES-256-GCM 密钥、克隆私有仓库 |
|
|
15
|
-
| `pull` |
|
|
16
|
-
| `push` | 将本地配置加密推送到私有仓库 |
|
|
17
|
-
| `status` | 查看仓库状态、工作区差异与文件清单 |
|
|
18
|
-
| `diff` |
|
|
19
|
-
| `list` | 列出所有托管文件,显示本地/仓库存在状态 |
|
|
20
|
-
| `dump` |
|
|
21
|
-
|
|
22
|
-
- **AES-256-GCM** 加密:密钥本地存储,永不提交 Git
|
|
23
|
-
- 全局 `--agent`
|
|
24
|
-
-
|
|
25
|
-
- **跨 agent
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- 推送前自动扫描明文 token/apiKey
|
|
29
|
-
- 拉取时检测本地独有文件,提示同步到云端
|
|
30
|
-
- 拉取冲突时交互式选择:覆盖 / 跳过 / 全部覆盖 / 全部跳过
|
|
31
|
-
- 失败自动回滚,不污染仓库历史
|
|
32
|
-
- v1→v2 自动迁移,备份 + 锁文件 + 回滚保护
|
|
33
|
-
- 支持 OpenClaw Skill 封装,对话直接调用
|
|
19
|
+
| `init` | 初始化系统、生成 AES-256-GCM 密钥、克隆私有仓库 / Initialize system, generate AES-256-GCM key, clone private repo |
|
|
20
|
+
| `pull` | 从私有仓库拉取并解密配置,还原到本地工作区 / Pull and decrypt configs from repo, restore to local workspace |
|
|
21
|
+
| `push` | 将本地配置加密推送到私有仓库 / Encrypt and push local configs to repo |
|
|
22
|
+
| `status` | 查看仓库状态、工作区差异与文件清单 / Show repo status, workspace diff and file inventory |
|
|
23
|
+
| `diff` | 逐文件显示本地与仓库的行级差异(自动解密)/ Show line-level diff per file (auto-decrypt) |
|
|
24
|
+
| `list` | 列出所有托管文件,显示本地/仓库存在状态 / List all managed files with local/repo presence |
|
|
25
|
+
| `dump` | 生成明文快照到临时目录,方便检查同步内容 / Generate plaintext snapshot to temp dir for inspection |
|
|
26
|
+
|
|
27
|
+
- **AES-256-GCM** 加密:密钥本地存储,永不提交 Git / Encryption: keys stored locally, never committed to Git
|
|
28
|
+
- 全局 `--agent` 过滤:只操作指定智能体 / Global `--agent` filter: operate on a single agent only
|
|
29
|
+
- **细粒度同步 / Fine-grained sync**:JSON 字段级提取(如 `.claude.json` 只同步 `mcpServers`) / JSON field-level extraction (e.g. only sync `mcpServers` from `.claude.json`)
|
|
30
|
+
- **跨 agent 共享 / Cross-agent sharing**:Skills 和 MCP 配置自动在所有 agent 间分发 / Skills and MCP configs auto-distributed across all agents
|
|
31
|
+
- **删除传播 / Delete propagation**:所有 agent 都删除的 skill/MCP → 自动从 repo 清理 / Items deleted from all agents are pruned from repo
|
|
32
|
+
- **一键还原 / One-click restore**:新服务器 `init + pull` 即可完整恢复所有 agent 配置 / New server `init + pull` fully restores all agent configs
|
|
33
|
+
- 推送前自动扫描明文 token/apiKey / Auto-scan for plaintext tokens before push
|
|
34
|
+
- 拉取时检测本地独有文件,提示同步到云端 / Detect local-only files on pull, prompt to push
|
|
35
|
+
- 拉取冲突时交互式选择:覆盖 / 跳过 / 全部覆盖 / 全部跳过 / Interactive conflict resolution on pull
|
|
36
|
+
- 失败自动回滚,不污染仓库历史 / Auto-rollback on failure, no repo pollution
|
|
37
|
+
- v1→v2 自动迁移,备份 + 锁文件 + 回滚保护 / Auto v1→v2 migration with backup + lock + rollback
|
|
38
|
+
- 支持 OpenClaw Skill 封装,对话直接调用 / OpenClaw Skill wrapper for conversational invocation
|
|
34
39
|
|
|
35
40
|
---
|
|
36
41
|
|
|
37
|
-
## 安装
|
|
42
|
+
## 安装 / Installation
|
|
38
43
|
|
|
39
44
|
```bash
|
|
40
45
|
git clone https://github.com/SUpermin6u/wangchuan.git ~/wangchuan
|
|
41
46
|
cd ~/wangchuan
|
|
42
47
|
npm install
|
|
43
|
-
npm run build # 编译 TypeScript
|
|
44
|
-
npm link # 全局注册 wangchuan
|
|
48
|
+
npm run build # 编译 TypeScript / Compile TypeScript
|
|
49
|
+
npm link # 全局注册 wangchuan 命令(可选)/ Register global command (optional)
|
|
45
50
|
```
|
|
46
51
|
|
|
47
52
|
---
|
|
48
53
|
|
|
49
|
-
## 快速开始
|
|
54
|
+
## 快速开始 / Quick Start
|
|
50
55
|
|
|
51
|
-
### 1. 初始化
|
|
56
|
+
### 1. 初始化 / Initialize
|
|
52
57
|
|
|
53
58
|
```bash
|
|
54
59
|
wangchuan init --repo git@github.com:yourname/your-brain.git
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
- 生成 `~/.wangchuan/config.json
|
|
59
|
-
- 生成 `~/.wangchuan/master.key
|
|
60
|
-
- 克隆仓库到 `~/.wangchuan/repo`
|
|
62
|
+
执行后 / After running:
|
|
63
|
+
- 生成 `~/.wangchuan/config.json`(系统配置)/ Creates system config
|
|
64
|
+
- 生成 `~/.wangchuan/master.key`(主密钥,**请妥善保管**)/ Creates master key (**keep it safe**)
|
|
65
|
+
- 克隆仓库到 `~/.wangchuan/repo` / Clones repo
|
|
61
66
|
|
|
62
|
-
### 2. 推送本地配置
|
|
67
|
+
### 2. 推送本地配置 / Push local configs
|
|
63
68
|
|
|
64
69
|
```bash
|
|
65
70
|
wangchuan push --message "初始化配置"
|
|
66
71
|
```
|
|
67
72
|
|
|
68
|
-
### 3. 在新环境拉取记忆
|
|
73
|
+
### 3. 在新环境拉取记忆 / Pull memories on a new machine
|
|
69
74
|
|
|
70
75
|
```bash
|
|
71
|
-
# 用 --key
|
|
76
|
+
# 用 --key 导入已有密钥 / Import existing key with --key
|
|
72
77
|
wangchuan init --repo git@github.com:yourname/your-brain.git --key /path/to/master.key
|
|
73
78
|
wangchuan pull
|
|
74
79
|
```
|
|
75
80
|
|
|
76
|
-
### 4. 查看同步状态
|
|
81
|
+
### 4. 查看同步状态 / Check sync status
|
|
77
82
|
|
|
78
83
|
```bash
|
|
79
84
|
wangchuan status
|
|
80
85
|
```
|
|
81
86
|
|
|
82
|
-
### 5. 只操作指定智能体
|
|
87
|
+
### 5. 只操作指定智能体 / Filter by agent
|
|
83
88
|
|
|
84
89
|
```bash
|
|
85
90
|
wangchuan push --agent openclaw -m "更新 OpenClaw 记忆"
|
|
@@ -89,73 +94,77 @@ wangchuan diff --agent gemini
|
|
|
89
94
|
|
|
90
95
|
---
|
|
91
96
|
|
|
92
|
-
## 支持同步的配置
|
|
97
|
+
## 支持同步的配置 / Sync Scope
|
|
93
98
|
|
|
94
99
|
每个智能体的 `workspacePath` 均可在 `~/.wangchuan/config.json` 中自定义。
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
Each agent's `workspacePath` can be customized in `~/.wangchuan/config.json`.
|
|
102
|
+
|
|
103
|
+
### Repo 目录结构 / Repo Structure (v2)
|
|
97
104
|
|
|
98
105
|
```
|
|
99
106
|
repo/
|
|
100
|
-
├── shared/ 跨 agent 共享
|
|
101
|
-
│ ├── skills/ 所有 agent 的 skills 合并
|
|
102
|
-
│ ├── mcp/ 各 agent 的 MCP 配置提取
|
|
103
|
-
│ └── memory/SHARED.md.enc 跨 agent 共享记忆
|
|
107
|
+
├── shared/ 跨 agent 共享 / Cross-agent shared
|
|
108
|
+
│ ├── skills/ 所有 agent 的 skills 合并 / Merged skills from all agents
|
|
109
|
+
│ ├── mcp/ 各 agent 的 MCP 配置提取 / Extracted MCP configs
|
|
110
|
+
│ └── memory/SHARED.md.enc 跨 agent 共享记忆 / Shared memory
|
|
104
111
|
├── agents/
|
|
105
112
|
│ ├── openclaw/
|
|
106
|
-
│ │ ├── MEMORY.md.enc
|
|
107
|
-
│ │ ├── AGENTS.md Agent 行为准则
|
|
108
|
-
│ │ └── SOUL.md Agent 人格设定
|
|
113
|
+
│ │ ├── MEMORY.md.enc 永久记忆(加密)/ Long-term memory (encrypted)
|
|
114
|
+
│ │ ├── AGENTS.md Agent 行为准则 / Agent behavior rules
|
|
115
|
+
│ │ └── SOUL.md Agent 人格设定 / Agent persona
|
|
109
116
|
│ ├── claude/
|
|
110
|
-
│ │ ├── CLAUDE.md 全局指令
|
|
111
|
-
│ │ ├── settings.json.enc
|
|
112
|
-
│ │ └── mcpServers.json.enc 从 .claude.json 提取的 mcpServers
|
|
117
|
+
│ │ ├── CLAUDE.md 全局指令 / Global instructions
|
|
118
|
+
│ │ ├── settings.json.enc 权限/插件/模型(加密)/ Permissions/plugins/model (encrypted)
|
|
119
|
+
│ │ └── mcpServers.json.enc 从 .claude.json 提取的 mcpServers(加密)/ Extracted from .claude.json (encrypted)
|
|
113
120
|
│ └── gemini/
|
|
114
|
-
│ └── settings-sync.json 从 settings.internal.json 提取的 security+model
|
|
121
|
+
│ └── settings-sync.json 从 settings.internal.json 提取的 security+model / Extracted fields
|
|
115
122
|
```
|
|
116
123
|
|
|
117
|
-
### OpenClaw
|
|
124
|
+
### OpenClaw(默认开启 / enabled by default)
|
|
118
125
|
|
|
119
|
-
| 文件 | 加密 | 说明 |
|
|
126
|
+
| 文件 / File | 加密 / Enc | 说明 / Description |
|
|
120
127
|
|------|------|------|
|
|
121
|
-
| `MEMORY.md` | ✔ | 永久记忆 |
|
|
122
|
-
| `AGENTS.md` | ✗ | 行为准则 |
|
|
123
|
-
| `SOUL.md` | ✗ | 人格设定 |
|
|
128
|
+
| `MEMORY.md` | ✔ | 永久记忆 / Long-term memory |
|
|
129
|
+
| `AGENTS.md` | ✗ | 行为准则 / Behavior rules |
|
|
130
|
+
| `SOUL.md` | ✗ | 人格设定 / Persona |
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
默认路径 / Default path:`~/.openclaw/workspace/`
|
|
126
133
|
|
|
127
|
-
### Claude
|
|
134
|
+
### Claude(默认开启 / enabled by default)
|
|
128
135
|
|
|
129
|
-
| 文件 | 加密 | 说明 |
|
|
136
|
+
| 文件 / File | 加密 / Enc | 说明 / Description |
|
|
130
137
|
|------|------|------|
|
|
131
|
-
| `CLAUDE.md` | ✗ | 全局指令 |
|
|
132
|
-
| `settings.json` | ✔ | 权限、插件、模型配置 |
|
|
133
|
-
| `.claude.json` → `mcpServers` | ✔ | JSON 字段级提取,仅同步 MCP
|
|
138
|
+
| `CLAUDE.md` | ✗ | 全局指令 / Global instructions |
|
|
139
|
+
| `settings.json` | ✔ | 权限、插件、模型配置 / Permissions, plugins, model |
|
|
140
|
+
| `.claude.json` → `mcpServers` | ✔ | JSON 字段级提取,仅同步 MCP 配置 / Field-level extraction, MCP config only |
|
|
134
141
|
|
|
135
|
-
|
|
142
|
+
默认路径 / Default path:`~/.claude-internal/`
|
|
136
143
|
|
|
137
|
-
### Gemini
|
|
144
|
+
### Gemini(默认开启 / enabled by default)
|
|
138
145
|
|
|
139
|
-
| 文件 | 加密 | 说明 |
|
|
146
|
+
| 文件 / File | 加密 / Enc | 说明 / Description |
|
|
140
147
|
|------|------|------|
|
|
141
|
-
| `settings.internal.json` → `security`, `model` | ✔ | JSON 字段级提取 |
|
|
148
|
+
| `settings.internal.json` → `security`, `model` | ✔ | JSON 字段级提取 / Field-level extraction |
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
默认路径 / Default path:`~/.gemini/`
|
|
144
151
|
|
|
145
|
-
### Shared 共享层
|
|
152
|
+
### Shared 共享层 / Shared Tier
|
|
146
153
|
|
|
147
|
-
| 内容 | 说明 |
|
|
154
|
+
| 内容 / Content | 说明 / Description |
|
|
148
155
|
|------|------|
|
|
149
|
-
| `shared/skills/` | 从 Claude 和 OpenClaw 的 skills
|
|
150
|
-
| `shared/mcp/` | 从各 agent 提取 MCP 配置,跨 agent
|
|
151
|
-
| `shared/memory/SHARED.md` | 跨 agent
|
|
156
|
+
| `shared/skills/` | 从 Claude 和 OpenClaw 的 skills 目录汇聚,自动分发 / Merged from all agents, auto-distributed |
|
|
157
|
+
| `shared/mcp/` | 从各 agent 提取 MCP 配置,跨 agent 共享 / Extracted MCP configs, shared across agents |
|
|
158
|
+
| `shared/memory/SHARED.md` | 跨 agent 共享记忆(加密)/ Cross-agent shared memory (encrypted) |
|
|
152
159
|
|
|
153
160
|
---
|
|
154
161
|
|
|
155
|
-
## 配置文件
|
|
162
|
+
## 配置文件 / Configuration
|
|
156
163
|
|
|
157
164
|
配置位于 `~/.wangchuan/config.json`,示例见 [.wangchuan/config.example.json](.wangchuan/config.example.json)。
|
|
158
165
|
|
|
166
|
+
Config at `~/.wangchuan/config.json`, see [.wangchuan/config.example.json](.wangchuan/config.example.json) for example.
|
|
167
|
+
|
|
159
168
|
```jsonc
|
|
160
169
|
{
|
|
161
170
|
"repo": "git@github.com:yourname/your-brain.git",
|
|
@@ -180,12 +189,12 @@ repo/
|
|
|
180
189
|
|
|
181
190
|
---
|
|
182
191
|
|
|
183
|
-
## 加密说明
|
|
192
|
+
## 加密说明 / Encryption
|
|
184
193
|
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
- **⚠️ master.key
|
|
194
|
+
- 算法 / Algorithm:**AES-256-GCM**(认证加密,防篡改 / Authenticated encryption, tamper-proof)
|
|
195
|
+
- 密钥 / Key:`~/.wangchuan/master.key`(32 字节,十六进制存储 / 32 bytes, hex-encoded)
|
|
196
|
+
- 密文格式 / Ciphertext format:`IV(12B) + AuthTag(16B) + CipherText`,Base64 编码后存储为 `.enc` 文件 / Base64-encoded `.enc` files
|
|
197
|
+
- **⚠️ master.key 丢失将无法解密历史配置,请做好备份 / Losing master.key means losing access to all encrypted history — back it up!**
|
|
189
198
|
|
|
190
199
|
---
|
|
191
200
|
|
|
@@ -193,57 +202,59 @@ repo/
|
|
|
193
202
|
|
|
194
203
|
将 `skill/` 目录注册为 OpenClaw Skill 后,即可在对话中直接说:
|
|
195
204
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
> "
|
|
199
|
-
> "
|
|
205
|
+
Register the `skill/` directory as an OpenClaw Skill, then invoke via conversation:
|
|
206
|
+
|
|
207
|
+
> "帮我拉取最新的 AI 配置" / "Pull the latest AI configs"
|
|
208
|
+
> "把修改推送一下,备注:更新项目记忆" / "Push changes with note: update project memory"
|
|
209
|
+
> "查看忘川状态" / "Check Wangchuan status"
|
|
210
|
+
> "列出所有托管文件" / "List all managed files"
|
|
200
211
|
|
|
201
212
|
---
|
|
202
213
|
|
|
203
|
-
## 安全规范
|
|
214
|
+
## 安全规范 / Security
|
|
204
215
|
|
|
205
|
-
1. `master.key` 已加入 `.gitignore`,不会意外提交
|
|
206
|
-
2. 推送前自动扫描明文 token(`api_key`, `sk-xxx`, `password`
|
|
207
|
-
3. 若需迁移密钥,用加密方式传输(不要通过明文邮件/IM
|
|
216
|
+
1. `master.key` 已加入 `.gitignore`,不会意外提交 / Added to `.gitignore`, never accidentally committed
|
|
217
|
+
2. 推送前自动扫描明文 token(`api_key`, `sk-xxx`, `password` 等)/ Auto-scan for plaintext tokens before push
|
|
218
|
+
3. 若需迁移密钥,用加密方式传输(不要通过明文邮件/IM)/ Transfer keys via encrypted channels only (never plaintext email/IM)
|
|
208
219
|
|
|
209
220
|
---
|
|
210
221
|
|
|
211
|
-
## 目录结构
|
|
222
|
+
## 目录结构 / Project Structure
|
|
212
223
|
|
|
213
224
|
```
|
|
214
225
|
wangchuan/
|
|
215
|
-
├── bin/wangchuan.ts CLI 入口
|
|
226
|
+
├── bin/wangchuan.ts CLI 入口 / CLI entry
|
|
216
227
|
├── src/
|
|
217
228
|
│ ├── core/
|
|
218
|
-
│ │ ├── sync.ts
|
|
219
|
-
│ │ ├── json-field.ts JSON 字段级提取与合并
|
|
220
|
-
│ │ ├── crypto.ts AES-256-GCM 加解密
|
|
221
|
-
│ │ ├── git.ts simple-git 封装
|
|
222
|
-
│ │ ├── config.ts
|
|
223
|
-
│ │ └── migrate.ts v1→v2
|
|
229
|
+
│ │ ├── sync.ts 同步引擎 / Sync engine (distribute, prune, 3-way ops)
|
|
230
|
+
│ │ ├── json-field.ts JSON 字段级提取与合并 / JSON field extraction & merge
|
|
231
|
+
│ │ ├── crypto.ts AES-256-GCM 加解密 / AES-256-GCM encrypt/decrypt
|
|
232
|
+
│ │ ├── git.ts simple-git 封装 / simple-git wrapper
|
|
233
|
+
│ │ ├── config.ts 配置管理 / Config management (v2 profiles + shared)
|
|
234
|
+
│ │ └── migrate.ts v1→v2 迁移 / v1→v2 migration (backup + lock + rollback)
|
|
224
235
|
│ ├── commands/
|
|
225
|
-
│ │ ├── init.ts init
|
|
226
|
-
│ │ ├── pull.ts pull
|
|
227
|
-
│ │ ├── push.ts push
|
|
228
|
-
│ │ ├── status.ts status
|
|
229
|
-
│ │ ├── diff.ts diff
|
|
230
|
-
│ │ ├── list.ts list
|
|
231
|
-
│ │ └── dump.ts dump
|
|
236
|
+
│ │ ├── init.ts 初始化命令 / init command
|
|
237
|
+
│ │ ├── pull.ts 拉取命令 / pull command (with localOnly detection)
|
|
238
|
+
│ │ ├── push.ts 推送命令 / push command (with stale file cleanup)
|
|
239
|
+
│ │ ├── status.ts 状态命令 / status command
|
|
240
|
+
│ │ ├── diff.ts 差异命令 / diff command
|
|
241
|
+
│ │ ├── list.ts 清单命令 / list command (shared/agents grouping)
|
|
242
|
+
│ │ └── dump.ts 明文快照 / dump command (plaintext snapshot)
|
|
232
243
|
│ ├── utils/
|
|
233
|
-
│ │ ├── logger.ts 日志工具
|
|
234
|
-
│ │ ├── validator.ts 参数校验
|
|
235
|
-
│ │ ├── linediff.ts LCS 行级差异算法
|
|
236
|
-
│ │ └── prompt.ts 交互式冲突提示
|
|
237
|
-
│ └── types.ts 全局类型定义
|
|
244
|
+
│ │ ├── logger.ts 日志工具 / Logger
|
|
245
|
+
│ │ ├── validator.ts 参数校验 / Validator
|
|
246
|
+
│ │ ├── linediff.ts LCS 行级差异算法 / LCS line diff
|
|
247
|
+
│ │ └── prompt.ts 交互式冲突提示 / Interactive conflict prompt
|
|
248
|
+
│ └── types.ts 全局类型定义 / Global type definitions
|
|
238
249
|
├── skill/
|
|
239
|
-
│ ├── SKILL.md OpenClaw Skill 说明
|
|
240
|
-
│ └── wangchuan-skill.sh Skill 脚本
|
|
250
|
+
│ ├── SKILL.md OpenClaw Skill 说明 / OpenClaw Skill doc
|
|
251
|
+
│ └── wangchuan-skill.sh Skill 脚本 / Skill script
|
|
241
252
|
├── test/
|
|
242
|
-
│ ├── crypto.test.ts 加密模块测试
|
|
243
|
-
│ ├── json-field.test.ts JSON 字段提取测试
|
|
244
|
-
│ └── sync.test.ts 同步引擎测试(42
|
|
253
|
+
│ ├── crypto.test.ts 加密模块测试 / Crypto tests
|
|
254
|
+
│ ├── json-field.test.ts JSON 字段提取测试 / JSON field tests
|
|
255
|
+
│ └── sync.test.ts 同步引擎测试(42 用例)/ Sync engine tests (42 cases)
|
|
245
256
|
└── .wangchuan/
|
|
246
|
-
└── config.example.json 配置示例(v2
|
|
257
|
+
└── config.example.json 配置示例(v2)/ Config example (v2)
|
|
247
258
|
```
|
|
248
259
|
|
|
249
260
|
---
|
|
@@ -21,8 +21,8 @@ export async function cmdPush({ message, agent } = {}) {
|
|
|
21
21
|
logger.info(`过滤智能体: ${chalk.cyan(agent)}`);
|
|
22
22
|
const agentTag = agent ? `[${agent}]` : '';
|
|
23
23
|
const msg = message
|
|
24
|
-
? `sync: ${message} ${agentTag}[${hostname}]`.trimEnd()
|
|
25
|
-
: `sync: update configs ${agentTag}[${hostname}]`.trimEnd();
|
|
24
|
+
? `sync: ${message} / update ${agentTag}[${hostname}]`.trimEnd()
|
|
25
|
+
: `sync: 更新配置 / update configs ${agentTag}[${hostname}]`.trimEnd();
|
|
26
26
|
// ── 1. 工作区 → 仓库目录 ────────────────────────────────────
|
|
27
27
|
let spinner = ora('加密并准备配置文件 …').start();
|
|
28
28
|
let stageResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/commands/push.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAe,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAO,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAY,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAW,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAY,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAe,oBAAoB,CAAC;AAErD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAQ,KAAK,CAAC;AAMxB,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,KAAkB,EAAE;IAChE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE3B,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACxB,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3B,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAE1B,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/C,IAAI,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC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EAAE,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YAC3C,CAAC,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,QAAQ;YAC3C,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,CAAC,EAAE,CAAC,UAAU,WAAW,CAAC,MAAM,CAAC,MAAM,OAAO,MAAM,YAAY,UAAU,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -1,73 +1,80 @@
|
|
|
1
|
-
# wangchuan — 智能体记忆同步技能
|
|
1
|
+
# wangchuan — 智能体记忆同步技能 / AI Agent Memory Sync Skill
|
|
2
2
|
|
|
3
|
-
## 技能简介
|
|
3
|
+
## 技能简介 / Overview
|
|
4
4
|
|
|
5
|
-
忘川(Wangchuan)AI 记忆同步系统的 OpenClaw Skill
|
|
6
|
-
在对话中直接调用以同步 AI 智能体的配置文件,跨环境永不遗失记忆。
|
|
5
|
+
忘川(Wangchuan)AI 记忆同步系统的 OpenClaw Skill 封装。在对话中直接调用以同步 AI 智能体的配置文件,跨环境永不遗失记忆。
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
OpenClaw Skill wrapper for the Wangchuan AI memory sync system. Invoke directly in conversation to sync AI agent configs — memories never lost across environments.
|
|
8
|
+
|
|
9
|
+
## 命令速查 / Command Reference
|
|
9
10
|
|
|
10
11
|
```
|
|
11
|
-
wangchuan list [--agent openclaw|claude|gemini] 列出所有受管配置项
|
|
12
|
-
wangchuan status [--agent openclaw|claude|gemini] 查看同步状态和差异摘要
|
|
13
|
-
wangchuan diff [--agent openclaw|claude|gemini] 显示行级文件差异
|
|
14
|
-
wangchuan pull [--agent openclaw|claude|gemini] 拉取远端配置,还原到本地
|
|
15
|
-
wangchuan push [--agent <name>] [-m "<描述>"] 加密推送本地配置到远端
|
|
16
|
-
wangchuan dump [--agent openclaw|claude|gemini] 生成明文快照到临时目录
|
|
17
|
-
wangchuan init --repo <git地址> 首次初始化
|
|
12
|
+
wangchuan list [--agent openclaw|claude|gemini] 列出所有受管配置项 / List managed configs
|
|
13
|
+
wangchuan status [--agent openclaw|claude|gemini] 查看同步状态和差异摘要 / Show sync status & diff summary
|
|
14
|
+
wangchuan diff [--agent openclaw|claude|gemini] 显示行级文件差异 / Show line-level file diff
|
|
15
|
+
wangchuan pull [--agent openclaw|claude|gemini] 拉取远端配置,还原到本地 / Pull & restore from repo
|
|
16
|
+
wangchuan push [--agent <name>] [-m "<描述>"] 加密推送本地配置到远端 / Encrypt & push to repo
|
|
17
|
+
wangchuan dump [--agent openclaw|claude|gemini] 生成明文快照到临时目录 / Plaintext snapshot to temp dir
|
|
18
|
+
wangchuan init --repo <git地址> 首次初始化 / First-time init
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
## 调用示例
|
|
21
|
+
## 调用示例 / Invocation Examples
|
|
22
|
+
|
|
23
|
+
> 帮我列出忘川管理的所有配置文件 / List all files managed by Wangchuan
|
|
21
24
|
|
|
22
|
-
>
|
|
25
|
+
> 查看一下忘川的同步状态 / Check Wangchuan sync status
|
|
23
26
|
|
|
24
|
-
>
|
|
27
|
+
> 只看 openclaw 的配置差异 / Show diff for openclaw only
|
|
25
28
|
|
|
26
|
-
>
|
|
29
|
+
> 帮我把最新的 AI 记忆同步到本地 / Pull the latest AI memories to local
|
|
27
30
|
|
|
28
|
-
>
|
|
31
|
+
> 只拉取 openclaw 的配置 / Pull openclaw configs only
|
|
29
32
|
|
|
30
|
-
>
|
|
33
|
+
> 我修改了 MEMORY.md,帮我推送一下,描述是"更新项目记忆" / Push my MEMORY.md changes with note "update project memory"
|
|
31
34
|
|
|
32
|
-
>
|
|
35
|
+
> 只推送 claude 的配置 / Push claude configs only
|
|
33
36
|
|
|
34
|
-
>
|
|
37
|
+
> 生成明文快照,让我检查一下同步内容 / Generate a plaintext dump so I can inspect
|
|
35
38
|
|
|
36
|
-
## 输出说明
|
|
39
|
+
## 输出说明 / Output Guide
|
|
37
40
|
|
|
38
41
|
### list
|
|
39
|
-
- `✔ 本地 ✔ 仓库` — 两侧均存在,已同步
|
|
40
|
-
- `✔ 本地 · 仓库` — 本地有但未推送
|
|
41
|
-
- `✖ 本地 ✔ 仓库` — 仓库有但本地缺失,执行 pull 还原
|
|
42
|
-
- `[enc]` — 该文件加密存储(AES-256-GCM
|
|
43
|
-
- `[字段]` — JSON
|
|
42
|
+
- `✔ 本地 ✔ 仓库` — 两侧均存在,已同步 / Present on both sides, in sync
|
|
43
|
+
- `✔ 本地 · 仓库` — 本地有但未推送 / Local only, not yet pushed
|
|
44
|
+
- `✖ 本地 ✔ 仓库` — 仓库有但本地缺失,执行 pull 还原 / In repo but missing locally, run pull
|
|
45
|
+
- `[enc]` — 该文件加密存储(AES-256-GCM)/ Encrypted (AES-256-GCM)
|
|
46
|
+
- `[字段]` — JSON 字段级提取(只同步指定字段)/ JSON field-level extraction (only syncs specified fields)
|
|
44
47
|
|
|
45
48
|
### diff
|
|
46
|
-
- `+` 绿色行 — 本地新增内容
|
|
47
|
-
- `-` 红色行 — 仓库有但本地已删除
|
|
48
|
-
- 灰色行 —
|
|
49
|
-
- `[enc]` — 加密文件已自动解密后再对比
|
|
49
|
+
- `+` 绿色行 — 本地新增内容 / Green: local additions
|
|
50
|
+
- `-` 红色行 — 仓库有但本地已删除 / Red: removed locally
|
|
51
|
+
- 灰色行 — 上下文(未变化)/ Gray: context (unchanged)
|
|
52
|
+
- `[enc]` — 加密文件已自动解密后再对比 / Encrypted files auto-decrypted for comparison
|
|
50
53
|
|
|
51
54
|
### push / pull
|
|
52
|
-
- `[已加密]` / `[已解密]` — 经过 AES-256-GCM 处理
|
|
53
|
-
- `[已清理]` — 所有 agent 都已删除的文件从 repo
|
|
54
|
-
- `⚠ 本地独有` — pull 时检测到本地有但 repo 无的文件,建议 push
|
|
55
|
+
- `[已加密]` / `[已解密]` — 经过 AES-256-GCM 处理 / Processed with AES-256-GCM
|
|
56
|
+
- `[已清理]` — 所有 agent 都已删除的文件从 repo 移除 / Stale files pruned from repo (delete propagation)
|
|
57
|
+
- `⚠ 本地独有` — pull 时检测到本地有但 repo 无的文件,建议 push / Local-only files detected, suggest push
|
|
55
58
|
|
|
56
|
-
## --agent 说明
|
|
59
|
+
## --agent 说明 / --agent Filter
|
|
57
60
|
|
|
58
|
-
所有命令均支持 `--agent`
|
|
61
|
+
所有命令均支持 `--agent` 过滤,只操作指定智能体的配置。
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
All commands support `--agent` to filter by agent.
|
|
64
|
+
|
|
65
|
+
| 值 / Value | 说明 / Description |
|
|
61
66
|
|----|------|
|
|
62
|
-
| `openclaw` | MEMORY.md(
|
|
63
|
-
| `claude` | CLAUDE.md、settings.json(
|
|
64
|
-
| `gemini` | settings.internal.json→security+model
|
|
67
|
+
| `openclaw` | MEMORY.md(加密/enc)、AGENTS.md、SOUL.md — 默认/default ~/.openclaw/workspace/ |
|
|
68
|
+
| `claude` | CLAUDE.md、settings.json(加密/enc)、.claude.json→mcpServers 字段提取(加密/enc) — 默认/default ~/.claude-internal/ |
|
|
69
|
+
| `gemini` | settings.internal.json→security+model 字段提取(加密/enc) — 默认/default ~/.gemini/ |
|
|
65
70
|
|
|
66
71
|
不指定 `--agent` 时,同时操作所有已启用的 agent 及 shared 共享层(skills/MCP/共享记忆)。
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
When omitted, operates on all enabled agents plus the shared tier (skills/MCP/shared memory).
|
|
74
|
+
|
|
75
|
+
## 前置条件 / Prerequisites
|
|
69
76
|
|
|
70
77
|
1. Node.js ≥ 18
|
|
71
|
-
2. 已执行过 `wangchuan init`(~/.wangchuan/config.json
|
|
72
|
-
3. 本地 SSH 密钥可访问目标 git 仓库
|
|
73
|
-
4. 跨机器迁移时需手动复制 `~/.wangchuan/master.key`
|
|
78
|
+
2. 已执行过 `wangchuan init`(~/.wangchuan/config.json 存在)/ `wangchuan init` has been run
|
|
79
|
+
3. 本地 SSH 密钥可访问目标 git 仓库 / Local SSH key has access to the target repo
|
|
80
|
+
4. 跨机器迁移时需手动复制 `~/.wangchuan/master.key` / Copy `master.key` manually when migrating across machines
|