-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathsession-manager.test.ts
More file actions
57 lines (46 loc) · 2.19 KB
/
Copy pathsession-manager.test.ts
File metadata and controls
57 lines (46 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { describe, expect, test } from "bun:test";
import { normalizeRootSlashCommand } from "./session-manager.js";
describe("normalizeRootSlashCommand", () => {
test("bare /compact -> /compact", () => {
expect(normalizeRootSlashCommand("/compact")).toBe("/compact");
});
test("/compact with args -> /compact (args dropped)", () => {
expect(normalizeRootSlashCommand("/compact focus on auth")).toBe(
"/compact",
);
});
test("bare /context -> /context all", () => {
expect(normalizeRootSlashCommand("/context")).toBe("/context all");
});
test("/context with args -> /context all", () => {
expect(normalizeRootSlashCommand("/context show usage")).toBe(
"/context all",
);
});
test("wrapped /compact (helmor preamble + User request marker) -> /compact", () => {
const wrapped = `<helmor_context>\nYou are running inside Helmor...\n</helmor_context>\n\nUser request:\n/compact`;
expect(normalizeRootSlashCommand(wrapped)).toBe("/compact");
});
test("wrapped /context -> /context all", () => {
const wrapped = `<helmor_context>\nframing\n</helmor_context>\n\nUser request:\n/context`;
expect(normalizeRootSlashCommand(wrapped)).toBe("/context all");
});
test("prompt with linked-dirs block AND helmor preamble -> command still extracted", () => {
const wrapped = `<helmor_context>\nframing\n</helmor_context>\n[Linked directories — you have read/write access:\n- /other]\n\nUser request:\n/compact`;
expect(normalizeRootSlashCommand(wrapped)).toBe("/compact");
});
test("/goal is not a recognized root command -> null", () => {
expect(normalizeRootSlashCommand("/goal fix all bugs")).toBe(null);
});
test("normal prompt -> null", () => {
expect(normalizeRootSlashCommand("fix the bug in auth.ts")).toBe(null);
});
test("wrapped normal prompt -> null", () => {
const wrapped = `<helmor_context>\nframing\n</helmor_context>\n\nUser request:\nfix the bug in auth.ts`;
expect(normalizeRootSlashCommand(wrapped)).toBe(null);
});
test("command-like text not at the end (mid-prompt) -> null", () => {
const wrapped = `<helmor_context>\nframing\n</helmor_context>\n\nUser request:\nPlease run /compact for me`;
expect(normalizeRootSlashCommand(wrapped)).toBe(null);
});
});