.PHONY: install dev lint fmt test test-unit test-integration golden dashboard-build dashboard-run example clean build

# Default shell
SHELL := /bin/bash

install: ## Install runtime deps
	uv sync

dev: install ## Install with dev tools
	uv sync --dev

lint: ## Ruff over engine, tests, scripts, plugins
	uv run ruff check src tests scripts examples/plugins

fmt: ## Auto-fix lint findings
	uv run ruff check --fix src tests scripts examples/plugins

test: ## Full test suite (skips live emulator probes unless env set)
	uv run pytest

test-unit: ## Fast unit slice only
	uv run pytest tests/unit

test-integration: ## Integration slice only
	uv run pytest tests/integration

golden: ## Run only the generator contract tests
	uv run pytest tests/unit/test_golden_generation.py -v

dashboard-build:
	cd dashboard && npm install && npm run build

dashboard-run: ## Serve dashboard against a workspace
	CLOUDPORT_WORKSPACE=$(CLOUDPORT_WORKSPACE) cd dashboard && npm start

example: ## Analyze + score the demo app
	cd examples/aws-production && uv run --project ../.. cloudport analyze . && uv run --project ../.. cloudport score

build: ## Build distributable wheel/sdist
	uv build

clean: ## Remove caches and local runtime artifacts
	rm -rf .pytest_cache .ruff_cache dist build *.egg-info
	find . -type d -name __pycache__ -not -path "./.venv/*" -exec rm -rf {} +
	rm -rf examples/*/cloudport-generated examples/*/.cloudport/envs 2>/dev/null || true
