From b14fab2340680b1af33bd55160398af1038effd8 Mon Sep 17 00:00:00 2001 From: umutcagand Date: Mon, 24 Aug 2026 00:30:14 +0300 Subject: [PATCH 1/3] chore: refresh fix/freebuff-commit-attribution onto current main --- .../run-terminal-command-branding.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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') + }) +}) From 1e865162c09af0740b2aacad6de772fd7027201e Mon Sep 17 00:00:00 2001 From: umutcagand Date: Mon, 24 Aug 2026 00:30:16 +0300 Subject: [PATCH 2/3] chore: refresh fix/freebuff-commit-attribution onto current main --- .../tools/params/tool/run-terminal-command.ts | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/common/src/tools/params/tool/run-terminal-command.ts b/common/src/tools/params/tool/run-terminal-command.ts index 197c02f3c7..f0418e28f3 100644 --- a/common/src/tools/params/tool/run-terminal-command.ts +++ b/common/src/tools/params/tool/run-terminal-command.ts @@ -65,7 +65,22 @@ export const terminalCommandOutputSchema = z.union([ }), ]) -export const gitCommitGuidePrompt = ` +const isFreebuffBuild = process.env.FREEBUFF_MODE === 'true' + +/** + * Build commit guidance for the product that owns the current binary. + * + * FREEBUFF_MODE is a compile-time flag for the Freebuff CLI build. Keeping the + * default in this shared prompt preserves Codebuff's existing attribution + * while Freebuff binaries no longer ask models to claim Codebuff commits. + */ +export const getGitCommitGuidePrompt = ( + isFreebuff = isFreebuffBuild, +): string => { + const productName = isFreebuff ? 'Freebuff' : 'Codebuff' + const productDomain = isFreebuff ? 'freebuff.com' : 'codebuff.com' + + return ` ### Using git to commit changes 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: 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 +130,11 @@ 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 commitProductName = isFreebuffBuild ? 'Freebuff' : 'Codebuff' +const commitProductDomain = isFreebuffBuild ? 'freebuff.com' : 'codebuff.com' const toolName = 'run_terminal_command' const endsAgentStep = true @@ -195,8 +215,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 12835624ec287b0c4b6356dfbf6c7bf088396f3f Mon Sep 17 00:00:00 2001 From: umutcagand Date: Mon, 24 Aug 2026 20:12:55 +0300 Subject: [PATCH 3/3] refactor(common): share commit attribution metadata --- .../tools/params/tool/run-terminal-command.ts | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/common/src/tools/params/tool/run-terminal-command.ts b/common/src/tools/params/tool/run-terminal-command.ts index f0418e28f3..8fab3c7144 100644 --- a/common/src/tools/params/tool/run-terminal-command.ts +++ b/common/src/tools/params/tool/run-terminal-command.ts @@ -65,20 +65,34 @@ export const terminalCommandOutputSchema = z.union([ }), ]) +// 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. * - * FREEBUFF_MODE is a compile-time flag for the Freebuff CLI build. Keeping the - * default in this shared prompt preserves Codebuff's existing attribution - * while Freebuff binaries no longer ask models to claim Codebuff commits. + * 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 = isFreebuff ? 'Freebuff' : 'Codebuff' - const productDomain = isFreebuff ? 'freebuff.com' : 'codebuff.com' + const { productName, productDomain } = getCommitAttribution(isFreebuff) return ` ### Using git to commit changes @@ -133,8 +147,10 @@ When the user requests a new git commit, please follow these steps closely: } export const gitCommitGuidePrompt = getGitCommitGuidePrompt() -const commitProductName = isFreebuffBuild ? 'Freebuff' : 'Codebuff' -const commitProductDomain = isFreebuffBuild ? 'freebuff.com' : 'codebuff.com' +const { + productName: commitProductName, + productDomain: commitProductDomain, +} = buildCommitAttribution const toolName = 'run_terminal_command' const endsAgentStep = true