Skip to content

feat: add native Cursor hooks support#53

Open
lperdereau wants to merge 1 commit intortk-ai:mainfrom
lperdereau:feat/cursor-hooks-support
Open

feat: add native Cursor hooks support#53
lperdereau wants to merge 1 commit intortk-ai:mainfrom
lperdereau:feat/cursor-hooks-support

Conversation

@lperdereau
Copy link

Hi 👋

I wanted to try icm, but it doesn't work with Cursor in hook mode.
Here's a pull request to integrate Cursor into the hook mode installation.
I hope this helps.


  • cmd_hook_pre: accept both "Shell" (Cursor) and "Bash" (Claude Code) tool names; detect runtime via cursor_version field and output the appropriate response format (Cursor: permission/updated_input, Claude Code: hookSpecificOutput)
  • inject_cursor_hook(): new helper to inject hooks into Cursor's native ~/.cursor/hooks.json format (flat {command, matcher} entries)
  • cmd_init --mode hook: now injects 3 Cursor hooks (preToolUse, postToolUse, preCompact) alongside Claude Code and OpenCode hooks

Note: Cursor's beforeSubmitPrompt does not support additional_context injection yet, so the prompt hook (Layer 2) is not installed for Cursor.

Made-with: Cursor

- cmd_hook_pre: accept both "Shell" (Cursor) and "Bash" (Claude Code)
  tool names; detect runtime via `cursor_version` field and output
  the appropriate response format (Cursor: `permission`/`updated_input`,
  Claude Code: `hookSpecificOutput`)
- inject_cursor_hook(): new helper to inject hooks into Cursor's native
  `~/.cursor/hooks.json` format (flat `{command, matcher}` entries)
- cmd_init --mode hook: now injects 3 Cursor hooks (preToolUse,
  postToolUse, preCompact) alongside Claude Code and OpenCode hooks

Note: Cursor's `beforeSubmitPrompt` does not support `additional_context`
injection yet, so the prompt hook (Layer 2) is not installed for Cursor.

Made-with: Cursor
@pszymkowiak
Copy link
Contributor

wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds native Cursor IDE hooks support to ICM. The pre-tool-use hook now accepts both 'Shell' (Cursor) and 'Bash' (Claude Code) tool names with runtime-appropriate response formats, and a new inject_cursor_hook() helper writes hooks into Cursor's ~/.cursor/hooks.json during cmd_init --mode hook.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants