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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ jobs:
- name: Lint Python surfaces touched by lucebox tooling
run: uv run --frozen --extra dev ruff check .

- name: Install shellcheck (for bash test runner)
# ubuntu-latest typically ships shellcheck pre-installed, but pin
# the dependency explicitly so the bash test runner can always rely
# on `command -v shellcheck` succeeding.
run: |
if ! command -v shellcheck >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y shellcheck
fi
shellcheck --version | head -3

- name: Typecheck lucebox CLI
run: uv run --frozen --extra dev python -m mypy --package lucebox

- name: Unit-test lucebox CLI
# The fast workspace sync above is enough: the suite mocks the
# docker / HTTP surfaces, so no torch wheel or GPU is needed.
# Keeps the lucebox Python honest on every push.
run: uv run --frozen --extra dev pytest lucebox -q
Comment thread
davide221 marked this conversation as resolved.

- name: Smoke-test lucebox.sh wrapper
# Catches `set -u` regressions, syntax errors, and stale dispatch
# handlers in the host-side wrapper + the in-container entrypoint.
# Runs shellcheck --severity=error across every shipped .sh file,
# exercises every subcommand dispatch under `set -u`, and drives the
# entrypoint's draft-resolution block through every family-glob
# branch — all on the bare runner without docker/nvidia/systemd.
run: bash scripts/test_lucebox_sh.sh

build:
name: Build (cmake + uv sync --extra megakernel)
runs-on: ubuntu-latest
Expand Down
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ RUN cd /src/server/build \
# of these reuses the cached CUDA layers above and only re-runs the
# runtime stage's uv sync (~70s) instead of the full ~25-minute build.
#
# Host-side Python tooling (lucebox/, harness/) is intentionally not copied
# here: this image is the server. Such tooling can layer on top later via a
# follow-up COPY directive or a runtime bind-mount during dev.
# The lucebox CLI is a workspace member (root pyproject + uv.lock), so its
# source must be present for `uv sync --frozen` in the runtime stage. It runs
# inside the container — the host wrapper `docker exec`s into it.
COPY pyproject.toml uv.lock README.md /src/
COPY server/pyproject.toml server/README.md /src/server/
COPY server/scripts /src/server/scripts
COPY optimizations/pflash /src/optimizations/pflash
COPY optimizations/megakernel /src/optimizations/megakernel
COPY lucebox/pyproject.toml lucebox/README.md /src/lucebox/
COPY lucebox/src /src/lucebox/src

# ─── Stage 2: runtime ───────────────────────────────────────────────────────
# Runtime image: ships nvidia driver libs but no nvcc / dev headers. Matches
Expand Down Expand Up @@ -179,9 +181,9 @@ COPY --from=builder /src/optimizations/megakernel/pyproject.toml \
/src/optimizations/megakernel/README.md \
/opt/lucebox-hub/optimizations/megakernel/

# Host-side Python tooling (lucebox/, harness/) is intentionally absent
# here: this image is the server base layer. Such tooling can layer on top
# later via a follow-up COPY directive or a runtime bind-mount during dev.
# The lucebox CLI package (a workspace member) — installed by the uv sync
# below and invoked in-container by the host wrapper via `docker exec`.
COPY --from=builder /src/lucebox /opt/lucebox-hub/lucebox

# server: ship the entrypoint/benchmark scripts, the pyproject + README that uv
# resolves against, and the pruned build tree (binaries + .so files from the
Expand All @@ -204,7 +206,12 @@ COPY --from=builder /src/server/build /opt/lucebox-hub/server/build
# server/share/model_cards. The canonical copy also lives at
# /opt/lucebox-hub/share/model_cards for any host-side tooling.
COPY share/model_cards /opt/lucebox-hub/share/model_cards
# Dedicated targets for narrow, read-only binds when a selected model is a
# symlink to storage outside the main models directory.
RUN mkdir -p /opt/lucebox-hub/server/share \
/opt/lucebox-resolved/target \
/opt/lucebox-resolved/draft \
/opt/lucebox-resolved/draft-dir \
&& ln -s /opt/lucebox-hub/share/model_cards \
/opt/lucebox-hub/server/share/model_cards

Expand Down
10 changes: 10 additions & 0 deletions Dockerfile.rocm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ COPY server/pyproject.toml server/README.md /src/server/
COPY server/scripts /src/server/scripts
COPY optimizations/pflash /src/optimizations/pflash
COPY optimizations/megakernel /src/optimizations/megakernel
COPY lucebox/pyproject.toml lucebox/README.md /src/lucebox/
COPY lucebox/src /src/lucebox/src

# ─── Stage 2: runtime ───────────────────────────────────────────────────────
# Runtime reuses the ROCm base so the HIP runtime libs (libamdhip64,
Expand Down Expand Up @@ -171,13 +173,21 @@ COPY --from=builder /src/optimizations/megakernel/pyproject.toml \
/src/optimizations/megakernel/README.md \
/opt/lucebox-hub/optimizations/megakernel/

# The lucebox CLI is a workspace member and must be present before uv sync.
COPY --from=builder /src/lucebox /opt/lucebox-hub/lucebox

COPY --from=builder /src/server/scripts /opt/lucebox-hub/server/scripts
COPY --from=builder /src/server/pyproject.toml /src/server/README.md \
/opt/lucebox-hub/server/
COPY --from=builder /src/server/build /opt/lucebox-hub/server/build

COPY share/model_cards /opt/lucebox-hub/share/model_cards
# Dedicated targets for narrow, read-only binds when a selected model is a
# symlink to storage outside the main models directory.
RUN mkdir -p /opt/lucebox-hub/server/share \
/opt/lucebox-resolved/target \
/opt/lucebox-resolved/draft \
/opt/lucebox-resolved/draft-dir \
&& ln -s /opt/lucebox-hub/share/model_cards \
/opt/lucebox-hub/server/share/model_cards

Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,35 @@ Reference target: **RTX 3090 (Ampere sm_86)** — all headline numbers. Other NV

`server/` (DFlash) builds with CMake 3.18+ and vendors the required `ggml` sources directly; only `Block-Sparse-Attention` remains a git submodule. No PyTorch is needed for `server/`. `optimizations/megakernel/` is the only component requiring PyTorch 2.0+ (CUDAExtension links against torch C++ libs). Power-tune: `sudo nvidia-smi -pl 220` (3090 sweet spot, re-sweep for other cards).

## Lucebox CLI

The easiest path for both Lucebox buyers and open-source users is one command:

```bash
# Buyers receive this preinstalled. Other users install the small host wrapper:
curl -fsSL https://raw.githubusercontent.com/Luce-Org/lucebox/main/install.sh | bash

lucebox
```

`lucebox` opens the branded menu. **Quick setup** detects NVIDIA CUDA or AMD
ROCm, lets you choose and download a model, applies safe hardware-aware
optimizations, and starts the inference service. Wi-Fi and device provisioning
are intentionally outside this inference-only CLI.

Contributors can open the same menu from a repository checkout with
`./lucebox.sh`. Its **Developer tools** can build and run the native C++ engine
or launch Claude Code, Codex, OpenCode, Hermes, Pi, OpenClaw, and Open WebUI
harnesses. Every menu action also has a scriptable command, for example:

```bash
lucebox models select
lucebox optimize --yes
lucebox start
./lucebox.sh build cuda
./lucebox.sh native cuda
```

## Quick Start On Harnesses

[`harness/`](harness/) contains RTX 3090 client launchers and regression tests
Expand Down
152 changes: 152 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
# install.sh — Bootstrap installer for the lucebox host wrapper.
#
# Canonical install (Luce-Org main, stable channel):
#
# curl -fsSL https://raw.githubusercontent.com/Luce-Org/lucebox/main/install.sh | bash
#
# Install from a different fork / branch (dev channel). Note the env var
# is on the `bash` side of the pipe — `VAR=val curl … | bash` would attach
# it to the `curl` process, leaving `bash` with the canonical default:
#
# curl -fsSL https://raw.githubusercontent.com/easel/lucebox-hub/feat/lucebox-docker/install.sh | \
# LUCEBOX_INSTALL_URL=https://raw.githubusercontent.com/easel/lucebox-hub/feat/lucebox-docker/lucebox.sh bash
#
# The installer bakes the source URL into the installed `lucebox.sh` as
# `LUCEBOX_INSTALLED_FROM=...`, so `lucebox update` later re-pulls from the
# same channel without the user having to remember which fork they used.
#
# Override the install destination via $LUCEBOX_INSTALL_DEST (default
# $HOME/.local/bin/lucebox). This is what `lucebox update` uses to replace
# the file in place.

set -euo pipefail

LUCEBOX_INSTALL_URL="${LUCEBOX_INSTALL_URL:-https://raw.githubusercontent.com/Luce-Org/lucebox/main/lucebox.sh}"
DEST="${LUCEBOX_INSTALL_DEST:-$HOME/.local/bin/lucebox}"

# ── helpers ───────────────────────────────────────────────────────────────
C_OK=$'\033[1;32m' ; C_ERR=$'\033[1;31m' ; C_DIM=$'\033[2m' ; C_RST=$'\033[0m'
if [ ! -t 1 ] || [ "${NO_COLOR:-}" ]; then
C_OK="" ; C_ERR="" ; C_DIM="" ; C_RST=""
fi
info() { printf '%s[install]%s %s\n' "$C_DIM" "$C_RST" "$*"; }
ok() { printf '%s[install] ✓%s %s\n' "$C_OK" "$C_RST" "$*"; }
die() { printf '%s[install] ✗%s %s\n' "$C_ERR" "$C_RST" "$*" >&2; exit 1; }

command -v curl >/dev/null 2>&1 || die "curl is required (apt-get install curl)"

sha256_file() {
Comment thread
davide221 marked this conversation as resolved.
local sum
if command -v sha256sum >/dev/null 2>&1; then
sum=$(sha256sum "$1")
elif command -v shasum >/dev/null 2>&1; then
sum=$(shasum -a 256 "$1")
else
die "checksum requested, but neither sha256sum nor shasum is installed"
fi
sum="${sum%% *}"
printf '%s' "$sum" | tr '[:upper:]' '[:lower:]'
}

# ── decide what gets baked in as the persisted channel ───────────────────
# Do this before fetching so a SHA-pinned URL is refused for the intended
# reason even when that remote object is unavailable.
channel_url="${LUCEBOX_INSTALL_CHANNEL:-}"
if [ -z "$channel_url" ]; then
# A full 40-char SHA is what `git rev-parse HEAD` and GitHub raw URLs use.
# Shorter hex-like path segments may be branch names, so don't reject them.
if [[ "$LUCEBOX_INSTALL_URL" =~ /[0-9a-fA-F]{40}/[^/]+\.sh$ ]]; then
die "$(cat <<EOM
LUCEBOX_INSTALL_URL is SHA-pinned ($LUCEBOX_INSTALL_URL).
Persisting that as LUCEBOX_INSTALLED_FROM would freeze \`lucebox update\`
to that specific commit forever. Set LUCEBOX_INSTALL_CHANNEL to the
branch URL you want \`update\` to track, e.g.:

curl -fsSL <sha-pinned>/install.sh | \\
LUCEBOX_INSTALL_URL=<sha-pinned>/lucebox.sh \\
LUCEBOX_INSTALL_CHANNEL=https://raw.githubusercontent.com/<org>/<repo>/<branch>/lucebox.sh \\
bash
EOM
)"
fi
channel_url="$LUCEBOX_INSTALL_URL"
fi

# ── fetch ─────────────────────────────────────────────────────────────────
tmp=$(mktemp -t lucebox.XXXXXX) || die "couldn't create temp file"
# shellcheck disable=SC2064 # we want $tmp expanded now, not at trap time
trap "rm -f '$tmp' '$tmp.baked'" EXIT
info "fetching $LUCEBOX_INSTALL_URL"
curl --connect-timeout 10 --max-time 120 -fsSL "$LUCEBOX_INSTALL_URL" -o "$tmp" \
|| die "download failed from $LUCEBOX_INSTALL_URL"

# Release automation can pin the exact wrapper payload. This is optional for
# branch-channel installs, where the URL intentionally moves over time.
expected_sha="${LUCEBOX_WRAPPER_SHA256:-}"
if [ -n "$expected_sha" ]; then
[[ "$expected_sha" =~ ^[0-9a-fA-F]{64}$ ]] \
|| die "LUCEBOX_WRAPPER_SHA256 must be exactly 64 hexadecimal characters"
actual_sha=$(sha256_file "$tmp")
expected_sha=$(printf '%s' "$expected_sha" | tr '[:upper:]' '[:lower:]')
[ "$actual_sha" = "$expected_sha" ] \
|| die "wrapper checksum mismatch (expected $expected_sha, got $actual_sha)"
ok "wrapper sha256 verified"
fi

# ── sanity check ──────────────────────────────────────────────────────────
# Refuse to install something that isn't recognizably lucebox.sh. Catches
# 404 pages, redirects to HTML, and accidental URL typos.
head -1 "$tmp" | grep -q '^#!/usr/bin/env bash$' \
|| die "downloaded file does not look like a bash script (got: $(head -1 "$tmp"))"
grep -q '^VERSION=' "$tmp" \
|| die "downloaded file is missing VERSION marker — not lucebox.sh?"

# Bake the channel URL into the file. Use a `|` delimiter since URLs
# contain `/`. The line is expected to exist in lucebox.sh with a `:-`
# default; we rewrite the whole assignment.
#
# The URL ends up inside a bash double-quoted literal in the installed
# script, so any of $ ` " \ in `channel_url` would break the installed
# file (or worse, allow command substitution to run at next sourcing).
# Validate that the URL is plain http(s)+ASCII-URL-safe characters; we
# don't expect arbitrary content here, only an upstream raw.github URL
# (or a forked equivalent). Escape the sed metachars (\&|) separately so
# the substitution itself round-trips.
case "$channel_url" in
*['"$`\']*) die "channel URL contains unsafe characters: $channel_url" ;;
esac
escaped_url=$(printf '%s' "$channel_url" | sed 's/[\\&|]/\\&/g')
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
sed "s|^LUCEBOX_INSTALLED_FROM=.*|LUCEBOX_INSTALLED_FROM=\"$escaped_url\"|" "$tmp" > "$tmp.baked"
mv "$tmp.baked" "$tmp"
grep -Fqx "LUCEBOX_INSTALLED_FROM=\"$channel_url\"" "$tmp" \
|| die "failed to bake install source into the downloaded script"

# ── install ───────────────────────────────────────────────────────────────
mkdir -p "$(dirname "$DEST")"
chmod +x "$tmp"
mv "$tmp" "$DEST"
trap - EXIT
ok "installed lucebox → $DEST"
info " fetched from: $LUCEBOX_INSTALL_URL"
info " update channel: $channel_url"
if [ "$LUCEBOX_INSTALL_URL" != "$channel_url" ]; then
info " (lucebox update will track the channel URL, not the fetch URL)"
fi

# ── PATH hint ─────────────────────────────────────────────────────────────
case ":${PATH:-}:" in
*":$(dirname "$DEST"):"*) ;;
*) info " hint: add $(dirname "$DEST") to PATH so 'lucebox' is on the path" ;;
esac

cat <<EOF

Next:
${C_DIM}lucebox${C_RST} open the guided setup and inference menu

For automation:
${C_DIM}lucebox check${C_RST} verify Docker + NVIDIA CUDA or AMD ROCm
${C_DIM}lucebox setup${C_RST} run guided setup directly
${C_DIM}lucebox update${C_RST} re-run this installer to fetch the latest lucebox.sh
EOF
59 changes: 59 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# lefthook.yml — git hook config for the lucebox-hub monorepo.
#
# Install once per checkout:
#
# # Option A: standalone binary (recommended)
# curl -sSfL https://raw.githubusercontent.com/evilmartians/lefthook/master/install.sh | sh
# lefthook install
#
# # Option B: via npm
# npm install -g lefthook && lefthook install
#
# After `lefthook install`, git's hook dir is wired so the pre-commit
# block below fires on every `git commit`. Skip a one-off with
# `LEFTHOOK=0 git commit ...`.
#
# What we enforce here is the same surface CI does — keeping commits
# from breaking the bash scripts that ship with the image. The goal is
# specifically to prevent another `unbound variable` regression like the
# DRAFT_FAMILY_GLOB / LUCEBOX_HOST_HAS_SYSTEMD ones from landing.

pre-commit:
parallel: true
commands:
shellcheck:
# Run shellcheck on every staged *.sh file with the same
# `--severity=error` gate the CI test runner uses
# (scripts/test_lucebox_sh.sh). Warning-level findings are
# informational; errors fail the commit.
#
# `--external-sources` lets shellcheck follow `source` directives
# — needed for harness/clients/common.sh consumers. The exclude
# below skips vendored llama.cpp scripts under server/deps/ so we
# don't trip on upstream style.
glob: "**/*.sh"
exclude:
- "server/deps/**"
run: shellcheck --severity=error --external-sources {staged_files}

bash-parse:
# `bash -n` catches syntax errors that shellcheck can miss when
# configured to error-only. Cheap second pass — runs in parallel.
glob: "**/*.sh"
exclude:
- "server/deps/**"
run: |
rc=0
for f in {staged_files}; do
bash -n "$f" || rc=1
done
exit "$rc"

# pre-push runs the full bash smoke test — more thorough, slower than
# pre-commit. Covers every subcommand dispatch under `set -u` plus the
# entrypoint's draft-resolution branches. Skip with `LEFTHOOK=0 git push`
# if you really need to push without local validation (CI still catches it).
pre-push:
commands:
bash-smoke:
run: bash scripts/test_lucebox_sh.sh
Loading