claude-evolve 1.2.2 → 1.2.4

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.
@@ -80,7 +80,7 @@ if [[ $use_strategies == true ]]; then
80
80
  fi
81
81
  fi
82
82
 
83
- # Get next ID
83
+ # Get next available ID
84
84
  get_next_id() {
85
85
  if [[ ! -f "$FULL_CSV_PATH" ]]; then
86
86
  echo "1"
@@ -96,8 +96,8 @@ get_next_id() {
96
96
  echo $((max_id + 1))
97
97
  }
98
98
 
99
- # Add idea to CSV
100
- add_idea() {
99
+ # Add idea to CSV manually (fallback for manual mode)
100
+ add_idea_manual() {
101
101
  local description="$1"
102
102
  local based_on_id="$2"
103
103
  local id
@@ -141,7 +141,7 @@ ideate_manual() {
141
141
  continue
142
142
  fi
143
143
 
144
- add_idea "$description" ""
144
+ add_idea_manual "$description" ""
145
145
  ((ideas_added++))
146
146
 
147
147
  if [[ $i -lt $TOTAL_IDEAS ]]; then
@@ -175,7 +175,7 @@ ideate_ai_strategies() {
175
175
  if [[ -z $top_performers ]]; then
176
176
  echo "[INFO] No completed algorithms found, using pure novel exploration"
177
177
  # Generate all ideas as novel exploration
178
- generate_novel_ideas "$TOTAL_IDEAS" ""
178
+ generate_novel_ideas_direct "$TOTAL_IDEAS"
179
179
  return 0
180
180
  fi
181
181
 
@@ -185,135 +185,147 @@ ideate_ai_strategies() {
185
185
  echo " Structural mutation: $STRUCTURAL_MUTATION"
186
186
  echo " Crossover hybrid: $CROSSOVER_HYBRID"
187
187
 
188
- # Generate each type of idea
189
- [[ $NOVEL_EXPLORATION -gt 0 ]] && generate_novel_ideas "$NOVEL_EXPLORATION" ""
190
- [[ $HILL_CLIMBING -gt 0 ]] && generate_hill_climbing_ideas "$HILL_CLIMBING" "$top_performers"
191
- [[ $STRUCTURAL_MUTATION -gt 0 ]] && generate_structural_mutation_ideas "$STRUCTURAL_MUTATION" "$top_performers"
192
- [[ $CROSSOVER_HYBRID -gt 0 ]] && generate_crossover_ideas "$CROSSOVER_HYBRID" "$top_performers"
188
+ # Generate each type of idea by having Claude directly edit the CSV
189
+ [[ $NOVEL_EXPLORATION -gt 0 ]] && generate_novel_ideas_direct "$NOVEL_EXPLORATION"
190
+ [[ $HILL_CLIMBING -gt 0 ]] && generate_hill_climbing_direct "$HILL_CLIMBING" "$top_performers"
191
+ [[ $STRUCTURAL_MUTATION -gt 0 ]] && generate_structural_mutation_direct "$STRUCTURAL_MUTATION" "$top_performers"
192
+ [[ $CROSSOVER_HYBRID -gt 0 ]] && generate_crossover_direct "$CROSSOVER_HYBRID" "$top_performers"
193
193
  }
194
194
 
195
- # Generate novel exploration ideas
196
- generate_novel_ideas() {
195
+ # Generate novel exploration ideas by having Claude edit CSV directly
196
+ generate_novel_ideas_direct() {
197
197
  local count="$1"
198
- local context="$2"
199
198
 
200
- local prompt="Generate $count completely novel algorithm approaches for this problem.
201
- Think outside the box - consider entirely different algorithmic paradigms, data structures, or mathematical approaches.
199
+ local prompt="Edit the file $FULL_CSV_PATH to add exactly $count new rows for novel algorithmic approaches.
202
200
 
203
201
  Project Brief:
204
202
  $(cat "$FULL_BRIEF_PATH")
205
203
 
206
- $context
204
+ Requirements for new CSV rows:
205
+ - IDs must be numbers only (suitable for filenames)
206
+ - basedOnId should be empty (these are novel approaches)
207
+ - Each description should be one clear sentence describing a specific algorithmic change
208
+ - Descriptions should explore completely different approaches than existing ones
209
+ - All new rows should have empty performance and status fields
207
210
 
208
- Provide $count creative, innovative ideas that explore fundamentally different solution approaches.
209
- Format: One idea per line, no numbering, no extra formatting."
211
+ Example descriptions:
212
+ - Use ensemble of 3 random forests with different feature subsets
213
+ - Replace neural network with gradient boosting decision trees
214
+ - Implement Monte Carlo tree search for feature selection
210
215
 
211
- generate_and_add_ideas "$prompt" "$count" ""
216
+ Add exactly $count rows to the CSV file now."
217
+
218
+ echo "[INFO] Calling Claude Opus to generate $count novel exploration ideas..."
219
+ if ! echo "$prompt" | claude --dangerously-skip-permissions --model opus -p; then
220
+ echo "[WARN] Claude failed to generate novel ideas" >&2
221
+ return 1
222
+ fi
223
+ echo "[INFO] Novel exploration ideas generated"
212
224
  }
213
225
 
214
- # Generate hill climbing ideas (parameter tuning)
215
- generate_hill_climbing_ideas() {
226
+ # Generate hill climbing ideas by having Claude edit CSV directly
227
+ generate_hill_climbing_direct() {
216
228
  local count="$1"
217
229
  local top_performers="$2"
218
230
 
219
- local prompt="Generate $count parameter optimization ideas based on these successful algorithms:
231
+ local prompt="Edit the file $FULL_CSV_PATH to add exactly $count new rows for parameter tuning based on successful algorithms.
220
232
 
233
+ Successful algorithms to build on:
221
234
  $top_performers
222
235
 
223
236
  Project Brief:
224
237
  $(cat "$FULL_BRIEF_PATH")
225
238
 
226
- Focus on tuning parameters, constants, thresholds, sizes, iteration counts, and optimization parameters.
227
- Make small incremental improvements to the existing successful approaches.
228
- Format: One idea per line, no numbering, no extra formatting."
239
+ Requirements for new CSV rows:
240
+ - IDs must be numbers only (suitable for filenames)
241
+ - basedOnId should reference ONE of the successful algorithm IDs above (pick the best one)
242
+ - Each description should be one clear sentence about parameter tuning
243
+ - Focus on adjusting hyperparameters, thresholds, sizes, learning rates
244
+ - All new rows should have empty performance and status fields
229
245
 
230
- # Get the best performer's ID for basedOnId
231
- local best_id
232
- best_id=$(echo "$top_performers" | head -1 | cut -d, -f1)
233
-
234
- generate_and_add_ideas "$prompt" "$count" "$best_id"
246
+ Example descriptions:
247
+ - Increase learning rate from 0.001 to 0.01 for faster convergence
248
+ - Reduce batch size from 32 to 16 to improve gradient estimates
249
+ - Set dropout rate to 0.3 instead of 0.1 to prevent overfitting
250
+
251
+ Add exactly $count parameter tuning rows to the CSV file now."
252
+
253
+ echo "[INFO] Calling Claude Opus to generate $count hill climbing ideas..."
254
+ if ! echo "$prompt" | claude --dangerously-skip-permissions --model opus -p; then
255
+ echo "[WARN] Claude failed to generate hill climbing ideas" >&2
256
+ return 1
257
+ fi
258
+ echo "[INFO] Hill climbing ideas generated"
235
259
  }
236
260
 
237
- # Generate structural mutation ideas
238
- generate_structural_mutation_ideas() {
261
+ # Generate structural mutation ideas by having Claude edit CSV directly
262
+ generate_structural_mutation_direct() {
239
263
  local count="$1"
240
264
  local top_performers="$2"
241
265
 
242
- local prompt="Generate $count structural algorithm modifications based on these successful algorithms:
266
+ local prompt="Edit the file $FULL_CSV_PATH to add exactly $count new rows for structural modifications based on successful algorithms.
243
267
 
268
+ Successful algorithms to build on:
244
269
  $top_performers
245
270
 
246
271
  Project Brief:
247
272
  $(cat "$FULL_BRIEF_PATH")
248
273
 
249
- Keep the core algorithmic insights but redesign the implementation approach.
250
- Consider: different data structures, alternative algorithms for sub-components, different execution patterns.
251
- Format: One idea per line, no numbering, no extra formatting."
274
+ Requirements for new CSV rows:
275
+ - IDs must be numbers only (suitable for filenames)
276
+ - basedOnId should reference ONE of the successful algorithm IDs above (pick the best one)
277
+ - Each description should be one clear sentence about architectural changes
278
+ - Keep core insights but change implementation approach
279
+ - All new rows should have empty performance and status fields
252
280
 
253
- # Get the best performer's ID for basedOnId
254
- local best_id
255
- best_id=$(echo "$top_performers" | head -1 | cut -d, -f1)
256
-
257
- generate_and_add_ideas "$prompt" "$count" "$best_id"
281
+ Example descriptions:
282
+ - Replace linear layers with convolutional layers for spatial feature learning
283
+ - Use bidirectional LSTM instead of unidirectional for better context
284
+ - Add residual connections between layers to improve gradient flow
285
+
286
+ Add exactly $count structural modification rows to the CSV file now."
287
+
288
+ echo "[INFO] Calling Claude Opus to generate $count structural mutation ideas..."
289
+ if ! echo "$prompt" | claude --dangerously-skip-permissions --model opus -p; then
290
+ echo "[WARN] Claude failed to generate structural mutation ideas" >&2
291
+ return 1
292
+ fi
293
+ echo "[INFO] Structural mutation ideas generated"
258
294
  }
259
295
 
260
- # Generate crossover hybrid ideas
261
- generate_crossover_ideas() {
296
+ # Generate crossover hybrid ideas by having Claude edit CSV directly
297
+ generate_crossover_direct() {
262
298
  local count="$1"
263
299
  local top_performers="$2"
264
300
 
265
- local prompt="Generate $count hybrid algorithms that combine successful approaches from these top performers:
301
+ local prompt="Edit the file $FULL_CSV_PATH to add exactly $count new rows for hybrid combinations of successful algorithms.
266
302
 
303
+ Top performers to combine:
267
304
  $top_performers
268
305
 
269
306
  Project Brief:
270
307
  $(cat "$FULL_BRIEF_PATH")
271
308
 
272
- Create novel combinations that merge the best aspects of different successful algorithms.
273
- Consider: what makes each successful? How could they complement each other?
274
- Format: One idea per line, no numbering, no extra formatting."
309
+ Requirements for new CSV rows:
310
+ - IDs must be numbers only (suitable for filenames)
311
+ - basedOnId should reference ONE of the successful algorithm IDs above (pick the best one as base)
312
+ - Each description should be one clear sentence combining elements from different algorithms
313
+ - Be specific about what elements to merge
314
+ - All new rows should have empty performance and status fields
275
315
 
276
- # Use the top two performers for crossover
277
- local parent_ids
278
- parent_ids=$(echo "$top_performers" | head -2 | cut -d, -f1 | tr '\n' '+' | sed 's/+$//')
279
-
280
- generate_and_add_ideas "$prompt" "$count" "$parent_ids"
281
- }
316
+ Example descriptions:
317
+ - Combine ensemble voting from algorithm 3 with feature selection from algorithm 5
318
+ - Use the attention mechanism from algorithm 2 with the optimizer from algorithm 4
319
+ - Merge the preprocessing pipeline from algorithm 1 with the architecture from algorithm 6
282
320
 
283
- # Helper function to generate and add ideas using Claude
284
- generate_and_add_ideas() {
285
- local prompt="$1"
286
- local count="$2"
287
- local based_on_id="$3"
288
-
289
- # Call Claude and process response
290
- local response
291
- if ! response=$(echo "$prompt" | claude --dangerously-skip-permissions --model opus -p 2>&1); then
292
- echo "[WARN] Claude API call failed for $count ideas" >&2
293
- return 1
294
- fi
321
+ Add exactly $count hybrid combination rows to the CSV file now."
295
322
 
296
- local ideas_added=0
297
- while IFS= read -r line; do
298
- # Clean up line
299
- line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
300
- [[ -z $line ]] && continue
301
-
302
- # Remove numbering/bullets
303
- line=$(echo "$line" | sed 's/^[0-9]*\. *//;s/^[-*] *//')
304
-
305
- add_idea "$line" "$based_on_id"
306
- ((ideas_added++))
307
-
308
- [[ $ideas_added -ge $count ]] && break
309
- done <<<"$response"
310
-
311
- if [[ $ideas_added -eq 0 ]]; then
312
- echo "[WARN] No valid ideas extracted from Claude response" >&2
323
+ echo "[INFO] Calling Claude Opus to generate $count crossover hybrid ideas..."
324
+ if ! echo "$prompt" | claude --dangerously-skip-permissions --model opus -p; then
325
+ echo "[WARN] Claude failed to generate crossover ideas" >&2
313
326
  return 1
314
327
  fi
315
-
316
- echo "[INFO] Generated $ideas_added ideas of requested type"
328
+ echo "[INFO] Crossover hybrid ideas generated"
317
329
  }
318
330
 
319
331
  # Legacy AI generation mode (for backward compatibility)
@@ -337,56 +349,34 @@ ideate_ai_legacy() {
337
349
  fi
338
350
 
339
351
  # Build prompt
340
- local prompt
341
- prompt="It's time for your megathinking mode! You are helping with algorithm evolution. Generate exactly $TOTAL_IDEAS new algorithm idea(s) based on the following context.
352
+ local prompt="Edit the file $FULL_CSV_PATH to add exactly $TOTAL_IDEAS new algorithm variation rows.
342
353
 
343
354
  Project Brief:
344
- $(cat "$FULL_BRIEF_PATH")
345
- "
355
+ $(cat "$FULL_BRIEF_PATH")"
346
356
 
347
357
  if [[ -n $top_performers ]]; then
348
358
  prompt+="
359
+
349
360
  Top Performing Algorithms So Far:
350
- $top_performers
351
- "
361
+ $top_performers"
352
362
  fi
353
363
 
354
364
  prompt+="
355
- Generate $TOTAL_IDEAS creative algorithm variation(s) that could potentially improve performance.
356
- For each idea, provide a single line description that explains the approach.
357
- Base it on the top algorithms by their ID.
358
- Format: One idea per line, no numbering, no extra formatting."
359
365
 
360
- echo "[INFO] Generating $TOTAL_IDEAS idea(s) with Claude (legacy mode)..."
366
+ Requirements for new CSV rows:
367
+ - IDs must be numbers only (suitable for filenames)
368
+ - basedOnId should be empty or reference existing algorithm ID
369
+ - Each description should be one clear sentence describing an algorithmic approach
370
+ - All new rows should have empty performance and status fields
361
371
 
362
- # Call Claude and process response
363
- local response
364
- if ! response=$(echo "$prompt" | claude --dangerously-skip-permissions --model opus -p 2>&1); then
365
- echo "[WARN] Claude API call failed, falling back to manual entry."
366
- return 1
367
- fi
368
-
369
- local ideas_added=0
370
- while IFS= read -r line; do
371
- # Clean up line
372
- line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
373
- [[ -z $line ]] && continue
374
-
375
- # Remove numbering/bullets
376
- line=$(echo "$line" | sed 's/^[0-9]*\. *//;s/^[-*] *//')
372
+ Add exactly $TOTAL_IDEAS algorithm variation rows to the CSV file now."
377
373
 
378
- add_idea "$line" ""
379
- ((ideas_added++))
380
-
381
- [[ $ideas_added -ge $TOTAL_IDEAS ]] && break
382
- done <<<"$response"
383
-
384
- if [[ $ideas_added -eq 0 ]]; then
385
- echo "[WARN] No valid ideas extracted from Claude response"
374
+ echo "[INFO] Calling Claude Opus to generate $TOTAL_IDEAS ideas (legacy mode)..."
375
+ if ! echo "$prompt" | claude --dangerously-skip-permissions --model opus -p; then
376
+ echo "[WARN] Claude failed to generate ideas" >&2
386
377
  return 1
387
378
  fi
388
-
389
- echo "[INFO] Successfully generated $ideas_added idea(s)"
379
+ echo "[INFO] Legacy ideas generated"
390
380
  }
391
381
 
392
382
  # Main execution
@@ -233,11 +233,16 @@ CLAUDE_MODEL="sonnet"
233
233
  echo "[INFO] Using Claude Sonnet for development"
234
234
 
235
235
  # Create mutation prompt - Claude will edit the file directly
236
- prompt="Please edit file $output_file to implement the following change for iteration $id: $description
236
+ prompt="Edit the file $output_file to implement this specific change: $description
237
237
 
238
- There may be extra information in documentation in the $FULL_EVOLUTION_DIR/*.md files.
238
+ Requirements:
239
+ - Edit the file directly (don't just provide comments or suggestions)
240
+ - Maintain the same function signatures and interfaces
241
+ - Make the specific change described above
242
+ - Ensure the code runs without syntax errors
243
+ - Add proper error handling if needed
239
244
 
240
- The algorithm should maintain the same interface (function signatures) and include proper error handling."
245
+ The file currently contains the parent algorithm. Modify it according to the description above."
241
246
 
242
247
  # Generate mutation (skip for baseline)
243
248
  if [[ $id == "000" || $id == "0" ]]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-evolve",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "bin": {
5
5
  "claude-evolve": "./bin/claude-evolve",
6
6
  "claude-evolve-main": "./bin/claude-evolve-main",