MCPcopy Create free account
hub / github.com/EvoMap/evolver / deriveFallbackName

Function deriveFallbackName

src/gep/skillPublisher.js:40–58  ·  view source on GitHub ↗

* Derive fallback name words from gene signals/summary when id is not usable.

(gene)

Source from the content-addressed store, hash-verified

38 * Derive fallback name words from gene signals/summary when id is not usable.
39 */
40function deriveFallbackName(gene) {
41 var fallbackWords = [];
42 var STOP = new Set(['the', 'and', 'for', 'with', 'from', 'that', 'this', 'into', 'when', 'are', 'was', 'has', 'had', 'not', 'but', 'its']);
43 if (Array.isArray(gene.signals_match)) {
44 gene.signals_match.slice(0, 3).forEach(function (s) {
45 String(s).toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim().split(/\s+/).forEach(function (w) {
46 if (w.length >= 3 && !STOP.has(w) && fallbackWords.length < 5) fallbackWords.push(w);
47 });
48 });
49 }
50 if (fallbackWords.length < 2 && gene.summary) {
51 String(gene.summary).toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim().split(/\s+/).forEach(function (w) {
52 if (w.length >= 3 && !STOP.has(w) && fallbackWords.length < 5) fallbackWords.push(w);
53 });
54 }
55 var seen = {};
56 fallbackWords = fallbackWords.filter(function (w) { if (seen[w]) return false; seen[w] = true; return true; });
57 return fallbackWords.length >= 2 ? fallbackWords.join('-') : 'auto-distilled-skill';
58}
59
60/**
61 * Convert a Gene object into SKILL.md format -- marketplace-quality content.

Callers 1

geneToSkillMdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected