rtk-ai/rtk

[FEATURE] Add Claude Code PowerShell hook compatibility

開放

#1,319 建立於 2026年4月15日

 (1 則留言) (0 個反應) (0 位負責人)Rust (2,914 個分叉)batch import
area:clieffort-largeenhancementhelp wantedplatform:windowspriority:medium

倉庫指標

星標
 (48,085 顆星)
PR 合併指標
 (平均合併 11天 1小時) (30 天內合併 45 個 PR)

描述

Summary

Add first-class Claude Code PowerShell compatibility when CLAUDE_CODE_USE_POWERSHELL_TOOL=1 is enabled.

Problem

RTK already supports Claude's Bash hook flow, but Claude Code on Windows can route shell calls through the PowerShell tool instead. In that mode RTK currently misses several integration points:

  • rtk init -g on Windows falls back to --claude-md instead of installing a compatible hook
  • settings.json cannot be patched with a matcher entry that covers both Bash and PowerShell tool names on Windows
  • rtk session / rtk discover only account for Bash tool-use extraction
  • hook diagnostics and status reporting do not surface a PowerShell hook path

Proposed solution

  • add an embedded hooks/claude/rtk-rewrite.ps1 hook script
  • support rtk init -g --shell powershell
  • auto-detect CLAUDE_CODE_USE_POWERSHELL_TOOL=1 on Windows during global init
  • patch and remove settings.json entries with a Bash|PowerShell matcher for the .ps1 hook
  • include PowerShell hooks in hook status and config reporting
  • extract PowerShell tool calls in session/discover analytics the same way as Bash
  • cover the new behavior with focused unit tests

Acceptance criteria

  • rtk init -g --shell powershell installs a .ps1 hook and patches Claude settings
  • Windows global init can route to the PowerShell hook flow when the Claude env var is set
  • hook health checks recognize either Bash or PowerShell Claude hooks
  • discover/session analytics count both Bash and PowerShell Claude tool calls
  • the PowerShell path is covered by unit tests for parsing, settings mutation, and embedded hook content

Related issues

  • Related: #1248

貢獻者指南