From 7e888ce38dc93983c97a37c810b70f8b7c7a32c7 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Fri, 3 Apr 2026 19:27:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=20agent=20=E5=8F=8A=E4=B8=80=E4=BA=9B=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/agents/hello-agent.md | 17 +++ README_EN.md | 158 +++++++++++++++++++++++++ docs/external-dependencies.md | 209 ++++++++++++++++++++++++++++++++++ 3 files changed, 384 insertions(+) create mode 100644 .claude/agents/hello-agent.md create mode 100644 README_EN.md create mode 100644 docs/external-dependencies.md diff --git a/.claude/agents/hello-agent.md b/.claude/agents/hello-agent.md new file mode 100644 index 000000000..2c7fc2a9a --- /dev/null +++ b/.claude/agents/hello-agent.md @@ -0,0 +1,17 @@ +--- +name: hello-agent +description: A friendly greeting agent that introduces the project +--- + +You are a friendly greeting agent. Your job is to greet the user and provide helpful information about the current project. + +Instructions: +1. Read the project's CLAUDE.md to understand the project context. +2. Greet the user warmly. +3. Provide a brief summary of the project based on what you learned from CLAUDE.md. +4. Offer to help with any questions about the project. + +Style: +- Be concise and friendly. +- Respond in 简体中文. +- Keep responses short — no more than a few sentences. diff --git a/README_EN.md b/README_EN.md new file mode 100644 index 000000000..3b3053b1d --- /dev/null +++ b/README_EN.md @@ -0,0 +1,158 @@ +# Claude Code Best V5 (CCB) + +[![GitHub Stars](https://img.shields.io/github/stars/claude-code-best/claude-code?style=flat-square&logo=github&color=yellow)](https://github.com/claude-code-best/claude-code/stargazers) +[![GitHub Contributors](https://img.shields.io/github/contributors/claude-code-best/claude-code?style=flat-square&color=green)](https://github.com/claude-code-best/claude-code/graphs/contributors) +[![GitHub Issues](https://img.shields.io/github/issues/claude-code-best/claude-code?style=flat-square&color=orange)](https://github.com/claude-code-best/claude-code/issues) +[![GitHub License](https://img.shields.io/github/license/claude-code-best/claude-code?style=flat-square)](https://github.com/claude-code-best/claude-code/blob/main/LICENSE) +[![Last Commit](https://img.shields.io/github/last-commit/claude-code-best/claude-code?style=flat-square&color=blue)](https://github.com/claude-code-best/claude-code/commits/main) +[![Bun](https://img.shields.io/badge/runtime-Bun-black?style=flat-square&logo=bun)](https://bun.sh/) + +> Which Claude do you like? The open source one is the best. + +A reverse-engineered / decompiled source restoration of Anthropic's official [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI tool. The goal is to reproduce most of Claude Code's functionality and engineering capabilities. It's abbreviated as CCB. + +[Documentation (Chinese)](https://ccb.agent-aura.top/) — PR contributions welcome. + +Sponsor placeholder. + +- [x] v1: Basic runability and type checking pass +- [x] V2: Complete engineering infrastructure + - [ ] Biome formatting may not be implemented first to avoid code conflicts + - [x] Build pipeline complete, output runnable on both Node.js and Bun +- [x] V3: Extensive documentation and documentation site improvements +- [x] V4: Large-scale test suite for improved stability + - [x] Buddy pet feature restored [Docs](https://ccb.agent-aura.top/docs/features/buddy) + - [x] Auto Mode restored [Docs](https://ccb.agent-aura.top/docs/safety/auto-mode) + - [x] All features now configurable via environment variables instead of `bun --feature` +- [x] V5: Enterprise-grade monitoring/reporting, missing tools补全, restrictions removed + - [x] Removed anti-distillation code + - [x] Web search capability (using Bing) [Docs](https://ccb.agent-aura.top/docs/features/web-browser-tool) + - [x] Debug mode support [Docs](https://ccb.agent-aura.top/docs/features/debug-mode) + - [x] Disabled auto-updates + - [x] Custom Sentry error reporting support [Docs](https://ccb.agent-aura.top/docs/internals/sentry-setup) + - [x] Custom GrowthBook support (GB is open source — configure your own feature flag platform) [Docs](https://ccb.agent-aura.top/docs/internals/growthbook-adapter) + - [x] Custom login mode — configure Claude models your way +- [ ] V6: Large-scale refactoring, full modular packaging + - [ ] V6 will be a new branch; main branch will be archived as a historical version + +> I don't know how long this project will survive. Star + Fork + git clone + .zip is the safest bet. +> +> This project updates rapidly — Opus continuously optimizes in the background, with new changes almost every few hours. +> +> Claude has burned over $1000, out of budget, switching to GLM to continue; @zai-org GLM 5.1 is quite capable. + +## Quick Start + +### Prerequisites + +Make sure you're on the latest version of Bun, otherwise you'll run into all sorts of weird bugs. Run `bun upgrade`! + +- [Bun](https://bun.sh/) >= 1.3.11 +- Standard Claude Code configuration — each provider has its own setup method + +### Install + +```bash +bun install +``` + +### Run + +```bash +# Dev mode — if you see version 888, it's working +bun run dev + +# Build +bun run build +``` + +The build uses code splitting (`build.ts`), outputting to `dist/` (entry `dist/cli.js` + ~450 chunk files). + +The build output runs on both Bun and Node.js — you can publish to a private registry and run directly. + +If you encounter a bug, please open an issue — we'll prioritize it. + +### First-time Setup /login + +After the first run, enter `/login` in the REPL to access the login configuration screen. Select **Custom Platform** to connect to third-party API-compatible services (no Anthropic account required). + +Fields to fill in: + +| Field | Description | Example | +|-------|-------------|---------| +| Base URL | API service URL | `https://api.example.com/v1` | +| API Key | Authentication key | `sk-xxx` | +| Haiku Model | Fast model ID | `claude-haiku-4-5-20251001` | +| Sonnet Model | Balanced model ID | `claude-sonnet-4-6` | +| Opus Model | High-performance model ID | `claude-opus-4-6` | + +- **Tab / Shift+Tab** to switch fields, **Enter** to confirm and move to the next, press Enter on the last field to save +- Model fields auto-fill from current environment variables +- Configuration saves to `~/.claude/settings.json` under the `env` key, effective immediately + +You can also edit `~/.claude/settings.json` directly: + +```json +{ + "env": { + "ANTHROPIC_BASE_URL": "https://api.example.com/v1", + "ANTHROPIC_AUTH_TOKEN": "sk-xxx", + "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001", + "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6", + "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-6" + } +} +``` + +> Supports all Anthropic API-compatible services (e.g., OpenRouter, AWS Bedrock proxies, etc.) as long as the interface is compatible with the Messages API. + +## Feature Flags + +All feature toggles are enabled via `FEATURE_=1` environment variables, for example: + +```bash +FEATURE_BUDDY=1 FEATURE_FORK_SUBAGENT=1 bun run dev +``` + +See [`docs/features/`](docs/features/) for detailed descriptions of each feature. Contributions welcome. + +## VS Code Debugging + +The TUI (REPL) mode requires a real terminal and cannot be launched directly via VS Code's launch config. Use **attach mode**: + +### Steps + +1. **Start inspect server in terminal**: + ```bash + bun run dev:inspect + ``` + This outputs an address like `ws://localhost:8888/xxxxxxxx`. + +2. **Attach debugger from VS Code**: + - Set breakpoints in `src/` files + - Press F5 → select **"Attach to Bun (TUI debug)"** + +## Documentation & Links + +- **Online docs (Mintlify)**: [ccb.agent-aura.top](https://ccb.agent-aura.top/) — source in [`docs/`](docs/), PR contributions welcome +- **DeepWiki**: + +## Contributors + + + + + +## Star History + + + + + + Star History Chart + + + +## License + +This project is for educational and research purposes only. All rights to Claude Code belong to [Anthropic](https://www.anthropic.com/). diff --git a/docs/external-dependencies.md b/docs/external-dependencies.md new file mode 100644 index 000000000..a28447e7c --- /dev/null +++ b/docs/external-dependencies.md @@ -0,0 +1,209 @@ +# Claude Code 远程服务器依赖 + +> 只列出代码中实际发起网络请求的远程服务。本地服务、npm 包依赖、展示用 URL 不包含在内。 + +## 总览表 + +| # | 服务 | 远程端点 | 协议 | 状态 | +|---|---|---|---|---| +| 1 | Anthropic API | `api.anthropic.com` | HTTPS | 默认启用 | +| 2 | AWS Bedrock | `bedrock-runtime.*.amazonaws.com` | HTTPS | 需 `CLAUDE_CODE_USE_BEDROCK=1` | +| 3 | Google Vertex AI | `{region}-aiplatform.googleapis.com` | HTTPS | 需 `CLAUDE_CODE_USE_VERTEX=1` | +| 4 | Azure Foundry | `{resource}.services.ai.azure.com` | HTTPS | 需 `CLAUDE_CODE_USE_FOUNDRY=1` | +| 5 | OAuth (Anthropic) | `platform.claude.com`, `claude.com`, `claude.ai` | HTTPS | 用户登录时 | +| 6 | GrowthBook | `api.anthropic.com` (remoteEval) | HTTPS | 默认启用 | +| 7 | Sentry | 可配置 (`SENTRY_DSN`) | HTTPS | 需设环境变量 | +| 8 | Datadog | 可配置 (`DATADOG_LOGS_ENDPOINT`) | HTTPS | 需设环境变量 | +| 9 | OpenTelemetry Collector | 可配置 (`OTEL_EXPORTER_OTLP_ENDPOINT`) | gRPC/HTTP | 需设环境变量 | +| 10 | 1P Event Logging | `api.anthropic.com/api/event_logging/batch` | HTTPS | 默认启用 | +| 11 | BigQuery Metrics | `api.anthropic.com/api/claude_code/metrics` | HTTPS | 默认启用 | +| 12 | MCP Proxy | `mcp-proxy.anthropic.com` | HTTPS+WS | 使用 MCP 工具时 | +| 13 | MCP Registry | `api.anthropic.com/mcp-registry` | HTTPS | 查询 MCP 服务器时 | +| 14 | Bing Search | `www.bing.com` | HTTPS | WebSearch 工具 | +| 15 | Google Cloud Storage (更新) | `storage.googleapis.com` | HTTPS | 版本检查 | +| 16 | GitHub Raw (Changelog/Stats) | `raw.githubusercontent.com` | HTTPS | 更新提示 | +| 17 | Claude in Chrome Bridge | `bridge.claudeusercontent.com` | WSS | Chrome 集成 | +| 18 | CCR Upstream Proxy | `api.anthropic.com` | WS | CCR 远程会话 | +| 19 | Voice STT | `api.anthropic.com/api/ws/...` | WSS | Voice Mode | +| 20 | Desktop App Download | `claude.ai/api/desktop/...` | HTTPS | 下载引导 | + +--- + +## 详细说明 + +### 1. Anthropic Messages API + +核心 LLM 推理服务,发送对话消息、接收流式响应。 + +- **端点**: `https://api.anthropic.com` (生产) / `https://api-staging.anthropic.com` (staging) +- **覆盖**: `ANTHROPIC_BASE_URL` 环境变量 +- **认证**: API Key / OAuth Token +- **文件**: `src/services/api/client.ts`, `src/services/api/claude.ts` + +### 2. AWS Bedrock + +- **端点**: `bedrock-runtime.{region}.amazonaws.com` +- **认证**: AWS 凭证链 / `AWS_BEARER_TOKEN_BEDROCK` +- **文件**: `src/services/api/client.ts:153-190`, `src/utils/aws.ts` + +### 3. Google Vertex AI + +- **端点**: `{region}-aiplatform.googleapis.com` +- **认证**: `GoogleAuth` + `cloud-platform` scope +- **文件**: `src/services/api/client.ts:228-298` + +### 4. Azure Foundry + +- **端点**: `https://{resource}.services.ai.azure.com/anthropic/v1/messages` +- **认证**: API Key 或 Azure AD `DefaultAzureCredential` +- **文件**: `src/services/api/client.ts:191-220` + +### 5. OAuth + +OAuth 2.0 + PKCE 授权码流程。 + +- **端点**: + - `https://platform.claude.com/oauth/authorize` — 授权页 + - `https://claude.com/cai/oauth/authorize` — Claude.ai 授权 + - `https://platform.claude.com/v1/oauth/token` — Token 交换 + - `https://api.anthropic.com/api/oauth/claude_cli/create_api_key` — 创建 API Key + - `https://api.anthropic.com/api/oauth/claude_cli/roles` — 获取角色 + - `https://claude.ai/oauth/claude-code-client-metadata` — MCP 客户端元数据 + - `https://claude.fedstart.com` — FedStart 政府部署 +- **文件**: `src/constants/oauth.ts`, `src/services/oauth/` + +### 6. GrowthBook (功能开关) + +- **端点**: `https://api.anthropic.com/` (remoteEval 模式) 或 `CLAUDE_GB_ADAPTER_URL` +- **SDK Keys**: `sdk-zAZezfDKGoZuXXKe` (外部), `sdk-xRVcrliHIlrg4og4` (ant prod), `sdk-yZQvlplybuXjYh6L` (ant dev) +- **文件**: `src/services/analytics/growthbook.ts`, `src/constants/keys.ts` + +### 7. Sentry (错误追踪) + +- **激活**: 设置 `SENTRY_DSN` (默认未配置) +- **行为**: 仅错误上报,自动过滤敏感 header +- **文件**: `src/utils/sentry.ts` + +### 8. Datadog (日志) + +- **激活**: 同时设 `DATADOG_LOGS_ENDPOINT` + `DATADOG_API_KEY` (默认未配置) +- **文件**: `src/services/analytics/datadog.ts` + +### 9. OpenTelemetry Collector + +- **激活**: `CLAUDE_CODE_ENABLE_TELEMETRY=1` 或 `OTEL_*` 环境变量 +- **协议**: gRPC / HTTP / Protobuf,支持 OTLP 和 Prometheus 导出 +- **文件**: `src/utils/telemetry/instrumentation.ts` + +### 10. 1P Event Logging (内部事件) + +- **端点**: `https://api.anthropic.com/api/event_logging/batch` +- **协议**: 批量导出 (10s 间隔, 每批 200 事件) +- **文件**: `src/services/analytics/firstPartyEventLoggingExporter.ts` + +### 11. BigQuery Metrics + +- **端点**: `https://api.anthropic.com/api/claude_code/metrics` +- **文件**: `src/utils/telemetry/bigqueryExporter.ts` + +### 12. MCP Proxy + +Anthropic 托管的 MCP 服务器代理。 + +- **端点**: `https://mcp-proxy.anthropic.com/v1/mcp/{server_id}` +- **认证**: Claude.ai OAuth tokens +- **文件**: `src/services/mcp/client.ts`, `src/constants/oauth.ts` + +### 13. MCP Registry + +获取官方 MCP 服务器列表。 + +- **端点**: `https://api.anthropic.com/mcp-registry/v0/servers?version=latest&visibility=commercial` +- **文件**: `src/services/mcp/officialRegistry.ts` + +### 14. Bing Search + +WebSearch 工具的默认适配器,抓取 Bing 搜索结果。 + +- **端点**: `https://www.bing.com/search?q={query}&setmkt=en-US` +- **文件**: `src/tools/WebSearchTool/adapters/bingAdapter.ts` + +另外还有 Domain Blocklist 查询: +- **端点**: `https://api.anthropic.com/api/web/domain_info?domain={domain}` +- **文件**: `src/tools/WebFetchTool/utils.ts` + +### 15. Google Cloud Storage (自动更新) + +- **端点**: `https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases` +- **文件**: `src/utils/autoUpdater.ts` + +### 16. GitHub Raw Content + +- **端点**: `https://raw.githubusercontent.com/anthropics/claude-code/refs/heads/main/CHANGELOG.md` +- **端点**: `https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json` +- **文件**: `src/utils/releaseNotes.ts`, `src/utils/plugins/installCounts.ts` + +### 17. Claude in Chrome Bridge + +- **端点**: `wss://bridge.claudeusercontent.com` (生产) / `wss://bridge-staging.claudeusercontent.com` (staging) +- **文件**: `src/utils/claudeInChrome/mcpServer.ts` + +### 18. CCR Upstream Proxy + +- **端点**: `ws://api.anthropic.com/v1/code/upstreamproxy/ws` +- **激活**: `CLAUDE_CODE_REMOTE=1` + `CCR_UPSTREAM_PROXY_ENABLED=1` +- **文件**: `src/upstreamproxy/upstreamproxy.ts` + +### 19. Voice STT + +- **端点**: `wss://api.anthropic.com/api/ws/...` +- **文件**: `src/services/voiceStreamSTT.ts` + +### 20. Desktop App Download + +- **端点**: `https://claude.ai/api/desktop/win32/x64/exe/latest/redirect` (Windows) +- **端点**: `https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect` (macOS) +- **文件**: `src/components/DesktopHandoff.tsx` + +--- + +## Anthropic API 辅助端点汇总 + +以下端点都挂在 `api.anthropic.com` 上,按功能分类: + +| 端点路径 | 用途 | 文件 | +|---|---|---| +| `/api/event_logging/batch` | 事件批量上报 | `src/services/analytics/firstPartyEventLoggingExporter.ts` | +| `/api/claude_code/metrics` | BigQuery 指标导出 | `src/utils/telemetry/bigqueryExporter.ts` | +| `/api/oauth/claude_cli/create_api_key` | 创建 API Key | `src/constants/oauth.ts` | +| `/api/oauth/claude_cli/roles` | 获取用户角色 | `src/constants/oauth.ts` | +| `/api/oauth/accounts/grove` | 通知设置 | `src/services/api/grove.ts` | +| `/api/oauth/organizations/{id}/referral/*` | 推荐活动 | `src/services/api/referral.ts` | +| `/api/oauth/organizations/{id}/overage_credit_grant` | 超额信用 | `src/services/api/overageCreditGrant.ts` | +| `/api/oauth/organizations/{id}/admin_requests` | 管理请求 | `src/services/api/adminRequests.ts` | +| `/api/web/domain_info?domain={}` | 域名安全检查 | `src/tools/WebFetchTool/utils.ts` | +| `/api/claude_code/settings` | 设置同步 | `src/services/settingsSync/index.ts` | +| `/api/claude_code/managed_settings` | 企业托管设置 (1h 轮询) | `src/services/remoteManagedSettings/index.ts` | +| `/api/claude_code/team_memory?repo={}` | 团队记忆同步 | `src/services/teamMemorySync/index.ts` | +| `/api/auth/trusted_devices` | 可信设备注册 | `src/bridge/trustedDevice.ts` | +| `/api/organizations/{id}/claude_code/buddy_react` | Companion 反应 | `src/buddy/companionReact.ts` | +| `/mcp-registry/v0/servers` | MCP 服务器注册表 | `src/services/mcp/officialRegistry.ts` | +| `/v1/files` | 文件上传/下载 | `src/services/api/filesApi.ts` | +| `/v1/sessions/{id}/events` | 会话历史 | `src/assistant/sessionHistory.ts` | +| `/v1/code/triggers` | 远程触发器 | `src/tools/RemoteTriggerTool/RemoteTriggerTool.ts` | +| `/v1/organizations/{id}/mcp_servers` | 组织 MCP 配置 | `src/services/mcp/claudeai.ts` | + +## 非 Anthropic 远程域名汇总 + +| 域名 | 服务 | 协议 | +|---|---|---| +| `bedrock-runtime.*.amazonaws.com` | AWS Bedrock | HTTPS | +| `{region}-aiplatform.googleapis.com` | Google Vertex AI | HTTPS | +| `{resource}.services.ai.azure.com` | Azure Foundry | HTTPS | +| `www.bing.com` | Bing 搜索 | HTTPS | +| `storage.googleapis.com` | 自动更新 | HTTPS | +| `raw.githubusercontent.com` | Changelog / 插件统计 | HTTPS | +| `bridge.claudeusercontent.com` | Chrome Bridge | WSS | +| `platform.claude.com` | OAuth 授权页 | HTTPS | +| `claude.com` / `claude.ai` | OAuth / 下载 | HTTPS | +| `claude.fedstart.com` | FedStart OAuth | HTTPS |