feat: add breadcrumb detection for Cursor via hooks#16
Open
sehajc wants to merge 2 commits intoblock:mainfrom
Open
feat: add breadcrumb detection for Cursor via hooks#16sehajc wants to merge 2 commits intoblock:mainfrom
sehajc wants to merge 2 commits intoblock:mainfrom
Conversation
Cursor's afterFileEdit hook can write breadcrumbs to ~/.cursor/attribution/<repo>.jsonl with a "cwd" field. This enables aittributor to detect Cursor involvement even when the editor is closed at commit time. The breadcrumb format is compatible with the existing find_session_file_with_cwd logic — no changes needed to the detection pipeline.
Made-with: Cursor
Collaborator
|
Seems reasonable, but getting the hook installed will be the trick. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
breadcrumb_dirto~/.cursor/attributionandbreadcrumb_exttojsonlon the Cursor agent definition.find_session_file_with_cwdpipeline.Motivation
Cursor is currently detected only via process scanning. If a developer uses Cursor to generate code, closes the editor, and commits later from a terminal, aittributor misses the attribution. This is the same gap that breadcrumbs solve for Claude (
~/.claude/projects/) and Codex (~/.codex/sessions/).How it works
A Cursor
afterFileEdithook (configured in~/.cursor/hooks.json) writes a breadcrumb file to~/.cursor/attribution/<repo-slug>.jsonlcontaining{"cwd":"<repo-root>"}every time the AI edits a file. The format is intentionally compatible with aittributor's existingextract_cwd_from_jsonparser — no changes to the detection pipeline are needed.At commit time, aittributor's tier 4 breadcrumb check walks
~/.cursor/attribution/, finds recent.jsonlfiles (mtime < 2h), and matches thecwdfield against the current repo. If matched,Co-authored-by: Cursor <cursoragent@cursor.com>is appended.Cursor hook setup (user-level,
~/.cursor/hooks.json){ "version": 1, "hooks": { "afterFileEdit": [ { "command": "./hooks/write-attribution-breadcrumb.sh" } ] } }Breadcrumb writer (
~/.cursor/hooks/write-attribution-breadcrumb.sh)Distribution
The hook files can be distributed to engineers via:
hooks.jsonand the script into~/.cursor/as part of your org's shared dotfiles)/Library/Application Support/Cursor/hooks.jsonon macOS, deployed via MDM)~/.cursor/)See the Cursor hooks docs for details on user-level vs enterprise-level vs project-level hook configuration.
Test plan
cargo test— all 21 tests pass including newtest_cursor_breadcrumb_formataittributor --debugconfirmed Cursor detected via breadcrumb path