What version of Kimi Code CLI is running?
kimi, version 1.41
Which open platform/subscription were you using?
Kimi Code
Which model were you using?
Kimi-k2.6
What platform is your computer?
Windows 64位
What issue are you seeing?
The Agent frequently generates PowerShell code using syntax only available in PowerShell 7.x, but Windows systems still default to PowerShell 5.1 (which Kimi CLI hardcodes as the shell). This causes script execution failures that are difficult for users to diagnose.
Case 1: Out-File -Encoding utf8NoBOM
"content" | Out-File -Encoding utf8NoBOM file.txt
Fails on PowerShell 5.1:
Out-File : Cannot validate argument on parameter 'Encoding'. The argument "utf8NoBOM" does not belong to the set
"unknown,string,unicode,bigendianunicode,utf8,utf7,utf32,ascii,default,oem" specified by the ValidateSet attribute.
Case 2: Join-Path with 3 arguments
$tmp = Join-Path $PWD ".git" "tmp-file-name"
Fails on PowerShell 5.1:
Join-Path : A positional parameter cannot be found that accepts argument 'tmp-file-name'.
(PowerShell 5.1 Join-Path only accepts 2 positional parameters; 3-parameter support was added in PowerShell 6.0)
Case 3: Pipeline chain operators
git pull && git merge ... # fails in PS 5.1
What steps can reproduce the bug?
- Use Kimi CLI on Windows (PowerShell 5.1 is the default shell)
- Ask the Agent to write a PowerShell script or one-liner that involves:
- File output with specific encoding
- Path joining with more than 2 segments
- Chaining multiple commands with
&& or ||
- Observe that the generated code fails when executed
What is the expected behavior?
The Agent should default to generating PowerShell 5.1-compatible code on Windows, since that is still the system default shell that Kimi CLI hardcodes (powershell.exe at C:\Windows\System32\WindowsPowerShell\v1.0\).
Compatible alternatives:
| PS 7.x syntax |
PS 5.1 compatible equivalent |
Out-File -Encoding utf8NoBOM |
Out-File -Encoding utf8 (then strip BOM if needed) or use .NET [IO.File]::WriteAllText() |
Join-Path $PWD ".git" "file" |
Join-Path (Join-Path $PWD ".git") "file" |
cmd1 && cmd2 |
cmd1; if ($?) { cmd2 } |
cmd1 || cmd2 |
cmd1; if (-not $?) { cmd2 } |
Additional information
Environment:
- OS: Windows 10/11
- Shell: Windows PowerShell 5.1 (hardcoded default)
Related Issues:
Suggested Fixes:
- Short-term: Update the system prompt to explicitly constrain the Agent: "On Windows, generate PowerShell 5.1 compatible code only"
- Medium-term: Maintain a PS 5.1 compatibility checklist in the system prompt or AGENTS.md for commonly used cmdlets
- Long-term: Detect the actual PowerShell version being used and communicate it to the Agent
What version of Kimi Code CLI is running?
kimi, version 1.41
Which open platform/subscription were you using?
Kimi Code
Which model were you using?
Kimi-k2.6
What platform is your computer?
Windows 64位
What issue are you seeing?
The Agent frequently generates PowerShell code using syntax only available in PowerShell 7.x, but Windows systems still default to PowerShell 5.1 (which Kimi CLI hardcodes as the shell). This causes script execution failures that are difficult for users to diagnose.
Case 1:
Out-File -Encoding utf8NoBOMFails on PowerShell 5.1:
Case 2:
Join-Pathwith 3 argumentsFails on PowerShell 5.1:
(PowerShell 5.1
Join-Pathonly accepts 2 positional parameters; 3-parameter support was added in PowerShell 6.0)Case 3: Pipeline chain operators
What steps can reproduce the bug?
&&or||What is the expected behavior?
The Agent should default to generating PowerShell 5.1-compatible code on Windows, since that is still the system default shell that Kimi CLI hardcodes (
powershell.exeatC:\Windows\System32\WindowsPowerShell\v1.0\).Compatible alternatives:
Out-File -Encoding utf8NoBOMOut-File -Encoding utf8(then strip BOM if needed) or use .NET[IO.File]::WriteAllText()Join-Path $PWD ".git" "file"Join-Path (Join-Path $PWD ".git") "file"cmd1 && cmd2cmd1; if ($?) { cmd2 }cmd1 || cmd2cmd1; if (-not $?) { cmd2 }Additional information
Environment:
Related Issues:
Feature Request: Configurable Default Shell on Windows #1274 - Configurable Default Shell on Windows
有关shell硬编码问题;已由kimi自身实现,代码奉上,希望可以采纳; || Regarding the issue of shell hard coding; it has been implemented by kimi itself, and the code is provided. I hope it can be adopted; #2066 - Support PowerShell 7 (pwsh) as Windows default shell
Config file with UTF-8 BOM causes Invalid TOML error on startup #2043 - Config file with UTF-8 BOM causes Invalid TOML error (also caused by PowerShell
Out-Filebehavior differences)Suggested Fixes: