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

Function geneToSkillMd

src/gep/skillPublisher.js:66–205  ·  view source on GitHub ↗

* Convert a Gene object into SKILL.md format -- marketplace-quality content. * * @param {object} gene - Gene asset * @returns {string} SKILL.md content

(gene)

Source from the content-addressed store, hash-verified

64 * @returns {string} SKILL.md content
65 */
66function geneToSkillMd(gene) {
67 var rawName = gene.id || 'unnamed-skill';
68 var name = sanitizeSkillName(rawName) || deriveFallbackName(gene);
69 var displayName = toTitleCase(name);
70 var desc = (gene.summary || '').replace(/[\r\n]+/g, ' ').replace(/\s*\d{10,}\s*$/g, '').trim();
71 if (!desc || desc.length < 10) desc = 'AI agent skill distilled from evolution experience.';
72
73 var lines = [
74 '---',
75 'name: ' + displayName,
76 'description: ' + desc,
77 '---',
78 '',
79 '# ' + displayName,
80 '',
81 desc,
82 '',
83 ];
84
85 // -- When to Use (derived from signals; preconditions go in their own section) --
86 if (gene.signals_match && gene.signals_match.length > 0) {
87 lines.push('## When to Use');
88 lines.push('');
89 lines.push('- When your project encounters: ' + gene.signals_match.slice(0, 4).map(function (s) {
90 return '`' + s + '`';
91 }).join(', '));
92 lines.push('');
93 }
94
95 // -- Trigger Signals --
96 if (gene.signals_match && gene.signals_match.length > 0) {
97 lines.push('## Trigger Signals');
98 lines.push('');
99 gene.signals_match.forEach(function (s) {
100 lines.push('- `' + s + '`');
101 });
102 lines.push('');
103 }
104
105 // -- Preconditions --
106 if (gene.preconditions && gene.preconditions.length > 0) {
107 lines.push('## Preconditions');
108 lines.push('');
109 gene.preconditions.forEach(function (p) {
110 lines.push('- ' + p);
111 });
112 lines.push('');
113 }
114
115 // -- Strategy --
116 if (gene.strategy && gene.strategy.length > 0) {
117 lines.push('## Strategy');
118 lines.push('');
119 var stepIdx = 0;
120 gene.strategy.forEach(function (step) {
121 var text = String(step);
122 // Defensive: legacy genes may still carry "AVOID: ..." steps from
123 // pre-2026-04-21 distillations. Skip them from Strategy -- the dedicated

Callers 2

publishSkillToHubFunction · 0.85

Calls 5

sanitizeSkillNameFunction · 0.85
deriveFallbackNameFunction · 0.85
toTitleCaseFunction · 0.85
extractStepVerbFunction · 0.85
stripLeadingVerbFunction · 0.85

Tested by

no test coverage detected