.PHONY: help install test test-phase3 coverage coverage-html lint type-check format clean dev

help:  ## Show this help message
	@echo "Blender Studio MCP - Development Commands"
	@echo ""
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

install:  ## Install package and dev dependencies
	uv pip install -e ".[dev]"

test:  ## Run all tests
	pytest -v

test-phase3:  ## Run Phase 3 tests only
	pytest tests/test_phase3.py -v

test-quick:  ## Run tests, skip slow ones
	pytest -v -m "not slow"

coverage:  ## Run tests with coverage report
	pytest --cov=blender_studio_mcp --cov-report=term-missing

coverage-html:  ## Generate HTML coverage report
	pytest --cov=blender_studio_mcp --cov-report=html
	@echo "Coverage report: htmlcov/index.html"

coverage-xml:  ## Generate XML coverage report (for CI)
	pytest --cov=blender_studio_mcp --cov-report=xml

lint:  ## Lint code with ruff
	ruff check .

lint-fix:  ## Lint and auto-fix issues
	ruff check --fix .

format:  ## Format code with ruff
	ruff format .

type-check:  ## Type check with pyright
	pyright

check-all: lint type-check test  ## Run all checks (lint, type-check, test)

clean:  ## Clean up generated files
	rm -rf htmlcov/
	rm -rf .pytest_cache/
	rm -rf .ruff_cache/
	rm -rf .coverage
	rm -rf coverage.xml
	rm -rf dist/
	rm -rf build/
	rm -rf *.egg-info
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete

dev:  ## Set up development environment
	@echo "Installing development dependencies..."
	uv pip install -e ".[dev]"
	@echo ""
	@echo "✅ Development environment ready!"
	@echo ""
	@echo "Quick start:"
	@echo "  make test          # Run tests"
	@echo "  make coverage-html # Generate coverage report"
	@echo "  make lint          # Check code style"
	@echo "  make help          # Show all commands"

watch-tests:  ## Watch for changes and re-run tests
	pytest-watch

build:  ## Build distribution packages
	python -m build

publish-test:  ## Publish to TestPyPI
	python -m twine upload --repository testpypi dist/*

publish:  ## Publish to PyPI
	python -m twine upload dist/*

.DEFAULT_GOAL := help
