MCPcopy
hub / github.com/garrytan/gstack / processVoiceTriggers

Function processVoiceTriggers

scripts/gen-skill-docs.ts:262–283  ·  view source on GitHub ↗

* Preprocess voice triggers: fold voice-triggers YAML field into description, * then strip the field from frontmatter. Must run BEFORE transformFrontmatter * and extractNameAndDescription so all hosts see the updated description.

(content: string)

Source from the content-addressed store, hash-verified

260 * and extractNameAndDescription so all hosts see the updated description.
261 */
262function processVoiceTriggers(content: string): string {
263 const triggers = extractVoiceTriggers(content);
264 if (triggers.length === 0) return content;
265
266 // Strip voice-triggers block from frontmatter
267 content = content.replace(/^voice-triggers:\n(?:\s+-\s+"[^"]*"\n?)*/m, '');
268
269 // Get current description (after stripping voice-triggers, so it's clean)
270 const { description } = extractNameAndDescription(content);
271 if (!description) return content;
272
273 // Build new description with voice triggers appended
274 const voiceLine = `Voice triggers (speech-to-text aliases): ${triggers.map(t => `"${t}"`).join(', ')}.`;
275 const newDescription = description + '\n' + voiceLine;
276
277 // Replace old indented description with new in frontmatter
278 const oldIndented = description.split('\n').map(l => ` ${l}`).join('\n');
279 const newIndented = newDescription.split('\n').map(l => ` ${l}`).join('\n');
280 content = content.replace(oldIndented, newIndented);
281
282 return content;
283}
284
285// Export for testing
286export { extractVoiceTriggers, processVoiceTriggers };

Callers 2

processTemplateFunction · 0.85

Calls 2

extractVoiceTriggersFunction · 0.85

Tested by

no test coverage detected