claude-evolve 1.8.42 → 1.8.43
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-worker +48 -7
- package/lib/ai-cli.sh +8 -3
- package/lib/config.sh +2 -2
- package/package.json +1 -1
package/bin/claude-evolve-worker
CHANGED
|
@@ -111,6 +111,8 @@ else
|
|
|
111
111
|
fi
|
|
112
112
|
|
|
113
113
|
# AI random selection function for code evolution
|
|
114
|
+
# AIDEV-NOTE: This function reads the model name from a temp file written by call_ai_random
|
|
115
|
+
# because exports don't propagate from subshells. The model is stored in SUCCESSFUL_RUN_MODEL.
|
|
114
116
|
call_ai_for_evolution() {
|
|
115
117
|
local prompt="$1"
|
|
116
118
|
local candidate_id="$2"
|
|
@@ -131,6 +133,17 @@ call_ai_for_evolution() {
|
|
|
131
133
|
ai_output=$(call_ai_random "$prompt" "run")
|
|
132
134
|
local ai_exit_code=$?
|
|
133
135
|
|
|
136
|
+
# Read the model name from temp file (written by call_ai_random in subshell)
|
|
137
|
+
local model_file="/tmp/.claude-evolve-model-$$"
|
|
138
|
+
if [[ -f "$model_file" ]]; then
|
|
139
|
+
SUCCESSFUL_RUN_MODEL=$(cat "$model_file")
|
|
140
|
+
rm -f "$model_file"
|
|
141
|
+
echo "[WORKER-$$] AI model used: $SUCCESSFUL_RUN_MODEL" >&2
|
|
142
|
+
else
|
|
143
|
+
echo "[WORKER-$$] Warning: Could not determine which AI model was used" >&2
|
|
144
|
+
SUCCESSFUL_RUN_MODEL=""
|
|
145
|
+
fi
|
|
146
|
+
|
|
134
147
|
# Check if the target file was actually modified
|
|
135
148
|
local file_was_modified=false
|
|
136
149
|
if [[ -f "$target_file" ]]; then
|
|
@@ -310,20 +323,48 @@ CRITICAL: If you do not know how to implement what was asked for, or if the requ
|
|
|
310
323
|
return 1
|
|
311
324
|
}
|
|
312
325
|
|
|
313
|
-
#
|
|
314
|
-
|
|
315
|
-
|
|
326
|
+
# AIDEV-NOTE: Retry logic for AI code generation
|
|
327
|
+
# Try up to 3 times with different random models before giving up
|
|
328
|
+
# This handles transient failures like rate limits or capacity issues
|
|
329
|
+
local max_retries=3
|
|
330
|
+
local retry_count=0
|
|
331
|
+
local ai_success=false
|
|
332
|
+
|
|
333
|
+
while [[ $retry_count -lt $max_retries ]]; do
|
|
334
|
+
((retry_count++))
|
|
335
|
+
echo "[WORKER-$$] AI attempt $retry_count/$max_retries for $candidate_id" >&2
|
|
336
|
+
|
|
337
|
+
# Re-copy source file if this is a retry (previous attempt may have corrupted it)
|
|
338
|
+
if [[ $retry_count -gt 1 ]]; then
|
|
339
|
+
echo "[WORKER-$$] Re-copying source file for retry attempt" >&2
|
|
340
|
+
cp "$source_file" "$target_file"
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
if call_ai_for_evolution "$evolution_prompt" "$candidate_id"; then
|
|
344
|
+
ai_success=true
|
|
345
|
+
break
|
|
346
|
+
else
|
|
347
|
+
echo "[WORKER-$$] AI attempt $retry_count failed" >&2
|
|
348
|
+
if [[ $retry_count -lt $max_retries ]]; then
|
|
349
|
+
echo "[WORKER-$$] Will retry with a different model..." >&2
|
|
350
|
+
sleep 2 # Brief pause before retry
|
|
351
|
+
fi
|
|
352
|
+
fi
|
|
353
|
+
done
|
|
354
|
+
|
|
355
|
+
if [[ "$ai_success" != "true" ]]; then
|
|
356
|
+
echo "[WORKER-$$] ERROR: All $max_retries AI attempts failed for $candidate_id" >&2
|
|
316
357
|
safe_popd
|
|
317
358
|
rm -f "$target_file" # Clean up on failure
|
|
318
|
-
# Return with special code to indicate AI failure
|
|
359
|
+
# Return with special code to indicate AI failure after all retries exhausted
|
|
319
360
|
return 77
|
|
320
361
|
fi
|
|
321
362
|
|
|
322
363
|
# Restore working directory
|
|
323
364
|
safe_popd
|
|
324
|
-
|
|
325
|
-
echo "[WORKER-$$] Evolution applied successfully"
|
|
326
|
-
|
|
365
|
+
|
|
366
|
+
echo "[WORKER-$$] Evolution applied successfully (attempt $retry_count/$max_retries)"
|
|
367
|
+
|
|
327
368
|
# Record which AI model generated the code (regardless of evaluation outcome)
|
|
328
369
|
if [[ -n "${SUCCESSFUL_RUN_MODEL:-}" ]]; then
|
|
329
370
|
echo "[WORKER-$$] Recording that $SUCCESSFUL_RUN_MODEL generated the code" >&2
|
package/lib/ai-cli.sh
CHANGED
|
@@ -302,6 +302,9 @@ get_models_for_command() {
|
|
|
302
302
|
# Usage: call_ai_random <prompt> <command>
|
|
303
303
|
# command: "run" or "ideate"
|
|
304
304
|
# Picks one random model from the list and uses it
|
|
305
|
+
# AIDEV-NOTE: This function writes the selected model to a temp file because
|
|
306
|
+
# export doesn't work from subshells (command substitution creates a subshell).
|
|
307
|
+
# The parent process should read /tmp/.claude-evolve-model-$$ to get the model name.
|
|
305
308
|
call_ai_random() {
|
|
306
309
|
local prompt="$1"
|
|
307
310
|
local command="$2"
|
|
@@ -330,6 +333,11 @@ call_ai_random() {
|
|
|
330
333
|
|
|
331
334
|
echo "[AI] Selected $model for $command (random from $num_models models)" >&2
|
|
332
335
|
|
|
336
|
+
# Write model to temp file so parent can read it
|
|
337
|
+
# (exports don't propagate from subshells created by $(...) command substitution)
|
|
338
|
+
local model_file="/tmp/.claude-evolve-model-$$"
|
|
339
|
+
echo "$model" > "$model_file"
|
|
340
|
+
|
|
333
341
|
# Call the AI model
|
|
334
342
|
local ai_output
|
|
335
343
|
ai_output=$(call_ai_model_configured "$model" "$prompt")
|
|
@@ -338,9 +346,6 @@ call_ai_random() {
|
|
|
338
346
|
# Clean output if needed
|
|
339
347
|
ai_output=$(clean_ai_output "$ai_output" "$model")
|
|
340
348
|
|
|
341
|
-
# Export the model used for tracking (used by worker)
|
|
342
|
-
export SUCCESSFUL_RUN_MODEL="$model"
|
|
343
|
-
|
|
344
349
|
# Log result
|
|
345
350
|
if [[ $ai_exit_code -eq 0 ]]; then
|
|
346
351
|
echo "[AI] $model returned exit code 0" >&2
|
package/lib/config.sh
CHANGED
|
@@ -58,9 +58,9 @@ DEFAULT_MEMORY_LIMIT_MB=12288
|
|
|
58
58
|
DEFAULT_WORKER_MAX_CANDIDATES=3
|
|
59
59
|
|
|
60
60
|
# Default LLM CLI configuration
|
|
61
|
-
DEFAULT_LLM_RUN="glm-zai
|
|
61
|
+
DEFAULT_LLM_RUN="glm-zai glm-zai glm-zai glm-zai glm-zai kimi-coder codex-oss-local haiku"
|
|
62
62
|
# Ideate: Commercial models for idea generation + local fallback
|
|
63
|
-
DEFAULT_LLM_IDEATE="opus-think kimi-k2-openrouter gemini-3-pro-preview gpt5high grok-4-openrouter deepseek-openrouter glm-zai
|
|
63
|
+
DEFAULT_LLM_IDEATE="opus-think kimi-k2-openrouter gemini-3-pro-preview gpt5high grok-4-openrouter deepseek-openrouter glm-zai"
|
|
64
64
|
|
|
65
65
|
# Load configuration from a YAML file and update variables
|
|
66
66
|
_load_yaml_config() {
|