# Makefile for arborist-viz (Merkle Command Center) # Matches the remarkbox / make_post_sell idiom. VENV_DIR = $(shell pwd)/env DATA_DIR = $(shell pwd)/data CONFIG_FILE = development.ini PYTHON = $(VENV_DIR)/bin/python PIP = $(VENV_DIR)/bin/pip PSERVE = $(VENV_DIR)/bin/pserve PYTEST = $(VENV_DIR)/bin/pytest ALEMBIC = $(VENV_DIR)/bin/alembic INITDB = $(VENV_DIR)/bin/arborist_viz_init_db SIX_SRC = $(HOME)/git/cupPCB/cdn/six SIX_DST = arborist_viz/static/six .PHONY: all clean install install-dev test serve six commit-hash version help \ arborist seed demo # `make all` = production install + serve. # `make demo` = full demo pipeline (deps + arborist + seed shard + serve). all: install-dev six init-db serve help: @echo "arborist-viz make targets:" @echo " make install install package (production deps only)" @echo " make install-dev install package with dev + test extras" @echo " make six vendor six.js bundles from cupPCB/cdn/six" @echo " make init-db create dashboard metadata SQLite + run migrations" @echo " make serve run waitress on :6543 with development.ini" @echo " make test run pytest" @echo " make clean nuke venv, build artifacts, sqlite" @echo " make commit-hash write commit-hash.txt for /version endpoint" $(VENV_DIR)/bin/activate: @echo "Creating virtual environment in $(VENV_DIR)..." python3 -m venv $(VENV_DIR) $(PIP) install --upgrade pip 'setuptools<81' wheel venv: $(VENV_DIR)/bin/activate install: venv $(PIP) install -e . install-dev: venv arborist $(PIP) install -e '.[dev,test]' # arborist lives in a sibling git repo; install it editable into our venv # so arborist_viz/storage.py can import arborist.embed + arborist.merkle. # If arborist is unavailable, VIZ falls back to fixture mode automatically. ARBORIST_SRC = $(HOME)/git/arborist arborist: venv @if [ -d "$(ARBORIST_SRC)" ]; then \ echo "Installing arborist from $(ARBORIST_SRC)..."; \ $(PIP) install -e "$(ARBORIST_SRC)" >/dev/null; \ echo " -> arborist installed (editable)"; \ else \ echo "WARNING: $(ARBORIST_SRC) not found — VIZ will run in fixture mode."; \ fi # Create a small demo shard so dropping a hash actually visualizes. SEED_DB = $(DATA_DIR)/demo_arborist.db seed: install-dev @mkdir -p $(DATA_DIR) $(VENV_DIR)/bin/arborist_viz_seed_demo $(SEED_DB) demo: install-dev six seed init-db @echo "" @echo "================================================================" @echo " arborist-viz demo ready." @echo "" @echo " Seed shard: $(SEED_DB)" @echo " Sample hashes printed above ^^" @echo "" @echo " Edit development.ini -> arborist.shards = $(SEED_DB)" @echo " Or just: make serve-demo" @echo "================================================================" @echo "" serve-demo: install-dev six seed ARBORIST_VIZ_SHARDS=$(SEED_DB) $(PSERVE) --reload $(CONFIG_FILE) # Serve against the real arborist corpus on this host. We glob every # *.db file in the shards directory — arborist owns its own internal file # layout (document shards, provenance shard, future kinds added by # recursive falsification) and arborist.read tolerates any shard whose # tables don't match a given query. VIZ never names individual files. ARBORIST_SHARDS_DIR ?= $(HOME)/.arborist/shards # Also mount the local crawl db (web.db) so the VIZ can resolve and # display the chunk content of locally-crawled sources (a context root's # leaves reference docs that live there, not in the main shards). It is a # single file, well under SQLite's 10-attach cap; arborist.read tolerates # a missing file, so this is a no-op when nothing has been crawled. ARBORIST_CRAWL_DB ?= $(HOME)/.arborist/crawl/web.db ARBORIST_REAL_SHARDS = $(shell { ls $(ARBORIST_SHARDS_DIR)/*.db 2>/dev/null; [ -f $(ARBORIST_CRAWL_DB) ] && echo $(ARBORIST_CRAWL_DB); } | paste -sd,) serve-arborist: install-dev six @echo "Mounting shards from $(ARBORIST_SHARDS_DIR) ..." @echo " -> $(ARBORIST_REAL_SHARDS)" ARBORIST_VIZ_SHARDS=$(ARBORIST_REAL_SHARDS) $(PSERVE) --reload $(CONFIG_FILE) six: @echo "Vendoring six.js bundles from $(SIX_SRC) -> $(SIX_DST)..." @if [ ! -d "$(SIX_SRC)" ]; then \ echo "ERROR: $(SIX_SRC) not found — check ~/git/cupPCB checkout"; exit 1; \ fi @mkdir -p $(SIX_DST) @cp -v $(SIX_SRC)/six*.js $(SIX_DST)/ @# six.module.js + siblings have `import { ... } from './three.core.js'` @# — the companion three.* bundles MUST sit alongside them in /static/six/ @# or the browser fails to resolve the ES-module import. @cp -v $(SIX_SRC)/three*.js $(SIX_DST)/ commit-hash: @git rev-parse --short HEAD > commit-hash.txt 2>/dev/null || echo "0" > commit-hash.txt @echo "commit-hash.txt -> $$(cat commit-hash.txt)" init-db: install-dev @mkdir -p $(DATA_DIR) $(INITDB) $(CONFIG_FILE) serve: install-dev $(PSERVE) --reload $(CONFIG_FILE) test: install-dev $(PYTEST) -q version: @curl -s http://127.0.0.1:6543/version || echo "server not running" clean: rm -rf $(VENV_DIR) build dist *.egg-info rm -f data/arborist_viz.sqlite find . -type d -name __pycache__ -exec rm -rf {} +