# One command surface (InnerLoop §agentic-efficiency #3). Deterministic,
# greppable output; precursor of the `cb` CLI.

CARGO := cargo

.PHONY: check test sim bench deps loc all

## fmt + clippy (deny warnings) + HashMap deny-lint
check:
	$(CARGO) fmt --all --check
	$(CARGO) clippy --workspace --all-targets -- -D warnings

## unit + scenario-format tests
test:
	$(CARGO) test --workspace

## run all GROUND scenarios through cb-sim
sim:
	$(CARGO) run -q -p cb-sim -- scenarios/ground/*.yaml

## Criterion benches (AM-6/AM-7 wiring)
bench:
	$(CARGO) bench -p games-ground

## AM-4: transitive crate count (excludes dev/build deps)
deps:
	@$(CARGO) tree --workspace -e normal --prefix none | sed 's/ (\*)//' | sort -u | grep -vE '^(cb-|games-|cb_|$$)' | tee /dev/stderr | wc -l

## AM-2/AM-3 input: source LOC per crate (excludes tests would need tokei)
loc:
	@for d in crates/cb-kernel crates/cb-events crates/cb-game-runtime games/ground tools/cb-sim; do \
		printf '%-28s %s\n' $$d "$$(find $$d/src -name '*.rs' | xargs cat | grep -vcE '^\s*(//|$$)')"; \
	done

all: check test sim
