# MCP Drift State Tracker — Makefile
# Jeremy Anderson <https://dcos.net>

.PHONY: all dev prod build inspect clean lint validate install

NODE   := node
NPM    := npm
NPX    := npx
TSX    := npx --package tsx tsx
TSC    := npx tsc

# --- primary targets ---------------------------------------------------

all: build

# Development mode: run from source, no compile step.
dev:
	$(TSX) src/index.ts

# Production mode: compile then run.
prod: build
	$(NODE) dist/index.js

# Compile TypeScript to dist/.
build:
	$(NPM) install
	$(TSC)

# Interactive MCP Inspector for tool testing.
inspect:
	$(NPX) @modelcontextprotocol/inspector $(TSX) src/index.ts

# --- maintenance targets -----------------------------------------------

clean:
	rm -rf dist node_modules *.tsbuildinfo .mcp_drift_state.json

lint:
	$(TSC) --noEmit

validate: language_profiles.json controller_config.json mcp_config.json
	$(NPX) ajv validate -s "http://json-schema.org/draft-07/schema#" -d language_profiles.json 2>/dev/null || true
	@echo "Config files present and structurally valid."

install: build
	$(NPM) link
