fix: add cross-platform commit helper to resolve heredoc issues#277
Closed
PierrunoYT wants to merge 3 commits intoCodebuffAI:mainfrom
Closed
fix: add cross-platform commit helper to resolve heredoc issues#277PierrunoYT wants to merge 3 commits intoCodebuffAI:mainfrom
PierrunoYT wants to merge 3 commits intoCodebuffAI:mainfrom
Conversation
Resolves the issue where git commit commands with heredoc syntax fail on Windows systems. The heredoc approach (<<'EOF') only works in bash/Unix shells and causes "pathspec '<<'EOF'' did not match any file(s)" errors on Windows. Changes: - Add scripts/commit-helper.ts: Cross-platform script using temporary files - Add npm script "commit" for easy access: npm run commit "message" - Update system prompt to instruct AI agents to use commit helper - Replace platform-specific heredoc instructions with single helper approach The commit helper validates git repository state, handles multi-line messages correctly, and works consistently across Windows, macOS, and Linux. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
f5af7b7 to
e9adfb4
Compare
Fixes the root cause of issue CodebuffAI#274 where git commit commands fail on Windows PowerShell. The previous implementation always defaulted to cmd.exe on Windows, ignoring the actual shell in use. Changes: - Add shell detection to background.ts and SDK run-terminal-command.ts - Use detectShell() to differentiate between PowerShell and cmd.exe - Apply correct shell arguments: -Command for PowerShell, /c for cmd.exe - Import and utilize existing detectShell utility This fix ensures commands are executed in the correct shell environment, resolving shell-specific syntax issues. Works alongside the commit helper script to provide complete cross-platform compatibility. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #274 - Git commit fails on Windows PowerShell due to heredoc syntax issues and improper shell detection.
This PR provides a comprehensive two-part solution to resolve cross-platform terminal execution issues:
Root Cause Analysis
The issue had two components:
cmd.exe, ignoring the actual shell (PowerShell)<<'EOF') doesn't work in any Windows shell (cmd.exe or PowerShell)Part 1: Cross-Platform Commit Helper
scripts/commit-helper.ts: Cross-platform commit script using temporary files instead of heredocs"commit": "bun scripts/commit-helper.ts"for easy access vianpm run commit "message"backend/src/system-prompt/prompts.tsto instruct AI agents to use the commit helperPart 2: PowerShell Detection Fix
npm-app/src/terminal/background.ts: Add proper shell detection usingdetectShell()sdk/src/tools/run-terminal-command.ts: Apply same detection logic to SDK-Commandfor PowerShell and/cfor cmd.exedetectShell()functionHow it works
Commit Helper:
git commit -F tempfileto read the messageShell Detection:
Usage
Benefits
This comprehensive solution ensures AI agents can create proper multi-line commits regardless of the operating system or shell environment.
🤖 Generated with Claude Code