UV ?= uv

.PHONY: help install lint format test build clean docs schema

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

install:  ## Create venv and install with test extras
	$(UV) venv
	$(UV) pip install -e ".[dev,server,cli,cpu]"

lint:  ## Ruff check + format check
	$(UV)x ruff@0.15.16 check src/ tests/
	$(UV)x ruff@0.15.16 format --check src/ tests/

format:  ## Ruff autoformat + autofix
	$(UV)x ruff@0.15.16 format src/ tests/
	$(UV)x ruff@0.15.16 check --fix src/ tests/

test:  ## Run the test suite
	$(UV) run --no-sync pytest --tb=short -q

schema:  ## Regenerate the committed wire schema (CI fails if it drifts)
	$(UV) run --no-sync argus-puppet schema

docs:  ## Regenerate docs/cli.md from the Typer CLI (CI fails if it drifts)
	$(UV) pip install -e ".[cli]"
	mkdir -p docs
	$(UV) run --no-sync python -m typer argus_puppet.cli utils docs --name argus-puppet --output docs/cli.md

build:  ## Build sdist + wheel
	$(UV) build

clean:  ## Remove build + cache artifacts
	rm -rf dist build .venv *.egg-info .pytest_cache .ruff_cache src/argus_puppet/_version.py
