diff --git a/common/src/tools/params/tool/__tests__/run-terminal-command-branding.test.ts b/common/src/tools/params/tool/__tests__/run-terminal-command-branding.test.ts new file mode 100644 index 0000000000..4f66c70676 --- /dev/null +++ b/common/src/tools/params/tool/__tests__/run-terminal-command-branding.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from 'bun:test' + +import { getGitCommitGuidePrompt } from '../run-terminal-command' + +describe('getGitCommitGuidePrompt', () => { + it('keeps Codebuff attribution for the standard build', () => { + const prompt = getGitCommitGuidePrompt(false) + + expect(prompt).toContain('Generated with Codebuff 🤖') + expect(prompt).toContain('Co-Authored-By: Codebuff ') + expect(prompt).not.toContain('Generated with Freebuff') + }) + + it('uses Freebuff attribution for Freebuff builds', () => { + const prompt = getGitCommitGuidePrompt(true) + + expect(prompt).toContain('Generated with Freebuff 🤖') + expect(prompt).toContain('Co-Authored-By: Freebuff ') + expect(prompt).not.toContain('Generated with Codebuff') + }) +}) diff --git a/common/src/tools/params/tool/run-terminal-command.ts b/common/src/tools/params/tool/run-terminal-command.ts index 197c02f3c7..8fab3c7144 100644 --- a/common/src/tools/params/tool/run-terminal-command.ts +++ b/common/src/tools/params/tool/run-terminal-command.ts @@ -65,7 +65,36 @@ export const terminalCommandOutputSchema = z.union([ }), ]) -export const gitCommitGuidePrompt = ` +// FREEBUFF_MODE is injected for Freebuff builds and read once when this module +// is initialized. Tests pass an explicit product flag to the prompt builder so +// they do not depend on mutating process.env after import. +const isFreebuffBuild = process.env.FREEBUFF_MODE === 'true' + +type CommitAttribution = { + productName: 'Freebuff' | 'Codebuff' + productDomain: 'freebuff.com' | 'codebuff.com' +} + +function getCommitAttribution(isFreebuff: boolean): CommitAttribution { + return isFreebuff + ? { productName: 'Freebuff', productDomain: 'freebuff.com' } + : { productName: 'Codebuff', productDomain: 'codebuff.com' } +} + +const buildCommitAttribution = getCommitAttribution(isFreebuffBuild) + +/** + * Build commit guidance for the product that owns the current binary. + * + * Keeping Codebuff as the default preserves existing attribution while + * Freebuff binaries no longer ask models to claim Codebuff commits. + */ +export const getGitCommitGuidePrompt = ( + isFreebuff = isFreebuffBuild, +): string => { + const { productName, productDomain } = getCommitAttribution(isFreebuff) + + return ` ### Using git to commit changes When the user requests a new git commit, please follow these steps closely: @@ -92,16 +121,16 @@ When the user requests a new git commit, please follow these steps closely: 4. **Create the commit, ending with this specific footer:** \`\`\` - Generated with Codebuff 🤖 - Co-Authored-By: Codebuff + Generated with ${productName} 🤖 + Co-Authored-By: ${productName} \`\`\` Commands run in bash on every OS (Git Bash on Windows), so always use HEREDOC syntax to format the message: \`\`\` git commit -m "$(cat <<'EOF' Your commit message here. - 🤖 Generated with Codebuff - Co-Authored-By: Codebuff + 🤖 Generated with ${productName} + Co-Authored-By: ${productName} EOF )" \`\`\` @@ -115,6 +144,13 @@ When the user requests a new git commit, please follow these steps closely: - Do not create an empty commit if there are no changes. - Make sure your commit message is concise yet descriptive, focusing on the intention behind the changes rather than merely describing them. ` +} + +export const gitCommitGuidePrompt = getGitCommitGuidePrompt() +const { + productName: commitProductName, + productDomain: commitProductDomain, +} = buildCommitAttribution const toolName = 'run_terminal_command' const endsAgentStep = true @@ -195,8 +231,8 @@ ${$getNativeToolCallExampleString({ input: { command: `git commit -m "Your commit message here. -🤖 Generated with Codebuff -Co-Authored-By: Codebuff "`, +🤖 Generated with ${commitProductName} +Co-Authored-By: ${commitProductName} "`, }, endsAgentStep, })}