Skip to content

Commit a9d3773

Browse files
sanbuphyclaude
andcommitted
添加 README: 项目结构说明
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent a988ee1 commit a9d3773

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Claude Code v2.1.88 Source Code
2+
3+
From npm package `@anthropic-ai/claude-code` version **2.1.88**.
4+
5+
The published package ships a single bundled `cli.js` (~12MB). The `src/` directory in this repo contains the **decompiled/unbundled TypeScript source** extracted from the npm tarball.
6+
7+
## Stats
8+
9+
| Item | Count |
10+
|------|-------|
11+
| Source files (.ts/.tsx) | ~1,884 |
12+
| Lines of code | ~512,664 |
13+
| Dependencies (node_modules) | ~192 packages |
14+
15+
## Directory Structure
16+
17+
```
18+
src/
19+
├── main.tsx # Main entry (~4,683 lines)
20+
├── QueryEngine.ts # Core query lifecycle engine
21+
├── query.ts # Query main loop (~785KB, largest file)
22+
├── Tool.ts # Tool interface + buildTool factory
23+
├── Task.ts # Task types and lifecycle
24+
├── tools.ts # Tool registry and presets
25+
├── bridge/ # Bridge to Claude Desktop / remote
26+
├── cli/ # CLI handlers and transports
27+
├── commands/ # Slash commands (~80+)
28+
├── components/ # React/Ink terminal UI
29+
├── entrypoints/ # CLI, SDK, MCP entry points
30+
├── hooks/ # React hooks
31+
├── screens/ # REPL and other screens
32+
├── services/ # API, analytics, MCP, compact, plugins
33+
├── state/ # AppState management
34+
├── tasks/ # Task implementations (bash, agent, remote)
35+
├── tools/ # Tool implementations (~40+)
36+
│ ├── AgentTool/ # Sub-agent spawning
37+
│ ├── BashTool/ # Shell execution
38+
│ ├── FileEditTool/ # File editing
39+
│ ├── FileReadTool/ # File reading
40+
│ ├── FileWriteTool/ # File writing
41+
│ ├── GlobTool/ # File glob search
42+
│ ├── GrepTool/ # Content grep search
43+
│ ├── MCPTool/ # MCP protocol tools
44+
│ ├── WebFetchTool/ # Web fetching
45+
│ └── ... # 30+ more tools
46+
├── types/ # TypeScript type definitions
47+
├── utils/ # Utilities
48+
└── vendor/ # Native module source stubs
49+
```
50+
51+
## Key Architecture
52+
53+
- **Runtime**: Bun (uses `bun:bundle` feature flags, macros)
54+
- **UI**: React + Ink (terminal rendering)
55+
- **API**: Anthropic Claude API with streaming
56+
- **Protocol**: MCP (Model Context Protocol) for tool extensions
57+
- **Build**: Bun bundler produces single `cli.js` with dead code elimination
58+
59+
## Notes
60+
61+
- This source is **not directly compilable** — it lacks `tsconfig.json`, build scripts, and the full Bun build pipeline
62+
- Feature flags (`feature('...')`) are compile-time gated via Bun's dead code elimination
63+
- `process.env.USER_TYPE === 'ant'` sections are Anthropic-internal only
64+
- The compiled `cli.js` is a self-contained bundle requiring only Node.js >= 18
65+
66+
## License
67+
68+
See the original package for license information.

0 commit comments

Comments
 (0)