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
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ freebuff

Then describe what you want. Freebuff finds the relevant files, makes changes, and runs the checks that matter for your project.

## Install a local build

The scripts in [`install/`](./install/) build the CLI from source and install it
for the current user. They do not require administrator privileges on Linux or
macOS.

On Linux or macOS:

```bash
git clone https://github.com/CodebuffAI/freebuff.git
cd freebuff
bash install/install-unix.sh
```

On Windows, run [`install/install-windows.bat`](./install/install-windows.bat)
from a Command Prompt after installing Git and Bun.

The installers use `CodebuffAI/freebuff` on `main` by default. To install a
fork or a specific branch, override the repository and branch. For example,
this installs the recovery-retry version from a personal fork:

```bash
FREEBUFF_REPO_URL=https://github.com/viniciusdebruin/freebuff.git \
FREEBUFF_BRANCH=contrib/engine-recovery \
bash install/install-unix.sh
```

On Windows:

```bat
set FREEBUFF_REPO_URL=https://github.com/viniciusdebruin/freebuff.git
set FREEBUFF_BRANCH=contrib/engine-recovery
install\install-windows.bat
```

Run the installer again to fetch the selected branch and rebuild the local
binary. A build made on one operating system should not be copied to another;
build it locally on each target machine.

## Models

Freebuff includes a curated model catalog. The regular picker currently offers:
Expand Down
82 changes: 82 additions & 0 deletions install/install-unix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
set -euo pipefail

# Install a local Freebuff build on Linux or macOS.
#
# Defaults can be changed without editing this file:
# FREEBUFF_REPO_URL=https://github.com/CodebuffAI/freebuff.git
# FREEBUFF_BRANCH=main
# FREEBUFF_SOURCE_DIR="$HOME/.local/share/freebuff-source"
# FREEBUFF_BIN_DIR="$HOME/.local/bin"

repo_url="${FREEBUFF_REPO_URL:-https://github.com/CodebuffAI/freebuff.git}"
branch="${FREEBUFF_BRANCH:-main}"
source_dir="${FREEBUFF_SOURCE_DIR:-$HOME/.local/share/freebuff-source}"
bin_dir="${FREEBUFF_BIN_DIR:-$HOME/.local/bin}"

fail() {
printf 'Freebuff installation failed: %s\n' "$1" >&2
exit 1
}

case "$(uname -s)" in
Linux|Darwin) ;;
*) fail 'this installer supports Linux and macOS only' ;;
esac

command -v git >/dev/null 2>&1 || fail 'Git is required; install it and run this script again'

if ! command -v bun >/dev/null 2>&1; then
if ! command -v curl >/dev/null 2>&1; then
fail 'Bun is missing and curl is unavailable to install it'
fi

printf 'Bun was not found. Installing Bun for the current user...\n'
curl -fsSL https://bun.sh/install | bash
export PATH="$HOME/.bun/bin:$PATH"
fi

command -v bun >/dev/null 2>&1 || fail 'Bun could not be found after installation'

if [ ! -e "$source_dir" ]; then
mkdir -p "$(dirname "$source_dir")"
printf 'Cloning %s (%s)...\n' "$repo_url" "$branch"
git clone --depth 1 --branch "$branch" "$repo_url" "$source_dir"
elif [ ! -d "$source_dir/.git" ]; then
fail "$source_dir exists but is not a Git repository; choose another FREEBUFF_SOURCE_DIR"
else
printf 'Updating source checkout in %s...\n' "$source_dir"
git -C "$source_dir" fetch --depth 1 origin "$branch"

if git -C "$source_dir" show-ref --verify --quiet "refs/heads/$branch"; then
git -C "$source_dir" checkout "$branch"
else
git -C "$source_dir" checkout -b "$branch" "origin/$branch"
fi

git -C "$source_dir" pull --ff-only origin "$branch"
fi

printf 'Installing dependencies...\n'
bun --cwd "$source_dir" install --frozen-lockfile

printf 'Building Freebuff for %s/%s...\n' "$(uname -s)" "$(uname -m)"
bun --cwd "$source_dir" run build:freebuff

binary="$source_dir/cli/bin/freebuff"
wasm="$source_dir/cli/bin/tree-sitter.wasm"
[ -f "$binary" ] || fail "build did not produce $binary"
[ -f "$wasm" ] || fail "build did not produce $wasm"

mkdir -p "$bin_dir"
cp "$binary" "$bin_dir/freebuff"
cp "$wasm" "$bin_dir/tree-sitter.wasm"
chmod 755 "$bin_dir/freebuff"

printf '\nFreebuff installed at %s\n' "$bin_dir/freebuff"
if case ":$PATH:" in *":$bin_dir:"*) false ;; *) true ;; esac; then
printf 'Add this directory to PATH for future terminals:\n'
printf ' export PATH="%s:$PATH"\n' "$bin_dir"
fi

"$bin_dir/freebuff" --version || true
99 changes: 99 additions & 0 deletions install/install-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
@echo off
setlocal EnableExtensions

rem Install a local Freebuff build on Windows.
rem Override these variables before running to install a fork or branch:
rem set FREEBUFF_REPO_URL=https://github.com/viniciusdebruin/freebuff.git
rem set FREEBUFF_BRANCH=contrib/engine-recovery

if not defined FREEBUFF_REPO_URL set "FREEBUFF_REPO_URL=https://github.com/CodebuffAI/freebuff.git"
if not defined FREEBUFF_BRANCH set "FREEBUFF_BRANCH=main"
if not defined FREEBUFF_SOURCE_DIR set "FREEBUFF_SOURCE_DIR=%USERPROFILE%\.local\share\freebuff-source"
if not defined FREEBUFF_BIN_DIR set "FREEBUFF_BIN_DIR=%LOCALAPPDATA%\Freebuff\bin"

where git >nul 2>nul
if errorlevel 1 (
echo Git is required. Install Git for Windows and run this script again.
exit /b 1
)

where bun >nul 2>nul
if errorlevel 1 (
echo Bun is required. Install Bun for Windows and run this script again.
echo See https://bun.sh/docs/installation
exit /b 1
)

if not exist "%FREEBUFF_SOURCE_DIR%\.git" (
if exist "%FREEBUFF_SOURCE_DIR%" (
echo %FREEBUFF_SOURCE_DIR% exists but is not a Git repository.
echo Choose another FREEBUFF_SOURCE_DIR and run this script again.
exit /b 1
)

echo Cloning %FREEBUFF_REPO_URL% (%FREEBUFF_BRANCH%)...
git clone --depth 1 --branch "%FREEBUFF_BRANCH%" "%FREEBUFF_REPO_URL%" "%FREEBUFF_SOURCE_DIR%"
if errorlevel 1 goto :error
) else (
echo Updating source checkout in %FREEBUFF_SOURCE_DIR%...
git -C "%FREEBUFF_SOURCE_DIR%" fetch --depth 1 origin "%FREEBUFF_BRANCH%"
if errorlevel 1 goto :error

git -C "%FREEBUFF_SOURCE_DIR%" show-ref --verify --quiet "refs/heads/%FREEBUFF_BRANCH%"
if errorlevel 1 (
git -C "%FREEBUFF_SOURCE_DIR%" checkout -b "%FREEBUFF_BRANCH%" "origin/%FREEBUFF_BRANCH%"
) else (
git -C "%FREEBUFF_SOURCE_DIR%" checkout "%FREEBUFF_BRANCH%"
)
if errorlevel 1 goto :error

git -C "%FREEBUFF_SOURCE_DIR%" pull --ff-only origin "%FREEBUFF_BRANCH%"
if errorlevel 1 goto :error
)

echo Installing dependencies...
pushd "%FREEBUFF_SOURCE_DIR%"
call bun install --frozen-lockfile
if errorlevel 1 (
popd
goto :error
)

echo Building Freebuff for Windows...
call bun run build:freebuff
if errorlevel 1 (
popd
goto :error
)
popd

if not exist "%FREEBUFF_SOURCE_DIR%\cli\bin\freebuff.exe" (
echo Build did not produce freebuff.exe.
goto :error
)
if not exist "%FREEBUFF_SOURCE_DIR%\cli\bin\tree-sitter.wasm" (
echo Build did not produce tree-sitter.wasm.
goto :error
)

if not exist "%FREEBUFF_BIN_DIR%" mkdir "%FREEBUFF_BIN_DIR%"
copy /Y "%FREEBUFF_SOURCE_DIR%\cli\bin\freebuff.exe" "%FREEBUFF_BIN_DIR%\freebuff.exe" >nul
copy /Y "%FREEBUFF_SOURCE_DIR%\cli\bin\tree-sitter.wasm" "%FREEBUFF_BIN_DIR%\tree-sitter.wasm" >nul
if errorlevel 1 goto :error

set "PATH=%FREEBUFF_BIN_DIR%;%PATH%"

rem Add the install directory to the current user's PATH without setx PATH truncation.
powershell -NoProfile -ExecutionPolicy Bypass -Command "$dir=[IO.Path]::GetFullPath('%FREEBUFF_BIN_DIR%'); $current=[Environment]::GetEnvironmentVariable('Path','User'); $parts=@($current -split ';' | Where-Object { $_ -and $_.Trim() }); if (-not ($parts -contains $dir)) { [Environment]::SetEnvironmentVariable('Path', (($parts + $dir) -join ';'), 'User') }"
if errorlevel 1 echo Could not update the persistent user PATH. The current terminal can still run Freebuff.

echo.
echo Freebuff installed at %FREEBUFF_BIN_DIR%\freebuff.exe
"%FREEBUFF_BIN_DIR%\freebuff.exe" --version
echo Open a new terminal before running: freebuff
exit /b 0

:error
echo.
echo Freebuff installation failed.
exit /b 1
Loading