CHATTO_REPO ?= ../chatto TAG ?= VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) CHATTO_VERSION := $(shell sed -n 's/^tag: //p' proto/CHATTO_VERSION) LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.chattoVersion=$(CHATTO_VERSION) PLATFORMS := linux/amd64 linux/arm64 darwin/arm64 .PHONY: build test test-integration test-contract skill-evals channel-evals sandbox vet proto vendor-proto emoji dist release docs-ref site site-publish site-push clean build: CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o chatline ./cmd/chatline test: go test ./... # Starts a throwaway Chatto in Docker (CHATLINE_IT_IMAGE overrides the image; # CHATLINE_IT_KEEP=1 leaves the container running for poking at). test-integration: go test -tags integration -count=1 -timeout 10m ./test/integration/... # Only the Chatto contract tests: assumptions about server behavior that # chatline relies on. Run against a new image before bumping the pin. test-contract: go test -tags integration -count=1 -timeout 10m -run '^TestChatto_' ./test/integration/... # Runs agents against a throwaway Chatto with each version of the skill and # grades what they did (test/skill-evals/README.md). Costs Claude tokens. skill-evals: go run ./test/skill-evals # The same, for `chatline channel`: each session gets one Chatto event and # the channel's MCP tools instead of the skill. channel-evals: go run ./test/skill-evals -mode channel # A throwaway Chatto on localhost to try things by hand: prints a login link # and writes a bot config to ~/.config/chatline/sandbox.json. Ctrl-C deletes # it. make sandbox CHATTO=0.5.0-rc.4 picks another Chatto version. sandbox: go run ./test/sandbox $(if $(CHATTO),-version $(CHATTO)) vet: go vet ./... @test -z "$$(gofmt -l $$(git ls-files '*.go' | grep -v '^gen/'))" || (gofmt -l $$(git ls-files '*.go' | grep -v '^gen/'); exit 1) proto: rm -rf gen buf generate # make vendor-proto TAG=v0.5.0-beta.N CHATTO_REPO=/path/to/chatto vendor-proto: @test -n "$(TAG)" || (echo "TAG is required"; exit 1) rm -rf proto/chatto for d in api realtime discovery; do \ git -C $(CHATTO_REPO) archive $(TAG) proto/chatto/$$d/v1 | tar -x --strip-components=1 -C proto; \ done find proto/chatto -name AGENTS.md -delete git -C $(CHATTO_REPO) show $(TAG):proto/buf.lock > proto/buf.lock printf 'tag: %s\ncommit: %s\n' $(TAG) $$(git -C $(CHATTO_REPO) rev-parse $(TAG)^{commit}) > proto/CHATTO_VERSION dist: rm -rf dist && mkdir -p dist for p in $(PLATFORMS); do \ CGO_ENABLED=0 GOOS=$${p%/*} GOARCH=$${p#*/} go build -trimpath -ldflags "$(LDFLAGS)" \ -o dist/chatline-$${p%/*}-$${p#*/} ./cmd/chatline || exit 1; \ done cd dist && sha256sum chatline-* > SHA256SUMS # make release VERSION=0.1.0 — tag (annotated, as Tangled artifacts require) and push. release: @test -n "$(VERSION)" || (echo "VERSION is required, e.g. make release VERSION=0.1.0"; exit 1) @test -z "$$(git status --porcelain)" || (echo "working tree is not clean"; exit 1) git tag -a v$(VERSION) -m "chatline v$(VERSION)" git push origin v$(VERSION) # Regenerate the emoji table from gemoji, the data Chatto uses (GEMOJI=x.y.z). GEMOJI ?= 8.1.0 emoji: tmp=$$(mktemp -d) && cd $$tmp && npm pack -s gemoji@$(GEMOJI) >/dev/null && tar xzf gemoji-$(GEMOJI).tgz && cd - >/dev/null && \ node tools/gen-emoji.mjs $$tmp/package > internal/emoji/gemoji_gen.go && cp $$tmp/package/license internal/emoji/LICENSE.gemoji && rm -rf $$tmp # Regenerate the site's command reference from the CLI's own help. docs-ref: go run ./tools/gen-docs site/src/content/docs/reference/commands # The docs site (Starlight) builds into site/dist. site: cd site && npm ci && npm run build # Build the site and publish it to the pages branch, which Tangled Sites serves. site-publish: site $(MAKE) site-push # Commit the already-built site/dist onto the pages branch and push it. The # branch holds only built output; each commit's parent is the last one # published. PAGES_REMOTE is a remote name or URL (CI pushes to the knot). PAGES_REMOTE ?= origin site-push: @test -f site/dist/index.html || (echo "site/dist isn't built; run make site"; exit 1) @test -z "$$(git status --porcelain)" || (echo "working tree is not clean"; exit 1) idx=$$(mktemp) && rm $$idx && \ tree=$$(cd site/dist && GIT_DIR=$$(git rev-parse --absolute-git-dir) GIT_WORK_TREE=. GIT_INDEX_FILE=$$idx sh -c 'git add -A && git write-tree') && \ rm -f $$idx && \ parent=$$(git fetch -q $(PAGES_REMOTE) pages 2>/dev/null && git rev-parse FETCH_HEAD || true) && \ commit=$$(git commit-tree $$tree $${parent:+-p $$parent} -m "Publish site from $(COMMIT)") && \ git push $(PAGES_REMOTE) $$commit:refs/heads/pages clean: rm -rf dist chatline site/dist