Skip to content

revdiff plugin Windows launcher (PowerShell + WezTerm) #4

Description

@shtirlitsDva

Task: revdiff plugin Windows launcher (PowerShell + WezTerm)

Description

Port the Claude Code revdiff plugin's bash launcher to PowerShell so it works on Windows + WezTerm. The existing launch-revdiff.sh is ~290 lines covering tmux, kitty, wezterm, cmux, ghostty, iTerm2, and emacs vterm. The Windows port targets only WezTerm via wezterm cli spawn --new-tab. Add a detect-ref.ps1 sibling for the existing detect-ref.sh helper. Update the SKILL.md so the loader picks .ps1 on Windows.

Acceptance Criteria

  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.ps1 created.
  • .claude-plugin/skills/revdiff/scripts/detect-ref.ps1 created with output format byte-identical to detect-ref.sh.
  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh is byte-identical to master — no edits.
  • .claude-plugin/skills/revdiff/scripts/detect-ref.sh is byte-identical to master — no edits.
  • .claude-plugin/skills/revdiff/SKILL.md includes a platform dispatch: on Windows it invokes launch-revdiff.ps1, elsewhere it invokes launch-revdiff.sh.
  • launch-revdiff.ps1 accepts the same arguments launch-revdiff.sh accepts (ref, --staged, annotation file path, etc.) and forwards them to revdiff.exe.
  • launch-revdiff.ps1 spawns revdiff via wezterm cli spawn --new-tab -- revdiff.exe <args> so the new tab lives in the same WezTerm window as the parent Claude session.
  • The PowerShell script captures the new pane id from wezterm cli spawn's stdout and waits for the spawned tab to exit before returning.
  • On revdiff exit, the spawned tab cleans up (closes or returns to a clean prompt) — no orphan tabs.
  • Temp files use $env:TEMP (via New-TemporaryFile or [IO.Path]::GetTempFileName) — no /tmp/... literals.
  • Sentinel/wait pattern uses file polling (Test-Path) or Wait-Jobnot mkfifo (named pipes work differently on Windows and aren't worth the complexity).
  • Both try { } finally { } cleanup blocks guarantee temp files and pane references are released even on revdiff crash.
  • Set-StrictMode -Version Latest and $ErrorActionPreference = 'Stop' at the top.
  • Header comment block links to the bash sibling so future edits are easy to mirror.
  • Argument forwarding to wezterm cli spawn is properly quoted to avoid injection (use the array form, not string interpolation).
  • Macos/Linux flow via launch-revdiff.sh is unchanged — verify by running the bash script on macOS after the SKILL.md edit.

Technical Details

Files to create

  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.ps1 — ~150 lines.
  • .claude-plugin/skills/revdiff/scripts/detect-ref.ps1 — ~50 lines.

Files to modify

  • .claude-plugin/skills/revdiff/SKILL.md — add a small platform dispatch block (~5–10 lines). Use $IsWindows (PowerShell 6+) with a fallback to [System.Environment]::OSVersion.Platform -eq 'Win32NT' for Windows PowerShell 5.1 if the harness might invoke it that way.

Files to read (do not modify)

  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh — read top-to-bottom. Identify:
    1. The full argument signature (positional + flag).
    2. The WezTerm code path (somewhere around line 84 per the audit) — port that logic.
    3. The exit code conventions and stdout/stderr expectations.
    4. The env vars Claude passes in (CLAUDE_PROJECT_DIR, annotation file path, etc.).
  • .claude-plugin/skills/revdiff/scripts/detect-ref.sh — read fully, port the git-detection logic line-for-line into PowerShell using & git ... and $LASTEXITCODE.
  • .claude-plugin/skills/revdiff/SKILL.md — read the existing loader/dispatch section to understand where the platform branch goes.

WezTerm spawn pattern

$wezArgs = @('cli', 'spawn', '--new-tab', '--')
$wezArgs += 'revdiff.exe'
$wezArgs += $forwardedArgs
$paneId = & wezterm @wezArgs
if ($LASTEXITCODE -ne 0) { throw "wezterm cli spawn failed: $LASTEXITCODE" }

After spawning, poll for the pane to exit using wezterm cli list --format json or wait on a sentinel file the spawned process touches when it exits. The bash script's wait pattern is the reference; mirror its semantics, not its mechanism.

detect-ref.ps1 sketch

# detect-ref.ps1 — Windows port of detect-ref.sh.
# Output format MUST match the bash version exactly so callers parse it identically.

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$inGit = & git rev-parse --is-inside-work-tree 2>$null
if ($LASTEXITCODE -ne 0) { Write-Output 'no-git'; exit 0 }

# ... mirror the rest of detect-ref.sh's logic via & git symbolic-ref / show-ref / status --porcelain

Notes

  • The audit found the bash launcher uses osascript, emacsclient, tmux, kitty @, wezterm cli, etc. Do not port any of those to PowerShell — only port the WezTerm path.
  • If the bash script exposes options like --no-tab or --window for non-WezTerm terminals, do not implement them in the PowerShell version. Document the omission in the header comment.
  • Per CLAUDE.md, after this task lands the plugin version should be bumped — but the bump itself is deferred to task 006 so it covers task 004 as well.
  • PowerShell argument forwarding gotcha: when calling external programs, use the call operator & with an array (@($arg1, $arg2)) rather than a single string. String interpolation invites injection if a ref name contains spaces or quotes.

Audit references

  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh:1 — bash shebang
  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh:84 — WezTerm overlay path (approximate)
  • .claude-plugin/skills/revdiff/scripts/launch-revdiff.sh:17,64,93,112,115,150,153,203,279,284mktemp /tmp/... calls to replace
  • .claude-plugin/skills/revdiff/scripts/detect-ref.sh:1–61 — full file to port

Dependencies

  • None for creation — can start in parallel with task 001.
  • For validation, requires task 001 (so revdiff.exe exists and resolves config paths correctly) and task 002 (so the local build is reproducible).
  • Validation in task 006 requires this task to be complete.

Effort Estimate

  • Size: M
  • Scope: ~150 lines of PowerShell across 2 files + a small SKILL.md edit. The bash original is 290+ lines but ~60% is non-WezTerm terminal handlers we are explicitly not porting.

Definition of Done

  • launch-revdiff.ps1 and detect-ref.ps1 created
  • SKILL.md dispatch updated, validated by reading the file end-to-end after the edit
  • Bash files in the same directory are byte-identical to master
  • Manual smoke test on Windows + WezTerm: invoke the skill from a Claude Code session, confirm a new tab opens and revdiff renders
  • Manual smoke test on macOS: invoke the skill, confirm bash path still runs (no SKILL.md regression)
  • Code reviewed

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

epic:windows-supportBelongs to the windows-support epicin-progressWork has started on this issuetaskTask within an epic

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions