LPK_FILE = codeflow.lpk

.PHONY: all doctor verify build install release-prep clean

all: install

doctor:
	@echo "Checking Lazycat tooling..."
	@command -v lzc-cli >/dev/null 2>&1 || (echo "Error: lzc-cli is required" && exit 1)
	@lzc-cli box default >/dev/null
	@echo "Tooling looks available"

verify:
	@echo "Checking CodeFlow Lazycat scaffold..."
	@test -f package.yml
	@test -f lzc-build.yml
	@test -f lzc-manifest.yml
	@test -f build.sh
	@test -f Makefile
	@test -f lzc-icon.png
	@test -d docs/requirements
	@test -d docs/api-design
	@test -d docs/architecture
	@test -d docs/release-prep
	@node --test tests/*.test.mjs tests/html-inline-script-analysis.smoke.js
	@sh build.sh
	@rg -n "\./vendor/react.production.min.js|\./vendor/tree-sitter.js|\./vendor/tree-sitter-python.wasm" dist/web/index.html >/dev/null
	@test -f dist/web/vendor/tree-sitter.wasm
	@test -f dist/meta/package.yml
	@echo "Scaffold looks consistent"

build: doctor
	@sh build.sh
	lzc-cli project build -o $(LPK_FILE)

install: build
	lzc-cli app install $(LPK_FILE)

release-prep: verify
	@echo "Run make install and complete the post-install smoke test before distribution."

clean:
	@rm -rf dist $(LPK_FILE)
