1、claude code源代码是如何泄漏的😱?
2026年3月31号Anthropic 在发布 @anthropic-ai/claude-code-2.1.88 npm包时将cli.js.map map文件也打进了包里,根据这个map文件可以把编译/压缩后的js还原成原始TypeScript代码。
紧接着在x上有人就发现了这一事件:

恢复流程:
1)下载claude-code@2.1.88 npm包:
bash
npm pack @anthropic-ai/claude-code@2.1.88
tar -xvzf anthropic-ai-claude-code-2.1.88.tgz
cd package/
$ ll
total 142488
drwxr-xr-x@ 10 320 4 5 00:11 ./
drwxr-xr-x@ 4 128 4 5 00:11 ../
-rw-r--r--@ 1 596 10 26 1985 bun.lock
-rwxr-xr-x@ 1 13047043 10 26 1985 cli.js*
-rw-r--r--@ 1 59766257 10 26 1985 cli.js.map
-rw-r--r--@ 1 147 10 26 1985 LICENSE.md
-rw-r--r--@ 1 1242 10 26 1985 package.json
-rw-r--r--@ 1 2037 10 26 1985 README.md
-rw-r--r--@ 1 116949 10 26 1985 sdk-tools.d.ts
drwxr-xr-x@ 4 128 4 5 00:11 vendor/
#cli.js.map 这个文件便是整个时间的罪魁祸首😢
2)创建一个recover.js
bash
import fs from "fs";
import path from "path";
const map = JSON.parse(fs.readFileSync("cli.js.map", "utf-8"));
if (!map.sources || !map.sourcesContent) {
console.error("❌ 没有 sourcesContent,无法直接还原");
process.exit(1);
}
map.sources.forEach((file, i) => {
const content = map.sourcesContent[i];
if (!content) return;
const filePath = path.join("recovered", file);
// 创建目录
fs.mkdirSync(path.dirname(filePath), { recursive: true });
// 写文件
fs.writeFileSync(filePath, content);
});
console.log("✅ 源码还原完成 -> ./recovered");
3)运行recover.js
bash
node recover.js
#执行成功后就会多了src目录,包含了 4756 个源文件😂
drwxr-xr-x@ 13 416 4 5 00:14 ./
drwxr-xr-x@ 4 128 4 5 00:11 ../
-rw-r--r--@ 1 596 10 26 1985 bun.lock
-rwxr-xr-x@ 1 13047043 10 26 1985 cli.js*
-rw-r--r--@ 1 59766257 10 26 1985 cli.js.map
-rw-r--r--@ 1 147 10 26 1985 LICENSE.md
drwxr-xr-x@ 194 6208 4 5 00:14 node_modules/
-rw-r--r--@ 1 1242 10 26 1985 package.json
-rw-r--r--@ 1 2037 10 26 1985 README.md
-rw-r--r--@ 1 588 4 5 00:14 recover.js
-rw-r--r--@ 1 116949 10 26 1985 sdk-tools.d.ts
drwxr-xr-x@ 55 1760 4 5 00:14 src/
2、编译源代码、运行
泄漏的源码包含完整的 TypeScript/TSX 源码树,但缺少编译所需的构建配置。所以无法直接编译,需要进行修改。
https://github.com/lanjingling/open-claude-code这个本仓库提供了使源代码可编译和可打包的必要构建基础设施,同时完整保留了原始源代码。可供学习,二次开发。
1)编译:
bash
# 克隆仓库
git clone https://github.com/lanjingling/open-claude-code.git
cd open-claude-code
# 安装依赖
npm install --ignore-scripts
# 打包(以下两种方法二选一)
#【推荐】使用 Bun 打包(单文件输出 → dist/cli.js)
bun run build
# 或使用 TypeScript 编译
npm run build:tsc
2)运行:
bash
# 测试版本输出
node dist/cli.js --version
# 输出: open-claude-code-1.0.0 (based on Claude Code-2.1.88)
# 交互模式(需要 API Key)
ANTHROPIC_BASE_URL="https://xxx/anthropic" \
ANTHROPIC_API_KEY="sk_xxx" \
ANTHROPIC_MODEL="claude-sonnet-4-20250514" \
DISABLE_TELEMETRY=1 \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
node dist/cli.js
说明:
- DISABLE_TELEMETRY和CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1主要用来避免远程遥测和非必要网络请求。
- 可以在国内购买一个大模型api账号(比如:接口ai)
- 为了方便,可将以上环境变量export到或项目(<项目>/.claude/setting.json)的配置文件 env 字段中(和官方一致)。例如:
bash
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-xxx",
"ANTHROPIC_BASE_URL": "https://xxx/anthropic",
"ANTHROPIC_MODEL": "claude-sonnet-4-20250514"
}
}
启动后界面如下:

这就是目前估值3800亿美金最牛ai coding公司的产品代码运行效果😂
3、修改内容总结
1)新增构建脚本:
- tsconfig.json:TypeScript 编译配置,无运行时影响
- build.ts:Bun 构建脚本,无运行时影响
2)新增存根文件:
在src下建立了107个存根文件,这些是 Anthropic 内部 Bun 构建时通过 feature() 标志进行死代码消除所删掉的模块的最小存根。
|-------------------|------|-----------------------------------------------------------------------------------|
| 空模块(export {};) | ~60 | 无 --- 仅满足模块解析 |
| 纯类型存根(interface) | ~30 | 无 --- 无运行时效果 |
| 运行时存根(空函数) | ~17 | 实际无影响 --- 这些模块位于 feature() 标志守护的代码路径上,在 external build 中始终为 false,永远不会被执行 |
修改package.json:添加了 70+ 个 npm 依赖和构建脚本,原始 `dependencies` 为空(所有依赖被打包),新增依赖仅用于编译
修改src/entrypoints/sdk/coreTypes.generated.ts:追加了约 120 行类型定义 + 1 个函数,因为原始生成文件在发布时被截断。补充的类型根据代码库中的使用方式推断。
3)关闭所有 Anthropic 内部功能:
KAIROS(助手模式)、DAEMON、BRIDGE_MODE、CHICAGO_MCP(计算机使用)、COORDINATOR_MODE、SSH_REMOTE、WORKFLOW_SCRIPTS 等90+)。与官方公开发布版行为一致,因为公开版本的这些功能本来就是关闭的。