# Makefile for langchain-agent-server

VERSION ?= $(shell grep '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/')

.PHONY: help
help: ## Show this help message
	@echo "Usage: make [target]"
	@echo ""
	@echo "Targets:"
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "  %-20s %s\n", $$1, $$2}'

.PHONY: clean
clean: ## Clean build artifacts
	@echo "Cleaning build artifacts..."
	rm -rf dist/ build/ *.egg-info src/*.egg-info
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	@echo "Clean complete"

.PHONY: build
build: clean ## Build package distribution
	@echo "Building version $(VERSION)..."
	uv build
	@echo "Build complete. Artifacts in dist/"

.PHONY: publish
publish: build ## Build and publish to PyPI
	@echo "Publishing version $(VERSION) to PyPI..."
	uv publish
	@echo "Publish complete"

.PHONY: publish-test
publish-test: build ## Build and publish to TestPyPI
	@echo "Publishing version $(VERSION) to TestPyPI..."
	uv publish --publish-url https://test.pypi.org/legacy/
	@echo "Publish complete"

.PHONY: install
install: ## Install package locally in development mode
	@echo "Installing in development mode..."
	uv pip install -e .
	@echo "Install complete"

.PHONY: test
test: ## Run tests
	@echo "Running tests..."
	uv run pytest
	@echo "Tests complete"

.PHONY: info
info: ## Display package information
	@echo "Package:  langchain-agent-server"
	@echo "Version:  $(VERSION)"
