Skip to content

Commit 7c6448c

Browse files
committed
Add wiggum
1 parent 6e6c499 commit 7c6448c

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

lib/zsh/functions/wiggum

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
wiggum() {
2+
local prompt_file max_iterations iteration current_branch custom_prompt no_git
3+
4+
while [[ $# -gt 0 ]]; do
5+
case "$1" in
6+
-p|--prompt)
7+
custom_prompt="$2"
8+
shift 2
9+
;;
10+
--no-git)
11+
no_git=1
12+
shift
13+
;;
14+
-i|--iterations)
15+
max_iterations="$2"
16+
shift 2
17+
;;
18+
*)
19+
shift
20+
;;
21+
esac
22+
done
23+
24+
max_iterations="${max_iterations:-0}"
25+
prompt_file="${custom_prompt:-PROMPT.md}"
26+
27+
iteration=0
28+
current_branch=$(git branch --show-current)
29+
30+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
31+
echo "Prompt: $prompt_file"
32+
echo "Branch: $current_branch"
33+
[[ $max_iterations -gt 0 ]] && echo "Max: $max_iterations iterations"
34+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
35+
36+
if [[ ! -f "$prompt_file" ]]; then
37+
echo "Error: $prompt_file not found"
38+
return 1
39+
fi
40+
41+
while true; do
42+
iteration=$((iteration + 1))
43+
44+
if [[ $max_iterations -gt 0 ]] && [[ $iteration -gt $max_iterations ]]; then
45+
echo "Reached max iterations: $max_iterations"
46+
break
47+
fi
48+
49+
local output=$({
50+
cat "$prompt_file"
51+
cat <<EOF
52+
53+
## Iteration context
54+
55+
This prompt is iteration number $iteration.
56+
57+
After you have completed the task, append an entry to activity.md with:
58+
59+
- a summary of what was done
60+
- a list of commands run
61+
- errors or issues encountered
62+
- success or failure
63+
64+
If activity.json doesn't exist, create it. It should be a JSON file containing an array of objects:
65+
66+
\`\`\`
67+
[
68+
{
69+
"iteration": 1,
70+
"success": true,
71+
"summary": "CSS added to style header",
72+
"commands_run": [
73+
"touch ./foo.css",
74+
],
75+
"issues_encountered": [],
76+
},
77+
...
78+
]
79+
\`\`\`
80+
81+
If there is no further work to do, output exactly WIGGUM:OVER
82+
EOF
83+
} | claude -p \
84+
--dangerously-skip-permissions \
85+
--output-format=stream-json \
86+
--model opus \
87+
--verbose)
88+
89+
if [[ "$output" == *"WIGGUM:OVER"* ]]; then
90+
echo "Work complete (WIGGUM:OVER)"
91+
break
92+
fi
93+
94+
if [[ -f "activity.json" ]]; then
95+
echo -e "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
96+
jq ".[] | select(.iteration == $iteration)" activity.json
97+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
98+
fi
99+
100+
[[ -z "$no_git" ]] && git commit -am "Wiggum iteration $iteration"
101+
echo -e "\n\n======================== LOOP $iteration ========================\n"
102+
done
103+
}

0 commit comments

Comments
 (0)