claude-evolve 1.8.22 → 1.8.24
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 +24 -19
- package/bin/claude-evolve-worker +4 -4
- package/lib/ai-cli.sh +40 -3
- package/package.json +1 -1
- package/lib/config.sh.bak +0 -337
package/bin/claude-evolve-ideate
CHANGED
|
@@ -1064,7 +1064,9 @@ generate_novel_ideas_direct() {
|
|
|
1064
1064
|
# Get existing Python files for this generation to avoid ID collisions
|
|
1065
1065
|
local existing_py_files=$(get_existing_py_files_for_generation "$CURRENT_GENERATION")
|
|
1066
1066
|
|
|
1067
|
-
local prompt="
|
|
1067
|
+
local prompt="$(get_git_protection_warning)
|
|
1068
|
+
|
|
1069
|
+
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1068
1070
|
|
|
1069
1071
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
1070
1072
|
|
|
@@ -1117,8 +1119,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1117
1119
|
11. Consider machine learning, new indicators, regime detection, risk management, etc.
|
|
1118
1120
|
|
|
1119
1121
|
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."
|
|
1122
|
+
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
1123
|
|
|
1123
1124
|
# Debug prompt size and context (removed - no longer needed)
|
|
1124
1125
|
|
|
@@ -1219,7 +1220,9 @@ generate_hill_climbing_direct() {
|
|
|
1219
1220
|
|
|
1220
1221
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1221
1222
|
local prompt
|
|
1222
|
-
prompt
|
|
1223
|
+
prompt="$(get_git_protection_warning)
|
|
1224
|
+
|
|
1225
|
+
$(cat <<EOF
|
|
1223
1226
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1224
1227
|
|
|
1225
1228
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1231,7 +1234,7 @@ $top_performers
|
|
|
1231
1234
|
|
|
1232
1235
|
IMPORTANT: Generate parameter tuning ideas based primarily on the descriptions and scores above.
|
|
1233
1236
|
EOF
|
|
1234
|
-
)
|
|
1237
|
+
)"
|
|
1235
1238
|
|
|
1236
1239
|
prompt+="
|
|
1237
1240
|
|
|
@@ -1273,8 +1276,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1273
1276
|
6. You may change the parent_id field if needed to reference a different top performer
|
|
1274
1277
|
7. Each description should focus on adjusting specific parameters - include current and new values
|
|
1275
1278
|
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."
|
|
1279
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1278
1280
|
|
|
1279
1281
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1280
1282
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1370,7 +1372,9 @@ generate_structural_mutation_direct() {
|
|
|
1370
1372
|
|
|
1371
1373
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1372
1374
|
local prompt
|
|
1373
|
-
prompt
|
|
1375
|
+
prompt="$(get_git_protection_warning)
|
|
1376
|
+
|
|
1377
|
+
$(cat <<EOF
|
|
1374
1378
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1375
1379
|
|
|
1376
1380
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1386,7 +1390,7 @@ IMPORTANT: DO NOT read evolution_*.py files. Generate structural ideas based ONL
|
|
|
1386
1390
|
- Your knowledge of common algorithmic structures and patterns
|
|
1387
1391
|
Reading code files wastes tokens and time. Focus on high-level architectural ideas based on the descriptions.
|
|
1388
1392
|
EOF
|
|
1389
|
-
)
|
|
1393
|
+
)"
|
|
1390
1394
|
|
|
1391
1395
|
prompt+="
|
|
1392
1396
|
|
|
@@ -1415,8 +1419,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1415
1419
|
5. When editing, preserve the CSV structure: keep the ID field unchanged
|
|
1416
1420
|
6. You may change the parent_id field if needed to reference a different top performer
|
|
1417
1421
|
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."
|
|
1422
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1420
1423
|
|
|
1421
1424
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1422
1425
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1512,7 +1515,9 @@ generate_crossover_direct() {
|
|
|
1512
1515
|
|
|
1513
1516
|
# Build prompt using cat with heredoc to avoid variable expansion issues
|
|
1514
1517
|
local prompt
|
|
1515
|
-
prompt
|
|
1518
|
+
prompt="$(get_git_protection_warning)
|
|
1519
|
+
|
|
1520
|
+
$(cat <<EOF
|
|
1516
1521
|
I need you to use your file editing capabilities to fill in PLACEHOLDER descriptions in the CSV file: $temp_csv_basename
|
|
1517
1522
|
|
|
1518
1523
|
THE FILE HAS $total_lines TOTAL LINES. Read from line $read_offset to see the placeholder rows at the end.
|
|
@@ -1528,7 +1533,7 @@ IMPORTANT: DO NOT read evolution_*.py files. Generate crossover ideas based ONLY
|
|
|
1528
1533
|
- Your knowledge of how different algorithmic approaches can be combined
|
|
1529
1534
|
Reading code files wastes tokens and time. Focus on combining the described features creatively.
|
|
1530
1535
|
EOF
|
|
1531
|
-
)
|
|
1536
|
+
)"
|
|
1532
1537
|
|
|
1533
1538
|
prompt+="
|
|
1534
1539
|
|
|
@@ -1557,8 +1562,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1557
1562
|
5. When editing, preserve the CSV structure: keep the ID field unchanged
|
|
1558
1563
|
6. You may change the parent_id field if needed (choose the primary parent)
|
|
1559
1564
|
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."
|
|
1565
|
+
8. CRITICAL: When editing, preserve the CSV formatting with proper quoting"
|
|
1562
1566
|
|
|
1563
1567
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1564
1568
|
safe_pushd "$FULL_EVOLUTION_DIR" || {
|
|
@@ -1625,7 +1629,9 @@ ideate_ai_legacy() {
|
|
|
1625
1629
|
|
|
1626
1630
|
# Build initial prompt safely
|
|
1627
1631
|
local prompt
|
|
1628
|
-
prompt
|
|
1632
|
+
prompt="$(get_git_protection_warning)
|
|
1633
|
+
|
|
1634
|
+
$(cat <<EOF
|
|
1629
1635
|
I need you to use your file editing capabilities to add exactly $TOTAL_IDEAS algorithmic ideas to the CSV file: $temp_csv_basename
|
|
1630
1636
|
|
|
1631
1637
|
Current evolution context:
|
|
@@ -1635,7 +1641,7 @@ Current evolution context:
|
|
|
1635
1641
|
|
|
1636
1642
|
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
1643
|
EOF
|
|
1638
|
-
)
|
|
1644
|
+
)"
|
|
1639
1645
|
|
|
1640
1646
|
if [[ -n $top_performers ]]; then
|
|
1641
1647
|
prompt+="
|
|
@@ -1677,8 +1683,7 @@ CRITICAL INSTRUCTIONS:
|
|
|
1677
1683
|
- Parameter Optimization: Entry thresholds, indicator periods, strategy weights
|
|
1678
1684
|
|
|
1679
1685
|
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."
|
|
1686
|
+
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
1687
|
|
|
1683
1688
|
# Change to evolution directory so AI can access files (with safe restoration on interrupt)
|
|
1684
1689
|
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
|
|
@@ -60,12 +96,12 @@ $prompt"
|
|
|
60
96
|
;;
|
|
61
97
|
gpt5high)
|
|
62
98
|
local ai_output
|
|
63
|
-
ai_output=$(timeout -k 30 600 codex exec -m gpt-5 -c model_reasoning_effort="high" --dangerously-bypass-approvals-and-sandbox "$prompt" 2>&1)
|
|
99
|
+
ai_output=$(timeout -k 30 600 codex exec -m gpt-5.1 -c model_reasoning_effort="high" --dangerously-bypass-approvals-and-sandbox "$prompt" 2>&1)
|
|
64
100
|
local ai_exit_code=$?
|
|
65
101
|
;;
|
|
66
102
|
gpt5)
|
|
67
103
|
local ai_output
|
|
68
|
-
ai_output=$(timeout -k 30 600 codex exec -m gpt-5 --dangerously-bypass-approvals-and-sandbox "$prompt" 2>&1)
|
|
104
|
+
ai_output=$(timeout -k 30 600 codex exec -m gpt-5.1 --dangerously-bypass-approvals-and-sandbox "$prompt" 2>&1)
|
|
69
105
|
local ai_exit_code=$?
|
|
70
106
|
;;
|
|
71
107
|
o3high)
|
|
@@ -134,7 +170,8 @@ $prompt"
|
|
|
134
170
|
;;
|
|
135
171
|
kimi-k2-think-moonshot)
|
|
136
172
|
local ai_output
|
|
137
|
-
|
|
173
|
+
# Use kimi CLI directly (assumes kimi is installed and configured)
|
|
174
|
+
ai_output=$(timeout -k 30 600 kimi --print -c "$prompt" 2>&1)
|
|
138
175
|
local ai_exit_code=$?
|
|
139
176
|
;;
|
|
140
177
|
codex-oss-local)
|
package/package.json
CHANGED
package/lib/config.sh.bak
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Configuration loader for claude-evolve
|
|
3
|
-
|
|
4
|
-
# Default configuration values
|
|
5
|
-
DEFAULT_EVOLUTION_DIR="evolution"
|
|
6
|
-
DEFAULT_ALGORITHM_FILE="algorithm.py"
|
|
7
|
-
DEFAULT_EVALUATOR_FILE="evaluator.py"
|
|
8
|
-
DEFAULT_BRIEF_FILE="BRIEF.md"
|
|
9
|
-
DEFAULT_EVOLUTION_CSV="evolution.csv"
|
|
10
|
-
DEFAULT_OUTPUT_DIR=""
|
|
11
|
-
DEFAULT_PARENT_SELECTION="best"
|
|
12
|
-
# Detect Python command based on platform
|
|
13
|
-
detect_python_cmd() {
|
|
14
|
-
# Try python3 first (macOS, Linux)
|
|
15
|
-
if command -v python3 >/dev/null 2>&1; then
|
|
16
|
-
echo "python3"
|
|
17
|
-
# Try python (Windows, some Linux)
|
|
18
|
-
elif command -v python >/dev/null 2>&1; then
|
|
19
|
-
# Verify it's Python 3
|
|
20
|
-
if python -c "import sys; sys.exit(0 if sys.version_info[0] >= 3 else 1)" 2>/dev/null; then
|
|
21
|
-
echo "python"
|
|
22
|
-
else
|
|
23
|
-
echo "python3" # Fallback
|
|
24
|
-
fi
|
|
25
|
-
else
|
|
26
|
-
echo "python3" # Default fallback
|
|
27
|
-
fi
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
DEFAULT_PYTHON_CMD="$(detect_python_cmd)"
|
|
31
|
-
|
|
32
|
-
# Default ideation strategy values
|
|
33
|
-
DEFAULT_TOTAL_IDEAS=15
|
|
34
|
-
DEFAULT_NOVEL_EXPLORATION=3
|
|
35
|
-
DEFAULT_HILL_CLIMBING=5
|
|
36
|
-
DEFAULT_STRUCTURAL_MUTATION=3
|
|
37
|
-
DEFAULT_CROSSOVER_HYBRID=4
|
|
38
|
-
DEFAULT_NUM_ELITES=3
|
|
39
|
-
DEFAULT_NUM_REVOLUTION=2 # Number of top novel candidates to include
|
|
40
|
-
|
|
41
|
-
# Default parallel execution values
|
|
42
|
-
DEFAULT_PARALLEL_ENABLED=false
|
|
43
|
-
DEFAULT_MAX_WORKERS=4
|
|
44
|
-
DEFAULT_LOCK_TIMEOUT=10
|
|
45
|
-
|
|
46
|
-
# Default auto ideation value
|
|
47
|
-
DEFAULT_AUTO_IDEATE=true
|
|
48
|
-
|
|
49
|
-
# Default retry value
|
|
50
|
-
DEFAULT_MAX_RETRIES=3
|
|
51
|
-
|
|
52
|
-
# Default memory limit (in MB, 0 means no limit)
|
|
53
|
-
# Set to reasonable limit for ML workloads - about half of available system RAM
|
|
54
|
-
DEFAULT_MEMORY_LIMIT_MB=12288
|
|
55
|
-
|
|
56
|
-
# Default LLM CLI configuration - use simple variables instead of arrays
|
|
57
|
-
# Run: 100% local with qwen3 via Codex+Ollama (more reliable than aider)
|
|
58
|
-
DEFAULT_LLM_RUN="codex-qwen3 codex-oss gemini-flash"
|
|
59
|
-
# Ideate: Commercial models for idea generation + local fallback
|
|
60
|
-
DEFAULT_LLM_IDEATE="gemini sonnet-think gpt5high glm grok-4 codex-qwen3 codex-oss"
|
|
61
|
-
|
|
62
|
-
# Load configuration from a YAML file and update variables
|
|
63
|
-
_load_yaml_config() {
|
|
64
|
-
local config_file="$1"
|
|
65
|
-
if [[ ! -f "$config_file" ]]; then
|
|
66
|
-
return 0 # File does not exist, nothing to load
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
echo "[DEBUG] Loading configuration from: $config_file" >&2
|
|
70
|
-
|
|
71
|
-
local in_ideation_section=false
|
|
72
|
-
local in_parallel_section=false
|
|
73
|
-
local in_llm_cli_section=false
|
|
74
|
-
local llm_cli_subsection=""
|
|
75
|
-
|
|
76
|
-
while IFS='' read -r line; do
|
|
77
|
-
[[ $line =~ ^[[:space:]]*# ]] || [[ -z $line ]] && continue
|
|
78
|
-
|
|
79
|
-
if [[ ! $line =~ ^([^:]+):(.*)$ ]]; then
|
|
80
|
-
continue
|
|
81
|
-
fi
|
|
82
|
-
local key="${BASH_REMATCH[1]}"
|
|
83
|
-
local value="${BASH_REMATCH[2]}"
|
|
84
|
-
|
|
85
|
-
local is_indented=false
|
|
86
|
-
[[ $key =~ ^[[:space:]]+ ]] && is_indented=true
|
|
87
|
-
|
|
88
|
-
key=$(echo "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
|
89
|
-
value=$(echo "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
|
90
|
-
|
|
91
|
-
if [[ "${DEBUG_CONFIG:-}" == "true" ]]; then
|
|
92
|
-
echo "[CONFIG DEBUG] Before comment removal: key='$key' value='$value'" >&2
|
|
93
|
-
fi
|
|
94
|
-
|
|
95
|
-
value=$(echo "$value" | sed 's/[[:space:]]*#.*$//')
|
|
96
|
-
value=$(echo "$value" | sed 's/^"//;s/"$//')
|
|
97
|
-
|
|
98
|
-
if [[ $key == "ideation_strategies" ]]; then
|
|
99
|
-
in_ideation_section=true
|
|
100
|
-
in_parallel_section=false
|
|
101
|
-
in_llm_cli_section=false
|
|
102
|
-
continue
|
|
103
|
-
elif [[ $key == "parallel" ]]; then
|
|
104
|
-
in_parallel_section=true
|
|
105
|
-
in_ideation_section=false
|
|
106
|
-
in_llm_cli_section=false
|
|
107
|
-
continue
|
|
108
|
-
elif [[ $key == "llm_cli" ]]; then
|
|
109
|
-
in_llm_cli_section=true
|
|
110
|
-
in_ideation_section=false
|
|
111
|
-
in_parallel_section=false
|
|
112
|
-
llm_cli_subsection=""
|
|
113
|
-
continue
|
|
114
|
-
elif [[ $is_indented == false ]] && [[ $in_ideation_section == true || $in_parallel_section == true || $in_llm_cli_section == true ]]; then
|
|
115
|
-
in_ideation_section=false
|
|
116
|
-
in_parallel_section=false
|
|
117
|
-
in_llm_cli_section=false
|
|
118
|
-
llm_cli_subsection=""
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
if [[ $in_ideation_section == true ]]; then
|
|
122
|
-
case $key in
|
|
123
|
-
total_ideas) TOTAL_IDEAS="$value" ;;
|
|
124
|
-
novel_exploration) NOVEL_EXPLORATION="$value" ;;
|
|
125
|
-
hill_climbing) HILL_CLIMBING="$value" ;;
|
|
126
|
-
structural_mutation) STRUCTURAL_MUTATION="$value" ;;
|
|
127
|
-
crossover_hybrid) CROSSOVER_HYBRID="$value" ;;
|
|
128
|
-
num_elites) NUM_ELITES="$value" ;;
|
|
129
|
-
num_revolution) NUM_REVOLUTION="$value" ;;
|
|
130
|
-
esac
|
|
131
|
-
elif [[ $in_parallel_section == true ]]; then
|
|
132
|
-
case $key in
|
|
133
|
-
enabled) PARALLEL_ENABLED="$value" ;;
|
|
134
|
-
max_workers) MAX_WORKERS="$value" ;;
|
|
135
|
-
lock_timeout) LOCK_TIMEOUT="$value" ;;
|
|
136
|
-
esac
|
|
137
|
-
elif [[ $in_llm_cli_section == true ]]; then
|
|
138
|
-
if [[ $key == "run" || $key == "ideate" ]]; then
|
|
139
|
-
case $key in
|
|
140
|
-
run) LLM_RUN="$value" ;;
|
|
141
|
-
ideate) LLM_IDEATE="$value" ;;
|
|
142
|
-
esac
|
|
143
|
-
else
|
|
144
|
-
value=$(echo "$value" | sed "s/^'//;s/'$//")
|
|
145
|
-
local var_key=$(echo "$key" | sed 's/-/_/g')
|
|
146
|
-
if [[ "${DEBUG_CONFIG:-}" == "true" ]]; then
|
|
147
|
-
echo "[CONFIG DEBUG] Setting LLM_CLI_${var_key} = '$value'" >&2
|
|
148
|
-
fi
|
|
149
|
-
eval "LLM_CLI_${var_key}=\"$value\""
|
|
150
|
-
fi
|
|
151
|
-
else
|
|
152
|
-
case $key in
|
|
153
|
-
algorithm_file) ALGORITHM_FILE="$value" ;;
|
|
154
|
-
evaluator_file) EVALUATOR_FILE="$value" ;;
|
|
155
|
-
brief_file) BRIEF_FILE="$value" ;;
|
|
156
|
-
evolution_csv) EVOLUTION_CSV="$value" ;;
|
|
157
|
-
output_dir) OUTPUT_DIR="$value" ;;
|
|
158
|
-
parent_selection) PARENT_SELECTION="$value" ;;
|
|
159
|
-
python_cmd) PYTHON_CMD="$value" ;;
|
|
160
|
-
auto_ideate) AUTO_IDEATE="$value" ;;
|
|
161
|
-
max_retries) MAX_RETRIES="$value" ;;
|
|
162
|
-
memory_limit_mb) MEMORY_LIMIT_MB="$value" ;;
|
|
163
|
-
evolution_dir):
|
|
164
|
-
echo "[WARN] evolution_dir in config is ignored - automatically inferred from config file location" >&2
|
|
165
|
-
;;
|
|
166
|
-
esac
|
|
167
|
-
fi
|
|
168
|
-
done < "$config_file"
|
|
169
|
-
# Keep track of the last config file loaded to infer evolution_dir
|
|
170
|
-
LAST_CONFIG_FILE_LOADED="$config_file"
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
load_config() {
|
|
174
|
-
echo "[DEBUG] $1 at start of load_config: '$1'" >&2
|
|
175
|
-
echo "[DEBUG] DEFAULT_EVOLUTION_DIR: $DEFAULT_EVOLUTION_DIR" >&2
|
|
176
|
-
# Set defaults first
|
|
177
|
-
EVOLUTION_DIR="$DEFAULT_EVOLUTION_DIR" # Initialize with default
|
|
178
|
-
ALGORITHM_FILE="$DEFAULT_ALGORITHM_FILE"
|
|
179
|
-
EVALUATOR_FILE="$DEFAULT_EVALUATOR_FILE"
|
|
180
|
-
BRIEF_FILE="$DEFAULT_BRIEF_FILE"
|
|
181
|
-
EVOLUTION_CSV="$DEFAULT_EVOLUTION_CSV"
|
|
182
|
-
OUTPUT_DIR="$DEFAULT_OUTPUT_DIR"
|
|
183
|
-
PARENT_SELECTION="$DEFAULT_PARENT_SELECTION"
|
|
184
|
-
PYTHON_CMD="$DEFAULT_PYTHON_CMD"
|
|
185
|
-
|
|
186
|
-
# Determine EVOLUTION_DIR based on specified logic, overriding default if found
|
|
187
|
-
if [[ -n "$CLAUDE_EVOLVE_WORKING_DIR" ]]; then
|
|
188
|
-
echo "[DEBUG] EVOLUTION_DIR set by CLAUDE_EVOLVE_WORKING_DIR: $CLAUDE_EVOLVE_WORKING_DIR" >&2
|
|
189
|
-
EVOLUTION_DIR="$CLAUDE_EVOLVE_WORKING_DIR"
|
|
190
|
-
elif [[ -f "evolution/evolution.csv" ]]; then
|
|
191
|
-
echo "[DEBUG] EVOLUTION_DIR set by evolution/evolution.csv: evolution" >&2
|
|
192
|
-
EVOLUTION_DIR="evolution"
|
|
193
|
-
elif [[ -f "./evolution.csv" ]]; then
|
|
194
|
-
echo "[DEBUG] EVOLUTION_DIR set by ./evolution.csv: ." >&2
|
|
195
|
-
EVOLUTION_DIR="."
|
|
196
|
-
else
|
|
197
|
-
echo "[DEBUG] EVOLUTION_DIR defaulting to: $DEFAULT_EVOLUTION_DIR" >&2
|
|
198
|
-
fi
|
|
199
|
-
echo "[DEBUG] EVOLUTION_DIR after initial determination: $EVOLUTION_DIR" >&2
|
|
200
|
-
|
|
201
|
-
TOTAL_IDEAS="$DEFAULT_TOTAL_IDEAS"
|
|
202
|
-
NOVEL_EXPLORATION="$DEFAULT_NOVEL_EXPLORATION"
|
|
203
|
-
HILL_CLIMBING="$DEFAULT_HILL_CLIMBING"
|
|
204
|
-
STRUCTURAL_MUTATION="$DEFAULT_STRUCTURAL_MUTATION"
|
|
205
|
-
CROSSOVER_HYBRID="$DEFAULT_CROSSOVER_HYBRID"
|
|
206
|
-
NUM_ELITES="$DEFAULT_NUM_ELITES"
|
|
207
|
-
NUM_REVOLUTION="$DEFAULT_NUM_REVOLUTION"
|
|
208
|
-
|
|
209
|
-
PARALLEL_ENABLED="$DEFAULT_PARALLEL_ENABLED"
|
|
210
|
-
MAX_WORKERS="$DEFAULT_MAX_WORKERS"
|
|
211
|
-
LOCK_TIMEOUT="$DEFAULT_LOCK_TIMEOUT"
|
|
212
|
-
|
|
213
|
-
AUTO_IDEATE="$DEFAULT_AUTO_IDEATE"
|
|
214
|
-
MAX_RETRIES="$DEFAULT_MAX_RETRIES"
|
|
215
|
-
MEMORY_LIMIT_MB="$DEFAULT_MEMORY_LIMIT_MB"
|
|
216
|
-
|
|
217
|
-
LLM_CLI_gpt5high='codex exec --profile gpt5high --dangerously-bypass-approvals-and-sandbox "{{PROMPT}}"'
|
|
218
|
-
LLM_CLI_o3high='codex exec --profile o3high --dangerously-bypass-approvals-and-sandbox "{{PROMPT}}"'
|
|
219
|
-
LLM_CLI_codex='codex exec --dangerously-bypass-approvals-and-sandbox "{{PROMPT}}"'
|
|
220
|
-
LLM_CLI_gemini='gemini -y -p "{{PROMPT}}"'
|
|
221
|
-
LLM_CLI_gemini_flash='gemini -y -p "{{PROMPT}}" --model gemini-2.5-flash'
|
|
222
|
-
LLM_CLI_opus='claude --dangerously-skip-permissions --mcp-config "" --model opus -p "{{PROMPT}}"'
|
|
223
|
-
LLM_CLI_opus_think='claude --dangerously-skip-permissions --mcp-config "" --model opus -p "ultrathink\n\n{{PROMPT}}"'
|
|
224
|
-
LLM_CLI_sonnet='claude --dangerously-skip-permissions --mcp-config "" --model sonnet -p "{{PROMPT}}"'
|
|
225
|
-
LLM_CLI_sonnet_think='claude --dangerously-skip-permissions --mcp-config "" --model sonnet -p "ultrathink\n\n{{PROMPT}}"'
|
|
226
|
-
LLM_CLI_cursor_sonnet='cursor-agent sonnet -p "{{PROMPT}}"'
|
|
227
|
-
LLM_CLI_cursor_opus='cursor-agent opus -p "{{PROMPT}}"'
|
|
228
|
-
LLM_CLI_glm='opencode -m openrouter/z-ai/glm-4.6 run "{{PROMPT}}"'
|
|
229
|
-
LLM_CLI_deepseek='opencode -m openrouter/deepseek/deepseek-v3.1-terminus run "{{PROMPT}}"'
|
|
230
|
-
LLM_CLI_ollama-cloud-kimi-k2='codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --oss --model kimi-k2:1t-cloud "{{PROMPT}}"' LLM_RUN="$DEFAULT_LLM_RUN"
|
|
231
|
-
LLM_IDEATE="$DEFAULT_LLM_IDEATE"
|
|
232
|
-
|
|
233
|
-
# Determine local config file path relative to EVOLUTION_DIR
|
|
234
|
-
local local_config_file="$EVOLUTION_DIR/config.yaml"
|
|
235
|
-
|
|
236
|
-
# Load local config
|
|
237
|
-
_load_yaml_config "$local_config_file"
|
|
238
|
-
|
|
239
|
-
# Load global config (overrides local config)
|
|
240
|
-
local global_config_file="$HOME/.config/claude-evolve/config.yaml"
|
|
241
|
-
_load_yaml_config "$global_config_file"
|
|
242
|
-
|
|
243
|
-
echo "[DEBUG] EVOLUTION_DIR before FULL_EVOLUTION_DIR calculation: $EVOLUTION_DIR" >&2
|
|
244
|
-
|
|
245
|
-
# Create full paths - ALL paths are relative to EVOLUTION_DIR
|
|
246
|
-
# Make EVOLUTION_DIR absolute if it\'s relative
|
|
247
|
-
if [[ "$EVOLUTION_DIR" = /* ]]; then
|
|
248
|
-
FULL_EVOLUTION_DIR="$EVOLUTION_DIR"
|
|
249
|
-
else
|
|
250
|
-
FULL_EVOLUTION_DIR="$(cd "$EVOLUTION_DIR" 2>/dev/null && pwd)" || FULL_EVOLUTION_DIR="$EVOLUTION_DIR"
|
|
251
|
-
fi
|
|
252
|
-
|
|
253
|
-
FULL_ALGORITHM_PATH="$FULL_EVOLUTION_DIR/$ALGORITHM_FILE"
|
|
254
|
-
FULL_EVALUATOR_PATH="$FULL_EVOLUTION_DIR/$EVALUATOR_FILE"
|
|
255
|
-
FULL_BRIEF_PATH="$FULL_EVOLUTION_DIR/$BRIEF_FILE"
|
|
256
|
-
FULL_CSV_PATH="$FULL_EVOLUTION_DIR/$EVOLUTION_CSV"
|
|
257
|
-
|
|
258
|
-
if [[ -n $OUTPUT_DIR ]]; then
|
|
259
|
-
FULL_OUTPUT_DIR="$FULL_EVOLUTION_DIR/$OUTPUT_DIR"
|
|
260
|
-
else
|
|
261
|
-
FULL_OUTPUT_DIR="$FULL_EVOLUTION_DIR"
|
|
262
|
-
fi
|
|
263
|
-
echo "[DEBUG] FULL_EVOLUTION_DIR at end of load_config: $FULL_EVOLUTION_DIR" >&2
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
# Validate configuration
|
|
267
|
-
validate_config() {
|
|
268
|
-
local errors=0
|
|
269
|
-
|
|
270
|
-
if [[ ! -d "$FULL_EVOLUTION_DIR" ]]; then
|
|
271
|
-
echo "[ERROR] Evolution directory not found: $FULL_EVOLUTION_DIR" >&2
|
|
272
|
-
((errors++))
|
|
273
|
-
fi
|
|
274
|
-
|
|
275
|
-
if [[ ! -f "$FULL_ALGORITHM_PATH" ]]; then
|
|
276
|
-
echo "[ERROR] Algorithm file not found: $FULL_ALGORITHM_PATH" >&2
|
|
277
|
-
((errors++))
|
|
278
|
-
fi
|
|
279
|
-
|
|
280
|
-
if [[ ! -f "$FULL_EVALUATOR_PATH" ]]; then
|
|
281
|
-
echo "[ERROR] Evaluator file not found: $FULL_EVALUATOR_PATH" >&2
|
|
282
|
-
((errors++))
|
|
283
|
-
fi
|
|
284
|
-
|
|
285
|
-
if [[ ! -f "$FULL_BRIEF_PATH" ]]; then
|
|
286
|
-
echo "[ERROR] Brief file not found: $FULL_BRIEF_PATH" >&2
|
|
287
|
-
((errors++))
|
|
288
|
-
fi
|
|
289
|
-
|
|
290
|
-
if ! command -v "$PYTHON_CMD" >/dev/null 2>&1; then
|
|
291
|
-
echo "[ERROR] Python command not found: $PYTHON_CMD" >&2
|
|
292
|
-
echo "[ERROR] Please install Python 3.x or set python_cmd in config.yaml" >&2
|
|
293
|
-
echo "[ERROR] Examples: python_cmd: \"python\" or python_cmd: \"C:\\Python39\\python.exe\"" >&2
|
|
294
|
-
((errors++))
|
|
295
|
-
else
|
|
296
|
-
# Verify Python version is 3.x
|
|
297
|
-
if ! "$PYTHON_CMD" -c "import sys; sys.exit(0 if sys.version_info[0] >= 3 else 1)" 2>/dev/null; then
|
|
298
|
-
echo "[ERROR] Python 3.x required, but $PYTHON_CMD appears to be Python 2" >&2
|
|
299
|
-
echo "[ERROR] Please set python_cmd in config.yaml to point to Python 3" >&2
|
|
300
|
-
((errors++))
|
|
301
|
-
fi
|
|
302
|
-
fi
|
|
303
|
-
|
|
304
|
-
return $errors
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
# Show current configuration
|
|
308
|
-
show_config() {
|
|
309
|
-
echo "Current claude-evolve configuration:"
|
|
310
|
-
echo " Evolution directory: $FULL_EVOLUTION_DIR"
|
|
311
|
-
echo " Algorithm file: $FULL_ALGORITHM_PATH"
|
|
312
|
-
echo " Evaluator file: $FULL_EVALUATOR_PATH"
|
|
313
|
-
echo " Brief file: $FULL_BRIEF_PATH"
|
|
314
|
-
echo " CSV file: $FULL_CSV_PATH"
|
|
315
|
-
echo " Output directory: $FULL_OUTPUT_DIR"
|
|
316
|
-
echo " Parent selection: $PARENT_SELECTION"
|
|
317
|
-
echo " Python command: $PYTHON_CMD"
|
|
318
|
-
echo " Parallel enabled: $PARALLEL_ENABLED"
|
|
319
|
-
echo " Max workers: $MAX_WORKERS"
|
|
320
|
-
echo " Lock timeout: $LOCK_TIMEOUT"
|
|
321
|
-
echo " Auto ideate: $AUTO_IDEATE"
|
|
322
|
-
echo " Max retries: $MAX_RETRIES"
|
|
323
|
-
echo " Memory limit: ${MEMORY_LIMIT_MB}MB"
|
|
324
|
-
echo " LLM configuration:"
|
|
325
|
-
# Show LLM configurations using dynamic variable names
|
|
326
|
-
for model in gpt5high o3high codex gemini opus opus_think sonnet sonnet_think cursor_sonnet cursor_opus glm deepseek; do
|
|
327
|
-
var_name="LLM_CLI_${model}"
|
|
328
|
-
var_value=$(eval echo "\$$var_name")
|
|
329
|
-
if [[ -n "$var_value" ]]; then
|
|
330
|
-
# Convert underscore back to dash for display
|
|
331
|
-
display_name=$(echo "$model" | sed 's/_/-/g')
|
|
332
|
-
echo " $display_name: $var_value"
|
|
333
|
-
fi
|
|
334
|
-
done
|
|
335
|
-
echo " LLM for run: $LLM_RUN"
|
|
336
|
-
echo " LLM for ideate: $LLM_IDEATE"
|
|
337
|
-
}
|