-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
199 lines (175 loc) · 7.38 KB
/
Copy pathMakefile
File metadata and controls
199 lines (175 loc) · 7.38 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
.PHONY: help install run-backend run-frontend run-voice run-tunnel-backend run-tunnel-frontend dev dev-voice dev-win dev-sqlite prod stop clean env generate-hash simulate build-exe build-non-tauri agents-zip
# Use bash for all commands
SHELL := /bin/bash
help:
@echo "ChitChats - Available commands:"
@echo ""
@echo "Development:"
@echo " make dev - Run backend + frontend (PostgreSQL)"
@echo " make dev-voice - Run backend + frontend + voice server"
@echo " make dev-win - Run backend + frontend (Windows, clean Ctrl+C)"
@echo " make dev-sqlite - Run backend + frontend (SQLite)"
@echo " make install - Install all dependencies (backend + frontend)"
@echo " make run-backend - Run backend server only"
@echo " make run-frontend - Run frontend server only"
@echo " make run-voice - Run voice TTS server only (port 8002)"
@echo ""
@echo "Build:"
@echo " make build-exe - Build standalone Windows exe"
@echo " make build-non-tauri - Build standalone Windows exe (same as build-exe)"
@echo " make agents-zip - Package agents/ as dist/agents.zip (ships next to the exe)"
@echo ""
@echo "Setup:"
@echo " make env - Create .env file (prompts for password)"
@echo " make generate-hash - Generate password hash and write it to .env"
@echo ""
@echo "Simulation:"
@echo " make simulate - Run chatroom simulation (requires args)"
@echo ""
@echo "Deployment (Cloudflare tunnels for remote access):"
@echo " make prod - Start tunnel + auto-update Vercel env + redeploy"
@echo " make run-tunnel-backend - Run Cloudflare tunnel for backend"
@echo " make run-tunnel-frontend- Run Cloudflare tunnel for frontend"
@echo ""
@echo "Maintenance:"
@echo " make stop - Stop all running servers"
@echo " make clean - Clean build artifacts and caches"
install:
@echo "Installing dependencies..."
@if ! command -v claude >/dev/null 2>&1; then \
echo "Note: the 'claude' CLI was not found on your PATH."; \
echo " The 'claude' provider needs it: npm install -g @anthropic-ai/claude-code"; \
echo " (Not needed if you only use the 'codex' provider.)"; \
fi
@echo "Installing backend dependencies with uv..."
uv sync
@echo "Installing frontend dependencies..."
cd frontend && npm install
@echo "Done!"
run-backend:
@echo "Starting backend server..."
cd backend && uv run uvicorn main:app --host 0.0.0.0 --port 8001
run-frontend:
@echo "Starting frontend server..."
cd frontend && npm run dev
run-voice:
@echo "Starting voice TTS server on port 8002..."
cd voice_server && uv run uvicorn main:app --host 0.0.0.0 --port 8002
run-tunnel-backend:
@echo "Starting Cloudflare tunnel for backend..."
cloudflared tunnel --url http://localhost:8001
run-tunnel-frontend:
@echo "Starting Cloudflare tunnel for frontend..."
cloudflared tunnel --url http://localhost:5173
dev:
@echo "Starting backend and frontend..."
@echo "Backend will run on http://localhost:8001"
@echo "Frontend will run on http://localhost:5173"
@echo "For remote access, run 'make run-tunnel-backend' and 'make run-tunnel-frontend' in separate terminals"
@echo "Press Ctrl+C to stop all servers"
# @$(MAKE) -j3 run-backend run-frontend run-tunnel-backend
@$(MAKE) -j2 run-backend run-frontend
dev-voice:
@echo "Starting backend, frontend, and voice server..."
@echo "Backend will run on http://localhost:8001"
@echo "Frontend will run on http://localhost:5173"
@echo "Voice server will run on http://localhost:8002"
@echo "Press Ctrl+C to stop all servers"
@$(MAKE) -j3 run-backend run-frontend run-voice
dev-win:
@echo "Starting backend and frontend (Windows)..."
@powershell.exe -ExecutionPolicy Bypass -File scripts/windows/dev.ps1
dev-sqlite:
@echo "Starting backend and frontend with SQLite..."
@echo "Backend will run on http://localhost:8000"
@echo "Frontend will run on http://localhost:5173"
@echo "SQLite database: ./chitchats.db"
@echo "Press Ctrl+C to stop all servers"
USE_SQLITE=true $(MAKE) -j3 run-backend run-frontend
prod:
@echo "Starting production deployment..."
@echo "This will:"
@echo " 1. Start backend server (port 8001)"
@echo " 2. Start cloudflared tunnel"
@echo " 3. Auto-update VITE_API_BASE_URL on Vercel"
@echo " 4. Trigger Vercel redeploy"
@echo ""
@echo "Prerequisites: vercel CLI logged in (run 'vercel login' first)"
@echo ""
@# Start backend in background (port 8001 to avoid conflict with dev)
@cd backend && uv run uvicorn main:app --reload --host 0.0.0.0 --port 8001 &
@sleep 2
@# Run tunnel script (handles URL detection, Vercel update, and redeploy)
@./scripts/deploy/update_vercel_backend_url.sh
stop:
@echo "Stopping servers..."
@pkill -f "uvicorn main:app" || true
@pkill -f "vite" || true
@pkill -f "cloudflared" || true
@echo "Servers stopped."
clean:
@echo "Cleaning build artifacts..."
rm -rf backend/__pycache__
rm -rf backend/**/__pycache__
rm -rf backend/*.db
rm -rf frontend/dist
rm -rf frontend/node_modules/.vite
@echo "Clean complete!"
env:
@echo "Creating .env file..."
@uv run python scripts/setup/create_env.py
generate-hash:
@echo "Generating password hash..."
@uv run python scripts/setup/generate_hash.py $(ARGS)
simulate:
@echo "Running chatroom simulation..."
@echo "Usage: make simulate ARGS='--password \"yourpass\" --scenario \"text\" --agents \"agent1,agent2\"'"
@if [ -z "$(ARGS)" ]; then \
./scripts/simulation/simulate_chatroom.sh --help; \
else \
./scripts/simulation/simulate_chatroom.sh $(ARGS); \
fi
# =============================================================================
# Build Commands
# =============================================================================
# Default agents, zipped for distribution alongside the exe.
# The exe extracts this into its own directory on first launch.
agents-zip:
@echo "Packaging agents/ into dist/agents.zip..."
@mkdir -p dist
@rm -f dist/agents.zip
@zip -qr dist/agents.zip agents -x '*/__pycache__/*' '*.DS_Store'
@echo "Created dist/agents.zip"
# Windows executable build (standalone PyInstaller)
build-exe:
@$(MAKE) build-non-tauri CLEAN=$(CLEAN) SKIP_FRONTEND=$(SKIP_FRONTEND)
# Standalone Windows executable (non-Tauri)
# Single exe with embedded frontend, no native desktop integration
# On Windows: uses powershell directly
# On Linux/macOS: uses pwsh (PowerShell Core)
build-non-tauri:
ifeq ($(OS),Windows_NT)
@echo "Building standalone Windows executable (non-Tauri)..."
@powershell.exe -ExecutionPolicy Bypass -File scripts/windows/build_exe.ps1 -Sign
else
@echo "Building standalone Windows executable (non-Tauri)..."
@if command -v pwsh >/dev/null 2>&1; then \
echo "Using PowerShell Core (pwsh)..."; \
pwsh -ExecutionPolicy Bypass -File scripts/windows/build_exe.ps1 $(if $(CLEAN),-Clean,) $(if $(SKIP_FRONTEND),-SkipFrontend,); \
else \
echo ""; \
echo "PowerShell Core not found. To build the Windows executable:"; \
echo ""; \
echo " Option 1: Install PowerShell Core"; \
echo " Ubuntu/Debian: sudo apt install powershell"; \
echo " macOS: brew install powershell"; \
echo ""; \
echo " Option 2: Run directly on Windows"; \
echo " .\\scripts\\windows\\build_exe.ps1"; \
echo ""; \
exit 1; \
fi
endif
# =============================================================================
# Archived Commands (Not Recommended for Windows)
# =============================================================================