.PHONY: help install test lint format typecheck demo dev status clean

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

install: ## Install all dependencies
	uv sync

test: ## Run all tests
	uv run pytest libs/maestro-ssot/tests/ -q
	uv run pytest libs/maestro-harness/tests/ -q
	uv run pytest libs/maestro-agents/tests/ -q
	uv run pytest libs/maestro-loop/tests/ -q
	uv run pytest tests/ -q

lint: ## Run ruff linter
	uv run ruff check .

format: ## Run ruff formatter
	uv run ruff format .

typecheck: ## Run mypy type checker
	uv run mypy libs/ src/maestro/

check: lint format typecheck test ## Run all checks (lint + format + typecheck + test)

demo: ## Run maestro demo
	uv run maestro demo

status: ## Run maestro status (requires project)
	uv run maestro status

dev: ## Hot-reload dev server (default: demo)
	python scripts/dev-server.py demo

dev-run: ## Hot-reload dev server with run --demo
	python scripts/dev-server.py run --demo "Build a JWT auth system"

dev-repl: ## Hot-reload dev server with REPL
	python scripts/dev-server.py

clean: ## Clean generated files
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type d -name .pytest_cache -exec rm -rf {} +
	find . -type d -name .mypy_cache -exec rm -rf {} +
	find . -type d -name .ruff_cache -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete
