# claude-code-source **Repository Path**: honlnk/claude-code-source ## Basic Information - **Project Name**: claude-code-source - **Description**: ClaudeCode源代码 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-04-07 - **Last Updated**: 2026-04-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Claude Code 源码 > 通过 npm source map 泄露提取的 Claude Code TypeScript 源码。 ## 背景 2026-03-31,npm 上意外暴露了 Claude Code 的 source map 文件(`cli.js.map`)。该文件内嵌了完整的 TypeScript 源码(通过 `sourcesContent` 字段),本项目即从中提取而来。 ## 项目构成 - **`src/`** — 从 source map 提取的 Claude Code TypeScript 源码(约 1900 个文件) - **`cli.js.map`** — 原始 source map 文件 ## 源码目录结构 ``` src/ ├── main.tsx # CLI 入口(Commander.js + React/Ink) ├── QueryEngine.ts # 核心 LLM API 引擎 ├── query.ts # Agentic 循环(async generator) ├── Tool.ts # 工具类型定义 ├── tools.ts # 工具注册表 ├── commands.ts # 命令注册表 ├── context.ts # 系统提示词上下文 │ ├── tools/ # 40+ 工具实现 │ ├── AgentTool/ # 子代理生成与协调 │ ├── BashTool/ # Shell 命令执行 │ ├── FileReadTool/ # 文件读取 │ ├── FileEditTool/ # 文件编辑 │ ├── GrepTool/ # 基于 ripgrep 的搜索 │ ├── MCPTool/ # MCP 服务器工具调用 │ └── ... │ ├── services/ # 外部集成 │ ├── api/ # Anthropic API 客户端 │ ├── mcp/ # MCP 服务器管理 │ └── ... │ ├── components/ # React/Ink 终端 UI(400+ 组件) ├── hooks/ # React Hooks ├── commands/ # 命令实现(200+) ├── utils/ # 工具函数(570+) ├── memdir/ # 持久化记忆系统 ├── skills/ # 技能系统 ├── coordinator/ # 多代理编排 └── stubs/ # 缺失模块的占位实现 ``` ## 规模 - 约 **1900** 个源码文件 - **51 万+** 行 TypeScript 代码 - 40+ 工具,100+ 命令,400+ UI 组件 ## 技术栈 | 层级 | 技术 | |------|------| | 运行时 | Bun | | 语言 | TypeScript | | 终端 UI | React + Ink | | CLI | Commander.js | | 验证 | Zod v4 | | 搜索 | ripgrep | | 协议 | MCP SDK, LSP | | API | Anthropic SDK | | 遥测 | OpenTelemetry | ## 声明 - 本仓库仅供**学习研究**用途 - 原始 Claude Code 源码归 **Anthropic** 所有 - 本仓库与 Anthropic 无任何关联