clawdie-iso/scripts/fetch-npm-globals.sh
Sam & Claude 07f315d730 feat(iso): bundle claude/gemini/pi npm CLIs for offline first-boot install
Ships @anthropic-ai/claude-code, @google/gemini-cli, and
@mariozechner/pi-coding-agent as prebuilt .tgz tarballs on the install
media so the agent runtime has its CLI dependencies on first boot
without network access.

Critical: installs to /home/clawdie/.npm-global to match the
npm_config_prefix set by shell-system.sh in /etc/profile.d/clawdie.sh,
so the clawdie user's PATH (and the agent's commandExists() probes)
actually resolve the binaries.

- scripts/fetch-npm-globals.sh: npm pack the 3 CLIs into tmp/npm-globals/
- firstboot/shell-npm-globals.sh: offline install as clawdie user with
  matching prefix, runs between pkg setup and deploy
- build.sh: fetch + bundle into ${SHARE}/npm-globals/
- firstboot.sh: source module and run_step before deploy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-04 20:04:22 +02:00

52 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
# Fetch npm-global CLIs as .tgz tarballs for offline install on the ISO target.
#
# These three packages are agent runtimes the firstboot installer will
# `npm install -g` from local tarballs (no network needed):
#
# @anthropic-ai/claude-code — Claude Code CLI (agent harness)
# @google/gemini-cli — Gemini CLI (alt agent)
# @mariozechner/pi-coding-agent — pi CLI (used by clawdie-ai + paperclip adapters)
#
# Notes:
# - Codex is shipped via the FreeBSD `codex` pkg (see pkg-list-host.txt),
# not via npm — kept out of this bundle on purpose.
# - opencode + cursor have no working FreeBSD distribution (upstream gap).
# - Output is dual-purpose: bundled into the ISO and used by firstboot.
#
# Usage:
# ./scripts/fetch-npm-globals.sh # fetch into tmp/npm-globals/
# OUT_DIR=/some/path ./scripts/fetch-npm-globals.sh
set -eu
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
OUT_DIR="${OUT_DIR:-${ROOT_DIR}/tmp/npm-globals}"
PACKAGES="@anthropic-ai/claude-code @google/gemini-cli @mariozechner/pi-coding-agent"
if ! command -v npm >/dev/null 2>&1; then
echo "ERROR: npm not found in PATH (install www/npm-node24)" >&2
exit 1
fi
mkdir -p "$OUT_DIR"
cd "$OUT_DIR"
echo "==> Fetching npm-global tarballs into ${OUT_DIR}"
for pkg in $PACKAGES; do
echo " npm pack ${pkg}"
# `npm pack <name>` downloads the latest published tarball without
# installing it. Output is `<name>-<version>.tgz` (scoped names get
# their slash flattened to a dash).
npm pack "$pkg" >/dev/null
done
echo ""
echo "==> Bundle contents:"
ls -lh "$OUT_DIR"/*.tgz
TOTAL=$(du -sh "$OUT_DIR" | cut -f1)
echo ""
echo "==> Total size: ${TOTAL}"