-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·56 lines (46 loc) · 1.5 KB
/
start.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.5 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
#!/usr/bin/env bash
set -euo pipefail
# Promptterfly Start Script
# Launches the interactive REPL or runs a single command.
# For first-time setup, run ./setup.sh first.
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$PROJECT_ROOT/.venv"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
log_error() { echo -e "${RED}[ERROR]${NC} $*"; }
# Check if venv exists
if [ ! -d "$VENV_DIR" ]; then
log_error "Virtual environment not found!"
log_info "Please run './setup.sh' first to set up Promptterfly."
exit 1
fi
# Activate venv
source "$VENV_DIR/bin/activate"
# Check if promptterfly is installed
if ! python -c "import promptterfly" > /dev/null 2>&1; then
log_error "promptterfly is not installed in the virtual environment."
log_info "Run './setup.sh' to install dependencies."
exit 1
fi
# Auto-initialize project if not already in one (skip if the command itself is "init")
should_auto_init=true
if [ $# -gt 0 ] && [ "$1" = "init" ]; then
should_auto_init=false
fi
if $should_auto_init; then
if ! promptterfly config > /dev/null 2>&1; then
log_info "Initializing Promptterfly..."
promptterfly init
fi
fi
# If arguments are provided, run the command directly via the promptterfly CLI
if [ $# -gt 0 ]; then
exec promptterfly "$@"
fi
# Otherwise, start interactive REPL
python -c "from promptterfly.repl import main; main()"