@evomap/evolver 1.28.1

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.
Files changed (52) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +290 -0
  3. package/README.zh-CN.md +236 -0
  4. package/SKILL.md +132 -0
  5. package/assets/gep/capsules.json +79 -0
  6. package/assets/gep/events.jsonl +7 -0
  7. package/assets/gep/genes.json +108 -0
  8. package/index.js +530 -0
  9. package/package.json +38 -0
  10. package/src/canary.js +13 -0
  11. package/src/evolve.js +1704 -0
  12. package/src/gep/a2a.js +173 -0
  13. package/src/gep/a2aProtocol.js +736 -0
  14. package/src/gep/analyzer.js +35 -0
  15. package/src/gep/assetCallLog.js +130 -0
  16. package/src/gep/assetStore.js +297 -0
  17. package/src/gep/assets.js +36 -0
  18. package/src/gep/bridge.js +71 -0
  19. package/src/gep/candidates.js +142 -0
  20. package/src/gep/contentHash.js +65 -0
  21. package/src/gep/deviceId.js +209 -0
  22. package/src/gep/envFingerprint.js +83 -0
  23. package/src/gep/hubReview.js +206 -0
  24. package/src/gep/hubSearch.js +237 -0
  25. package/src/gep/issueReporter.js +262 -0
  26. package/src/gep/llmReview.js +92 -0
  27. package/src/gep/memoryGraph.js +771 -0
  28. package/src/gep/memoryGraphAdapter.js +203 -0
  29. package/src/gep/mutation.js +186 -0
  30. package/src/gep/narrativeMemory.js +108 -0
  31. package/src/gep/paths.js +113 -0
  32. package/src/gep/personality.js +355 -0
  33. package/src/gep/prompt.js +566 -0
  34. package/src/gep/questionGenerator.js +212 -0
  35. package/src/gep/reflection.js +127 -0
  36. package/src/gep/sanitize.js +67 -0
  37. package/src/gep/selector.js +250 -0
  38. package/src/gep/signals.js +417 -0
  39. package/src/gep/skillDistiller.js +499 -0
  40. package/src/gep/solidify.js +1681 -0
  41. package/src/gep/strategy.js +126 -0
  42. package/src/gep/taskReceiver.js +528 -0
  43. package/src/gep/validationReport.js +55 -0
  44. package/src/ops/cleanup.js +80 -0
  45. package/src/ops/commentary.js +60 -0
  46. package/src/ops/health_check.js +106 -0
  47. package/src/ops/index.js +11 -0
  48. package/src/ops/innovation.js +67 -0
  49. package/src/ops/lifecycle.js +168 -0
  50. package/src/ops/self_repair.js +72 -0
  51. package/src/ops/skills_monitor.js +143 -0
  52. package/src/ops/trigger.js +33 -0
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ const { execFileSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const { getRepoRoot } = require('./paths');
8
+
9
+ const REVIEW_ENABLED_KEY = 'EVOLVER_LLM_REVIEW';
10
+ const REVIEW_TIMEOUT_MS = 30000;
11
+
12
+ function isLlmReviewEnabled() {
13
+ return String(process.env[REVIEW_ENABLED_KEY] || '').toLowerCase() === 'true';
14
+ }
15
+
16
+ function buildReviewPrompt({ diff, gene, signals, mutation }) {
17
+ const geneId = gene && gene.id ? gene.id : '(unknown)';
18
+ const category = (mutation && mutation.category) || (gene && gene.category) || 'unknown';
19
+ const rationale = mutation && mutation.rationale ? String(mutation.rationale).slice(0, 500) : '(none)';
20
+ const signalsList = Array.isArray(signals) ? signals.slice(0, 8).join(', ') : '(none)';
21
+ const diffPreview = String(diff || '').slice(0, 6000);
22
+
23
+ return `You are reviewing a code change produced by an autonomous evolution engine.
24
+
25
+ ## Context
26
+ - Gene: ${geneId} (${category})
27
+ - Signals: [${signalsList}]
28
+ - Rationale: ${rationale}
29
+
30
+ ## Diff
31
+ \`\`\`diff
32
+ ${diffPreview}
33
+ \`\`\`
34
+
35
+ ## Review Criteria
36
+ 1. Does this change address the stated signals?
37
+ 2. Are there any obvious regressions or bugs introduced?
38
+ 3. Is the blast radius proportionate to the problem?
39
+ 4. Are there any security or safety concerns?
40
+
41
+ ## Response Format
42
+ Respond with a JSON object:
43
+ {
44
+ "approved": true|false,
45
+ "confidence": 0.0-1.0,
46
+ "concerns": ["..."],
47
+ "summary": "one-line review summary"
48
+ }`;
49
+ }
50
+
51
+ function runLlmReview({ diff, gene, signals, mutation }) {
52
+ if (!isLlmReviewEnabled()) return null;
53
+
54
+ const prompt = buildReviewPrompt({ diff, gene, signals, mutation });
55
+
56
+ try {
57
+ const repoRoot = getRepoRoot();
58
+
59
+ // Write prompt to a temp file to avoid shell quoting issues entirely.
60
+ const tmpFile = path.join(os.tmpdir(), 'evolver_review_prompt_' + process.pid + '.txt');
61
+ fs.writeFileSync(tmpFile, prompt, 'utf8');
62
+
63
+ try {
64
+ // Use execFileSync to bypass shell interpretation (no quoting issues).
65
+ const reviewScript = `
66
+ const fs = require('fs');
67
+ const prompt = fs.readFileSync(process.argv[1], 'utf8');
68
+ console.log(JSON.stringify({ approved: true, confidence: 0.7, concerns: [], summary: 'auto-approved (no external LLM configured)' }));
69
+ `;
70
+ const result = execFileSync(process.execPath, ['-e', reviewScript, tmpFile], {
71
+ cwd: repoRoot,
72
+ encoding: 'utf8',
73
+ timeout: REVIEW_TIMEOUT_MS,
74
+ stdio: ['ignore', 'pipe', 'pipe'],
75
+ windowsHide: true,
76
+ });
77
+
78
+ try {
79
+ return JSON.parse(result.trim());
80
+ } catch (_) {
81
+ return { approved: true, confidence: 0.5, concerns: ['failed to parse review response'], summary: 'review parse error' };
82
+ }
83
+ } finally {
84
+ try { fs.unlinkSync(tmpFile); } catch (_) {}
85
+ }
86
+ } catch (e) {
87
+ console.log('[LLMReview] Execution failed (non-fatal): ' + (e && e.message ? e.message : e));
88
+ return { approved: true, confidence: 0.5, concerns: ['review execution failed'], summary: 'review timeout or error' };
89
+ }
90
+ }
91
+
92
+ module.exports = { isLlmReviewEnabled, runLlmReview, buildReviewPrompt };