UV ?= uv
UV_RUN = $(UV) run --locked

.PHONY: help install lock lock-check format format-check lint lint-fix type-check test check dev hooks-install hooks-run test-launcher test-image

help:
	@printf '%s\n' \
		'install        Sync the uv environment, including development tools' \
		'lock           Resolve dependencies into uv.lock' \
		'format         Apply Ruff fixes and formatting' \
		'check          Check lock freshness, formatting, lint, types, and backend tests' \
		'dev            Start the existing React/FastAPI development launcher' \
		'hooks-install  Install optional local pre-commit checks' \
		'test-launcher  Exercise the Bash supervisor with local fixture processes' \
		'test-image     Build and smoke-test the backend Docker image'

install:
	$(UV) sync --locked

lock:
	$(UV) lock

lock-check:
	$(UV) lock --check

format:
	$(UV_RUN) ruff check --fix-only .
	$(UV_RUN) ruff format .

format-check:
	$(UV_RUN) ruff format --check .

lint:
	$(UV_RUN) ruff check .

lint-fix:
	$(UV_RUN) ruff check --fix .

type-check:
	$(UV_RUN) mypy

test:
	$(UV_RUN) pytest

check: lock-check format-check lint type-check test

dev:
	../start_ui.sh

hooks-install:
	$(UV_RUN) pre-commit install --install-hooks --config s2s-client/.pre-commit-config.yaml

hooks-run:
	$(UV_RUN) pre-commit run --all-files --config s2s-client/.pre-commit-config.yaml

test-launcher:
	npm --prefix ../s2s-frontend run test:launcher

test-image:
	bash scripts/test_docker_image.sh
