fix: avoid directive hits inside URLs and add tests

This commit is contained in:
Peter Steinberger
2025-12-05 22:28:36 +00:00
parent 5949ef0e2c
commit 99b174f495
2 changed files with 38 additions and 5 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import { extractVerboseDirective, extractThinkDirective } from "./reply.js";
describe("directive parsing", () => {
it("ignores verbose directive inside URL", () => {
const body = "https://x.com/verioussmith/status/1997066835133669687";
const res = extractVerboseDirective(body);
expect(res.hasDirective).toBe(false);
expect(res.cleaned).toBe(body);
});
it("ignores think directive inside URL", () => {
const body = "see https://example.com/path/thinkstuff";
const res = extractThinkDirective(body);
expect(res.hasDirective).toBe(false);
});
it("matches verbose with leading space", () => {
const res = extractVerboseDirective(" please /verbose on now");
expect(res.hasDirective).toBe(true);
expect(res.verboseLevel).toBe("on");
});
it("matches think at start of line", () => {
const res = extractThinkDirective("/think:high run slow");
expect(res.hasDirective).toBe(true);
expect(res.thinkLevel).toBe("high");
});
});