From 8006dfe3f9ab492e78bf1d2d3f4534cf86f0c0ef Mon Sep 17 00:00:00 2001 From: umutcagand Date: Tue, 1 Sep 2026 09:52:37 +0300 Subject: [PATCH 1/2] fix(common): use product-specific commit attribution --- .../run-terminal-command-branding.test.ts | 21 ++++++++ .../tools/params/tool/run-terminal-command.ts | 50 ++++++++++++++++--- 2 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 common/src/tools/params/tool/__tests__/run-terminal-command-branding.test.ts 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, })} From 6b573c5a095566fa8473657a8648ada89e205b6a Mon Sep 17 00:00:00 2001 From: c8dhjp4tyv-bit Date: Tue, 1 Sep 2026 17:17:47 +0000 Subject: [PATCH 2/2] refactor(common): reuse build commit attribution --- common/src/tools/params/tool/run-terminal-command.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/tools/params/tool/run-terminal-command.ts b/common/src/tools/params/tool/run-terminal-command.ts index 8fab3c7144..ef95bfbc4e 100644 --- a/common/src/tools/params/tool/run-terminal-command.ts +++ b/common/src/tools/params/tool/run-terminal-command.ts @@ -90,9 +90,12 @@ const buildCommitAttribution = getCommitAttribution(isFreebuffBuild) * Freebuff binaries no longer ask models to claim Codebuff commits. */ export const getGitCommitGuidePrompt = ( - isFreebuff = isFreebuffBuild, + isFreebuff?: boolean, ): string => { - const { productName, productDomain } = getCommitAttribution(isFreebuff) + const { productName, productDomain } = + isFreebuff === undefined + ? buildCommitAttribution + : getCommitAttribution(isFreebuff) return ` ### Using git to commit changes