claude-evolve 1.0.0

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/BRIEF.md ADDED
@@ -0,0 +1,41 @@
1
+ # Project Brief
2
+
3
+ ## Vision
4
+
5
+ We've been very excited by the possibilities and demonstrated performance of AlphaEvolve, and the potential
6
+ of OpenEvolve, a clone of AlphaEvolve. However, in testing, it hasn't worked super well, at least for design
7
+ of neural network architectures. It tended to evolve very slowly, and get caught up in local minima.
8
+
9
+ We would like to like to try a new idea, based on the success of the claude-fsd approach (in
10
+ ../claude-fsd for reference). The claude-fsd package is a npm package based on simple shell scripts
11
+ that leans on `claude -p` to call the Claude Code coder to perform workhorse functions like planning,
12
+ architecting, and running a plan-develop-test loop until the projet is done. So with this `claude-evolve`
13
+ variant, we take the same approach for develop, but this is for algorithm development, using a
14
+ plan-develop-run-record loop, running test after test and recording the quantitative results, all
15
+ the while providing the human operator the opportunity to fill the tail end of the ideas pipeline
16
+ using `claude-evolve ideate` or just interactive conversations with an AI, or editing the file
17
+ directly.
18
+
19
+ ## Core Requirements
20
+
21
+ Commands:
22
+
23
+ - claude-evolve -- runs a menu like with claude-fsd
24
+ - claude-evolve setup -- sets up the baseline evolution/ files if they're not present, and allows for editing the brief
25
+ - claude-evolve ideate [50] -- takes user input and launches `claude -p` to generate [param] new ideas
26
+ - claude-evolve run -- runs the plan-develop-run-record loop
27
+ - claude-evolve analyze -- shows a chart of performance and performance changes over time, and highlights the top candidate so far
28
+
29
+ Files:
30
+
31
+ - evolution/BRIEF.md -- a description of what the project is about and the goals of the thing to be evolved, as well as identifying the evolving algo baseline file and the evaluator file
32
+ - evolution/evolution.csv -- a list of all iterations, with columns ID,basedonID,description,performance,status
33
+ - evolution/evolution_details.md -- a description, for each ID, of the details of what should be changed or what did change, any commentary about the design or the performance, etc., all of which is optional
34
+ - evolution/evolution_id[id].py -- a copy of the tested algo version at that ID
35
+
36
+ The evaluator file takes the name of the file to test as its one argument, and outputs a dictionary with one performance metric as the output.
37
+
38
+ ## Success Criteria
39
+
40
+ - Success criterion 1
41
+ - Success criterion 2
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ # Main dispatcher script for claude-evolve
4
+ exec "$(dirname "$0")/claude-evolve-main" "$@"
@@ -0,0 +1,173 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Parse arguments
6
+ open_chart=false
7
+ csv_file="evolution/evolution.csv"
8
+ output_file="evolution/performance.png"
9
+
10
+ while [[ $# -gt 0 ]]; do
11
+ case $1 in
12
+ --help)
13
+ cat <<EOF
14
+ claude-evolve analyze - Analyze evolution results
15
+
16
+ USAGE:
17
+ claude-evolve analyze [--open] [--csv <path>] [--output <path>]
18
+
19
+ OPTIONS:
20
+ --open Open the generated chart automatically
21
+ --csv <path> Path to evolution.csv (default: ./evolution/evolution.csv)
22
+ --output <path> Output path for chart PNG (default: ./evolution/performance.png)
23
+ --help Show this help message
24
+
25
+ DESCRIPTION:
26
+ Analyzes the evolution.csv file and generates a performance chart.
27
+ Displays summary statistics and identifies the top performing algorithm.
28
+ EOF
29
+ exit 0
30
+ ;;
31
+ --open)
32
+ open_chart=true
33
+ shift
34
+ ;;
35
+ --csv)
36
+ csv_file="$2"
37
+ shift 2
38
+ ;;
39
+ --output)
40
+ output_file="$2"
41
+ shift 2
42
+ ;;
43
+ *)
44
+ echo "[ERROR] Unknown option: $1" >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+ done
49
+
50
+ # Check if CSV exists
51
+ if [[ ! -f $csv_file ]]; then
52
+ echo "[ERROR] CSV file not found: $csv_file" >&2
53
+ echo "[ERROR] Run 'claude-evolve setup' and 'claude-evolve ideate' first." >&2
54
+ exit 1
55
+ fi
56
+
57
+ echo "=== Evolution Analysis Summary ==="
58
+ echo
59
+
60
+ # Count totals (pure shell)
61
+ total=0
62
+ completed=0
63
+ running=0
64
+ failed=0
65
+ pending=0
66
+ total_performance=0
67
+ count_with_performance=0
68
+ top_score=""
69
+ top_id=""
70
+ top_desc=""
71
+
72
+ while IFS=, read -r id _ desc perf status; do
73
+ [[ $id == "id" ]] && continue # Skip header
74
+
75
+ ((total++))
76
+
77
+ case "$status" in
78
+ "completed") ((completed++)) ;;
79
+ "running") ((running++)) ;;
80
+ "failed" | "timeout" | "interrupted") ((failed++)) ;;
81
+ *) ((pending++)) ;;
82
+ esac
83
+
84
+ # Track performance stats
85
+ if [[ -n $perf && $perf != "" ]]; then
86
+ total_performance=$(echo "$total_performance + $perf" | bc -l 2>/dev/null || echo "$total_performance")
87
+ ((count_with_performance++))
88
+
89
+ # Check if this is the top performer
90
+ if [[ -z $top_score ]] || (($(echo "$perf > $top_score" | bc -l 2>/dev/null || echo "0"))); then
91
+ top_score="$perf"
92
+ top_id="$id"
93
+ top_desc="$desc"
94
+ fi
95
+ fi
96
+ done <"$csv_file"
97
+
98
+ # Display summary
99
+ echo "Total Candidates: $total"
100
+ echo "Completed: $completed"
101
+ echo "Running: $running"
102
+ echo "Failed: $failed"
103
+ echo "Pending: $pending"
104
+
105
+ if [[ $count_with_performance -gt 0 ]]; then
106
+ avg_performance=$(echo "scale=4; $total_performance / $count_with_performance" | bc -l 2>/dev/null || echo "0")
107
+ echo "Average Performance: $avg_performance"
108
+ else
109
+ echo "Average Performance: N/A"
110
+ fi
111
+
112
+ echo
113
+ echo "=== Top Performer ==="
114
+ if [[ -n $top_id ]]; then
115
+ echo "ID: $top_id"
116
+ echo "Performance: $top_score"
117
+ echo "Description: $top_desc"
118
+ else
119
+ echo "No completed candidates yet"
120
+ fi
121
+
122
+ # Simple chart generation using gnuplot if available
123
+ if command -v gnuplot >/dev/null 2>&1 && [[ $count_with_performance -gt 0 ]]; then
124
+ echo
125
+ echo "Generating performance chart: $output_file"
126
+
127
+ # Create data file for gnuplot
128
+ data_file="/tmp/evolution_data_$$.dat"
129
+ echo "# ID Performance" >"$data_file"
130
+
131
+ while IFS=, read -r id _ desc perf status; do
132
+ [[ $id == "id" ]] && continue # Skip header
133
+ if [[ -n $perf && $perf != "" ]]; then
134
+ echo "$id $perf" >>"$data_file"
135
+ fi
136
+ done <"$csv_file"
137
+
138
+ # Generate plot
139
+ gnuplot <<EOF
140
+ set terminal png size 800,600
141
+ set output "$output_file"
142
+ set title "Algorithm Evolution Performance"
143
+ set xlabel "Evolution ID"
144
+ set ylabel "Performance Score"
145
+ set grid
146
+ plot "$data_file" using 1:2 with linespoints title "Performance"
147
+ EOF
148
+
149
+ rm -f "$data_file"
150
+ echo "Chart saved successfully!"
151
+
152
+ # Open chart if requested
153
+ if [[ $open_chart == true ]]; then
154
+ if command -v open >/dev/null 2>&1; then
155
+ open "$output_file"
156
+ elif command -v xdg-open >/dev/null 2>&1; then
157
+ xdg-open "$output_file"
158
+ else
159
+ echo "[WARN] Cannot open chart automatically. View: $output_file"
160
+ fi
161
+ fi
162
+ else
163
+ if [[ $count_with_performance -eq 0 ]]; then
164
+ echo
165
+ echo "No performance data available for chart generation."
166
+ echo "Run 'claude-evolve run' to execute candidates first."
167
+ else
168
+ echo
169
+ echo "[WARN] gnuplot not found. Install gnuplot for chart generation."
170
+ echo " On macOS: brew install gnuplot"
171
+ echo " On Ubuntu: sudo apt install gnuplot"
172
+ fi
173
+ fi
@@ -0,0 +1,206 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Parse arguments
6
+ count=1
7
+ no_ai=false
8
+
9
+ while [[ $# -gt 0 ]]; do
10
+ case $1 in
11
+ --help)
12
+ cat <<EOF
13
+ claude-evolve ideate - Generate new algorithm ideas
14
+
15
+ USAGE:
16
+ claude-evolve ideate [N] [--no-ai]
17
+
18
+ ARGUMENTS:
19
+ N Number of ideas to generate (default: 1, max: 50)
20
+
21
+ OPTIONS:
22
+ --no-ai Use manual entry mode instead of AI generation
23
+ --help Show this help message
24
+
25
+ DESCRIPTION:
26
+ Generates new algorithm variations by prompting Claude with context
27
+ from the project BRIEF.md and top performers from evolution.csv.
28
+ Falls back to manual entry if --no-ai is specified or Claude fails.
29
+ EOF
30
+ exit 0
31
+ ;;
32
+ --no-ai)
33
+ no_ai=true
34
+ shift
35
+ ;;
36
+ *)
37
+ if [[ $1 =~ ^[0-9]+$ ]]; then
38
+ count=$1
39
+ else
40
+ echo "[ERROR] Invalid number of ideas: $1" >&2
41
+ exit 1
42
+ fi
43
+ shift
44
+ ;;
45
+ esac
46
+ done
47
+
48
+ # Validate count
49
+ if [[ $count -lt 1 || $count -gt 50 ]]; then
50
+ echo "[ERROR] Number of ideas must be between 1 and 50" >&2
51
+ exit 1
52
+ fi
53
+
54
+ # Check workspace
55
+ if [[ ! -d evolution ]]; then
56
+ echo "[ERROR] Evolution workspace not found. Run 'claude-evolve setup' first." >&2
57
+ exit 1
58
+ fi
59
+
60
+ # Ensure CSV exists
61
+ if [[ ! -f evolution/evolution.csv ]]; then
62
+ echo "id,basedOnId,description,performance,status" >evolution/evolution.csv
63
+ fi
64
+
65
+ # Get next ID
66
+ get_next_id() {
67
+ if [[ ! -f evolution/evolution.csv ]]; then
68
+ echo "1"
69
+ return
70
+ fi
71
+ # Find highest ID and increment (pure shell)
72
+ local max_id=0
73
+ while IFS=, read -r id rest; do
74
+ if [[ $id =~ ^[0-9]+$ ]] && [[ $id -gt $max_id ]]; then
75
+ max_id=$id
76
+ fi
77
+ done < <(tail -n +2 evolution/evolution.csv)
78
+ echo $((max_id + 1))
79
+ }
80
+
81
+ # Add idea to CSV
82
+ add_idea() {
83
+ local description="$1"
84
+ local id
85
+ id=$(get_next_id)
86
+
87
+ # Escape quotes in description
88
+ local escaped_desc="${description//\"/\"\"}"
89
+
90
+ # Append to CSV
91
+ echo "${id},,\"${escaped_desc}\",," >>evolution/evolution.csv
92
+ echo "[INFO] Added idea: $description"
93
+ }
94
+
95
+ # Manual entry mode
96
+ ideate_manual() {
97
+ local ideas_added=0
98
+
99
+ for ((i = 1; i <= count; i++)); do
100
+ if [[ $count -eq 1 ]]; then
101
+ read -r -p "Enter algorithm idea (or empty to skip): " description
102
+ else
103
+ read -r -p "Enter algorithm idea $i/$count (or empty to skip): " description
104
+ fi
105
+
106
+ if [[ -z $description ]]; then
107
+ echo "[INFO] Empty description, skipping idea"
108
+ continue
109
+ fi
110
+
111
+ add_idea "$description"
112
+ ((ideas_added++))
113
+
114
+ if [[ $i -lt $count ]]; then
115
+ read -r -p "Add another idea? (y/N) " continue_adding
116
+ if [[ $continue_adding != "y" && $continue_adding != "Y" ]]; then
117
+ break
118
+ fi
119
+ fi
120
+ done
121
+
122
+ echo "[INFO] Added $ideas_added idea(s) to evolution.csv"
123
+ }
124
+
125
+ # AI generation mode
126
+ ideate_ai() {
127
+ # Check for claude CLI
128
+ if ! command -v claude >/dev/null 2>&1; then
129
+ echo "[WARN] Claude CLI not found. Falling back to manual entry."
130
+ return 1
131
+ fi
132
+
133
+ if [[ ! -f evolution/BRIEF.md ]]; then
134
+ echo "[WARN] BRIEF.md not found. Falling back to manual entry."
135
+ return 1
136
+ fi
137
+
138
+ # Get top performers (pure shell)
139
+ local top_performers=""
140
+ if [[ -f evolution/evolution.csv ]]; then
141
+ # Simple top performers extraction (lines with non-empty performance)
142
+ top_performers=$(awk -F, 'NR > 1 && $4 != "" { print $1 ": " $3 " (score: " $4 ")" }' evolution/evolution.csv | head -5)
143
+ fi
144
+
145
+ # Build prompt
146
+ local prompt
147
+ prompt="You are helping with algorithm evolution. Generate exactly $count new algorithm idea(s) based on the following context.
148
+
149
+ Project Brief:
150
+ $(cat evolution/BRIEF.md)
151
+ "
152
+
153
+ if [[ -n $top_performers ]]; then
154
+ prompt+="
155
+ Top Performing Algorithms So Far:
156
+ $top_performers
157
+ "
158
+ fi
159
+
160
+ prompt+="
161
+ Generate $count creative algorithm variation(s) that could potentially improve performance.
162
+ For each idea, provide a single line description that explains the approach.
163
+ Format: One idea per line, no numbering, no extra formatting."
164
+
165
+ echo "[INFO] Generating $count idea(s) with Claude..."
166
+
167
+ # Call Claude and process response
168
+ local response
169
+ if ! response=$(echo "$prompt" | claude -p 2>&1); then
170
+ echo "[WARN] Claude API call failed, falling back to manual entry."
171
+ return 1
172
+ fi
173
+
174
+ local ideas_added=0
175
+ while IFS= read -r line; do
176
+ # Clean up line
177
+ line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
178
+ [[ -z $line ]] && continue
179
+
180
+ # Remove numbering/bullets
181
+ line=$(echo "$line" | sed 's/^[0-9]*\. *//;s/^[-*] *//')
182
+
183
+ add_idea "$line"
184
+ ((ideas_added++))
185
+
186
+ [[ $ideas_added -ge $count ]] && break
187
+ done <<<"$response"
188
+
189
+ if [[ $ideas_added -eq 0 ]]; then
190
+ echo "[WARN] No valid ideas extracted from Claude response"
191
+ return 1
192
+ fi
193
+
194
+ echo "[INFO] Successfully generated $ideas_added idea(s)"
195
+ }
196
+
197
+ # Main execution
198
+ if [[ $no_ai == true ]]; then
199
+ echo "[INFO] Manual entry mode"
200
+ ideate_manual
201
+ else
202
+ if ! ideate_ai; then
203
+ echo "[INFO] Falling back to manual entry"
204
+ ideate_manual
205
+ fi
206
+ fi
@@ -0,0 +1,126 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Colors for output
6
+ GREEN='\033[0;32m'
7
+ RED='\033[0;31m'
8
+ NC='\033[0m' # No Color
9
+
10
+ # Get script directory
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
13
+
14
+ # Get version from package.json
15
+ get_version() {
16
+ if [[ -f "$PROJECT_ROOT/package.json" ]]; then
17
+ grep '"version"' "$PROJECT_ROOT/package.json" | sed 's/.*"version": *"\([^"]*\)".*/\1/'
18
+ else
19
+ echo "unknown"
20
+ fi
21
+ }
22
+
23
+
24
+ show_help() {
25
+ cat <<EOF
26
+ claude-evolve - AI-powered algorithm evolution tool
27
+
28
+ USAGE:
29
+ claude-evolve [COMMAND] [OPTIONS]
30
+
31
+ COMMANDS:
32
+ setup Initialize evolution workspace
33
+ ideate Generate new algorithm ideas
34
+ run Execute evolution candidates
35
+ analyze Analyze evolution results
36
+ help Show this help message
37
+
38
+ OPTIONS:
39
+ -h, --help Show help message
40
+ -v, --version Show version
41
+
42
+ EXAMPLES:
43
+ claude-evolve setup
44
+ claude-evolve ideate 5
45
+ claude-evolve run --timeout 300
46
+ claude-evolve analyze --open
47
+
48
+ For more information, visit: https://github.com/anthropics/claude-evolve
49
+ EOF
50
+ }
51
+
52
+ show_menu() {
53
+ echo -e "${GREEN}🧬 Claude Evolve - Algorithm Evolution Tool${NC}"
54
+ echo
55
+ echo "This tool helps you evolve algorithms using AI-powered mutations."
56
+ echo
57
+ echo "What would you like to do?"
58
+ echo
59
+ echo " 1) setup - Initialize evolution workspace"
60
+ echo " 2) ideate - Generate new algorithm ideas"
61
+ echo " 3) run - Execute evolution candidates"
62
+ echo " 4) analyze - Analyze evolution results"
63
+ echo " 5) help - Show help message"
64
+ echo " 6) exit - Exit"
65
+ echo
66
+
67
+ # Show workspace status
68
+ echo "Current status:"
69
+ [[ -d evolution ]] && echo " ✓ evolution/ workspace exists" || echo " ✗ evolution/ workspace missing"
70
+ [[ -f evolution/BRIEF.md ]] && echo " ✓ BRIEF.md exists" || echo " ✗ BRIEF.md missing"
71
+ [[ -f evolution/evolution.csv ]] && echo " ✓ evolution.csv exists" || echo " ✗ evolution.csv missing"
72
+ echo
73
+ }
74
+
75
+ # Main logic
76
+ if [[ $# -eq 0 ]]; then
77
+ show_menu
78
+ read -r -p "Enter your choice (1-6): " choice
79
+
80
+ case $choice in
81
+ 1) exec "$SCRIPT_DIR/claude-evolve-setup" ;;
82
+ 2) exec "$SCRIPT_DIR/claude-evolve-ideate" ;;
83
+ 3) exec "$SCRIPT_DIR/claude-evolve-run" ;;
84
+ 4) exec "$SCRIPT_DIR/claude-evolve-analyze" ;;
85
+ 5) show_help ;;
86
+ 6)
87
+ echo "Goodbye!"
88
+ exit 0
89
+ ;;
90
+ *)
91
+ echo -e "${RED}Invalid choice. Please select 1-6.${NC}"
92
+ exit 1
93
+ ;;
94
+ esac
95
+ fi
96
+
97
+ case "${1:-}" in
98
+ -h | --help | help)
99
+ show_help
100
+ ;;
101
+ -v | --version)
102
+ echo "claude-evolve v$(get_version)"
103
+ ;;
104
+ setup)
105
+ shift
106
+ exec "$SCRIPT_DIR/claude-evolve-setup" "$@"
107
+ ;;
108
+ ideate)
109
+ shift
110
+ exec "$SCRIPT_DIR/claude-evolve-ideate" "$@"
111
+ ;;
112
+ run)
113
+ shift
114
+ exec "$SCRIPT_DIR/claude-evolve-run" "$@"
115
+ ;;
116
+ analyze)
117
+ shift
118
+ exec "$SCRIPT_DIR/claude-evolve-analyze" "$@"
119
+ ;;
120
+ *)
121
+ echo "Unknown command: ${1:-}"
122
+ echo
123
+ show_help
124
+ exit 1
125
+ ;;
126
+ esac