# search-assistant - GCP Deployment
# Generated by: bedsheet deploy --target gcp

.PHONY: help setup test build deploy deploy-terraform logs clean tf-init tf-plan tf-apply tf-destroy dev-ui dev-ui-local

PROJECT = bedsheet-e2e-test
REGION = me-west1
SERVICE = search_assistant

help:
	@echo "search-assistant - GCP Deployment"
	@echo ""
	@echo "Commands:"
	@echo "  make setup          - Install dependencies"
	@echo "  make test           - Test agent locally with ADK"
	@echo "  make build          - Build container image"
	@echo "  make deploy         - Deploy via Cloud Build (quick)"
	@echo "  make deploy-terraform - Deploy via Terraform (full IaC)"
	@echo "  make logs           - View Cloud Run logs"
	@echo "  make clean          - Clean build artifacts"
	@echo ""
	@echo "Terraform Commands:"
	@echo "  make tf-init        - Initialize Terraform"
	@echo "  make tf-plan        - Plan infrastructure changes"
	@echo "  make tf-apply       - Apply infrastructure changes"
	@echo "  make tf-destroy     - Destroy infrastructure"
	@echo ""
	@echo "Development with ADK Dev UI:"
	@echo "  make dev-ui-local   - Run ADK Dev UI locally (http://localhost:8000)"
	@echo "  make dev-ui         - Deploy to Cloud Run with ADK Dev UI"

setup:
	pip install google-adk google-genai bedsheet

test:
	python -m google.adk.cli run agent.agent

build:
	docker build -t gcr.io/$(PROJECT)/$(SERVICE):latest .

# Quick deploy via Cloud Build (uses gcloud, no state management)
deploy:
	gcloud builds submit --config cloudbuild.yaml --project $(PROJECT)

# Full IaC deploy via Terraform (recommended for production)
deploy-terraform: tf-init tf-apply

logs:
	gcloud run logs read $(SERVICE) --region $(REGION) --project $(PROJECT)

clean:
	rm -rf __pycache__ agent/__pycache__ terraform/.terraform

# Terraform commands
tf-init:
	cd terraform && terraform init

tf-plan:
	cd terraform && terraform plan

tf-apply:
	cd terraform && terraform apply

tf-destroy:
	cd terraform && terraform destroy

# Development with ADK Dev UI
# These commands use ADK's built-in deployment with the Dev UI for testing
# The Dev UI includes: chat interface, execution trace, state inspector, evaluation tools

dev-ui-local:
	@echo "Starting ADK Dev UI locally..."
	@echo "Open http://localhost:8000 in your browser"
	@echo ""
	@echo "Note: Set GOOGLE_API_KEY in .env file or environment for Gemini API"
	@echo ""
	python -m google.adk.cli web .

dev-ui:
	@echo "Deploying to Cloud Run with ADK Dev UI..."
	@echo "This creates a SEPARATE service ($(SERVICE)-dev) for development testing."
	@echo "Your production deployment ($(SERVICE)) is NOT affected."
	@echo ""
	python -m google.adk.cli deploy cloud_run \
		--project $(PROJECT) \
		--region $(REGION) \
		--service_name $(SERVICE)-dev \
		--with_ui \
		.