-
Notifications
You must be signed in to change notification settings - Fork 242
feat(lucebox): hub CLI + autotune/sweep/profile + harness adapters + shell wrapper #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
easel
wants to merge
9
commits into
Luce-Org:main
Choose a base branch
from
easel:feat/lucebox-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
03713c5
feat(lucebox): hub CLI with autotune, sweep, profile, smoke + harness…
easel c59d22c
fix(harness): drop unused subprocess import in codex client (ruff F401)
easel 27d343a
fix(lucebox): host_info write skips missing dir; test expects refuse-…
easel e71a44d
test(lucebox): assert rc != 0 on multi-target refuse-to-auto-pick
easel 71139a5
refactor(lucebox): dedupe CLI/adapters/shell, fix tty regression, wir…
easel 829864d
refactor(lucebox): slim #335 to wrapper + launch/config/download core
easel 535ae55
test(lucebox): cover recommend_preset tiers in download (moved from a…
easel d9ca9f8
test(lucebox): cover docker_run serve-argv; lint lucebox; tidy slim l…
easel aeae314
refactor(lucebox): drop stack scaffolding from core (YAGNI)
easel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| #!/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-hub/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-hub/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)" | ||
|
|
||
| # ── 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.bak'" EXIT | ||
| info "fetching $LUCEBOX_INSTALL_URL" | ||
| curl -fsSL "$LUCEBOX_INSTALL_URL" -o "$tmp" \ | ||
| || die "download failed from $LUCEBOX_INSTALL_URL" | ||
|
|
||
| # ── 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?" | ||
|
|
||
| # ── decide what gets baked in as the persisted channel ─────────────────── | ||
| # `lucebox update` reads LUCEBOX_INSTALLED_FROM from the installed copy and | ||
| # re-fetches from it. Persisting a SHA-pinned URL is a footgun — every | ||
| # future update would re-install the same frozen SHA forever, defeating | ||
| # the point of `update`. So: | ||
| # | ||
| # 1. If $LUCEBOX_INSTALL_CHANNEL is set, that's the persisted URL | ||
| # (caller takes responsibility for picking a real branch URL). | ||
| # 2. Else if LUCEBOX_INSTALL_URL has a 40-char hex SHA segment, refuse | ||
| # to persist it — tell the user to set LUCEBOX_INSTALL_CHANNEL. | ||
| # Common case: someone curl'd from /raw/<sha>/ to bypass a stale CDN | ||
| # cache during dev; they meant for updates to track the branch. | ||
| # 3. Else persist LUCEBOX_INSTALL_URL as-is (branch or canonical main). | ||
| channel_url="${LUCEBOX_INSTALL_CHANNEL:-}" | ||
| if [ -z "$channel_url" ]; then | ||
| # Match a full 40-char hex SHA in the URL path, not the broader | ||
| # {7,40} range — a 7-39 char hex segment is more likely a branch | ||
| # name shaped like a short SHA (e.g. `feat/abc1234-hotfix`) than an | ||
| # actual SHA-pin. Keeping the gate at exactly 40 chars matches what | ||
| # `git rev-parse HEAD` emits and what `/raw/<sha>/` URLs from | ||
| # GitHub's CDN actually carry. | ||
| 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 | ||
|
|
||
| # 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') | ||
| sed "s|^LUCEBOX_INSTALLED_FROM=.*|LUCEBOX_INSTALLED_FROM=\"$escaped_url\"|" "$tmp" > "$tmp.baked" | ||
| mv "$tmp.baked" "$tmp" | ||
| grep -q "^LUCEBOX_INSTALLED_FROM=\"$escaped_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 check${C_RST} verify host prereqs (docker + NVIDIA CTK + driver) | ||
| ${C_DIM}lucebox install${C_RST} install the user systemd unit | ||
| ${C_DIM}lucebox start${C_RST} start the server | ||
| ${C_DIM}lucebox update${C_RST} re-run this installer to fetch the latest lucebox.sh | ||
| EOF | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.