diff --git a/PLAN-OPERATOR-USB-NEXT.md b/PLAN-OPERATOR-USB-NEXT.md index d84dd8c4..dd452d21 100644 --- a/PLAN-OPERATOR-USB-NEXT.md +++ b/PLAN-OPERATOR-USB-NEXT.md @@ -624,12 +624,13 @@ and let that agent inspect the live system and the shipped source side by side. **Goal:** make the live USB self-debuggable without first cloning repositories over a possibly flaky network. -**Candidate layout:** +**Candidate layout:** keep the source snapshots under one operator-facing +folder so `$HOME` stays uncluttered: ```text -/home/clawdie/src/clawdie-iso -/home/clawdie/src/clawdie-ai -/home/clawdie/src/colibri +/home/clawdie/ai/clawdie-iso +/home/clawdie/ai/clawdie-ai +/home/clawdie/ai/colibri ``` **Implementation notes:** @@ -640,7 +641,7 @@ over a possibly flaky network. - Prefer the exact branch/commit used by the image build, recorded in `/usr/local/share/clawdie-iso/build-manifest.json` and visible from `hw-report`. -- The checkouts should be owned by `clawdie:clawdie` and readable/writable from +- The snapshots should be owned by `clawdie:clawdie` and readable/writable from XFCE terminals. - Keep provider authentication manual. The image may include code, but it must not bake provider credentials. diff --git a/build.sh b/build.sh index 7ea73173..cb2f1e36 100755 --- a/build.sh +++ b/build.sh @@ -802,6 +802,67 @@ install_live_npm_globals() { fi } +seed_live_ai_source_repo() { + _repo_src="$1" + _repo_name="$2" + _repo_dest="${MOUNT_POINT}/home/clawdie/ai/${_repo_name}" + + if [ ! -d "${_repo_src}" ]; then + echo " Skipping AI source seed ${_repo_name}: ${_repo_src} not found" + return 0 + fi + if ! command -v git >/dev/null 2>&1 || ! git -C "${_repo_src}" rev-parse --git-dir >/dev/null 2>&1; then + echo " Skipping AI source seed ${_repo_name}: not a git worktree" + return 0 + fi + + echo " Seeding AI source snapshot: ${_repo_name}" + rm -rf "${_repo_dest}" + mkdir -p "${_repo_dest}" + git -C "${_repo_src}" archive --format=tar HEAD | tar -C "${_repo_dest}" -xf - + + _repo_branch=$(git -C "${_repo_src}" symbolic-ref --short -q HEAD 2>/dev/null || echo detached) + _repo_commit=$(git -C "${_repo_src}" rev-parse HEAD 2>/dev/null || echo unknown) + _repo_origin=$(git -C "${_repo_src}" remote get-url origin 2>/dev/null || echo unknown) + _repo_dirty=false + if ! git -C "${_repo_src}" diff --quiet 2>/dev/null || ! git -C "${_repo_src}" diff --cached --quiet 2>/dev/null; then + _repo_dirty=true + fi + + cat > "${_repo_dest}/.clawdie-source.json" < "${MOUNT_POINT}/home/clawdie/ai/README.txt" <<'EOF' +Clawdie live AI source snapshots + +These directories are included so the operator can start a local provider-backed +Pi session from the live XFCE desktop and inspect the shipped source beside the +running system. + +No API keys, .env files, SSH private keys, build caches, package caches, tmp/ +directories, or uncommitted worktree changes are included. Each snapshot has a +.clawdie-source.json file recording the source remote, branch, commit, and dirty +state at image build time. +EOF + seed_live_ai_source_repo "${SCRIPT_DIR}" "clawdie-iso" + seed_live_ai_source_repo "${SCRIPT_DIR}/../clawdie-ai" "clawdie-ai" + seed_live_ai_source_repo "${SCRIPT_DIR}/../colibri" "colibri" + chroot "${MOUNT_POINT}" chown -R clawdie:clawdie /home/clawdie/ai +} + configure_live_operator_session() { echo " Configuring live operator session..." @@ -1152,6 +1213,8 @@ EOF "${MOUNT_POINT}/home/clawdie/Desktop/Clawdie Bootstrap.desktop" \ "${MOUNT_POINT}/home/clawdie/Desktop/Clawdie Hardware Report.desktop" + install_live_ai_source_snapshots + # The stock FreeBSD install memstick is intentionally read-only. This live # operator USB needs a writable root so SDDM, Xorg, NetworkMgr, logs, and # operator diagnostics can create runtime state on the flashed stick.