- setup.sh: Skip git init if .git already exists (prevents errors in existing repos) - install.sh: Copy setup.sh directly instead of hardcoding a simplified version This ensures global installation uses the same setup logic as local, including .ralphrc generation via enable_core.sh Co-authored-by: dawenrenhub <darwinren321@gmail.com>
108 lines
3.3 KiB
Bash
Executable file
108 lines
3.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Ralph Project Setup Script
|
|
# Creates project structure with Ralph-specific files in .ralph/ subfolder
|
|
set -e
|
|
|
|
PROJECT_NAME=${1:-"my-project"}
|
|
|
|
echo "🚀 Setting up Ralph project: $PROJECT_NAME"
|
|
|
|
# Create project directory
|
|
mkdir -p "$PROJECT_NAME"
|
|
cd "$PROJECT_NAME"
|
|
|
|
# Determine templates directory location (checked AFTER cd into project)
|
|
# Check local ../templates first, then global ~/.ralph/templates
|
|
TEMPLATES_DIR=""
|
|
LIB_DIR=""
|
|
if [[ -d "../templates" ]]; then
|
|
TEMPLATES_DIR="../templates"
|
|
LIB_DIR="../lib"
|
|
elif [[ -d "$HOME/.ralph/templates" ]]; then
|
|
TEMPLATES_DIR="$HOME/.ralph/templates"
|
|
LIB_DIR="$HOME/.ralph/lib"
|
|
else
|
|
echo "❌ Error: Templates directory not found."
|
|
echo " Expected at: ../templates or ~/.ralph/templates"
|
|
echo " Please run ./install.sh first to install Ralph globally."
|
|
exit 1
|
|
fi
|
|
|
|
# Verify required template files exist
|
|
if [[ ! -f "$TEMPLATES_DIR/PROMPT.md" ]]; then
|
|
echo "❌ Error: Required template file PROMPT.md not found in $TEMPLATES_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
# Create structure:
|
|
# - src/ stays at root for compatibility with existing tooling
|
|
# - All Ralph-specific files go in .ralph/ subfolder
|
|
mkdir -p src
|
|
mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
|
|
|
|
# Copy templates to .ralph/
|
|
cp "$TEMPLATES_DIR/PROMPT.md" .ralph/
|
|
cp "$TEMPLATES_DIR/fix_plan.md" .ralph/fix_plan.md
|
|
cp "$TEMPLATES_DIR/AGENT.md" .ralph/AGENT.md
|
|
cp -r "$TEMPLATES_DIR/specs"/* .ralph/specs/ 2>/dev/null || true
|
|
|
|
# Generate .ralphrc configuration file
|
|
# Source enable_core.sh if available for generate_ralphrc(), otherwise create inline
|
|
if [[ -f "$LIB_DIR/enable_core.sh" ]]; then
|
|
# Temporarily disable colors for cleaner output
|
|
export ENABLE_USE_COLORS=false
|
|
source "$LIB_DIR/enable_core.sh"
|
|
# Generate .ralphrc and fix the generator label (library says "ralph enable")
|
|
generate_ralphrc "$PROJECT_NAME" "generic" "local" | sed 's/Generated by: ralph enable/Generated by: ralph-setup/' > .ralphrc
|
|
else
|
|
# Fallback: create minimal .ralphrc inline (same content as generate_ralphrc)
|
|
cat > .ralphrc << RALPHRCEOF
|
|
# .ralphrc - Ralph project configuration
|
|
# Generated by: ralph-setup
|
|
# Documentation: https://github.com/frankbria/ralph-claude-code
|
|
|
|
# Project identification
|
|
PROJECT_NAME="${PROJECT_NAME}"
|
|
PROJECT_TYPE="generic"
|
|
|
|
# Loop settings
|
|
MAX_CALLS_PER_HOUR=100
|
|
CLAUDE_TIMEOUT_MINUTES=15
|
|
CLAUDE_OUTPUT_FORMAT="json"
|
|
|
|
# Tool permissions
|
|
# Comma-separated list of allowed tools
|
|
ALLOWED_TOOLS="Write,Read,Edit,Bash(git *),Bash(npm *),Bash(pytest)"
|
|
|
|
# Session management
|
|
SESSION_CONTINUITY=true
|
|
SESSION_EXPIRY_HOURS=24
|
|
|
|
# Task sources (for ralph enable --sync)
|
|
# Options: local, beads, github (comma-separated for multiple)
|
|
TASK_SOURCES="local"
|
|
GITHUB_TASK_LABEL="ralph-task"
|
|
BEADS_FILTER="status:open"
|
|
|
|
# Circuit breaker thresholds
|
|
CB_NO_PROGRESS_THRESHOLD=3
|
|
CB_SAME_ERROR_THRESHOLD=5
|
|
CB_OUTPUT_DECLINE_THRESHOLD=70
|
|
RALPHRCEOF
|
|
fi
|
|
|
|
# Initialize git (skip if already initialized)
|
|
if [[ ! -d ".git" ]]; then
|
|
git init
|
|
fi
|
|
echo "# $PROJECT_NAME" > README.md
|
|
git add .
|
|
git commit -m "Initial Ralph project setup"
|
|
|
|
echo "✅ Project $PROJECT_NAME created!"
|
|
echo "Next steps:"
|
|
echo " 1. Edit .ralph/PROMPT.md with your project requirements"
|
|
echo " 2. Update .ralph/specs/ with your project specifications"
|
|
echo " 3. Run: ../ralph_loop.sh"
|
|
echo " 4. Monitor: ../ralph_monitor.sh"
|