# Rapport de couverture des tests Python
coverage:
	python3 -m coverage run -m pytest
	python3 -m coverage html -d docs/coverage_report

CAD_STACK ?= ./tools/hw/cad_stack.sh
CAD_ARGS ?=

.PHONY: coverage fw hw s0 lots-status lots-run docs compliance cad-up cad-down cad-ps cad-build cad-doctor cad-mcp cad-kicad cad-freecad cad-openscad cad-pio

s0:
	python3 tools/cockpit/cockpit.py gate_s0

fw:
	python3 tools/cockpit/cockpit.py fw

lots-status:
	python3 tools/cockpit/cockpit.py lots-status

lots-run:
	python3 tools/cockpit/cockpit.py lots-run

hw:
	@echo "usage: make hw SCHEM=hardware/kicad/<p>/<p>.kicad_sch"
	bash tools/hw/hw_check.sh $(SCHEM)

docs:
	python3 -m pip install -U mkdocs
	mkdocs build --strict

compliance:
	python3 tools/compliance/validate.py --strict

cad-up:
	$(CAD_STACK) up $(CAD_ARGS)

cad-down:
	$(CAD_STACK) down

cad-ps:
	$(CAD_STACK) ps

cad-build:
	$(CAD_STACK) build $(CAD_ARGS)

cad-doctor:
	$(CAD_STACK) doctor

cad-mcp:
	$(CAD_STACK) mcp $(CAD_ARGS)

cad-kicad:
	@if [ -z "$(CAD_ARGS)" ]; then echo "usage: make cad-kicad CAD_ARGS='version'"; exit 1; fi
	$(CAD_STACK) kicad-cli $(CAD_ARGS)

cad-freecad:
	@if [ -z "$(CAD_ARGS)" ]; then echo "usage: make cad-freecad CAD_ARGS='-c \"import FreeCAD; print(FreeCAD.Version())\"'"; exit 1; fi
	$(CAD_STACK) freecad-cmd $(CAD_ARGS)

cad-openscad:
	@if [ -z "$(CAD_ARGS)" ]; then echo "usage: make cad-openscad CAD_ARGS='--version'"; exit 1; fi
	$(CAD_STACK) openscad $(CAD_ARGS)

cad-pio:
	@if [ -z "$(CAD_ARGS)" ]; then echo "usage: make cad-pio CAD_ARGS='system info'"; exit 1; fi
	$(CAD_STACK) pio $(CAD_ARGS)

# ── Aperant (autonomous multi-agent framework) ──────────────────
APERANT_BRIDGE := bash tools/cockpit/aperant_bridge.sh

.PHONY: aperant-status aperant-install aperant-dev aperant-start aperant-build aperant-test aperant-update

aperant-status:
	$(APERANT_BRIDGE) status

aperant-install:
	$(APERANT_BRIDGE) install

aperant-dev:
	$(APERANT_BRIDGE) dev

aperant-start:
	$(APERANT_BRIDGE) start

aperant-build:
	$(APERANT_BRIDGE) build

aperant-test:
	$(APERANT_BRIDGE) test

aperant-update:
	$(APERANT_BRIDGE) update

aperant-web-install:
	$(APERANT_BRIDGE) web-install

aperant-web-dev:
	$(APERANT_BRIDGE) web-dev

aperant-web-build:
	$(APERANT_BRIDGE) web-build

aperant-deploy:
	$(APERANT_BRIDGE) deploy

aperant-tower-status:
	$(APERANT_BRIDGE) tower-status

aperant-tower-logs:
	$(APERANT_BRIDGE) tower-logs
