Skip to content

fix(codebuddy): run Windows hooks without requiring PowerShell 7 - #27626

Merged
Jinwoo-H merged 1 commit into
mainfrom
OrcaWin/codebuddy-hooks-without-pwsh
Oct 12, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
OrcaWin/codebuddy-hooks-without-pwsh

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 0

ELI5

On Windows, Orca told CodeBuddy to run its status hooks with "PowerShell". CodeBuddy takes that to mean PowerShell 7 (pwsh), which most Windows machines don't have. Every hook failed with spawn pwsh ENOENT and CodeBuddy blocked the prompt. The hooks now run on a stock Windows install.

What Changed

CodeBuddy's hook service no longer sets windowsHookShell: 'powershell'. It now gets the same Windows hook command Claude uses (getWindowsManagedLifecycleHook):

  • On normal profile paths, the bare path to Orca's .cmd hook script.
  • On paths a bare command can't handle (spaces, special characters), Orca's existing launcher, which calls the built-in powershell.exe by its full path.

Existing installs are fixed automatically. The old entry still matches agent-hooks\codebuddy-hook.cmd, so status reports it as not installed and the next startup install replaces it. Users' own hooks are kept.

Why

I checked CodeBuddy's published package (@tencent-ai/codebuddy-code 2.164.0, dist/codebuddy.js). For shell: "powershell" it returns {executable: "pwsh", ...} with no lookup and no fallback, and a failed start counts as a block. Without a shell setting, it runs the command under Git Bash -c if it finds it, otherwise under the first PowerShell it finds (pwsh, then powershell, then the System32 path). The plain script path works either way.

Alternatives I rejected:

  • Checking whether pwsh is installed when writing the hook: the answer goes stale as soon as the user installs or removes PowerShell 7.
  • Another PowerShell wrapper: one more process on every hook event, plus more antivirus/EDR exposure.

Qoder and Qwen Code also write shell: "powershell", but their runners resolve it to Windows PowerShell 5.1 (Qoder 1.1.68 uses powershell.exe on win32; Qwen Code 0.25.1 uses powershell), which ships with Windows. They're unchanged.

SSH and remote installs already use the POSIX form and are unaffected.

Linked Issue

Fixes #27182

Visual Proof

N/A: this only changes the hook config Orca writes. Nothing in the UI changes.

Testing

  • Unit tests: on Windows, CodeBuddy hooks have no shell field, and an existing shell: "powershell" entry is replaced while user hooks are kept. Updated the managed-hook command contract test.
  • 110/110 pass across the CodeBuddy, hook-command and Windows hook-file test files.
  • Live check on Windows 11 with pwsh removed from PATH. I installed the hooks into a temporary profile and ran the registered command the way CodeBuddy does:
    • Old config: spawn pwsh ENOENT.
    • New config under Git Bash, and under Windows PowerShell 5.1: exit 0, {}.
    • Fallback launcher with a profile path containing a space: exit 0, {}.
  • pnpm tc:node, oxlint and check:code-quality:changed are clean.

Known limit: for profile paths with spaces or non-ASCII characters, CodeBuddy adds -WindowStyle Hidden in front of the fallback launcher. #16003 found Kaspersky blocking that pair, so those users may still need follow-up.

  • I manually tested these changes locally
  • Automated tests added/updated

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered: Windows-only branch; POSIX and remote hook forms are unchanged

CodeBuddy spawns hooks registered with shell: 'powershell' as a bare
`pwsh`, so on Windows without PowerShell 7 every hook failed with
spawn pwsh ENOENT and the failed UserPromptSubmit hook blocked prompts.
Register CodeBuddy's hooks the way Claude's are: the managed .cmd path
on cmd-safe profiles (runs under CodeBuddy's Git Bash or Windows
PowerShell default shell) and the absolute powershell.exe encoded
launcher otherwise. The next install rewrites existing registrations.

Fixes #27182
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61df0b47-408a-45c4-a131-f2c80540a757

📥 Commits

Reviewing files that changed from the base of the PR and between b022406 and a776097.


📒 Files selected for processing (3)
  • src/main/agent-hooks/managed-hook-command-contract.test.ts
  • src/main/codebuddy/hook-service.test.ts
  • src/main/codebuddy/hook-service.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

CodeBuddy hook settings retain the Windows compatibility launcher and omit the explicit PowerShell shell setting. Tests cover replacement of a legacy PowerShell-shell hook, retention of a user hook, and scanning of CodeBuddy commands.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a7760

No actionable issue remains before merging. The change removes CodeBuddy’s explicit PowerShell requirement for Windows hooks.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the CodeBuddy Windows hook fix and the removal of the PowerShell 7 requirement.
Description check Passed The description covers the required core sections, including the user impact, implementation, rationale, linked issue, visual-proof status, testing, and compatibility considerations. It is sufficientl…
Linked Issues check Passed Issue #27182 requires Windows CodeBuddy prompts to avoid the spawn pwsh ENOENT hook failure. The change removes windowsHookShell: 'powershell' from codebuddyHookService, so CodeBuddy receives th…
Out of Scope Changes check Passed The pull request changes one CodeBuddy production setting and adds focused contract and replacement tests. The tests directly verify the Windows hook behavior required by issue #27182. No unrelated pr…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit b0e73d9 into main Oct 12, 2026
29 checks passed
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.

[Bug]: Codebuddy CLI meets problem with "Hook execution failed: spawn pwsh ENOENT"

2 participants