You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/zsh/functions/wiggum
+36-33Lines changed: 36 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -88,17 +88,15 @@ UNDER NO CIRCUMESTANCES SHOULD YOU MODIFY, DELETE, etc FILES LIKE:
88
88
89
89
This prompt is iteration number $iteration.
90
90
91
-
After you have completed the task, output a log entry as JSON on a single line prefixed with WIGGUM_LOG:
91
+
ONLY WORK ON A SINGLE TASK.
92
92
93
-
\`\`\`
94
-
WIGGUM_LOG:{"success":true,"summary":"CSS added to style header","steps_taken":["decided to name CSS file foo.css","created CSS file"],"commands_run":["touch ./foo.css"],"issues_encountered":[]}
95
-
\`\`\`
93
+
## Response format
96
94
97
-
ONLY WORK ON A SINGLE TASK.
95
+
Your final line of output MUST be raw JSON (not wrapped in markdown) in this exact format:
98
96
99
-
If there is no further work to do, output exactly WIGGUM:OVER instead of a log entry.
97
+
{"done":false,"success":true,"summary":"CSS added to style header","steps_taken":["decided to name CSS file foo.css","created CSS file"],"commands_run":["touch ./foo.css"],"issues_encountered":[]}
100
98
101
-
ONLY WORK ON A SINGLE TASK.
99
+
Set "done":true when there is no further work to do. Set "done":false if more iterations are needed.
102
100
EOF
103
101
} | claude -p \
104
102
--dangerously-skip-permissions \
@@ -107,43 +105,48 @@ EOF
107
105
local end_time=$(date -Iseconds)
108
106
109
107
local result_text=$(echo "$output" | jq -r '.result // empty')
108
+
local json_line=$(echo "$result_text" | grep '^{' | tail -1)
109
+
local log_json=$(echo "$json_line" | jq -c '.' 2>/dev/null)
110
110
111
-
if [[ "$result_text" == *"WIGGUM:OVER"* ]]; then
112
-
echo "Work complete (WIGGUM:OVER)"
111
+
if [[ -z "$log_json" ]]; then
112
+
echo "Warning: Failed to parse log JSON"
113
+
echo "Last JSON-like line: $json_line"
114
+
continue
115
+
fi
116
+
117
+
if [[ $(echo "$log_json" | jq -r '.done') == "true" ]]; then
118
+
echo "Work complete (done:true)"
113
119
break
114
120
fi
115
-
local log_json=$(echo "$result_text" | grep -oE 'WIGGUM_LOG:\{[^}]+\}' | head -1 | sed 's/WIGGUM_LOG://')
116
121
local input_tokens=$(echo "$output" | jq -r '.usage.input_tokens // 0')
117
122
local output_tokens=$(echo "$output" | jq -r '.usage.output_tokens // 0')
118
123
local start_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${start_time%[-+]*}" "+%s" 2>/dev/null)
119
124
local end_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${end_time%[-+]*}" "+%s" 2>/dev/null)
0 commit comments