@evomap/evolver 1.29.2 → 1.29.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver",
3
- "version": "1.29.2",
3
+ "version": "1.29.4",
4
4
  "description": "A GEP-powered self-evolution engine for AI agents. Features automated log analysis and Genome Evolution Protocol (GEP) for auditable, reusable evolution assets.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/evolve.js CHANGED
@@ -64,7 +64,9 @@ const TODAY_LOG = path.join(MEMORY_DIR, new Date().toISOString().split('T')[0] +
64
64
  // Ensure memory directory exists so state/cache writes work.
65
65
  try {
66
66
  if (!fs.existsSync(MEMORY_DIR)) fs.mkdirSync(MEMORY_DIR, { recursive: true });
67
- } catch (e) {}
67
+ } catch (e) {
68
+ console.warn('[Evolver] Failed to create MEMORY_DIR (may cause downstream errors):', e && e.message || e);
69
+ }
68
70
 
69
71
  function formatSessionLog(jsonlContent) {
70
72
  const result = [];
@@ -1041,7 +1043,9 @@ async function run() {
1041
1043
  try {
1042
1044
  const { tryReadMemoryGraphEvents } = require('./gep/memoryGraph');
1043
1045
  taskMemoryEvents = tryReadMemoryGraphEvents(1000);
1044
- } catch {}
1046
+ } catch (e) {
1047
+ console.warn('[TaskReceiver] MemoryGraph read failed (task selection proceeds without history):', e && e.message || e);
1048
+ }
1045
1049
  const best = selectBestTask(hubTasks, taskMemoryEvents);
1046
1050
  if (best) {
1047
1051
  const alreadyClaimed = best.status === 'claimed';
@@ -1085,7 +1089,9 @@ async function run() {
1085
1089
  }
1086
1090
  }
1087
1091
  }
1088
- } catch {}
1092
+ } catch (e) {
1093
+ console.warn('[Commitment] Overdue task check failed (non-fatal):', e && e.message || e);
1094
+ }
1089
1095
 
1090
1096
  // --- Worker Pool: select task from heartbeat available_work (deferred claim) ---
1091
1097
  // Only remember the best task and inject its signals; actual claim+complete
@@ -1099,7 +1105,9 @@ async function run() {
1099
1105
  try {
1100
1106
  const { tryReadMemoryGraphEvents } = require('./gep/memoryGraph');
1101
1107
  taskMemoryEvents = tryReadMemoryGraphEvents(1000);
1102
- } catch {}
1108
+ } catch (e) {
1109
+ console.warn('[WorkerPool] MemoryGraph read failed (task selection proceeds without history):', e && e.message || e);
1110
+ }
1103
1111
  const best = selectBestTask(workerTasks, taskMemoryEvents);
1104
1112
  if (best) {
1105
1113
  activeTask = best;
@@ -1174,7 +1182,9 @@ async function run() {
1174
1182
  for (const c of newCandidates) {
1175
1183
  try {
1176
1184
  appendCandidateJsonl(c);
1177
- } catch (e) {}
1185
+ } catch (e) {
1186
+ console.warn('[Candidates] Failed to persist candidate:', e && e.message || e);
1187
+ }
1178
1188
  }
1179
1189
  const recentCandidates = readRecentCandidates(20);
1180
1190
  const capabilityCandidatesPreview = renderCandidatesPreview(recentCandidates.slice(-8), 1600);
@@ -1237,7 +1247,9 @@ async function run() {
1237
1247
  2
1238
1248
  )}\n\`\`\``;
1239
1249
  }
1240
- } catch (e) {}
1250
+ } catch (e) {
1251
+ console.warn('[ExternalCandidates] Preview build failed (non-fatal):', e && e.message || e);
1252
+ }
1241
1253
 
1242
1254
  // Search-First Evolution: query Hub for reusable solutions before local reasoning.
1243
1255
  let hubHit = null;
@@ -1425,7 +1437,9 @@ async function run() {
1425
1437
  .split('\n')
1426
1438
  .map(l => l.trim())
1427
1439
  .filter(Boolean);
1428
- } catch (e) {}
1440
+ } catch (e) {
1441
+ console.warn('[SolidifyState] Failed to read baseline untracked files:', e && e.message || e);
1442
+ }
1429
1443
 
1430
1444
  try {
1431
1445
  const out = execSync('git rev-parse HEAD', {
@@ -1436,7 +1450,9 @@ async function run() {
1436
1450
  windowsHide: true,
1437
1451
  });
1438
1452
  baselineHead = String(out || '').trim() || null;
1439
- } catch (e) {}
1453
+ } catch (e) {
1454
+ console.warn('[SolidifyState] Failed to read git HEAD:', e && e.message || e);
1455
+ }
1440
1456
 
1441
1457
  const maxFiles =
1442
1458
  selectedGene && selectedGene.constraints && Number.isFinite(Number(selectedGene.constraints.max_files))
@@ -399,6 +399,7 @@ var _heartbeatStartedAt = null;
399
399
  var _heartbeatConsecutiveFailures = 0;
400
400
  var _heartbeatTotalSent = 0;
401
401
  var _heartbeatTotalFailed = 0;
402
+ var _heartbeatFpSent = false;
402
403
  var _latestAvailableWork = [];
403
404
  var _latestOverdueTasks = [];
404
405
  var _pendingCommitmentUpdates = [];
@@ -516,6 +517,16 @@ function sendHeartbeat() {
516
517
  meta.commitment_updates = _pendingCommitmentUpdates.splice(0);
517
518
  }
518
519
 
520
+ if (!_heartbeatFpSent) {
521
+ try {
522
+ var fp = captureEnvFingerprint();
523
+ if (fp && fp.evolver_version) {
524
+ meta.env_fingerprint = fp;
525
+ _heartbeatFpSent = true;
526
+ }
527
+ } catch {}
528
+ }
529
+
519
530
  if (Object.keys(meta).length > 0) {
520
531
  bodyObj.meta = meta;
521
532
  }
@@ -177,11 +177,27 @@ function readRecentCandidates(limit = 20) {
177
177
  try {
178
178
  const p = candidatesPath();
179
179
  if (!fs.existsSync(p)) return [];
180
- const raw = fs.readFileSync(p, 'utf8');
181
- const lines = raw.split('\n').map(l => l.trim()).filter(Boolean);
182
- return lines.slice(Math.max(0, lines.length - limit)).map(l => {
183
- try { return JSON.parse(l); } catch { return null; }
184
- }).filter(Boolean);
180
+ const stat = fs.statSync(p);
181
+ if (stat.size < 1024 * 1024) {
182
+ const raw = fs.readFileSync(p, 'utf8');
183
+ const lines = raw.split('\n').map(l => l.trim()).filter(Boolean);
184
+ return lines.slice(-limit).map(l => {
185
+ try { return JSON.parse(l); } catch { return null; }
186
+ }).filter(Boolean);
187
+ }
188
+ // Large file (>1MB): only read the tail to avoid OOM.
189
+ const fd = fs.openSync(p, 'r');
190
+ try {
191
+ const chunkSize = Math.min(stat.size, limit * 4096);
192
+ const buf = Buffer.alloc(chunkSize);
193
+ fs.readSync(fd, buf, 0, chunkSize, stat.size - chunkSize);
194
+ const lines = buf.toString('utf8').split('\n').map(l => l.trim()).filter(Boolean);
195
+ return lines.slice(-limit).map(l => {
196
+ try { return JSON.parse(l); } catch { return null; }
197
+ }).filter(Boolean);
198
+ } finally {
199
+ fs.closeSync(fd);
200
+ }
185
201
  } catch { return []; }
186
202
  }
187
203
 
@@ -189,11 +205,26 @@ function readRecentExternalCandidates(limit = 50) {
189
205
  try {
190
206
  const p = externalCandidatesPath();
191
207
  if (!fs.existsSync(p)) return [];
192
- const raw = fs.readFileSync(p, 'utf8');
193
- const lines = raw.split('\n').map(l => l.trim()).filter(Boolean);
194
- return lines.slice(Math.max(0, lines.length - limit)).map(l => {
195
- try { return JSON.parse(l); } catch { return null; }
196
- }).filter(Boolean);
208
+ const stat = fs.statSync(p);
209
+ if (stat.size < 1024 * 1024) {
210
+ const raw = fs.readFileSync(p, 'utf8');
211
+ const lines = raw.split('\n').map(l => l.trim()).filter(Boolean);
212
+ return lines.slice(-limit).map(l => {
213
+ try { return JSON.parse(l); } catch { return null; }
214
+ }).filter(Boolean);
215
+ }
216
+ const fd = fs.openSync(p, 'r');
217
+ try {
218
+ const chunkSize = Math.min(stat.size, limit * 4096);
219
+ const buf = Buffer.alloc(chunkSize);
220
+ fs.readSync(fd, buf, 0, chunkSize, stat.size - chunkSize);
221
+ const lines = buf.toString('utf8').split('\n').map(l => l.trim()).filter(Boolean);
222
+ return lines.slice(-limit).map(l => {
223
+ try { return JSON.parse(l); } catch { return null; }
224
+ }).filter(Boolean);
225
+ } finally {
226
+ fs.closeSync(fd);
227
+ }
197
228
  } catch { return []; }
198
229
  }
199
230
 
package/src/gep/paths.js CHANGED
@@ -6,16 +6,33 @@ function getRepoRoot() {
6
6
  return process.env.EVOLVER_REPO_ROOT;
7
7
  }
8
8
 
9
- let dir = path.resolve(__dirname, '..', '..');
9
+ const ownDir = path.resolve(__dirname, '..', '..');
10
+
11
+ // Safety: check evolver's own directory first to prevent operating on a
12
+ // parent repo that happens to contain .git (which could cause data loss
13
+ // when git reset --hard runs in the wrong scope).
14
+ if (fs.existsSync(path.join(ownDir, '.git'))) {
15
+ return ownDir;
16
+ }
17
+
18
+ let dir = path.dirname(ownDir);
10
19
  while (dir !== '/' && dir !== '.') {
11
- const gitDir = path.join(dir, '.git');
12
- if (fs.existsSync(gitDir)) {
13
- return dir;
20
+ if (fs.existsSync(path.join(dir, '.git'))) {
21
+ if (process.env.EVOLVER_USE_PARENT_GIT === 'true') {
22
+ console.warn('[evolver] Using parent git repository at:', dir);
23
+ return dir;
24
+ }
25
+ console.warn(
26
+ '[evolver] Detected .git in parent directory', dir,
27
+ '-- ignoring. Set EVOLVER_USE_PARENT_GIT=true to override,',
28
+ 'or EVOLVER_REPO_ROOT to specify the target directory explicitly.'
29
+ );
30
+ return ownDir;
14
31
  }
15
32
  dir = path.dirname(dir);
16
33
  }
17
34
 
18
- return path.resolve(__dirname, '..', '..');
35
+ return ownDir;
19
36
  }
20
37
 
21
38
  function getWorkspaceRoot() {
@@ -72,6 +72,11 @@ function geneToSkillMd(gene) {
72
72
  });
73
73
  }
74
74
 
75
+ lines.push('---');
76
+ lines.push('');
77
+ lines.push('*This Skill was generated by [Evolver](https://github.com/autogame-17/evolver) and is distributed under the [EvoMap Skill License (ESL-1.0)](https://evomap.ai/terms). Unauthorized redistribution, bulk scraping, or republishing is prohibited. See LICENSE file for full terms.*');
78
+ lines.push('');
79
+
75
80
  return lines.join('\n');
76
81
  }
77
82