.PHONY: help install sync lock test test-cov lint format typecheck build clean run-example

# Default target
help:
	@echo "Available targets:"
	@echo "  install    — create venv and install all dependencies (incl. dev)"
	@echo "  sync       — sync .venv to match uv.lock (no resolution)"
	@echo "  lock       — regenerate uv.lock from pyproject.toml"
	@echo "  test       — run the full test suite"
	@echo "  test-cov   — run tests with coverage report"
	@echo "  lint       — run ruff linter"
	@echo "  format     — format code with ruff"
	@echo "  typecheck  — run mypy"
	@echo "  build      — build wheel + sdist into dist/"
	@echo "  clean      — remove build artifacts, caches, .venv"
	@echo "  run-example NAME=01_hello_world — run a specific example"

install:
	unset PIP_INDEX_URL UV_DEFAULT_INDEX UV_INDEX && uv sync --all-extras

sync:
	unset PIP_INDEX_URL UV_DEFAULT_INDEX UV_INDEX && uv sync --all-extras

lock:
	unset PIP_INDEX_URL UV_DEFAULT_INDEX UV_INDEX && uv lock

test:
	uv run --frozen pytest tests/ --timeout=30

test-cov:
	uv run --frozen pytest tests/ --timeout=30 --cov=claude_interactive_sdk --cov-report=term-missing

lint:
	uv run --frozen ruff check src tests examples

format:
	uv run --frozen ruff format src tests examples

typecheck:
	uv run --frozen mypy src

build:
	uv build

clean:
	rm -rf .venv build dist *.egg-info .pytest_cache .ruff_cache .mypy_cache htmlcov .coverage
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true

run-example:
	@if [ -z "$(NAME)" ]; then \
		echo "Usage: make run-example NAME=01_hello_world"; \
		exit 1; \
	fi
	uv run --frozen python examples/$(NAME).py
