claude-evolve 1.0.10 → 1.0.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.
- package/bin/claude-evolve-analyze +8 -2
- package/bin/claude-evolve-run +53 -27
- package/lib/config.sh +23 -2
- package/package.json +1 -1
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
set -e
|
|
4
4
|
|
|
5
|
+
# Load configuration
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
# shellcheck source=../lib/config.sh
|
|
8
|
+
source "$SCRIPT_DIR/../lib/config.sh"
|
|
9
|
+
load_config
|
|
10
|
+
|
|
5
11
|
# Parse arguments
|
|
6
12
|
open_chart=false
|
|
7
|
-
csv_file="
|
|
8
|
-
output_file="
|
|
13
|
+
csv_file="$FULL_CSV_PATH"
|
|
14
|
+
output_file="$FULL_OUTPUT_DIR/performance.png"
|
|
9
15
|
|
|
10
16
|
while [[ $# -gt 0 ]]; do
|
|
11
17
|
case $1 in
|
package/bin/claude-evolve-run
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
set -e
|
|
4
4
|
|
|
5
|
+
# Load configuration
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
# shellcheck source=../lib/config.sh
|
|
8
|
+
source "$SCRIPT_DIR/../lib/config.sh"
|
|
9
|
+
load_config
|
|
10
|
+
|
|
5
11
|
# Parse arguments
|
|
6
12
|
timeout_seconds=""
|
|
7
13
|
|
|
@@ -46,35 +52,45 @@ done
|
|
|
46
52
|
echo "[INFO] Starting evolution run..."
|
|
47
53
|
[[ -n $timeout_seconds ]] && echo "[INFO] Using timeout: ${timeout_seconds} seconds"
|
|
48
54
|
|
|
49
|
-
# Validate workspace
|
|
50
|
-
if [[ ! -d
|
|
51
|
-
echo "[ERROR] Evolution directory not found. Run 'claude-evolve setup' first." >&2
|
|
55
|
+
# Validate workspace using config
|
|
56
|
+
if [[ ! -d "$FULL_EVOLUTION_DIR" ]]; then
|
|
57
|
+
echo "[ERROR] Evolution directory not found: $FULL_EVOLUTION_DIR. Run 'claude-evolve setup' first." >&2
|
|
52
58
|
exit 1
|
|
53
59
|
fi
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
# Check required files
|
|
62
|
+
if [[ ! -f "$FULL_CSV_PATH" ]]; then
|
|
63
|
+
echo "[ERROR] CSV file not found: $FULL_CSV_PATH" >&2
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
if [[ ! -f "$FULL_EVALUATOR_PATH" ]]; then
|
|
68
|
+
echo "[ERROR] Evaluator not found: $FULL_EVALUATOR_PATH" >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
if [[ ! -f "$FULL_ALGORITHM_PATH" ]]; then
|
|
73
|
+
echo "[ERROR] Algorithm not found: $FULL_ALGORITHM_PATH" >&2
|
|
74
|
+
exit 1
|
|
75
|
+
fi
|
|
61
76
|
|
|
62
|
-
# Find oldest
|
|
77
|
+
# Find oldest pending row (pure shell)
|
|
63
78
|
find_empty_row() {
|
|
64
79
|
local row_num=2 # Start after header
|
|
65
80
|
while IFS=, read -r id based_on desc perf status; do
|
|
66
|
-
|
|
81
|
+
# Look for rows with pending status or empty status (but not complete/failed/running)
|
|
82
|
+
if [[ $status == "pending" || (-z $perf && -z $status) ]]; then
|
|
67
83
|
echo $row_num
|
|
68
84
|
return 0
|
|
69
85
|
fi
|
|
70
86
|
((row_num++))
|
|
71
|
-
done < <(tail -n +2
|
|
87
|
+
done < <(tail -n +2 "$FULL_CSV_PATH")
|
|
72
88
|
return 1
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
# Get CSV row (pure shell)
|
|
76
92
|
get_csv_row() {
|
|
77
|
-
sed -n "${1}p"
|
|
93
|
+
sed -n "${1}p" "$FULL_CSV_PATH"
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
# Update CSV row (pure shell with temp file)
|
|
@@ -84,7 +100,7 @@ update_csv_row() {
|
|
|
84
100
|
local status="$3"
|
|
85
101
|
|
|
86
102
|
# Read CSV and update specific row
|
|
87
|
-
local temp_file="
|
|
103
|
+
local temp_file="${FULL_CSV_PATH}.tmp"
|
|
88
104
|
local current_row=1
|
|
89
105
|
|
|
90
106
|
while IFS=, read -r id based_on desc perf stat; do
|
|
@@ -96,14 +112,14 @@ update_csv_row() {
|
|
|
96
112
|
echo "$id,$based_on,$desc,$perf,$stat"
|
|
97
113
|
fi
|
|
98
114
|
((current_row++))
|
|
99
|
-
done <
|
|
115
|
+
done <"$FULL_CSV_PATH" >"$temp_file"
|
|
100
116
|
|
|
101
|
-
mv "$temp_file"
|
|
117
|
+
mv "$temp_file" "$FULL_CSV_PATH"
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
# Find next candidate
|
|
105
121
|
if ! row_num=$(find_empty_row); then
|
|
106
|
-
echo "[ERROR] No
|
|
122
|
+
echo "[ERROR] No pending candidates found in CSV. Run 'claude-evolve ideate' to add more candidates." >&2
|
|
107
123
|
exit 1
|
|
108
124
|
fi
|
|
109
125
|
|
|
@@ -111,6 +127,13 @@ fi
|
|
|
111
127
|
row_data=$(get_csv_row "$row_num")
|
|
112
128
|
IFS=, read -r id based_on_id description performance status <<<"$row_data"
|
|
113
129
|
|
|
130
|
+
# Check if ID is empty
|
|
131
|
+
if [[ -z $id ]]; then
|
|
132
|
+
echo "[ERROR] Empty ID found at row $row_num. CSV may be malformed." >&2
|
|
133
|
+
echo "[ERROR] Row data: $row_data" >&2
|
|
134
|
+
exit 1
|
|
135
|
+
fi
|
|
136
|
+
|
|
114
137
|
# Clean up description (remove quotes)
|
|
115
138
|
description=${description#\"}
|
|
116
139
|
description=${description%\"}
|
|
@@ -126,9 +149,12 @@ trap 'update_csv_row "$row_num" "" "interrupted"; echo "[INFO] Evolution interru
|
|
|
126
149
|
update_csv_row "$row_num" "" "running"
|
|
127
150
|
|
|
128
151
|
# Determine parent algorithm
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
parent_file="
|
|
152
|
+
if [[ -z $based_on_id || $based_on_id == "0" || $based_on_id == '""' ]]; then
|
|
153
|
+
# Empty or zero basedonID means use the base algorithm
|
|
154
|
+
parent_file="$FULL_ALGORITHM_PATH"
|
|
155
|
+
echo "[INFO] Using base algorithm (basedonID is empty or 0)"
|
|
156
|
+
else
|
|
157
|
+
parent_file="$FULL_OUTPUT_DIR/evolution_id${based_on_id}.py"
|
|
132
158
|
if [[ ! -f $parent_file ]]; then
|
|
133
159
|
echo "[ERROR] Parent algorithm file not found: $parent_file" >&2
|
|
134
160
|
update_csv_row "$row_num" "" "failed"
|
|
@@ -139,7 +165,7 @@ fi
|
|
|
139
165
|
echo "[INFO] Using parent algorithm: $parent_file"
|
|
140
166
|
|
|
141
167
|
# Generate mutation
|
|
142
|
-
output_file="
|
|
168
|
+
output_file="$FULL_OUTPUT_DIR/evolution_id${id}.py"
|
|
143
169
|
echo "[INFO] Generating algorithm mutation..."
|
|
144
170
|
|
|
145
171
|
# Copy parent algorithm to output file first
|
|
@@ -156,8 +182,8 @@ fi
|
|
|
156
182
|
|
|
157
183
|
# Implement claude-fsd style model selection
|
|
158
184
|
# Read/create loop counter for megathinking mode
|
|
159
|
-
if [[ -f
|
|
160
|
-
LOOP_COUNTER=$(cat
|
|
185
|
+
if [[ -f "$FULL_EVOLUTION_DIR/.loop_counter" ]]; then
|
|
186
|
+
LOOP_COUNTER=$(cat "$FULL_EVOLUTION_DIR/.loop_counter")
|
|
161
187
|
else
|
|
162
188
|
LOOP_COUNTER=1
|
|
163
189
|
fi
|
|
@@ -175,13 +201,13 @@ else
|
|
|
175
201
|
fi
|
|
176
202
|
|
|
177
203
|
# Increment and save counter
|
|
178
|
-
echo $((LOOP_COUNTER + 1)) >
|
|
204
|
+
echo $((LOOP_COUNTER + 1)) > "$FULL_EVOLUTION_DIR/.loop_counter"
|
|
179
205
|
|
|
180
206
|
# Create mutation prompt
|
|
181
207
|
prompt="${MEGATHINK_PREFIX}You are an AI assistant helping to evolve algorithms through mutations. Please modify the Python algorithm file at $output_file based on the requested modification.
|
|
182
208
|
|
|
183
209
|
CONTEXT:
|
|
184
|
-
$(cat
|
|
210
|
+
$(cat "$FULL_BRIEF_PATH" 2>/dev/null || echo "No brief available")
|
|
185
211
|
|
|
186
212
|
ALGORITHM FILE TO MODIFY: $output_file
|
|
187
213
|
|
|
@@ -216,7 +242,7 @@ eval_exit_code=0
|
|
|
216
242
|
|
|
217
243
|
if [[ -n $timeout_seconds ]]; then
|
|
218
244
|
echo "[INFO] Starting evaluation with ${timeout_seconds}s timeout..."
|
|
219
|
-
if eval_output=$(timeout "$timeout_seconds"
|
|
245
|
+
if eval_output=$(timeout "$timeout_seconds" "$PYTHON_CMD" "$FULL_EVALUATOR_PATH" "$output_file" 2>&1); then
|
|
220
246
|
eval_exit_code=0
|
|
221
247
|
else
|
|
222
248
|
eval_exit_code=$?
|
|
@@ -227,7 +253,7 @@ if [[ -n $timeout_seconds ]]; then
|
|
|
227
253
|
fi
|
|
228
254
|
fi
|
|
229
255
|
else
|
|
230
|
-
if eval_output=$(
|
|
256
|
+
if eval_output=$("$PYTHON_CMD" "$FULL_EVALUATOR_PATH" "$output_file" 2>&1); then
|
|
231
257
|
eval_exit_code=0
|
|
232
258
|
else
|
|
233
259
|
eval_exit_code=$?
|
package/lib/config.sh
CHANGED
|
@@ -59,8 +59,29 @@ load_config() {
|
|
|
59
59
|
|
|
60
60
|
# Create full paths
|
|
61
61
|
FULL_EVOLUTION_DIR="$EVOLUTION_DIR"
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
|
|
63
|
+
# Handle relative paths properly
|
|
64
|
+
if [[ $ALGORITHM_FILE == /* ]]; then
|
|
65
|
+
# Absolute path
|
|
66
|
+
FULL_ALGORITHM_PATH="$ALGORITHM_FILE"
|
|
67
|
+
elif [[ $ALGORITHM_FILE == ../* ]]; then
|
|
68
|
+
# Relative to parent directory
|
|
69
|
+
FULL_ALGORITHM_PATH="$ALGORITHM_FILE"
|
|
70
|
+
else
|
|
71
|
+
# Relative to evolution directory
|
|
72
|
+
FULL_ALGORITHM_PATH="$EVOLUTION_DIR/$ALGORITHM_FILE"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Same for evaluator
|
|
76
|
+
if [[ $EVALUATOR_FILE == /* ]]; then
|
|
77
|
+
FULL_EVALUATOR_PATH="$EVALUATOR_FILE"
|
|
78
|
+
elif [[ $EVALUATOR_FILE == ../* ]]; then
|
|
79
|
+
FULL_EVALUATOR_PATH="$EVALUATOR_FILE"
|
|
80
|
+
else
|
|
81
|
+
FULL_EVALUATOR_PATH="$EVOLUTION_DIR/$EVALUATOR_FILE"
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
# Brief and CSV are always in evolution dir
|
|
64
85
|
FULL_BRIEF_PATH="$EVOLUTION_DIR/$BRIEF_FILE"
|
|
65
86
|
FULL_CSV_PATH="$EVOLUTION_DIR/$EVOLUTION_CSV"
|
|
66
87
|
|