-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-loop
More file actions
55 lines (46 loc) · 1.2 KB
/
task-loop
File metadata and controls
55 lines (46 loc) · 1.2 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
#!/usr/bin/env bash
set -euo pipefail
# task-loop: Run complete-next-task in loop until PRD complete
# Usage: task-loop <feature> [--max-iterations=N]
MAX_ITERATIONS=25
# Parse args
while [[ $# -gt 0 ]]; do
case $1 in
--max-iterations=*)
MAX_ITERATIONS="${1#*=}"
shift
;;
--max-iterations)
MAX_ITERATIONS="$2"
shift 2
;;
-*)
echo "Unknown option: $1" >&2
exit 1
;;
*)
FEATURE="$1"
shift
;;
esac
done
if [[ -z "${FEATURE:-}" ]]; then
echo "Usage: task-loop <feature> [--max-iterations=N]"
exit 1
fi
COMPLETE_MARKER="<tasks>COMPLETE</tasks>"
for ((i=1; i<=MAX_ITERATIONS; i++)); do
echo "=== Iteration $i/$MAX_ITERATIONS ==="
# Stream output and check for completion marker
found=false
while IFS= read -r line; do
printf '%s\n' "$line"
[[ "$line" == *"$COMPLETE_MARKER"* ]] && found=true
done < <(opencode run --command complete-next-task "$FEATURE" 2>&1)
if $found; then
echo "PRD complete, exiting."
exit 0
fi
done
echo "Max iterations ($MAX_ITERATIONS) reached."
exit 1