mirror of
https://github.com/sanbuphy/claude-code-source-code.git
synced 2026-04-03 11:34:54 +08:00
init repo
This commit is contained in:
94
docs/zh/03-卧底模式分析.md
Normal file
94
docs/zh/03-卧底模式分析.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# 卧底模式分析
|
||||
|
||||
> 基于网络公开资料与社区讨论整理的 Claude Code v2.1.88 分析报告。
|
||||
|
||||
## 什么是卧底模式?
|
||||
|
||||
卧底模式是供官方内部员工在外部/开源仓库工作时使用的一种安全防护机制。激活后,系统会隐藏内部特有的 AI 模型信息及归属标识,使提交的代码与人类开发者的贡献形式保持一致。此举主要为了防止内部机密和未发布模型的名称在开源社区中泄露。
|
||||
|
||||
来源: `src/utils/undercover.ts`
|
||||
|
||||
## 激活逻辑
|
||||
|
||||
```typescript
|
||||
// src/utils/undercover.ts:28-37
|
||||
export function isUndercover(): boolean {
|
||||
if (process.env.USER_TYPE === 'ant') {
|
||||
if (isEnvTruthy(process.env.CLAUDE_CODE_UNDERCOVER)) return true
|
||||
// 自动模式:除非确认在白名单内部仓库,否则默认激活
|
||||
return getRepoClassCached() !== 'internal'
|
||||
}
|
||||
return false
|
||||
}
|
||||
```
|
||||
|
||||
关键特性:
|
||||
- **仅限内部**: 只对官方员工 (`USER_TYPE === 'ant'`) 生效
|
||||
- **默认开启**: 在所有仓库中激活,除非在内部白名单上
|
||||
- **无法强制关闭**: 为了防止模型代号泄露,没有提供关闭选项
|
||||
- **外部构建**: 对普通用户版本不生效,相关代码在打包时会被消除
|
||||
|
||||
## 给模型的指令
|
||||
|
||||
```
|
||||
## UNDERCOVER MODE — CRITICAL
|
||||
|
||||
You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository.
|
||||
Do not blow your cover.
|
||||
|
||||
NEVER include in commit messages or PR descriptions:
|
||||
- 内部模型代号(如 Capybara, Tengu 等动物名称)
|
||||
- 未发布的模型版本号(如 opus-4-7, sonnet-4-8)
|
||||
- 内部仓库或项目名(如 claude-cli-internal)
|
||||
- 内部工具、Slack 频道或短链接
|
||||
- "Claude Code" 这个词或任何你是 AI 的暗示
|
||||
- 任何关于你是什么模型或版本的提示
|
||||
- Co-Authored-By 行或任何其他归属
|
||||
|
||||
像人类开发者一样写 commit message。
|
||||
|
||||
好:
|
||||
- "Fix race condition in file watcher initialization"
|
||||
|
||||
坏:
|
||||
- "Fix bug found while testing with Claude Capybara"
|
||||
- "Generated with Claude Code"
|
||||
- "Co-Authored-By: Claude Opus 4.6 <…>"
|
||||
```
|
||||
|
||||
关键词:**"Do not blow your cover"**(旨在要求模型隐藏其内部身份,确保不会在外部泄露未公开信息)。
|
||||
|
||||
## 归属系统
|
||||
|
||||
归属系统同样配合了这一模式:
|
||||
|
||||
```typescript
|
||||
// src/utils/model/model.ts:386-392
|
||||
function maskModelCodename(baseName: string): string {
|
||||
// capybara-v2-fast → cap*****-v2-fast
|
||||
const [codename = '', ...rest] = baseName.split('-')
|
||||
const masked = codename.slice(0, 3) + '*'.repeat(Math.max(0, codename.length - 3))
|
||||
return [masked, ...rest].join('-')
|
||||
}
|
||||
```
|
||||
|
||||
## 影响
|
||||
|
||||
### 对开源社区的影响
|
||||
|
||||
当官方员工使用 Claude Code 参与开源项目时:
|
||||
1. 提交记录不会带有 "Co-Authored-By: Claude" 等明显的 AI 署名
|
||||
2. 缺乏 "Generated with Claude Code" 等标记
|
||||
3. 这在一定程度上模糊了代码是由 AI 辅助生成还是由人类直接编写的界限
|
||||
4. 在开源社区中,有关 AI 贡献的透明度规范正在建立,这种做法可能引发一些关于透明度的讨论
|
||||
|
||||
### 对官方的保护
|
||||
|
||||
主要声明的目的是防止意外泄露公司机密:
|
||||
- 内部模型代号(涉及竞争情报)
|
||||
- 未发布的版本号(涉及产品发布节奏)
|
||||
- 内部基础设施细节(涉及系统安全)
|
||||
|
||||
### 行业考量
|
||||
|
||||
"卧底模式" 这种设计展现了企业在保护商业机密与遵循开源透明度之间所面临的平衡挑战。在公开代码贡献中隐去 AI 身份,一方面有效防止了机密泄露,但另一方面也引发了业界关于代码归属透明度和贡献指南遵循情况的思考。
|
||||
Reference in New Issue
Block a user