claude-evolve 1.0.20 → 1.1.1
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-run +46 -25
- package/package.json +1 -1
package/bin/claude-evolve-run
CHANGED
|
@@ -53,6 +53,9 @@ echo "[INFO] Starting continuous evolution run..."
|
|
|
53
53
|
echo "[INFO] Will continue running until no more pending candidates or 5 consecutive failures"
|
|
54
54
|
[[ -n $timeout_seconds ]] && echo "[INFO] Using timeout: ${timeout_seconds} seconds per evaluation"
|
|
55
55
|
|
|
56
|
+
# Prepare logging directory
|
|
57
|
+
mkdir -p logs
|
|
58
|
+
|
|
56
59
|
# Track consecutive failures
|
|
57
60
|
consecutive_failures=0
|
|
58
61
|
MAX_FAILURES=5
|
|
@@ -145,6 +148,9 @@ while true; do
|
|
|
145
148
|
echo "[INFO] No more pending candidates found. Evolution run complete!"
|
|
146
149
|
exit 0
|
|
147
150
|
fi
|
|
151
|
+
|
|
152
|
+
# Create log file for this iteration
|
|
153
|
+
LOGFILE="logs/claude-$(date +%Y%m%d_%H%M%S).txt"
|
|
148
154
|
|
|
149
155
|
# Get row data
|
|
150
156
|
row_data=$(get_csv_row "$row_num")
|
|
@@ -227,36 +233,39 @@ fi
|
|
|
227
233
|
# Increment and save counter
|
|
228
234
|
echo $((LOOP_COUNTER + 1)) > "$FULL_EVOLUTION_DIR/.loop_counter"
|
|
229
235
|
|
|
230
|
-
# Create mutation prompt
|
|
231
|
-
prompt="${MEGATHINK_PREFIX}
|
|
232
|
-
|
|
233
|
-
CONTEXT:
|
|
234
|
-
$(cat "$FULL_BRIEF_PATH" 2>/dev/null || echo "No brief available")
|
|
235
|
-
|
|
236
|
-
ALGORITHM FILE TO MODIFY: $output_file
|
|
236
|
+
# Create mutation prompt - Claude will edit the file directly
|
|
237
|
+
prompt="${MEGATHINK_PREFIX}Please edit file $output_file to implement the following change for iteration $id: $description
|
|
237
238
|
|
|
238
|
-
|
|
239
|
-
$description
|
|
239
|
+
There may be extra information in documentation in the $FULL_EVOLUTION_DIR/*.md files.
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
1. Read the existing algorithm file at $output_file
|
|
243
|
-
2. Apply the requested modification while preserving the core structure
|
|
244
|
-
3. Ensure the modified algorithm maintains the same interface (function signatures)
|
|
245
|
-
4. Include proper error handling and documentation
|
|
246
|
-
5. Overwrite the file with your improved version
|
|
247
|
-
6. Return ONLY the complete Python code without explanation
|
|
248
|
-
|
|
249
|
-
The output should be a complete, executable Python file that builds upon the existing algorithm."
|
|
241
|
+
The algorithm should maintain the same interface (function signatures) and include proper error handling."
|
|
250
242
|
|
|
251
243
|
# Generate mutation (skip for baseline)
|
|
252
244
|
if [[ $id == "000" || $id == "0" ]]; then
|
|
253
245
|
echo "[INFO] Baseline algorithm - skipping mutation, using original"
|
|
254
246
|
else
|
|
255
247
|
echo "[INFO] Calling Claude $CLAUDE_MODEL to apply mutation..."
|
|
248
|
+
echo "[INFO] Claude will edit: $output_file"
|
|
249
|
+
echo "[INFO] Logging to: ${LOGFILE}-developer"
|
|
250
|
+
|
|
251
|
+
# Claude will edit the file directly - log both prompt and response
|
|
252
|
+
{
|
|
253
|
+
echo "=== EVOLUTION MUTATION PROMPT ==="
|
|
254
|
+
echo "ID: $id"
|
|
255
|
+
echo "Based on: $based_on_id"
|
|
256
|
+
echo "Description: $description"
|
|
257
|
+
echo "Output file: $output_file"
|
|
258
|
+
echo "Model: $CLAUDE_MODEL"
|
|
259
|
+
echo "Timestamp: $(date)"
|
|
260
|
+
echo
|
|
261
|
+
echo "$prompt"
|
|
262
|
+
echo
|
|
263
|
+
echo "=== CLAUDE RESPONSE ==="
|
|
264
|
+
} >> "${LOGFILE}-developer"
|
|
256
265
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
echo "[ERROR] Claude
|
|
266
|
+
# Use tee to show output and log simultaneously
|
|
267
|
+
if ! echo "$prompt" | "$claude_cmd" --model $CLAUDE_MODEL -p 2>&1 | tee -a "${LOGFILE}-developer"; then
|
|
268
|
+
echo "[ERROR] Claude failed to mutate algorithm" >&2
|
|
260
269
|
update_csv_row "$row_num" "" "failed"
|
|
261
270
|
if should_continue_after_failure; then
|
|
262
271
|
continue
|
|
@@ -265,9 +274,7 @@ else
|
|
|
265
274
|
fi
|
|
266
275
|
fi
|
|
267
276
|
|
|
268
|
-
|
|
269
|
-
echo "$generated_code" >"$output_file"
|
|
270
|
-
echo "[INFO] Claude successfully mutated algorithm"
|
|
277
|
+
echo "[INFO] Claude completed mutation"
|
|
271
278
|
fi
|
|
272
279
|
|
|
273
280
|
echo "[INFO] Algorithm ready at: $output_file"
|
|
@@ -302,12 +309,26 @@ else
|
|
|
302
309
|
fi
|
|
303
310
|
fi
|
|
304
311
|
|
|
305
|
-
# Show evaluator output
|
|
312
|
+
# Show evaluator output and log it
|
|
306
313
|
echo "[INFO] Evaluator output:"
|
|
307
314
|
echo "----------------------------------------"
|
|
308
315
|
echo "$eval_output"
|
|
309
316
|
echo "----------------------------------------"
|
|
310
317
|
|
|
318
|
+
# Log evaluator phase
|
|
319
|
+
{
|
|
320
|
+
echo "=== EVALUATOR EXECUTION ==="
|
|
321
|
+
echo "ID: $id"
|
|
322
|
+
echo "Algorithm: $output_file"
|
|
323
|
+
echo "Command: $PYTHON_CMD $FULL_EVALUATOR_PATH $output_file"
|
|
324
|
+
echo "Exit code: $eval_exit_code"
|
|
325
|
+
echo "Timestamp: $(date)"
|
|
326
|
+
echo
|
|
327
|
+
echo "=== EVALUATOR OUTPUT ==="
|
|
328
|
+
echo "$eval_output"
|
|
329
|
+
echo
|
|
330
|
+
} >> "${LOGFILE}-evaluator"
|
|
331
|
+
|
|
311
332
|
# Process results
|
|
312
333
|
if [[ $eval_exit_code -eq 0 ]]; then
|
|
313
334
|
# Extract score from JSON (simple grep approach)
|