MCPcopy Index your code
hub / github.com/garrytan/gstack / extractVoiceTriggers

Function extractVoiceTriggers

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

* Extract voice-triggers YAML list from frontmatter. * Returns an array of trigger strings, or [] if no voice-triggers field.

(content: string)

Source from the content-addressed store, hash-verified

235 * Returns an array of trigger strings, or [] if no voice-triggers field.
236 */
237function extractVoiceTriggers(content: string): string[] {
238 const fmStart = content.indexOf('---\n');
239 if (fmStart !== 0) return [];
240 const fmEnd = content.indexOf('\n---', fmStart + 4);
241 if (fmEnd === -1) return [];
242 const frontmatter = content.slice(fmStart + 4, fmEnd);
243
244 const triggers: string[] = [];
245 let inVoice = false;
246 for (const line of frontmatter.split('\n')) {
247 if (/^voice-triggers:/.test(line)) { inVoice = true; continue; }
248 if (inVoice) {
249 const m = line.match(/^\s+-\s+"(.+)"$/);
250 if (m) triggers.push(m[1]);
251 else if (!/^\s/.test(line)) break;
252 }
253 }
254 return triggers;
255}
256
257/**
258 * Preprocess voice triggers: fold voice-triggers YAML field into description,

Callers 2

processVoiceTriggersFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected