.DEFAULT_GOAL := help

.PHONY: help setup test lint install mcp-http mcp-stop

help: ## List available make targets
	@awk 'BEGIN {FS = ":.*## "}; /^[a-zA-Z0-9_.-]+:.*## / {printf "  %-16s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

setup: ## Sync dependencies and install the bridge CLI wrapper
	uv sync --all-groups
	uv tool install -e . --force

test: ## Run the test suite
	uv run pytest

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

install: ## Install the bridge CLI wrapper
	uv tool install -e . --force

mcp-http: ## Start MCP server in SSE mode (default port 8002)
	BRIDGE_MCP_PORT=$${BRIDGE_MCP_PORT:-8002} uv run python src/bridge/mcp_server/server.py --http

mcp-stop: ## Stop MCP server running on port 8002
	@lsof -ti:$${BRIDGE_MCP_PORT:-8002} | xargs -r kill -TERM && echo "MCP server stopped" || echo "No MCP server running on port $${BRIDGE_MCP_PORT:-8002}"
