claude-evolve 1.0.6 → 1.0.8

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.
@@ -0,0 +1,179 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Load configuration
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ # shellcheck source=../lib/config.sh
8
+ source "$SCRIPT_DIR/../lib/config.sh"
9
+
10
+ show_help() {
11
+ cat <<EOF
12
+ claude-evolve config - Manage configuration settings
13
+
14
+ USAGE:
15
+ claude-evolve config [--show] [--edit] [--reset]
16
+
17
+ OPTIONS:
18
+ --show Show current configuration (default)
19
+ --edit Open config file in editor
20
+ --reset Reset to default configuration
21
+ --help Show this help message
22
+
23
+ DESCRIPTION:
24
+ Manages claude-evolve configuration settings including file paths,
25
+ algorithm locations, and behavior settings.
26
+
27
+ CONFIGURATION FILES:
28
+ The configuration is loaded from the first file found:
29
+ 1. ./config.sh (current directory)
30
+ 2. ./evolution/config.sh (evolution workspace)
31
+ 3. ./.claude-evolve.config (hidden config file)
32
+
33
+ If no config file exists, defaults are used.
34
+ EOF
35
+ }
36
+
37
+ # Parse arguments
38
+ action="show"
39
+ while [[ $# -gt 0 ]]; do
40
+ case $1 in
41
+ --help)
42
+ show_help
43
+ exit 0
44
+ ;;
45
+ --show)
46
+ action="show"
47
+ shift
48
+ ;;
49
+ --edit)
50
+ action="edit"
51
+ shift
52
+ ;;
53
+ --reset)
54
+ action="reset"
55
+ shift
56
+ ;;
57
+ *)
58
+ echo "[ERROR] Unknown option: $1" >&2
59
+ echo "Use --help for usage information" >&2
60
+ exit 1
61
+ ;;
62
+ esac
63
+ done
64
+
65
+ # Load current config
66
+ load_config
67
+
68
+ case $action in
69
+ show)
70
+ show_config
71
+ ;;
72
+ edit)
73
+ # Find or create config file
74
+ config_file=""
75
+ if [[ -f "evolution/config.sh" ]]; then
76
+ config_file="evolution/config.sh"
77
+ elif [[ -f "config.sh" ]]; then
78
+ config_file="config.sh"
79
+ elif [[ -f ".claude-evolve.config" ]]; then
80
+ config_file=".claude-evolve.config"
81
+ else
82
+ # Create in evolution directory if it exists
83
+ if [[ -d "evolution" ]]; then
84
+ config_file="evolution/config.sh"
85
+ else
86
+ config_file="config.sh"
87
+ fi
88
+ echo "[INFO] Creating new config file: $config_file"
89
+
90
+ # Copy template if available
91
+ if [[ -f "$SCRIPT_DIR/../templates/config.sh" ]]; then
92
+ cp "$SCRIPT_DIR/../templates/config.sh" "$config_file"
93
+ else
94
+ # Create basic config
95
+ cat > "$config_file" <<EOF
96
+ #!/bin/bash
97
+ # claude-evolve configuration file
98
+
99
+ # Working directory for evolution files
100
+ EVOLUTION_DIR="evolution"
101
+
102
+ # Algorithm and evaluator file paths (relative to EVOLUTION_DIR)
103
+ ALGORITHM_FILE="algorithm.py"
104
+ EVALUATOR_FILE="evaluator.py"
105
+ BRIEF_FILE="BRIEF.md"
106
+
107
+ # CSV file for tracking evolution (relative to EVOLUTION_DIR)
108
+ EVOLUTION_CSV="evolution.csv"
109
+
110
+ # Output directory for generated algorithms (relative to EVOLUTION_DIR)
111
+ OUTPUT_DIR=""
112
+
113
+ # Parent algorithm selection strategy: "best", "random", "latest"
114
+ PARENT_SELECTION="best"
115
+
116
+ # Maximum number of ideas to generate at once
117
+ MAX_IDEAS=50
118
+
119
+ # Python command to use for evaluation
120
+ PYTHON_CMD="python3"
121
+ EOF
122
+ fi
123
+ fi
124
+
125
+ # Open in editor
126
+ if [[ -n ${EDITOR:-} ]]; then
127
+ "$EDITOR" "$config_file"
128
+ elif command -v code >/dev/null 2>&1; then
129
+ code "$config_file"
130
+ elif command -v nano >/dev/null 2>&1; then
131
+ nano "$config_file"
132
+ else
133
+ echo "[INFO] Config file created at: $config_file"
134
+ echo "[INFO] Edit manually or set EDITOR environment variable"
135
+ fi
136
+ ;;
137
+ reset)
138
+ if [[ -d "evolution" ]]; then
139
+ config_file="evolution/config.sh"
140
+ else
141
+ config_file="config.sh"
142
+ fi
143
+
144
+ echo "[INFO] Resetting configuration to defaults: $config_file"
145
+ if [[ -f "$SCRIPT_DIR/../templates/config.sh" ]]; then
146
+ cp "$SCRIPT_DIR/../templates/config.sh" "$config_file"
147
+ else
148
+ # Create default config
149
+ cat > "$config_file" <<EOF
150
+ #!/bin/bash
151
+ # claude-evolve configuration file
152
+
153
+ # Working directory for evolution files
154
+ EVOLUTION_DIR="evolution"
155
+
156
+ # Algorithm and evaluator file paths (relative to EVOLUTION_DIR)
157
+ ALGORITHM_FILE="algorithm.py"
158
+ EVALUATOR_FILE="evaluator.py"
159
+ BRIEF_FILE="BRIEF.md"
160
+
161
+ # CSV file for tracking evolution (relative to EVOLUTION_DIR)
162
+ EVOLUTION_CSV="evolution.csv"
163
+
164
+ # Output directory for generated algorithms (relative to EVOLUTION_DIR)
165
+ OUTPUT_DIR=""
166
+
167
+ # Parent algorithm selection strategy: "best", "random", "latest"
168
+ PARENT_SELECTION="best"
169
+
170
+ # Maximum number of ideas to generate at once
171
+ MAX_IDEAS=50
172
+
173
+ # Python command to use for evaluation
174
+ PYTHON_CMD="python3"
175
+ EOF
176
+ fi
177
+ echo "[INFO] Configuration reset successfully"
178
+ ;;
179
+ esac
@@ -2,6 +2,12 @@
2
2
 
3
3
  set -e
4
4
 
5
+ # Load configuration
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ # shellcheck source=../lib/config.sh
8
+ source "$SCRIPT_DIR/../lib/config.sh"
9
+ load_config
10
+
5
11
  # Parse arguments
6
12
  count=20
7
13
  no_ai=false
@@ -51,20 +57,20 @@ if [[ $count -lt 1 || $count -gt 50 ]]; then
51
57
  exit 1
52
58
  fi
53
59
 
54
- # Check workspace
55
- if [[ ! -d evolution ]]; then
56
- echo "[ERROR] Evolution workspace not found. Run 'claude-evolve setup' first." >&2
60
+ # Check workspace using config
61
+ if [[ ! -d "$FULL_EVOLUTION_DIR" ]]; then
62
+ echo "[ERROR] Evolution workspace not found: $FULL_EVOLUTION_DIR. Run 'claude-evolve setup' first." >&2
57
63
  exit 1
58
64
  fi
59
65
 
60
66
  # Ensure CSV exists
61
- if [[ ! -f evolution/evolution.csv ]]; then
62
- echo "id,basedOnId,description,performance,status" >evolution/evolution.csv
67
+ if [[ ! -f "$FULL_CSV_PATH" ]]; then
68
+ echo "id,basedOnId,description,performance,status" >"$FULL_CSV_PATH"
63
69
  fi
64
70
 
65
71
  # Get next ID
66
72
  get_next_id() {
67
- if [[ ! -f evolution/evolution.csv ]]; then
73
+ if [[ ! -f "$FULL_CSV_PATH" ]]; then
68
74
  echo "1"
69
75
  return
70
76
  fi
@@ -74,7 +80,7 @@ get_next_id() {
74
80
  if [[ $id =~ ^[0-9]+$ ]] && (( 10#$id > max_id )); then
75
81
  max_id=$((10#$id))
76
82
  fi
77
- done < <(tail -n +2 evolution/evolution.csv)
83
+ done < <(tail -n +2 "$FULL_CSV_PATH")
78
84
  echo $((max_id + 1))
79
85
  }
80
86
 
@@ -88,7 +94,7 @@ add_idea() {
88
94
  local escaped_desc="${description//\"/\"\"}"
89
95
 
90
96
  # Append to CSV
91
- echo "${id},,\"${escaped_desc}\",," >>evolution/evolution.csv
97
+ echo "${id},,\"${escaped_desc}\",," >>"$FULL_CSV_PATH"
92
98
  echo "[INFO] Added idea: $description"
93
99
  }
94
100
 
@@ -119,7 +125,7 @@ ideate_manual() {
119
125
  fi
120
126
  done
121
127
 
122
- echo "[INFO] Added $ideas_added idea(s) to evolution.csv"
128
+ echo "[INFO] Added $ideas_added idea(s) to $EVOLUTION_CSV"
123
129
  }
124
130
 
125
131
  # AI generation mode
@@ -130,24 +136,24 @@ ideate_ai() {
130
136
  return 1
131
137
  fi
132
138
 
133
- if [[ ! -f evolution/BRIEF.md ]]; then
134
- echo "[WARN] BRIEF.md not found. Falling back to manual entry."
139
+ if [[ ! -f "$FULL_BRIEF_PATH" ]]; then
140
+ echo "[WARN] $BRIEF_FILE not found. Falling back to manual entry."
135
141
  return 1
136
142
  fi
137
143
 
138
144
  # Get top performers (pure shell)
139
145
  local top_performers=""
140
- if [[ -f evolution/evolution.csv ]]; then
146
+ if [[ -f "$FULL_CSV_PATH" ]]; then
141
147
  # 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)
148
+ top_performers=$(awk -F, 'NR > 1 && $4 != "" { print $1 ": " $3 " (score: " $4 ")" }' "$FULL_CSV_PATH" | head -5)
143
149
  fi
144
150
 
145
151
  # Build prompt
146
152
  local prompt
147
- prompt="You are helping with algorithm evolution. Generate exactly $count new algorithm idea(s) based on the following context.
153
+ prompt="It's time for your megathinking mode! You are helping with algorithm evolution. Generate exactly $count new algorithm idea(s) based on the following context.
148
154
 
149
155
  Project Brief:
150
- $(cat evolution/BRIEF.md)
156
+ $(cat "$FULL_BRIEF_PATH")
151
157
  "
152
158
 
153
159
  if [[ -n $top_performers ]]; then
@@ -81,8 +81,9 @@ show_menu() {
81
81
  echo " 2) ideate - Generate new algorithm ideas"
82
82
  echo " 3) run - Execute evolution candidates"
83
83
  echo " 4) analyze - Analyze evolution results"
84
- echo " 5) help - Show help message"
85
- echo " 6) exit - Exit"
84
+ echo " 5) config - Manage configuration settings"
85
+ echo " 6) help - Show help message"
86
+ echo " 7) exit - Exit"
86
87
  echo
87
88
 
88
89
  # Show workspace status
@@ -99,20 +100,21 @@ check_for_updates
99
100
  # Main logic
100
101
  if [[ $# -eq 0 ]]; then
101
102
  show_menu
102
- read -r -p "Enter your choice (1-6): " choice
103
+ read -r -p "Enter your choice (1-7): " choice
103
104
 
104
105
  case $choice in
105
106
  1) exec "$SCRIPT_DIR/claude-evolve-setup" ;;
106
107
  2) exec "$SCRIPT_DIR/claude-evolve-ideate" ;;
107
108
  3) exec "$SCRIPT_DIR/claude-evolve-run" ;;
108
109
  4) exec "$SCRIPT_DIR/claude-evolve-analyze" ;;
109
- 5) show_help ;;
110
- 6)
110
+ 5) exec "$SCRIPT_DIR/claude-evolve-config" ;;
111
+ 6) show_help ;;
112
+ 7)
111
113
  echo "Goodbye!"
112
114
  exit 0
113
115
  ;;
114
116
  *)
115
- echo -e "${RED}Invalid choice. Please select 1-6.${NC}"
117
+ echo -e "${RED}Invalid choice. Please select 1-7.${NC}"
116
118
  exit 1
117
119
  ;;
118
120
  esac
@@ -141,6 +143,10 @@ analyze)
141
143
  shift
142
144
  exec "$SCRIPT_DIR/claude-evolve-analyze" "$@"
143
145
  ;;
146
+ config)
147
+ shift
148
+ exec "$SCRIPT_DIR/claude-evolve-config" "$@"
149
+ ;;
144
150
  *)
145
151
  echo "Unknown command: ${1:-}"
146
152
  echo
@@ -20,7 +20,7 @@ else
20
20
  fi
21
21
 
22
22
  # Copy template files
23
- for file in BRIEF.md algorithm.py evaluator.py; do
23
+ for file in BRIEF.md algorithm.py evaluator.py config.sh; do
24
24
  if [[ ! -f evolution/$file ]]; then
25
25
  if [[ -f "$PROJECT_ROOT/templates/$file" ]]; then
26
26
  echo "[INFO] Copying $file from templates..."
package/lib/config.sh ADDED
@@ -0,0 +1,103 @@
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
+ DEFAULT_MAX_IDEAS=50
13
+ DEFAULT_PYTHON_CMD="python3"
14
+
15
+ # Load configuration from config file
16
+ load_config() {
17
+ # Set defaults first
18
+ EVOLUTION_DIR="$DEFAULT_EVOLUTION_DIR"
19
+ ALGORITHM_FILE="$DEFAULT_ALGORITHM_FILE"
20
+ EVALUATOR_FILE="$DEFAULT_EVALUATOR_FILE"
21
+ BRIEF_FILE="$DEFAULT_BRIEF_FILE"
22
+ EVOLUTION_CSV="$DEFAULT_EVOLUTION_CSV"
23
+ OUTPUT_DIR="$DEFAULT_OUTPUT_DIR"
24
+ PARENT_SELECTION="$DEFAULT_PARENT_SELECTION"
25
+ MAX_IDEAS="$DEFAULT_MAX_IDEAS"
26
+ PYTHON_CMD="$DEFAULT_PYTHON_CMD"
27
+
28
+ # Look for config file in current directory, then evolution directory
29
+ local config_file=""
30
+ if [[ -f "config.sh" ]]; then
31
+ config_file="config.sh"
32
+ elif [[ -f "evolution/config.sh" ]]; then
33
+ config_file="evolution/config.sh"
34
+ elif [[ -f ".claude-evolve.config" ]]; then
35
+ config_file=".claude-evolve.config"
36
+ fi
37
+
38
+ # Load config if found
39
+ if [[ -n $config_file ]]; then
40
+ echo "[INFO] Loading configuration from: $config_file"
41
+ # shellcheck source=/dev/null
42
+ source "$config_file"
43
+ fi
44
+
45
+ # Create full paths
46
+ FULL_EVOLUTION_DIR="$EVOLUTION_DIR"
47
+ FULL_ALGORITHM_PATH="$EVOLUTION_DIR/$ALGORITHM_FILE"
48
+ FULL_EVALUATOR_PATH="$EVOLUTION_DIR/$EVALUATOR_FILE"
49
+ FULL_BRIEF_PATH="$EVOLUTION_DIR/$BRIEF_FILE"
50
+ FULL_CSV_PATH="$EVOLUTION_DIR/$EVOLUTION_CSV"
51
+
52
+ if [[ -n $OUTPUT_DIR ]]; then
53
+ FULL_OUTPUT_DIR="$EVOLUTION_DIR/$OUTPUT_DIR"
54
+ else
55
+ FULL_OUTPUT_DIR="$EVOLUTION_DIR"
56
+ fi
57
+ }
58
+
59
+ # Validate configuration
60
+ validate_config() {
61
+ local errors=0
62
+
63
+ if [[ ! -d "$FULL_EVOLUTION_DIR" ]]; then
64
+ echo "[ERROR] Evolution directory not found: $FULL_EVOLUTION_DIR" >&2
65
+ ((errors++))
66
+ fi
67
+
68
+ if [[ ! -f "$FULL_ALGORITHM_PATH" ]]; then
69
+ echo "[ERROR] Algorithm file not found: $FULL_ALGORITHM_PATH" >&2
70
+ ((errors++))
71
+ fi
72
+
73
+ if [[ ! -f "$FULL_EVALUATOR_PATH" ]]; then
74
+ echo "[ERROR] Evaluator file not found: $FULL_EVALUATOR_PATH" >&2
75
+ ((errors++))
76
+ fi
77
+
78
+ if [[ ! -f "$FULL_BRIEF_PATH" ]]; then
79
+ echo "[ERROR] Brief file not found: $FULL_BRIEF_PATH" >&2
80
+ ((errors++))
81
+ fi
82
+
83
+ if ! command -v "$PYTHON_CMD" >/dev/null 2>&1; then
84
+ echo "[ERROR] Python command not found: $PYTHON_CMD" >&2
85
+ ((errors++))
86
+ fi
87
+
88
+ return $errors
89
+ }
90
+
91
+ # Show current configuration
92
+ show_config() {
93
+ echo "Current claude-evolve configuration:"
94
+ echo " Evolution directory: $FULL_EVOLUTION_DIR"
95
+ echo " Algorithm file: $FULL_ALGORITHM_PATH"
96
+ echo " Evaluator file: $FULL_EVALUATOR_PATH"
97
+ echo " Brief file: $FULL_BRIEF_PATH"
98
+ echo " CSV file: $FULL_CSV_PATH"
99
+ echo " Output directory: $FULL_OUTPUT_DIR"
100
+ echo " Parent selection: $PARENT_SELECTION"
101
+ echo " Max ideas: $MAX_IDEAS"
102
+ echo " Python command: $PYTHON_CMD"
103
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "claude-evolve",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "bin": {
5
5
  "claude-evolve": "./bin/claude-evolve",
6
6
  "claude-evolve-main": "./bin/claude-evolve-main",
7
7
  "claude-evolve-setup": "./bin/claude-evolve-setup",
8
8
  "claude-evolve-ideate": "./bin/claude-evolve-ideate",
9
9
  "claude-evolve-run": "./bin/claude-evolve-run",
10
- "claude-evolve-analyze": "./bin/claude-evolve-analyze"
10
+ "claude-evolve-analyze": "./bin/claude-evolve-analyze",
11
+ "claude-evolve-config": "./bin/claude-evolve-config"
11
12
  },
12
13
  "files": [
13
14
  "bin/",
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+ # claude-evolve configuration file
3
+ # This file defines paths and settings for the evolution process
4
+
5
+ # Working directory for evolution files
6
+ EVOLUTION_DIR="evolution"
7
+
8
+ # Algorithm and evaluator file paths (relative to EVOLUTION_DIR)
9
+ ALGORITHM_FILE="algorithm.py"
10
+ EVALUATOR_FILE="evaluator.py"
11
+ BRIEF_FILE="BRIEF.md"
12
+
13
+ # CSV file for tracking evolution (relative to EVOLUTION_DIR)
14
+ EVOLUTION_CSV="evolution.csv"
15
+
16
+ # Output directory for generated algorithms (relative to EVOLUTION_DIR)
17
+ OUTPUT_DIR=""
18
+
19
+ # Parent algorithm selection strategy
20
+ # Options: "best", "random", "latest"
21
+ PARENT_SELECTION="best"
22
+
23
+ # Maximum number of ideas to generate at once
24
+ MAX_IDEAS=50
25
+
26
+ # Python command to use for evaluation
27
+ PYTHON_CMD="python3"