You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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)
> **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.
@@ -379,6 +442,8 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
379
442
380
443
**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.
381
444
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
+
382
447
**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.
383
448
384
449
**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
> **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.
403
469
>
@@ -412,6 +478,7 @@ Hooks intercept tool calls programmatically — they can block dangerous command
412
478
| Claude Code | Yes (auto) |[`CLAUDE.md`](configs/claude-code/CLAUDE.md)|**~98% saved**|~60% saved |
|**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`|
|**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/`|
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
0 commit comments