#!/usr/bin/env bash set -euo pipefail usage() { cat <<'USAGE' Usage: scripts/print-session-bootstrap.sh [--tool ] [--branch ] [--task-id ] [--gateway-url ] [--hostname ] Prints a ready-to-paste first message for Claude/Codex/Cursor/OpenClaw sessions. USAGE } TOOL="codex" BRANCH="main" TASK_ID="" GATEWAY_URL="http://100.64.0.45:8787" HOSTNAME_INPUT="" while [[ $# -gt 0 ]]; do case "$1" in --tool) TOOL="${2:-}" shift 2 ;; --branch) BRANCH="${2:-}" shift 2 ;; --task-id) TASK_ID="${2:-}" shift 2 ;; --gateway-url) GATEWAY_URL="${2:-}" shift 2 ;; --hostname) HOSTNAME_INPUT="${2:-}" shift 2 ;; -h|--help) usage exit 0 ;; *) echo "ERROR: unknown arg: $1" >&2 usage exit 1 ;; esac done REPO_ROOT="$(git rev-parse --show-toplevel)" ARGS=(--field all --tool "$TOOL") if [[ -n "$HOSTNAME_INPUT" ]]; then ARGS+=(--hostname "$HOSTNAME_INPUT") fi INFO="$($REPO_ROOT/scripts/resolve-machine-alias.sh "${ARGS[@]}")" hostname_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="hostname"{print $2}')" alias_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="alias"{print $2}')" agent_id_v="$(printf '%s\n' "$INFO" | awk -F= '$1=="agent_id"{print $2}')" cat <