feat: add provider-aware model name resolution for attribution (cherry-pick 771e3db + f7f69b7)

- 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.
This commit is contained in:
James Feng 2026-06-04 12:46:51 +08:00
parent 2ea37816a6
commit 379335e3b2
2 changed files with 21 additions and 8 deletions

View File

@ -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} <noreply@anthropic.com>`

View File

@ -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())
}