[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74948":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},74948,"claude-code","tanbiralam\u002Fclaude-code","tanbiralam","Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands. All original source code is the property of Anthropic.","https:\u002F\u002Fx.com\u002FFried_rice\u002Fstatus\u002F2038894956459290963",null,"TypeScript",1842,2602,31,4,0,20,52,190,60,23,false,"main",true,[5,26],"claude-code-source-code","2026-06-12 02:03:30","# Claude Code — Leaked Source (2026-03-31)\n\n> **On March 31, 2026, the full source code of Anthropic's Claude Code CLI was leaked** via a `.map` file exposed in their npm registry.\n\n---\n\n## How It Leaked\n\n[Chaofan Shou (@Fried_rice)](https:\u002F\u002Fx.com\u002FFried_rice) discovered the leak and posted it publicly:\n\n> **\"Claude code source code has been leaked via a map file in their npm registry!\"**\n>\n> — [@Fried_rice, March 31, 2026](https:\u002F\u002Fx.com\u002FFried_rice\u002Fstatus\u002F2038894956459290963)\n\nThe source map file in the published npm package contained a reference to the full, unobfuscated TypeScript source, which was downloadable as a zip archive from Anthropic's R2 storage bucket.\n\n---\n\n## Quick Setup\n\n### Prerequisites\n\n- **[Bun](https:\u002F\u002Fbun.sh)** v1.3+ (the project's runtime)\n- **Node.js** v18+ (for npm package installation)\n- An **Anthropic API key** (set as `ANTHROPIC_API_KEY` environment variable)\n\n### Install & Run\n\n```bash\n# 1. Install Bun (if not already installed)\ncurl -fsSL https:\u002F\u002Fbun.sh\u002Finstall | bash\nsource ~\u002F.bash_profile  # or restart your terminal\n\n# 2. Install dependencies\nnpm install --legacy-peer-deps\n\n# 3. Run Claude Code\nbun run start\n\n# Or with arguments:\nbun run start -- --help\nbun run start -- --version\nbun run start -- -p \"Hello Claude\"\n```\n\n### Available Scripts\n\n| Script | Description |\n|--------|-------------|\n| `bun run start` | Run Claude Code CLI |\n| `bun run dev` | Run with hot-reloading (--watch) |\n| `bun run build` | Bundle for production |\n| `bun run typecheck` | Run TypeScript type checking |\n\n### Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `ANTHROPIC_API_KEY` | Your Anthropic API key (required to use Claude) |\n| `FEATURE_FLAGS` | Comma-separated list of feature flags to enable (e.g., `KAIROS,VOICE_MODE`) |\n\n### Notes\n\n- Some modules from the original source were not included in the leak (Anthropic-internal `@ant\u002F*` packages, some tools). These have been replaced with stubs that export no-ops.\n- The `bun:bundle` feature flag system is shimmed via a Bun plugin at `plugins\u002FbunBundleDev.ts`. All flags default to `false` unless enabled via `FEATURE_FLAGS`.\n- The `MACRO.*` build-time constants are defined in `bunfig.toml` and injected by Bun's `--define` system.\n\n---\n\n## Overview\n\nClaude Code is Anthropic's official CLI tool that lets you interact with Claude directly from the terminal to perform software engineering tasks — editing files, running commands, searching codebases, managing git workflows, and more.\n\nThis repository contains the leaked `src\u002F` directory.\n\n- **Leaked on**: 2026-03-31\n- **Language**: TypeScript\n- **Runtime**: Bun\n- **Terminal UI**: React + [Ink](https:\u002F\u002Fgithub.com\u002Fvadimdemedes\u002Fink) (React for CLI)\n- **Scale**: ~1,900 files, 512,000+ lines of code\n\n---\n\n## Directory Structure\n\n```\nsrc\u002F\n├── main.tsx                 # Entrypoint (Commander.js-based CLI parser)\n├── commands.ts              # Command registry\n├── tools.ts                 # Tool registry\n├── Tool.ts                  # Tool type definitions\n├── QueryEngine.ts           # LLM query engine (core Anthropic API caller)\n├── context.ts               # System\u002Fuser context collection\n├── cost-tracker.ts          # Token cost tracking\n│\n├── commands\u002F                # Slash command implementations (~50)\n├── tools\u002F                   # Agent tool implementations (~40)\n├── components\u002F              # Ink UI components (~140)\n├── hooks\u002F                   # React hooks\n├── services\u002F                # External service integrations\n├── screens\u002F                 # Full-screen UIs (Doctor, REPL, Resume)\n├── types\u002F                   # TypeScript type definitions\n├── utils\u002F                   # Utility functions\n│\n├── bridge\u002F                  # IDE integration bridge (VS Code, JetBrains)\n├── coordinator\u002F             # Multi-agent coordinator\n├── plugins\u002F                 # Plugin system\n├── skills\u002F                  # Skill system\n├── keybindings\u002F             # Keybinding configuration\n├── vim\u002F                     # Vim mode\n├── voice\u002F                   # Voice input\n├── remote\u002F                  # Remote sessions\n├── server\u002F                  # Server mode\n├── memdir\u002F                  # Memory directory (persistent memory)\n├── tasks\u002F                   # Task management\n├── state\u002F                   # State management\n├── migrations\u002F              # Config migrations\n├── schemas\u002F                 # Config schemas (Zod)\n├── entrypoints\u002F             # Initialization logic\n├── ink\u002F                     # Ink renderer wrapper\n├── buddy\u002F                   # Companion sprite (Easter egg)\n├── native-ts\u002F               # Native TypeScript utils\n├── outputStyles\u002F            # Output styling\n├── query\u002F                   # Query pipeline\n└── upstreamproxy\u002F           # Proxy configuration\n```\n\n---\n\n## Core Architecture\n\n### 1. Tool System (`src\u002Ftools\u002F`)\n\nEvery tool Claude Code can invoke is implemented as a self-contained module. Each tool defines its input schema, permission model, and execution logic.\n\n| Tool | Description |\n|---|---|\n| `BashTool` | Shell command execution |\n| `FileReadTool` | File reading (images, PDFs, notebooks) |\n| `FileWriteTool` | File creation \u002F overwrite |\n| `FileEditTool` | Partial file modification (string replacement) |\n| `GlobTool` | File pattern matching search |\n| `GrepTool` | ripgrep-based content search |\n| `WebFetchTool` | Fetch URL content |\n| `WebSearchTool` | Web search |\n| `AgentTool` | Sub-agent spawning |\n| `SkillTool` | Skill execution |\n| `MCPTool` | MCP server tool invocation |\n| `LSPTool` | Language Server Protocol integration |\n| `NotebookEditTool` | Jupyter notebook editing |\n| `TaskCreateTool` \u002F `TaskUpdateTool` | Task creation and management |\n| `SendMessageTool` | Inter-agent messaging |\n| `TeamCreateTool` \u002F `TeamDeleteTool` | Team agent management |\n| `EnterPlanModeTool` \u002F `ExitPlanModeTool` | Plan mode toggle |\n| `EnterWorktreeTool` \u002F `ExitWorktreeTool` | Git worktree isolation |\n| `ToolSearchTool` | Deferred tool discovery |\n| `CronCreateTool` | Scheduled trigger creation |\n| `RemoteTriggerTool` | Remote trigger |\n| `SleepTool` | Proactive mode wait |\n| `SyntheticOutputTool` | Structured output generation |\n\n### 2. Command System (`src\u002Fcommands\u002F`)\n\nUser-facing slash commands invoked with `\u002F` prefix.\n\n| Command | Description |\n|---|---|\n| `\u002Fcommit` | Create a git commit |\n| `\u002Freview` | Code review |\n| `\u002Fcompact` | Context compression |\n| `\u002Fmcp` | MCP server management |\n| `\u002Fconfig` | Settings management |\n| `\u002Fdoctor` | Environment diagnostics |\n| `\u002Flogin` \u002F `\u002Flogout` | Authentication |\n| `\u002Fmemory` | Persistent memory management |\n| `\u002Fskills` | Skill management |\n| `\u002Ftasks` | Task management |\n| `\u002Fvim` | Vim mode toggle |\n| `\u002Fdiff` | View changes |\n| `\u002Fcost` | Check usage cost |\n| `\u002Ftheme` | Change theme |\n| `\u002Fcontext` | Context visualization |\n| `\u002Fpr_comments` | View PR comments |\n| `\u002Fresume` | Restore previous session |\n| `\u002Fshare` | Share session |\n| `\u002Fdesktop` | Desktop app handoff |\n| `\u002Fmobile` | Mobile app handoff |\n\n### 3. Service Layer (`src\u002Fservices\u002F`)\n\n| Service | Description |\n|---|---|\n| `api\u002F` | Anthropic API client, file API, bootstrap |\n| `mcp\u002F` | Model Context Protocol server connection and management |\n| `oauth\u002F` | OAuth 2.0 authentication flow |\n| `lsp\u002F` | Language Server Protocol manager |\n| `analytics\u002F` | GrowthBook-based feature flags and analytics |\n| `plugins\u002F` | Plugin loader |\n| `compact\u002F` | Conversation context compression |\n| `policyLimits\u002F` | Organization policy limits |\n| `remoteManagedSettings\u002F` | Remote managed settings |\n| `extractMemories\u002F` | Automatic memory extraction |\n| `tokenEstimation.ts` | Token count estimation |\n| `teamMemorySync\u002F` | Team memory synchronization |\n\n### 4. Bridge System (`src\u002Fbridge\u002F`)\n\nA bidirectional communication layer connecting IDE extensions (VS Code, JetBrains) with the Claude Code CLI.\n\n- `bridgeMain.ts` — Bridge main loop\n- `bridgeMessaging.ts` — Message protocol\n- `bridgePermissionCallbacks.ts` — Permission callbacks\n- `replBridge.ts` — REPL session bridge\n- `jwtUtils.ts` — JWT-based authentication\n- `sessionRunner.ts` — Session execution management\n\n### 5. Permission System (`src\u002Fhooks\u002FtoolPermission\u002F`)\n\nChecks permissions on every tool invocation. Either prompts the user for approval\u002Fdenial or automatically resolves based on the configured permission mode (`default`, `plan`, `bypassPermissions`, `auto`, etc.).\n\n### 6. Feature Flags\n\nDead code elimination via Bun's `bun:bundle` feature flags:\n\n```typescript\nimport { feature } from 'bun:bundle'\n\n\u002F\u002F Inactive code is completely stripped at build time\nconst voiceCommand = feature('VOICE_MODE')\n  ? require('.\u002Fcommands\u002Fvoice\u002Findex.js').default\n  : null\n```\n\nNotable flags: `PROACTIVE`, `KAIROS`, `BRIDGE_MODE`, `DAEMON`, `VOICE_MODE`, `AGENT_TRIGGERS`, `MONITOR_TOOL`\n\n---\n\n## Key Files in Detail\n\n### `QueryEngine.ts` (~46K lines)\n\nThe core engine for LLM API calls. Handles streaming responses, tool-call loops, thinking mode, retry logic, and token counting.\n\n### `Tool.ts` (~29K lines)\n\nDefines base types and interfaces for all tools — input schemas, permission models, and progress state types.\n\n### `commands.ts` (~25K lines)\n\nManages registration and execution of all slash commands. Uses conditional imports to load different command sets per environment.\n\n### `main.tsx`\n\nCommander.js-based CLI parser + React\u002FInk renderer initialization. At startup, parallelizes MDM settings, keychain prefetch, and GrowthBook initialization for faster boot.\n\n---\n\n## Tech Stack\n\n| Category | Technology |\n|---|---|\n| Runtime | [Bun](https:\u002F\u002Fbun.sh) |\n| Language | TypeScript (strict) |\n| Terminal UI | [React](https:\u002F\u002Freact.dev) + [Ink](https:\u002F\u002Fgithub.com\u002Fvadimdemedes\u002Fink) |\n| CLI Parsing | [Commander.js](https:\u002F\u002Fgithub.com\u002Ftj\u002Fcommander.js) (extra-typings) |\n| Schema Validation | [Zod v4](https:\u002F\u002Fzod.dev) |\n| Code Search | [ripgrep](https:\u002F\u002Fgithub.com\u002FBurntSushi\u002Fripgrep) (via GrepTool) |\n| Protocols | [MCP SDK](https:\u002F\u002Fmodelcontextprotocol.io), LSP |\n| API | [Anthropic SDK](https:\u002F\u002Fdocs.anthropic.com) |\n| Telemetry | OpenTelemetry + gRPC |\n| Feature Flags | GrowthBook |\n| Auth | OAuth 2.0, JWT, macOS Keychain |\n\n---\n\n## Notable Design Patterns\n\n### Parallel Prefetch\n\nStartup time is optimized by prefetching MDM settings, keychain reads, and API preconnect in parallel — before heavy module evaluation begins.\n\n```typescript\n\u002F\u002F main.tsx — fired as side-effects before other imports\nstartMdmRawRead()\nstartKeychainPrefetch()\n```\n\n### Lazy Loading\n\nHeavy modules (OpenTelemetry ~400KB, gRPC ~700KB) are deferred via dynamic `import()` until actually needed.\n\n### Agent Swarms\n\nSub-agents are spawned via `AgentTool`, with `coordinator\u002F` handling multi-agent orchestration. `TeamCreateTool` enables team-level parallel work.\n\n### Skill System\n\nReusable workflows defined in `skills\u002F` and executed through `SkillTool`. Users can add custom skills.\n\n### Plugin Architecture\n\nBuilt-in and third-party plugins are loaded through the `plugins\u002F` subsystem.\n\n---\n\n## Disclaimer\n\nThis repository archives source code that was leaked from Anthropic's npm registry on **2026-03-31**. All original source code is the property of [Anthropic](https:\u002F\u002Fwww.anthropic.com).\n","Claude Code 是一个基于终端的智能编码工具，能够理解你的代码库，并通过自然语言命令帮助你快速执行常规任务、解释复杂代码和处理 Git 工作流。该项目使用 TypeScript 编写，运行于 Bun 环境下，采用 React 和 Ink 构建终端用户界面，支持多种软件工程任务如文件编辑、命令执行、代码搜索等。适用于需要提高开发效率、简化日常编程工作的场景，尤其适合频繁与代码库和版本控制系统交互的开发者。",2,"2026-06-11 03:51:41","high_star"]