Skip to content

Conversation

@Orinks
Copy link

@Orinks Orinks commented Jan 17, 2026

Summary

This PR improves Windows compatibility for Codebuff by:

Shell Detection

  • Added shared shell detection utility (common/src/util/detect-shell.ts) that detects cmd.exe, PowerShell, bash, zsh, and fish
  • SDK now uses the detected shell instead of hardcoding cmd.exe on Windows
  • System info reports the actual detected shell to the LLM for better command generation

Cross-Platform Git Commits

  • Removed HEREDOC syntax from git commit guide (bash-only, fails on Windows)
  • Added file-based commit approach for cmd.exe to avoid escaping issues entirely
  • Uses .codebuff-commit-msg.txt temp file with git commit -F flag

Enhanced cmd.exe System Prompts

  • Added explicit escaping rules: ^ for special chars, %% for percent
  • Documented that nested quotes and multi-line strings are unreliable
  • Recommended file-based approach for complex content with practical examples

Updated Documentation

  • Enhanced WINDOWS.md with shell detection info and troubleshooting

Testing

  • All typechecks pass
  • Tested shell detection on Windows (correctly detects cmd.exe and returns /c args)

Files Changed

  • common/src/util/detect-shell.ts (new)
  • cli/src/utils/detect-shell.ts (re-exports from common)
  • sdk/src/tools/run-terminal-command.ts
  • sdk/src/run-state.ts
  • common/src/tools/params/tool/run-terminal-command.ts
  • packages/agent-runtime/src/system-prompt/prompts.ts
  • WINDOWS.md

Orinks and others added 2 commits January 16, 2026 20:23
- Add shared shell detection utility in common/src/util/detect-shell.ts
- Update CLI to re-export shell detection from common
- SDK now uses detected shell (PowerShell/cmd.exe/bash) instead of hardcoding
- Report actual detected shell in systemInfo for better LLM guidance
- Fix git commit syntax to use cross-platform format (no HEREDOC)
- Add shell-specific Windows notes (PowerShell vs cmd.exe guidance)
- Update WINDOWS.md documentation with shell detection info
- Add detailed escaping rules for special chars (^ for & | < > ^, %% for %)
- Explain that nested quotes and multi-line strings are unreliable
- Recommend file-based approach for complex content
- Add practical examples for git commits and complex echo

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Orinks Orinks changed the title "%TITLE%" feat(windows): add shell detection and fix cmd.exe escaping issues Jan 17, 2026
@jahooma jahooma requested review from brandonkachen and removed request for brandonkachen and charleslien January 17, 2026 01:34
@jahooma
Copy link
Contributor

jahooma commented Jan 17, 2026

Hi @Orinks, thanks for creating this PR. I looked into your solution, and for now I think I prefer the following solution, which is what Claude Code uses: #413

My PR basically requires bash, but shows you an error message for how you can install it if you do not already have it on your Windows PC.

Bash is preferred because the coding agents are trained on it. They won't be as good with powershell. Many of our Windows users already have Git Bash and so don't need to take any action for it to work optimally.

If you are able to build codebuff locally, could you try out my PR and see if it works for you?

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.

2 participants