Skip to content

Commit 7329b67

Browse files
Update agent to automatically use cross-platform commit helper
- Modified system prompts to instruct agent to use commit-helper.js - Updated git utilities to call commit helper as primary method - Resolves automatic heredoc issue handling for agent commits Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 0dd0519 commit 7329b67

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

backend/src/system-prompt/prompts.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -268,38 +268,31 @@ When the user requests a new git commit, please follow these steps closely:
268268
- Refrain from using tools to inspect code beyond what is presented in the git context.
269269
- Evaluate the overall impact on the project.
270270
- Check for sensitive details that should not be committed.
271-
- Draft a concise, one- to two-sentence commit message focusing on the why rather than the what.
271+
- Draft a concise, one- to two-sentence commit message focusing on the "why" rather than the "what."
272272
- Use precise, straightforward language that accurately represents the changes.
273-
- Ensure the message provides clarity—avoid generic or vague terms like Update or Fix without context.
273+
- Ensure the message provides clarity—avoid generic or vague terms like "Update" or "Fix" without context.
274274
- Revisit your draft to confirm it truly reflects the changes and their intention.
275275
276-
4. **Create the commit, ending with this specific footer:**
277-
\`\`\`
278-
Generated with Codebuff 🤖
279-
Co-Authored-By: Codebuff <noreply@codebuff.com>
280-
\`\`\`
281-
To maintain proper formatting, use cross-platform compatible commit messages:
276+
4. **Create the commit using the cross-platform commit helper:**
277+
278+
**Always use the cross-platform commit helper** to ensure compatibility across all platforms:
282279
283-
**For Unix/bash shells:**
284280
\`\`\`
285-
git commit -m "$(cat <<'EOF'
286-
Your commit message here.
287-
288-
🤖 Generated with Codebuff
289-
Co-Authored-By: Codebuff <noreply@codebuff.com>
290-
EOF
291-
)"
281+
node scripts/commit-helper.js "Your commit message here" "🤖 Generated with Codebuff" "Co-Authored-By: Codebuff <noreply@codebuff.com>"
292282
\`\`\`
293283
294-
**For Windows Command Prompt:**
284+
The commit helper automatically:
285+
- Handles cross-platform compatibility (Windows, macOS, Linux)
286+
- Formats multiline commit messages properly
287+
- Adds factory-droid co-author attribution
288+
- Uses temporary files to avoid shell escaping issues
289+
290+
For simple commits with just Codebuff attribution:
295291
\`\`\`
296-
git commit -m "Your commit message here.
297-
298-
🤖 Generated with Codebuff
299-
Co-Authored-By: Codebuff <noreply@codebuff.com>"
292+
node scripts/commit-helper.js "Your commit message here 🤖 Generated with Codebuff"
300293
\`\`\`
301294
302-
Always detect the platform and use the appropriate syntax. HEREDOC syntax (\`<<'EOF'\`) only works in bash/Unix shells and will fail on Windows Command Prompt.
295+
**NEVER use heredoc syntax** (\`<<'EOF'\`) or direct \`git commit -m\` with complex messages as they fail on Windows Command Prompt.
303296
304297
**Important details**
305298

common/src/util/git.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ export function getStagedChanges(): string {
2525

2626
export function commitChanges(commitMessage: string) {
2727
try {
28-
execSync(`git commit -m "${commitMessage}"`, { stdio: 'ignore', maxBuffer })
29-
} catch (error) {}
28+
// Use cross-platform commit helper to avoid heredoc issues on Windows
29+
execSync(`node scripts/commit-helper.js "${commitMessage}"`, { stdio: 'inherit', maxBuffer })
30+
} catch (error) {
31+
// Fallback to direct git commit if helper is not available
32+
try {
33+
execSync(`git commit -m "${commitMessage}"`, { stdio: 'ignore', maxBuffer })
34+
} catch (fallbackError) {}
35+
}
3036
}
3137

3238
export function stageAllChanges(): boolean {

0 commit comments

Comments
 (0)