FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
    curl jq unzip git \
    && rm -rf /var/lib/apt/lists/*

# --- Node (installed here, not via devcontainer features, so `docker compose
#     build` works too — features only apply to the devcontainer CLI) ---
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*

# --- Claude Code CLI ---
RUN npm install -g @anthropic-ai/claude-code@latest

# --- Bun (runtime for antigravity-acp adapter) ---
RUN curl -fsSL https://bun.sh/install | bash \
    && ln -sf /root/.bun/bin/bun /usr/local/bin/bun \
    && ln -sf /root/.bun/bin/bunx /usr/local/bin/bunx

# --- Antigravity CLI (agy) so the in-container orchestrator can delegate to
#     Gemini. Auth comes from the mounted ~/.gemini at runtime. Best-effort:
#     the build won't fail if the installer can't resolve this arch. ---
RUN (curl -fsSL https://antigravity.google/cli/install.sh | bash) || true \
    && for d in /root/.local/bin /root/.antigravity/bin; do \
         if [ -x "$d/agy" ]; then install -m 0755 "$d/agy" /usr/local/bin/agy; fi; \
       done; true

# --- Antigravity headless permissions ---
RUN mkdir -p /home/vscode/.gemini/antigravity-cli \
    && echo '{"permissions":{"allow":["read_file(*)","write_file(*)","command(*)"]},"trustedWorkspaces":["/workspaces"]}' \
    > /home/vscode/.gemini/antigravity-cli/settings.json \
    && chown -R vscode:vscode /home/vscode/.gemini
