claude-evolve 1.2.10 → 1.2.12

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.
@@ -11,7 +11,7 @@ load_config
11
11
  # Parse arguments
12
12
  open_chart=false
13
13
  csv_file="$FULL_CSV_PATH"
14
- output_file="$FULL_OUTPUT_DIR/performance.png"
14
+ output_file="" # Will be set later if not specified
15
15
 
16
16
  while [[ $# -gt 0 ]]; do
17
17
  case $1 in
@@ -53,6 +53,17 @@ EOF
53
53
  esac
54
54
  done
55
55
 
56
+ # Set default output file if not specified
57
+ if [[ -z "$output_file" ]]; then
58
+ if [[ -d "$FULL_OUTPUT_DIR" ]]; then
59
+ # We're in an evolution workspace
60
+ output_file="$FULL_OUTPUT_DIR/performance.png"
61
+ else
62
+ # Not in workspace, use temp file
63
+ output_file="/tmp/claude_evolve_performance_$$.png"
64
+ fi
65
+ fi
66
+
56
67
  # Check if CSV exists
57
68
  if [[ ! -f $csv_file ]]; then
58
69
  echo "[ERROR] CSV file not found: $csv_file" >&2
@@ -163,15 +174,21 @@ while IFS=, read -r id _ desc perf status; do
163
174
  done <"$csv_file"
164
175
 
165
176
  # Process generation stats
166
- for gen in $(cut -d' ' -f1 "$gen_stats_file" | sort -u); do
167
- total_in_gen=$(grep -c "^$gen " "$gen_stats_file")
168
- completed_in_gen=$(grep -c "^$gen completed" "$gen_stats_file")
177
+ for gen in $(cut -d' ' -f1 "$gen_stats_file" | sort -u || echo ""); do
178
+ [[ -z "$gen" ]] && continue
179
+ total_in_gen=$(grep -c "^$gen " "$gen_stats_file" 2>/dev/null || echo "0")
180
+ completed_in_gen=$(grep -c "^$gen completed" "$gen_stats_file" 2>/dev/null || echo "0")
181
+ # Clean any whitespace from the numbers
182
+ completed_in_gen=$(echo "$completed_in_gen" | tr -d '[:space:]')
169
183
 
170
184
  echo -n "$gen: $total_in_gen candidates"
171
185
 
172
- if [[ $completed_in_gen -gt 0 ]]; then
173
- # Calculate average performance for this generation
174
- sum=$(grep "^$gen completed" "$gen_stats_file" | awk '{s+=$3} END {print s}')
186
+ if [[ "$completed_in_gen" -gt 0 ]]; then
187
+ # Calculate average performance for this generation
188
+ sum="0"
189
+ if grep -q "^$gen completed" "$gen_stats_file"; then
190
+ sum=$(grep "^$gen completed" "$gen_stats_file" | awk '{s+=$3} END {printf "%.6f", s}' 2>/dev/null || echo "0")
191
+ fi
175
192
  avg=$(echo "scale=4; $sum / $completed_in_gen" | bc -l 2>/dev/null || echo "0")
176
193
  echo " ($completed_in_gen completed, avg: $avg)"
177
194
  else
@@ -181,16 +198,52 @@ done
181
198
 
182
199
  rm -f "$gen_stats_file"
183
200
 
201
+ # Count valid performance entries for chart (excluding zeros)
202
+ valid_performance_count=0
203
+ while IFS=, read -r id _ desc perf status; do
204
+ [[ $id == "id" ]] && continue # Skip header
205
+ if [[ $status =~ ^(complete|completed)$ && -n $perf && $perf != "" ]]; then
206
+ if (( $(echo "$perf > 0" | bc -l 2>/dev/null || echo "0") )); then
207
+ ((valid_performance_count++))
208
+ fi
209
+ fi
210
+ done <"$csv_file"
211
+
184
212
  # Simple chart generation using gnuplot if available
185
- if command -v gnuplot >/dev/null 2>&1 && [[ $count_with_performance -gt 0 ]]; then
213
+ if command -v gnuplot >/dev/null 2>&1 && [[ $valid_performance_count -gt 0 ]]; then
186
214
  echo
187
215
  echo "Generating performance chart: $output_file"
188
216
 
189
- # Create data file for gnuplot with row numbers, excluding zeros
217
+ # Create data files for gnuplot
190
218
  data_file="/tmp/evolution_data_$$.dat"
191
219
  winner_file="/tmp/evolution_winner_$$.dat"
192
- echo "# Row ID Performance" >"$data_file"
193
-
220
+ gen_avg_file="/tmp/evolution_gen_avg_$$.dat"
221
+
222
+ echo "# Row ID Performance Generation" >"$data_file"
223
+ echo "# Generation AvgPerformance Color" >"$gen_avg_file"
224
+
225
+ # Get color by generation number
226
+ get_gen_color() {
227
+ local gen_num="$1"
228
+ case $gen_num in
229
+ 1) echo "#1f77b4" ;; # blue
230
+ 2) echo "#ff7f0e" ;; # orange
231
+ 3) echo "#2ca02c" ;; # green
232
+ 4) echo "#d62728" ;; # red
233
+ 5) echo "#9467bd" ;; # purple
234
+ 6) echo "#8c564b" ;; # brown
235
+ 7) echo "#e377c2" ;; # pink
236
+ 8) echo "#7f7f7f" ;; # gray
237
+ 9) echo "#bcbd22" ;; # olive
238
+ 10) echo "#17becf" ;; # cyan
239
+ *) echo "#cccccc" ;; # default gray
240
+ esac
241
+ }
242
+
243
+ # Create temporary files for generation tracking
244
+ gen_data_temp="/tmp/evolution_gen_temp_$$.dat"
245
+ >"$gen_data_temp"
246
+
194
247
  row_num=0
195
248
  max_perf=0
196
249
  max_row=0
@@ -200,11 +253,26 @@ if command -v gnuplot >/dev/null 2>&1 && [[ $count_with_performance -gt 0 ]]; th
200
253
  [[ $id == "id" ]] && continue # Skip header
201
254
  ((row_num++))
202
255
 
256
+ # Extract generation from ID
257
+ gen="gen01" # default
258
+ if [[ $id =~ ^(gen[0-9]+)- ]]; then
259
+ gen="${BASH_REMATCH[1]}"
260
+ fi
261
+
203
262
  # Only include completed algorithms with non-zero performance
204
263
  if [[ -n $perf && $perf != "" && $status =~ ^(complete|completed)$ ]]; then
205
264
  # Skip zero values (they're errors)
206
265
  if (( $(echo "$perf > 0" | bc -l) )); then
207
- echo "$row_num \"$id\" $perf" >>"$data_file"
266
+ # Assign generation number for coloring (1-based)
267
+ gen_num=1
268
+ if [[ $id =~ ^gen([0-9]+)- ]]; then
269
+ gen_num=$((10#${BASH_REMATCH[1]}))
270
+ fi
271
+
272
+ echo "$row_num \"$id\" $perf $gen_num" >>"$data_file"
273
+
274
+ # Track for generation averages
275
+ echo "$gen $perf" >>"$gen_data_temp"
208
276
 
209
277
  # Track the winner
210
278
  if (( $(echo "$perf > $max_perf" | bc -l) )); then
@@ -216,35 +284,80 @@ if command -v gnuplot >/dev/null 2>&1 && [[ $count_with_performance -gt 0 ]]; th
216
284
  fi
217
285
  done <"$csv_file"
218
286
 
287
+ # Create generation averages file
288
+ gen_index=1
289
+ for gen in $(cut -d' ' -f1 "$gen_data_temp" | sort -u); do
290
+ if grep -q "^$gen " "$gen_data_temp"; then
291
+ # Calculate average for this generation
292
+ sum=$(grep "^$gen " "$gen_data_temp" | awk '{s+=$2} END {printf "%.6f", s}' 2>/dev/null || echo "0")
293
+ count=$(grep -c "^$gen " "$gen_data_temp")
294
+ if [[ $count -gt 0 ]]; then
295
+ avg=$(echo "scale=4; $sum / $count" | bc -l 2>/dev/null || echo "0")
296
+ gen_num=$(echo "$gen" | sed 's/gen0*//')
297
+ color=$(get_gen_color "$gen_num")
298
+ echo "$gen_index \"$gen\" $avg \"$color\"" >>"$gen_avg_file"
299
+ ((gen_index++))
300
+ fi
301
+ fi
302
+ done
303
+
219
304
  # Create winner data point
220
305
  if [[ -n $max_id ]]; then
221
306
  echo "$max_row \"$max_id\" $max_perf" >"$winner_file"
222
307
  fi
223
308
 
224
- # Generate plot
225
- gnuplot <<EOF
226
- set terminal png size 1000,600
309
+ # Generate dual plot
310
+ if [[ -s "$data_file" ]]; then
311
+ gnuplot <<EOF
312
+ set terminal png size 1200,800
227
313
  set output "$output_file"
228
- set title "Algorithm Evolution Performance"
314
+
315
+ # Set up multiplot with proper spacing
316
+ set multiplot layout 2,1 margins 0.08,0.82,0.15,0.95 spacing 0.1,0.15
317
+
318
+ #=================== TOP PLOT: Performance Over Time ===================
319
+ set title "Algorithm Evolution Performance Over Time" font ",14"
229
320
  set xlabel "Evolution Run"
230
321
  set ylabel "Performance Score"
231
322
  set grid
232
- set key off
233
-
234
- # Set y-axis range with some padding
235
- stats "$data_file" using 3 nooutput
236
- set yrange [STATS_min*0.95:STATS_max*1.05]
237
-
238
- # Plot the main line in dark blue, winner as large blue circle
239
- plot "$data_file" using 1:3 with lines linewidth 2 linecolor rgb "#1f77b4" notitle, \
240
- "$data_file" using 1:3 with points pointtype 7 pointsize 0.5 linecolor rgb "#1f77b4" notitle, \
241
- "$winner_file" using 1:3 with points pointtype 7 pointsize 3 linecolor rgb "#0000ff" notitle
242
-
243
- # Add label with winner info at bottom
244
- set label 1 "Best: $max_id (Score: $max_perf)" at graph 0.5, -0.15 center font ",10"
323
+ set key outside right
324
+
325
+ # Define colors for generations
326
+ plot "$data_file" using (\$4==1?\$1:1/0):3 with linespoints linewidth 2 linecolor rgb "#1f77b4" pointsize 0.8 title "Gen 1", \\
327
+ "$data_file" using (\$4==2?\$1:1/0):3 with linespoints linewidth 2 linecolor rgb "#ff7f0e" pointsize 0.8 title "Gen 2", \\
328
+ "$data_file" using (\$4==3?\$1:1/0):3 with linespoints linewidth 2 linecolor rgb "#2ca02c" pointsize 0.8 title "Gen 3", \\
329
+ "$data_file" using (\$4==4?\$1:1/0):3 with linespoints linewidth 2 linecolor rgb "#d62728" pointsize 0.8 title "Gen 4", \\
330
+ "$data_file" using (\$4==5?\$1:1/0):3 with linespoints linewidth 2 linecolor rgb "#9467bd" pointsize 0.8 title "Gen 5", \\
331
+ "$winner_file" using 1:3 with points pointtype 7 pointsize 4 linecolor rgb "#000000" title "Winner"
332
+
333
+ #=================== BOTTOM PLOT: Generation Averages ===================
334
+ set title "Average Performance by Generation" font ",14"
335
+ set xlabel "Generation"
336
+ set ylabel "Avg Performance"
337
+ set style fill solid 0.8
338
+ set boxwidth 0.6
339
+ unset key
340
+ set grid y
341
+
342
+ # Set custom x-axis labels
343
+ set xtics ("Gen1" 1, "Gen2" 2, "Gen3" 3, "Gen4" 4, "Gen5" 5)
344
+
345
+ plot "$gen_avg_file" using 1:3 with boxes linecolor rgb "#4CAF50" notitle
346
+
347
+ unset multiplot
348
+
349
+ # Add winner label at bottom
350
+ set terminal png size 1200,830
351
+ set output "$output_file"
352
+ set label "Best Overall: $max_id (Score: $max_perf)" at screen 0.5, 0.05 center font ",12"
353
+ replot
245
354
  EOF
355
+ else
356
+ echo "[WARN] No valid performance data to plot"
357
+ exit 0
358
+ fi
246
359
 
247
- rm -f "$data_file" "$winner_file"
360
+ rm -f "$data_file" "$winner_file" "$gen_avg_file" "$gen_data_temp"
248
361
  echo "Chart saved to: $output_file"
249
362
 
250
363
  # Always try to open chart (not just when --open is used)
@@ -258,9 +371,9 @@ EOF
258
371
  echo "[WARN] Cannot open chart automatically. View: $output_file"
259
372
  fi
260
373
  else
261
- if [[ $count_with_performance -eq 0 ]]; then
374
+ if [[ $valid_performance_count -eq 0 ]]; then
262
375
  echo
263
- echo "No performance data available for chart generation."
376
+ echo "No valid performance data available for chart generation."
264
377
  echo "Run 'claude-evolve run' to execute candidates first."
265
378
  else
266
379
  echo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-evolve",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "bin": {
5
5
  "claude-evolve": "./bin/claude-evolve",
6
6
  "claude-evolve-main": "./bin/claude-evolve-main",