forked from zeroclaw-labs/zeroclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bat
More file actions
335 lines (289 loc) Ā· 9.94 KB
/
setup.bat
File metadata and controls
335 lines (289 loc) Ā· 9.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
@echo off
setlocal enabledelayedexpansion
:: ============================================================================
:: ZeroClaw Windows Setup Script
:: Simplifies building and installing ZeroClaw on Windows.
:: Usage: setup.bat [--prebuilt | --minimal | --standard | --full | --help]
:: ============================================================================
set "VERSION=0.6.2"
set "RUST_MIN_VERSION=1.87"
set "TARGET=x86_64-pc-windows-msvc"
set "REPO=https://github.com/zeroclaw-labs/zeroclaw"
:: Colors via ANSI (Windows 10+ Terminal)
set "GREEN=[32m"
set "YELLOW=[33m"
set "RED=[31m"
set "BLUE=[34m"
set "BOLD=[1m"
set "RESET=[0m"
:: Parse arguments
set "MODE=interactive"
if "%~1"=="--help" goto :show_help
if "%~1"=="-h" goto :show_help
if "%~1"=="--prebuilt" set "MODE=prebuilt" & goto :start
if "%~1"=="--minimal" set "MODE=minimal" & goto :start
if "%~1"=="--standard" set "MODE=standard" & goto :start
if "%~1"=="--full" set "MODE=full" & goto :start
:start
echo.
echo %BOLD%%BLUE%=========================================%RESET%
echo %BOLD%%BLUE% ZeroClaw Windows Setup v%VERSION%%RESET%
echo %BOLD%%BLUE%=========================================%RESET%
echo.
:: ---- Step 1: Check prerequisites ----
echo %BOLD%[1/5] Checking prerequisites...%RESET%
:: Check available RAM (rough estimate via wmic)
for /f "tokens=2 delims==" %%a in ('wmic os get FreePhysicalMemory /value 2^>nul ^| find "="') do (
set /a "FREE_RAM_MB=%%a / 1024"
)
if defined FREE_RAM_MB (
if !FREE_RAM_MB! LSS 2048 (
echo %YELLOW%WARNING: Only !FREE_RAM_MB! MB free RAM detected. 2048 MB recommended for source builds.%RESET%
echo %YELLOW%Consider using --prebuilt instead.%RESET%
) else (
echo %GREEN%OK%RESET% Free RAM: !FREE_RAM_MB! MB
)
)
:: Check disk space
for /f "tokens=3" %%a in ('dir /-C "%~dp0" 2^>nul ^| findstr /C:"bytes free"') do (
set /a "FREE_DISK_GB=%%a / 1073741824"
)
:: Check Rust
where cargo >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo %YELLOW%Rust not found.%RESET%
goto :install_rust
) else (
for /f "tokens=2" %%v in ('rustc --version 2^>nul') do set "RUST_VER=%%v"
echo %GREEN%OK%RESET% Rust !RUST_VER! found
)
:: Check Node.js (optional)
where node >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo %YELLOW%Node.js not found (optional - web dashboard will use stub).%RESET%
) else (
for /f "tokens=1" %%v in ('node --version 2^>nul') do set "NODE_VER=%%v"
echo %GREEN%OK%RESET% Node.js !NODE_VER! found
)
:: Check Git
where git >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo %RED%ERROR: Git is required but not found.%RESET%
echo Install Git from https://git-scm.com/download/win
goto :error_exit
) else (
echo %GREEN%OK%RESET% Git found
)
goto :choose_mode
:: ---- Install Rust ----
:install_rust
echo.
echo %BOLD%Installing Rust...%RESET%
echo Downloading rustup-init.exe...
:: Download rustup-init.exe
curl -sSfL -o "%TEMP%\rustup-init.exe" https://win.rustup.rs
if %ERRORLEVEL% NEQ 0 (
echo %RED%ERROR: Failed to download rustup-init.exe%RESET%
echo Please install Rust manually from https://rustup.rs
goto :error_exit
)
:: Run rustup-init with defaults
"%TEMP%\rustup-init.exe" -y --default-toolchain stable --target %TARGET%
if %ERRORLEVEL% NEQ 0 (
echo %RED%ERROR: Rust installation failed.%RESET%
goto :error_exit
)
:: Refresh PATH
set "PATH=%USERPROFILE%\.cargo\bin;%PATH%"
echo %GREEN%OK%RESET% Rust installed successfully.
echo %YELLOW%NOTE: You may need to restart your terminal for PATH changes.%RESET%
goto :choose_mode
:: ---- Choose build mode ----
:choose_mode
echo.
if "%MODE%"=="prebuilt" goto :install_prebuilt
if "%MODE%"=="minimal" goto :build_minimal
if "%MODE%"=="standard" goto :build_standard
if "%MODE%"=="full" goto :build_full
:: Interactive mode
echo %BOLD%[2/5] Choose installation method:%RESET%
echo.
echo 1) Prebuilt binary - Download pre-compiled release (fastest, ~2 min)
echo 2) Minimal build - Default features only (~15 min)
echo 3) Standard build - Default + Lark/Feishu + Matrix (~20 min)
echo 4) Full build - All features including hardware + browser (~30 min)
echo.
set /p "CHOICE= Select [1-4] (default: 1): "
if "%CHOICE%"=="" set "CHOICE=1"
if "%CHOICE%"=="1" goto :install_prebuilt
if "%CHOICE%"=="2" goto :build_minimal
if "%CHOICE%"=="3" goto :build_standard
if "%CHOICE%"=="4" goto :build_full
echo %RED%Invalid choice. Please enter 1-4.%RESET%
goto :choose_mode
:: ---- Prebuilt binary ----
:install_prebuilt
echo.
echo %BOLD%[3/5] Downloading prebuilt binary...%RESET%
:: Try to get latest release URL via gh or curl
where gh >nul 2>&1
if %ERRORLEVEL% EQU 0 (
for /f "tokens=*" %%u in ('gh release view --repo %REPO% --json assets --jq ".assets[] | select(.name | test(\"windows-msvc\")) | .url" 2^>nul') do (
set "DOWNLOAD_URL=%%u"
)
)
if not defined DOWNLOAD_URL (
:: Fallback: construct URL from known release pattern
set "DOWNLOAD_URL=https://github.com/zeroclaw-labs/zeroclaw/releases/latest/download/zeroclaw-%TARGET%.zip"
)
echo Downloading from release...
curl -sSfL -o "%TEMP%\zeroclaw-windows.zip" "!DOWNLOAD_URL!"
if %ERRORLEVEL% NEQ 0 (
echo %YELLOW%Prebuilt binary not available. Falling back to source build (standard).%RESET%
goto :build_standard
)
:: Extract
echo Extracting...
mkdir "%USERPROFILE%\.zeroclaw\bin" 2>nul
tar -xf "%TEMP%\zeroclaw-windows.zip" -C "%USERPROFILE%\.zeroclaw\bin"
if %ERRORLEVEL% NEQ 0 (
powershell -Command "Expand-Archive -Force '%TEMP%\zeroclaw-windows.zip' '%USERPROFILE%\.zeroclaw\bin'"
)
:: Add to PATH if not already there
echo %PATH% | findstr /I /C:".zeroclaw\bin" >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
setx PATH "%PATH%;%USERPROFILE%\.zeroclaw\bin" >nul 2>&1
set "PATH=%PATH%;%USERPROFILE%\.zeroclaw\bin"
echo %GREEN%OK%RESET% Added to PATH
)
echo %GREEN%OK%RESET% Binary installed to %USERPROFILE%\.zeroclaw\bin\zeroclaw.exe
goto :post_install
:: ---- Minimal build ----
:build_minimal
set "FEATURES="
set "BUILD_DESC=minimal (default features)"
goto :do_build
:: ---- Standard build ----
:build_standard
set "FEATURES=--features channel-matrix,channel-lark"
set "BUILD_DESC=standard (Matrix + Lark/Feishu)"
goto :do_build
:: ---- Full build ----
:build_full
set "FEATURES=--features channel-matrix,channel-lark,browser-native,hardware,rag-pdf,observability-otel"
set "BUILD_DESC=full (all features)"
goto :do_build
:: ---- Build from source ----
:do_build
echo.
echo %BOLD%[3/5] Building ZeroClaw (%BUILD_DESC%)...%RESET%
echo Target: %TARGET%
:: Ensure we're in the repo root (check for Cargo.toml)
if not exist "Cargo.toml" (
echo %RED%ERROR: Cargo.toml not found. Run this script from the zeroclaw repository root.%RESET%
echo Example:
echo git clone %REPO%
echo cd zeroclaw
echo setup.bat
goto :error_exit
)
:: Add target if missing
rustup target add %TARGET% >nul 2>&1
echo This may take 15-30 minutes on first build...
echo.
cargo build --release --locked %FEATURES% --target %TARGET%
if %ERRORLEVEL% NEQ 0 (
echo.
echo %RED%ERROR: Build failed.%RESET%
echo Common fixes:
echo - Ensure Visual Studio Build Tools are installed (C++ workload)
echo - Run: rustup update
echo - Check disk space (6 GB needed)
goto :error_exit
)
echo %GREEN%OK%RESET% Build succeeded.
:: Copy binary to a convenient location
echo.
echo %BOLD%[4/5] Installing binary...%RESET%
mkdir "%USERPROFILE%\.zeroclaw\bin" 2>nul
copy /Y "target\%TARGET%\release\zeroclaw.exe" "%USERPROFILE%\.zeroclaw\bin\zeroclaw.exe" >nul
echo %GREEN%OK%RESET% Installed to %USERPROFILE%\.zeroclaw\bin\zeroclaw.exe
:: Add to PATH if not already there
echo %PATH% | findstr /I /C:".zeroclaw\bin" >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
setx PATH "%PATH%;%USERPROFILE%\.zeroclaw\bin" >nul 2>&1
set "PATH=%PATH%;%USERPROFILE%\.zeroclaw\bin"
echo %GREEN%OK%RESET% Added to PATH
)
goto :post_install
:: ---- Post install ----
:post_install
echo.
echo %BOLD%[5/5] Verifying installation...%RESET%
"%USERPROFILE%\.zeroclaw\bin\zeroclaw.exe" --version >nul 2>&1
if %ERRORLEVEL% EQU 0 (
for /f "tokens=*" %%v in ('"%USERPROFILE%\.zeroclaw\bin\zeroclaw.exe" --version 2^>nul') do (
echo %GREEN%OK%RESET% %%v
)
) else (
zeroclaw --version >nul 2>&1
if %ERRORLEVEL% EQU 0 (
for /f "tokens=*" %%v in ('zeroclaw --version 2^>nul') do (
echo %GREEN%OK%RESET% %%v
)
) else (
echo %YELLOW%Binary installed but not on PATH yet. Restart your terminal.%RESET%
)
)
echo.
echo %BOLD%%GREEN%=========================================%RESET%
echo %BOLD%%GREEN% ZeroClaw setup complete!%RESET%
echo %BOLD%%GREEN%=========================================%RESET%
echo.
echo Next steps:
echo 1. Restart your terminal (for PATH changes)
echo 2. Run: zeroclaw init
echo 3. Configure your API key in %%USERPROFILE%%\.zeroclaw\config.toml
echo.
echo Alternative install via Scoop:
echo scoop bucket add zeroclaw https://github.com/zeroclaw-labs/scoop-zeroclaw
echo scoop install zeroclaw
echo.
echo Documentation: https://github.com/zeroclaw-labs/zeroclaw
echo.
goto :end
:: ---- Help ----
:show_help
echo.
echo ZeroClaw Windows Setup Script
echo.
echo Usage: setup.bat [OPTIONS]
echo.
echo Options:
echo --prebuilt Download pre-compiled binary (fastest)
echo --minimal Build with default features only
echo --standard Build with Matrix + Lark/Feishu
echo --full Build with all features
echo --help, -h Show this help message
echo.
echo Without arguments, runs in interactive mode.
echo.
echo Prerequisites:
echo - Git (required)
echo - Rust 1.87+ (auto-installed if missing)
echo - Visual Studio Build Tools with C++ workload (for source builds)
echo - Node.js (optional, for web dashboard)
echo.
goto :end
:: ---- Error exit ----
:error_exit
echo.
echo %RED%Setup failed. See errors above.%RESET%
echo Need help? Open an issue at %REPO%/issues
echo.
endlocal
exit /b 1
:: ---- Clean exit ----
:end
endlocal
exit /b 0