From 379335e3b2176d939079c3967e543e13a7219dde Mon Sep 17 00:00:00 2001 From: James Feng <47167674+GhostDragon124@users.noreply.github.com> Date: Thu, 4 Jun 2026 12:46:51 +0800 Subject: [PATCH] feat: add provider-aware model name resolution for attribution (cherry-pick 771e3db + f7f69b7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add attributionModel.ts: getRealModelName() resolves model names for OpenAI/Gemini providers, so Git commit sign-off shows correct model name (DeepSeek/GPT/Gemini) instead of Anthropic default. - Wire into attribution.ts: replace multi-branch fallback logic with simple getRealModelName() call. - CCP's APIProvider doesn't include 'grok' — skipped that case. --- src/utils/attribution.ts | 11 +++-------- src/utils/attributionModel.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/utils/attributionModel.ts diff --git a/src/utils/attribution.ts b/src/utils/attribution.ts index d76291637..4c79417f0 100644 --- a/src/utils/attribution.ts +++ b/src/utils/attribution.ts @@ -21,6 +21,7 @@ import { isInternalModelRepoCached, sanitizeModelName, } from './commitAttribution.js' +import { getRealModelName } from './attributionModel.js' import { logForDebugging } from './debug.js' import { parseJSONL } from './json.js' import { logError } from './log.js' @@ -68,14 +69,8 @@ export function getAttributionTexts(): AttributionTexts { } // @[MODEL LAUNCH]: Update the hardcoded fallback model name below (guards against codename leaks). - // For internal repos, use the real model name. For external repos, - // fall back to "Claude Opus 4.6" for unrecognized models to avoid leaking codenames. - const model = getMainLoopModel() - const isKnownPublicModel = getPublicModelDisplayName(model) !== null - const modelName = - isInternalModelRepoCached() || isKnownPublicModel - ? getPublicModelName(model) - : 'Claude Opus 4.6' + // Uses getRealModelName() for provider-aware model resolution (DeepSeek/Gemini/Grok → correct name). + const modelName = getRealModelName() || 'Claude Opus 4.6' const defaultAttribution = `🤖 Generated with [Claude Code](${PRODUCT_URL})` const defaultCommit = `Co-Authored-By: ${modelName} ` diff --git a/src/utils/attributionModel.ts b/src/utils/attributionModel.ts new file mode 100644 index 000000000..a45c3c545 --- /dev/null +++ b/src/utils/attributionModel.ts @@ -0,0 +1,18 @@ +import { resolveGeminiModel, resolveOpenAIModel } from '@ant/model-provider' +import { getMainLoopModel } from './model/model.js' +import { getAPIProvider } from './model/providers.js' + +function resolveProviderModel(anthropicModel: string): string { + switch (getAPIProvider()) { + case 'openai': + return resolveOpenAIModel(anthropicModel) + case 'gemini': + return resolveGeminiModel(anthropicModel) + default: + return anthropicModel + } +} + +export function getRealModelName(): string { + return resolveProviderModel(getMainLoopModel()) +}