wangchuan 5.7.0 → 5.8.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 +83 -64
- package/README.zh-CN.md +82 -63
- package/dist/bin/wangchuan.js +1 -1
- package/dist/src/commands/sync.d.ts.map +1 -1
- package/dist/src/commands/sync.js +16 -0
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/watch.d.ts +16 -4
- package/dist/src/commands/watch.d.ts.map +1 -1
- package/dist/src/commands/watch.js +85 -85
- package/dist/src/commands/watch.js.map +1 -1
- package/dist/src/core/sync.d.ts.map +1 -1
- package/dist/src/core/sync.js +13 -9
- package/dist/src/core/sync.js.map +1 -1
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/i18n.js +8 -10
- package/dist/src/i18n.js.map +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +86 -212
- package/skill/references/environment.md +198 -0
- package/skill/references/inspect-status.md +90 -0
- package/skill/references/install-setup.md +142 -0
- package/skill/references/resource-crud.md +153 -0
- package/skill/references/sync-conflict.md +69 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Installation, Initialization, and Key Management
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
1. Node.js >= 18
|
|
6
|
+
2. Git installed and configured (SSH key or HTTPS credentials)
|
|
7
|
+
3. A **private** Git repo on any hosting platform
|
|
8
|
+
|
|
9
|
+
## Install CLI
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g wangchuan
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Initialization (when `~/.wangchuan/config.json` does not exist)
|
|
16
|
+
|
|
17
|
+
**IMPORTANT: Interactive mode does NOT work in agent shell (non-TTY). Always pass flags explicitly.**
|
|
18
|
+
|
|
19
|
+
Ask user: brand new setup or restoring existing repo?
|
|
20
|
+
|
|
21
|
+
### Scenario A — Brand new setup
|
|
22
|
+
|
|
23
|
+
1. Guide user to create a **private** repo (or auto-create via `gh repo create wangchuan-sync --private`)
|
|
24
|
+
2. Run: `wangchuan init --repo <url>`
|
|
25
|
+
3. Auto: generates key → clones → detects agents → extracts shared resources → first sync
|
|
26
|
+
4. **Remind user to back up key**: `wangchuan doctor --key-export`
|
|
27
|
+
|
|
28
|
+
### Scenario B — Restore / new machine (may already have local agent data)
|
|
29
|
+
|
|
30
|
+
This is a multi-step flow with a **mandatory backup checkpoint**. If the user doesn't confirm backup, **stop and do not proceed** — next time the skill is triggered, start from Step 1 again.
|
|
31
|
+
|
|
32
|
+
**Step 1: Collect credentials.**
|
|
33
|
+
Ask for **repo SSH URL** and **master key** (`wangchuan_<hex>`).
|
|
34
|
+
|
|
35
|
+
**Step 2: Init (clone only, no sync yet).**
|
|
36
|
+
```bash
|
|
37
|
+
wangchuan init --repo <url> --key <key>
|
|
38
|
+
```
|
|
39
|
+
Init clones the repo and auto-runs a first sync. But BEFORE that happens, the agent must handle Steps 3-5 manually. Since init auto-syncs, the agent should instead do a **manual init sequence** to control the flow:
|
|
40
|
+
|
|
41
|
+
Actually, `wangchuan init` auto-syncs at the end and there's no flag to skip it. So the agent must do the backup warning BEFORE running init:
|
|
42
|
+
|
|
43
|
+
**Step 3: Check if local agent data exists and warn about shared resource overwrites.**
|
|
44
|
+
```bash
|
|
45
|
+
# Check if any agent workspace has data
|
|
46
|
+
for agent_dir in ~/.claude ~/.cursor ~/.openclaw/workspace ~/.codebuddy ~/.workbuddy ~/.codex ~/.gemini; do
|
|
47
|
+
[ -d "$agent_dir" ] && echo " ⚠️ Local data found: $agent_dir"
|
|
48
|
+
done
|
|
49
|
+
```
|
|
50
|
+
If local data exists, **inform the user**:
|
|
51
|
+
- "⚠️ **Shared skills and custom agents in the cloud will OVERWRITE your local versions** (no merge — direct copy)."
|
|
52
|
+
- "Your MCP servers will be safely merged (additive)."
|
|
53
|
+
- "Your memory files (CLAUDE.md, MEMORY.md) will be preserved (local wins on conflict)."
|
|
54
|
+
- "Your local-only files (skills, configs not in cloud) will be auto-pushed to cloud — please review after init."
|
|
55
|
+
|
|
56
|
+
**Ask user: "Have you backed up your important local skills/agents? Confirm to proceed, or cancel to back up first."**
|
|
57
|
+
|
|
58
|
+
If user says **cancel/not yet** → **STOP**. Do NOT run init. Tell user:
|
|
59
|
+
```
|
|
60
|
+
Please back up your local data first:
|
|
61
|
+
cp -r ~/.claude/skills/ ~/backup-claude-skills/
|
|
62
|
+
cp -r ~/.claude/agents/ ~/backup-claude-agents/
|
|
63
|
+
# (repeat for other agents as needed)
|
|
64
|
+
Then say "初始化忘川" again to resume.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If user says **confirmed** → proceed to Step 4.
|
|
68
|
+
|
|
69
|
+
**Step 4: Check cloud environments and let user choose.**
|
|
70
|
+
After init, check if cloud repo has multiple environments:
|
|
71
|
+
```bash
|
|
72
|
+
# Init first (this will clone + auto-sync to default branch)
|
|
73
|
+
wangchuan init --repo <url> --key <key>
|
|
74
|
+
# Then check for environments
|
|
75
|
+
wangchuan env list
|
|
76
|
+
```
|
|
77
|
+
If multiple environments exist (e.g. `default`, `work`, `personal`):
|
|
78
|
+
- List all environments to the user
|
|
79
|
+
- Ask: "Which environment do you want to sync with this machine?"
|
|
80
|
+
- If user picks non-default → `wangchuan env switch <chosen>` (auto-pulls that env's data)
|
|
81
|
+
|
|
82
|
+
If only `default` exists → no need to ask, already synced.
|
|
83
|
+
|
|
84
|
+
**Step 5: Post-init review.**
|
|
85
|
+
```bash
|
|
86
|
+
wangchuan status -v
|
|
87
|
+
```
|
|
88
|
+
Report what was synced: pulled files, pushed files, any conflicts detected. If shared skills were overwritten, inform user which ones.
|
|
89
|
+
|
|
90
|
+
**Complete flow summary:**
|
|
91
|
+
```
|
|
92
|
+
Ask credentials → Check local data exists?
|
|
93
|
+
→ Yes: warn overwrites → ask backup confirmed?
|
|
94
|
+
→ No: STOP (resume next time)
|
|
95
|
+
→ Yes: init → check envs → user picks env → status -v → ensure watch
|
|
96
|
+
→ No: init → check envs → user picks env → ensure watch
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Key management
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Export key (on source machine):
|
|
103
|
+
wangchuan doctor --key-export # prints wangchuan_<hex>
|
|
104
|
+
# Import key (on target machine):
|
|
105
|
+
wangchuan init --repo <url> --key wangchuan_<hex>
|
|
106
|
+
# Rotate key:
|
|
107
|
+
wangchuan doctor --key-rotate
|
|
108
|
+
# Generate setup one-liner for new machine:
|
|
109
|
+
wangchuan doctor --setup
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**`master.key` is the ONLY thing that cannot be recovered.** Back it up securely.
|
|
113
|
+
|
|
114
|
+
## Key mismatch handling
|
|
115
|
+
|
|
116
|
+
If `Key mismatch!` appears during sync:
|
|
117
|
+
1. `wangchuan doctor --key-export` on the machine that last pushed
|
|
118
|
+
2. Copy key hex to current machine
|
|
119
|
+
3. `wangchuan init --key <hex>` or write to `~/.wangchuan/master.key`
|
|
120
|
+
|
|
121
|
+
## Installing the skill to agents
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Claude
|
|
125
|
+
cp -r wangchuan/ ~/.claude/skills/wangchuan/
|
|
126
|
+
# OpenClaw
|
|
127
|
+
cp -r wangchuan/ ~/.openclaw/workspace/skills/wangchuan/
|
|
128
|
+
# Codex
|
|
129
|
+
cp -r wangchuan/ ~/.codex/skills/wangchuan/
|
|
130
|
+
# Or let sync distribute automatically:
|
|
131
|
+
wangchuan sync
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Setting up Git repo
|
|
135
|
+
|
|
136
|
+
| Platform | How |
|
|
137
|
+
|----------|-----|
|
|
138
|
+
| GitHub | `wangchuan init` auto-creates via `gh` CLI |
|
|
139
|
+
| GitLab | gitlab.com → New project → Private |
|
|
140
|
+
| Gitee | gitee.com → New repo → Private |
|
|
141
|
+
| Bitbucket | bitbucket.org → Create repository → Private |
|
|
142
|
+
| Gitea | Your instance → New Repository → Private |
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Resource CRUD — Skills, Custom Agents, MCP, Memory
|
|
2
|
+
|
|
3
|
+
## Resource types and their mechanisms
|
|
4
|
+
|
|
5
|
+
| Resource | Local path | Sharing model | Registry | Applicable agents |
|
|
6
|
+
|----------|-----------|---------------|----------|-------------------|
|
|
7
|
+
| **Skills** | `<workspace>/skills/<name>/` | Directory copy, shared-registry | `kind:'skill'` | OpenClaw, Claude, CodeBuddy, WorkBuddy, Gemini (5) |
|
|
8
|
+
| **Custom agents** | `<workspace>/agents/<name>/` | Directory copy, shared-registry | `kind:'agent'` | Claude, Cursor, CodeBuddy, WorkBuddy (4) |
|
|
9
|
+
| **MCP servers** | JSON field `mcpServers` in config file | JSON key merge, single shared file in cloud | None (auto) | Claude (`.claude.json`), OpenClaw (`config/mcporter.json`), CodeBuddy/WorkBuddy/Cursor (`mcp.json`) (5) |
|
|
10
|
+
| **Memory** | `<workspace>/MEMORY.md` etc. | Per-agent file, manual copy/broadcast | None | OpenClaw/CodeBuddy/WorkBuddy/Codex (`MEMORY.md`); Claude (`CLAUDE.md`); shared (`SHARED.md`) |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Creating or modifying skills or custom agents
|
|
15
|
+
|
|
16
|
+
Skills and custom agents use the **same** flow — both are directories tracked by `shared-registry.json`.
|
|
17
|
+
|
|
18
|
+
**`shared-registry.json` schema** (at `~/.wangchuan/shared-registry.json`):
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"entries": [
|
|
22
|
+
{ "name": "wangchuan", "kind": "skill", "sourceAgent": "claude", "sharedAt": "2026-04-14T10:00:00Z" },
|
|
23
|
+
{ "name": "my-reviewer", "kind": "agent", "sourceAgent": "claude", "sharedAt": "2026-04-14T11:00:00Z" }
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
- `kind`: `"skill"` or `"agent"` — determines which resource type
|
|
28
|
+
- `name`: directory name (e.g. skill dir name or custom agent dir name)
|
|
29
|
+
- `sourceAgent`: which agent first shared it
|
|
30
|
+
- A resource is **shared** only if it has an entry here. Absent = local-only.
|
|
31
|
+
|
|
32
|
+
**Step 1: Determine if the resource is already shared.**
|
|
33
|
+
- **Newly created** → NOT shared (skip to Step 2b).
|
|
34
|
+
- **Existing** → check `~/.wangchuan/shared-registry.json` for the name with `kind:'skill'` or `kind:'agent'`.
|
|
35
|
+
|
|
36
|
+
**Step 2a: Already-shared** — distribute + sync automatically:
|
|
37
|
+
```bash
|
|
38
|
+
# Example: shared skill "foo" modified in claude, also used by cursor and codebuddy
|
|
39
|
+
cp -r ~/.claude/skills/foo/ ~/.cursor/skills/foo/
|
|
40
|
+
cp -r ~/.claude/skills/foo/ ~/.codebuddy/skills/foo/
|
|
41
|
+
# Example: shared custom agent "my-reviewer" modified in claude
|
|
42
|
+
cp -r ~/.claude/agents/my-reviewer/ ~/.cursor/agents/my-reviewer/
|
|
43
|
+
cp -r ~/.claude/agents/my-reviewer/ ~/.codebuddy/agents/my-reviewer/
|
|
44
|
+
wangchuan sync -y
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Step 2b: New / agent-local** — ask the user before distributing:
|
|
48
|
+
```bash
|
|
49
|
+
# List enabled agents for skills:
|
|
50
|
+
jq -r '.profiles.default | to_entries[] | select(.value.enabled) | "\(.key) → \(.value.workspacePath)/skills/"' ~/.wangchuan/config.json
|
|
51
|
+
# List enabled agents for custom agents (only 4 support them):
|
|
52
|
+
for a in claude cursor codebuddy workbuddy; do
|
|
53
|
+
jq -r --arg a "$a" '.profiles.default[$a] | select(.enabled) | "\($a) → \(.workspacePath)/agents/"' ~/.wangchuan/config.json
|
|
54
|
+
done
|
|
55
|
+
```
|
|
56
|
+
Present options:
|
|
57
|
+
- **All agents** — copy to every applicable agent's dir → `wangchuan sync -y` (registers as shared)
|
|
58
|
+
- **Specific agents** — copy only to selected → `wangchuan sync -y`
|
|
59
|
+
- **No distribution** — keep local only → `wangchuan sync -y`
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Deleting skills or custom agents
|
|
64
|
+
|
|
65
|
+
Deletion is destructive — **always ask the user** regardless of shared status.
|
|
66
|
+
|
|
67
|
+
**Step 1: Determine shared status and inform the user.**
|
|
68
|
+
```bash
|
|
69
|
+
# For skills:
|
|
70
|
+
cat ~/.wangchuan/shared-registry.json 2>/dev/null | grep -q '"name":"xxx".*"kind":"skill"' && echo "SHARED SKILL" || echo "LOCAL SKILL"
|
|
71
|
+
# For custom agents:
|
|
72
|
+
cat ~/.wangchuan/shared-registry.json 2>/dev/null | grep -q '"name":"xxx".*"kind":"agent"' && echo "SHARED AGENT" || echo "LOCAL AGENT"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Step 2: List agents that have it and ask which to remove from.**
|
|
76
|
+
```bash
|
|
77
|
+
# For skills:
|
|
78
|
+
for entry in $(jq -r '.profiles.default | to_entries[] | select(.value.enabled) | "\(.key)=\(.value.workspacePath)"' ~/.wangchuan/config.json); do
|
|
79
|
+
agent="${entry%%=*}"; expanded=$(echo "${entry#*=}" | sed "s|^~|$HOME|")
|
|
80
|
+
[ -d "${expanded}/skills/xxx" ] && echo " ✓ $agent"
|
|
81
|
+
done
|
|
82
|
+
# For custom agents (only 4 agents support them):
|
|
83
|
+
for a in claude cursor codebuddy workbuddy; do
|
|
84
|
+
wspath=$(jq -r ".profiles.default.${a}.workspacePath" ~/.wangchuan/config.json)
|
|
85
|
+
expanded=$(echo "$wspath" | sed "s|^~|$HOME|")
|
|
86
|
+
[ -d "${expanded}/agents/xxx" ] && echo " ✓ $a"
|
|
87
|
+
done
|
|
88
|
+
```
|
|
89
|
+
Options: **All agents** / **[individual agents]** / **Cancel**
|
|
90
|
+
|
|
91
|
+
**Step 3: Execute.**
|
|
92
|
+
|
|
93
|
+
**All agents**: `rm -rf` from every agent → unregister from shared-registry.json → `wangchuan sync -y`.
|
|
94
|
+
```bash
|
|
95
|
+
rm -rf ~/.claude/skills/xxx/ ~/.cursor/skills/xxx/ ~/.codebuddy/skills/xxx/ # etc.
|
|
96
|
+
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
|
|
97
|
+
wangchuan sync -y
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Specific agents**: `rm -rf` from selected → unregister (demote) → `wangchuan sync -y`. Remaining agents keep local copies.
|
|
101
|
+
|
|
102
|
+
**Cancel**: no action.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Creating, modifying, or deleting MCP servers
|
|
107
|
+
|
|
108
|
+
MCP servers are JSON fields (`mcpServers`). They have **no shared registry** — wangchuan auto-merges on sync. But agent should give user control.
|
|
109
|
+
|
|
110
|
+
**Creating or modifying:**
|
|
111
|
+
1. Edit the current agent's MCP config file:
|
|
112
|
+
- Claude: `~/.claude/.claude.json` → `mcpServers`
|
|
113
|
+
- CodeBuddy/WorkBuddy/Cursor: `~/<workspace>/mcp.json` → `mcpServers`
|
|
114
|
+
- OpenClaw: `~/.openclaw/workspace/config/mcporter.json` → `mcpServers`
|
|
115
|
+
2. Ask user: "Sync this MCP server to other agents?"
|
|
116
|
+
- **All**: write same entry to every MCP-enabled agent's config via jq
|
|
117
|
+
- **Specific**: write to selected only
|
|
118
|
+
- **No**: keep local
|
|
119
|
+
3. `wangchuan sync -y`
|
|
120
|
+
|
|
121
|
+
Example — add server to another agent:
|
|
122
|
+
```bash
|
|
123
|
+
SERVER_JSON=$(jq '.mcpServers["my-db"]' ~/.claude/.claude.json)
|
|
124
|
+
jq --argjson srv "$SERVER_JSON" '.mcpServers["my-db"] = $srv' ~/.codebuddy/mcp.json > /tmp/mcp.json && mv /tmp/mcp.json ~/.codebuddy/mcp.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Deleting:**
|
|
128
|
+
1. List which agents have it: `jq -e '.mcpServers["xxx"]' <file>` per agent
|
|
129
|
+
2. Ask user: All / Specific / Cancel
|
|
130
|
+
3. Remove via `jq 'del(.mcpServers["xxx"])'` from selected agents
|
|
131
|
+
4. `wangchuan sync -y`
|
|
132
|
+
|
|
133
|
+
**Note**: wangchuan's MCP auto-merge is **additive only** (never deletes keys). Agent-side `jq del()` is the only way to propagate removal.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Creating, modifying, or deleting memory
|
|
138
|
+
|
|
139
|
+
Memory files are **per-agent** — no automatic cross-agent distribution.
|
|
140
|
+
|
|
141
|
+
**Creating or modifying:**
|
|
142
|
+
1. Write/update memory file (e.g. `~/.claude/CLAUDE.md`)
|
|
143
|
+
2. Ask user: "Sync to other agents?"
|
|
144
|
+
- **All**: `wangchuan memory broadcast <agent>` → `wangchuan sync -y`
|
|
145
|
+
- **Specific**: `wangchuan memory copy <source> <target>` → `wangchuan sync -y`
|
|
146
|
+
- **No**: `wangchuan sync -y`
|
|
147
|
+
|
|
148
|
+
**Deleting:**
|
|
149
|
+
1. `wangchuan memory list` to see who has what
|
|
150
|
+
2. Ask user: All / Specific / Cancel
|
|
151
|
+
3. `rm -f` selected agents' memory files → `wangchuan sync -y`
|
|
152
|
+
|
|
153
|
+
**Note**: Memory filenames differ per agent — Claude uses `CLAUDE.md`, OpenClaw/CodeBuddy/WorkBuddy/Codex use `MEMORY.md`.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Pushing, Pulling, and Conflict Resolution
|
|
2
|
+
|
|
3
|
+
## How sync works
|
|
4
|
+
|
|
5
|
+
`wangchuan sync` is **bidirectional**: pull first, then push. `wangchuan watch` is **pull-only** — it periodically pulls cloud changes but never pushes. Users must run `wangchuan sync` manually to push local changes.
|
|
6
|
+
|
|
7
|
+
Flow of `sync`: **auto-snapshot** → fetch remote → if remote ahead → git pull → three-way merge → then stage + push local changes.
|
|
8
|
+
Flow of `watch`: fetch remote → if remote ahead → git pull → restore to local → record unresolved conflicts.
|
|
9
|
+
|
|
10
|
+
**Note**: sync automatically creates a safety snapshot of the repo before every sync. This means you can always roll back to the pre-sync state via `wangchuan snapshot list` + `wangchuan snapshot restore`.
|
|
11
|
+
|
|
12
|
+
**Environment**: all sync/push/pull operations target the **current environment's branch only** (`cfg.environment`). After sync completes, always report the current environment name to the user (e.g. "Synced to cloud (environment: work)").
|
|
13
|
+
|
|
14
|
+
## Pushing memory to cloud
|
|
15
|
+
|
|
16
|
+
1. **Preview** (optional): `wangchuan status -v`
|
|
17
|
+
2. **Sync**: `wangchuan sync -y`
|
|
18
|
+
3. **Conflict resolution** (auto for `.md` files):
|
|
19
|
+
- Non-overlapping edits → auto-merged ✅
|
|
20
|
+
- Overlapping identical edits → deduplicated ✅
|
|
21
|
+
- Overlapping conflicting edits → conflict markers written:
|
|
22
|
+
```
|
|
23
|
+
<<<<<<< LOCAL
|
|
24
|
+
(your local changes)
|
|
25
|
+
=======
|
|
26
|
+
(cloud changes)
|
|
27
|
+
>>>>>>> REMOTE
|
|
28
|
+
```
|
|
29
|
+
4. **If conflict markers written** → read file, show conflicts to user, ask how to resolve, edit to remove markers, `wangchuan sync -y` again.
|
|
30
|
+
5. **If no conflicts** → done.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Full push flow:
|
|
34
|
+
wangchuan sync -y
|
|
35
|
+
# Check for conflict markers:
|
|
36
|
+
grep -l '<<<<<<< LOCAL' ~/.claude/CLAUDE.md ~/.openclaw/workspace/MEMORY.md ~/.codebuddy/MEMORY.md ~/.workbuddy/MEMORY.md ~/.codex/MEMORY.md 2>/dev/null
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Pulling memory from cloud
|
|
40
|
+
|
|
41
|
+
Same command: `wangchuan sync -y`. Use `wangchuan sync -n` for dry-run preview first.
|
|
42
|
+
|
|
43
|
+
Conflict resolution is identical to pushing. Encrypted files are decrypted transparently during pull.
|
|
44
|
+
|
|
45
|
+
**Pulling from a specific environment**: push/pull always targets the **current** environment's branch. To pull from a different env:
|
|
46
|
+
```bash
|
|
47
|
+
wangchuan env switch <target-env> # switches branch + auto-syncs (pulls target env's data)
|
|
48
|
+
# When done, switch back:
|
|
49
|
+
wangchuan env switch <original-env>
|
|
50
|
+
```
|
|
51
|
+
There is no `--from-env` flag — must switch first.
|
|
52
|
+
|
|
53
|
+
## Syncing resources between agents
|
|
54
|
+
|
|
55
|
+
When user says "sync A's config to B", intent may be ambiguous.
|
|
56
|
+
|
|
57
|
+
**Step 1: Clarify** — ask which resources: Memory / Skills / MCP servers / Custom agents / All.
|
|
58
|
+
|
|
59
|
+
**Step 2: Execute per type:**
|
|
60
|
+
- **Memory**: `wangchuan memory copy <source> <target>` → `wangchuan sync -y`
|
|
61
|
+
- **Skills**: `cp -r "${SRC_WS}/skills/"* "${DST_WS}/skills/"` → `wangchuan sync -y`
|
|
62
|
+
- **MCP**: read mcpServers from source, jq merge into target → `wangchuan sync -y`
|
|
63
|
+
- **Custom agents**: `cp -r "${SRC_WS}/agents/"* "${DST_WS}/agents/"` → `wangchuan sync -y`
|
|
64
|
+
|
|
65
|
+
Get workspace paths:
|
|
66
|
+
```bash
|
|
67
|
+
SRC=$(jq -r '.profiles.default.<source>.workspacePath' ~/.wangchuan/config.json | sed "s|^~|$HOME|")
|
|
68
|
+
DST=$(jq -r '.profiles.default.<target>.workspacePath' ~/.wangchuan/config.json | sed "s|^~|$HOME|")
|
|
69
|
+
```
|