claudecode 曝光了部分代码解析
cc的代码分析.
scripts: scripts\build.mjs 用于构建最后的cc程序
vendor: 第三方依赖. vendor\audio-capture-src\index.ts 音频模块. vendor\url-handler-src\index.ts url处理模块.只有苹果有用.别人点击了url就返回url地址字符串. src\assistant\sessionHistory.ts 会话话历史模块.
Disclaimer: All source code in this repository is the intellectual property of Anthropic and Claude. This repository is provided strictly for technical research, study, and educational exchange among enthusiasts. Commercial use is strictly prohibited. No individual, organization, or entity may use this content for commercial purposes, profit-making activities, illegal activities, or any other unauthorized scenarios. If any content infringes upon your legal rights, intellectual property, or other interests, please contact us and we will verify and remove it immediately.
Extracted from npm package
@anthropic-ai/claude-codeversion 2.1.88. The published package ships a single bundledcli.js(~12MB). Thesrc/directory in this repo contains the unbundled TypeScript source extracted from the npm tarball.
Language: English | 中文
docs/) — Telemetry, codenames, undercover mode, remote control, future roadmapdocs/)Source code analysis reports derived from decompiled v2.1.88. Bilingual (EN/ZH).
…Click any filename above to jump to the full report.
| # | Topic | Key Findings |
|---|---|---|
| 01 | Telemetry & Privacy | Two analytics sinks (1P → Anthropic, Datadog). Environment fingerprint, process metrics, repo hash on every event. No UI-exposed opt-out for 1st-party logging. OTEL_LOG_TOOL_DETAILS=1 enables full tool input capture. |
| 02 | Hidden Features & Codenames | Animal codenames (Capybara v8, Tengu, Fennec→Opus 4.6, Numbat next). Feature flags use random word pairs (tengu_frond_boric) to obscure purpose. Internal users get better prompts, verification agents, and effort anchors. Hidden commands: /btw, /stickers. |
| 03 | Undercover Mode | Anthropic employees auto-enter undercover mode in public repos. Model instructed: "Do not blow your cover" — strip all AI attribution, write commits "as a human developer would." No force-OFF exists. Raises transparency questions for open-source communities. |
| 04 | Remote Control | Hourly polling of /api/claude_code/settings. Dangerous changes show blocking dialog — reject = app exits. 6+ killswitches (bypass permissions, fast mode, voice mode, analytics sink). GrowthBook flags can change any user's behavior without consent. |
| 05 | Future Roadmap | Numbat codename confirmed. Opus 4.7 / Sonnet 4.8 in development. KAIROS = fully autonomous agent mode with `` heartbeats, push notifications, PR subscriptions. Voice mode (push-to-talk) ready but gated. 17 unreleased tools found. |
This source is incomplete. 108 modules referenced by
feature()-gated branches are not included in the npm package. They exist only in Anthropic's internal monorepo and were dead-code-eliminated at compile time. They cannot be recovered fromcli.js,sdk-tools.d.ts, or any published artifact.
These modules have no source files anywhere in the npm package. They are internal Anthropic infrastructure.
Click to expand full list
| Module | Purpose | Feature Gate |
|---|---|---|
daemon/main.js |
Background daemon supervisor | DAEMON |
daemon/workerRegistry.js |
Daemon worker registry | DAEMON |
proactive/index.js |
Proactive notification system | PROACTIVE |
contextCollapse/index.js |
Context collapse service (experimental) | CONTEXT_COLLAPSE |
contextCollapse/operations.js |
Collapse operations | CONTEXT_COLLAPSE |
contextCollapse/persist.js |
Collapse persistence | CONTEXT_COLLAPSE |
skillSearch/featureCheck.js |
Remote skill feature check | EXPERIMENTAL_SKILL_SEARCH |
skillSearch/remoteSkillLoader.js |
Remote skill loader | EXPERIMENTAL_SKILL_SEARCH |
skillSearch/remoteSkillState.js |
Remote skill state | EXPERIMENTAL_SKILL_SEARCH |
skillSearch/telemetry.js |
Skill search telemetry | EXPERIMENTAL_SKILL_SEARCH |
skillSearch/localSearch.js |
Local skill search | EXPERIMENTAL_SKILL_SEARCH |
skillSearch/prefetch.js |
Skill prefetch | EXPERIMENTAL_SKILL_SEARCH |
coordinator/workerAgent.js |
Multi-agent coordinator worker | COORDINATOR_MODE |
bridge/peerSessions.js |
Bridge peer session management | BRIDGE_MODE |
assistant/index.js |
Kairos assistant mode | KAIROS |
assistant/AssistantSessionChooser.js |
Assistant session picker | KAIROS |
compact/reactiveCompact.js |
Reactive context compaction | CACHED_MICROCOMPACT |
compact/snipCompact.js |
Snip-based compaction | HISTORY_SNIP |
compact/snipProjection.js |
Snip projection | HISTORY_SNIP |
compact/cachedMCConfig.js |
Cached micro-compact config | CACHED_MICROCOMPACT |
sessionTranscript/sessionTranscript.js |
Session transcript service | TRANSCRIPT_CLASSIFIER |
commands/agents-platform/index.js |
Internal agents platform | ant (internal) |
commands/assistant/index.js |
Assistant command | KAIROS |
commands/buddy/index.js |
Buddy system notifications | BUDDY |
commands/fork/index.js |
Fork subagent command | FORK_SUBAGENT |
commands/peers/index.js |
Multi-peer commands | BRIDGE_MODE |
commands/proactive.js |
Proactive command | PROACTIVE |
commands/remoteControlServer/index.js |
Remote control server | DAEMON + BRIDGE_MODE |
commands/subscribe-pr.js |
GitHub PR subscription | KAIROS_GITHUB_WEBHOOKS |
commands/torch.js |
Internal debug tool | TORCH |
commands/workflows/index.js |
Workflow commands | WORKFLOW_SCRIPTS |
jobs/classifier.js |
Internal job classifier | TEMPLATES |
memdir/memoryShapeTelemetry.js |
Memory shape telemetry | MEMORY_SHAPE_TELEMETRY |
services/sessionTranscript/sessionTranscript.js |
Session transcript | TRANSCRIPT_CLASSIFIER |
tasks/LocalWorkflowTask/LocalWorkflowTask.js |
Local workflow task | WORKFLOW_SCRIPTS |
protectedNamespace.js |
Internal namespace guard | ant (internal) |
protectedNamespace.js (envUtils) |
Protected namespace runtime | ant (internal) |
coreTypes.generated.js |
Generated core types | ant (internal) |
devtools.js |
Internal dev tools | ant (internal) |
attributionHooks.js |
Internal attribution hooks | COMMIT_ATTRIBUTION |
systemThemeWatcher.js |
System theme watcher | AUTO_THEME |
udsClient.js / udsMessaging.js |
UDS messaging client | UDS_INBOX |
systemThemeWatcher.js |
Theme watcher | AUTO_THEME |
These tools have type signatures in sdk-tools.d.ts but their implementations were stripped at compile time.
Click to expand full list
| Tool | Purpose | Feature Gate |
|---|---|---|
REPLTool |
Interactive REPL (VM sandbox) | ant (internal) |
SnipTool |
Context snipping | HISTORY_SNIP |
SleepTool |
Sleep/delay in agent loop | PROACTIVE / KAIROS |
MonitorTool |
MCP monitoring | MONITOR_TOOL |
OverflowTestTool |
Overflow testing | OVERFLOW_TEST_TOOL |
WorkflowTool |
Workflow execution | WORKFLOW_SCRIPTS |
WebBrowserTool |
Browser automation | WEB_BROWSER_TOOL |
TerminalCaptureTool |
Terminal capture | TERMINAL_PANEL |
TungstenTool |
Internal perf monitoring | ant (internal) |
VerifyPlanExecutionTool |
Plan verification | CLAUDE_CODE_VERIFY_PLAN |
SendUserFileTool |
Send files to users | KAIROS |
SubscribePRTool |
GitHub PR subscription | KAIROS_GITHUB_WEBHOOKS |
SuggestBackgroundPRTool |
Suggest background PRs | KAIROS |
PushNotificationTool |
Push notifications | KAIROS |
CtxInspectTool |
Context inspection | CONTEXT_COLLAPSE |
ListPeersTool |
List active peers | UDS_INBOX |
DiscoverSkillsTool |
Skill discovery | EXPERIMENTAL_SKILL_SEARCH |
These are internal prompt templates and documentation, never published.
Click to expand
| File | Purpose |
|---|---|
yolo-classifier-prompts/auto_mode_system_prompt.txt |
Auto-mode system prompt for classifier |
yolo-classifier-prompts/permissions_anthropic.txt |
Anthropic-internal permission prompt |
yolo-classifier-prompts/permissions_external.txt |
External user permission prompt |
verify/SKILL.md |
Verification skill documentation |
verify/examples/cli.md |
CLI verification examples |
verify/examples/server.md |
Server verification examples |
Anthropic Internal Monorepo Published npm Package
────────────────────────── ─────────────────────
feature('DAEMON') → true ──build──→ feature('DAEMON') → false
↓ ↓
daemon/main.js ← INCLUDED ──bundle─→ daemon/main.js ← DELETED (DCE)
tools/REPLTool ← INCLUDED ──bundle─→ tools/REPLTool ← DELETED (DCE)
proactive/ ← INCLUDED ──bundle─→ (referenced but absent from src/) Bun's feature() is a compile-time intrinsic:
true in Anthropic's internal build → code is kept in the bundlefalse in the published build → code is dead-code-eliminatedCopyright (c) Anthropic. All rights reserved.
All source code in this repository is the intellectual property of Anthropic and Claude.
This repository is provided strictly for technical research and educational purposes.
Commercial use is strictly prohibited.
If you are the copyright owner and believe this repository infringes your rights,
please contact the repository owner for immediate removal.| Item | Count |
|---|---|
| Source files (.ts/.tsx) | ~1,884 |
| Lines of code | ~512,664 |
| Largest single file | query.ts (~785KB) |
| Built-in tools | ~40+ |
| Slash commands | ~80+ |
| Dependencies (node_modules) | ~192 packages |
| Runtime | Bun (compiled to Node.js >= 18 bundle) |
……………………………………This source code demonstrates 12 layered mechanisms that a production AI agent harness needs beyond the basic loop. Each builds on the previous:
…| Pattern | Where | Purpose |
|---|---|---|
| AsyncGenerator streaming | `QueryEngin |
暂无开放 Issues,或尚未同步最近议题。