A detector is a pure predicate that decides whether new speech warrants an answer. ~30 lines including tests.
- Add a function in
src/renderer/overlay/trigger-engine/detectors.ts:
/** Fires when someone sounds uncertain — for a coaching profile. */
export const hesitation: Detector = ({ newText }) =>
/\b(um+|uh+|i'?m not sure|good question)\b/i.test(newText);- Register it in the
DETECTORSmap in the same file. - Add its name to
KNOWN_DETECTORSinsrc/shared/profile-schema.tsso profiles referencing it validate. - Unit-test it in
tests/trigger-engine.test.ts.
Profiles opt in via triggers.detectors: [hesitation, …].
The DetectorContext gives you newText (speech since the last answer),
recentText (last few finals), and the profile's keywords. Detectors must be
pure — no IPC, no DOM, no state.