-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
173 lines (144 loc) · 7.04 KB
/
Copy pathMakefile
File metadata and controls
173 lines (144 loc) · 7.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.PHONY: help preflight dev test test-go test-py test-ts lint lint-go lint-py lint-ts \
lint-migrations \
sdk-conformance worker-conformance \
build build-go build-cli build-runtime build-dashboard build-images \
install-cli smoke-cli \
up down logs clean install-deps fmt
# Default target
help:
@echo "BackAI - common development commands"
@echo ""
@echo " make install-deps Install all language-level deps (Go, Python, Node)"
@echo " make preflight Check local port conflicts before Docker starts"
@echo " make dev Start dev environment (docker-compose up + hot reload)"
@echo " make up docker-compose up -d"
@echo " make down docker-compose down"
@echo " make logs Tail docker-compose logs"
@echo " make test Run all test suites"
@echo " make test-go Run Go tests"
@echo " make test-py Run Python tests"
@echo " make test-ts Run TypeScript tests"
@echo " make sdk-conformance Live SDK conformance (py+ts) vs a running stack"
@echo " make worker-conformance Live worker-protocol conformance vs a running stack"
@echo " make lint Run all linters"
@echo " make fmt Auto-format all code"
@echo " make build Build all artifacts (CLI + runtime + dashboard)"
@echo " make build-cli Build the af-stack CLI -> bin/af-stack"
@echo " make install-cli Install the af-stack CLI onto your PATH (go install)"
@echo " make clean Remove build artifacts and caches"
install-deps:
@echo "==> Installing Go deps"
@go mod download 2>/dev/null || true
@echo "==> Installing Node deps"
@command -v pnpm >/dev/null && pnpm install || echo "pnpm not found, skipping"
@echo "==> Installing Python deps"
@command -v uv >/dev/null && uv sync || echo "uv not found, skipping"
preflight:
node scripts/preflight.mjs
dev: preflight
@echo "==> Starting docker-compose stack"
docker compose up
up: preflight
docker compose up -d
down:
docker compose down
logs:
docker compose logs -f
test: test-go test-py test-ts
@echo "==> All tests passed"
test-go:
@echo "==> Running Go tests"
@go test ./... 2>/dev/null || echo "(no Go packages yet)"
test-py:
@echo "==> Running Python tests"
@command -v uv >/dev/null && uv run pytest packages/sdk-py 2>/dev/null || echo "(no Python tests yet)"
test-ts:
@echo "==> Running TypeScript tests"
@command -v pnpm >/dev/null && pnpm -r test 2>/dev/null || echo "(no TS tests yet)"
# ─── Live conformance harnesses (run against a RUNNING stack) ──────────────
# Config: BASE_URL (default below) and API_KEY (optional in personal mode).
# Both harnesses emit a JSON summary on stdout and exit non-zero on any FAIL.
BASE_URL ?= http://localhost:8080
# sdk-conformance runs the Python AND TypeScript SDK harnesses back-to-back,
# proving both SDKs speak the same live wire contract (see scripts/sdk-conformance).
sdk-conformance:
@echo "==> SDK conformance (Python)"
@BASE_URL="$(BASE_URL)" API_KEY="$(API_KEY)" python3 scripts/sdk-conformance/run.py
@echo "==> SDK conformance (TypeScript)"
@pnpm --filter @af-stack/sdk build >/dev/null
@BASE_URL="$(BASE_URL)" API_KEY="$(API_KEY)" sh -c 'if command -v tsx >/dev/null 2>&1; then tsx scripts/sdk-conformance/run.ts; else node --experimental-strip-types scripts/sdk-conformance/run.ts; fi'
# worker-conformance enqueues the spec.json vector jobs and verifies their
# terminal states against a reference worker (see scripts/worker-conformance).
# WORKER=py|ts selects the reference worker language (default py).
worker-conformance:
@echo "==> Worker conformance (WORKER=$(or $(WORKER),py))"
@BASE_URL="$(BASE_URL)" API_KEY="$(API_KEY)" WORKER="$(or $(WORKER),py)" bash scripts/worker-conformance/run.sh
lint: lint-go lint-py lint-ts
@echo "==> Lint passed"
lint-go: lint-migrations
@echo "==> Linting Go"
@command -v golangci-lint >/dev/null && golangci-lint run ./... 2>/dev/null || echo "(golangci-lint not installed or no Go yet)"
@go vet ./... 2>/dev/null || echo "(no Go packages yet)"
# Static safety lint for goose migrations (Up/Down present, no unmarked
# destructive Up ops, balanced StatementBegin/End). Fails hard on any finding.
lint-migrations:
@echo "==> Linting migrations"
@go run ./services/runtime/cmd/migrationlint
lint-py:
@echo "==> Linting Python"
@command -v ruff >/dev/null && ruff check packages/sdk-py 2>/dev/null || echo "(ruff not installed or no Python yet)"
lint-ts:
@echo "==> Linting TypeScript"
@command -v pnpm >/dev/null && pnpm -r lint 2>/dev/null || echo "(pnpm not installed or no TS yet)"
fmt:
@echo "==> Formatting Go"
@gofmt -w . 2>/dev/null || true
@echo "==> Formatting Python"
@command -v ruff >/dev/null && ruff format packages/sdk-py 2>/dev/null || true
@echo "==> Formatting TS"
@command -v pnpm >/dev/null && pnpm -r format 2>/dev/null || true
build: build-cli build-runtime build-dashboard
@echo "==> Build complete"
# The af-stack CLI is the canonical, user-facing binary: `af-stack init`,
# `af-stack dev`, `af-stack agent new`, etc. It is the front door of the stack,
# so `bin/af-stack` resolves to the CLI (not the runtime server). This build is
# strict — a broken CLI fails the build rather than being silently skipped.
build-cli:
@echo "==> Building af-stack CLI -> bin/af-stack"
@mkdir -p bin
@go build -o bin/af-stack ./services/cli/cmd/af-stack
# The runtime server normally runs inside docker compose (its own Dockerfile
# builds /usr/local/bin/af-stack in-container). This target builds it for local,
# non-container runs under a distinct name so it can't shadow the CLI binary.
build-runtime:
@echo "==> Building af-stack runtime server -> bin/af-stack-runtime"
@mkdir -p bin
@go build -o bin/af-stack-runtime ./services/runtime/cmd/af-stack 2>/dev/null || echo "(runtime build skipped)"
# Back-compat alias for the old single Go build target.
build-go: build-cli build-runtime
# Put `af-stack` on your PATH (lands in $(go env GOBIN) or $(go env GOPATH)/bin).
install-cli:
@echo "==> Installing af-stack CLI via go install"
@go install ./services/cli/cmd/af-stack
@echo " Installed. Ensure your Go bin dir is on PATH, then run: af-stack help"
# Smoke-test that the built CLI is actually the CLI (regression guard for the
# binary-name collision: the front-door command must not error 'unknown command').
smoke-cli: build-cli
@echo "==> Smoke-testing bin/af-stack"
@bin/af-stack version
@bin/af-stack help >/dev/null
@bin/af-stack init --help >/dev/null 2>&1 || true
@echo " CLI smoke OK"
build-dashboard:
@echo "==> Building dashboard"
@command -v pnpm >/dev/null && pnpm --filter=dashboard build 2>/dev/null || echo "(dashboard not implemented yet)"
build-images:
@echo "==> Building docker images"
docker compose build
clean:
@echo "==> Cleaning build artifacts"
@rm -rf bin/ dist/ build/
@find . -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name .pytest_cache -prune -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name node_modules -prune -exec rm -rf {} + 2>/dev/null || true
@echo "Cleaned"