forked from snarktank/ralph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-repo.sh
More file actions
executable file
·181 lines (156 loc) · 6.37 KB
/
setup-repo.sh
File metadata and controls
executable file
·181 lines (156 loc) · 6.37 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
#!/bin/bash
# setup-repo.sh - Set up a repository for Ralph usage (from source)
#
# Run this script FROM INSIDE your target project repository to set it up
# with Ralph's autonomous agent tooling.
#
# Usage:
# /path/to/ralph/setup-repo.sh
set -e
# ---------------------------------------------------------------------------
# Arguments
# ---------------------------------------------------------------------------
while [[ $# -gt 0 ]]; do
case $1 in
--mega)
# Accepted for backwards compat but ignored (always installs everything)
shift
;;
-h|--help)
echo "Usage: setup-repo.sh"
echo ""
echo "Run from inside your target project repository."
echo "Installs plans/ and .ralph/ at the project root."
exit 0
;;
*)
echo "Error: Unknown argument '$1'. Use --help for usage."
exit 1
;;
esac
done
# ---------------------------------------------------------------------------
# Resolve paths
# ---------------------------------------------------------------------------
# RALPH_HOME is where the ralph source files live (where this script is)
RALPH_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# TARGET_DIR is the project repo (current working directory)
TARGET_DIR="$(pwd)"
VERSION="5.0.0"
# Sanity checks
if [[ "$RALPH_HOME" == "$TARGET_DIR" ]]; then
echo "Error: You are running this from inside the ralph repo itself."
echo "Run this from inside your TARGET project directory:"
echo " cd /path/to/your/project"
echo " $RALPH_HOME/setup-repo.sh"
exit 1
fi
if [[ ! -d "$TARGET_DIR/.git" ]]; then
echo "Warning: Current directory does not appear to be a git repository."
echo "Ralph works best with git. Consider running 'git init' first."
echo ""
read -r -p "Continue anyway? [y/N] " response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
exit 0
fi
fi
# ---------------------------------------------------------------------------
# Create directory structure
# ---------------------------------------------------------------------------
echo "Setting up Ralph v${VERSION} in: $TARGET_DIR"
echo ""
mkdir -p ".ralph/skills/prd"
mkdir -p ".ralph/skills/ralph"
mkdir -p ".ralph/skills/masterplan"
mkdir -p ".ralph/state"
mkdir -p ".ralph/archive"
mkdir -p "plans"
# ---------------------------------------------------------------------------
# Copy infrastructure files (always overwrite)
# ---------------------------------------------------------------------------
echo "Infrastructure (.ralph/):"
cp -f "$RALPH_HOME/run.sh" ".ralph/run.sh"
chmod +x ".ralph/run.sh"
echo " [done] run.sh"
cp -f "$RALPH_HOME/CLAUDE.md" ".ralph/CLAUDE.md"
echo " [done] CLAUDE.md"
if [[ -f "$RALPH_HOME/prompt.md" ]]; then
cp -f "$RALPH_HOME/prompt.md" ".ralph/prompt.md"
echo " [done] prompt.md"
fi
# ---------------------------------------------------------------------------
# Copy mega-ralph templates (always overwrite)
# ---------------------------------------------------------------------------
echo ""
echo "Mega-ralph templates (.ralph/):"
cp -f "$RALPH_HOME/mega-claude-prompt.md" ".ralph/mega-claude-prompt.md"
echo " [done] mega-claude-prompt.md"
cp -f "$RALPH_HOME/mega-ralph-convert-prompt.md" ".ralph/mega-ralph-convert-prompt.md"
echo " [done] mega-ralph-convert-prompt.md"
cp -f "$RALPH_HOME/mega-ralph-reflect-prompt.md" ".ralph/mega-ralph-reflect-prompt.md"
echo " [done] mega-ralph-reflect-prompt.md"
echo ""
echo "Review templates (.ralph/):"
cp -f "$RALPH_HOME/review-prompt.md" ".ralph/review-prompt.md"
echo " [done] review-prompt.md"
cp -f "$RALPH_HOME/review-fixes-prompt.md" ".ralph/review-fixes-prompt.md"
echo " [done] review-fixes-prompt.md"
cp -f "$RALPH_HOME/phase-review-prompt.md" ".ralph/phase-review-prompt.md"
echo " [done] phase-review-prompt.md"
# ---------------------------------------------------------------------------
# Copy skills (always overwrite)
# ---------------------------------------------------------------------------
echo ""
echo "Skills (.ralph/skills/):"
if [[ -d "$RALPH_HOME/skills" ]]; then
cp -f "$RALPH_HOME/skills/prd/SKILL.md" ".ralph/skills/prd/SKILL.md"
cp -f "$RALPH_HOME/skills/ralph/SKILL.md" ".ralph/skills/ralph/SKILL.md"
cp -f "$RALPH_HOME/skills/masterplan/SKILL.md" ".ralph/skills/masterplan/SKILL.md"
echo " [done] skills/prd/SKILL.md"
echo " [done] skills/ralph/SKILL.md"
echo " [done] skills/masterplan/SKILL.md"
fi
# ---------------------------------------------------------------------------
# Append .ralph/ to project .gitignore
# ---------------------------------------------------------------------------
echo ""
grep -qxF '.ralph/' .gitignore 2>/dev/null || echo '.ralph/' >> .gitignore
echo " [done] .gitignore (.ralph/ entry)"
# ---------------------------------------------------------------------------
# Remove old ralph.sh / mega-ralph.sh if present (v3 remnants)
# ---------------------------------------------------------------------------
rm -f ".ralph/ralph.sh" 2>/dev/null || true
rm -f ".ralph/mega-ralph.sh" 2>/dev/null || true
# ---------------------------------------------------------------------------
# Write VERSION
# ---------------------------------------------------------------------------
echo "$VERSION" > ".ralph/VERSION"
# ---------------------------------------------------------------------------
# Print instructions
# ---------------------------------------------------------------------------
echo ""
echo "================================================================"
echo " Ralph v${VERSION} setup complete!"
echo "================================================================"
echo ""
echo "Directory structure:"
echo " plans/ - PRD & masterplan files (committed)"
echo " .gitignore - Has .ralph/ entry"
echo ""
echo " .ralph/ - Infrastructure (gitignored)"
echo " run.sh - Unified entry point"
echo " state/ - Per-plan runtime state"
echo " archive/ - Completed run archives"
echo " skills/ - Skill definitions"
echo ""
echo "Next steps:"
echo ""
echo " Single feature:"
echo " 1. Create a PRD: use /prd skill"
echo " 2. Convert to JSON: use /ralph skill"
echo " 3. Run: .ralph/run.sh --tool claude"
echo ""
echo " Multi-phase project:"
echo " 1. Create a masterplan: use /masterplan skill"
echo " 2. Run: .ralph/run.sh --plan M1 --tool claude"
echo ""