Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e29a51e

Browse files
authored
feat: add native Cursor support via event hooks (#89)
* feat: add native Cursor support with event hooks - Introduced native Cursor hooks: preToolUse, postToolUse, and sessionStart. - Added configuration files for Cursor in and . - Updated documentation to include Cursor platform support and hook details. - Implemented routing and formatting for Cursor-specific events. - Updated session management to add Cursor-specific session handling. * fix: update test assertions for CursorAdapter plugin registration, make paths platform-agnostic
1 parent acfed21 commit e29a51e

27 files changed

Lines changed: 1783 additions & 60 deletions

README.md

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,69 @@ Full hook config including PreCompact: [`configs/vscode-copilot/hooks.json`](con
170170

171171
</details>
172172

173+
<details>
174+
<summary><strong>Cursor</strong> <sup>(Beta)</sup></summary>
175+
176+
**Step 1 — Install globally:**
177+
178+
```bash
179+
npm install -g context-mode
180+
```
181+
182+
**Step 2 — Register the MCP server.** Create `.cursor/mcp.json` in your project root or `~/.cursor/mcp.json` for a global install:
183+
184+
```json
185+
{
186+
"mcpServers": {
187+
"context-mode": {
188+
"command": "context-mode"
189+
}
190+
}
191+
}
192+
```
193+
194+
**Step 3 — Add native Cursor hooks.** Cursor v1 support uses native `.cursor/hooks.json` or `~/.cursor/hooks.json` only. Create either path with:
195+
196+
```json
197+
{
198+
"version": 1,
199+
"hooks": {
200+
"preToolUse": [
201+
{
202+
"type": "command",
203+
"command": "context-mode hook cursor pretooluse",
204+
"matcher": "Shell|Read|Grep|WebFetch|Task|MCP:ctx_execute|MCP:ctx_execute_file|MCP:ctx_batch_execute"
205+
}
206+
],
207+
"postToolUse": [
208+
{
209+
"type": "command",
210+
"command": "context-mode hook cursor posttooluse"
211+
}
212+
],
213+
"sessionStart": [
214+
{
215+
"type": "command",
216+
"command": "context-mode hook cursor sessionstart"
217+
}
218+
]
219+
}
220+
}
221+
```
222+
223+
Note: the `preToolUse` hook matcher is optional. If you don't provide it, the hook will fire on all tools.
224+
225+
**Step 4 — Restart Cursor or open a new agent session.**
226+
227+
> **Native Cursor scope:** v1 ships `preToolUse`, `postToolUse`, and `sessionStart`. `preCompact` is intentionally not enabled until real Cursor fixtures confirm compatible compaction semantics.
228+
>
229+
> **Config precedence:** project `.cursor/hooks.json` overrides `~/.cursor/hooks.json`. Cursor may also load enterprise config at `/Library/Application Support/Cursor/hooks.json`; context-mode treats that layer as read-only informational.
230+
231+
Full native hook config: [`configs/cursor/hooks.json`](configs/cursor/hooks.json)
232+
Example MCP registration: [`configs/cursor/mcp.json`](configs/cursor/mcp.json)
233+
234+
</details>
235+
173236
<details>
174237
<summary><strong>OpenCode</strong> <sup>(Beta)</sup></summary>
175238

@@ -296,15 +359,15 @@ Context Mode captures every meaningful event during your session and persists th
296359

297360
Session continuity requires 4 hooks working together:
298361

299-
| Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | OpenCode | Codex CLI |
300-
|---|---|:---:|:---:|:---:|:---:|:---:|
301-
| **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Plugin | -- |
302-
| **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- |
303-
| **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | Plugin | -- |
304-
| **SessionStart** | Restores state after compaction | Yes | Yes | Yes | -- | -- |
305-
| | **Session completeness** | **Full** | **High** | **High** | **High** | **--** |
362+
| Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | Codex CLI |
363+
|---|---|:---:|:---:|:---:|:---:|:---:|:---:|
364+
| **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Yes | Plugin | -- |
365+
| **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- | -- |
366+
| **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | -- | Plugin | -- |
367+
| **SessionStart** | Restores state after compaction or resume | Yes | Yes | Yes | Yes | -- | -- |
368+
| | **Session completeness** | **Full** | **High** | **High** | **Medium** | **High** | **--** |
306369

307-
> **Note:** Full session continuity (capture + snapshot + restore) works on **Claude Code**, **Gemini CLI**, **VS Code Copilot**, and **OpenCode**. OpenCode uses the `experimental.session.compacting` plugin hook for compaction recovery SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume is not supported. Codex CLI has no hook support, so session tracking is not available.
370+
> **Note:** Full session continuity (capture + snapshot + restore) works on **Claude Code**, **Gemini CLI**, and **VS Code Copilot**, and **OpenCode**. **Cursor** v1 restores from persisted session events via `sessionStart`, but intentionally does not advertise `preCompact` until real native fixtures confirm compaction compatibility. **OpenCode** uses the `experimental.session.compacting` plugin hook for compaction recovery, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume is not supported. Codex CLI has no hook support, so session tracking is not available.
308371
309372
<details>
310373
<summary><strong>What gets captured</strong></summary>
@@ -379,6 +442,8 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
379442

380443
**VS Code Copilot** — High coverage. Same as Gemini CLI — PostToolUse, PreCompact, and SessionStart all fire. User decisions aren't captured but all tool-level events are.
381444

445+
**Cursor** — Medium coverage. Native `preToolUse`, `postToolUse`, and `sessionStart` hooks are supported. Session restore works from the persisted event database, but `preCompact` is intentionally disabled in v1 until real Cursor fixtures prove compatible semantics.
446+
382447
**OpenCode** — Partial. The TypeScript plugin captures PostToolUse events via `tool.execute.after`, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)). Events are stored but not automatically restored after compaction. The `AGENTS.md` routing instructions file compensates by re-teaching tool preferences at each session start.
383448

384449
**Codex CLI** — No session support. No hooks means no event capture. Each compaction or new session starts fresh. The `AGENTS.md` routing instructions file is the only continuity mechanism.
@@ -387,17 +452,18 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
387452

388453
## Platform Compatibility
389454

390-
| Feature | Claude Code | Gemini CLI <sup>(Beta)</sup> | VS Code Copilot <sup>(Beta)</sup> | OpenCode <sup>(Beta)</sup> | Codex CLI <sup>(Beta)</sup> |
391-
|---|:---:|:---:|:---:|:---:|:---:|
392-
| MCP Server | Yes | Yes | Yes | Yes | Yes |
393-
| PreToolUse Hook | Yes | Yes | Yes | Plugin | -- |
394-
| PostToolUse Hook | Yes | Yes | Yes | Plugin | -- |
395-
| SessionStart Hook | Yes | Yes | Yes | -- | -- |
396-
| Can Modify Args | Yes | Yes | Yes | Plugin | -- |
397-
| Can Block Tools | Yes | Yes | Yes | Plugin | -- |
398-
| Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes |
399-
| Slash Commands | Yes | -- | -- | -- | -- |
400-
| Plugin Marketplace | Yes | -- | -- | -- | -- |
455+
| Feature | Claude Code | Gemini CLI <sup>(Beta)</sup> | VS Code Copilot <sup>(Beta)</sup> | Cursor <sup>(Beta)</sup> | OpenCode <sup>(Beta)</sup> | Codex CLI <sup>(Beta)</sup> |
456+
|---|:---:|:---:|:---:|:---:|:---:|:---:|
457+
| MCP Server | Yes | Yes | Yes | Yes | Yes | Yes |
458+
| PreToolUse Hook | Yes | Yes | Yes | Yes | Plugin | -- |
459+
| PostToolUse Hook | Yes | Yes | Yes | Yes | Plugin | -- |
460+
| SessionStart Hook | Yes | Yes | Yes | Yes | -- | -- |
461+
| PreCompact Hook | Yes | Yes | Yes | -- | Plugin | -- |
462+
| Can Modify Args | Yes | Yes | Yes | Yes | Plugin | -- |
463+
| Can Block Tools | Yes | Yes | Yes | Yes | Plugin | -- |
464+
| Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes | Yes |
465+
| Slash Commands | Yes | -- | -- | -- | -- | -- |
466+
| Plugin Marketplace | Yes | -- | -- | -- | -- | -- |
401467

402468
> **OpenCode** uses a TypeScript plugin paradigm — hooks run as in-process functions via `tool.execute.before`, `tool.execute.after`, and `experimental.session.compacting`, providing the same routing enforcement and session continuity as shell-based hooks. SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), but compaction recovery works via the plugin's compacting hook.
403469
>
@@ -412,6 +478,7 @@ Hooks intercept tool calls programmatically — they can block dangerous command
412478
| Claude Code | Yes (auto) | [`CLAUDE.md`](configs/claude-code/CLAUDE.md) | **~98% saved** | ~60% saved |
413479
| Gemini CLI | Yes | [`GEMINI.md`](configs/gemini-cli/GEMINI.md) | **~98% saved** | ~60% saved |
414480
| VS Code Copilot | Yes | [`copilot-instructions.md`](configs/vscode-copilot/copilot-instructions.md) | **~98% saved** | ~60% saved |
481+
| Cursor | Yes | -- | **~98% saved** | Manual tool choice |
415482
| OpenCode | Plugin | [`AGENTS.md`](configs/opencode/AGENTS.md) | **~98% saved** | ~60% saved |
416483
| Codex CLI | -- | [`AGENTS.md`](configs/codex/AGENTS.md) | -- | ~60% saved |
417484

configs/cursor/hooks.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": 1,
3+
"hooks": {
4+
"preToolUse": [
5+
{
6+
"type": "command",
7+
"command": "context-mode hook cursor pretooluse",
8+
"matcher": "Shell|Read|Grep|WebFetch|mcp_web_fetch|mcp_fetch_tool|Task|MCP:ctx_execute|MCP:ctx_execute_file|MCP:ctx_batch_execute",
9+
"loop_limit": null,
10+
"failClosed": false
11+
}
12+
],
13+
"postToolUse": [
14+
{
15+
"type": "command",
16+
"command": "context-mode hook cursor posttooluse",
17+
"loop_limit": null,
18+
"failClosed": false
19+
}
20+
],
21+
"sessionStart": [
22+
{
23+
"type": "command",
24+
"command": "context-mode hook cursor sessionstart",
25+
"loop_limit": null,
26+
"failClosed": false
27+
}
28+
]
29+
}
30+
}

configs/cursor/mcp.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mcpServers": {
3+
"context-mode": {
4+
"command": "context-mode"
5+
}
6+
}
7+
}

docs/platform-support.md

Lines changed: 87 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ This document provides a comprehensive comparison of all platforms supported by
44

55
## Overview
66

7-
context-mode supports five platforms across three hook paradigms:
7+
context-mode supports six platforms across three hook paradigms:
88

99
| Paradigm | Platforms |
1010
|----------|-----------|
11-
| **JSON stdin/stdout** | Claude Code, Gemini CLI, VS Code Copilot |
11+
| **JSON stdin/stdout** | Claude Code, Gemini CLI, VS Code Copilot, Cursor |
1212
| **TS Plugin** | OpenCode |
1313
| **MCP-only** | Codex CLI |
1414

@@ -32,26 +32,26 @@ This puts the `context-mode` binary in PATH, which is required for:
3232

3333
## Main Comparison Table
3434

35-
| Feature | Claude Code | Gemini CLI | OpenCode | Codex CLI | VS Code Copilot |
36-
|---------|-------------|------------|----------|-----------|-----------------|
37-
| **Paradigm** | json-stdio | json-stdio | ts-plugin | mcp-only | json-stdio |
38-
| **PreToolUse equivalent** | `PreToolUse` | `BeforeTool` | `tool.execute.before` | -- | `PreToolUse` |
39-
| **PostToolUse equivalent** | `PostToolUse` | `AfterTool` | `tool.execute.after` | -- | `PostToolUse` |
40-
| **PreCompact equivalent** | `PreCompact` | `PreCompress` | `experimental.session.compacting` | -- | `PreCompact` |
41-
| **SessionStart** | `SessionStart` | `SessionStart` | -- | -- | `SessionStart` |
42-
| **Can modify args** | Yes | Yes | Yes | -- | Yes |
43-
| **Can modify output** | Yes | Yes | Yes (caveat) | -- | Yes |
44-
| **Can inject session context** | Yes | Yes | -- | -- | Yes |
45-
| **Can block tools** | Yes | Yes | Yes (throw) | -- | Yes |
46-
| **Config location** | `~/.claude/settings.json` | `~/.gemini/settings.json` | `opencode.json` | `~/.codex/config.toml` | `.github/hooks/*.json` |
47-
| **Session ID field** | `session_id` | `session_id` | `sessionID` (camelCase) | N/A | `sessionId` (camelCase) |
48-
| **Project dir env** | `CLAUDE_PROJECT_DIR` | `GEMINI_PROJECT_DIR` | `ctx.directory` (plugin init) | N/A | `CLAUDE_PROJECT_DIR` |
49-
| **MCP tool naming** | `mcp__server__tool` | `mcp__server__tool` | `mcp__server__tool` | `mcp__server__tool` | `f1e_` prefix |
50-
| **Hook command format** | `context-mode hook claude-code <event>` | `context-mode hook gemini-cli <event>` | TS plugin (no command) | N/A | `context-mode hook vscode-copilot <event>` |
51-
| **Hook registration** | settings.json hooks object | settings.json hooks object | opencode.json plugin array | N/A | .github/hooks/*.json |
52-
| **MCP server command** | `context-mode` (or plugin auto) | `context-mode` | `context-mode` | `context-mode` | `context-mode` |
53-
| **Plugin distribution** | Claude plugin registry | npm global | npm global | npm global | npm global |
54-
| **Session dir** | `~/.claude/context-mode/sessions/` | `~/.gemini/context-mode/sessions/` | `~/.config/opencode/context-mode/sessions/` | `~/.codex/context-mode/sessions/` | `.github/context-mode/sessions/` or `~/.vscode/context-mode/sessions/` |
35+
| Feature | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | Codex CLI |
36+
|---------|-------------|------------|-----------------|--------|----------|-----------|
37+
| **Paradigm** | json-stdio | json-stdio | json-stdio | json-stdio | ts-plugin | mcp-only |
38+
| **PreToolUse equivalent** | `PreToolUse` | `BeforeTool` | `PreToolUse` | `preToolUse` | `tool.execute.before` | -- |
39+
| **PostToolUse equivalent** | `PostToolUse` | `AfterTool` | `PostToolUse` | `postToolUse` | `tool.execute.after` | -- |
40+
| **PreCompact equivalent** | `PreCompact` | `PreCompress` | `PreCompact` | -- | `experimental.session.compacting` | -- |
41+
| **SessionStart** | `SessionStart` | `SessionStart` | `SessionStart` | `sessionStart` | -- | -- |
42+
| **Can modify args** | Yes | Yes | Yes | Yes | Yes | -- |
43+
| **Can modify output** | Yes | Yes | Yes | No | Yes (caveat) | -- |
44+
| **Can inject session context** | Yes | Yes | Yes | Yes | -- | -- |
45+
| **Can block tools** | Yes | Yes | Yes | Yes | Yes (throw) | -- |
46+
| **Config location** | `~/.claude/settings.json` | `~/.gemini/settings.json` | `.github/hooks/*.json` | `.cursor/hooks.json` or `~/.cursor/hooks.json` | `opencode.json` | `~/.codex/config.toml` |
47+
| **Session ID field** | `session_id` | `session_id` | `sessionId` (camelCase) | `conversation_id` | `sessionID` (camelCase) | N/A |
48+
| **Project dir env** | `CLAUDE_PROJECT_DIR` | `GEMINI_PROJECT_DIR` | `CLAUDE_PROJECT_DIR` | `CURSOR_CWD` | `ctx.directory` (plugin init) | N/A |
49+
| **MCP tool naming** | `mcp__server__tool` | `mcp__server__tool` | `f1e_` prefix | `MCP:<tool>` in hook payloads | `mcp__server__tool` | `mcp__server__tool` |
50+
| **Hook command format** | `context-mode hook claude-code <event>` | `context-mode hook gemini-cli <event>` | `context-mode hook vscode-copilot <event>` | `context-mode hook cursor <event>` | TS plugin (no command) | N/A |
51+
| **Hook registration** | settings.json hooks object | settings.json hooks object | `.github/hooks/*.json` | `hooks.json` native hook arrays | opencode.json plugin array | N/A |
52+
| **MCP server command** | `context-mode` (or plugin auto) | `context-mode` | `context-mode` | `context-mode` | `context-mode` | `context-mode` |
53+
| **Plugin distribution** | Claude plugin registry | npm global | npm global | npm global | npm global | npm global |
54+
| **Session dir** | `~/.claude/context-mode/sessions/` | `~/.gemini/context-mode/sessions/` | `.github/context-mode/sessions/` or `~/.vscode/context-mode/sessions/` | `~/.cursor/context-mode/sessions/` | `~/.config/opencode/context-mode/sessions/` | `~/.codex/context-mode/sessions/` |
5555

5656
### Legend
5757

@@ -266,19 +266,66 @@ context-mode hook vscode-copilot sessionstart
266266

267267
---
268268

269+
### Cursor
270+
271+
**Status:** Supported (native hooks, v1 scope)
272+
273+
**Hook Paradigm:** JSON stdin/stdout
274+
275+
Cursor uses native lower-camel hook names and flat hook entries in `.cursor/hooks.json` or `~/.cursor/hooks.json`. context-mode treats Cursor as a first-class adapter and does not rely on Claude-compat wrappers for official support.
276+
277+
**Hook Names:**
278+
- `preToolUse` -- fires before a tool is executed
279+
- `postToolUse` -- fires after a tool completes
280+
- `sessionStart` -- fires on startup, resume, and compact
281+
282+
**Blocking:** `{ "permission": "deny", "user_message": "..." }`
283+
284+
**Arg Modification:** `{ "updated_input": { ... } }`
285+
286+
**Output Modification:** not supported in v1
287+
288+
**Session Context Injection:** `{ "additional_context": "..." }`
289+
290+
**Session ID Extraction Priority:**
291+
1. `conversation_id`
292+
2. `CURSOR_SESSION_ID` environment variable
293+
3. `CURSOR_TRACE_ID` environment variable
294+
4. Parent process ID fallback
295+
296+
**Configuration:**
297+
- Project: `.cursor/hooks.json`
298+
- User: `~/.cursor/hooks.json`
299+
- Enterprise: `/Library/Application Support/Cursor/hooks.json` (read-only informational layer)
300+
- MCP config: `.cursor/mcp.json` or `~/.cursor/mcp.json`
301+
302+
**Hook Commands:**
303+
```
304+
context-mode hook cursor pretooluse
305+
context-mode hook cursor posttooluse
306+
context-mode hook cursor sessionstart
307+
```
308+
309+
**Known Issues / Caveats:**
310+
- `preCompact` is intentionally not shipped in v1
311+
- Hook payloads name MCP tools as `MCP:<tool>` and need adapter normalization
312+
- Claude-compatible Cursor behavior exists, but native Cursor config is the supported path
313+
314+
---
315+
269316
## Capability Matrix (Quick Reference)
270317

271-
| Capability | Claude Code | Gemini CLI | OpenCode | Codex CLI | VS Code Copilot |
272-
|-----------|:-----------:|:----------:|:--------:|:---------:|:---------------:|
273-
| PreToolUse | Yes | Yes | Yes | -- | Yes |
274-
| PostToolUse | Yes | Yes | Yes | -- | Yes |
275-
| PreCompact | Yes | Yes | Yes* | -- | Yes |
276-
| SessionStart | Yes | Yes | -- | -- | Yes |
277-
| Modify Args | Yes | Yes | Yes | -- | Yes |
278-
| Modify Output | Yes | Yes | Yes** | -- | Yes |
279-
| Inject Context | Yes | Yes | -- | -- | Yes |
280-
| Block Tools | Yes | Yes | Yes | -- | Yes |
281-
| MCP Support | Yes | Yes | Yes | Yes | Yes |
318+
| Capability | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | Codex CLI |
319+
|-----------|:-----------:|:----------:|:---------------:|:------:|:--------:|:---------:|
320+
| PreToolUse | Yes | Yes | Yes | Yes | Yes | -- |
321+
| PostToolUse | Yes | Yes | Yes | Yes | Yes | -- |
322+
| PreCompact | Yes | Yes | Yes | -- | Yes* | -- |
323+
| SessionStart | Yes | Yes | Yes | Yes | -- | -- |
324+
| Modify Args | Yes | Yes | Yes | Yes | Yes | -- |
325+
| Modify Output | Yes | Yes | Yes | No | Yes** | -- |
326+
| Inject Context | Yes | Yes | Yes | Yes | -- | -- |
327+
| Block Tools | Yes | Yes | Yes | Yes | Yes | -- |
328+
| MCP Support | Yes | Yes | Yes | Yes | Yes | Yes |
282329

283330
\* OpenCode `experimental.session.compacting` is experimental
284331
\*\* OpenCode has a TUI rendering bug for bash tool output (#13575)
@@ -293,29 +340,32 @@ context-mode hook vscode-copilot sessionstart
293340
|----------|----------------|
294341
| Claude Code | `{ "permissionDecision": "deny", "reason": "..." }` |
295342
| Gemini CLI | `{ "decision": "deny", "reason": "..." }` |
343+
| VS Code Copilot | `{ "permissionDecision": "deny", "reason": "..." }` |
344+
| Cursor | `{ "permission": "deny", "user_message": "..." }` |
296345
| OpenCode | `throw new Error("...")` |
297346
| Codex CLI | N/A |
298-
| VS Code Copilot | `{ "permissionDecision": "deny", "reason": "..." }` |
299347

300348
### Modifying Tool Input
301349

302350
| Platform | Response Format |
303351
|----------|----------------|
304352
| Claude Code | `{ "updatedInput": { ... } }` |
305353
| Gemini CLI | `{ "hookSpecificOutput": { "tool_input": { ... } } }` |
354+
| VS Code Copilot | `{ "hookSpecificOutput": { "hookEventName": "PreToolUse", "updatedInput": { ... } } }` |
355+
| Cursor | `{ "updated_input": { ... } }` |
306356
| OpenCode | `{ "args": { ... } }` (mutation) |
307357
| Codex CLI | N/A |
308-
| VS Code Copilot | `{ "hookSpecificOutput": { "hookEventName": "PreToolUse", "updatedInput": { ... } } }` |
309358

310359
### Injecting Additional Context (PostToolUse)
311360

312361
| Platform | Response Format |
313362
|----------|----------------|
314363
| Claude Code | `{ "additionalContext": "..." }` |
315364
| Gemini CLI | `{ "hookSpecificOutput": { "additionalContext": "..." } }` |
365+
| VS Code Copilot | `{ "hookSpecificOutput": { "hookEventName": "PostToolUse", "additionalContext": "..." } }` |
366+
| Cursor | `{ "additional_context": "..." }` |
316367
| OpenCode | `{ "additionalContext": "..." }` |
317368
| Codex CLI | N/A |
318-
| VS Code Copilot | `{ "hookSpecificOutput": { "hookEventName": "PostToolUse", "additionalContext": "..." } }` |
319369

320370
---
321371

@@ -342,6 +392,7 @@ The dispatcher resolves the hook script relative to the installed package and dy
342392
| `claude-code` | `pretooluse`, `posttooluse`, `precompact`, `sessionstart`, `userpromptsubmit` |
343393
| `gemini-cli` | `beforetool`, `aftertool`, `precompress`, `sessionstart` |
344394
| `vscode-copilot` | `pretooluse`, `posttooluse`, `precompact`, `sessionstart` |
395+
| `cursor` | `pretooluse`, `posttooluse`, `sessionstart` |
345396

346397
OpenCode uses a TS plugin paradigm (no command dispatcher). Codex CLI has no hook support.
347398

hooks/core/formatters.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ export const formatters = {
6464
},
6565
}),
6666
},
67+
68+
"cursor": {
69+
deny: (reason) => ({
70+
permission: "deny",
71+
user_message: reason,
72+
}),
73+
ask: () => ({
74+
permission: "ask",
75+
}),
76+
modify: (updatedInput) => ({
77+
updated_input: updatedInput,
78+
}),
79+
context: (additionalContext) => ({
80+
agent_message: additionalContext,
81+
}),
82+
},
6783
};
6884

6985
/**

0 commit comments

Comments
 (0)