-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathralph.sh
More file actions
executable file
·79 lines (67 loc) · 2.1 KB
/
ralph.sh
File metadata and controls
executable file
·79 lines (67 loc) · 2.1 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
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 || -z "${1:-}" ]]; then
echo "Usage: $0 <iterations>"
exit 1
fi
if ! [[ "$1" =~ ^[0-9]+$ ]] || [[ "$1" -lt 1 ]]; then
echo "Error: <iterations> must be a positive integer"
exit 1
fi
iterations="$1"
# Default model if not provided
MODEL="${MODEL:-gpt-5.2}"
PROMPT=$(
cat <<'PROMPT'
Work in the current repo. Use these files as your source of truth:
- plans/prd.json
- progress.txt
1. Find the highest-priority feature to work on and work only on that feature.
This should be the one YOU decide has the highest priority - not necessarily the first in the list.
2. Run checks:
- npx wp-env start
- composer lint
- composer test (PHPUnit + Brain Monkey)
- npm run build
3. Update the PRD with the work that was done (plans/prd.json).
4. Append your progress to progress.txt.
Use this to leave a note for the next person working in the codebase.
5. Make a git commit of that feature.
ONLY WORK ON A SINGLE FEATURE.
If, while implementing the feature, you notice the PRD is complete, output <promise>COMPLETE</promise>.
PROMPT
)
for ((i=1; i<=iterations; i++)); do
echo -e "\nIteration $i"
echo "------------------------------------"
# Copilot may return non-zero (auth/rate limit/etc). Don't let that kill the loop.
set +e
result=$(
copilot --model "$MODEL" \
-p "@plans/prd.json @progress.txt $PROMPT" \
--allow-all-tools \
--allow-tool 'write' \
--allow-tool 'shell(composer)' \
--allow-tool 'shell(npm)' \
--allow-tool 'shell(npx)' \
--allow-tool 'shell(git)' \
--deny-tool 'shell(rm)' \
--deny-tool 'shell(git push)' \
2>&1
)
status=$?
set -e
echo "$result"
if [[ $status -ne 0 ]]; then
echo "Copilot exited with status $status; continuing to next iteration."
continue
fi
if [[ "$result" == *"<promise>COMPLETE</promise>"* ]]; then
echo "PRD complete, exiting."
if command -v tt >/dev/null 2>&1; then
tt notify "PRD complete after $i iterations"
fi
exit 0
fi
done
echo "Finished $iterations iterations without receiving the completion signal."