.PHONY: help install lint format test test-integration run validate-audit docker-build clean

help:
	@echo "AegisGitea MCP - available targets"
	@echo "  make install           Install dependencies (uv sync)"
	@echo "  make lint              ruff check, ruff format --check, mypy"
	@echo "  make format            Format and autofix with ruff"
	@echo "  make test              Run unit tests with coverage"
	@echo "  make test-integration  Run integration tests (needs Docker)"
	@echo "  make run               Run the server (uses .env)"
	@echo "  make validate-audit    Verify audit log hash-chain integrity"
	@echo "  make docker-build      Build the Docker image"
	@echo "  make clean             Remove build artifacts and caches"

install:
	uv sync

lint:
	uv run ruff check .
	uv run ruff format --check .
	uv run mypy src

format:
	uv run ruff format .
	uv run ruff check --fix .

test:
	uv run pytest

test-integration:
	AEGIS_INTEGRATION=1 uv run pytest -m integration

run:
	uv run aegis-gitea-mcp serve

validate-audit:
	uv run python scripts/validate_audit_log.py

docker-build:
	docker build -f docker/Dockerfile -t aegis-gitea-mcp:dev .

clean:
	rm -rf build/ dist/ *.egg-info .pytest_cache/ .mypy_cache/ .ruff_cache/ .coverage htmlcov/
	find . -type d -name __pycache__ -not -path "./.venv/*" -exec rm -rf {} +
