fix: setup.sh and install.sh improvements (#155)

- 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>
This commit is contained in:
Dawen Ren 2026-02-03 00:00:11 +08:00 committed by GitHub
parent 627ad7d9a5
commit 48ba86a2de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 45 deletions

View file

@ -240,49 +240,15 @@ install_ralph_loop() {
install_setup() {
log "INFO" "Installing global setup script..."
# Create modified setup.sh for global operation
cat > "$RALPH_HOME/setup.sh" << 'EOF'
#!/bin/bash
# Ralph Project Setup Script - Global Version
set -e
PROJECT_NAME=${1:-"my-project"}
RALPH_HOME="$HOME/.ralph"
echo "🚀 Setting up Ralph project: $PROJECT_NAME"
# Create project directory in current location
mkdir -p "$PROJECT_NAME"
cd "$PROJECT_NAME"
# Create structure with .ralph/ subfolder
mkdir -p src
mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
# Copy templates from Ralph home to .ralph/ subfolder
cp "$RALPH_HOME/templates/PROMPT.md" .ralph/
cp "$RALPH_HOME/templates/fix_plan.md" .ralph/fix_plan.md
cp "$RALPH_HOME/templates/AGENT.md" .ralph/AGENT.md
cp -r "$RALPH_HOME/templates/specs/"* .ralph/specs/ 2>/dev/null || true
# Initialize git
git init
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 --monitor"
echo " 4. Monitor: ralph-monitor (if running manually)"
EOF
chmod +x "$RALPH_HOME/setup.sh"
log "SUCCESS" "Global setup script installed"
# Copy the actual setup.sh from ralph-claude-code root directory so setup information will be consistent
if [[ -f "$SCRIPT_DIR/setup.sh" ]]; then
cp "$SCRIPT_DIR/setup.sh" "$RALPH_HOME/setup.sh"
chmod +x "$RALPH_HOME/setup.sh"
log "SUCCESS" "Global setup script installed (copied from $SCRIPT_DIR/setup.sh)"
else
log "ERROR" "setup.sh not found in $SCRIPT_DIR"
return 1
fi
}
# Check PATH