#!/usr/bin/env bash # Re-pin 4429a104f window step wrapper (copied from Darkwing's window-rows-177-185/w.sh): w.sh FILE TITLE CMD... runs CMD in REPO under a clean env (no ANTHROPIC_*, CLAUDE_*, # MOSAIC_* or pi variables), appends the title, command, output, exit code and date -u stamps to window/FILE, # prints the output, and exits with CMD's exit code. set -uo pipefail W=/mnt/storage/src/mosaic-stack/agents/sage/work/window-repin-4429a104f f="$W/$1"; title="$2"; shift 2 E=(env -i HOME="$HOME" PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin" LANG=C.UTF-8 XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=$XDG_RUNTIME_DIR/bus}") t0=$(date -u +%FT%T.%3NZ) { echo; echo "## $title"; echo "# start $t0"; echo "# command: (cd \$REPO && $*)"; } >> "$f" out=$(cd /mnt/storage/src/mosaic-stack && "${E[@]}" "$@" 2>&1); rc=$? printf '%s\n' "$out" >> "$f" echo "# exit $rc, end $(date -u +%FT%T.%3NZ)" >> "$f" printf '%s\n# exit %s\n' "$out" "$rc" exit $rc