From 4757dc988fb5ae8a68ae88bc79d07a2e5ffba65a Mon Sep 17 00:00:00 2001 From: Alima Date: Sat, 28 Nov 2026 23:28:37 +0000 Subject: [PATCH] fix(model): recognize compose/type reply commands (#110) --- packages/model/src/intent-hints.ts | 2 +- packages/model/test/intent-hints.test.ts | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/model/src/intent-hints.ts b/packages/model/src/intent-hints.ts index 86eee25..f2a23b8 100644 --- a/packages/model/src/intent-hints.ts +++ b/packages/model/src/intent-hints.ts @@ -154,7 +154,7 @@ const PAY_PAGE = { test: (t: string) => !QUESTION.test(t) && ((PAY_PAGE_VERB.tes * answer sent, written, posted or drafted to someone is asked for: "send a reply to Ana", "post the answer to Ana". Only * with "to": "did Ana send a reply?" stays a question. */ -export const REPLY_COMMAND_WORDS = String.raw`dile a|dile que|d[ií]gale a|dec[ií]le|resp[oó]ndele|respondele|contesta(le)?|cont[eé]stale|contestale|av[ií]sale a|escr[ií]bele a|m[aá]ndale (un mensaje )?a \w+ (que|diciendo)|tell (?!me\b|us\b)\w+|text (?!me\b|us\b|messages?\b|back\b)\w+ \S+|let (?!me\b|us\b)\S+( \S+)? know|(? narrowMenu(text, firstWinSkills).map((s) => s.id); +/** The same boundary rule the port uses to decide that the user asked for a reply (#110). */ +const replyCommand = new RegExp(`(? { + test.each([ + "compose a reply to Ana Prueba saying I'm late", + "type a reply to Carlos Demo: on my way", + "send a reply to Ana Prueba saying I'm late", + "write an answer to Carlos Demo: on my way", + ])("a reply command: %s", (text) => { + expect(replyCommand.test(text)).toBe(true); + }); + + test.each([ + "did Ana Prueba type a reply?", + "Carlos Demo is composing a reply", + "compose a reply for Ana Prueba", + ])("not a reply command: %s", (text) => { + expect(replyCommand.test(text)).toBe(false); + }); +}); + describe("intent hints narrow the menu, never widen it", () => { test.each([ ["recuérdame comprar pan mañana a las 7", ["remind"]],