Add Cursor as a fourth supported platform - #21
Merged
Conversation
Foundation module for the Cursor integration: platform identifiers, hooks.json location, registered hook events, dedicated tool-name set used to dedupe postToolUse events, and the strip-keys set for routing and PII fields removed before payloads land in the event store. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Update README tagline, browser UI doc filter list, and the use-thirdeye setup reference so Cursor is documented alongside Claude, Codex, and Gemini. Notes Cursor's hook config lives at ~/.cursor/hooks.json. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements capture_usage_cursor which extracts model and token counts directly from the Cursor hook payload (no transcript parsing). Handles both snake_case (IDE) and camelCase (CLI) field variants, skips writes when required fields are missing, and dedups between stop/sessionEnd fallback calls via UsageStore state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements CursorPlatform with idempotent install of all 14 traced events into ~/.cursor/hooks.json, basename-based dedup so pipx upgrades don't double-register, and uninstall that preserves the file plus unrelated hooks. Wires --cursor into thirdeye add/remove. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Registers thirdeye-cursor-hook as a single CLI entrypoint that dispatches on hook_event_name / hookEventName, translating each of the 14 traced Cursor events into thirdeye events (or a usage capture for stop / sessionEnd). Always prints a permissive JSON response to sys.__stdout__ and exits 0, never gating Cursor execution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Adds Cursor support to thirdeye alongside Claude Code, Codex, and Gemini. The
integration installs a single multiplexed hook entry into
~/.cursor/hooks.jsonthat dispatches all 14 Cursor hook events (lifecycle, prompts, response,
shell/MCP/file/tab tool pairs,
postToolUse,stop) through one Pythonentrypoint, and captures token usage directly from the
stop/sessionEndpayload without transcript parsing.
Changes
src/thirdeye/platforms/cursor/constants.py— Cursor hook event names, configpaths, and payload strip-key set.
src/thirdeye/platforms/cursor/install.py— install/uninstall of themultiplexed hook entry in
~/.cursor/hooks.json.src/thirdeye/platforms/cursor/hook.py— stdin-JSON dispatcher thatnormalizes IDE/CLI payload key variants and writes typed thirdeye events.
src/thirdeye/platforms/cursor/usage.py— token usage extraction from theCursor
stop/sessionEndpayload (input_tokens,output_tokens, etc.).src/thirdeye/commands/add.py— wiresthirdeye add --cursorinto the CLI.pyproject.toml— registers thethirdeye-cursor-hookentrypoint.README.md,docs/ui.md,.../setup-and-tracing.md— mention Cursor as asupported platform.
tests/test_cursor_constants.py,test_cursor_install.py,test_cursor_hook.py,test_cursor_usage.py, additions totest_add_command.py— coverage for constants, install/uninstall, dispatcherbehavior across all events, usage extraction, and CLI wiring.
Test plan
pytestpasses the full suite, including the newtest_cursor_constants.py,test_cursor_install.py,test_cursor_hook.py,test_cursor_usage.py, and updatedtest_add_command.py.ruff check .andruff format --check .are clean.thirdeye add --cursorwrites a multiplexedthirdeye-cursor-hookentryinto
~/.cursor/hooks.jsonandthirdeye remove --cursorreverses itwithout disturbing unrelated entries.
thirdeye-cursor-hookroutes to the correct event type for each of the 14 events, including
both IDE (
hookEventName) and CLI (hook_event_name) key variants.stoppayload withinput_tokens/output_tokensproduces a usageevent with the reported counts; routing/PII keys are stripped from stored
payloads.
🤖 Generated by workbench pr_writer