Skip to content

fix(cursor): validate native PowerShell hooks on Windows#651

Draft
tirth8205 wants to merge 3 commits into
mainfrom
codex/port-cursor-windows
Draft

fix(cursor): validate native PowerShell hooks on Windows#651
tirth8205 wants to merge 3 commits into
mainfrom
codex/port-cursor-windows

Conversation

@tirth8205

@tirth8205 tirth8205 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Latest refresh — 18 July 2026

  • rebased patch-identically onto main 0a3bd6c; current head 8a24a02
  • all 15 hosted checks passed after this rebase
  • released Cursor-on-Windows client validation remains required; this stays draft and is not mergeable by policy## Status

Draft — do not merge until the released Cursor Windows-client checks below pass.

Change

This carries the safe Windows Cursor-hook work from source PR #617, with Mohammad Farahani preserved as co-author. It emits native PowerShell hooks on Windows, quotes paths containing spaces, migrates exact CRG-owned Bash or PowerShell entries without touching unrelated hooks, drains the full Cursor event, emits valid JSON, and fails open.

Why source PR #617 was closed

The source left the PowerShell -File path unquoted, appended Windows entries beside stale Unix CRG entries, and asserted strings instead of executing the generated hooks on Windows. This draft fixes those gaps. Source PR #617 is closed as superseded.

Automated validation

  • patch-equivalent rebase onto current main (0a3bd6c); current head 8a24a02
  • focused install/uninstall tests: 227 passed, 6 Windows-only skipped locally
  • complete non-daemon suite: 1,909 passed, 7 skipped, 2 expected deselections, 2 xpassed
  • both multiprocessing parity checks: 2 passed
  • Ruff and git diff --check: clean
  • GitHub CI run 29619426482: every job passed, including native Windows execution on Windows Server 2025
  • PR Review run 29619426468: passed

Automated Windows CI covers paths with spaces, migration and reinstall, 2 MiB stdin events, missing and non-zero code-review-graph, valid JSON output, exit code 0, and exact owned-hook cleanup.

Required real-client validation

Do not mark this ready or merge it until all items below are recorded with a released Cursor client on Windows, using a home path containing spaces and an existing Unix-only CRG configuration plus an unrelated user hook:

  • afterFileEdit invokes the installed update hook without a hook-output or configuration error
  • sessionStart invokes the installed status hook and Cursor accepts its JSON output
  • beforeShellExecution invokes the installed pre-commit hook and Cursor accepts its JSON output
  • reinstall replaces stale CRG entries without duplicates and preserves the unrelated hook
  • uninstall removes only CRG entries/scripts and Cursor still loads the remaining hook configuration

Carries PR #617 with original contributor attribution.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.40 (MEDIUM) — 31 changed function(s)/class(es), 0 affected flow(s), 22 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.40 medium code_review_graph/skills.py::_is_windows code_review_graph/skills.py:1385 no
0.40 medium code_review_graph/skills.py::_cursor_hooks_dir code_review_graph/skills.py:1390 no
0.40 medium code_review_graph/skills.py::_cursor_windows_hook_command code_review_graph/skills.py:1395 no
0.40 medium code_review_graph/skills.py::_cursor_hook_command code_review_graph/skills.py:1404 no
0.40 medium code_review_graph/skills.py::_cursor_owned_hook_commands code_review_graph/skills.py:1411 no
0.40 medium code_review_graph/skills.py::generate_cursor_hooks_config code_review_graph/skills.py:1438 no
0.40 medium code_review_graph/skills.py::_cursor_hook_scripts code_review_graph/skills.py:1636 no
0.40 medium code_review_graph/skills.py::install_cursor_hooks code_review_graph/skills.py:1654 no
0.40 medium tests/test_skills.py::TestInstallCursorHooks._run_windows_hook tests/test_skills.py:1601 no
0.35 low code_review_graph/skills.py::_cursor_hook_scripts_unix code_review_graph/skills.py:1480 no

Test gaps

  • code_review_graph/skills.py::_is_windows (code_review_graph/skills.py:1385)
  • code_review_graph/skills.py::_cursor_hooks_dir (code_review_graph/skills.py:1390)
  • code_review_graph/skills.py::_cursor_windows_hook_command (code_review_graph/skills.py:1395)
  • code_review_graph/skills.py::_cursor_hook_command (code_review_graph/skills.py:1404)
  • code_review_graph/skills.py::_cursor_owned_hook_commands (code_review_graph/skills.py:1411)
  • ...and 17 more without direct tests

Token savings: this graph-backed report used ~74,483 fewer tokens (~93%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205
tirth8205 force-pushed the codex/port-cursor-windows branch 2 times, most recently from 0f5da3f to 02eb8d9 Compare July 17, 2026 19:44
@tirth8205
tirth8205 force-pushed the codex/port-cursor-windows branch from 02eb8d9 to 36743ed Compare July 17, 2026 22:57
@tirth8205
tirth8205 force-pushed the codex/port-cursor-windows branch from 36743ed to 8a24a02 Compare July 17, 2026 23:36

@rajpratham1 rajpratham1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request significantly improves Cursor integration on Windows by introducing native PowerShell hook support while preserving compatibility with existing Unix-based installations. The implementation cleanly separates platform-specific hook generation, correctly handles PowerShell command quoting, migrates existing CRG-managed Bash hooks without affecting unrelated user configuration, and extends uninstall logic to clean up both Unix and Windows hook artifacts across platform migrations. The accompanying test suite is comprehensive, covering configuration generation, migration scenarios, fail-open behavior, Windows command execution, uninstall behavior, and cross-platform compatibility. The implementation is cohesive, well-scoped, and no blocking issues were identified during review. LGTM and approved.

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.

2 participants