claude-evolve 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/claude-evolve-analyze +26 -25
- package/bin/claude-evolve-run +66 -26
- package/package.json +1 -1
|
@@ -81,24 +81,25 @@ while IFS=, read -r id _ desc perf status; do
|
|
|
81
81
|
((total++))
|
|
82
82
|
|
|
83
83
|
case "$status" in
|
|
84
|
-
"
|
|
84
|
+
"complete" | "completed")
|
|
85
|
+
((completed++))
|
|
86
|
+
# Only count performance for completed runs
|
|
87
|
+
if [[ -n $perf && $perf != "" ]]; then
|
|
88
|
+
total_performance=$(echo "$total_performance + $perf" | bc -l 2>/dev/null || echo "$total_performance")
|
|
89
|
+
((count_with_performance++))
|
|
90
|
+
|
|
91
|
+
# Check if this is the top performer
|
|
92
|
+
if [[ -z $top_score ]] || (($(echo "$perf > $top_score" | bc -l 2>/dev/null || echo "0"))); then
|
|
93
|
+
top_score="$perf"
|
|
94
|
+
top_id="$id"
|
|
95
|
+
top_desc="$desc"
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
;;
|
|
85
99
|
"running") ((running++)) ;;
|
|
86
100
|
"failed" | "timeout" | "interrupted") ((failed++)) ;;
|
|
87
101
|
*) ((pending++)) ;;
|
|
88
102
|
esac
|
|
89
|
-
|
|
90
|
-
# Track performance stats
|
|
91
|
-
if [[ -n $perf && $perf != "" ]]; then
|
|
92
|
-
total_performance=$(echo "$total_performance + $perf" | bc -l 2>/dev/null || echo "$total_performance")
|
|
93
|
-
((count_with_performance++))
|
|
94
|
-
|
|
95
|
-
# Check if this is the top performer
|
|
96
|
-
if [[ -z $top_score ]] || (($(echo "$perf > $top_score" | bc -l 2>/dev/null || echo "0"))); then
|
|
97
|
-
top_score="$perf"
|
|
98
|
-
top_id="$id"
|
|
99
|
-
top_desc="$desc"
|
|
100
|
-
fi
|
|
101
|
-
fi
|
|
102
103
|
done <"$csv_file"
|
|
103
104
|
|
|
104
105
|
# Display summary
|
|
@@ -153,17 +154,17 @@ plot "$data_file" using 1:2 with linespoints title "Performance"
|
|
|
153
154
|
EOF
|
|
154
155
|
|
|
155
156
|
rm -f "$data_file"
|
|
156
|
-
echo "Chart saved
|
|
157
|
-
|
|
158
|
-
#
|
|
159
|
-
if
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
157
|
+
echo "Chart saved to: $output_file"
|
|
158
|
+
|
|
159
|
+
# Always try to open chart (not just when --open is used)
|
|
160
|
+
if command -v open >/dev/null 2>&1; then
|
|
161
|
+
open "$output_file"
|
|
162
|
+
echo "Opening chart..."
|
|
163
|
+
elif command -v xdg-open >/dev/null 2>&1; then
|
|
164
|
+
xdg-open "$output_file"
|
|
165
|
+
echo "Opening chart..."
|
|
166
|
+
else
|
|
167
|
+
echo "[WARN] Cannot open chart automatically. View: $output_file"
|
|
167
168
|
fi
|
|
168
169
|
else
|
|
169
170
|
if [[ $count_with_performance -eq 0 ]]; then
|
package/bin/claude-evolve-run
CHANGED
|
@@ -49,8 +49,27 @@ EOF
|
|
|
49
49
|
esac
|
|
50
50
|
done
|
|
51
51
|
|
|
52
|
-
echo "[INFO] Starting evolution run..."
|
|
53
|
-
[
|
|
52
|
+
echo "[INFO] Starting continuous evolution run..."
|
|
53
|
+
echo "[INFO] Will continue running until no more pending candidates or 5 consecutive failures"
|
|
54
|
+
[[ -n $timeout_seconds ]] && echo "[INFO] Using timeout: ${timeout_seconds} seconds per evaluation"
|
|
55
|
+
|
|
56
|
+
# Track consecutive failures
|
|
57
|
+
consecutive_failures=0
|
|
58
|
+
MAX_FAILURES=5
|
|
59
|
+
|
|
60
|
+
# Track if we should continue after a failure
|
|
61
|
+
should_continue_after_failure() {
|
|
62
|
+
((consecutive_failures++))
|
|
63
|
+
|
|
64
|
+
if [[ $consecutive_failures -ge $MAX_FAILURES ]]; then
|
|
65
|
+
echo "[ERROR] Too many consecutive failures ($consecutive_failures). Stopping evolution run." >&2
|
|
66
|
+
return 1
|
|
67
|
+
else
|
|
68
|
+
echo "[WARN] Failure $consecutive_failures of $MAX_FAILURES. Continuing to next candidate..." >&2
|
|
69
|
+
echo "----------------------------------------"
|
|
70
|
+
return 0
|
|
71
|
+
fi
|
|
72
|
+
}
|
|
54
73
|
|
|
55
74
|
# Validate workspace using config
|
|
56
75
|
if [[ ! -d "$FULL_EVOLUTION_DIR" ]]; then
|
|
@@ -119,11 +138,13 @@ update_csv_row() {
|
|
|
119
138
|
mv "$temp_file" "$FULL_CSV_PATH"
|
|
120
139
|
}
|
|
121
140
|
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
# Main evolution loop
|
|
142
|
+
while true; do
|
|
143
|
+
# Find next candidate
|
|
144
|
+
if ! row_num=$(find_empty_row); then
|
|
145
|
+
echo "[INFO] No more pending candidates found. Evolution run complete!"
|
|
146
|
+
exit 0
|
|
147
|
+
fi
|
|
127
148
|
|
|
128
149
|
# Get row data
|
|
129
150
|
row_data=$(get_csv_row "$row_num")
|
|
@@ -157,7 +178,11 @@ else
|
|
|
157
178
|
if [[ ! -f $parent_file ]]; then
|
|
158
179
|
echo "[ERROR] Parent algorithm file not found: $parent_file" >&2
|
|
159
180
|
update_csv_row "$row_num" "" "failed"
|
|
160
|
-
|
|
181
|
+
if should_continue_after_failure; then
|
|
182
|
+
continue
|
|
183
|
+
else
|
|
184
|
+
exit 1
|
|
185
|
+
fi
|
|
161
186
|
fi
|
|
162
187
|
fi
|
|
163
188
|
|
|
@@ -192,11 +217,11 @@ if [ $((LOOP_COUNTER % 4)) -eq 0 ]; then
|
|
|
192
217
|
echo -e "\033[33m**** MEGATHINKING MODE ACTIVATED ****\033[0m"
|
|
193
218
|
CLAUDE_MODEL="opus"
|
|
194
219
|
MEGATHINK_PREFIX="megathink: "
|
|
195
|
-
echo "[INFO] Using Claude Opus for architectural thinking
|
|
220
|
+
echo "[INFO] Using Claude Opus for architectural thinking"
|
|
196
221
|
else
|
|
197
222
|
CLAUDE_MODEL="sonnet"
|
|
198
223
|
MEGATHINK_PREFIX=""
|
|
199
|
-
echo "[INFO] Using Claude Sonnet for development
|
|
224
|
+
echo "[INFO] Using Claude Sonnet for development"
|
|
200
225
|
fi
|
|
201
226
|
|
|
202
227
|
# Increment and save counter
|
|
@@ -228,24 +253,18 @@ if [[ $id == "000" || $id == "0" ]]; then
|
|
|
228
253
|
echo "[INFO] Baseline algorithm - skipping mutation, using original"
|
|
229
254
|
else
|
|
230
255
|
echo "[INFO] Calling Claude $CLAUDE_MODEL to apply mutation..."
|
|
231
|
-
echo "[DEBUG] Claude command: $claude_cmd --model $CLAUDE_MODEL -p"
|
|
232
|
-
|
|
233
|
-
# Save prompt to temp file for debugging
|
|
234
|
-
local prompt_file="/tmp/claude-evolve-prompt-$$.txt"
|
|
235
|
-
echo "$prompt" > "$prompt_file"
|
|
236
|
-
echo "[DEBUG] Prompt saved to: $prompt_file ($(wc -l < "$prompt_file") lines)"
|
|
237
256
|
|
|
238
|
-
# Try with explicit pipe and error capture - NEED -p flag for piped input!
|
|
239
257
|
if ! generated_code=$(echo "$prompt" | "$claude_cmd" --model $CLAUDE_MODEL -p 2>&1); then
|
|
240
258
|
echo "[ERROR] Claude failed to generate algorithm mutation" >&2
|
|
241
259
|
echo "[ERROR] Claude output: $generated_code" >&2
|
|
242
|
-
rm -f "$prompt_file"
|
|
243
260
|
update_csv_row "$row_num" "" "failed"
|
|
244
|
-
|
|
261
|
+
if should_continue_after_failure; then
|
|
262
|
+
continue
|
|
263
|
+
else
|
|
264
|
+
exit 1
|
|
265
|
+
fi
|
|
245
266
|
fi
|
|
246
267
|
|
|
247
|
-
rm -f "$prompt_file"
|
|
248
|
-
|
|
249
268
|
# Save generated algorithm (overwrite the copied file)
|
|
250
269
|
echo "$generated_code" >"$output_file"
|
|
251
270
|
echo "[INFO] Claude successfully mutated algorithm"
|
|
@@ -268,7 +287,11 @@ if [[ -n $timeout_seconds ]]; then
|
|
|
268
287
|
if [[ $eval_exit_code -eq 124 ]]; then
|
|
269
288
|
echo "[ERROR] Evaluation timed out after ${timeout_seconds} seconds" >&2
|
|
270
289
|
update_csv_row "$row_num" "" "timeout"
|
|
271
|
-
|
|
290
|
+
if should_continue_after_failure; then
|
|
291
|
+
continue 2 # Continue outer while loop from nested context
|
|
292
|
+
else
|
|
293
|
+
exit 1
|
|
294
|
+
fi
|
|
272
295
|
fi
|
|
273
296
|
fi
|
|
274
297
|
else
|
|
@@ -303,20 +326,37 @@ if [[ $eval_exit_code -eq 0 ]]; then
|
|
|
303
326
|
echo "[ERROR] No score found in evaluator output" >&2
|
|
304
327
|
echo "[ERROR] Output: $eval_output" >&2
|
|
305
328
|
update_csv_row "$row_num" "" "failed"
|
|
306
|
-
|
|
329
|
+
if should_continue_after_failure; then
|
|
330
|
+
continue 2
|
|
331
|
+
else
|
|
332
|
+
exit 1
|
|
333
|
+
fi
|
|
307
334
|
fi
|
|
308
335
|
fi
|
|
309
336
|
else
|
|
310
337
|
echo "[ERROR] Failed to parse evaluator output" >&2
|
|
311
338
|
echo "[ERROR] Output: $eval_output" >&2
|
|
312
339
|
update_csv_row "$row_num" "" "failed"
|
|
313
|
-
|
|
340
|
+
if should_continue_after_failure; then
|
|
341
|
+
continue
|
|
342
|
+
else
|
|
343
|
+
exit 1
|
|
344
|
+
fi
|
|
314
345
|
fi
|
|
315
346
|
else
|
|
316
347
|
echo "[ERROR] Evaluator failed with exit code $eval_exit_code" >&2
|
|
317
348
|
echo "[ERROR] Output: $eval_output" >&2
|
|
318
349
|
update_csv_row "$row_num" "" "failed"
|
|
319
|
-
|
|
350
|
+
if should_continue_after_failure; then
|
|
351
|
+
continue
|
|
352
|
+
else
|
|
353
|
+
exit 1
|
|
354
|
+
fi
|
|
320
355
|
fi
|
|
321
356
|
|
|
322
|
-
echo "[INFO] Evolution cycle completed successfully!"
|
|
357
|
+
echo "[INFO] Evolution cycle completed successfully!"
|
|
358
|
+
consecutive_failures=0 # Reset failure counter on success
|
|
359
|
+
|
|
360
|
+
echo "[INFO] Looking for next candidate..."
|
|
361
|
+
echo "----------------------------------------"
|
|
362
|
+
done # End of main evolution loop
|