# https://just.systems

default: run

# Start dev server with hot reload
run:
    uv run uvicorn server:app --host 0.0.0.0 --port 8800 --reload

# Install/sync dependencies
sync:
    uv sync

# Build Docker image
docker-build:
    docker build -t kitmaker .

# Run in Docker
docker-run:
    docker run -p 8800:8800 kitmaker

# Kill server, clean cache DB, start fresh
restart:
    pkill -f "uvicorn server:app" || true
    sleep 1
    rm -f cache.db cache.db-shm cache.db-wal
    uv run uvicorn server:app --host 0.0.0.0 --port 8800 &
    sleep 2
    curl -s http://localhost:8800/api/ping

# Clean cache DB and __pycache__
clean:
    rm -f cache.db cache.db-shm cache.db-wal
    find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null

# Install Playwright browsers
install-browsers:
    PLAYWRIGHT_BROWSERS_PATH=/usr/local/share/ms-playwright uv run python -m playwright install chromium || true

# Run tests (API only, no browser needed)
test:
    uv run python -m pytest tests/ -v -k "TestAPI"

# Run full tests (API + UI, requires Playwright browsers)
test-full:
    PLAYWRIGHT_BROWSERS_PATH=/usr/local/share/ms-playwright uv run python -m pytest tests/ -v

# Run UI tests only
test-ui:
    uv run python -m pytest tests/ -v -k "TestFrontend"

# Run BDD tests (requires server running)
test-bdd:
    uv run behave features/ -v

# Run BDD: UI architecture only
test-bdd-ui:
    uv run behave features/ui-components.feature features/component-library.feature features/audio-engine.feature -v
