-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
235 lines (224 loc) · 13.1 KB
/
Makefile
File metadata and controls
235 lines (224 loc) · 13.1 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
# .d8888b.
# d88P Y88b
# Y88b.
# "Y888b. 888 888 888 8888b. 888d888 88888b.d88b.
# "Y88b. 888 888 888 "88b 888P" 888 "888 "88b
# "888 888 888 888 .d888888 888 888 888 888
# Y88b d88P Y88b 888 d88P 888 888 888 888 888 888
# "Y8888P" "Y8888888P" "Y888888 888 888 888 888
#
#
#
# .d8888b. d8b 888
# d88P Y88b Y8P 888
# Y88b. 888
# "Y888b. .d88b. .d8888b 888 888 888d888 888 888888 888 888
# "Y88b. d8P Y8b d88P" 888 888 888P" 888 888 888 888
# "888 88888888 888 888 888 888 888 888 888 888
# Y88b d88P Y8b. Y88b. Y88b 888 888 888 Y88b. Y88b 888
# "Y8888P" "Y8888 "Y8888P "Y88888 888 888 "Y888 "Y88888
# 888
# Y8b d88P
# "Y88P"
# d8888
# d88888
# d88P888
# d88P 888 888d888 .d88b. 888 888 .d88b. 888 888
# d88P 888 888P" d8P Y8b 888 888 d88""88b 888 888
# d88P 888 888 88888888 888 888 888 888 888 888
# d8888888888 888 Y8b. Y88b 888 Y88..88P Y88b 888
# d88P 888 888 "Y8888 "Y88888 "Y88P" "Y88888
# 888
# Y8b d88P
# "Y88P"
# 888 888
# 888 888
# 888 888
# 888d888 .d88b. 8888b. .d88888 888 888 888888 .d88b.
# 888P" d8P Y8b "88b d88" 888 888 888 888 d88""88b
# 888 88888888 .d888888 888 888 888 888 888 888 888
# 888 Y8b. 888 888 Y88b 888 Y88b 888 Y88b. Y88..88P
# 888 "Y8888 "Y888888 "Y88888 "Y88888 "Y888 "Y88P"
# 888
# Y8b d88P
# "Y88P"
# 888
# 888
# 888
# 8888b. 88888b. 8888b. 888 888 888 .d8888b .d88b.
# "88b 888 "88b "88b 888 888 888 88K d8P Y8b
# .d888888 888 888 .d888888 888 888 888 "Y8888b. 88888888
# 888 888 888 888 888 888 888 Y88b 888 X88 Y8b.
# "Y888888 888 888 "Y888888 888 "Y88888 88888P' "Y8888
# 888
# Y8b d88P
# "Y88P"
#
#
#
# 888 888 .d88b. 888 888 888d888
# 888 888 d88""88b 888 888 888P"
# 888 888 888 888 888 888 888
# Y88b 888 Y88..88P Y88b 888 888
# "Y88888 "Y88P" "Y88888 888
# 888
# Y8b d88P
# "Y88P"
# 888 888
# 888 888
# 888 888
# .d8888b .d88b. 88888b. 888888 888d888 8888b. .d8888b 888888 .d8888b
# d88P" d88""88b 888 "88b 888 888P" "88b d88P" 888 88K
# 888 888 888 888 888 888 888 .d888888 888 888 "Y8888b.
# Y88b. Y88..88P 888 888 Y88b. 888 888 888 Y88b. Y88b. X88
# "Y8888P "Y88P" 888 888 "Y888 888 "Y888888 "Y8888P "Y888 88888P'
#
#
#
# d8b 888 888 888 888
# Y8P 888 888 888 888
# 888 888 888 888
# 888 888 888 888 888888 88888b. 888888 88888b. .d88b.
# 888 888 888 888 888 888 "88b 888 888 "88b d8P Y8b
# 888 888 888 888 888 888 888 888 888 888 88888888
# Y88b 888 d88P 888 Y88b. 888 888 Y88b. 888 888 Y8b.
# "Y8888888P" 888 "Y888 888 888 "Y888 888 888 "Y8888
#
#
#
# 888
# 888
# 888
# .d88b. 888 888 88888b. .d88b. 888d888 888888
# d8P Y8b `Y8bd8P' 888 "88b d8P Y8b 888P" 888
# 88888888 X88K 888 888 88888888 888 888
# Y8b. .d8""8b. 888 d88P Y8b. 888 Y88b.
# "Y8888 888 888 88888P" "Y8888 888 "Y888
# 888
# 888
# 888
# 888
# 888
# 888
# 8888b. .d88b. .d88b. 88888b. 888888 .d8888b
# "88b d88P"88b d8P Y8b 888 "88b 888 88K
# .d888888 888 888 88888888 888 888 888 "Y8888b.
# 888 888 Y88b 888 Y8b. 888 888 Y88b. X88 d8b
# "Y888888 "Y88888 "Y8888 888 888 "Y888 88888P' Y8P
# 888
# Y8b d88P
# "Y88P"
# RedSpectre Makefile
.PHONY: help setup-env setup-venv install install-deps server tunnel setup all
# Default target
help:
@echo "RedSpectre Makefile"
@echo ""
@echo "Available targets:"
@echo " setup-env - Create .env file by prompting for required keys"
@echo " setup-venv - Create Python virtual environment"
@echo " install - Install Python packages (requires venv to be activated)"
@echo " install-deps - Install npm global dependencies (localtunnel)"
@echo " server - Start audit-agent server on port 8000"
@echo " tunnel - Start localtunnel on port 8000 (requires server to be running)"
@echo " setup - Run full setup: env, venv, install, install-deps"
@echo " all - Run setup, start server, and start tunnel"
# Create .env file by prompting for required keys
setup-env:
@if [ -f .env ]; then \
echo ".env file already exists. Remove it first if you want to recreate it."; \
exit 1; \
fi
@echo "Creating .env file..."
@bash -c '\
echo "# OpenAI Configuration" > .env; \
read -sp "Enter OPENAI_API_KEY: " key; echo ""; { echo "OPENAI_API_KEY=$$key"; } >> .env; \
read -p "Enter OPENAI_MODEL [gpt-4.1-nano-2025-04-14]: " model && echo "OPENAI_MODEL=$${model:-gpt-4.1-nano-2025-04-14}" >> .env || echo "OPENAI_MODEL=gpt-4.1-nano-2025-04-14" >> .env; \
echo "" >> .env; \
echo "# Logging" >> .env; \
read -p "Enter LOG_LEVEL [INFO]: " level && echo "LOG_LEVEL=$${level:-INFO}" >> .env || echo "LOG_LEVEL=INFO" >> .env; \
read -p "Enter LOG_FILE [agent.log]: " file && echo "LOG_FILE=$${file:-agent.log}" >> .env || echo "LOG_FILE=agent.log" >> .env; \
echo "" >> .env; \
echo "# Server Mode (Optional)" >> .env; \
read -sp "Enter AGENTARENA_API_KEY (optional, press Enter to skip): " api_key; echo ""; { echo "AGENTARENA_API_KEY=$$api_key"; } >> .env; \
read -sp "Enter WEBHOOK_AUTH_TOKEN (optional, press Enter to skip): " token; echo ""; { echo "WEBHOOK_AUTH_TOKEN=$$token"; } >> .env; \
read -p "Enter DATA_DIR [./data]: " dir && echo "DATA_DIR=$${dir:-./data}" >> .env || echo "DATA_DIR=./data" >> .env; \
echo ".env file created successfully!"'
# Create virtual environment
setup-venv:
@if [ -d venv ]; then \
echo "Virtual environment already exists. Remove it first if you want to recreate it."; \
exit 1; \
fi
@echo "Creating virtual environment..."
python3 -m venv venv
@echo "Virtual environment created. Activate it with: source venv/bin/activate"
# Install Python packages (requires venv to be activated)
install:
@if [ -z "$$VIRTUAL_ENV" ]; then \
echo "Error: Virtual environment not activated. Please run: source venv/bin/activate"; \
exit 1; \
fi
@echo "Installing Python packages..."
pip install -e .
@echo "Python packages installed successfully!"
# Install npm global dependencies
install-deps:
@echo "Installing localtunnel globally..."
npm install -g localtunnel
@echo "localtunnel installed successfully!"
# Start audit-agent server on port 8000
server:
@if [ -z "$$VIRTUAL_ENV" ]; then \
echo "Error: Virtual environment not activated. Please run: source venv/bin/activate"; \
exit 1; \
fi
@echo "Starting audit-agent server on port 8000..."
@audit-agent server
# Start localtunnel on port 8000 (requires server to be running)
tunnel:
@if [ -z "$$VIRTUAL_ENV" ]; then \
echo "Error: Virtual environment not activated. Please run: source venv/bin/activate"; \
exit 1; \
fi
@echo "Starting audit-agent server in background..."
@bash -c "source venv/bin/activate && audit-agent server &"
@sleep 3
@echo "Server started. Starting localtunnel on port 8000..."
@echo "Add /webhook at the end of the tunnel address (e.g., https://siteaddress/webhook)"
@lt --port 8000
# Full setup: create env, venv, install packages, install deps
setup: setup-env setup-venv
@echo ""
@echo "=========================================="
@echo "Setup completed!"
@echo "=========================================="
@echo ""
@echo "Next steps:"
@echo "1. Activate the virtual environment:"
@echo " source venv/bin/activate"
@echo ""
@echo "2. Install Python packages:"
@echo " make install"
@echo ""
@echo "3. Install npm dependencies:"
@echo " make install-deps"
@echo ""
@echo "4. Start the server and tunnel:"
@echo " make tunnel"
@echo ""
# Complete setup and start server + tunnel
all: setup
@echo ""
@echo "Activating virtual environment and installing packages..."
@bash -c "source venv/bin/activate && pip install -e ."
@echo ""
@echo "Installing npm dependencies..."
@npm install -g localtunnel || true
@echo ""
@echo "Setup complete! Starting server..."
@bash -c "source venv/bin/activate && audit-agent server &"
@sleep 3
@echo "Server started. Starting tunnel..."
@echo "Add /webhook at the end of the tunnel address (e.g., https://siteaddress/webhook)"
@lt --port 8000