.PHONY: test lint smoke install reload help

PYTHON ?= python3.11
LABEL  := com.p2ptb.fidus-uno

help:
	@echo "Fidus-Uno targets:"
	@echo "  test     — pytest tests/  (excludes integration)"
	@echo "  smoke    — config load + SDK import check"
	@echo "  reload   — launchctl kickstart the daemon"
	@echo "  status   — launchctl print + live agent state"

test:
	PYTHONPATH=. $(PYTHON) -m pytest tests/ -q -m 'not integration'

smoke:
	@PYTHONPATH=. $(PYTHON) -c "from p2ptb_agent.config import load; cfg = load('agent.toml'); print('agent_id =', cfg.identity.agent_id)"
	@PYTHONPATH=. $(PYTHON) -c "from p2ptb.client import Client; print('p2ptb.client OK')"

reload:
	launchctl kickstart -k gui/$$(id -u)/$(LABEL)

status:
	@launchctl print gui/$$(id -u)/$(LABEL) | grep -E 'state|pid' | head -4
	@echo '---'
	@curl -ks https://localhost:8766/agents | python3 -m json.tool | grep -B1 -A2 fidus-uno || true
