wangchuan 6.0.3 → 7.0.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/README.md +7 -13
- package/README.zh-CN.md +7 -13
- package/dist/bin/wangchuan.d.ts +2 -2
- package/dist/bin/wangchuan.js +20 -19
- package/dist/bin/wangchuan.js.map +1 -1
- package/dist/src/commands/pull.d.ts +9 -1
- package/dist/src/commands/pull.d.ts.map +1 -1
- package/dist/src/commands/pull.js +129 -53
- package/dist/src/commands/pull.js.map +1 -1
- package/dist/src/commands/push.d.ts +12 -5
- package/dist/src/commands/push.d.ts.map +1 -1
- package/dist/src/commands/push.js +152 -80
- package/dist/src/commands/push.js.map +1 -1
- package/dist/src/commands/status.d.ts +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +1 -17
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/core/sync-stage.d.ts.map +1 -1
- package/dist/src/core/sync-stage.js +0 -1
- package/dist/src/core/sync-stage.js.map +1 -1
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/i18n.js +12 -76
- package/dist/src/i18n.js.map +1 -1
- package/dist/src/types.d.ts +3 -8
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +22 -33
- package/skill/references/environment.md +19 -26
- package/skill/references/inspect-status.md +4 -4
- package/skill/references/install-setup.md +17 -25
- package/skill/references/resource-crud.md +11 -11
- package/skill/references/sync-conflict.md +20 -16
- package/skill/wangchuan-skill.sh +9 -11
package/skill/SKILL.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: wangchuan
|
|
3
|
-
version:
|
|
3
|
+
version: 3.0.0
|
|
4
4
|
description: >-
|
|
5
5
|
Encrypt and sync AI agent configs, memories, skills, and MCP servers across environments via a private Git repo.
|
|
6
6
|
Supports Claude, OpenClaw, Gemini, CodeBuddy, WorkBuddy, Cursor, and Codex.
|
|
7
|
-
TRIGGER when: user mentions syncing AI memories/configs, wangchuan/忘川, cross-machine agent setup, backup/restore agent settings, memory sync, skill distribution, MCP server sync, agent migration, master key export, sync status,
|
|
8
|
-
Triggers: 忘川、wangchuan、同步记忆、同步配置、同步技能、同步MCP、初始化忘川、备份记忆、恢复记忆、恢复云端记忆、绑定云端记忆、迁移agent、导出密钥、轮换密钥、同步状态、健康检查、多环境、快照、跨机器同步、agent记忆、配置路径、查看技能、删除技能、新增技能、修改技能、自定义agent、MCP服务器、新增MCP、删除MCP、修改MCP、查看MCP、写记忆、删除记忆、修改记忆、查看记忆、广播记忆、复制记忆、推送记忆、拉取记忆、同步到agent
|
|
7
|
+
TRIGGER when: user mentions syncing AI memories/configs, wangchuan/忘川, cross-machine agent setup, backup/restore agent settings, memory sync, skill distribution, MCP server sync, agent migration, master key export, sync status, workspace leakage, environment management, snapshot, pushing/pulling memories, conflict resolution, syncing between agents, rolling back/restoring versions, switching environments, health check, customizing agent paths, restore cloud memories, or any commands: init, restore, pull, push, status, doctor, memory, env, snapshot, lang.
|
|
8
|
+
Triggers: 忘川、wangchuan、同步记忆、同步配置、同步技能、同步MCP、初始化忘川、备份记忆、恢复记忆、恢复云端记忆、绑定云端记忆、迁移agent、导出密钥、轮换密钥、同步状态、健康检查、多环境、快照、跨机器同步、agent记忆、配置路径、查看技能、删除技能、新增技能、修改技能、自定义agent、MCP服务器、新增MCP、删除MCP、修改MCP、查看MCP、写记忆、删除记忆、修改记忆、查看记忆、广播记忆、复制记忆、推送记忆、拉取记忆、同步到agent、冲突、合并记忆、回退记忆、回滚、恢复版本、切换环境、忘川状态、新建环境、删除环境、查看环境、切换语言、升级忘川、更新忘川、环境泄漏、旧环境文件、sync memories、push memory、pull memory、rollback、switch environment、custom agent、MCP server、health status、rotate key、switch language、upgrade wangchuan、update wangchuan、restore memory、restore cloud.
|
|
9
9
|
DO NOT TRIGGER when: general git operations, unrelated CLI tools, or AI model APIs.
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -23,16 +23,16 @@ If `~/.wangchuan/config.json` does not exist → Read [references/install-setup.
|
|
|
23
23
|
```
|
|
24
24
|
wangchuan init [--repo <url>] [--key <path>] One-time setup
|
|
25
25
|
wangchuan restore --repo <url> --key <key> Restore cloud to new machine
|
|
26
|
-
wangchuan
|
|
26
|
+
wangchuan pull [-a <agent>] [-o <pat>] [-x <pat>] Pull cloud data to local
|
|
27
|
+
wangchuan push [-a <agent>] [-n] [-y] [-o <pat>] [-x <pat>] Push local changes to cloud
|
|
27
28
|
wangchuan status [-v] Health + diff summary
|
|
28
|
-
wangchuan watch [-i <min>] Pull-only background daemon
|
|
29
29
|
wangchuan doctor [--key-export|--key-rotate|--setup] Diagnose + auto-fix
|
|
30
30
|
wangchuan memory list|show|copy|broadcast [-a <agent>] Memory management
|
|
31
31
|
wangchuan env list|create|switch|current|delete Multi-environment
|
|
32
32
|
wangchuan snapshot save|list|restore|delete [name] Snapshots
|
|
33
33
|
wangchuan lang [zh|en] Display language
|
|
34
34
|
```
|
|
35
|
-
Aliases: `
|
|
35
|
+
Aliases: `push`→`s`, `status`→`st`, `snapshot`→`snap`. All support `--agent` / `-a` filter.
|
|
36
36
|
|
|
37
37
|
## Task Routing — Load the right reference BEFORE acting
|
|
38
38
|
|
|
@@ -54,7 +54,7 @@ Aliases: `sync`→`s`, `status`→`st`, `snapshot`→`snap`. All support `--agen
|
|
|
54
54
|
|---------|-----------|----------|
|
|
55
55
|
| `wangchuan init` | Interactive prompt fails | Must pass `--repo <url>` |
|
|
56
56
|
| `wangchuan restore` | Interactive prompt fails | Must pass `--repo <url>` and `--key <key>` |
|
|
57
|
-
| `wangchuan
|
|
57
|
+
| `wangchuan push` | Pending confirmations skipped | Must pass `-y` |
|
|
58
58
|
| `wangchuan env create` | Memory import prompt fails | Auto-forks (OK) |
|
|
59
59
|
|
|
60
60
|
## Customizing Agent Workspace Paths
|
|
@@ -63,52 +63,41 @@ Default paths are in `~/.wangchuan/config.json`. To change (e.g. Claude to `~/.c
|
|
|
63
63
|
```bash
|
|
64
64
|
jq '.profiles.default.claude.workspacePath = "~/.claude-internal"' ~/.wangchuan/config.json > /tmp/wc-cfg.json && mv /tmp/wc-cfg.json ~/.wangchuan/config.json
|
|
65
65
|
```
|
|
66
|
-
Tell user: "Path updated locally. Run `wangchuan
|
|
66
|
+
Tell user: "Path updated locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
67
67
|
|
|
68
68
|
## Sync Protocol — Rules agents MUST follow
|
|
69
69
|
|
|
70
70
|
### On session start
|
|
71
71
|
```bash
|
|
72
|
-
wangchuan
|
|
73
|
-
wangchuan sync -n # dry-run preview of pending changes
|
|
72
|
+
wangchuan pull
|
|
74
73
|
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### After EVERY skill invocation (mandatory)
|
|
78
|
-
After completing any user instruction, check if the watch daemon is running and start it if not:
|
|
79
|
-
```bash
|
|
80
|
-
# Check if watch is running, start if not (pull-only daemon)
|
|
81
|
-
pgrep -f 'wangchuan.*watch' >/dev/null 2>&1 || nohup wangchuan watch >/dev/null 2>&1 &
|
|
82
|
-
```
|
|
83
|
-
This ensures cloud memories are always pulled in the background. Watch is pull-only — it never pushes.
|
|
74
|
+
Pull cloud data to local on session start. No push needed.
|
|
84
75
|
|
|
85
76
|
### Rule summary
|
|
86
77
|
|
|
87
78
|
| Event | Action |
|
|
88
79
|
|-------|--------|
|
|
89
|
-
| Created/modified a **shared** skill or custom agent | Copy to all other agents → tell user: "Changes saved locally. Run `wangchuan
|
|
90
|
-
| Created/modified a **new/local** skill or custom agent | Resource stays in current agent by default. Only distribute if user **explicitly asks** to share → ask which agents → copy → register in shared-registry → tell user: "Changes saved locally. Run `wangchuan
|
|
91
|
-
| **Deleted** a skill or custom agent | **Always ask** → inform shared status → remove selected → tell user: "Changes saved locally. Run `wangchuan
|
|
92
|
-
| Created/modified an **MCP server** | Resource stays in current agent by default. Each agent's MCP config is independent. Only copy to other agents if user **explicitly asks** → ask which agents → jq write → tell user: "Changes saved locally. Run `wangchuan
|
|
93
|
-
| **Deleted** an MCP server | Ask user which agents → jq del → tell user: "Changes saved locally. Run `wangchuan
|
|
94
|
-
| Created/modified **memory** | Ask user → broadcast/copy if yes → tell user: "Changes saved locally. Run `wangchuan
|
|
95
|
-
| **Deleted** memory | Ask user which agents → rm → tell user: "Changes saved locally. Run `wangchuan
|
|
80
|
+
| Created/modified a **shared** skill or custom agent | Copy to all other agents → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
81
|
+
| Created/modified a **new/local** skill or custom agent | Resource stays in current agent by default. Only distribute if user **explicitly asks** to share → ask which agents → copy → register in shared-registry → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
82
|
+
| **Deleted** a skill or custom agent | **Always ask** → inform shared status → remove selected → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
83
|
+
| Created/modified an **MCP server** | Resource stays in current agent by default. Each agent's MCP config is independent. Only copy to other agents if user **explicitly asks** → ask which agents → jq write → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
84
|
+
| **Deleted** an MCP server | Ask user which agents → jq del → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
85
|
+
| Created/modified **memory** | Ask user → broadcast/copy if yes → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
86
|
+
| **Deleted** memory | Ask user which agents → rm → tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
96
87
|
| **Files deleted from cloud** detected on pull | Automatically deleted from local workspace (cloud is source of truth). All changes preserved in git history for rollback. |
|
|
97
|
-
| Updated other config | Tell user: "Changes saved locally. Run `wangchuan
|
|
98
|
-
| **Any skill invocation completes** | **Ensure watch daemon is running** (see above) |
|
|
88
|
+
| Updated other config | Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." → if user confirms: `wangchuan push -y` |
|
|
99
89
|
|
|
100
90
|
**IMPORTANT: Resources are agent-specific by default.** Skills, custom agents, and MCP servers are NOT auto-distributed or auto-merged across agents. They stay in the agent where they were created. Cross-agent sharing only happens when the user explicitly requests it.
|
|
101
91
|
|
|
102
|
-
**IMPORTANT: Pushing to cloud NEVER happens automatically.** After any CRUD operation, inform the user that changes are saved locally and ask if they want to
|
|
92
|
+
**IMPORTANT: Pushing to cloud NEVER happens automatically.** After any CRUD operation, inform the user that changes are saved locally and ask if they want to push to cloud. Only run `wangchuan push -y` when the user explicitly confirms.
|
|
103
93
|
|
|
104
94
|
### Environment awareness
|
|
105
95
|
|
|
106
|
-
All push/pull
|
|
96
|
+
All push/pull operations target the **current environment's branch only**. Key rules:
|
|
107
97
|
- **Push/pull**: always bound to `cfg.environment` → the current env's git branch
|
|
108
|
-
- **
|
|
109
|
-
- **Cross-env access**: NOT supported — must `env switch` first, then sync
|
|
98
|
+
- **Cross-env access**: NOT supported — must `env switch` first, then pull/push
|
|
110
99
|
- **Workspace leakage**: switching env does NOT delete local files from the previous env. After switch, stale files from old env may remain in `~/.claude/skills/` etc. Do NOT push these to the new env — run `wangchuan status -v` to check `localOnly` files first
|
|
111
|
-
- **Pull from another env**: if user asks "pull work env's memory", must switch first: `wangchuan env switch work` → auto-
|
|
100
|
+
- **Pull from another env**: if user asks "pull work env's memory", must switch first: `wangchuan env switch work` → auto-pulls
|
|
112
101
|
|
|
113
102
|
### --agent filter values
|
|
114
103
|
|
|
@@ -10,14 +10,13 @@ Environments map to git branches: `default` → `main`, `<name>` → `env/<name>
|
|
|
10
10
|
|
|
11
11
|
| Operation | Environment behavior |
|
|
12
12
|
|-----------|---------------------|
|
|
13
|
-
| `
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
| `memory copy/broadcast` | Operates on local workspace files (shared). Pushed to current env on sync. |
|
|
13
|
+
| `push` / `pull` | Always targets current env's branch. Cannot push to or pull from another env. |
|
|
14
|
+
| Skill/agent/MCP CRUD | Changes apply to local workspace, pushed to current env's branch on push. |
|
|
15
|
+
| `memory copy/broadcast` | Operates on local workspace files (shared). Pushed to current env on push. |
|
|
17
16
|
| After `env switch` | Old env's local files may linger. Check `wangchuan status -v` for `localOnly` files before pushing — do NOT blindly push stale files to the new env. |
|
|
18
17
|
| Pull from another env | Must `env switch <target>` first. No `--from-env` flag exists. |
|
|
19
18
|
|
|
20
|
-
## Listing environments
|
|
19
|
+
## Listing environments
|
|
21
20
|
|
|
22
21
|
When user says "查看忘川环境列表" / "list environments":
|
|
23
22
|
|
|
@@ -45,7 +44,7 @@ git log origin/main --oneline -20 --format="%s" | grep -oP '\[([^\]]+)\]$' | sor
|
|
|
45
44
|
|
|
46
45
|
For detailed health of a specific environment, switch to it and run `wangchuan status -v` (see inspect-status.md).
|
|
47
46
|
|
|
48
|
-
## Current environment
|
|
47
|
+
## Current environment
|
|
49
48
|
|
|
50
49
|
When user says "看下忘川当前环境" / "which environment am I in":
|
|
51
50
|
|
|
@@ -56,7 +55,7 @@ wangchuan status -v
|
|
|
56
55
|
|
|
57
56
|
Report: environment name, active machines count, health score, unsynced files, anomalies.
|
|
58
57
|
|
|
59
|
-
## Creating a new environment
|
|
58
|
+
## Creating a new environment
|
|
60
59
|
|
|
61
60
|
When user says "新建忘川 xxx 环境" / "create xxx environment":
|
|
62
61
|
|
|
@@ -65,7 +64,7 @@ When user says "新建忘川 xxx 环境" / "create xxx environment":
|
|
|
65
64
|
wangchuan env list
|
|
66
65
|
```
|
|
67
66
|
If the name already exists, inform the user and ask: "Environment 'xxx' already exists. Would you like to: (1) Import current env's memories into it, or (2) Just switch to it?"
|
|
68
|
-
- Import: `wangchuan env switch <name>` → then ask user if they want to
|
|
67
|
+
- Import: `wangchuan env switch <name>` → then ask user if they want to push: `wangchuan push -y`
|
|
69
68
|
- Switch only: `wangchuan env switch <name>`
|
|
70
69
|
|
|
71
70
|
**Step 2: Ask about data initialization.**
|
|
@@ -92,7 +91,7 @@ wangchuan env switch <name>
|
|
|
92
91
|
|
|
93
92
|
`env create` in non-TTY mode auto-forks with memories (no interactive prompt needed). To create an empty environment, there is no flag — the fork behavior is the default. If user explicitly wants empty, agent would need to create the branch manually.
|
|
94
93
|
|
|
95
|
-
## Deleting an environment
|
|
94
|
+
## Deleting an environment
|
|
96
95
|
|
|
97
96
|
When user says "删除忘川 xxx 环境" / "delete xxx environment":
|
|
98
97
|
|
|
@@ -118,14 +117,14 @@ When user says "切换到 xxx 环境" / "switch to work environment":
|
|
|
118
117
|
```bash
|
|
119
118
|
wangchuan status
|
|
120
119
|
```
|
|
121
|
-
- **Few changes (≤3 files)**: warn briefly, ask user: "Push changes before switching?" If yes: `wangchuan
|
|
120
|
+
- **Few changes (≤3 files)**: warn briefly, ask user: "Push changes before switching?" If yes: `wangchuan push -y`
|
|
122
121
|
- **Many changes or conflicts**: `wangchuan status -v` → show diff → ask "Push current changes first, or discard and switch?"
|
|
123
122
|
|
|
124
123
|
**Step 2: Switch.**
|
|
125
124
|
```bash
|
|
126
125
|
wangchuan env switch <name>
|
|
127
126
|
```
|
|
128
|
-
Auto-switches branch, updates config, runs
|
|
127
|
+
Auto-switches branch, updates config, runs pull to get target env's data.
|
|
129
128
|
|
|
130
129
|
**Step 3: Post-switch checks.**
|
|
131
130
|
|
|
@@ -144,13 +143,7 @@ Warn user: "These files exist locally but not in the new environment. Do NOT pus
|
|
|
144
143
|
|
|
145
144
|
**Note**: Since v1.9.0, pull automatically deletes local files that were removed from cloud (cloud is source of truth). All changes are preserved in git history for rollback.
|
|
146
145
|
|
|
147
|
-
**Step 4:
|
|
148
|
-
```bash
|
|
149
|
-
pkill -f 'wangchuan.*watch' 2>/dev/null; nohup wangchuan watch >/dev/null 2>&1 &
|
|
150
|
-
```
|
|
151
|
-
Watch mode **only pulls** cloud changes — it does NOT push local changes. Users must run `wangchuan sync` manually to push. If watch encounters a conflict it cannot auto-merge, it records it to `~/.wangchuan/pending-conflicts.json` — the next `wangchuan sync` will display these conflicts for user resolution.
|
|
152
|
-
|
|
153
|
-
**Step 5: If user asked "pull memory from env X" without switching:**
|
|
146
|
+
**Step 4: If user asked "pull memory from env X" without switching:**
|
|
154
147
|
Explain that cross-env pull is not supported — must switch first:
|
|
155
148
|
```bash
|
|
156
149
|
wangchuan env switch <target-env> # switch → auto-pulls target env's data
|
|
@@ -192,7 +185,7 @@ Confirm with user before deleting.
|
|
|
192
185
|
When user says "回退记忆" / "rollback" / "restore a previous version":
|
|
193
186
|
|
|
194
187
|
**Step 1: Identify target.** Ask user's intent:
|
|
195
|
-
- **Undo last
|
|
188
|
+
- **Undo last push** → find auto-snapshot
|
|
196
189
|
- **Specific time** → `wangchuan snapshot list`
|
|
197
190
|
- **Recover deleted file** → `cd ~/.wangchuan/repo && git log --oneline --name-status -20`
|
|
198
191
|
- **Revert specific change** → `git log` + `git show <hash> --stat`
|
|
@@ -213,20 +206,20 @@ cd ~/.wangchuan/repo && git show <hash>:<file-path>
|
|
|
213
206
|
|
|
214
207
|
**Step 3: Execute.**
|
|
215
208
|
|
|
216
|
-
Snapshot restore (restores locally, ask user to
|
|
209
|
+
Snapshot restore (restores locally, ask user to push):
|
|
217
210
|
```bash
|
|
218
211
|
wangchuan snapshot restore <name>
|
|
219
212
|
```
|
|
220
|
-
Tell user: "Snapshot restored locally. Run `wangchuan
|
|
213
|
+
Tell user: "Snapshot restored locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
221
214
|
|
|
222
|
-
Single file from git (needs
|
|
215
|
+
Single file from git (needs push after):
|
|
223
216
|
```bash
|
|
224
217
|
cd ~/.wangchuan/repo && git checkout <hash> -- <file-path>
|
|
225
218
|
```
|
|
226
|
-
Tell user: "File restored locally. Run `wangchuan
|
|
219
|
+
Tell user: "File restored locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
227
220
|
|
|
228
|
-
Undo last
|
|
221
|
+
Undo last push:
|
|
229
222
|
```bash
|
|
230
|
-
wangchuan snapshot list # find pre-
|
|
231
|
-
wangchuan snapshot restore <pre-
|
|
223
|
+
wangchuan snapshot list # find pre-push auto-snapshot (second most recent)
|
|
224
|
+
wangchuan snapshot restore <pre-push-snapshot>
|
|
232
225
|
```
|
|
@@ -81,10 +81,10 @@ All of compact, plus:
|
|
|
81
81
|
|
|
82
82
|
| Symptom | Meaning | Fix |
|
|
83
83
|
|---------|---------|-----|
|
|
84
|
-
| Freshness low | Haven't synced recently | `wangchuan
|
|
85
|
-
| Coverage low | Local files missing | `wangchuan
|
|
84
|
+
| Freshness low | Haven't synced recently | `wangchuan push -y` |
|
|
85
|
+
| Coverage low | Local files missing | `wangchuan pull` (pull restores) |
|
|
86
86
|
| Integrity low | Checksums mismatch | `wangchuan doctor` |
|
|
87
87
|
| Encryption low | Sensitive files unencrypted | Review config profiles |
|
|
88
|
-
| Conflict warning | Local+remote both changed | `wangchuan
|
|
88
|
+
| Conflict warning | Local+remote both changed | `wangchuan push -y` → resolve markers |
|
|
89
89
|
| Stale sync lock | Previous sync crashed | `wangchuan doctor` |
|
|
90
|
-
| Pending distributions | Unprocessed sharing | `wangchuan
|
|
90
|
+
| Pending distributions | Unprocessed sharing | `wangchuan push -y` |
|
|
@@ -26,44 +26,41 @@ npm update -g wangchuan
|
|
|
26
26
|
wangchuan --version
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
**Step 3: Pull cloud first, then
|
|
29
|
+
**Step 3: Pull cloud first, then push local changes when ready.**
|
|
30
30
|
|
|
31
|
-
After upgrade, the new version may include new/changed agent sync profiles (new syncDirs, syncFiles, jsonFields). The built-in `reconcileProfiles` mechanism automatically detects these changes when `
|
|
31
|
+
After upgrade, the new version may include new/changed agent sync profiles (new syncDirs, syncFiles, jsonFields). The built-in `reconcileProfiles` mechanism automatically detects these changes when `push` runs — it compares the built-in agent definitions against `config.json`, adds any missing entries, and saves the updated config. No manual config editing needed.
|
|
32
32
|
|
|
33
|
-
Tell the user: "Upgrade complete. Run `wangchuan
|
|
33
|
+
Tell the user: "Upgrade complete. Run `wangchuan pull` to get cloud data, then `wangchuan push` to push any newly-discovered local files." When the user confirms:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
# Pull cloud data
|
|
37
|
-
wangchuan
|
|
36
|
+
# Pull cloud data
|
|
37
|
+
wangchuan pull
|
|
38
|
+
# Push local changes
|
|
39
|
+
wangchuan push -y
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
This
|
|
42
|
+
This flow:
|
|
41
43
|
1. Auto-runs `reconcileProfiles` → detects new sync entries → updates `config.json`
|
|
42
44
|
2. **Pulls latest from cloud first** (current env branch) — ensures no cloud data is lost
|
|
43
45
|
3. Then pushes any newly-synced local files to cloud
|
|
44
46
|
|
|
45
|
-
If the first
|
|
47
|
+
If the first push shows "no changes" but you expect new files to be discovered, run push again — the first run updates config.json, the second picks up newly-discovered files:
|
|
46
48
|
```bash
|
|
47
|
-
wangchuan
|
|
49
|
+
wangchuan push -y # second push if needed
|
|
48
50
|
```
|
|
49
51
|
|
|
50
|
-
**Note**:
|
|
52
|
+
**Note**: Push is NOT automatic after upgrade. The user must explicitly request it.
|
|
51
53
|
|
|
52
54
|
**Step 4: Report results.**
|
|
53
55
|
Tell the user:
|
|
54
56
|
- New version number
|
|
55
|
-
- Any new sync entries added (visible in
|
|
57
|
+
- Any new sync entries added (visible in push output as newly-discovered files)
|
|
56
58
|
- Files synced (pulled/pushed)
|
|
57
59
|
- Current environment name
|
|
58
60
|
|
|
59
|
-
**Step 5: Ensure watch daemon running.**
|
|
60
|
-
```bash
|
|
61
|
-
pgrep -f 'wangchuan.*watch' >/dev/null 2>&1 || nohup wangchuan watch >/dev/null 2>&1 &
|
|
62
|
-
```
|
|
63
|
-
|
|
64
61
|
**Complete upgrade flow:**
|
|
65
62
|
```
|
|
66
|
-
npm update -g wangchuan → wangchuan --version → ask user to
|
|
63
|
+
npm update -g wangchuan → wangchuan --version → ask user to pull/push → wangchuan pull + wangchuan push -y (if confirmed) → report
|
|
67
64
|
```
|
|
68
65
|
|
|
69
66
|
## Initialization (when `~/.wangchuan/config.json` does not exist)
|
|
@@ -76,7 +73,7 @@ npm update -g wangchuan → wangchuan --version → ask user to sync → wangchu
|
|
|
76
73
|
2. Run: `wangchuan init --repo <url>`
|
|
77
74
|
3. Auto: generates key → clones → detects agents → extracts shared resources → pulls cloud data
|
|
78
75
|
4. **Remind user to back up key**: `wangchuan doctor --key-export`
|
|
79
|
-
5. After init, tell user: "Initialization complete. Run `wangchuan
|
|
76
|
+
5. After init, tell user: "Initialization complete. Run `wangchuan push` when ready to push local data to cloud."
|
|
80
77
|
|
|
81
78
|
## Restore (New Machine)
|
|
82
79
|
|
|
@@ -125,11 +122,6 @@ If only `default` exists → no need to ask, already synced.
|
|
|
125
122
|
wangchuan status -v
|
|
126
123
|
```
|
|
127
124
|
|
|
128
|
-
**Step 6: Ensure watch daemon.**
|
|
129
|
-
```bash
|
|
130
|
-
pgrep -f 'wangchuan.*watch' >/dev/null 2>&1 || nohup wangchuan watch >/dev/null 2>&1 &
|
|
131
|
-
```
|
|
132
|
-
|
|
133
125
|
## Key management
|
|
134
126
|
|
|
135
127
|
```bash
|
|
@@ -147,7 +139,7 @@ wangchuan doctor --setup
|
|
|
147
139
|
|
|
148
140
|
## Key mismatch handling
|
|
149
141
|
|
|
150
|
-
If `Key mismatch!` appears during
|
|
142
|
+
If `Key mismatch!` appears during push/pull:
|
|
151
143
|
1. `wangchuan doctor --key-export` on the machine that last pushed
|
|
152
144
|
2. Copy key hex to current machine
|
|
153
145
|
3. `wangchuan init --key <hex>` or write to `~/.wangchuan/master.key`
|
|
@@ -161,8 +153,8 @@ cp -r wangchuan/ ~/.claude/skills/wangchuan/
|
|
|
161
153
|
cp -r wangchuan/ ~/.openclaw/workspace/skills/wangchuan/
|
|
162
154
|
# Codex
|
|
163
155
|
cp -r wangchuan/ ~/.codex/skills/wangchuan/
|
|
164
|
-
# Or let
|
|
165
|
-
wangchuan
|
|
156
|
+
# Or let push distribute automatically:
|
|
157
|
+
wangchuan push -y
|
|
166
158
|
```
|
|
167
159
|
|
|
168
160
|
## Setting up Git repo
|
|
@@ -33,7 +33,7 @@ Skills and custom agents use the **same** flow — both are directories tracked
|
|
|
33
33
|
- **Newly created** → NOT shared (skip to Step 2b).
|
|
34
34
|
- **Existing** → check `~/.wangchuan/shared-registry.json` for the name with `kind:'skill'` or `kind:'agent'`.
|
|
35
35
|
|
|
36
|
-
**Step 2a: Already-shared** — distribute + ask user to
|
|
36
|
+
**Step 2a: Already-shared** — distribute + ask user to push:
|
|
37
37
|
```bash
|
|
38
38
|
# Example: shared skill "foo" modified in claude, also used by cursor and codebuddy
|
|
39
39
|
cp -r ~/.claude/skills/foo/ ~/.cursor/skills/foo/
|
|
@@ -42,7 +42,7 @@ cp -r ~/.claude/skills/foo/ ~/.codebuddy/skills/foo/
|
|
|
42
42
|
cp -r ~/.claude/agents/my-reviewer/ ~/.cursor/agents/my-reviewer/
|
|
43
43
|
cp -r ~/.claude/agents/my-reviewer/ ~/.codebuddy/agents/my-reviewer/
|
|
44
44
|
```
|
|
45
|
-
Tell user: "Changes saved locally and distributed to all agents. Run `wangchuan
|
|
45
|
+
Tell user: "Changes saved locally and distributed to all agents. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
46
46
|
|
|
47
47
|
**Step 2b: New / agent-local** — resource stays in the current agent by default. Only distribute if user **explicitly asks** to share:
|
|
48
48
|
```bash
|
|
@@ -58,7 +58,7 @@ If user asks to share, present options:
|
|
|
58
58
|
- **Specific agents** — copy only to selected
|
|
59
59
|
- **No distribution** (default) — keep in current agent only
|
|
60
60
|
|
|
61
|
-
After copying, tell user: "Changes saved locally. Run `wangchuan
|
|
61
|
+
After copying, tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
62
62
|
|
|
63
63
|
---
|
|
64
64
|
|
|
@@ -92,15 +92,15 @@ Options: **All agents** / **[individual agents]** / **Cancel**
|
|
|
92
92
|
|
|
93
93
|
**Step 3: Execute.**
|
|
94
94
|
|
|
95
|
-
**All agents**: `rm -rf` from every agent → unregister from shared-registry.json. Tell user: "Changes saved locally. Run `wangchuan
|
|
95
|
+
**All agents**: `rm -rf` from every agent → unregister from shared-registry.json. Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`.
|
|
96
96
|
```bash
|
|
97
97
|
rm -rf ~/.claude/skills/xxx/ ~/.cursor/skills/xxx/ ~/.codebuddy/skills/xxx/ # etc.
|
|
98
98
|
jq '.entries |= map(select(.name != "xxx" or .kind != "skill"))' ~/.wangchuan/shared-registry.json > /tmp/wc-sr.json && mv /tmp/wc-sr.json ~/.wangchuan/shared-registry.json
|
|
99
|
-
# Only
|
|
100
|
-
wangchuan
|
|
99
|
+
# Only push when user confirms:
|
|
100
|
+
wangchuan push -y
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
**Specific agents**: `rm -rf` from selected → unregister (demote). Tell user: "Changes saved locally. Run `wangchuan
|
|
103
|
+
**Specific agents**: `rm -rf` from selected → unregister (demote). Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`. Remaining agents keep local copies.
|
|
104
104
|
|
|
105
105
|
**Cancel**: no action.
|
|
106
106
|
|
|
@@ -117,7 +117,7 @@ MCP servers are JSON fields (`mcpServers`). Each agent's MCP config is **indepen
|
|
|
117
117
|
- OpenClaw: `~/.openclaw/workspace/config/mcporter.json` → `mcpServers`
|
|
118
118
|
2. Resource stays in the current agent by default. Only copy to other agents if the user **explicitly asks**.
|
|
119
119
|
- If user asks to share: ask which agents → jq write to selected
|
|
120
|
-
3. Tell user: "Changes saved locally. Run `wangchuan
|
|
120
|
+
3. Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
121
121
|
|
|
122
122
|
Example — manually copy a server to another agent:
|
|
123
123
|
```bash
|
|
@@ -129,7 +129,7 @@ jq --argjson srv "$SERVER_JSON" '.mcpServers["my-db"] = $srv' ~/.codebuddy/mcp.j
|
|
|
129
129
|
1. List which agents have it: `jq -e '.mcpServers["xxx"]' <file>` per agent
|
|
130
130
|
2. Ask user: All / Specific / Cancel
|
|
131
131
|
3. Remove via `jq 'del(.mcpServers["xxx"])'` from selected agents
|
|
132
|
-
4. Tell user: "Changes saved locally. Run `wangchuan
|
|
132
|
+
4. Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
133
133
|
|
|
134
134
|
**Note**: `jq del()` is the only way to remove an MCP server from an agent's config. There is no auto-propagation of deletions across agents.
|
|
135
135
|
|
|
@@ -145,12 +145,12 @@ Memory files are **per-agent** — no automatic cross-agent distribution.
|
|
|
145
145
|
- **All**: `wangchuan memory broadcast <agent>`
|
|
146
146
|
- **Specific**: `wangchuan memory copy <source> <target>`
|
|
147
147
|
- **No**: keep local
|
|
148
|
-
3. Tell user: "Changes saved locally. Run `wangchuan
|
|
148
|
+
3. Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
149
149
|
|
|
150
150
|
**Deleting:**
|
|
151
151
|
1. `wangchuan memory list` to see who has what
|
|
152
152
|
2. Ask user: All / Specific / Cancel
|
|
153
153
|
3. `rm -f` selected agents' memory files
|
|
154
|
-
4. Tell user: "Changes saved locally. Run `wangchuan
|
|
154
|
+
4. Tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
155
155
|
|
|
156
156
|
**Note**: Memory filenames differ per agent — Claude uses `CLAUDE.md`, OpenClaw/CodeBuddy/WorkBuddy/Codex use `MEMORY.md`.
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# Pushing, Pulling, and Conflict Resolution
|
|
2
2
|
|
|
3
|
-
## How
|
|
3
|
+
## How push and pull work
|
|
4
4
|
|
|
5
|
-
`wangchuan
|
|
5
|
+
`wangchuan push` pushes local changes to cloud. `wangchuan pull` pulls cloud changes to local. Both are one-directional. Users run `pull` to get cloud data and `push` to upload local changes.
|
|
6
6
|
|
|
7
|
-
**IMPORTANT: Pushing to cloud NEVER happens automatically.** The agent should only suggest `wangchuan
|
|
7
|
+
**IMPORTANT: Pushing to cloud NEVER happens automatically.** The agent should only suggest `wangchuan push -y` when the user explicitly asks to push. After CRUD operations, inform the user that changes are saved locally and ask if they want to push.
|
|
8
8
|
|
|
9
|
-
**IMPORTANT:
|
|
9
|
+
**IMPORTANT: Push sends each agent's files independently.** There is no cross-agent auto-distribution during push. Each agent's resources (skills, MCP servers, custom agents) are pushed to/from their own directory in the cloud repo. Sharing resources across agents is a separate, explicit user action.
|
|
10
10
|
|
|
11
|
-
Flow of `
|
|
12
|
-
Flow of `
|
|
11
|
+
Flow of `push`: **auto-snapshot** → fetch remote → if remote ahead → git pull → three-way merge → then stage + push local changes.
|
|
12
|
+
Flow of `pull`: fetch remote → if remote ahead → git pull → restore to local.
|
|
13
13
|
|
|
14
|
-
**Note**:
|
|
14
|
+
**Note**: push automatically creates a safety snapshot of the repo before every push. This means you can always roll back to the pre-push state via `wangchuan snapshot list` + `wangchuan snapshot restore`.
|
|
15
15
|
|
|
16
|
-
**Environment**: all
|
|
16
|
+
**Environment**: all push/pull operations target the **current environment's branch only** (`cfg.environment`). After push completes, always report the current environment name to the user (e.g. "Pushed to cloud (environment: work)").
|
|
17
17
|
|
|
18
18
|
## Pushing memory to cloud
|
|
19
19
|
|
|
20
20
|
1. **Preview** (optional): `wangchuan status -v`
|
|
21
|
-
2. **
|
|
21
|
+
2. **Push**: `wangchuan push -y`
|
|
22
22
|
3. **Conflict resolution** (auto for `.md` files):
|
|
23
23
|
- Non-overlapping edits → auto-merged ✅
|
|
24
24
|
- Overlapping identical edits → deduplicated ✅
|
|
@@ -30,25 +30,29 @@ Flow of `watch`: fetch remote → if remote ahead → git pull → restore to lo
|
|
|
30
30
|
(cloud changes)
|
|
31
31
|
>>>>>>> REMOTE
|
|
32
32
|
```
|
|
33
|
-
4. **If conflict markers written** → read file, show conflicts to user, ask how to resolve, edit to remove markers, `wangchuan
|
|
33
|
+
4. **If conflict markers written** → read file, show conflicts to user, ask how to resolve, edit to remove markers, `wangchuan push -y` again.
|
|
34
34
|
5. **If no conflicts** → done.
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
# Full push flow:
|
|
38
|
-
wangchuan
|
|
38
|
+
wangchuan push -y
|
|
39
39
|
# Check for conflict markers:
|
|
40
40
|
grep -l '<<<<<<< LOCAL' ~/.claude/CLAUDE.md ~/.openclaw/workspace/MEMORY.md ~/.codebuddy/MEMORY.md ~/.workbuddy/MEMORY.md ~/.codex/MEMORY.md 2>/dev/null
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Pulling memory from cloud
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
```bash
|
|
46
|
+
wangchuan pull
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use `wangchuan push -n` for a dry-run preview of what would be pushed.
|
|
46
50
|
|
|
47
51
|
Conflict resolution is identical to pushing. Encrypted files are decrypted transparently during pull.
|
|
48
52
|
|
|
49
53
|
**Pulling from a specific environment**: push/pull always targets the **current** environment's branch. To pull from a different env:
|
|
50
54
|
```bash
|
|
51
|
-
wangchuan env switch <target-env> # switches branch + auto-
|
|
55
|
+
wangchuan env switch <target-env> # switches branch + auto-pulls target env's data
|
|
52
56
|
# When done, switch back:
|
|
53
57
|
wangchuan env switch <original-env>
|
|
54
58
|
```
|
|
@@ -66,7 +70,7 @@ When user says "sync A's config to B", intent may be ambiguous.
|
|
|
66
70
|
- **MCP**: read mcpServers from source, jq merge into target
|
|
67
71
|
- **Custom agents**: `cp -r "${SRC_WS}/agents/"* "${DST_WS}/agents/"`
|
|
68
72
|
|
|
69
|
-
After completing the local operations, tell user: "Changes saved locally. Run `wangchuan
|
|
73
|
+
After completing the local operations, tell user: "Changes saved locally. Run `wangchuan push` to push to cloud." If user confirms: `wangchuan push -y`
|
|
70
74
|
|
|
71
75
|
Get workspace paths:
|
|
72
76
|
```bash
|
|
@@ -76,11 +80,11 @@ DST=$(jq -r '.profiles.default.<target>.workspacePath' ~/.wangchuan/config.json
|
|
|
76
80
|
|
|
77
81
|
## Files deleted from cloud
|
|
78
82
|
|
|
79
|
-
When another machine deletes files from the cloud repo, the next pull (via `wangchuan
|
|
83
|
+
When another machine deletes files from the cloud repo, the next pull (via `wangchuan pull`) automatically deletes them from the local workspace too. No confirmation needed — cloud is the single source of truth.
|
|
80
84
|
|
|
81
85
|
All changes are preserved in git history. To recover accidentally deleted files:
|
|
82
86
|
```bash
|
|
83
87
|
cd ~/.wangchuan/repo && git log --name-status -10 # find the deletion commit
|
|
84
88
|
git checkout <hash>~1 -- <file-path> # restore the file
|
|
85
|
-
wangchuan
|
|
89
|
+
wangchuan push -y # push it back
|
|
86
90
|
```
|
package/skill/wangchuan-skill.sh
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
# wangchuan-skill.sh — OpenClaw Skill script / OpenClaw Skill 脚本
|
|
3
3
|
#
|
|
4
4
|
# Usage (invoked by OpenClaw / Claude) / 用法(由 OpenClaw / Claude 调用):
|
|
5
|
-
# wangchuan-skill.sh pull
|
|
6
|
-
# wangchuan-skill.sh push
|
|
7
|
-
# wangchuan-skill.sh status
|
|
8
|
-
# wangchuan-skill.sh
|
|
9
|
-
# wangchuan-skill.sh
|
|
10
|
-
# wangchuan-skill.sh dump [--agent <name>]
|
|
11
|
-
# wangchuan-skill.sh init --repo <url>
|
|
5
|
+
# wangchuan-skill.sh pull [--agent openclaw|claude|gemini]
|
|
6
|
+
# wangchuan-skill.sh push [--agent <name>] [--dry-run] [--yes]
|
|
7
|
+
# wangchuan-skill.sh status [--agent <name>] [--verbose]
|
|
8
|
+
# wangchuan-skill.sh init --repo <url>
|
|
9
|
+
# wangchuan-skill.sh restore --repo <url> --key <key>
|
|
12
10
|
#
|
|
13
11
|
# Environment variables / 环境变量:
|
|
14
12
|
# WANGCHUAN_DIR Override wangchuan install path (default ~/wangchuan) / 可覆盖安装路径(默认 ~/wangchuan)
|
|
@@ -41,15 +39,15 @@ CMD="${1:-status}"
|
|
|
41
39
|
shift || true # Remove first arg, pass remaining / 移除第一个参数,剩余透传
|
|
42
40
|
|
|
43
41
|
case "$CMD" in
|
|
44
|
-
pull|push|status|diff|list|dump|lang
|
|
42
|
+
pull|push|status|diff|list|dump|lang)
|
|
45
43
|
node "$BIN" "$CMD" "$@"
|
|
46
44
|
;;
|
|
47
|
-
init)
|
|
48
|
-
node "$BIN"
|
|
45
|
+
init|restore)
|
|
46
|
+
node "$BIN" "$CMD" "$@"
|
|
49
47
|
;;
|
|
50
48
|
*)
|
|
51
49
|
echo "✖ Unknown command / 未知命令: $CMD" >&2
|
|
52
|
-
echo " Available / 可用: pull | push | status | diff | list | dump | lang |
|
|
50
|
+
echo " Available / 可用: pull | push | status | diff | list | dump | lang | init" >&2
|
|
53
51
|
exit 1
|
|
54
52
|
;;
|
|
55
53
|
esac
|