@aiyiran/myclaw 1.0.37 → 1.0.39

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.
Files changed (3) hide show
  1. package/index.js +66 -67
  2. package/package.json +2 -2
  3. package/prepare.js +12 -0
package/index.js CHANGED
@@ -292,90 +292,89 @@ function runBat() {
292
292
  const desktopPath = path.join(os.homedir(), 'Desktop');
293
293
  const lnkPath = path.join(desktopPath, 'OpenClaw.lnk');
294
294
 
295
- // === 智能启动器 bat 内容 ===
295
+ // === 智能启动器 bat 内容(用 goto 标签避免中文在 if 块内的编码问题) ===
296
296
  const batContent = `@echo off
297
297
  chcp 65001 >nul 2>&1
298
- title OpenClaw 智能启动器
299
- color 0A
298
+ title OpenClaw
300
299
  echo.
301
300
  echo ============================================
302
- echo OpenClaw 智能启动器
301
+ echo OpenClaw
303
302
  echo ============================================
304
303
  echo.
305
304
 
306
- REM ---- Step 1: 自动更新 MyClaw ----
307
- echo [1/5] 检查 MyClaw 更新...
308
- call npm update -g @aiyiran/myclaw >nul 2>&1
305
+ REM ---- Step 1: WSL ----
306
+ echo [1/4] WSL...
307
+ wsl --version >nul 2>&1
308
+ if not errorlevel 1 goto :wsl_ok
309
+ echo [!] WSL not installed
310
+ call myclaw wsl2
311
+ echo.
312
+ echo Please restart your computer, then double-click this icon again.
313
+ echo.
314
+ pause
315
+ exit /b
316
+
317
+ :wsl_ok
309
318
  echo [OK]
310
319
 
311
- REM ---- Step 2: 检测 WSL 是否可用 ----
312
- echo [2/5] 检测 WSL 状态...
313
- wsl --version >nul 2>&1
314
- if errorlevel 1 (
315
- echo.
316
- echo [!] WSL 未安装或功能未启用
317
- echo [!] 正在调用 myclaw wsl2 进行安装...
318
- echo.
319
- call myclaw wsl2
320
- echo.
321
- echo ============================================
322
- echo WSL 安装完成后,请 [重启电脑]
323
- echo 重启后再次双击此图标即可继续
324
- echo ============================================
325
- echo.
326
- pause
327
- exit /b
328
- )
329
- echo [OK] WSL 已安装
330
-
331
- REM ---- Step 3: 检测 OpenClaw 发行版 ----
332
- echo [3/5] 检测 OpenClaw Linux 环境...
333
- wsl -l -q 2>nul | findstr /i "OpenClaw" >nul 2>&1
334
- if errorlevel 1 (
335
- echo.
336
- echo [!] OpenClaw Linux 环境未导入
337
- echo [!] 正在调用 myclaw wsl2 进行导入...
338
- echo.
339
- call myclaw wsl2
340
- echo.
341
- echo 导入完成后,请再次双击此图标启动
342
- echo.
343
- pause
344
- exit /b
345
- )
346
- echo [OK] OpenClaw Linux 环境已就绪
347
-
348
- REM ---- Step 4: 用 myclaw open 打开浏览器(带 token) ----
349
- echo [4/5] 打开浏览器(带 Token)...
350
- call myclaw open
320
+ REM ---- Step 2: OpenClaw distro ----
321
+ echo [2/4] OpenClaw Linux...
322
+ wsl -d OpenClaw -- echo ok >nul 2>&1
323
+ if not errorlevel 1 goto :distro_ok
324
+ echo [!] OpenClaw Linux not found
325
+ call myclaw wsl2
326
+ echo.
327
+ echo Done. Double-click this icon again to start.
328
+ echo.
329
+ pause
330
+ exit /b
331
+
332
+ :distro_ok
351
333
  echo [OK]
352
334
 
353
- REM ---- Step 5: 检测并启动 Gateway ----
354
- echo [5/5] 检测 OpenClaw Gateway...
355
- netstat -an | findstr "18789" | findstr "LISTENING" >nul 2>&1
356
- if not errorlevel 1 (
357
- echo [OK] Gateway 已在运行中
358
- echo.
359
- echo ============================================
360
- echo OpenClaw 已在运行!浏览器已打开
361
- echo 输入 exit 可关闭此窗口
362
- echo ============================================
363
- echo.
364
- wsl -d OpenClaw
365
- pause
366
- exit /b
367
- )
368
-
369
- echo Gateway 未运行,正在启动...
335
+ REM ---- Step 3: Gateway ----
336
+ echo [3/4] Gateway...
337
+ netstat -an 2>nul | findstr "18789" | findstr "LISTENING" >nul 2>&1
338
+ if not errorlevel 1 goto :gateway_running
339
+
340
+ REM Gateway not running -> update myclaw first, then start
341
+ echo Starting...
342
+ echo.
343
+ echo [update] npm update -g @aiyiran/myclaw
344
+ call npm update -g @aiyiran/myclaw >nul 2>&1
345
+ echo [update] OK
346
+ echo.
347
+
348
+ REM ---- Step 4: Open browser ----
349
+ echo [4/4] Browser...
350
+ call myclaw open
351
+ echo [OK]
370
352
  echo.
371
353
  echo ============================================
372
- echo 正在启动 OpenClaw 服务...
373
- echo 关闭此窗口将停止服务
354
+ echo Gateway starting...
355
+ echo Close this window = stop service
374
356
  echo ============================================
375
357
  echo.
376
358
  wsl -d OpenClaw -- openclaw gateway
377
359
  echo.
378
- echo [!] Gateway 已退出
360
+ echo Gateway exited.
361
+ pause
362
+ exit /b
363
+
364
+ :gateway_running
365
+ echo [OK] Running
366
+
367
+ REM ---- Step 4: Open browser ----
368
+ echo [4/4] Browser...
369
+ call myclaw open
370
+ echo [OK]
371
+ echo.
372
+ echo ============================================
373
+ echo OpenClaw is running. Browser opened.
374
+ echo Type exit to close this window.
375
+ echo ============================================
376
+ echo.
377
+ wsl -d OpenClaw
379
378
  pause
380
379
  `;
381
380
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
- "postinstall": "node -e \"try{require('./patch').patch()}catch(e){console.log('[myclaw] patch skipped:',e.message)}\""
12
+ "postinstall": "node index.js prepare"
13
13
  },
14
14
  "keywords": [],
15
15
  "author": "",
package/prepare.js CHANGED
@@ -36,6 +36,9 @@ const C = isWindows
36
36
 
37
37
  const BAR = '========================================';
38
38
 
39
+ // 检测是否在 npm postinstall 中运行(非交互模式)
40
+ const isPostInstall = process.env.npm_lifecycle_event === 'postinstall';
41
+
39
42
  // ============================================================================
40
43
  // 工具:交互式问答
41
44
  // ============================================================================
@@ -220,6 +223,15 @@ async function installOpenClaw(env, openclawStatus) {
220
223
  }
221
224
 
222
225
  // Mac / Linux
226
+ if (isPostInstall) {
227
+ // postinstall 模式下不交互,跳过安装
228
+ console.log('');
229
+ console.log(' OpenClaw 未安装,请手动运行:');
230
+ console.log(' ' + C.y + 'myclaw install' + C.nc);
231
+ console.log('');
232
+ return false;
233
+ }
234
+
223
235
  console.log('');
224
236
  const answer = await ask(
225
237
  ' 是否现在安装 OpenClaw? (y/n): '