#!/usr/bin/env bash # asandbox container entrypoint — normalize env, ensure dirs, run command set -euo pipefail # Ensure common agent config + install dirs exist (host mounts may be empty) mkdir -p \ "${HOME}/.claude" \ "${HOME}/.codex" \ "${HOME}/.config" \ "${HOME}/.local/bin" \ "${HOME}/.npm-global/bin" \ "${HOME}/.ssh" \ "${HOME}/.npm" \ "${HOME}/.gemini" \ "${HOME}/.cursor" \ 2>/dev/null || true export PATH="${HOME}/.local/bin:${HOME}/.npm-global/bin:/usr/local/bin:${PATH}" # npm prefix for user installs via installagent if command -v npm >/dev/null 2>&1; then npm config set prefix "${HOME}/.npm-global" >/dev/null 2>&1 || true fi # Git identity fallback so commits work without host gitconfig mount if [[ -n "${GIT_AUTHOR_NAME:-}" ]]; then git config --global user.name "${GIT_AUTHOR_NAME}" 2>/dev/null || true fi if [[ -n "${GIT_AUTHOR_EMAIL:-}" ]]; then git config --global user.email "${GIT_AUTHOR_EMAIL}" 2>/dev/null || true fi # Respect ASANDBOX_WORKDIR if set if [[ -n "${ASANDBOX_WORKDIR:-}" && -d "${ASANDBOX_WORKDIR}" ]]; then cd "${ASANDBOX_WORKDIR}" fi # Interactive shell banner _is_shell=0 if [[ $# -eq 0 || "${1:-}" == "bash" || "${1:-}" == "sh" || "${1:-}" == "bash" ]]; then _is_shell=1 fi if [[ "${ASANDBOX_BANNER:-0}" == "1" ]] || { [[ -t 0 ]] && [[ $_is_shell -eq 1 ]]; }; then if [[ "${ASANDBOX_QUIET:-0}" != "1" ]]; then echo "┌──────────────────────────────────────────────────┐" >&2 echo "│ asandbox — isolated agent environment │" >&2 echo "│ cwd: $(pwd)" >&2 echo "│ │" >&2 echo "│ installagent list │" >&2 echo "│ installagent # claude cursor opencode │" >&2 echo "│ # antigravity gemini … │" >&2 echo "└──────────────────────────────────────────────────┘" >&2 fi fi if [[ $# -eq 0 ]]; then exec bash -l fi # If launching bash login/interactive, keep as-is exec "$@"