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
58
59
60
61
62
63
64
65
import { expect, test } from "claude-code/testing";
import {
	done,
	isPrimaryAgent,
	permissionRequest,
	questionRequest,
	recordArguments,
	stateScript,
	working,
} from "../hooks/state.ts";

test("permission request records the blocked tool", () => {
	expect(recordArguments(permissionRequest("Bash", "/repo"))).toEqual([
		"record",
		"--app",
		"claude-code",
		"--kind",
		"permission",
		"blocked",
		"/repo",
		"Bash",
	]);
});

test("question request records a blocked question without a message", () => {
	expect(recordArguments(questionRequest("/repo"))).toEqual([
		"record",
		"--app",
		"claude-code",
		"--kind",
		"question",
		"blocked",
		"/repo",
		"",
	]);
});

test("turn lifecycle records working and done states", () => {
	expect(recordArguments(working("/repo"))).toEqual([
		"record",
		"--app",
		"claude-code",
		"working",
		"/repo",
		"",
	]);
	expect(recordArguments(done("/repo"))).toEqual([
		"record",
		"--app",
		"claude-code",
		"done",
		"/repo",
		"turn finished",
	]);
});

test("only primary-agent events update the tmux pane", () => {
	expect(isPrimaryAgent(undefined)).toBe(true);
	expect(isPrimaryAgent("")).toBe(true);
	expect(isPrimaryAgent("subagent-1")).toBe(false);
});

test("the state script is installed from the dotfiles directory", () => {
	expect(stateScript("/Users/alpha.chen")).toBe("/Users/alpha.chen/.dotfiles/ai/bin/,agent-state");
});