docs: overhaul docs IA and multilingual navigation
This commit is contained in:
parent
5e800c38f1
commit
93e5383cb2
40 changed files with 2495 additions and 198 deletions
314
scripts/bootstrap.sh
Executable file
314
scripts/bootstrap.sh
Executable file
|
|
@ -0,0 +1,314 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
info() {
|
||||
echo "==> $*"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo "warning: $*" >&2
|
||||
}
|
||||
|
||||
error() {
|
||||
echo "error: $*" >&2
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
ZeroClaw one-click bootstrap
|
||||
|
||||
Usage:
|
||||
./bootstrap.sh [options]
|
||||
|
||||
Modes:
|
||||
Default mode installs/builds ZeroClaw only (requires existing Rust toolchain).
|
||||
Optional bootstrap mode can also install system dependencies and Rust.
|
||||
|
||||
Options:
|
||||
--install-system-deps Install build dependencies (Linux/macOS)
|
||||
--install-rust Install Rust via rustup if missing
|
||||
--onboard Run onboarding after install
|
||||
--interactive-onboard Run interactive onboarding (implies --onboard)
|
||||
--api-key <key> API key for non-interactive onboarding
|
||||
--provider <id> Provider for non-interactive onboarding (default: openrouter)
|
||||
--skip-build Skip `cargo build --release --locked`
|
||||
--skip-install Skip `cargo install --path . --force --locked`
|
||||
-h, --help Show help
|
||||
|
||||
Examples:
|
||||
./bootstrap.sh
|
||||
./bootstrap.sh --install-system-deps --install-rust
|
||||
./bootstrap.sh --onboard --api-key "sk-..." --provider openrouter
|
||||
./bootstrap.sh --interactive-onboard
|
||||
|
||||
# Remote one-liner
|
||||
curl -fsSL https://raw.githubusercontent.com/zeroclaw-labs/zeroclaw/main/scripts/bootstrap.sh | bash
|
||||
|
||||
Environment:
|
||||
ZEROCLAW_API_KEY Used when --api-key is not provided
|
||||
ZEROCLAW_PROVIDER Used when --provider is not provided (default: openrouter)
|
||||
USAGE
|
||||
}
|
||||
|
||||
have_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
run_privileged() {
|
||||
if [[ "$(id -u)" -eq 0 ]]; then
|
||||
"$@"
|
||||
elif have_cmd sudo; then
|
||||
sudo "$@"
|
||||
else
|
||||
error "sudo is required to install system dependencies."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_system_deps() {
|
||||
info "Installing system dependencies"
|
||||
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
if have_cmd apt-get; then
|
||||
run_privileged apt-get update -qq
|
||||
run_privileged apt-get install -y build-essential pkg-config git curl
|
||||
elif have_cmd dnf; then
|
||||
run_privileged dnf groupinstall -y "Development Tools"
|
||||
run_privileged dnf install -y pkg-config git curl
|
||||
else
|
||||
warn "Unsupported Linux distribution. Install compiler toolchain + pkg-config + git + curl manually."
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
if ! xcode-select -p >/dev/null 2>&1; then
|
||||
info "Installing Xcode Command Line Tools"
|
||||
xcode-select --install || true
|
||||
cat <<'MSG'
|
||||
Please complete the Xcode Command Line Tools installation dialog,
|
||||
then re-run bootstrap.
|
||||
MSG
|
||||
exit 0
|
||||
fi
|
||||
if ! have_cmd git; then
|
||||
warn "git is not available. Install git (e.g., Homebrew) and re-run bootstrap."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
warn "Unsupported OS for automatic dependency install. Continuing without changes."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_rust_toolchain() {
|
||||
if have_cmd cargo && have_cmd rustc; then
|
||||
info "Rust already installed: $(rustc --version)"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! have_cmd curl; then
|
||||
error "curl is required to install Rust via rustup."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
info "Installing Rust via rustup"
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
|
||||
if [[ -f "$HOME/.cargo/env" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$HOME/.cargo/env"
|
||||
fi
|
||||
|
||||
if ! have_cmd cargo; then
|
||||
error "Rust installation completed but cargo is still unavailable in PATH."
|
||||
error "Run: source \"$HOME/.cargo/env\""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" >/dev/null 2>&1 && pwd || pwd)"
|
||||
ROOT_DIR="$(cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd || pwd)"
|
||||
REPO_URL="https://github.com/zeroclaw-labs/zeroclaw.git"
|
||||
|
||||
INSTALL_SYSTEM_DEPS=false
|
||||
INSTALL_RUST=false
|
||||
RUN_ONBOARD=false
|
||||
INTERACTIVE_ONBOARD=false
|
||||
SKIP_BUILD=false
|
||||
SKIP_INSTALL=false
|
||||
API_KEY="${ZEROCLAW_API_KEY:-}"
|
||||
PROVIDER="${ZEROCLAW_PROVIDER:-openrouter}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--install-system-deps)
|
||||
INSTALL_SYSTEM_DEPS=true
|
||||
shift
|
||||
;;
|
||||
--install-rust)
|
||||
INSTALL_RUST=true
|
||||
shift
|
||||
;;
|
||||
--onboard)
|
||||
RUN_ONBOARD=true
|
||||
shift
|
||||
;;
|
||||
--interactive-onboard)
|
||||
RUN_ONBOARD=true
|
||||
INTERACTIVE_ONBOARD=true
|
||||
shift
|
||||
;;
|
||||
--api-key)
|
||||
API_KEY="${2:-}"
|
||||
[[ -n "$API_KEY" ]] || {
|
||||
error "--api-key requires a value"
|
||||
exit 1
|
||||
}
|
||||
shift 2
|
||||
;;
|
||||
--provider)
|
||||
PROVIDER="${2:-}"
|
||||
[[ -n "$PROVIDER" ]] || {
|
||||
error "--provider requires a value"
|
||||
exit 1
|
||||
}
|
||||
shift 2
|
||||
;;
|
||||
--skip-build)
|
||||
SKIP_BUILD=true
|
||||
shift
|
||||
;;
|
||||
--skip-install)
|
||||
SKIP_INSTALL=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
error "unknown option: $1"
|
||||
echo
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$INSTALL_SYSTEM_DEPS" == true ]]; then
|
||||
install_system_deps
|
||||
fi
|
||||
|
||||
if [[ "$INSTALL_RUST" == true ]]; then
|
||||
install_rust_toolchain
|
||||
fi
|
||||
|
||||
if ! have_cmd cargo; then
|
||||
error "cargo is not installed."
|
||||
cat <<'MSG' >&2
|
||||
Install Rust first: https://rustup.rs/
|
||||
or re-run with:
|
||||
./bootstrap.sh --install-rust
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WORK_DIR="$ROOT_DIR"
|
||||
TEMP_CLONE=false
|
||||
TEMP_DIR=""
|
||||
|
||||
cleanup() {
|
||||
if [[ "$TEMP_CLONE" == true && -n "$TEMP_DIR" && -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Support three launch modes:
|
||||
# 1) ./bootstrap.sh from repo root
|
||||
# 2) scripts/bootstrap.sh from repo
|
||||
# 3) curl | bash (no local repo => temporary clone)
|
||||
if [[ ! -f "$WORK_DIR/Cargo.toml" ]]; then
|
||||
if [[ -f "$(pwd)/Cargo.toml" ]]; then
|
||||
WORK_DIR="$(pwd)"
|
||||
else
|
||||
if ! have_cmd git; then
|
||||
error "git is required when running bootstrap outside a local repository checkout."
|
||||
if [[ "$INSTALL_SYSTEM_DEPS" == false ]]; then
|
||||
error "Re-run with --install-system-deps or install git manually."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEMP_DIR="$(mktemp -d -t zeroclaw-bootstrap-XXXXXX)"
|
||||
info "No local repository detected; cloning latest main branch"
|
||||
git clone --depth 1 "$REPO_URL" "$TEMP_DIR"
|
||||
WORK_DIR="$TEMP_DIR"
|
||||
TEMP_CLONE=true
|
||||
fi
|
||||
fi
|
||||
|
||||
info "ZeroClaw bootstrap"
|
||||
echo " workspace: $WORK_DIR"
|
||||
|
||||
cd "$WORK_DIR"
|
||||
|
||||
if [[ "$SKIP_BUILD" == false ]]; then
|
||||
info "Building release binary"
|
||||
cargo build --release --locked
|
||||
else
|
||||
info "Skipping build"
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_INSTALL" == false ]]; then
|
||||
info "Installing zeroclaw to cargo bin"
|
||||
cargo install --path "$WORK_DIR" --force --locked
|
||||
else
|
||||
info "Skipping install"
|
||||
fi
|
||||
|
||||
ZEROCLAW_BIN=""
|
||||
if have_cmd zeroclaw; then
|
||||
ZEROCLAW_BIN="zeroclaw"
|
||||
elif [[ -x "$WORK_DIR/target/release/zeroclaw" ]]; then
|
||||
ZEROCLAW_BIN="$WORK_DIR/target/release/zeroclaw"
|
||||
fi
|
||||
|
||||
if [[ "$RUN_ONBOARD" == true ]]; then
|
||||
if [[ -z "$ZEROCLAW_BIN" ]]; then
|
||||
error "onboarding requested but zeroclaw binary is not available."
|
||||
error "Run without --skip-install, or ensure zeroclaw is in PATH."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$INTERACTIVE_ONBOARD" == true ]]; then
|
||||
info "Running interactive onboarding"
|
||||
"$ZEROCLAW_BIN" onboard --interactive
|
||||
else
|
||||
if [[ -z "$API_KEY" ]]; then
|
||||
cat <<'MSG'
|
||||
==> Onboarding requested, but API key not provided.
|
||||
Use either:
|
||||
--api-key "sk-..."
|
||||
or:
|
||||
ZEROCLAW_API_KEY="sk-..." ./bootstrap.sh --onboard
|
||||
or run interactive:
|
||||
./bootstrap.sh --interactive-onboard
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
info "Running quick onboarding (provider: $PROVIDER)"
|
||||
"$ZEROCLAW_BIN" onboard --api-key "$API_KEY" --provider "$PROVIDER"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat <<'DONE'
|
||||
|
||||
✅ Bootstrap complete.
|
||||
|
||||
Next steps:
|
||||
zeroclaw status
|
||||
zeroclaw agent -m "Hello, ZeroClaw!"
|
||||
zeroclaw gateway
|
||||
DONE
|
||||
179
scripts/install.sh
Normal file → Executable file
179
scripts/install.sh
Normal file → Executable file
|
|
@ -1,151 +1,58 @@
|
|||
#!/usr/bin/env bash
|
||||
# install.sh — Build and install ZeroClaw from source.
|
||||
# Usage:
|
||||
# curl -LsSf https://raw.githubusercontent.com/zeroclaw-labs/zeroclaw/main/scripts/install.sh | bash
|
||||
# # or
|
||||
# bash scripts/install.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- Logging --------------------------------------------------------------
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd || pwd)"
|
||||
BOOTSTRAP_LOCAL="$SCRIPT_DIR/bootstrap.sh"
|
||||
REPO_URL="https://github.com/zeroclaw-labs/zeroclaw.git"
|
||||
|
||||
info() { printf ">>> %s\n" "$*"; }
|
||||
warn() { printf ">>> [WARN] %s\n" "$*"; }
|
||||
error() { printf ">>> [ERROR] %s\n" "$*" >&2; }
|
||||
die() { error "$@"; exit 1; }
|
||||
echo "[deprecated] scripts/install.sh -> bootstrap.sh" >&2
|
||||
|
||||
# --- Step 1: Detect OS and install system dependencies --------------------
|
||||
if [[ -f "$BOOTSTRAP_LOCAL" ]]; then
|
||||
exec "$BOOTSTRAP_LOCAL" "$@"
|
||||
fi
|
||||
|
||||
install_system_deps() {
|
||||
info "Detecting operating system..."
|
||||
|
||||
local os
|
||||
os="$(uname -s)"
|
||||
|
||||
case "${os}" in
|
||||
Linux)
|
||||
install_linux_deps
|
||||
;;
|
||||
Darwin)
|
||||
install_macos_deps
|
||||
;;
|
||||
*)
|
||||
die "Unsupported operating system: ${os}. Only Linux and macOS are supported."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_linux_deps() {
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
info "Detected Debian/Ubuntu — installing build-essential, pkg-config, git..."
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y build-essential pkg-config git
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
info "Detected Fedora/RHEL — installing Development Tools, pkg-config, git..."
|
||||
sudo dnf groupinstall -y "Development Tools"
|
||||
sudo dnf install -y pkg-config git
|
||||
else
|
||||
die "Unsupported Linux distribution. Please install a C compiler, pkg-config, and git manually, then re-run this script."
|
||||
fi
|
||||
}
|
||||
|
||||
install_macos_deps() {
|
||||
if ! xcode-select -p >/dev/null 2>&1; then
|
||||
info "Installing Xcode Command Line Tools..."
|
||||
xcode-select --install
|
||||
warn "A dialog may have appeared. Please complete the Xcode CLT installation, then re-run this script."
|
||||
exit 0
|
||||
else
|
||||
info "Xcode Command Line Tools already installed."
|
||||
fi
|
||||
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
die "git not found. Please install git (e.g. via Homebrew) and re-run this script."
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Step 2: Install Rust -------------------------------------------------
|
||||
|
||||
install_rust() {
|
||||
if command -v rustc >/dev/null 2>&1; then
|
||||
info "Rust already installed ($(rustc --version))."
|
||||
else
|
||||
info "Installing Rust via rustup..."
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
# shellcheck source=/dev/null
|
||||
source "${HOME}/.cargo/env"
|
||||
info "Rust installed ($(rustc --version))."
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Step 3: Clone repository ---------------------------------------------
|
||||
|
||||
CLONE_DIR="/tmp/zeroclaw-install"
|
||||
|
||||
clone_repo() {
|
||||
if [ -d "${CLONE_DIR}" ]; then
|
||||
info "Removing previous clone at ${CLONE_DIR}..."
|
||||
rm -rf "${CLONE_DIR}"
|
||||
fi
|
||||
|
||||
info "Cloning ZeroClaw repository..."
|
||||
git clone --depth 1 https://github.com/zeroclaw-labs/zeroclaw.git "${CLONE_DIR}"
|
||||
}
|
||||
|
||||
# --- Step 4: Build and install --------------------------------------------
|
||||
|
||||
build_and_install() {
|
||||
info "Building ZeroClaw (release mode)..."
|
||||
cargo build --release --locked --manifest-path "${CLONE_DIR}/Cargo.toml"
|
||||
|
||||
info "Installing ZeroClaw binary..."
|
||||
cargo install --path "${CLONE_DIR}" --force --locked
|
||||
}
|
||||
|
||||
# --- Step 5: Cleanup ------------------------------------------------------
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "error: git is required for legacy install.sh remote mode" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEMP_DIR="$(mktemp -d -t zeroclaw-install-XXXXXX)"
|
||||
cleanup() {
|
||||
info "Cleaning up build directory..."
|
||||
rm -rf "${CLONE_DIR}"
|
||||
rm -rf "$TEMP_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# --- Step 6: Success message ----------------------------------------------
|
||||
git clone --depth 1 "$REPO_URL" "$TEMP_DIR" >/dev/null 2>&1
|
||||
|
||||
print_success() {
|
||||
echo ""
|
||||
info "ZeroClaw installed successfully!"
|
||||
echo ""
|
||||
echo " To use zeroclaw in your current shell, run:"
|
||||
echo ""
|
||||
echo " source \"\${HOME}/.cargo/env\""
|
||||
echo ""
|
||||
echo " To make it permanent, add the line above to your shell profile"
|
||||
echo " (~/.bashrc, ~/.zshrc, etc.)."
|
||||
echo ""
|
||||
echo " Then get started:"
|
||||
echo ""
|
||||
echo " zeroclaw onboard"
|
||||
echo ""
|
||||
}
|
||||
if [[ -x "$TEMP_DIR/scripts/bootstrap.sh" ]]; then
|
||||
"$TEMP_DIR/scripts/bootstrap.sh" "$@"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- Main -----------------------------------------------------------------
|
||||
echo "[deprecated] cloned revision has no bootstrap.sh; falling back to legacy source install flow" >&2
|
||||
|
||||
main() {
|
||||
echo ""
|
||||
info "ZeroClaw — Source Install"
|
||||
echo ""
|
||||
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
||||
cat <<'USAGE'
|
||||
Legacy install.sh fallback mode
|
||||
|
||||
install_system_deps
|
||||
echo ""
|
||||
install_rust
|
||||
echo ""
|
||||
clone_repo
|
||||
echo ""
|
||||
build_and_install
|
||||
echo ""
|
||||
cleanup
|
||||
echo ""
|
||||
print_success
|
||||
}
|
||||
Behavior:
|
||||
- Clone repository
|
||||
- cargo build --release --locked
|
||||
- cargo install --path <clone> --force --locked
|
||||
|
||||
main
|
||||
For the new dual-mode installer, use:
|
||||
./bootstrap.sh --help
|
||||
USAGE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v cargo >/dev/null 2>&1; then
|
||||
echo "error: cargo is required for legacy install.sh fallback mode" >&2
|
||||
echo "Install Rust first: https://rustup.rs/" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo build --release --locked --manifest-path "$TEMP_DIR/Cargo.toml"
|
||||
cargo install --path "$TEMP_DIR" --force --locked
|
||||
|
||||
echo "Legacy source install completed." >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue