Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 235 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 Coiguration" > .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
Loading