FROM python:3.13-slim-bookworm

# --- path layer (config-root; no hardcoded host paths) -------------------------------
ENV KIT_ROOT=/opt/kit
ENV KIT_DATA=/opt/kit/.data \
    PYTHONUNBUFFERED=1 \
    DEBIAN_FRONTEND=noninteractive

# --- OS deps + Node (for the two brain CLIs) -----------------------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates curl git gnupg libicu72 sqlite3 \
 && curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
 && apt-get install -y --no-install-recommends nodejs \
 && rm -rf /var/lib/apt/lists/*

# --- both brain CLIs (CLI-only doctrine; no provider SDKs for agent work) --------------
RUN npm install -g @openai/codex @anthropic-ai/claude-code

# --- the kit layer + the files it sources (copy the subset, not the whole tree) --------
WORKDIR ${KIT_ROOT}
COPY pyproject.toml AGENTS.md CLAUDE.md ${KIT_ROOT}/
COPY kitcore/       ${KIT_ROOT}/kitcore/
COPY brains/        ${KIT_ROOT}/brains/
COPY rules/         ${KIT_ROOT}/rules/
COPY memory/        ${KIT_ROOT}/memory/

# --- kitcore (config-root resolver) + minimal Python deps -----------------------------
RUN pip install --no-cache-dir -e . \
 && pip install --no-cache-dir -r brains/install/requirements-brain.txt

# Sign in through the chosen client using a private runtime volume.
ENTRYPOINT ["python", "/opt/kit/brains/brain.py"]
CMD ["codex"]
