From 32b252cabfe01a476c175bd407c2a136cb9b7cd0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 07:42:01 +0100 Subject: [PATCH] test: move inline directive stripping coverage --- ...nk-low-reasoning-capable-models-no.test.ts | 48 ------------------- src/auto-reply/reply.directive.parse.test.ts | 15 ++++++ 2 files changed, 15 insertions(+), 48 deletions(-) diff --git a/src/auto-reply/reply.directive.directive-behavior.defaults-think-low-reasoning-capable-models-no.test.ts b/src/auto-reply/reply.directive.directive-behavior.defaults-think-low-reasoning-capable-models-no.test.ts index 88dfebf4886..116337b8cd0 100644 --- a/src/auto-reply/reply.directive.directive-behavior.defaults-think-low-reasoning-capable-models-no.test.ts +++ b/src/auto-reply/reply.directive.directive-behavior.defaults-think-low-reasoning-capable-models-no.test.ts @@ -9,7 +9,6 @@ import { makeWhatsAppDirectiveConfig, mockEmbeddedTextResult, replyText, - replyTexts, sessionStorePath, withTempHome, } from "./reply.directive.directive-behavior.e2e-harness.js"; @@ -22,16 +21,6 @@ import { handleDirectiveOnly } from "./reply/directive-handling.impl.js"; import type { HandleDirectiveOnlyParams } from "./reply/directive-handling.params.js"; import { parseInlineDirectives } from "./reply/directive-handling.parse.js"; -function makeDefaultModelConfig(home: string) { - return makeWhatsAppDirectiveConfig(home, { - model: { primary: "anthropic/claude-opus-4-6" }, - models: { - "anthropic/claude-opus-4-6": {}, - "openai/gpt-4.1-mini": {}, - }, - }); -} - async function runReplyToCurrentCase(home: string, text: string) { runEmbeddedPiAgentMock.mockResolvedValue(makeEmbeddedTextResult(text)); @@ -213,43 +202,6 @@ describe("directive behavior", () => { expect(result.sessionEntry.providerOverride).toBe("openai"); expect(runEmbeddedPiAgentMock).not.toHaveBeenCalled(); }); - it("ignores inline /model and /think directives while still running agent content", async () => { - await withTempHome(async (home) => { - mockEmbeddedTextResult("done"); - - const inlineModelRes = await getReplyFromConfig( - { - Body: "please sync /model openai/gpt-4.1-mini now", - From: "+1004", - To: "+2000", - }, - {}, - makeDefaultModelConfig(home), - ); - - const texts = replyTexts(inlineModelRes); - expect(texts).toContain("done"); - expect(runEmbeddedPiAgentMock).toHaveBeenCalledOnce(); - const call = runEmbeddedPiAgentMock.mock.calls[0]?.[0]; - expect(call?.provider).toBe("anthropic"); - expect(call?.model).toBe("claude-opus-4-6"); - runEmbeddedPiAgentMock.mockClear(); - - mockEmbeddedTextResult("done"); - const inlineThinkRes = await getReplyFromConfig( - { - Body: "please sync /think:high now", - From: "+1004", - To: "+2000", - }, - {}, - makeWhatsAppDirectiveConfig(home, { model: { primary: "anthropic/claude-opus-4-6" } }), - ); - - expect(replyTexts(inlineThinkRes)).toContain("done"); - expect(runEmbeddedPiAgentMock).toHaveBeenCalledOnce(); - }); - }); it("persists /reasoning off on discord even when model defaults reasoning on", async () => { await withTempHome(async (home) => { const storePath = sessionStorePath(home); diff --git a/src/auto-reply/reply.directive.parse.test.ts b/src/auto-reply/reply.directive.parse.test.ts index be51089200e..dc9fe0b1a2d 100644 --- a/src/auto-reply/reply.directive.parse.test.ts +++ b/src/auto-reply/reply.directive.parse.test.ts @@ -8,6 +8,7 @@ import { extractThinkDirective, extractVerboseDirective, } from "./reply.js"; +import { parseInlineDirectives } from "./reply/directive-handling.parse.js"; import { extractFastDirective, extractStatusDirective } from "./reply/directives.js"; describe("directive parsing", () => { @@ -164,6 +165,20 @@ describe("directive parsing", () => { expect(res.cleaned).toBe("please now"); }); + it("strips inline /model and /think directives while keeping user text", () => { + expect(parseInlineDirectives("please sync /model openai/gpt-4.1-mini now")).toMatchObject({ + cleaned: "please sync now", + hasModelDirective: true, + rawModelDirective: "openai/gpt-4.1-mini", + }); + + expect(parseInlineDirectives("please sync /think:high now")).toMatchObject({ + cleaned: "please sync now", + hasThinkDirective: true, + thinkLevel: "high", + }); + }); + it("preserves spacing when stripping think directives before paths", () => { const res = extractThinkDirective("thats not /think high/tmp/hello"); expect(res.hasDirective).toBe(true);