.PHONY: build test test-live-mcp fmt release verify-release clean

VERSION ?= dev
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || printf unknown)
BUILD_DATE ?= $(shell git show -s --format=%cI HEAD 2>/dev/null || printf unknown)
LDFLAGS := -X main.version=$(patsubst v%,%,$(VERSION)) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)

build:
	mkdir -p bin
	go build -trimpath -ldflags "$(LDFLAGS)" -o bin/profilescribe-mcp ./cmd/profilescribe-mcp

test:
	go test ./...
	./scripts/test-release-inputs.sh
	python3 ./scripts/update-profile-scribe-release_test.py
	./scripts/promote-profile-scribe-release_test.sh
	./scripts/release-workflow-contract_test.sh

# Runs a read-only initialize handshake through the compiled stdio bridge.
# PROFILESCRIBE_MCP_URL may override the default https://profilescribe.com/api/mcp.
# The test replaces any ambient agent token with a fixed non-credential value.
test-live-mcp:
	PROFILESCRIBE_LIVE_MCP_COMPAT=1 go test -count=1 -run '^TestLiveInitializeCompatibility$$' -v ./cmd/profilescribe-mcp

fmt:
	gofmt -w cmd internal

release:
	./scripts/build-release.sh "$(VERSION)"

verify-release:
	./scripts/verify-release.sh "$(VERSION)"

clean:
	rm -rf bin dist
