Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ runtime/__pycache__

# Codex logs
.codex-logs/
/dist
138 changes: 138 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
@echo off
setlocal EnableDelayedExpansion

echo ============================================
echo cc-haha Build Script
echo ============================================
echo.

cd /d "%~dp0"

set "BUN_EXE="
where bun >nul 2>&1
if %ERRORLEVEL% equ 0 (
set "BUN_EXE=bun"
) else if exist "%USERPROFILE%\.bun\bin\bun.exe" (
set "BUN_EXE=%USERPROFILE%\.bun\bin\bun.exe"
) else if exist "C:\Users\Administrator\.bun\bin\bun.exe" (
set "BUN_EXE=C:\Users\Administrator\.bun\bin\bun.exe"
) else (
echo [ERROR] bun not found, please install: https://bun.sh
pause
exit /b 1
)

if "%BUN_EXE%"=="bun" goto :build_bun_in_path
for %%I in ("%BUN_EXE%") do set "BUN_DIR=%%~dpI"
set "PATH=%BUN_DIR%;%PATH%"
:build_bun_in_path

if not exist "node_modules" (
echo [INFO] Installing dependencies...
"%BUN_EXE%" install
if %ERRORLEVEL% neq 0 (
echo [ERROR] Install failed
pause
exit /b 1
)
echo.
)

set OUTPUT_DIR=%~dp0dist
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"

set VERSION=999.0.0-local
for /f "tokens=2 delims=:," %%a in ('findstr /c:"\"version\"" package.json') do (
set VERSION=%%a
set VERSION=!VERSION: =!
set VERSION=!VERSION:"=!
)
for /f "tokens=*" %%t in ('powershell -command "Get-Date -Format yyyy-MM-ddTHH:mm:ss"') do set BUILD_TIME=%%t

echo [INFO] Version: %VERSION%
echo [INFO] Build time: %BUILD_TIME%
echo.

set EXTERNALS=^
--external @anthropic-ai/bedrock-sdk ^
--external @anthropic-ai/foundry-sdk ^
--external @anthropic-ai/vertex-sdk ^
--external @anthropic-ai/mcpb ^
--external @azure/identity ^
--external @aws-sdk/client-sts ^
--external @aws-sdk/client-bedrock ^
--external @opentelemetry/exporter-* ^
--external fflate ^
--external sharp

echo [1/3] Building CLI entry...
"%BUN_EXE%" build ./src/entrypoints/cli.tsx ^
--compile ^
--outfile "%OUTPUT_DIR%\claude-haha.exe" ^
--define:process.env.CLAUDE_CODE_LOCAL_VERSION="'%VERSION%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_BUILD_TIME="'%BUILD_TIME%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_PACKAGE_URL="'claude-code-local'" ^
--define:process.env.CLAUDE_CODE_LOCAL_SKIP_REMOTE_PREFETCH="'1'" ^
%EXTERNALS%
if %ERRORLEVEL% neq 0 (
echo [ERROR] CLI build failed
pause
exit /b 1
)
echo -^> %OUTPUT_DIR%\claude-haha.exe

echo [2/3] Building Server entry...
"%BUN_EXE%" build ./src/server/index.ts ^
--compile ^
--outfile "%OUTPUT_DIR%\cc-haha-server.exe" ^
--define:process.env.CLAUDE_CODE_LOCAL_VERSION="'%VERSION%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_BUILD_TIME="'%BUILD_TIME%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_PACKAGE_URL="'claude-code-local'" ^
--define:process.env.CLAUDE_CODE_LOCAL_SKIP_REMOTE_PREFETCH="'1'" ^
%EXTERNALS%
if %ERRORLEVEL% neq 0 (
echo [ERROR] Server build failed
pause
exit /b 1
)
echo -^> %OUTPUT_DIR%\cc-haha-server.exe

echo [3/3] Building MCP entry...
"%BUN_EXE%" build ./src/entrypoints/mcp.ts ^
--compile ^
--outfile "%OUTPUT_DIR%\cc-haha-mcp.exe" ^
--define:process.env.CLAUDE_CODE_LOCAL_VERSION="'%VERSION%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_BUILD_TIME="'%BUILD_TIME%'" ^
--define:process.env.CLAUDE_CODE_LOCAL_PACKAGE_URL="'claude-code-local'" ^
--define:process.env.CLAUDE_CODE_LOCAL_SKIP_REMOTE_PREFETCH="'1'" ^
%EXTERNALS%
if %ERRORLEVEL% neq 0 (
echo [WARN] MCP build failed (non-critical, skipping)
) else (
echo -^> %OUTPUT_DIR%\cc-haha-mcp.exe
)

echo.
echo ============================================
echo Build complete!
echo ============================================
echo.
echo Output: %OUTPUT_DIR%\
echo.
echo Usage:
echo CLI: claude-haha.exe
echo Server: cc-haha-server.exe --port 3456
echo MCP: cc-haha-mcp.exe
echo.
echo Environment variables:
echo SERVER_PORT Server port (default 3456)
echo ANTHROPIC_API_KEY API key
echo ANTHROPIC_BASE_URL API base URL
echo.

for %%f in ("%OUTPUT_DIR%\*.exe") do (
echo %%~nxf: %%~zf bytes
)
echo.

pause
63 changes: 62 additions & 1 deletion bun.lock

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions desktop/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
@echo off
setlocal EnableDelayedExpansion

echo ============================================
echo cc-haha Desktop Build Script
echo ============================================
echo.

cd /d "%~dp0"

set "BUN_EXE="
where bun >nul 2>&1
if %ERRORLEVEL% equ 0 (
set "BUN_EXE=bun"
) else if exist "%USERPROFILE%\.bun\bin\bun.exe" (
set "BUN_EXE=%USERPROFILE%\.bun\bin\bun.exe"
) else if exist "C:\Users\Administrator\.bun\bin\bun.exe" (
set "BUN_EXE=C:\Users\Administrator\.bun\bin\bun.exe"
) else (
echo [ERROR] bun not found, please install: https://bun.sh
pause
exit /b 1
)

if "%BUN_EXE%"=="bun" goto :desktop_build_bun_in_path
for %%I in ("%BUN_EXE%") do set "BUN_DIR=%%~dpI"
set "PATH=%BUN_DIR%;%PATH%"
:desktop_build_bun_in_path

where cargo >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo [ERROR] cargo not found. Install Rust: https://rustup.rs
pause
exit /b 1
)

echo Select build type:
echo 1. Frontend only (Vite build, no installer)
echo 2. Full Tauri build (MSI installer)
echo.
set /p MODE="Enter option (1/2): "

if "%MODE%"=="1" goto :frontend
if "%MODE%"=="2" goto :tauri
echo [ERROR] Invalid option
pause
exit /b 1

:frontend
echo.
echo [1/2] Type checking...
"%BUN_EXE%" run lint
if %ERRORLEVEL% neq 0 (
echo [ERROR] Type check failed
pause
exit /b 1
)

echo [2/2] Building frontend...
"%BUN_EXE%" run build
if %ERRORLEVEL% neq 0 (
echo [ERROR] Frontend build failed
pause
exit /b 1
)

echo.
echo ============================================
echo Frontend build complete!
echo ============================================
echo.
echo Output: dist\
echo.
goto :end

:tauri
echo.
echo [INFO] Full Tauri build for Windows x64
echo ============================================
echo.
echo This requires:
echo - Visual Studio 2022 Build Tools (C++ workload)
echo - Rust toolchain (stable-x86_64-pc-windows-msvc)
echo.
echo The build may take several minutes on first run.
echo.

if not exist "node_modules" (
echo [INFO] Installing root dependencies...
pushd ..
"%BUN_EXE%" install
if %ERRORLEVEL% neq 0 (
echo [ERROR] Root install failed
popd
pause
exit /b 1
)
popd
echo [INFO] Installing desktop dependencies...
"%BUN_EXE%" install
if %ERRORLEVEL% neq 0 (
echo [ERROR] Desktop install failed
pause
exit /b 1
)
echo [INFO] Installing adapter dependencies...
pushd ..\adapters
if not exist "node_modules" (
"%BUN_EXE%" install
if %ERRORLEVEL% neq 0 (
echo [ERROR] Adapter install failed
popd
pause
exit /b 1
)
)
popd
echo.
)

echo Starting Tauri build...
powershell -ExecutionPolicy Bypass -File ".\scripts\build-windows-x64.ps1"
if %ERRORLEVEL% neq 0 (
echo.
echo [ERROR] Tauri build failed
pause
exit /b 1
)

echo.
echo ============================================
echo Tauri build complete!
echo ============================================
echo.
echo Output: build-artifacts\windows-x64\
echo Look for the .msi installer there.
echo.

if exist "build-artifacts\windows-x64\BUILD_INFO.txt" (
echo Build info:
for /f "tokens=*" %%l in (build-artifacts\windows-x64\BUILD_INFO.txt) do (
echo %%l
)
)

:end
echo.
pause
9 changes: 9 additions & 0 deletions desktop/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading