-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·229 lines (203 loc) · 9.36 KB
/
Copy pathinit.sh
File metadata and controls
executable file
·229 lines (203 loc) · 9.36 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
#!/bin/bash
# Ralph Initialization Script
# Guides you through customizing Ralph for your project
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "╔════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ Ralph for Claude Code CLI - Setup ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
echo "This script will customize Ralph for your project."
echo "Press Ctrl+C at any time to cancel."
echo ""
read -p "Press Enter to continue..."
echo ""
# ============================================================================
# Step 1: Project Information
# ============================================================================
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Step 1: Project Information"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
read -p "Project name (e.g., 'MyApp'): " PROJECT_NAME
echo ""
# ============================================================================
# Step 2: Quality Check Commands
# ============================================================================
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Step 2: Quality Check Commands"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "What commands does your project use for quality checks?"
echo ""
read -p "Type check command (e.g., 'npm run check-types'): " TYPE_CHECK_CMD
read -p "Linting command (e.g., 'npm run lint'): " LINT_CMD
read -p "Auto-fix formatting command (e.g., 'npm run lint:fix'): " FORMAT_CMD
echo ""
# ============================================================================
# Step 3: Browser Testing (optional)
# ============================================================================
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Step 3: Browser Testing Configuration (Optional)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Does your project need browser testing for UI changes?"
echo ""
read -p "Enable browser testing? (y/n, default: y): " ENABLE_BROWSER
ENABLE_BROWSER=${ENABLE_BROWSER:-y}
if [[ "$ENABLE_BROWSER" == "y" || "$ENABLE_BROWSER" == "Y" ]]; then
echo ""
read -p "Dev server URL (e.g., 'http://localhost:3000'): " DEV_SERVER_URL
read -p "Test account email (for browser login): " TEST_EMAIL
read -p "Test account password: " -s TEST_PASSWORD
echo ""
echo ""
else
DEV_SERVER_URL=""
TEST_EMAIL=""
TEST_PASSWORD=""
fi
# ============================================================================
# Step 4: Project-Specific Patterns (optional)
# ============================================================================
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Step 4: Project-Specific Patterns (Optional)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Do you have any coding patterns Ralph should always follow?"
echo "Examples:"
echo " - Never use .filter() - always use .withIndex()"
echo " - All routes scoped under /app/"
echo " - Use specific UI library components"
echo ""
echo "You can add these now or later by editing prompt.md"
echo ""
PATTERNS=()
while true; do
read -p "Add a pattern? (press Enter to skip): " PATTERN
if [ -z "$PATTERN" ]; then
break
fi
PATTERNS+=("$PATTERN")
done
# ============================================================================
# Step 5: Summary and Confirmation
# ============================================================================
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Configuration Summary"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Project Name: $PROJECT_NAME"
echo "Type Check: $TYPE_CHECK_CMD"
echo "Linting: $LINT_CMD"
echo "Formatting: $FORMAT_CMD"
if [ -n "$DEV_SERVER_URL" ]; then
echo "Dev Server: $DEV_SERVER_URL"
echo "Test Account: $TEST_EMAIL"
fi
if [ ${#PATTERNS[@]} -gt 0 ]; then
echo "Patterns:"
for pattern in "${PATTERNS[@]}"; do
echo " - $pattern"
done
fi
echo ""
read -p "Apply these settings? (y/n): " CONFIRM
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
echo "Setup cancelled."
exit 1
fi
# ============================================================================
# Step 6: Update prompt.md
# ============================================================================
echo ""
echo "Updating prompt.md..."
# Update type check command
sed -i.bak "s|npm run check-types|$TYPE_CHECK_CMD|g" "$SCRIPT_DIR/prompt.md"
# Update lint commands
sed -i.bak "s|npm run lint:fix|$FORMAT_CMD|g" "$SCRIPT_DIR/prompt.md"
sed -i.bak "s|npm run lint|$LINT_CMD|g" "$SCRIPT_DIR/prompt.md"
# Update browser testing if enabled
if [ -n "$DEV_SERVER_URL" ]; then
sed -i.bak "s|\*\*\[REPLACE WITH YOUR DEV SERVER URL, e.g., http://localhost:3000\]\*\*|$DEV_SERVER_URL|g" "$SCRIPT_DIR/prompt.md"
sed -i.bak "s|\*\*\[REPLACE WITH YOUR TEST ACCOUNT\]\*\*|$TEST_EMAIL / $TEST_PASSWORD|g" "$SCRIPT_DIR/prompt.md"
fi
# Add project-specific patterns if provided
if [ ${#PATTERNS[@]} -gt 0 ]; then
# Create patterns string
PATTERN_STRING=""
for pattern in "${PATTERNS[@]}"; do
PATTERN_STRING+="- $pattern\n"
done
# Replace placeholder with actual patterns
sed -i.bak "/<!-- CUSTOMIZE: Add your project's specific patterns here -->/,/-->/c\\
<!-- Project-Specific Patterns -->\n$PATTERN_STRING" "$SCRIPT_DIR/prompt.md"
fi
# Remove backup file
rm -f "$SCRIPT_DIR/prompt.md.bak"
echo "✅ prompt.md updated"
# ============================================================================
# Step 7: Create example PRD
# ============================================================================
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Create Example PRD?"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Would you like to create an example PRD to test Ralph?"
echo ""
read -p "Create example PRD? (y/n, default: n): " CREATE_PRD
CREATE_PRD=${CREATE_PRD:-n}
if [[ "$CREATE_PRD" == "y" || "$CREATE_PRD" == "Y" ]]; then
cat > "$SCRIPT_DIR/prd.json" << EOF
{
"projectName": "$PROJECT_NAME - Ralph Test",
"branchName": "ralph/test-run",
"description": "Test Ralph with a simple story",
"userStories": [
{
"id": "TEST-001",
"title": "Add hello world comment to README",
"priority": 1,
"passes": false,
"acceptanceCriteria": [
"Add comment '<!-- Hello from Ralph! -->' at top of README.md",
"Verify comment appears in file",
"Commit changes"
],
"notes": "This is a simple test story to verify Ralph is working correctly."
}
]
}
EOF
echo "✅ Created test PRD: $SCRIPT_DIR/prd.json"
echo ""
echo "You can now run: ./scripts/ralph/ralph.sh 1"
fi
# ============================================================================
# Final Instructions
# ============================================================================
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Setup Complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Next steps:"
echo ""
echo "1. Review prompt.md to verify customizations"
echo "2. Create a PRD file (or use one of the examples/)"
echo "3. Run: ./scripts/ralph/ralph.sh [max-iterations]"
echo ""
echo "Documentation:"
echo " - README.md - Quick start guide"
echo " - QUICKSTART.md - Detailed getting started"
echo " - ARCHITECTURE.md - Technical overview"
echo " - LEARNING_SYSTEM.md - How Ralph learns"
echo ""
echo "Need help? Check README.md or QUICKSTART.md"
echo ""
echo "Happy autonomous coding! 🤖"
echo ""