compass-agent 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { toSqliteDatetime } from "../src/lib/log.ts";
3
+ import { branchNameFromThread } from "../src/lib/worktree.ts";
4
+ import { toolTitle } from "../src/handlers/stream.ts";
5
+
6
+ describe("toSqliteDatetime", () => {
7
+ test("formats Date object to SQLite datetime", () => {
8
+ const result = toSqliteDatetime(new Date("2025-06-15T14:30:45.123Z"));
9
+ expect(result).toBe("2025-06-15 14:30:45");
10
+ });
11
+
12
+ test("formats ISO string to SQLite datetime", () => {
13
+ const result = toSqliteDatetime("2025-01-01T00:00:00.000Z");
14
+ expect(result).toBe("2025-01-01 00:00:00");
15
+ });
16
+
17
+ test("strips milliseconds and timezone", () => {
18
+ const result = toSqliteDatetime(new Date("2025-12-31T23:59:59.999Z"));
19
+ expect(result).not.toContain("T");
20
+ expect(result).not.toContain("Z");
21
+ expect(result).not.toContain(".");
22
+ });
23
+ });
24
+
25
+ describe("branchNameFromThread", () => {
26
+ test("replaces dot with dash and adds slack/ prefix", () => {
27
+ expect(branchNameFromThread("1234567890.123456")).toBe("slack/1234567890-123456");
28
+ });
29
+
30
+ test("handles thread_ts without dot", () => {
31
+ expect(branchNameFromThread("1234567890")).toBe("slack/1234567890");
32
+ });
33
+ });
34
+
35
+ describe("toolTitle", () => {
36
+ test("Read shows file path", () => {
37
+ expect(toolTitle("Read", { file_path: "/src/app.ts" })).toBe("Read /src/app.ts");
38
+ });
39
+
40
+ test("Write shows file path", () => {
41
+ expect(toolTitle("Write", { file_path: "/src/db.ts" })).toBe("Write /src/db.ts");
42
+ });
43
+
44
+ test("Edit shows file path", () => {
45
+ expect(toolTitle("Edit", { file_path: "/src/types.ts" })).toBe("Edit /src/types.ts");
46
+ });
47
+
48
+ test("Bash truncates long commands", () => {
49
+ const longCmd = "a".repeat(100);
50
+ const title = toolTitle("Bash", { command: longCmd });
51
+ expect(title.length).toBeLessThanOrEqual(65);
52
+ expect(title).toContain("...");
53
+ });
54
+
55
+ test("Bash shows short commands fully", () => {
56
+ expect(toolTitle("Bash", { command: "ls -la" })).toBe("Run: ls -la");
57
+ });
58
+
59
+ test("Glob shows pattern", () => {
60
+ expect(toolTitle("Glob", { pattern: "**/*.ts" })).toBe("Search: **/*.ts");
61
+ });
62
+
63
+ test("Grep shows pattern", () => {
64
+ expect(toolTitle("Grep", { pattern: "TODO" })).toBe("Search: TODO");
65
+ });
66
+
67
+ test("unknown tool returns tool name", () => {
68
+ expect(toolTitle("CustomTool", {})).toBe("CustomTool");
69
+ });
70
+
71
+ test("handles missing input gracefully", () => {
72
+ expect(toolTitle("Read", {})).toBe("Read file");
73
+ expect(toolTitle("Bash", {})).toBe("Run: ");
74
+ });
75
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "allowImportingTsExtensions": true,
11
+ "types": ["bun-types"]
12
+ },
13
+ "include": ["src/**/*.ts"]
14
+ }