[PR #44] First class support for Cursor via Hooks Preset #219

Closed
opened 2026-03-02 04:12:59 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/44

State: closed
Merged: Yes


The Cursor team enabled hooks feature flag for some git-ai contributors. It's in 1.7.x https://cursor.com/nightlydownload and will launch more broadly soon.

We reported a few bugs/limitations to the team that we expect them to fix

  • Unlike claude code, cursor does not use the system shell's configuration (looks like they just run bash). This makes it difficult to reliably call user installed binaries x-platform. Hoping this is resolved, for now a mac compatible solution zsh -c 'source ~/.zprofile; source ~/.zshrc; is being used for testing
  • Shared a preference forbeforeFileEdit. It's on their roadmap and hoping it makes the cut for public release
  • Clarification - will these hooks work with cursor-agent CLI or just the IDE.

To test, add the following to ~/.cursor/hooks.json

{
  "version": 1,
  "hooks": {
    "beforeSubmitPrompt": [
      {
        "command": "zsh -c 'source ~/.zprofile; source ~/.zshrc; git-ai checkpoint cursor --hook-input \"$(cat)\"' >/dev/null 2>&1"
      }
    ],
    "afterFileEdit": [
      {
        "command": "zsh -c 'source ~/.zprofile; source ~/.zshrc; git-ai checkpoint cursor --hook-input \"$(cat)\"' >/dev/null 2>&1"
      }
    ]
  }
}

You'll notice both of these commands are the same -- for the cursor preset git-ai is responsible for deciding whether it should mark code as AI or human based on the JSON stdin. It's not safe to assume people have jq or other JSON tools on their shell so we're insourcing that concern. When the hook_event_name is beforeSubmitPrompt a human checkpoint is created, when it is afterFileEdit an AI checkpoint is created.

{
  "conversation_id": string // an identifier for the conversation as a whole
  "hook_event_name": string // the name of the hook this is being called in response to
  "workspace_roots": string[] // The roots of the folders in the workspace.  Usually just one, but multiroot can have many
}

Known issues:

  • Race condition. The last assistant message is not persisting until after the hook runs. Planning to fetch latest messages when preparing the authorship logs in post-commit. The many seconds between code being generated, reviewed, tested and committed should guarantee changes have hit the SQLlite on disk.
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/44 **State:** closed **Merged:** Yes --- The Cursor team enabled hooks feature flag for some git-ai contributors. It's in 1.7.x https://cursor.com/nightlydownload and will launch more broadly soon. We reported a few bugs/limitations to the team that we expect them to fix - [ ] Unlike claude code, cursor does not use the system shell's configuration (looks like they just run bash). This makes it difficult to reliably call user installed binaries x-platform. Hoping this is resolved, for now a mac compatible solution `zsh -c 'source ~/.zprofile; source ~/.zshrc;` is being used for testing - [x] Shared a preference for`beforeFileEdit`. _It's on their roadmap and hoping it makes the cut for public release_ - [ ] Clarification - will these hooks work with `cursor-agent `CLI or just the IDE. To test, add the following to `~/.cursor/hooks.json` ```json { "version": 1, "hooks": { "beforeSubmitPrompt": [ { "command": "zsh -c 'source ~/.zprofile; source ~/.zshrc; git-ai checkpoint cursor --hook-input \"$(cat)\"' >/dev/null 2>&1" } ], "afterFileEdit": [ { "command": "zsh -c 'source ~/.zprofile; source ~/.zshrc; git-ai checkpoint cursor --hook-input \"$(cat)\"' >/dev/null 2>&1" } ] } } ``` You'll notice both of these commands are the same -- for the cursor preset git-ai is responsible for deciding whether it should mark code as AI or human based on the JSON stdin. It's not safe to assume people have jq or other JSON tools on their shell so we're insourcing that concern. When the `hook_event_name` is `beforeSubmitPrompt` a human checkpoint is created, when it is `afterFileEdit` an AI checkpoint is created. ``` { "conversation_id": string // an identifier for the conversation as a whole "hook_event_name": string // the name of the hook this is being called in response to "workspace_roots": string[] // The roots of the folders in the workspace. Usually just one, but multiroot can have many } ``` Known issues: - [x] Race condition. The last assistant message is not persisting until after the hook runs. Planning to fetch latest messages when preparing the authorship logs in post-commit. The many seconds between code being generated, reviewed, tested and committed should guarantee changes have hit the SQLlite on disk.
kerem 2026-03-02 04:12:59 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#219
No description provided.