@aiyiran/myclaw 1.0.47 → 1.0.48
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 +193 -85
- package/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,126 +1,234 @@
|
|
|
1
|
-
# MyClaw
|
|
1
|
+
# MyClaw CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
为 OpenClaw 教学环境设计的一站式命令行工具。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @aiyiran/myclaw
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 命令速查
|
|
12
|
+
|
|
13
|
+
| 命令 | 说明 | 平台 |
|
|
14
|
+
|------|------|------|
|
|
15
|
+
| `myclaw prepare` | 🚀 一键初始化(推荐第一次用) | 全平台 |
|
|
16
|
+
| `myclaw open` | 打开浏览器(自动带 Token) | 全平台 |
|
|
17
|
+
| `myclaw patch` | 注入 UI 扩展(语音输入等) | Mac/Linux |
|
|
18
|
+
| `myclaw unpatch` | 移除 UI 扩展 | Mac/Linux |
|
|
19
|
+
| `myclaw install` | 安装 OpenClaw | 全平台 |
|
|
20
|
+
| `myclaw status` | 查看 Gateway / Agent 状态 | 全平台 |
|
|
21
|
+
| `myclaw new <name>` | 创建新 Agent | 全平台 |
|
|
22
|
+
| `myclaw restart` | 重启 Gateway | 全平台 |
|
|
23
|
+
| `myclaw bat` | 生成 Windows 桌面快捷启动器 | Windows |
|
|
24
|
+
| `myclaw wsl2` | WSL2 安装向导 | Windows |
|
|
25
|
+
| `myclaw weixin` | 微信绑定向导 | 全平台 |
|
|
26
|
+
| `myclaw rebind` | 微信重绑向导 | 全平台 |
|
|
27
|
+
| `myclaw help` | 显示帮助 | 全平台 |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 核心流程
|
|
32
|
+
|
|
33
|
+
### `myclaw prepare` — 初始化链条
|
|
34
|
+
|
|
35
|
+
自动检测环境并按需执行安装、配置、注入:
|
|
6
36
|
|
|
7
37
|
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
║ ✅ macOS - 完全支持,包括颜色和 Emoji ║
|
|
14
|
-
║ ✅ Linux - 完全支持,包括颜色和 Emoji ║
|
|
15
|
-
║ ✅ Windows 10/11 - 基本支持,推荐使用 Windows Terminal ║
|
|
16
|
-
║ ⚠️ Windows 7/8 - 支持,但 Emoji 可能显示为方块 ║
|
|
17
|
-
║ ║
|
|
18
|
-
║ Windows 用户建议: ║
|
|
19
|
-
║ • 安装 Windows Terminal (Microsoft Store 免费下载) ║
|
|
20
|
-
║ • 或使用 PowerShell 7+ (https://aka.ms/powershell) ║
|
|
21
|
-
║ ║
|
|
22
|
-
║ 颜色说明: ║
|
|
23
|
-
║ • macOS/Linux: 正常显示 ANSI 颜色 ║
|
|
24
|
-
║ • Windows: 自动禁用颜色输出,避免乱码 ║
|
|
25
|
-
║ ║
|
|
26
|
-
╚══════════════════════════════════════════════════════════════════════╝
|
|
38
|
+
Step 1: 检测环境 (Mac / Windows / Linux / WSL)
|
|
39
|
+
Step 2: 检测 Chrome 浏览器
|
|
40
|
+
Step 3: 检测 OpenClaw → 未装则安装
|
|
41
|
+
Step 4: 执行 Patch(受 AUTO_PATCH 开关控制)
|
|
42
|
+
Step 5: [Windows] 生成桌面快捷启动器
|
|
27
43
|
```
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
**触发方式:**
|
|
46
|
+
- 手动运行 `myclaw prepare`
|
|
47
|
+
- `npm install -g @aiyiran/myclaw` 时通过 `postinstall` 自动触发
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
**postinstall 模式(无交互):**
|
|
50
|
+
- OpenClaw 已装 → 自动 patch
|
|
51
|
+
- OpenClaw 未装 → 跳过,提示手动安装
|
|
52
|
+
- 不会弹出 y/n 询问
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
ln -s /path/to/myclaw/index.js /usr/local/bin/myclaw
|
|
37
|
-
chmod +x /usr/local/bin/myclaw
|
|
54
|
+
---
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
### `myclaw bat` — Windows 桌面启动器
|
|
57
|
+
|
|
58
|
+
生成一个 `.bat` 启动脚本 + 桌面快捷方式,双击即可智能启动。
|
|
59
|
+
|
|
60
|
+
**快捷方式命名规则:**
|
|
61
|
+
```
|
|
62
|
+
版本号_OpenClaw_MM-DD_HH-MM-SS.lnk
|
|
63
|
+
例: 1.0.46_OpenClaw_04-01_00-36-19.lnk
|
|
41
64
|
```
|
|
42
65
|
|
|
43
|
-
|
|
66
|
+
> 通过桌面图标名称可验证 prepare 是否执行过,以及执行的版本和时间。
|
|
67
|
+
|
|
68
|
+
**双击后的完整流程:**
|
|
44
69
|
|
|
45
|
-
### 查看状态
|
|
46
|
-
```bash
|
|
47
|
-
myclaw status
|
|
48
70
|
```
|
|
49
|
-
|
|
71
|
+
Gateway 未运行:
|
|
72
|
+
[1/5] WSL → 检测/安装 WSL2
|
|
73
|
+
[2/5] OpenClaw Linux → 检测/导入 WSL 发行版
|
|
74
|
+
[3/5] Gateway → 未运行 → 更新 myclaw
|
|
75
|
+
[4/5] Patch → 注入 UI 扩展
|
|
76
|
+
[5/5] Browser → myclaw open(带 Token)
|
|
77
|
+
→ 启动 openclaw gateway(保持窗口)
|
|
78
|
+
|
|
79
|
+
Gateway 已运行:
|
|
80
|
+
[1/4] WSL
|
|
81
|
+
[2/4] OpenClaw Linux
|
|
82
|
+
[3/4] Gateway → 已运行
|
|
83
|
+
[4/4] Browser → myclaw open(带 Token)
|
|
84
|
+
→ 进入 WSL 终端(cd /root/.openclaw)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `myclaw patch` — UI 扩展注入
|
|
90
|
+
|
|
91
|
+
向 OpenClaw 的 control-ui 注入自定义功能:
|
|
92
|
+
- `myclaw-inject.js` — 自定义 UI 逻辑
|
|
93
|
+
- `voice-input.js` — 语音输入 SDK
|
|
94
|
+
|
|
95
|
+
**原理:** 修改 `control-ui/index.html`,在 `</body>` 前插入 `<script>` 标签。
|
|
50
96
|
|
|
51
|
-
### 创建新 Agent
|
|
52
97
|
```bash
|
|
53
|
-
myclaw
|
|
98
|
+
myclaw patch # 注入
|
|
99
|
+
myclaw unpatch # 还原
|
|
54
100
|
```
|
|
55
|
-
快速创建一个新的 OpenClaw Agent,自动完成:
|
|
56
|
-
- 创建 workspace 目录
|
|
57
|
-
- 配置 agent 文件
|
|
58
|
-
- 发送出生消息
|
|
59
101
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
102
|
+
> 注意:每次 OpenClaw 更新后需要重新 patch(index.html 会被覆盖)。
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### `myclaw open` — 打开浏览器
|
|
107
|
+
|
|
108
|
+
自动检测 Chrome 路径,拼接 Token 打开:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
http://127.0.0.1:18789?token=aiyiran
|
|
64
112
|
```
|
|
65
113
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
114
|
+
支持的 Chrome 路径:
|
|
115
|
+
- **Mac:** `/Applications/Google Chrome.app`
|
|
116
|
+
- **Windows:** `C:\Program Files\Google\Chrome\Application\chrome.exe`
|
|
117
|
+
- **Linux:** `google-chrome` / `chromium-browser`
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### `myclaw wsl2` — WSL2 安装向导
|
|
122
|
+
|
|
123
|
+
Windows 专用,分两阶段:
|
|
124
|
+
|
|
125
|
+
| 阶段 | 内容 |
|
|
126
|
+
|------|------|
|
|
127
|
+
| Phase 1 | 启用 WSL 功能 + 安装 WSL2(需要重启) |
|
|
128
|
+
| Phase 2 | 下载并导入 OpenClaw rootfs.tar |
|
|
129
|
+
|
|
130
|
+
已安装时会提示:
|
|
131
|
+
```
|
|
132
|
+
是否要重新安装 Linux 环境? (y/N):
|
|
69
133
|
```
|
|
70
|
-
自动检测操作系统并执行对应的安装命令。
|
|
71
134
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 配置文件
|
|
138
|
+
|
|
139
|
+
### `config.js`
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
module.exports = {
|
|
143
|
+
TOKEN: 'aiyiran', // Gateway 认证 Token
|
|
144
|
+
DEFAULT_URL: 'http://127.0.0.1:18789', // 默认地址
|
|
145
|
+
AUTO_PATCH: true, // prepare 时是否自动 patch
|
|
146
|
+
};
|
|
75
147
|
```
|
|
76
148
|
|
|
149
|
+
| 配置项 | 说明 |
|
|
150
|
+
|--------|------|
|
|
151
|
+
| `TOKEN` | 所有 open 命令和 bat 启动器使用的认证令牌 |
|
|
152
|
+
| `DEFAULT_URL` | Gateway 地址 |
|
|
153
|
+
| `AUTO_PATCH` | `true` = prepare/postinstall 自动 patch;`false` = 跳过 |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
77
157
|
## 文件结构
|
|
78
158
|
|
|
79
159
|
```
|
|
80
160
|
myclaw/
|
|
81
|
-
├── index.js
|
|
82
|
-
├──
|
|
83
|
-
|
|
161
|
+
├── index.js # CLI 主入口 + 命令路由 + bat 模板
|
|
162
|
+
├── config.js # 全局配置(Token、URL、开关)
|
|
163
|
+
├── prepare.js # 初始化链条
|
|
164
|
+
├── patch.js # UI 扩展注入逻辑
|
|
165
|
+
├── wsl2.js # WSL2 安装向导
|
|
166
|
+
├── create_agent.js # Agent 创建
|
|
167
|
+
├── package.json # npm 包配置(含 postinstall)
|
|
168
|
+
├── publish.sh # 一键发布脚本
|
|
169
|
+
├── assets/
|
|
170
|
+
│ ├── myclaw-inject.js # 注入到 control-ui 的 JS
|
|
171
|
+
│ └── detect-browser.sh # Chrome 检测脚本
|
|
172
|
+
├── voice-input/
|
|
173
|
+
│ ├── index.html # 语音输入独立页
|
|
174
|
+
│ └── voice-input.js # 语音 SDK
|
|
175
|
+
└── wizards/ # 交互式向导系统
|
|
176
|
+
├── index.js # 向导入口
|
|
177
|
+
├── runner/ # 向导运行引擎
|
|
178
|
+
├── configs/ # 向导配置文件
|
|
179
|
+
├── scripts/ # Python 后端脚本
|
|
180
|
+
└── commons/ # 共享步骤定义
|
|
84
181
|
```
|
|
85
182
|
|
|
86
|
-
|
|
183
|
+
---
|
|
87
184
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
| `create_agent.js` | Agent 创建的完整逻辑,可独立使用 |
|
|
185
|
+
## 调试
|
|
186
|
+
|
|
187
|
+
### 查看 prepare 执行日志
|
|
92
188
|
|
|
93
|
-
|
|
189
|
+
prepare 运行时会写入日志文件:
|
|
190
|
+
- **Mac/Linux:** `/tmp/myclaw-prepare.log`
|
|
191
|
+
- **Windows WSL:** `/tmp/myclaw-prepare.log`
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
cat /tmp/myclaw-prepare.log
|
|
195
|
+
```
|
|
94
196
|
|
|
95
|
-
|
|
197
|
+
示例输出:
|
|
198
|
+
```
|
|
199
|
+
[2026-04-01T00:30:00.000Z] === prepare start (postinstall=true, version=1.0.46)
|
|
200
|
+
[2026-04-01T00:30:00.100Z] Step 1: env=linux
|
|
201
|
+
[2026-04-01T00:30:00.200Z] Step 2: chrome=true
|
|
202
|
+
[2026-04-01T00:30:00.300Z] Step 3: openclaw=installed
|
|
203
|
+
[2026-04-01T00:30:00.400Z] Step 4: AUTO_PATCH=true, env=linux
|
|
204
|
+
[2026-04-01T00:30:01.000Z] Step 4: patch executed
|
|
205
|
+
[2026-04-01T00:30:01.100Z] === prepare end (success)
|
|
206
|
+
```
|
|
96
207
|
|
|
97
|
-
|
|
98
|
-
- 使用 `os.platform()` 检测系统
|
|
99
|
-
- Windows 下禁用 ANSI 颜色输出
|
|
100
|
-
- 避免使用只在 Unix 系统有效的命令
|
|
208
|
+
### npm 缓存问题
|
|
101
209
|
|
|
102
|
-
|
|
103
|
-
- 所有 `execSync` 调用必须使用 `try-catch`
|
|
104
|
-
- 失败时提供清晰的错误信息和解决方案
|
|
210
|
+
如果 `npm install -g @aiyiran/myclaw` 拿到旧版本:
|
|
105
211
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
212
|
+
```bash
|
|
213
|
+
# 方案 1: 强制最新
|
|
214
|
+
npm install -g @aiyiran/myclaw@latest --prefer-online
|
|
109
215
|
|
|
110
|
-
|
|
216
|
+
# 方案 2: 清缓存
|
|
217
|
+
npm cache clean --force
|
|
218
|
+
npm install -g @aiyiran/myclaw
|
|
111
219
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- [ ] Windows 10/11 (CMD)
|
|
117
|
-
- [ ] Windows Terminal (如果可用)
|
|
220
|
+
# 方案 3: 先 view 刷新元数据
|
|
221
|
+
npm view @aiyiran/myclaw version
|
|
222
|
+
npm install -g @aiyiran/myclaw
|
|
223
|
+
```
|
|
118
224
|
|
|
119
|
-
|
|
225
|
+
---
|
|
120
226
|
|
|
121
|
-
|
|
122
|
-
- OpenClaw CLI (用于实际命令执行)
|
|
227
|
+
## 发布
|
|
123
228
|
|
|
124
|
-
|
|
229
|
+
```bash
|
|
230
|
+
cd myclaw
|
|
231
|
+
sh publish.sh
|
|
232
|
+
```
|
|
125
233
|
|
|
126
|
-
|
|
234
|
+
自动完成:git commit → 版本号 +1 → git push + tag → npm publish
|
package/index.js
CHANGED
|
@@ -404,7 +404,7 @@ pause
|
|
|
404
404
|
// 写入 bat 文件(Windows CMD 需要 CRLF 换行符)
|
|
405
405
|
fs.writeFileSync(batPath, batContent.replace(/\n/g, '\r\n'), 'utf8');
|
|
406
406
|
|
|
407
|
-
// 用 PowerShell 创建带图标的桌面快捷方式
|
|
407
|
+
// 用 PowerShell 创建带图标的桌面快捷方式 + 刷新桌面
|
|
408
408
|
const psScript = `
|
|
409
409
|
$ws = New-Object -ComObject WScript.Shell
|
|
410
410
|
$sc = $ws.CreateShortcut('${lnkPath.replace(/\\/g, '\\\\')}')
|
|
@@ -412,8 +412,10 @@ $sc.TargetPath = '${batPath.replace(/\\/g, '\\\\')}'
|
|
|
412
412
|
$sc.WorkingDirectory = '${myClawDir.replace(/\\/g, '\\\\')}'
|
|
413
413
|
$sc.WindowStyle = 1
|
|
414
414
|
$sc.IconLocation = '%SystemRoot%\\System32\\shell32.dll,176'
|
|
415
|
-
$sc.Description = 'OpenClaw
|
|
415
|
+
$sc.Description = 'OpenClaw'
|
|
416
416
|
$sc.Save()
|
|
417
|
+
Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class Shell { [DllImport("shell32.dll")] public static extern void SHChangeNotify(int e, int f, IntPtr i1, IntPtr i2); }' -ErrorAction SilentlyContinue
|
|
418
|
+
[Shell]::SHChangeNotify(0x08000000, 0, [IntPtr]::Zero, [IntPtr]::Zero)
|
|
417
419
|
`;
|
|
418
420
|
|
|
419
421
|
try {
|