#!/bin/bash
set -e

echo "Setting up workspace: ${WORKSPACE_NAME}"

# Backend setup
if [ -f "pyproject.toml" ]; then
    echo "Installing Python dependencies..."
    uv sync
fi

{% if frontend_path %}
# Frontend setup
if [ -f "{{ frontend_path }}/package.json" ]; then
    echo "Installing Node dependencies..."
    cd {{ frontend_path }} && pnpm install
    cd /workspace
fi
{% endif %}

{% if spec_path %}
# Prism generate (if spec exists)
if [ -f "{{ spec_path }}" ]; then
    echo "Running prism generate..."
    uv run prism generate --no-devcontainer || true
fi
{% endif %}

echo ""
echo "Workspace ready!"
echo "  URL: http://${WORKSPACE_NAME}.localhost"
echo "  Run 'claude' to start Claude Code"
echo ""
