Telegram: fix /think command to show current level when no arg

This commit is contained in:
Lutro
2026-01-07 12:21:20 +01:00
committed by Peter Steinberger
parent 0d34f330b8
commit 36b443f4f3
4 changed files with 78 additions and 3 deletions
+64
View File
@@ -124,6 +124,25 @@ describe("directive parsing", () => {
expect(res.thinkLevel).toBe("high");
});
it("does not match /think followed by extra letters", () => {
// e.g. someone typing "/think" + extra letter "hink"
const res = extractThinkDirective("/thinkstuff");
expect(res.hasDirective).toBe(false);
});
it("matches /think with no argument", () => {
const res = extractThinkDirective("/think");
expect(res.hasDirective).toBe(true);
expect(res.thinkLevel).toBeUndefined();
expect(res.rawLevel).toBeUndefined();
});
it("matches /t with no argument", () => {
const res = extractThinkDirective("/t");
expect(res.hasDirective).toBe(true);
expect(res.thinkLevel).toBeUndefined();
});
it("matches queue directive", () => {
const res = extractQueueDirective("please /queue interrupt now");
expect(res.hasDirective).toBe(true);
@@ -355,6 +374,51 @@ describe("directive parsing", () => {
});
});
it("shows current think level when /think has no argument", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockReset();
const res = await getReplyFromConfig(
{ Body: "/think", From: "+1222", To: "+1222" },
{},
{
agent: {
model: "anthropic/claude-opus-4-5",
workspace: path.join(home, "clawd"),
thinkingDefault: "high",
},
session: { store: path.join(home, "sessions.json") },
},
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Current thinking level: high");
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});
it("shows off when /think has no argument and no default set", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockReset();
const res = await getReplyFromConfig(
{ Body: "/think", From: "+1222", To: "+1222" },
{},
{
agent: {
model: "anthropic/claude-opus-4-5",
workspace: path.join(home, "clawd"),
},
session: { store: path.join(home, "sessions.json") },
},
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Current thinking level: off");
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});
it("rejects invalid elevated level", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockReset();