-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathmap.js
More file actions
57 lines (51 loc) · 1.27 KB
/
Copy pathmap.js
File metadata and controls
57 lines (51 loc) · 1.27 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
/** Tools that map to the typing animation (from former hooks.json matcher). */
export const TYPING_TOOLS = new Set([
"Write",
"StrReplace",
"EditNotebook",
"Delete",
"Shell",
"Task",
"CallMcpTool",
"TodoWrite",
"GenerateImage",
]);
export const READING_TOOLS = new Set([
"Read",
"Grep",
"Glob",
"WebSearch",
"WebFetch",
"AwaitShell",
]);
const EVENT_ANIM = {
sessionStart: "reading",
beforeSubmitPrompt: "reading",
beforeReadFile: "reading",
afterAgentThought: "thinking",
preCompact: "thinking",
beforeShellExecution: "typing",
subagentStart: "typing",
afterFileEdit: "typing",
};
/**
* Map a Cursor hook payload to an animation name, or null to skip.
* @param {{ hook_event_name?: string, tool_name?: string, status?: string }} event
* @returns {string | null}
*/
export function animationForEvent(event) {
const name = event?.hook_event_name;
if (!name) return null;
if (name === "preToolUse") {
const tool = event.tool_name;
if (READING_TOOLS.has(tool)) return "reading";
if (TYPING_TOOLS.has(tool)) return "typing";
return null;
}
if (name === "stop") {
if (event.status === "aborted") return "abort";
if (event.status === "error") return "error";
return "ring";
}
return EVENT_ANIM[name] ?? null;
}