Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ ANTHROPIC_API_KEY=sk-ant-your-key-here
# Disable "Co-authored-by" line in git commits made by OpenClaude
# OPENCLAUDE_DISABLE_CO_AUTHORED_BY=1

# Enable PowerShell tool on Windows as the default shell for ! commands and bash-mode.
# Without this, OpenClaude uses bash (Git Bash / WSL / MSYS2) on Windows.
# Set to 1/true to activate; set to 0/false to explicitly disable.
# Only takes effect on Windows; ignored on macOS and Linux.
# OPENCLAUDE_USE_POWERSHELL_TOOL=1

# Disable strict tool schema normalization for non-Gemini providers
# Useful when MCP tools with complex optional params (e.g. list[dict])
# trigger "Extra required key ... supplied" errors from OpenAI-compatible endpoints
Expand Down
4 changes: 2 additions & 2 deletions src/services/tips/tipRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ const externalTips: Tip[] = [
{
id: 'powershell-tool-env',
content: async () =>
'Set CLAUDE_CODE_USE_POWERSHELL_TOOL=1 to enable the PowerShell tool (preview)',
'Set OPENCLAUDE_USE_POWERSHELL_TOOL=1 to enable the PowerShell tool (preview)',
cooldownSessions: 10,
isRelevant: async () =>
getPlatform() === 'windows' &&
process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL === undefined,
process.env.OPENCLAUDE_USE_POWERSHELL_TOOL === undefined,
},
{
id: 'status-line',
Expand Down
16 changes: 12 additions & 4 deletions src/utils/shell/resolveDefaultShell.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { isEnvTruthy } from '../envUtils.js'
import { getPlatform } from '../platform.js'
import { getInitialSettings } from '../settings/settings.js'

/**
* Resolve the default shell for input-box `!` commands.
*
* Resolution order (docs/design/ps-shell-selection.md §4.2):
* settings.defaultShell 'bash'
* settings.defaultShell -> (Windows + OPENCLAUDE_USE_POWERSHELL_TOOL) -> 'bash'
*
* Platform default is 'bash' everywhere — we do NOT auto-flip Windows to
* PowerShell (would break existing Windows users with bash hooks).
* Platform default is 'bash' on all platforms, unless the user has explicitly
* opted into PowerShell via OPENCLAUDE_USE_POWERSHELL_TOOL=true on Windows.
* This restores the upstream behavior where setting the env var also makes
* PowerShell the default for ! commands without requiring a separate
* settings.defaultShell change.
*/
export function resolveDefaultShell(): 'bash' | 'powershell' {
return getInitialSettings().defaultShell ?? 'bash'
return getInitialSettings().defaultShell ??
(getPlatform() === 'windows' && isEnvTruthy(process.env.OPENCLAUDE_USE_POWERSHELL_TOOL)
? 'powershell'
: 'bash')
}
4 changes: 2 additions & 2 deletions src/utils/shell/shellToolUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const SHELL_TOOL_NAMES: string[] = [BASH_TOOL_NAME, POWERSHELL_TOOL_NAME]
export function isPowerShellToolEnabled(): boolean {
if (getPlatform() !== 'windows') return false
return process.env.USER_TYPE === 'ant'
? !isEnvDefinedFalsy(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL)
: isEnvTruthy(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL)
? !isEnvDefinedFalsy(process.env.OPENCLAUDE_USE_POWERSHELL_TOOL)
: isEnvTruthy(process.env.OPENCLAUDE_USE_POWERSHELL_TOOL)
}
Loading