diff --git a/portable/Mac-Diagnose.command b/portable/Mac-Diagnose.command new file mode 100644 index 0000000..cbddca5 --- /dev/null +++ b/portable/Mac-Diagnose.command @@ -0,0 +1,136 @@ +#!/bin/bash +# ============================================================ +# U-Claw Diagnostic Tool - macOS +# 诊断工具 +# ============================================================ + +UCLAW_DIR="$(cd "$(dirname "$0")" && pwd)" +LOG_FILE="$UCLAW_DIR/diagnostic-log.txt" + +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +NC='\033[0m' + +clear +echo "" +echo " ========================================" +echo " U-Claw Diagnostic Tool" +echo " 诊断工具" +echo " ========================================" +echo "" +echo " Checking system... 正在检查系统..." +echo "" + +# Clear old log +cat > "$LOG_FILE" << EOF +U-Claw Diagnostic Report +Generated: $(date) +======================================== + +EOF + +# 1. Check Node.js +echo "[1/6] Checking Node.js runtime..." +ARCH=$(uname -m) +if [ "$ARCH" = "arm64" ]; then + NODE_BIN="$UCLAW_DIR/app/runtime/node-mac-arm64/bin/node" +else + NODE_BIN="$UCLAW_DIR/app/runtime/node-mac-x64/bin/node" +fi + +if [ -f "$NODE_BIN" ]; then + echo " [OK] Node.js found" >> "$LOG_FILE" + echo " Version: $($NODE_BIN --version)" >> "$LOG_FILE" + echo -e " ${GREEN}✓${NC} Node.js: Found" +else + echo " [ERROR] Node.js not found" >> "$LOG_FILE" + echo " Path: $NODE_BIN" >> "$LOG_FILE" + echo -e " ${RED}✗${NC} Node.js: NOT FOUND" +fi + +# 2. Check core-mac directory +echo "[2/6] Checking core-mac directory..." +CORE_DIR="$UCLAW_DIR/app/core-mac" +if [ -d "$CORE_DIR" ]; then + echo " [OK] core-mac directory exists" >> "$LOG_FILE" + echo -e " ${GREEN}✓${NC} core-mac: Found" +else + echo " [ERROR] core-mac directory not found" >> "$LOG_FILE" + echo -e " ${RED}✗${NC} core-mac: NOT FOUND" +fi + +# 3. Check node_modules +echo "[3/6] Checking dependencies..." +if [ -d "$CORE_DIR/node_modules" ]; then + echo " [OK] node_modules exists" >> "$LOG_FILE" + echo -e " ${GREEN}✓${NC} Dependencies: Found" +else + echo " [ERROR] node_modules not found" >> "$LOG_FILE" + echo -e " ${RED}✗${NC} Dependencies: NOT FOUND" +fi + +# 4. Check OpenClaw +echo "[4/6] Checking OpenClaw..." +OPENCLAW_MJS="$CORE_DIR/node_modules/openclaw/openclaw.mjs" +if [ -f "$OPENCLAW_MJS" ]; then + echo " [OK] openclaw.mjs found" >> "$LOG_FILE" + echo -e " ${GREEN}✓${NC} OpenClaw: Found" +else + echo " [ERROR] openclaw.mjs not found" >> "$LOG_FILE" + echo " Path: $OPENCLAW_MJS" >> "$LOG_FILE" + echo -e " ${RED}✗${NC} OpenClaw: NOT FOUND" +fi + +# 5. Check port availability +echo "[5/6] Checking port 18789..." +if lsof -i:18789 >/dev/null 2>&1; then + echo " [WARNING] Port 18789 is in use" >> "$LOG_FILE" + lsof -i:18789 >> "$LOG_FILE" 2>&1 + echo -e " ${YELLOW}⚠${NC} Port 18789: IN USE" +else + echo " [OK] Port 18789 is available" >> "$LOG_FILE" + echo -e " ${GREEN}✓${NC} Port 18789: Available" +fi + +# 6. Test OpenClaw startup +echo "[6/6] Testing OpenClaw startup..." +echo "" >> "$LOG_FILE" +echo "Testing OpenClaw startup:" >> "$LOG_FILE" +echo "----------------------------------------" >> "$LOG_FILE" + +export OPENCLAW_HOME="$UCLAW_DIR/data" +export OPENCLAW_STATE_DIR="$UCLAW_DIR/data/.openclaw" +export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json" + +if [ -f "$NODE_BIN" ] && [ -f "$OPENCLAW_MJS" ]; then + cd "$CORE_DIR" + "$NODE_BIN" "$OPENCLAW_MJS" --version >> "$LOG_FILE" 2>&1 + if [ $? -eq 0 ]; then + echo -e " ${GREEN}✓${NC} OpenClaw: Can run" + else + echo -e " ${RED}✗${NC} OpenClaw: Failed to run" + echo " [ERROR] OpenClaw failed to start" >> "$LOG_FILE" + fi +else + echo -e " ${RED}✗${NC} Cannot test - files missing" + echo " [SKIP] Cannot test - required files missing" >> "$LOG_FILE" +fi + +echo "" +echo "" >> "$LOG_FILE" +echo "========================================" >> "$LOG_FILE" +echo "Diagnostic complete." >> "$LOG_FILE" + +echo " ========================================" +echo " Diagnostic Complete" +echo " ========================================" +echo "" +echo " Log saved to: diagnostic-log.txt" +echo "" +echo " Next steps:" +echo " 1. Check diagnostic-log.txt for details" +echo " 2. If errors found, try running Mac-Start.command" +echo " to auto-install missing dependencies" +echo "" +read -p " Press Enter to exit..." diff --git a/portable/Mac-Menu.command b/portable/Mac-Menu.command index 9efedee..474c77a 100755 --- a/portable/Mac-Menu.command +++ b/portable/Mac-Menu.command @@ -4,7 +4,7 @@ UCLAW_DIR="$(cd "$(dirname "$0")" && pwd)" APP_DIR="$UCLAW_DIR/app" -CORE_DIR="$APP_DIR/core" +CORE_DIR="$APP_DIR/core-mac" DATA_DIR="$UCLAW_DIR/data" STATE_DIR="$DATA_DIR/.openclaw" CONFIG_PATH="$STATE_DIR/openclaw.json" diff --git a/portable/Mac-Start.command b/portable/Mac-Start.command index bafb451..67ae4d3 100755 --- a/portable/Mac-Start.command +++ b/portable/Mac-Start.command @@ -6,7 +6,7 @@ UCLAW_DIR="$(cd "$(dirname "$0")" && pwd)" APP_DIR="$UCLAW_DIR/app" -CORE_DIR="$APP_DIR/core" +CORE_DIR="$APP_DIR/core-mac" DATA_DIR="$UCLAW_DIR/data" SYSTEM_DIR="$UCLAW_DIR/system" diff --git a/portable/Welcome.html b/portable/Welcome.html new file mode 100644 index 0000000..98e3d6a --- /dev/null +++ b/portable/Welcome.html @@ -0,0 +1,254 @@ + + + + + +U-Claw 使用指南 + + + +
+

🦞 U-Claw 使用指南

+
AI助手便携U盘 · 3步开始使用
+ +
+
快速开始
+
+
+
第1步:启动服务
+
+ 根据您的系统,双击对应的启动文件:

+ Windows 用户:双击 Windows-Start.bat
+ Mac 用户:双击 Mac-Start.command +
+
+ +
+
第2步:配置AI模型
+
+ 首次启动会自动打开配置页面,按照提示操作:
+ 1. 选择一个AI模型(推荐 DeepSeek - 便宜好用)
+ 2. 填写API Key(去模型官网注册获取)
+ 3. 点击"保存配置" +
+
+ +
+
第3步:开始对话
+
+ 配置完成后,浏览器会自动打开AI对话界面
+ 地址:http://127.0.0.1:18789
+ 现在可以和AI助手对话了! +
+
+
+ +
+

✅ 所有配置和对话记录保存在U盘的 data/ 目录,Mac和Windows自动共享!

+
+
+ +
+
推荐AI模型
+
+
+ 🔥 DeepSeek + 编程首选,极便宜 +
+
+ 📄 Kimi + 长文档处理专家 +
+
+ 🆓 通义千问 + 免费额度大 +
+
+ 🌟 Claude + 最强理解能力 +
+
+
+ +
+
遇到问题?
+
+ 💡 运行诊断工具 +

+ 如果启动失败,双击运行诊断工具:
+ Windows: Windows-Diagnose.bat
+ Mac: Mac-Diagnose.command +

+
+
+ +
+ 打开配置页面 + 查看文档 +
+ + +
+ + diff --git a/portable/Windows-Diagnose.bat b/portable/Windows-Diagnose.bat new file mode 100644 index 0000000..9fe4633 --- /dev/null +++ b/portable/Windows-Diagnose.bat @@ -0,0 +1,121 @@ +@echo off +chcp 65001 >nul 2>&1 +title U-Claw - Diagnostic Tool + +set "UCLAW_DIR=%~dp0" +set "LOG_FILE=%UCLAW_DIR%diagnostic-log.txt" + +echo. +echo ======================================== +echo U-Claw Diagnostic Tool +echo 诊断工具 +echo ======================================== +echo. +echo Checking system... 正在检查系统... +echo. + +REM Clear old log +echo U-Claw Diagnostic Report > "%LOG_FILE%" +echo Generated: %date% %time% >> "%LOG_FILE%" +echo ======================================== >> "%LOG_FILE%" +echo. >> "%LOG_FILE%" + +REM 1. Check Node.js +echo [1/6] Checking Node.js runtime... +set "NODE_BIN=%UCLAW_DIR%app\runtime\node-win-x64\node.exe" +if exist "%NODE_BIN%" ( + echo [OK] Node.js found >> "%LOG_FILE%" + for /f "tokens=*" %%v in ('"%NODE_BIN%" --version 2^>^&1') do echo Version: %%v >> "%LOG_FILE%" + echo ✓ Node.js: Found +) else ( + echo [ERROR] Node.js not found >> "%LOG_FILE%" + echo [X] Node.js: NOT FOUND + echo Path: %NODE_BIN% >> "%LOG_FILE%" +) + +REM 2. Check core-win directory +echo [2/6] Checking core-win directory... +set "CORE_DIR=%UCLAW_DIR%app\core-win" +if exist "%CORE_DIR%" ( + echo [OK] core-win directory exists >> "%LOG_FILE%" + echo ✓ core-win: Found +) else ( + echo [ERROR] core-win directory not found >> "%LOG_FILE%" + echo [X] core-win: NOT FOUND +) + +REM 3. Check node_modules +echo [3/6] Checking dependencies... +if exist "%CORE_DIR%\node_modules" ( + echo [OK] node_modules exists >> "%LOG_FILE%" + echo ✓ Dependencies: Found +) else ( + echo [ERROR] node_modules not found >> "%LOG_FILE%" + echo [X] Dependencies: NOT FOUND +) + +REM 4. Check OpenClaw +echo [4/6] Checking OpenClaw... +set "OPENCLAW_MJS=%CORE_DIR%\node_modules\openclaw\openclaw.mjs" +if exist "%OPENCLAW_MJS%" ( + echo [OK] openclaw.mjs found >> "%LOG_FILE%" + echo ✓ OpenClaw: Found +) else ( + echo [ERROR] openclaw.mjs not found >> "%LOG_FILE%" + echo [X] OpenClaw: NOT FOUND + echo Path: %OPENCLAW_MJS% >> "%LOG_FILE%" +) + +REM 5. Check port availability +echo [5/6] Checking port 18789... +netstat -an | findstr ":18789 " | findstr "LISTENING" >nul 2>&1 +if %errorlevel%==0 ( + echo [WARNING] Port 18789 is in use >> "%LOG_FILE%" + echo ⚠ Port 18789: IN USE + netstat -ano | findstr ":18789 " >> "%LOG_FILE%" +) else ( + echo [OK] Port 18789 is available >> "%LOG_FILE%" + echo ✓ Port 18789: Available +) + +REM 6. Test OpenClaw startup +echo [6/6] Testing OpenClaw startup... +echo. >> "%LOG_FILE%" +echo Testing OpenClaw startup: >> "%LOG_FILE%" +echo ---------------------------------------- >> "%LOG_FILE%" + +set "OPENCLAW_HOME=%UCLAW_DIR%data" +set "OPENCLAW_STATE_DIR=%UCLAW_DIR%data\.openclaw" +set "OPENCLAW_CONFIG_PATH=%OPENCLAW_STATE_DIR%\openclaw.json" + +if exist "%NODE_BIN%" if exist "%OPENCLAW_MJS%" ( + cd /d "%CORE_DIR%" + "%NODE_BIN%" "%OPENCLAW_MJS%" --version >> "%LOG_FILE%" 2>&1 + if %errorlevel%==0 ( + echo ✓ OpenClaw: Can run + ) else ( + echo [X] OpenClaw: Failed to run + echo [ERROR] OpenClaw failed to start >> "%LOG_FILE%" + ) +) else ( + echo [X] Cannot test - files missing + echo [SKIP] Cannot test - required files missing >> "%LOG_FILE%" +) + +echo. +echo. >> "%LOG_FILE%" +echo ======================================== >> "%LOG_FILE%" +echo Diagnostic complete. >> "%LOG_FILE%" + +echo ======================================== +echo Diagnostic Complete +echo ======================================== +echo. +echo Log saved to: diagnostic-log.txt +echo. +echo Next steps: +echo 1. Check diagnostic-log.txt for details +echo 2. If errors found, try running Windows-Start.bat +echo to auto-install missing dependencies +echo. +pause diff --git a/portable/Windows-Menu.bat b/portable/Windows-Menu.bat index f3efed0..cc2bbcb 100644 --- a/portable/Windows-Menu.bat +++ b/portable/Windows-Menu.bat @@ -3,7 +3,7 @@ chcp 65001 >nul 2>&1 title U-Claw Menu set "UCLAW_DIR=%~dp0" -set "CORE_DIR=%UCLAW_DIR%app\core" +set "CORE_DIR=%UCLAW_DIR%app\core-win" set "DATA_DIR=%UCLAW_DIR%data" set "STATE_DIR=%DATA_DIR%\.openclaw" set "NODE_DIR=%UCLAW_DIR%app\runtime\node-win-x64" diff --git a/portable/Windows-Start.bat b/portable/Windows-Start.bat index a82dacf..d6d190c 100644 --- a/portable/Windows-Start.bat +++ b/portable/Windows-Start.bat @@ -10,7 +10,7 @@ echo. set "UCLAW_DIR=%~dp0" set "APP_DIR=%UCLAW_DIR%app" -set "CORE_DIR=%APP_DIR%\core" +set "CORE_DIR=%APP_DIR%\core-win" set "DATA_DIR=%UCLAW_DIR%data" set "STATE_DIR=%DATA_DIR%\.openclaw" set "NODE_DIR=%APP_DIR%\runtime\node-win-x64" diff --git a/portable/setup.sh b/portable/setup.sh index dfb367a..fef4d6b 100755 --- a/portable/setup.sh +++ b/portable/setup.sh @@ -9,7 +9,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" APP_DIR="$SCRIPT_DIR/app" -CORE_DIR="$APP_DIR/core" +CORE_DIR="$APP_DIR/core-mac" RUNTIME_DIR="$APP_DIR/runtime" MIRROR="https://registry.npmmirror.com" NODE_MIRROR="https://npmmirror.com/mirrors/node" @@ -49,11 +49,11 @@ fi echo -e " 系统: ${GREEN}$OS $ARCH${NC}" echo "" -# ---- 1. Download Node.js ---- +# ---- 1. Download Node.js (Current Platform) ---- NODE_TARGET="$RUNTIME_DIR/$NODE_DIR_NAME" if [ -f "$NODE_TARGET/bin/node" ]; then - echo -e " ${GREEN}✓${NC} Node.js 已存在,跳过下载" + echo -e " ${GREEN}✓${NC} Node.js ($PLATFORM) 已存在,跳过下载" else echo -e " ${CYAN}↓${NC} 下载 Node.js $NODE_VERSION ($PLATFORM)..." mkdir -p "$NODE_TARGET" @@ -64,13 +64,45 @@ else curl -fSL "$NODE_URL" | tar xz -C "$NODE_TARGET" --strip-components=1 if [ -f "$NODE_TARGET/bin/node" ]; then - echo -e " ${GREEN}✓${NC} Node.js 下载完成" + echo -e " ${GREEN}✓${NC} Node.js ($PLATFORM) 下载完成" else echo -e " ${RED}✗ Node.js 下载失败${NC}" exit 1 fi fi +# ---- 1b. Download Node.js for Windows (Cross-platform support) ---- +WIN_NODE_TARGET="$RUNTIME_DIR/node-win-x64" +if [ -f "$WIN_NODE_TARGET/node.exe" ]; then + echo -e " ${GREEN}✓${NC} Node.js (win-x64) 已存在,跳过下载" +else + echo -e " ${CYAN}↓${NC} 下载 Node.js $NODE_VERSION (win-x64) - Windows支持..." + mkdir -p "$WIN_NODE_TARGET" + + WIN_NODE_URL="$NODE_MIRROR/$NODE_VERSION/node-$NODE_VERSION-win-x64.zip" + echo " $WIN_NODE_URL" + + # Download zip file to temp, extract, then move + TMP_ZIP="/tmp/node-win-x64-$$.zip" + curl -fSL "$WIN_NODE_URL" -o "$TMP_ZIP" + + # Use unzip if available, otherwise try native tools + if command -v unzip >/dev/null 2>&1; then + unzip -q "$TMP_ZIP" -d "/tmp/node-win-extract-$$" + cp -r "/tmp/node-win-extract-$$"/node-$NODE_VERSION-win-x64/* "$WIN_NODE_TARGET/" + rm -rf "/tmp/node-win-extract-$$" + else + echo -e " ${RED}✗ unzip not found, skipping Windows runtime${NC}" + fi + rm -f "$TMP_ZIP" + + if [ -f "$WIN_NODE_TARGET/node.exe" ]; then + echo -e " ${GREEN}✓${NC} Node.js (win-x64) 下载完成" + else + echo -e " ${CYAN}⚠${NC} Windows runtime下载失败 (不影响当前平台使用)" + fi +fi + # ---- 2. Install OpenClaw ---- if [ -d "$CORE_DIR/node_modules/openclaw" ]; then echo -e " ${GREEN}✓${NC} OpenClaw 已安装,跳过"