* Extract voice-triggers YAML list from frontmatter. * Returns an array of trigger strings, or [] if no voice-triggers field.
(content: string)
| 235 | * Returns an array of trigger strings, or [] if no voice-triggers field. |
| 236 | */ |
| 237 | function 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, |
no test coverage detected