Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
320 lines (275 loc) · 14.4 KB
/
Copy pathMakefile
File metadata and controls
320 lines (275 loc) · 14.4 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
SHELL := /bin/bash
CORE_DIR := packages/core
GOAL ?= fitness_plan
SESSION_ID ?=
SCENARIO ?=
.DEFAULT_GOAL := help
# ── Colors ────────────────────────────────────────────────────────────────────
BOLD := \033[1m
RESET := \033[0m
GREEN := \033[32m
CYAN := \033[36m
DIM := \033[2m
SAMPLES_REPO := https://github.com/amareshhebbar/TrueNorth-samples.git
SAMPLES_DIR := samples
SHELL := /bin/bash
define PRINT_LOGO
@echo ""
@printf "$(CYAN)"
@echo "████████╗██████╗ ██╗ ██╗███████╗ ███╗ ██╗ ██████╗ ██████╗ ████████╗██╗ ██╗"
@echo "╚══██╔══╝██╔══██╗██║ ██║██╔════╝ ████╗ ██║██╔═══██╗██╔══██╗╚══██╔══╝██║ ██║"
@echo " ██║ ██████╔╝██║ ██║█████╗ ██╔██╗ ██║██║ ██║██████╔╝ ██║ ███████║"
@echo " ██║ ██╔══██╗██║ ██║██╔══╝ ██║╚██╗██║██║ ██║██╔══██╗ ██║ ██╔══██║"
@echo " ██║ ██║ ██║╚██████╔╝███████╗ ██║ ╚████║╚██████╔╝██║ ██║ ██║ ██║ ██║"
@echo " ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝"
@printf "$(RESET)\n"
endef
.PHONY: help install dev stop chat dry-run validate cost \
test test-unit test-integration test-all \
test-node test-go test-rust test-expo \
migrate migrate-create format lint typecheck \
clean docker-build sample-clone sample-list sample-run
# ─────────────────────────────────────────────────────────────────────────────
# Help
# ─────────────────────────────────────────────────────────────────────────────
help:
@echo ""
$(call PRINT_LOGO)
@printf "$(BOLD)TrueNorth — AI Agent Framework$(RESET)\n"
@echo ""
@printf "$(CYAN)CONVERSATION$(RESET)\n"
@printf " make chat interactive chat (mock LLM, free)\n"
@printf " make chat GOAL=medical_intake chat with different goal\n"
@printf " make chat LIVE=1 chat with real LLM (needs API keys)\n"
@printf " make dry-run automated test run (no human input)\n"
@printf " make dry-run GOAL=medical_intake\n"
@printf " make dry-run SCENARIO=tests/fixtures/scenarios/fitness_happy_path.json\n"
@printf " make validate GOAL=fitness_plan validate YAML schema\n"
@echo ""
@printf "$(CYAN)SERVER$(RESET)\n"
@printf " make dev start API + Postgres + Redis (hot-reload)\n"
@printf " make stop stop all docker services\n"
@printf " make logs tail all service logs\n"
@echo ""
@printf "$(CYAN)TESTING$(RESET)\n"
@printf " make test-all run ALL tests (Python + Node + Go + Rust)\n"
@printf " make test run Python tests only\n"
@printf " make test-unit run Python unit tests only\n"
@printf " make test-integration run Python integration tests only\n"
@printf " make test-node TypeScript type-check (sdk-node)\n"
@printf " make test-go Go build + vet (sdk-go)\n"
@printf " make test-rust Rust cargo check (sdk-rust)\n"
@echo ""
@printf "$(CYAN)DATABASE$(RESET)\n"
@printf " make migrate run pending Alembic migrations\n"
@printf " make migrate-create MSG='...' create a new migration\n"
@echo ""
@printf "$(CYAN)CODE QUALITY$(RESET)\n"
@printf " make format auto-format with ruff\n"
@printf " make lint lint check with ruff\n"
@printf " make typecheck type-check with mypy\n"
@echo ""
@printf "$(CYAN)SETUP$(RESET)\n"
@printf " make install install ALL dependencies (Python + Node + Go + Rust)\n"
@printf " make clean remove build artifacts\n"
@echo ""
# ─────────────────────────────────────────────────────────────────────────────
# Setup — installs everything
# ─────────────────────────────────────────────────────────────────────────────
install:
@printf "$(BOLD)Installing dependencies...$(RESET)\n"
@echo ""
@printf "$(CYAN)▶ Python$(RESET)\n"
@cd $(CORE_DIR) && pip install poetry --quiet && poetry install
@printf " $(GREEN)✅ Python ready$(RESET)\n"
@printf "$(CYAN)▶ Node SDK$(RESET)\n"
@cd packages/sdk-node && npm install --silent
@printf " $(GREEN)✅ Node SDK ready$(RESET)\n"
@printf "$(CYAN)▶ Go SDK$(RESET)\n"
@cd packages/sdk-go && go mod tidy
@printf " $(GREEN)✅ Go SDK ready$(RESET)\n"
@printf "$(CYAN)▶ Rust SDK$(RESET)\n"
@cd packages/sdk-rust && cargo fetch --quiet
@printf " $(GREEN)✅ Rust SDK ready$(RESET)\n"
@echo ""
@printf "$(GREEN)$(BOLD)All dependencies installed.$(RESET)\n"
@echo ""
# ─────────────────────────────────────────────────────────────────────────────
# CONVERSATION COMMANDS
# ─────────────────────────────────────────────────────────────────────────────
chat:
@if [ -f .env ]; then export $$(grep -v '^#' .env | xargs) 2>/dev/null; fi; \
MOCK_FLAG="--mock"; \
if [ "$(LIVE)" = "1" ]; then MOCK_FLAG=""; fi; \
cd $(CORE_DIR) && PYTHONPATH=. python cli/main.py chat \
--goal $(GOAL) \
$$MOCK_FLAG
dry-run:
@SCENARIO_FLAG=""; \
if [ -n "$(SCENARIO)" ]; then SCENARIO_FLAG="--scenario $(SCENARIO)"; fi; \
MOCK_FLAG="--mock"; \
if [ "$(LIVE)" = "1" ]; then MOCK_FLAG="--no-mock"; fi; \
cd $(CORE_DIR) && PYTHONPATH=. python cli/main.py dry-run \
--goal $(GOAL) \
$$MOCK_FLAG \
$$SCENARIO_FLAG \
--verbose
validate:
@cd $(CORE_DIR) && PYTHONPATH=. python cli/main.py validate --goal $(GOAL)
cost:
@cd $(CORE_DIR) && PYTHONPATH=. python cli/main.py cost --session-id $(SESSION_ID)
# ─────────────────────────────────────────────────────────────────────────────
# Docker / Dev server
# ─────────────────────────────────────────────────────────────────────────────
dev:
@printf "$(BOLD)Starting TrueNorth dev server...$(RESET)\n"
@cp -n .env.example .env 2>/dev/null || true
@docker compose -f docker-compose.dev.yml up --build
stop:
@docker compose -f docker-compose.dev.yml down
logs:
@docker compose -f docker-compose.dev.yml logs -f
# ─────────────────────────────────────────────────────────────────────────────
# Testing
# ─────────────────────────────────────────────────────────────────────────────
# Run every SDK in one command
test-all:
@echo ""
$(call PRINT_LOGO)
@echo ""
@$(MAKE) --no-print-directory test
@$(MAKE) --no-print-directory test-node
@$(MAKE) --no-print-directory test-go
@$(MAKE) --no-print-directory test-rust
@echo ""
@printf "$(GREEN)$(BOLD)✅ All suites passed$(RESET)\n"
@echo ""
# Python — full suite
test:
@printf "$(CYAN)▶ Python — pytest$(RESET)\n"
@cd $(CORE_DIR) && PYTHONPATH=. poetry run pytest tests/ \
--asyncio-mode=auto \
-q \
--tb=short \
--no-header \
-p no:warnings \
&& printf " $(GREEN)✅ Python tests passed$(RESET)\n" \
|| (printf " \033[31m❌ Python tests FAILED$(RESET)\n" && exit 1)
test-unit:
@printf "$(CYAN)▶ Python unit tests$(RESET)\n"
@cd $(CORE_DIR) && PYTHONPATH=. poetry run pytest tests/unit/ \
--asyncio-mode=auto \
-q \
--tb=short \
--no-header \
-p no:warnings
test-integration:
@printf "$(CYAN)▶ Python integration tests$(RESET)\n"
@cd $(CORE_DIR) && PYTHONPATH=. poetry run pytest tests/integration/ \
--asyncio-mode=auto \
-v \
--tb=short
test-node:
@printf "$(CYAN)▶ Node SDK — TypeScript$(RESET)\n"
@cd packages/sdk-node && npm install --silent && npm run typecheck \
&& printf " $(GREEN)✅ TypeScript types valid$(RESET)\n" \
|| (printf " \033[31m❌ TypeScript errors found$(RESET)\n" && exit 1)
test-expo:
@printf "$(CYAN)▶ Expo SDK — TypeScript$(RESET)\n"
@cd packages/sdk-expo && npm install --silent && npx tsc --noEmit \
&& printf " $(GREEN)✅ Expo types valid$(RESET)\n" \
|| (printf " \033[31m❌ Expo TypeScript errors$(RESET)\n" && exit 1)
test-go:
@printf "$(CYAN)▶ Go SDK — build + vet$(RESET)\n"
@cd packages/sdk-go && go mod tidy && go build ./... && go vet ./... \
&& printf " $(GREEN)✅ Go SDK builds cleanly$(RESET)\n" \
|| (printf " \033[31m❌ Go SDK FAILED$(RESET)\n" && exit 1)
test-rust:
@printf "$(CYAN)▶ Rust SDK — cargo check$(RESET)\n"
@cd packages/sdk-rust && cargo check --quiet \
&& printf " $(GREEN)✅ Rust SDK compiles$(RESET)\n" \
|| (printf " \033[31m❌ Rust SDK FAILED$(RESET)\n" && exit 1)
test-coverage:
@cd $(CORE_DIR) && PYTHONPATH=. poetry run pytest tests/unit/ \
--asyncio-mode=auto \
--cov=truenorth \
--cov-report=term-missing \
--cov-report=html \
-q \
&& echo "Coverage report → packages/core/htmlcov/index.html"
# ─────────────────────────────────────────────────────────────────────────────
# Database
# ─────────────────────────────────────────────────────────────────────────────
migrate:
@cd $(CORE_DIR) && poetry run alembic upgrade head
migrate-create:
@cd $(CORE_DIR) && poetry run alembic revision --autogenerate -m "$(MSG)"
# ─────────────────────────────────────────────────────────────────────────────
# Code quality
# ─────────────────────────────────────────────────────────────────────────────
format:
@cd $(CORE_DIR) && poetry run ruff format truenorth/ cli/ tests/
lint:
@cd $(CORE_DIR) && poetry run ruff check truenorth/ cli/ tests/
typecheck:
@cd $(CORE_DIR) && poetry run mypy truenorth/ --ignore-missing-imports
# ─────────────────────────────────────────────────────────────────────────────
# Clean
# ─────────────────────────────────────────────────────────────────────────────
clean:
@find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name .mypy_cache -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
@find . -name "*.pyc" -delete 2>/dev/null || true
@printf "$(GREEN)Cleaned.$(RESET)\n"
sample-clone:
@if [ -d "$(SAMPLES_DIR)/.git" ]; then \
echo "Samples present — pulling latest"; \
cd $(SAMPLES_DIR) && git pull --quiet; \
else \
echo "Cloning samples..."; \
git clone --quiet $(SAMPLES_REPO) $(SAMPLES_DIR); \
fi
sample-list: sample-clone
@echo "python:" && ls $(SAMPLES_DIR)/python
@echo "nodejs:" && ls $(SAMPLES_DIR)/nodejs
@echo "go-lang:" && ls $(SAMPLES_DIR)/go-lang
sample-run: sample-clone
@lang=""; \
echo "Select language:"; \
echo " a) python"; \
echo " b) nodejs"; \
echo " c) go-lang"; \
read -p "Choice: " lchoice; \
case "$$lchoice" in \
a) lang=python ;; \
b) lang=nodejs ;; \
c) lang=go-lang ;; \
*) echo "Invalid choice"; exit 1 ;; \
esac; \
names=($$(ls $(SAMPLES_DIR)/$$lang)); \
letters=(a b c d e f g h i j k l m n o p q r s t u v w x y z); \
echo "Select sample:"; \
i=0; \
for n in "$${names[@]}"; do \
echo " $${letters[$$i]}) $$n"; \
i=$$((i+1)); \
done; \
read -p "Choice: " schoice; \
idx=-1; \
for j in "$${!letters[@]}"; do \
if [ "$${letters[$$j]}" = "$$schoice" ]; then idx=$$j; fi; \
done; \
if [ "$$idx" = "-1" ] || [ "$$idx" -ge "$${#names[@]}" ]; then \
echo "Invalid selection"; exit 1; \
fi; \
name="$${names[$$idx]}"; \
echo "Running $$lang/$$name..."; \
if [ "$$lang" = "python" ]; then \
cd packages/core && GOAL_YAML=../../$(SAMPLES_DIR)/python/$$name/goal.yaml \
poetry run python ../../$(SAMPLES_DIR)/python/$$name/app.py; \
elif [ "$$lang" = "go-lang" ]; then \
cd $(SAMPLES_DIR)/go-lang/$$name && go run main.go; \
elif [ "$$lang" = "nodejs" ]; then \
cd $(SAMPLES_DIR)/nodejs/$$name && npm install --silent && npx tsx app.ts; \
fi