# Simple developer Makefile for can-you-assist
# Focus: easy dev-head install and common tasks

.PHONY: dev-install install test clean dist version release-prep check-dist

# Install the package in editable mode from the current source
# This is the recommended way to work on the latest code
dev-install:
	pip install -e ".[dev]"

# Standard install (for comparison / released packages later)
install:
	pip install .

# Run the test suite
test:
	python3 -m pytest tests/ -q

# Clean build artifacts
clean:
	rm -rf build/ dist/ *.egg-info/ src/cya/_version.py
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true

# Build distribution packages (sdist + wheel)
dist: clean
	python -m build

# Show current version (useful after setuptools_scm changes)
version:
	python3 -c "import cya; print(cya.__version__)"

# Prepare for a release (run tests + build clean artifacts)
release-prep: clean test dist
	@echo ""
	@echo "Release artifacts ready in dist/"
	@echo "Next steps: create annotated git tag and push it."

# Verify the built wheel in an isolated environment
check-dist:
	@echo "Testing wheel in fresh venv..."
	@python3 -m venv /tmp/cya-dist-check
	@/tmp/cya-dist-check/bin/pip install dist/can_you_assist-*.whl --quiet
	@/tmp/cya-dist-check/bin/cya --version
	@rm -rf /tmp/cya-dist-check
	@echo "Wheel verification successful."