claude-evolve 1.8.23 → 1.8.25
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-ideate +31 -25
- package/bin/claude-evolve-worker +4 -4
- package/lib/ai-cli.sh +36 -0
- package/package.json +1 -1
package/bin/claude-evolve-ideate
CHANGED
|
@@ -335,14 +335,15 @@ print(max_gen)
|
|
|
335
335
|
# Keep incrementing until we find a generation with no Python files
|
|
336
336
|
local candidate_gen=$start_gen
|
|
337
337
|
while true; do
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
# No padding - generation numbers are used as-is in filenames
|
|
339
|
+
local gen_formatted="$candidate_gen"
|
|
340
|
+
|
|
340
341
|
# Check if any Python files exist for this generation
|
|
341
342
|
local py_files_exist=false
|
|
342
343
|
if ls "$FULL_OUTPUT_DIR"/evolution_gen${gen_formatted}-*.py >/dev/null 2>&1; then
|
|
343
344
|
py_files_exist=true
|
|
344
345
|
fi
|
|
345
|
-
|
|
346
|
+
|
|
346
347
|
if [[ "$py_files_exist" == "false" ]]; then
|
|
347
348
|
# This generation is safe to use
|
|
348
349
|
echo "$gen_formatted"
|
|
@@ -350,10 +351,10 @@ print(max_gen)
|
|
|
350
351
|
else
|
|
351
352
|
echo "[WARN] Generation $gen_formatted already has Python files, skipping to next generation" >&2
|
|
352
353
|
candidate_gen=$((candidate_gen + 1))
|
|
353
|
-
|
|
354
|
+
|
|
354
355
|
# Safety check to prevent infinite loop
|
|
355
|
-
if [[ $candidate_gen -gt
|
|
356
|
-
echo "[ERROR] Could not find a safe generation number (checked up to
|
|
356
|
+
if [[ $candidate_gen -gt 9999 ]]; then
|
|
357
|
+
echo "[ERROR] Could not find a safe generation number (checked up to 9999)" >&2
|
|
357
358
|
exit 1
|
|
358
359
|
fi
|
|
359
360
|
fi
|
|
@@ -1064,7 +1065,9 @@ generate_novel_ideas_direct() {
|
|
|
1064
1065
|
# Get existing Python files for this generation to avoid ID collisions
|
|
1065
1066
|
local existing_py_files=$(get_existing_py_files_for_generation "$CURRENT_GENERATION")
|
|
1066
1067
|
|
|
1067
|
-
local prompt="
|
|
1068
|
+
local prompt="$(get_git_protection_warning)
|
|
1069
|
+
|
|
1070
|
+
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1068
1071
|
|
|
1069
1072
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
1070
1073
|
|
|
@@ -1117,8 +1120,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1117
1120
|
11. Consider machine learning, new indicators, regime detection, risk management, etc.
|
|
1118
1121
|
|
|
1119
1122
|
IMPORTANT: You must APPEND new rows to the existing CSV file. DO NOT replace the file contents. All existing rows must remain unchanged.
|
|
1120
|
-
CRITICAL: You must use your file editing tools (Edit/MultiEdit) to modify the CSV file. DO NOT return CSV text - use your tools to edit the file directly.
|
|
1121
|
-
CRITICAL: Do NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
1123
|
+
CRITICAL: You must use your file editing tools (Edit/MultiEdit) to modify the CSV file. DO NOT return CSV text - use your tools to edit the file directly."
|
|
1122
1124
|
|
|
1123
1125
|
# Debug prompt size and context (removed - no longer needed)
|
|
1124
1126
|
|
|
@@ -1219,7 +1221,9 @@ generate_hill_climbing_direct() {
|
|
|
1219
1221
|
|
|
1220
1222
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1221
1223
|
local prompt
|
|
1222
|
-
prompt
|
|
1224
|
+
prompt="$(get_git_protection_warning)
|
|
1225
|
+
|
|
1226
|
+
$(cat <<EOF
|
|
1223
1227
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1224
1228
|
|
|
1225
1229
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1231,7 +1235,7 @@ $top_performers
|
|
|
1231
1235
|
|
|
1232
1236
|
IMPORTANT: Generate parameter tuning ideas based primarily on the descriptions and scores above.
|
|
1233
1237
|
EOF
|
|
1234
|
-
)
|
|
1238
|
+
)"
|
|
1235
1239
|
|
|
1236
1240
|
prompt+="
|
|
1237
1241
|
|
|
@@ -1273,8 +1277,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1273
1277
|
6. You may change the parent_id field if needed to reference a different top performer
|
|
1274
1278
|
7. Each description should focus on adjusting specific parameters - include current and new values
|
|
1275
1279
|
Example: \"Lower rsi_entry from 21 to 18\" or \"Increase MA period from 20 to 50\"
|
|
1276
|
-
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting
|
|
1277
|
-
9. DO NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
1280
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1278
1281
|
|
|
1279
1282
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1280
1283
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1370,7 +1373,9 @@ generate_structural_mutation_direct() {
|
|
|
1370
1373
|
|
|
1371
1374
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1372
1375
|
local prompt
|
|
1373
|
-
prompt
|
|
1376
|
+
prompt="$(get_git_protection_warning)
|
|
1377
|
+
|
|
1378
|
+
$(cat <<EOF
|
|
1374
1379
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1375
1380
|
|
|
1376
1381
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1386,7 +1391,7 @@ IMPORTANT: DO NOT read evolution_*.py files. Generate structural ideas based ONL
|
|
|
1386
1391
|
- Your knowledge of common algorithmic structures and patterns
|
|
1387
1392
|
Reading code files wastes tokens and time. Focus on high-level architectural ideas based on the descriptions.
|
|
1388
1393
|
EOF
|
|
1389
|
-
)
|
|
1394
|
+
)"
|
|
1390
1395
|
|
|
1391
1396
|
prompt+="
|
|
1392
1397
|
|
|
@@ -1415,8 +1420,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1415
1420
|
5. When editing, preserve the CSV structure: keep the ID field unchanged
|
|
1416
1421
|
6. You may change the parent_id field if needed to reference a different top performer
|
|
1417
1422
|
7. Each description should focus on architectural/structural changes
|
|
1418
|
-
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting
|
|
1419
|
-
9. DO NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
1423
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1420
1424
|
|
|
1421
1425
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1422
1426
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1512,7 +1516,9 @@ generate_crossover_direct() {
|
|
|
1512
1516
|
|
|
1513
1517
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1514
1518
|
local prompt
|
|
1515
|
-
prompt
|
|
1519
|
+
prompt="$(get_git_protection_warning)
|
|
1520
|
+
|
|
1521
|
+
$(cat <<EOF
|
|
1516
1522
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1517
1523
|
|
|
1518
1524
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1528,7 +1534,7 @@ IMPORTANT: DO NOT read evolution_*.py files. Generate crossover ideas based ONLY
|
|
|
1528
1534
|
- Your knowledge of how different algorithmic approaches can be combined
|
|
1529
1535
|
Reading code files wastes tokens and time. Focus on combining the described features creatively.
|
|
1530
1536
|
EOF
|
|
1531
|
-
)
|
|
1537
|
+
)"
|
|
1532
1538
|
|
|
1533
1539
|
prompt+="
|
|
1534
1540
|
|
|
@@ -1557,8 +1563,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1557
1563
|
5. When editing, preserve the CSV structure: keep the ID field unchanged
|
|
1558
1564
|
6. You may change the parent_id field if needed (choose the primary parent)
|
|
1559
1565
|
7. Each description should combine actual elements from 2+ top performers
|
|
1560
|
-
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting
|
|
1561
|
-
9. DO NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
1566
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1562
1567
|
|
|
1563
1568
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1564
1569
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1625,7 +1630,9 @@ ideate_ai_legacy() {
|
|
|
1625
1630
|
|
|
1626
1631
|
# Build initial prompt safely
|
|
1627
1632
|
local prompt
|
|
1628
|
-
prompt
|
|
1633
|
+
prompt="$(get_git_protection_warning)
|
|
1634
|
+
|
|
1635
|
+
$(cat <<EOF
|
|
1629
1636
|
I need you to use your file editing capabilities to add exactly $TOTAL_IDEAS algorithmic ideas to the CSV file: $temp_csv_basename
|
|
1630
1637
|
|
|
1631
1638
|
Current evolution context:
|
|
@@ -1635,7 +1642,7 @@ Current evolution context:
|
|
|
1635
1642
|
|
|
1636
1643
|
IMPORTANT: DO NOT read algorithm.py or any evolution_*.py files - that uses too many tokens and is unnecessary for ideation. Just generate creative ideas based on the brief and top performers listed above. Focus your creativity on the problem space, not the implementation details.
|
|
1637
1644
|
EOF
|
|
1638
|
-
)
|
|
1645
|
+
)"
|
|
1639
1646
|
|
|
1640
1647
|
if [[ -n $top_performers ]]; then
|
|
1641
1648
|
prompt+="
|
|
@@ -1677,8 +1684,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1677
1684
|
- Parameter Optimization: Entry thresholds, indicator periods, strategy weights
|
|
1678
1685
|
|
|
1679
1686
|
IMPORTANT: You must APPEND new rows to the existing CSV file. DO NOT replace the file contents. All existing rows must remain unchanged.
|
|
1680
|
-
CRITICAL: You must use your file editing tools (Edit/MultiEdit) to modify the CSV file. DO NOT return CSV text - use your tools to edit the file directly.
|
|
1681
|
-
CRITICAL: Do NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
1687
|
+
CRITICAL: You must use your file editing tools (Edit/MultiEdit) to modify the CSV file. DO NOT return CSV text - use your tools to edit the file directly."
|
|
1682
1688
|
|
|
1683
1689
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1684
1690
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
package/bin/claude-evolve-worker
CHANGED
|
@@ -348,7 +348,9 @@ with EvolutionCSV('$FULL_CSV_PATH') as csv:
|
|
|
348
348
|
|
|
349
349
|
# Use relative path for AI prompt
|
|
350
350
|
local target_basename=$(basename "$target_file")
|
|
351
|
-
local evolution_prompt="
|
|
351
|
+
local evolution_prompt="$(get_git_protection_warning)
|
|
352
|
+
|
|
353
|
+
Modify the algorithm in $target_basename based on this description: $description
|
|
352
354
|
|
|
353
355
|
The modification should be substantial and follow the description exactly. Make sure the algorithm still follows all interface requirements and can run properly.
|
|
354
356
|
|
|
@@ -358,9 +360,7 @@ IMPORTANT: If you need to read Python (.py) or CSV files, read them in chunks us
|
|
|
358
360
|
Example: Read(file_path='evolution_gen01-001.py', offset=0, limit=100) then Read(offset=100, limit=100), etc.
|
|
359
361
|
This is especially important for models with smaller context windows (like GLM).
|
|
360
362
|
|
|
361
|
-
CRITICAL: If you do not know how to implement what was asked for, or if the requested change is unclear or not feasible, you MUST refuse to make any changes. DO NOT modify the code if you are uncertain about the implementation. Simply respond that you cannot implement the requested change and explain why. It is better to refuse than to make incorrect or random changes.
|
|
362
|
-
|
|
363
|
-
CRITICAL: Do NOT use any git commands (git add, git commit, git reset, etc.). Only modify the file directly."
|
|
363
|
+
CRITICAL: If you do not know how to implement what was asked for, or if the requested change is unclear or not feasible, you MUST refuse to make any changes. DO NOT modify the code if you are uncertain about the implementation. Simply respond that you cannot implement the requested change and explain why. It is better to refuse than to make incorrect or random changes."
|
|
364
364
|
|
|
365
365
|
if [[ "$is_baseline" != "true" ]]; then
|
|
366
366
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
package/lib/ai-cli.sh
CHANGED
|
@@ -12,6 +12,42 @@
|
|
|
12
12
|
# Source config to get LLM_CLI array and model lists
|
|
13
13
|
# This will be sourced after config.sh in the main scripts
|
|
14
14
|
|
|
15
|
+
# Generate ultra-prominent git warning for AI prompts
|
|
16
|
+
# This MUST be at the TOP of every AI prompt to prevent git operations
|
|
17
|
+
get_git_protection_warning() {
|
|
18
|
+
cat <<'EOF'
|
|
19
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
20
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
21
|
+
!!!
|
|
22
|
+
!!! ⛔ ABSOLUTE PROHIBITION - READ THIS FIRST ⛔
|
|
23
|
+
!!!
|
|
24
|
+
!!! YOU ARE STRICTLY FORBIDDEN FROM USING ANY GIT COMMANDS WHATSOEVER
|
|
25
|
+
!!!
|
|
26
|
+
!!! ❌ FORBIDDEN: git commit, git add, git reset, git checkout, git revert,
|
|
27
|
+
!!! git branch, git merge, git stash, git clean, git push, git pull
|
|
28
|
+
!!! OR ANY OTHER COMMAND STARTING WITH 'git'
|
|
29
|
+
!!!
|
|
30
|
+
!!! ⚠️ WHY: This runs in production. Git operations have caused DATA LOSS.
|
|
31
|
+
!!! Multiple times AIs have corrupted evolution runs with git commands.
|
|
32
|
+
!!! Version control is ONLY managed by the human operator.
|
|
33
|
+
!!!
|
|
34
|
+
!!! ✅ WHAT YOU CAN DO: Edit files directly using file editing tools ONLY.
|
|
35
|
+
!!! Never touch version control. Ever.
|
|
36
|
+
!!!
|
|
37
|
+
!!! 💀 IF YOU USE GIT: You will corrupt the entire evolution run and lose data.
|
|
38
|
+
!!! This is an automated system. No git operations allowed.
|
|
39
|
+
!!!
|
|
40
|
+
!!! 🚨 CONSEQUENCES: If you execute ANY git command, the human operator will be
|
|
41
|
+
!!! forced to SHUT DOWN ALL AI-BASED EVOLUTION WORK and switch
|
|
42
|
+
!!! to manual-only mode. You will cause the termination of this
|
|
43
|
+
!!! entire automated evolution system. DO NOT BE THAT AI.
|
|
44
|
+
!!!
|
|
45
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
46
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
47
|
+
|
|
48
|
+
EOF
|
|
49
|
+
}
|
|
50
|
+
|
|
15
51
|
# Call an AI model using the configured command template
|
|
16
52
|
# Usage: call_ai_model_configured <model_name> <prompt>
|
|
17
53
|
# Returns: 0 on success, non-zero on failure
|