Skip to content

Commit 390712a

Browse files
fix(common): use product-specific commit attribution
1 parent 366311e commit 390712a

2 files changed

Lines changed: 48 additions & 7 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { describe, expect, it } from 'bun:test'
2+
3+
import { getGitCommitGuidePrompt } from '../run-terminal-command'
4+
5+
describe('getGitCommitGuidePrompt', () => {
6+
it('keeps Codebuff attribution for the standard build', () => {
7+
const prompt = getGitCommitGuidePrompt(false)
8+
9+
expect(prompt).toContain('Generated with Codebuff 🤖')
10+
expect(prompt).toContain('Co-Authored-By: Codebuff <noreply@codebuff.com>')
11+
expect(prompt).not.toContain('Generated with Freebuff')
12+
})
13+
14+
it('uses Freebuff attribution for Freebuff builds', () => {
15+
const prompt = getGitCommitGuidePrompt(true)
16+
17+
expect(prompt).toContain('Generated with Freebuff 🤖')
18+
expect(prompt).toContain('Co-Authored-By: Freebuff <noreply@freebuff.com>')
19+
expect(prompt).not.toContain('Generated with Codebuff')
20+
})
21+
})

common/src/tools/params/tool/run-terminal-command.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ export const terminalCommandOutputSchema = z.union([
6565
}),
6666
])
6767

68-
export const gitCommitGuidePrompt = `
68+
const isFreebuffBuild = process.env.FREEBUFF_MODE === 'true'
69+
70+
/**
71+
* Build commit guidance for the product that owns the current binary.
72+
*
73+
* FREEBUFF_MODE is a compile-time flag for the Freebuff CLI build. Keeping the
74+
* default in this shared prompt preserves Codebuff's existing attribution
75+
* while Freebuff binaries no longer ask models to claim Codebuff commits.
76+
*/
77+
export const getGitCommitGuidePrompt = (
78+
isFreebuff = isFreebuffBuild,
79+
): string => {
80+
const productName = isFreebuff ? 'Freebuff' : 'Codebuff'
81+
const productDomain = isFreebuff ? 'freebuff.com' : 'codebuff.com'
82+
83+
return `
6984
### Using git to commit changes
7085
7186
When the user requests a new git commit, please follow these steps closely:
@@ -92,16 +107,16 @@ When the user requests a new git commit, please follow these steps closely:
92107
93108
4. **Create the commit, ending with this specific footer:**
94109
\`\`\`
95-
Generated with Codebuff 🤖
96-
Co-Authored-By: Codebuff <noreply@codebuff.com>
110+
Generated with ${productName} 🤖
111+
Co-Authored-By: ${productName} <noreply@${productDomain}>
97112
\`\`\`
98113
Commands run in bash on every OS (Git Bash on Windows), so always use HEREDOC syntax to format the message:
99114
\`\`\`
100115
git commit -m "$(cat <<'EOF'
101116
Your commit message here.
102117
103-
🤖 Generated with Codebuff
104-
Co-Authored-By: Codebuff <noreply@codebuff.com>
118+
🤖 Generated with ${productName}
119+
Co-Authored-By: ${productName} <noreply@${productDomain}>
105120
EOF
106121
)"
107122
\`\`\`
@@ -115,6 +130,11 @@ When the user requests a new git commit, please follow these steps closely:
115130
- Do not create an empty commit if there are no changes.
116131
- Make sure your commit message is concise yet descriptive, focusing on the intention behind the changes rather than merely describing them.
117132
`
133+
}
134+
135+
export const gitCommitGuidePrompt = getGitCommitGuidePrompt()
136+
const commitProductName = isFreebuffBuild ? 'Freebuff' : 'Codebuff'
137+
const commitProductDomain = isFreebuffBuild ? 'freebuff.com' : 'codebuff.com'
118138

119139
const toolName = 'run_terminal_command'
120140
const endsAgentStep = true
@@ -195,8 +215,8 @@ ${$getNativeToolCallExampleString({
195215
input: {
196216
command: `git commit -m "Your commit message here.
197217
198-
🤖 Generated with Codebuff
199-
Co-Authored-By: Codebuff <noreply@codebuff.com>"`,
218+
🤖 Generated with ${commitProductName}
219+
Co-Authored-By: ${commitProductName} <noreply@${commitProductDomain}>"`,
200220
},
201221
endsAgentStep,
202222
})}

0 commit comments

Comments
 (0)