[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74888":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},74888,"claude-code","jarmuine\u002Fclaude-code","jarmuine","Fork of instructkr\u002Fclaude-code",null,"TypeScript",2195,5912,17,3,0,12,22,63,36,32,false,"main",true,[],"2026-06-12 02:03:29","# Claude Code Source Snapshot for Security Research\n\n> This repository mirrors a **publicly exposed Claude Code source snapshot** that became accessible on **March 31, 2026** through a source map exposure in the npm distribution. It is maintained for **educational, defensive security research, and software supply-chain analysis**.\n\n---\n\n## Research Context\n\nThis repository is maintained by a **university student** studying:\n\n- software supply-chain exposure and build artifact leaks\n- secure software engineering practices\n- agentic developer tooling architecture\n- defensive analysis of real-world CLI systems\n\nThis archive is intended to support:\n\n- educational study\n- security research practice\n- architecture review\n- discussion of packaging and release-process failures\n\nIt does **not** claim ownership of the original code, and it should not be interpreted as an official Anthropic repository.\n\n---\n\n## How the Public Snapshot Became Accessible\n\n[Chaofan Shou (@Fried_rice)](https:\u002F\u002Fx.com\u002FFried_rice) publicly noted that Claude Code source material was reachable through a `.map` file exposed in the npm package:\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 published source map referenced unobfuscated TypeScript sources hosted in Anthropic's R2 storage bucket, which made the `src\u002F` snapshot publicly downloadable.\n\n---\n\n## Repository Scope\n\nClaude Code is Anthropic's CLI for interacting with Claude from the terminal to perform software engineering tasks such as editing files, running commands, searching codebases, and coordinating workflows.\n\nThis repository contains a mirrored `src\u002F` snapshot for research and analysis.\n\n- **Public exposure identified on**: 2026-03-31\n- **Language**: TypeScript\n- **Runtime**: Bun\n- **Terminal UI**: React + [Ink](https:\u002F\u002Fgithub.com\u002Fvadimdemedes\u002Fink)\n- **Scale**: ~1,900 files, 512,000+ lines of code\n\n---\n\n## Directory Structure\n\n```text\nsrc\u002F\n├── main.tsx                 # Entrypoint orchestration (Commander.js-based CLI path)\n├── commands.ts              # Command registry\n├── tools.ts                 # Tool registry\n├── Tool.ts                  # Tool type definitions\n├── QueryEngine.ts           # LLM query engine\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 and remote-control bridge\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                  # Persistent memory directory\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\n├── native-ts\u002F               # Native TypeScript utilities\n├── outputStyles\u002F            # Output styling\n├── query\u002F                   # Query pipeline\n└── upstreamproxy\u002F           # Proxy configuration\n```\n\n---\n\n## Architecture Summary\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 and React\u002FInk renderer initialization. At startup, it overlaps 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) |\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, gRPC, analytics, and some feature-gated subsystems) 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` are 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## Research \u002F Ownership Disclaimer\n\n- This repository is an **educational and defensive security research archive** maintained by a university student.\n- It exists to study source exposure, packaging failures, and the architecture of modern agentic CLI systems.\n- The original Claude Code source remains the property of **Anthropic**.\n- This repository is **not affiliated with, endorsed by, or maintained by Anthropic**.\n","该项目是一个公开的Claude Code源代码快照，旨在支持教育、防御性安全研究和软件供应链分析。核心功能包括通过命令行界面与Claude进行交互，执行文件编辑、运行命令、搜索代码库和协调工作流等任务。技术特点包括使用TypeScript编写，运行时环境为Bun，终端用户界面基于React和Ink框架构建。适合用于学习软件供应链暴露及构建工件泄露、安全软件工程实践、代理开发工具架构以及对真实世界CLI系统的防御性分析等场景。",2,"2026-06-11 03:51:18","high_star"]