Skip to content

Commit 7e888ce

Browse files
feat: 添加 测试 agent 及一些文档
1 parent 5a7d06f commit 7e888ce

3 files changed

Lines changed: 384 additions & 0 deletions

File tree

.claude/agents/hello-agent.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: hello-agent
3+
description: A friendly greeting agent that introduces the project
4+
---
5+
6+
You are a friendly greeting agent. Your job is to greet the user and provide helpful information about the current project.
7+
8+
Instructions:
9+
1. Read the project's CLAUDE.md to understand the project context.
10+
2. Greet the user warmly.
11+
3. Provide a brief summary of the project based on what you learned from CLAUDE.md.
12+
4. Offer to help with any questions about the project.
13+
14+
Style:
15+
- Be concise and friendly.
16+
- Respond in 简体中文.
17+
- Keep responses short — no more than a few sentences.

README_EN.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Claude Code Best V5 (CCB)
2+
3+
[![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)
4+
[![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)
5+
[![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)
6+
[![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)
7+
[![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)
8+
[![Bun](https://img.shields.io/badge/runtime-Bun-black?style=flat-square&logo=bun)](https://bun.sh/)
9+
10+
> Which Claude do you like? The open source one is the best.
11+
12+
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.
13+
14+
[Documentation (Chinese)](https://ccb.agent-aura.top/) — PR contributions welcome.
15+
16+
Sponsor placeholder.
17+
18+
- [x] v1: Basic runability and type checking pass
19+
- [x] V2: Complete engineering infrastructure
20+
- [ ] Biome formatting may not be implemented first to avoid code conflicts
21+
- [x] Build pipeline complete, output runnable on both Node.js and Bun
22+
- [x] V3: Extensive documentation and documentation site improvements
23+
- [x] V4: Large-scale test suite for improved stability
24+
- [x] Buddy pet feature restored [Docs](https://ccb.agent-aura.top/docs/features/buddy)
25+
- [x] Auto Mode restored [Docs](https://ccb.agent-aura.top/docs/safety/auto-mode)
26+
- [x] All features now configurable via environment variables instead of `bun --feature`
27+
- [x] V5: Enterprise-grade monitoring/reporting, missing tools补全, restrictions removed
28+
- [x] Removed anti-distillation code
29+
- [x] Web search capability (using Bing) [Docs](https://ccb.agent-aura.top/docs/features/web-browser-tool)
30+
- [x] Debug mode support [Docs](https://ccb.agent-aura.top/docs/features/debug-mode)
31+
- [x] Disabled auto-updates
32+
- [x] Custom Sentry error reporting support [Docs](https://ccb.agent-aura.top/docs/internals/sentry-setup)
33+
- [x] Custom GrowthBook support (GB is open source — configure your own feature flag platform) [Docs](https://ccb.agent-aura.top/docs/internals/growthbook-adapter)
34+
- [x] Custom login mode — configure Claude models your way
35+
- [ ] V6: Large-scale refactoring, full modular packaging
36+
- [ ] V6 will be a new branch; main branch will be archived as a historical version
37+
38+
> I don't know how long this project will survive. Star + Fork + git clone + .zip is the safest bet.
39+
>
40+
> This project updates rapidly — Opus continuously optimizes in the background, with new changes almost every few hours.
41+
>
42+
> Claude has burned over $1000, out of budget, switching to GLM to continue; @zai-org GLM 5.1 is quite capable.
43+
44+
## Quick Start
45+
46+
### Prerequisites
47+
48+
Make sure you're on the latest version of Bun, otherwise you'll run into all sorts of weird bugs. Run `bun upgrade`!
49+
50+
- [Bun](https://bun.sh/) >= 1.3.11
51+
- Standard Claude Code configuration — each provider has its own setup method
52+
53+
### Install
54+
55+
```bash
56+
bun install
57+
```
58+
59+
### Run
60+
61+
```bash
62+
# Dev mode — if you see version 888, it's working
63+
bun run dev
64+
65+
# Build
66+
bun run build
67+
```
68+
69+
The build uses code splitting (`build.ts`), outputting to `dist/` (entry `dist/cli.js` + ~450 chunk files).
70+
71+
The build output runs on both Bun and Node.js — you can publish to a private registry and run directly.
72+
73+
If you encounter a bug, please open an issue — we'll prioritize it.
74+
75+
### First-time Setup /login
76+
77+
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).
78+
79+
Fields to fill in:
80+
81+
| Field | Description | Example |
82+
|-------|-------------|---------|
83+
| Base URL | API service URL | `https://api.example.com/v1` |
84+
| API Key | Authentication key | `sk-xxx` |
85+
| Haiku Model | Fast model ID | `claude-haiku-4-5-20251001` |
86+
| Sonnet Model | Balanced model ID | `claude-sonnet-4-6` |
87+
| Opus Model | High-performance model ID | `claude-opus-4-6` |
88+
89+
- **Tab / Shift+Tab** to switch fields, **Enter** to confirm and move to the next, press Enter on the last field to save
90+
- Model fields auto-fill from current environment variables
91+
- Configuration saves to `~/.claude/settings.json` under the `env` key, effective immediately
92+
93+
You can also edit `~/.claude/settings.json` directly:
94+
95+
```json
96+
{
97+
"env": {
98+
"ANTHROPIC_BASE_URL": "https://api.example.com/v1",
99+
"ANTHROPIC_AUTH_TOKEN": "sk-xxx",
100+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001",
101+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
102+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-6"
103+
}
104+
}
105+
```
106+
107+
> Supports all Anthropic API-compatible services (e.g., OpenRouter, AWS Bedrock proxies, etc.) as long as the interface is compatible with the Messages API.
108+
109+
## Feature Flags
110+
111+
All feature toggles are enabled via `FEATURE_<FLAG_NAME>=1` environment variables, for example:
112+
113+
```bash
114+
FEATURE_BUDDY=1 FEATURE_FORK_SUBAGENT=1 bun run dev
115+
```
116+
117+
See [`docs/features/`](docs/features/) for detailed descriptions of each feature. Contributions welcome.
118+
119+
## VS Code Debugging
120+
121+
The TUI (REPL) mode requires a real terminal and cannot be launched directly via VS Code's launch config. Use **attach mode**:
122+
123+
### Steps
124+
125+
1. **Start inspect server in terminal**:
126+
```bash
127+
bun run dev:inspect
128+
```
129+
This outputs an address like `ws://localhost:8888/xxxxxxxx`.
130+
131+
2. **Attach debugger from VS Code**:
132+
- Set breakpoints in `src/` files
133+
- Press F5 → select **"Attach to Bun (TUI debug)"**
134+
135+
## Documentation & Links
136+
137+
- **Online docs (Mintlify)**: [ccb.agent-aura.top](https://ccb.agent-aura.top/) — source in [`docs/`](docs/), PR contributions welcome
138+
- **DeepWiki**: <https://deepwiki.com/claude-code-best/claude-code>
139+
140+
## Contributors
141+
142+
<a href="https://github.com/claude-code-best/claude-code/graphs/contributors">
143+
<img src="https://contrib.rocks/image?repo=claude-code-best/claude-code" />
144+
</a>
145+
146+
## Star History
147+
148+
<a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left">
149+
<picture>
150+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&theme=dark&legend=top-left" />
151+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left" />
152+
<img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left" />
153+
</picture>
154+
</a>
155+
156+
## License
157+
158+
This project is for educational and research purposes only. All rights to Claude Code belong to [Anthropic](https://www.anthropic.com/).

docs/external-dependencies.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# Claude Code 远程服务器依赖
2+
3+
> 只列出代码中实际发起网络请求的远程服务。本地服务、npm 包依赖、展示用 URL 不包含在内。
4+
5+
## 总览表
6+
7+
| # | 服务 | 远程端点 | 协议 | 状态 |
8+
|---|---|---|---|---|
9+
| 1 | Anthropic API | `api.anthropic.com` | HTTPS | 默认启用 |
10+
| 2 | AWS Bedrock | `bedrock-runtime.*.amazonaws.com` | HTTPS |`CLAUDE_CODE_USE_BEDROCK=1` |
11+
| 3 | Google Vertex AI | `{region}-aiplatform.googleapis.com` | HTTPS |`CLAUDE_CODE_USE_VERTEX=1` |
12+
| 4 | Azure Foundry | `{resource}.services.ai.azure.com` | HTTPS |`CLAUDE_CODE_USE_FOUNDRY=1` |
13+
| 5 | OAuth (Anthropic) | `platform.claude.com`, `claude.com`, `claude.ai` | HTTPS | 用户登录时 |
14+
| 6 | GrowthBook | `api.anthropic.com` (remoteEval) | HTTPS | 默认启用 |
15+
| 7 | Sentry | 可配置 (`SENTRY_DSN`) | HTTPS | 需设环境变量 |
16+
| 8 | Datadog | 可配置 (`DATADOG_LOGS_ENDPOINT`) | HTTPS | 需设环境变量 |
17+
| 9 | OpenTelemetry Collector | 可配置 (`OTEL_EXPORTER_OTLP_ENDPOINT`) | gRPC/HTTP | 需设环境变量 |
18+
| 10 | 1P Event Logging | `api.anthropic.com/api/event_logging/batch` | HTTPS | 默认启用 |
19+
| 11 | BigQuery Metrics | `api.anthropic.com/api/claude_code/metrics` | HTTPS | 默认启用 |
20+
| 12 | MCP Proxy | `mcp-proxy.anthropic.com` | HTTPS+WS | 使用 MCP 工具时 |
21+
| 13 | MCP Registry | `api.anthropic.com/mcp-registry` | HTTPS | 查询 MCP 服务器时 |
22+
| 14 | Bing Search | `www.bing.com` | HTTPS | WebSearch 工具 |
23+
| 15 | Google Cloud Storage (更新) | `storage.googleapis.com` | HTTPS | 版本检查 |
24+
| 16 | GitHub Raw (Changelog/Stats) | `raw.githubusercontent.com` | HTTPS | 更新提示 |
25+
| 17 | Claude in Chrome Bridge | `bridge.claudeusercontent.com` | WSS | Chrome 集成 |
26+
| 18 | CCR Upstream Proxy | `api.anthropic.com` | WS | CCR 远程会话 |
27+
| 19 | Voice STT | `api.anthropic.com/api/ws/...` | WSS | Voice Mode |
28+
| 20 | Desktop App Download | `claude.ai/api/desktop/...` | HTTPS | 下载引导 |
29+
30+
---
31+
32+
## 详细说明
33+
34+
### 1. Anthropic Messages API
35+
36+
核心 LLM 推理服务,发送对话消息、接收流式响应。
37+
38+
- **端点**: `https://api.anthropic.com` (生产) / `https://api-staging.anthropic.com` (staging)
39+
- **覆盖**: `ANTHROPIC_BASE_URL` 环境变量
40+
- **认证**: API Key / OAuth Token
41+
- **文件**: `src/services/api/client.ts`, `src/services/api/claude.ts`
42+
43+
### 2. AWS Bedrock
44+
45+
- **端点**: `bedrock-runtime.{region}.amazonaws.com`
46+
- **认证**: AWS 凭证链 / `AWS_BEARER_TOKEN_BEDROCK`
47+
- **文件**: `src/services/api/client.ts:153-190`, `src/utils/aws.ts`
48+
49+
### 3. Google Vertex AI
50+
51+
- **端点**: `{region}-aiplatform.googleapis.com`
52+
- **认证**: `GoogleAuth` + `cloud-platform` scope
53+
- **文件**: `src/services/api/client.ts:228-298`
54+
55+
### 4. Azure Foundry
56+
57+
- **端点**: `https://{resource}.services.ai.azure.com/anthropic/v1/messages`
58+
- **认证**: API Key 或 Azure AD `DefaultAzureCredential`
59+
- **文件**: `src/services/api/client.ts:191-220`
60+
61+
### 5. OAuth
62+
63+
OAuth 2.0 + PKCE 授权码流程。
64+
65+
- **端点**:
66+
- `https://platform.claude.com/oauth/authorize` — 授权页
67+
- `https://claude.com/cai/oauth/authorize` — Claude.ai 授权
68+
- `https://platform.claude.com/v1/oauth/token` — Token 交换
69+
- `https://api.anthropic.com/api/oauth/claude_cli/create_api_key` — 创建 API Key
70+
- `https://api.anthropic.com/api/oauth/claude_cli/roles` — 获取角色
71+
- `https://claude.ai/oauth/claude-code-client-metadata` — MCP 客户端元数据
72+
- `https://claude.fedstart.com` — FedStart 政府部署
73+
- **文件**: `src/constants/oauth.ts`, `src/services/oauth/`
74+
75+
### 6. GrowthBook (功能开关)
76+
77+
- **端点**: `https://api.anthropic.com/` (remoteEval 模式) 或 `CLAUDE_GB_ADAPTER_URL`
78+
- **SDK Keys**: `sdk-zAZezfDKGoZuXXKe` (外部), `sdk-xRVcrliHIlrg4og4` (ant prod), `sdk-yZQvlplybuXjYh6L` (ant dev)
79+
- **文件**: `src/services/analytics/growthbook.ts`, `src/constants/keys.ts`
80+
81+
### 7. Sentry (错误追踪)
82+
83+
- **激活**: 设置 `SENTRY_DSN` (默认未配置)
84+
- **行为**: 仅错误上报,自动过滤敏感 header
85+
- **文件**: `src/utils/sentry.ts`
86+
87+
### 8. Datadog (日志)
88+
89+
- **激活**: 同时设 `DATADOG_LOGS_ENDPOINT` + `DATADOG_API_KEY` (默认未配置)
90+
- **文件**: `src/services/analytics/datadog.ts`
91+
92+
### 9. OpenTelemetry Collector
93+
94+
- **激活**: `CLAUDE_CODE_ENABLE_TELEMETRY=1``OTEL_*` 环境变量
95+
- **协议**: gRPC / HTTP / Protobuf,支持 OTLP 和 Prometheus 导出
96+
- **文件**: `src/utils/telemetry/instrumentation.ts`
97+
98+
### 10. 1P Event Logging (内部事件)
99+
100+
- **端点**: `https://api.anthropic.com/api/event_logging/batch`
101+
- **协议**: 批量导出 (10s 间隔, 每批 200 事件)
102+
- **文件**: `src/services/analytics/firstPartyEventLoggingExporter.ts`
103+
104+
### 11. BigQuery Metrics
105+
106+
- **端点**: `https://api.anthropic.com/api/claude_code/metrics`
107+
- **文件**: `src/utils/telemetry/bigqueryExporter.ts`
108+
109+
### 12. MCP Proxy
110+
111+
Anthropic 托管的 MCP 服务器代理。
112+
113+
- **端点**: `https://mcp-proxy.anthropic.com/v1/mcp/{server_id}`
114+
- **认证**: Claude.ai OAuth tokens
115+
- **文件**: `src/services/mcp/client.ts`, `src/constants/oauth.ts`
116+
117+
### 13. MCP Registry
118+
119+
获取官方 MCP 服务器列表。
120+
121+
- **端点**: `https://api.anthropic.com/mcp-registry/v0/servers?version=latest&visibility=commercial`
122+
- **文件**: `src/services/mcp/officialRegistry.ts`
123+
124+
### 14. Bing Search
125+
126+
WebSearch 工具的默认适配器,抓取 Bing 搜索结果。
127+
128+
- **端点**: `https://www.bing.com/search?q={query}&setmkt=en-US`
129+
- **文件**: `src/tools/WebSearchTool/adapters/bingAdapter.ts`
130+
131+
另外还有 Domain Blocklist 查询:
132+
- **端点**: `https://api.anthropic.com/api/web/domain_info?domain={domain}`
133+
- **文件**: `src/tools/WebFetchTool/utils.ts`
134+
135+
### 15. Google Cloud Storage (自动更新)
136+
137+
- **端点**: `https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`
138+
- **文件**: `src/utils/autoUpdater.ts`
139+
140+
### 16. GitHub Raw Content
141+
142+
- **端点**: `https://raw.githubusercontent.com/anthropics/claude-code/refs/heads/main/CHANGELOG.md`
143+
- **端点**: `https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json`
144+
- **文件**: `src/utils/releaseNotes.ts`, `src/utils/plugins/installCounts.ts`
145+
146+
### 17. Claude in Chrome Bridge
147+
148+
- **端点**: `wss://bridge.claudeusercontent.com` (生产) / `wss://bridge-staging.claudeusercontent.com` (staging)
149+
- **文件**: `src/utils/claudeInChrome/mcpServer.ts`
150+
151+
### 18. CCR Upstream Proxy
152+
153+
- **端点**: `ws://api.anthropic.com/v1/code/upstreamproxy/ws`
154+
- **激活**: `CLAUDE_CODE_REMOTE=1` + `CCR_UPSTREAM_PROXY_ENABLED=1`
155+
- **文件**: `src/upstreamproxy/upstreamproxy.ts`
156+
157+
### 19. Voice STT
158+
159+
- **端点**: `wss://api.anthropic.com/api/ws/...`
160+
- **文件**: `src/services/voiceStreamSTT.ts`
161+
162+
### 20. Desktop App Download
163+
164+
- **端点**: `https://claude.ai/api/desktop/win32/x64/exe/latest/redirect` (Windows)
165+
- **端点**: `https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect` (macOS)
166+
- **文件**: `src/components/DesktopHandoff.tsx`
167+
168+
---
169+
170+
## Anthropic API 辅助端点汇总
171+
172+
以下端点都挂在 `api.anthropic.com` 上,按功能分类:
173+
174+
| 端点路径 | 用途 | 文件 |
175+
|---|---|---|
176+
| `/api/event_logging/batch` | 事件批量上报 | `src/services/analytics/firstPartyEventLoggingExporter.ts` |
177+
| `/api/claude_code/metrics` | BigQuery 指标导出 | `src/utils/telemetry/bigqueryExporter.ts` |
178+
| `/api/oauth/claude_cli/create_api_key` | 创建 API Key | `src/constants/oauth.ts` |
179+
| `/api/oauth/claude_cli/roles` | 获取用户角色 | `src/constants/oauth.ts` |
180+
| `/api/oauth/accounts/grove` | 通知设置 | `src/services/api/grove.ts` |
181+
| `/api/oauth/organizations/{id}/referral/*` | 推荐活动 | `src/services/api/referral.ts` |
182+
| `/api/oauth/organizations/{id}/overage_credit_grant` | 超额信用 | `src/services/api/overageCreditGrant.ts` |
183+
| `/api/oauth/organizations/{id}/admin_requests` | 管理请求 | `src/services/api/adminRequests.ts` |
184+
| `/api/web/domain_info?domain={}` | 域名安全检查 | `src/tools/WebFetchTool/utils.ts` |
185+
| `/api/claude_code/settings` | 设置同步 | `src/services/settingsSync/index.ts` |
186+
| `/api/claude_code/managed_settings` | 企业托管设置 (1h 轮询) | `src/services/remoteManagedSettings/index.ts` |
187+
| `/api/claude_code/team_memory?repo={}` | 团队记忆同步 | `src/services/teamMemorySync/index.ts` |
188+
| `/api/auth/trusted_devices` | 可信设备注册 | `src/bridge/trustedDevice.ts` |
189+
| `/api/organizations/{id}/claude_code/buddy_react` | Companion 反应 | `src/buddy/companionReact.ts` |
190+
| `/mcp-registry/v0/servers` | MCP 服务器注册表 | `src/services/mcp/officialRegistry.ts` |
191+
| `/v1/files` | 文件上传/下载 | `src/services/api/filesApi.ts` |
192+
| `/v1/sessions/{id}/events` | 会话历史 | `src/assistant/sessionHistory.ts` |
193+
| `/v1/code/triggers` | 远程触发器 | `src/tools/RemoteTriggerTool/RemoteTriggerTool.ts` |
194+
| `/v1/organizations/{id}/mcp_servers` | 组织 MCP 配置 | `src/services/mcp/claudeai.ts` |
195+
196+
## 非 Anthropic 远程域名汇总
197+
198+
| 域名 | 服务 | 协议 |
199+
|---|---|---|
200+
| `bedrock-runtime.*.amazonaws.com` | AWS Bedrock | HTTPS |
201+
| `{region}-aiplatform.googleapis.com` | Google Vertex AI | HTTPS |
202+
| `{resource}.services.ai.azure.com` | Azure Foundry | HTTPS |
203+
| `www.bing.com` | Bing 搜索 | HTTPS |
204+
| `storage.googleapis.com` | 自动更新 | HTTPS |
205+
| `raw.githubusercontent.com` | Changelog / 插件统计 | HTTPS |
206+
| `bridge.claudeusercontent.com` | Chrome Bridge | WSS |
207+
| `platform.claude.com` | OAuth 授权页 | HTTPS |
208+
| `claude.com` / `claude.ai` | OAuth / 下载 | HTTPS |
209+
| `claude.fedstart.com` | FedStart OAuth | HTTPS |

0 commit comments

Comments
 (0)