fix(windows): PowerShell completion install and time-format detection#39644
fix(windows): PowerShell completion install and time-format detection#39644lijinlar wants to merge 3 commits intoopenclaw:mainfrom
Conversation
- completion-cli: installCompletion() now handles the 'powershell' shell
case instead of falling through to the 'not supported' error branch.
- completion-cli: formatCompletionSourceLine() now emits PS dot-source
syntax (`. "${path}"`) for PowerShell instead of the bash-only
`source` keyword, which is not a valid PowerShell cmdlet.
- date-time: detectSystemTimeFormat() now calls resolvePowerShellPath()
instead of the hardcoded `powershell` binary, so PS7 (pwsh.exe) is
preferred over PS5.1 when available, consistent with shell-utils.ts.
Adds src/cli/completion-cli.powershell.test.ts with 7 tests covering
shell detection, dot-source line format, and end-to-end profile install.
Greptile SummaryThis PR fixes two real Windows-only bugs: PowerShell completion installation was entirely broken (the Key changes:
Minor issue found: The post-install success message in Confidence Score: 4/5
|
Post-install success message was unconditionally printing `source <profilePath>` which is bash syntax and not valid in PowerShell. Now branches on the shell type so PowerShell users see the correct dot-source form: `. "<profilePath>"`. Addresses greptile review comment on PR openclaw#39644.
After adding the powershell case, all CompletionShell values (zsh, bash, fish, powershell) are now handled. The else branch is dead code and oxlint --type-aware correctly flags shell as never there. Collapse powershell into the final else to satisfy exhaustiveness while keeping the fallback readable.
Summary
openclaw completion --install --shell powershellsilently printed "not supported" and exited without writing anything. Additionally, the time-format detection always invoked PS 5.1 (powershell.exe) even when PS7 (pwsh.exe) was installed.powershellbranch ininstallCompletion(), corrected the source-line syntax from bashsourceto PS dot-source (.), and switcheddetectSystemTimeFormat()to useresolvePowerShellPath()(which already prefers PS7).Change Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
openclaw completion --install --shell powershellnow works on Windows: creates/updatesMicrosoft.PowerShell_profile.ps1with. "${cachePath}"dot-source syntax.pwsh.exeinstead ofpowershell.exe.Security Impact
resolvePowerShellPath()was already used throughoutshell-utils.ts; this alignsdate-time.tswith the existing pattern.Repro + Verification
Environment
Steps
openclaw completion --write-stateopenclaw completion --install --shell powershellExpected
%USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1is created/updated with. "${cachePath}"Actual (before fix)
Automated installation not supported for powershell yet.and exits with no file writtenEvidence
Human Verification
tsc --noEmit) clean, oxlint 0 errors, oxfmt clean, all 7 new tests pass on Windows.isCompletionInstalled()correctly detects after install.Compatibility / Migration
Failure Recovery
git revertthe single commit; no config changes were made.Risks and Mitigations
.config/powershell/Microsoft.PowerShell_profile.ps1) — untested on those platforms withpwshinstalled.getShellProfilePath()and is unchanged; this PR only wires up the call that was missing.