fix: cursor CLI capture for WSL2 (hook execution + path normalization + transcript lookup)#9
fix: cursor CLI capture for WSL2 (hook execution + path normalization + transcript lookup)#9codeprakhar25 wants to merge 5 commits intomainfrom
Conversation
Document the new context command, context-aware reports, and skill installer so users can discover the released workflow from the main README.
AgentDiff ReportSummary
Review Context
Files To Review First
Trace details
|
Greptile SummaryThis PR fixes three independent bugs that caused Cursor agent traces to be silently dropped on WSL2: the hook command is now prefixed with Confidence Score: 5/5Safe to merge; both remaining findings are P2 and do not affect the primary WSL2 code path. All three targeted bugs are well-diagnosed and correctly fixed. The two P2 findings (dead
Important Files Changed
Reviews (2): Last reviewed commit: "fix: address PR review issues — shell in..." | Re-trigger Greptile |
- Fix shell injection in agentdiff-policy.yml: pass github.head_ref and head.sha through env vars instead of interpolating directly into the run block, preventing branch-name-based code execution in the runner. - Fix wrong Windows user selection in _cursor_transcript_candidates: use the Linux $USER env var to find the matching Windows home directory before falling back to alphabetical scan, avoiding reads from unrelated user dirs (Administrator, Default, etc.) on shared machines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
What does this PR do?
Fixes cursor agent traces never appearing in
agentdiffwhen working with Cursor on WSL2. Three independent bugs combined to silently drop every cursor event.Bug 1 — Hook never executed (
src/configure/cursor.rs)The Windows-side
~/.cursor/hooks.jsonwas written withpython3 /home/prakh/.agentdiff/.... Cursor (a Windows app) runs hooks in a Windows shell where that Linux path is invalid, so every hook invocation failed silently. Fixed by prefixing withwslfor anyhooks.jsonunder/mnt/(Windows-side paths).Bug 2 — UNC paths broke repo detection (
scripts/capture-cursor.py)When Cursor opens a WSL workspace, it passes file paths as Windows UNC strings like
\\wsl.localhost\Ubuntu\home\prakh\agentdiff\src\main.rs. After backslash conversion this became/wsl.localhost/Ubuntu/home/...— a path that doesn't exist in WSL.git rev-parsefailed, no.git/agentdiff/was found, and the script exited withSKIP no_agentdiff_init. Fixed innormalize_pathto strip the WSL UNC host prefix and convert Windows drive letters (D:/→/mnt/d/).Bug 3 — Transcript lookup missed (
scripts/capture-cursor.py)get_prompt_from_transcriptderived the project slug ashome-prakh-agentdifffrom the Linux path, but Cursor stores data underwsl-localhost-Ubuntu-home-prakh-agentdiff(the Windows UNC slug). The prompt was always"unknown". Fixed by scanning both the Linux-side and Windows-side cursorprojects/dirs for a matching slug suffix, with Linux$USERused to pick the right Windows user directory (avoids reading from unrelated system accounts on shared machines).Type of change
Testing
cargo test --lockedpassespython3 -m unittest discover -s scripts/tests -p "test_*.py"passessession.jsonland are attributed correctly inagentdiff reportChecklist