claude-evolve 1.3.43 → 1.3.44

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,121 @@
1
+ #!/usr/bin/env python3
2
+ """Robust CSV helper for evolution system that handles edge cases properly."""
3
+
4
+ import csv
5
+ import sys
6
+
7
+
8
+ def is_valid_candidate_row(row):
9
+ """Check if a row represents a valid candidate (not empty, has ID)."""
10
+ if not row:
11
+ return False
12
+ if len(row) == 0:
13
+ return False
14
+ # First column should have a non-empty ID
15
+ if not row[0] or row[0].strip() == '':
16
+ return False
17
+ return True
18
+
19
+
20
+ def is_pending_candidate(row):
21
+ """Check if a candidate row is pending (needs processing)."""
22
+ if not is_valid_candidate_row(row):
23
+ return False
24
+
25
+ # Must have at least 5 columns to check status
26
+ if len(row) < 5:
27
+ return True # Incomplete row is pending
28
+
29
+ # Check status field (5th column, index 4)
30
+ status = row[4].strip().lower() if row[4] else ''
31
+
32
+ # Blank, missing, "pending", or "running" all mean pending
33
+ if not status or status in ['pending', 'running']:
34
+ return True
35
+
36
+ # Check for retry statuses
37
+ if status.startswith('failed-retry'):
38
+ return True
39
+
40
+ return False
41
+
42
+
43
+ def get_pending_candidates(csv_file):
44
+ """Get list of pending candidate IDs from CSV."""
45
+ pending = []
46
+
47
+ try:
48
+ with open(csv_file, 'r') as f:
49
+ reader = csv.reader(f)
50
+ # Skip header
51
+ next(reader, None)
52
+
53
+ for row in reader:
54
+ if is_pending_candidate(row):
55
+ candidate_id = row[0].strip()
56
+ status = row[4].strip() if len(row) > 4 else ''
57
+ pending.append((candidate_id, status))
58
+
59
+ except Exception as e:
60
+ print(f"Error reading CSV: {e}", file=sys.stderr)
61
+ return []
62
+
63
+ return pending
64
+
65
+
66
+ def update_candidate_status(csv_file, candidate_id, new_status):
67
+ """Update the status of a specific candidate."""
68
+ rows = []
69
+ updated = False
70
+
71
+ try:
72
+ # Read all rows
73
+ with open(csv_file, 'r') as f:
74
+ reader = csv.reader(f)
75
+ rows = list(reader)
76
+
77
+ # Update the specific candidate
78
+ for i, row in enumerate(rows):
79
+ if is_valid_candidate_row(row) and row[0].strip() == candidate_id:
80
+ # Ensure row has at least 5 columns
81
+ while len(row) < 5:
82
+ row.append('')
83
+ row[4] = new_status
84
+ updated = True
85
+ break
86
+
87
+ # Write back if updated
88
+ if updated:
89
+ with open(csv_file, 'w', newline='') as f:
90
+ writer = csv.writer(f)
91
+ writer.writerows(rows)
92
+
93
+ return updated
94
+
95
+ except Exception as e:
96
+ print(f"Error updating CSV: {e}", file=sys.stderr)
97
+ return False
98
+
99
+
100
+ if __name__ == '__main__':
101
+ # Test functionality
102
+ if len(sys.argv) < 2:
103
+ print("Usage: csv_helper_robust.py <csv_file> [command]")
104
+ sys.exit(1)
105
+
106
+ csv_file = sys.argv[1]
107
+ command = sys.argv[2] if len(sys.argv) > 2 else 'list'
108
+
109
+ if command == 'list':
110
+ pending = get_pending_candidates(csv_file)
111
+ for candidate_id, status in pending:
112
+ print(f"{candidate_id}|{status}")
113
+
114
+ elif command == 'update' and len(sys.argv) >= 5:
115
+ candidate_id = sys.argv[3]
116
+ new_status = sys.argv[4]
117
+ if update_candidate_status(csv_file, candidate_id, new_status):
118
+ print(f"Updated {candidate_id} to {new_status}")
119
+ else:
120
+ print(f"Failed to update {candidate_id}")
121
+ sys.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-evolve",
3
- "version": "1.3.43",
3
+ "version": "1.3.44",
4
4
  "bin": {
5
5
  "claude-evolve": "./bin/claude-evolve",
6
6
  "claude-evolve-main": "./bin/claude-evolve-main",