mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
feat: 添加自动邮箱映射功能并完善署名系统
- 新增 attributionEmail.ts 实现模型名到邮箱的自动映射 - 重构署名逻辑,统一使用 getRealModelName() 和 getAttributionEmail() - 将产品名从 Claude Code 更新为 Claude Code Best - 更新 PRODUCT_URL 指向 claude-code-best fork 仓库 Co-Authored-By: glm-4.7 <noreply@zhipuai.cn>
This commit is contained in:
@@ -18,18 +18,12 @@ import {
|
||||
type AttributionData,
|
||||
calculateCommitAttribution,
|
||||
isInternalModelRepo,
|
||||
isInternalModelRepoCached,
|
||||
sanitizeModelName,
|
||||
} from './commitAttribution.js'
|
||||
import { logForDebugging } from './debug.js'
|
||||
import { parseJSONL } from './json.js'
|
||||
import { logError } from './log.js'
|
||||
import {
|
||||
getCanonicalName,
|
||||
getMainLoopModel,
|
||||
getPublicModelDisplayName,
|
||||
getPublicModelName,
|
||||
} from './model/model.js'
|
||||
import { getAttributionEmail } from './attributionEmail.js'
|
||||
import { getRealModelName } from './attributionModel.js'
|
||||
import { isMemoryFileAccess } from './sessionFileAccessHooks.js'
|
||||
import { getTranscriptPath } from './sessionStorage.js'
|
||||
import { readTranscriptForLoad } from './sessionStoragePortable.js'
|
||||
@@ -44,7 +38,8 @@ export type AttributionTexts = {
|
||||
/**
|
||||
* Returns attribution text for commits and PRs based on user settings.
|
||||
* Handles:
|
||||
* - Dynamic model name via getPublicModelName()
|
||||
* - Dynamic model name via getRealModelName()
|
||||
* - Auto email mapping via getAttributionEmail()
|
||||
* - Custom attribution settings (settings.attribution.commit/pr)
|
||||
* - Backward compatibility with deprecated includeCoAuthoredBy setting
|
||||
* - Remote mode: returns session URL for attribution
|
||||
@@ -67,17 +62,10 @@ export function getAttributionTexts(): AttributionTexts {
|
||||
return { commit: '', pr: '' }
|
||||
}
|
||||
|
||||
// @[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.7'
|
||||
const defaultAttribution = `🤖 Generated with [Claude Code](${PRODUCT_URL})`
|
||||
const defaultCommit = `Co-Authored-By: ${modelName} <noreply@anthropic.com>`
|
||||
const modelName = getRealModelName()
|
||||
const email = getAttributionEmail(modelName)
|
||||
const defaultAttribution = `🤖 Generated with [Claude Code Best](${PRODUCT_URL})`
|
||||
const defaultCommit = `Co-Authored-By: ${modelName} <${email}>`
|
||||
|
||||
const settings = getInitialSettings()
|
||||
|
||||
@@ -354,11 +342,8 @@ export async function getEnhancedPRAttribution(
|
||||
`PR Attribution: claudePercent: ${claudePercent}, promptCount: ${promptCount}, memoryAccessCount: ${memoryAccessCount}`,
|
||||
)
|
||||
|
||||
// Get short model name, sanitized for non-internal repos
|
||||
const rawModelName = getCanonicalName(getMainLoopModel())
|
||||
const shortModelName = isInternal
|
||||
? rawModelName
|
||||
: sanitizeModelName(rawModelName)
|
||||
// Get real model name for attribution
|
||||
const realModelName = getRealModelName()
|
||||
|
||||
// If no attribution data, return default
|
||||
if (claudePercent === 0 && promptCount === 0 && memoryAccessCount === 0) {
|
||||
@@ -371,7 +356,7 @@ export async function getEnhancedPRAttribution(
|
||||
memoryAccessCount > 0
|
||||
? `, ${memoryAccessCount} ${memoryAccessCount === 1 ? 'memory' : 'memories'} recalled`
|
||||
: ''
|
||||
const summary = `🤖 Generated with [Claude Code](${PRODUCT_URL}) (${claudePercent}% ${promptCount}-shotted by ${shortModelName}${memSuffix})`
|
||||
const summary = `🤖 Generated with [Claude Code Best](${PRODUCT_URL}) (${claudePercent}% ${promptCount}-shotted by ${realModelName}${memSuffix})`
|
||||
|
||||
// Append trailer lines for squash-merge survival. Only for allowlisted repos
|
||||
// (INTERNAL_MODEL_REPOS) and only in builds with COMMIT_ATTRIBUTION enabled —
|
||||
|
||||
Reference in New Issue
Block a user