Skip to content

Add Cursor as a fourth supported platform - #21

Merged
duncankmckinnon merged 8 commits into
mainfrom
cursor-integration
Jun 3, 2026
Merged

Add Cursor as a fourth supported platform#21
duncankmckinnon merged 8 commits into
mainfrom
cursor-integration

Conversation

@duncankmckinnon

Copy link
Copy Markdown
Owner

Summary

Adds Cursor support to thirdeye alongside Claude Code, Codex, and Gemini. The
integration installs a single multiplexed hook entry into ~/.cursor/hooks.json
that dispatches all 14 Cursor hook events (lifecycle, prompts, response,
shell/MCP/file/tab tool pairs, postToolUse, stop) through one Python
entrypoint, and captures token usage directly from the stop/sessionEnd
payload without transcript parsing.

Changes

  • src/thirdeye/platforms/cursor/constants.py — Cursor hook event names, config
    paths, and payload strip-key set.
  • src/thirdeye/platforms/cursor/install.py — install/uninstall of the
    multiplexed hook entry in ~/.cursor/hooks.json.
  • src/thirdeye/platforms/cursor/hook.py — stdin-JSON dispatcher that
    normalizes IDE/CLI payload key variants and writes typed thirdeye events.
  • src/thirdeye/platforms/cursor/usage.py — token usage extraction from the
    Cursor stop/sessionEnd payload (input_tokens, output_tokens, etc.).
  • src/thirdeye/commands/add.py — wires thirdeye add --cursor into the CLI.
  • pyproject.toml — registers the thirdeye-cursor-hook entrypoint.
  • README.md, docs/ui.md, .../setup-and-tracing.md — mention Cursor as a
    supported platform.
  • tests/test_cursor_constants.py, test_cursor_install.py,
    test_cursor_hook.py, test_cursor_usage.py, additions to
    test_add_command.py — coverage for constants, install/uninstall, dispatcher
    behavior across all events, usage extraction, and CLI wiring.

Test plan

  • pytest passes the full suite, including the new
    test_cursor_constants.py, test_cursor_install.py,
    test_cursor_hook.py, test_cursor_usage.py, and updated
    test_add_command.py.
  • ruff check . and ruff format --check . are clean.
  • thirdeye add --cursor writes a multiplexed thirdeye-cursor-hook entry
    into ~/.cursor/hooks.json and thirdeye remove --cursor reverses it
    without disturbing unrelated entries.
  • Piping a sample Cursor hook JSON payload into thirdeye-cursor-hook
    routes to the correct event type for each of the 14 events, including
    both IDE (hookEventName) and CLI (hook_event_name) key variants.
  • A stop payload with input_tokens / output_tokens produces a usage
    event with the reported counts; routing/PII keys are stripped from stored
    payloads.

🤖 Generated by workbench pr_writer

duncankmckinnon and others added 8 commits May 30, 2026 17:40
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>
@duncankmckinnon
duncankmckinnon merged commit 496f0a9 into main Jun 3, 2026
5 checks passed
@duncankmckinnon
duncankmckinnon deleted the cursor-integration branch June 3, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant