Compare commits

..

10 Commits

Author SHA1 Message Date
claude-code-best
9a57642d3a feat: 完成最新的可构建版本 2026-04-01 10:42:53 +08:00
claude-code-best
604110272f docs: 尝试修复 docs 的位置 2026-04-01 10:09:00 +08:00
claude-code-best
b32dd4549d fix: 修复构建问题 2026-04-01 09:58:26 +08:00
claude-code-best
0135ad99ad chore: 更新 lock 文件 2026-04-01 09:54:12 +08:00
claude-code-best
9018c7afdb Merge branch 'feature/prod' 2026-04-01 09:53:21 +08:00
claude-code-best
ce2f19cc48 Merge pull request #5 from claude-code-best/feature/prod
docs: mintlify 文档撰写
2026-04-01 09:29:58 +08:00
claude-code-best
c57f5a29e8 Merge pull request #4 from claude-code-best/feature/prod
Feature/prod
2026-04-01 09:05:04 +08:00
claude-code-best
8f6800f508 Create SECURITY.md 2026-04-01 08:54:08 +08:00
claude-code-best
04c8ef2ecc docs: 调整样式 2026-03-31 23:21:54 +00:00
claude-code-best
b759df5b0e docs: 继续更新 2026-03-31 23:20:33 +00:00
12 changed files with 201 additions and 122 deletions

View File

@@ -1,17 +1,23 @@
# Claude Code V1
# Claude Code Best V1 (CCB)
Anthropic 官方 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI 工具的源码反编译/逆向还原项目。目标是将 Claude Code 大部分功能及工程化能力复现。
Anthropic 官方 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI 工具的源码反编译/逆向还原项目。目标是将 Claude Code 大部分功能及工程化能力复现。虽然很难绷, 但是它叫做 CCB(踩踩背)...
> V1 会完成跑通及基本的类型检查通过;
> V2 会完整实现工程化配套设施;
> V3 会实现多层级解耦, 很多比如 UI 包, Agent 包都可以独立优化;
> V1 会完成跑通及基本的类型检查通过;
>
> V2 会完整实现工程化配套设施;
>
> V3 会实现多层级解耦, 很多比如 UI 包, Agent 包都可以独立优化;
>
> V4 会完成大量的测试文件, 以提高稳定性
>
> 我不知道这个项目还会存在多久, fork 不好使, git clone 或者下载 .zip 包才稳健;
>
>
> 这个项目更新很快, 后台有 Opus 持续优化, 所以你可以提 issues, 但是 PR 暂时不会接受;
>
> 如果你想要私人咨询服务, 那么可以发送邮件到 claude-code-best@proton.me, 备注咨询与联系方式即可; 由于后续工作非常多, 可能会忽略邮件, 半天没回复, 可以多发;
> 存活记录:
> 开源后 12 小时: 愚人节, star 破 1k, 并且牢 A 没有发邮件搞这个项目
>
> 如果你想要私人咨询服务, 那么可以发送邮件到 <claude-code-best@proton.me>, 备注咨询与联系方式即可; 由于后续工作非常多, 可能会忽略邮件, 半天没回复, 可以多发;
## 快速开始
@@ -20,8 +26,7 @@ Anthropic 官方 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) C
一定要最新版本的 bun 啊, 不然一堆奇奇怪怪的 BUG!!! bun upgrade!!!
- [Bun](https://bun.sh/) >= 1.3.11
- Node.js >= 18部分依赖需要
- 有效的 Anthropic API Key或 Bedrock / Vertex 凭据)
- 常规的配置 CC 的方式, 各大提供商都有自己的配置方式
### 安装
@@ -35,17 +40,11 @@ bun install
# 开发模式, 看到版本号 888 说明就是对了
bun run dev
# 直接运行
bun run src/entrypoints/cli.tsx
# 管道模式(-p
echo "say hello" | bun run src/entrypoints/cli.tsx -p
# 构建
bun run build
```
构建产物输出到 `dist/cli.js`~25.75 MB5326 模块)。
构建产物输出到 `dist/cli.js`, 构建出的版本 bun 和 node 都可以启动, 你 publish 到私有源可以直接启动
## 能力清单
@@ -296,7 +295,6 @@ bun run build
`ABLATION_BASELINE` `AGENT_MEMORY_SNAPSHOT` `BG_SESSIONS` `BRIDGE_MODE` `BUDDY` `CCR_MIRROR` `CCR_REMOTE_SETUP` `CHICAGO_MCP` `COORDINATOR_MODE` `DAEMON` `DIRECT_CONNECT` `EXPERIMENTAL_SKILL_SEARCH` `FORK_SUBAGENT` `HARD_FAIL` `HISTORY_SNIP` `KAIROS` `KAIROS_BRIEF` `KAIROS_CHANNELS` `KAIROS_GITHUB_WEBHOOKS` `LODESTONE` `MCP_SKILLS` `PROACTIVE` `SSH_REMOTE` `TORCH` `TRANSCRIPT_CLASSIFIER` `UDS_INBOX` `ULTRAPLAN` `UPLOAD_USER_SETTINGS` `VOICE_MODE` `WEB_BROWSER_TOOL` `WORKFLOW_SCRIPTS`
## 项目结构
```

21
SECURITY.md Normal file
View File

@@ -0,0 +1,21 @@
# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |
## Reporting a Vulnerability
Use this section to tell people how to report a vulnerability.
Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.

47
build.ts Normal file
View File

@@ -0,0 +1,47 @@
import { readdir, readFile, writeFile } from "fs/promises";
import { join } from "path";
const outdir = "dist";
// Step 1: Clean output directory
const { rmSync } = await import("fs");
rmSync(outdir, { recursive: true, force: true });
// Step 2: Bundle with splitting
const result = await Bun.build({
entrypoints: ["src/entrypoints/cli.tsx"],
outdir,
target: "bun",
splitting: true,
});
if (!result.success) {
console.error("Build failed:");
for (const log of result.logs) {
console.error(log);
}
process.exit(1);
}
// Step 3: Post-process — replace Bun-only `import.meta.require` with Node.js compatible version
const files = await readdir(outdir);
const IMPORT_META_REQUIRE = "var __require = import.meta.require;";
const COMPAT_REQUIRE = `var __require = typeof import.meta.require === "function" ? import.meta.require : (await import("module")).createRequire(import.meta.url);`;
let patched = 0;
for (const file of files) {
if (!file.endsWith(".js")) continue;
const filePath = join(outdir, file);
const content = await readFile(filePath, "utf-8");
if (content.includes(IMPORT_META_REQUIRE)) {
await writeFile(
filePath,
content.replace(IMPORT_META_REQUIRE, COMPAT_REQUIRE),
);
patched++;
}
}
console.log(
`Bundled ${result.outputs.length} files to ${outdir}/ (patched ${patched} for Node.js compat)`,
);

View File

@@ -4,7 +4,7 @@
"workspaces": {
"": {
"name": "claude-code",
"dependencies": {
"devDependencies": {
"@alcalzone/ansi-tokenize": "^0.3.0",
"@ant/claude-for-chrome-mcp": "workspace:*",
"@ant/computer-use-input": "workspace:*",
@@ -23,6 +23,7 @@
"@aws-sdk/credential-provider-node": "^3.972.28",
"@aws-sdk/credential-providers": "^3.1020.0",
"@azure/identity": "^4.13.1",
"@biomejs/biome": "^2.4.10",
"@commander-js/extra-typings": "^14.0.0",
"@growthbook/growthbook": "^1.6.5",
"@modelcontextprotocol/sdk": "^1.29.0",
@@ -46,6 +47,13 @@
"@opentelemetry/semantic-conventions": "^1.40.0",
"@smithy/core": "^3.23.13",
"@smithy/node-http-handler": "^4.5.1",
"@types/bun": "^1.3.11",
"@types/cacache": "^20.0.1",
"@types/plist": "^3.0.5",
"@types/react": "^19.2.14",
"@types/react-reconciler": "^0.33.0",
"@types/sharp": "^0.32.0",
"@types/turndown": "^5.0.6",
"ajv": "^8.18.0",
"asciichart": "^1.5.25",
"audio-capture-napi": "workspace:*",
@@ -74,6 +82,7 @@
"image-processor-napi": "workspace:*",
"indent-string": "^5.0.0",
"jsonc-parser": "^3.3.1",
"knip": "^6.1.1",
"lodash-es": "^4.17.23",
"lru-cache": "^11.2.7",
"marked": "^17.0.5",
@@ -96,6 +105,7 @@
"tree-kill": "^1.2.2",
"turndown": "^7.2.2",
"type-fest": "^5.5.0",
"typescript": "^6.0.2",
"undici": "^7.24.6",
"url-handler-napi": "workspace:*",
"usehooks-ts": "^3.1.1",
@@ -108,18 +118,6 @@
"yaml": "^2.8.3",
"zod": "^4.3.6",
},
"devDependencies": {
"@biomejs/biome": "^2.4.10",
"@types/bun": "^1.3.11",
"@types/cacache": "^20.0.1",
"@types/plist": "^3.0.5",
"@types/react": "^19.2.14",
"@types/react-reconciler": "^0.33.0",
"@types/sharp": "^0.32.0",
"@types/turndown": "^5.0.6",
"knip": "^6.1.1",
"typescript": "^6.0.2",
},
},
"packages/@ant/claude-for-chrome-mcp": {
"name": "@ant/claude-for-chrome-mcp",

4
docs/favicon.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
<circle cx="16" cy="16" r="14" fill="#D97706"/>
<path d="M12 10l10 6-10 6V10z" fill="#FFFFFF"/>
</svg>

After

Width:  |  Height:  |  Size: 180 B

5
docs/logo/dark.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 28" fill="none">
<circle cx="14" cy="14" r="11" stroke="#F59E0B" stroke-width="2" fill="none"/>
<path d="M11 10l6 4-6 4V10z" fill="#F59E0B"/>
<text x="30" y="19.5" font-family="system-ui, -apple-system, sans-serif" font-size="15" font-weight="700" letter-spacing="1" fill="#F1F5F9">CCB</text>
</svg>

After

Width:  |  Height:  |  Size: 362 B

5
docs/logo/light.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 28" fill="none">
<circle cx="14" cy="14" r="11" stroke="#D97706" stroke-width="2" fill="none"/>
<path d="M11 10l6 4-6 4V10z" fill="#D97706"/>
<text x="30" y="19.5" font-family="system-ui, -apple-system, sans-serif" font-size="15" font-weight="700" letter-spacing="1" fill="#0F172A">CCB</text>
</svg>

After

Width:  |  Height:  |  Size: 362 B

View File

@@ -1,84 +0,0 @@
{
"$schema": "https://mintlify.com/schema.json",
"name": "Claude Code Architecture",
"logo": {
"dark": "/logo/dark.svg",
"light": "/logo/light.svg"
},
"favicon": "/favicon.svg",
"colors": {
"primary": "#D97706",
"light": "#F59E0B",
"dark": "#B45309",
"background": {
"dark": "#0F172A",
"light": "#FFFFFF"
}
},
"navigation": [
{
"group": "开始",
"pages": [
"introduction/what-is-claude-code",
"introduction/why-this-whitepaper",
"introduction/architecture-overview"
]
},
{
"group": "对话是如何运转的",
"pages": [
"conversation/the-loop",
"conversation/streaming",
"conversation/multi-turn"
]
},
{
"group": "工具AI 的双手",
"pages": [
"tools/what-are-tools",
"tools/file-operations",
"tools/shell-execution",
"tools/search-and-navigation",
"tools/task-management"
]
},
{
"group": "安全与权限",
"pages": [
"safety/why-safety-matters",
"safety/permission-model",
"safety/sandbox",
"safety/plan-mode"
]
},
{
"group": "上下文工程",
"pages": [
"context/system-prompt",
"context/project-memory",
"context/compaction",
"context/token-budget"
]
},
{
"group": "多 Agent 协作",
"pages": [
"agent/sub-agents",
"agent/worktree-isolation",
"agent/coordinator-and-swarm"
]
},
{
"group": "可扩展性",
"pages": [
"extensibility/mcp-protocol",
"extensibility/hooks",
"extensibility/skills",
"extensibility/custom-agents"
]
}
],
"footerSocials": {
"github": "https://github.com/anthropics/claude-code"
}
}

84
mint.json Normal file
View File

@@ -0,0 +1,84 @@
{
"$schema": "https://mintlify.com/schema.json",
"name": "Claude Code Architecture",
"logo": {
"dark": "/docs/logo/dark.svg",
"light": "/docs/logo/light.svg"
},
"favicon": "/docs/favicon.svg",
"colors": {
"primary": "#D97706",
"light": "#F59E0B",
"dark": "#B45309",
"background": {
"dark": "#0F172A",
"light": "#FFFFFF"
}
},
"navigation": [
{
"group": "开始",
"pages": [
"docs/introduction/what-is-claude-code",
"docs/introduction/why-this-whitepaper",
"docs/introduction/architecture-overview"
]
},
{
"group": "对话是如何运转的",
"pages": [
"docs/conversation/the-loop",
"docs/conversation/streaming",
"docs/conversation/multi-turn"
]
},
{
"group": "工具AI 的双手",
"pages": [
"docs/tools/what-are-tools",
"docs/tools/file-operations",
"docs/tools/shell-execution",
"docs/tools/search-and-navigation",
"docs/tools/task-management"
]
},
{
"group": "安全与权限",
"pages": [
"docs/safety/why-safety-matters",
"docs/safety/permission-model",
"docs/safety/sandbox",
"docs/safety/plan-mode"
]
},
{
"group": "上下文工程",
"pages": [
"docs/context/system-prompt",
"docs/context/project-memory",
"docs/context/compaction",
"docs/context/token-budget"
]
},
{
"group": "多 Agent 协作",
"pages": [
"docs/agent/sub-agents",
"docs/agent/worktree-isolation",
"docs/agent/coordinator-and-swarm"
]
},
{
"group": "可扩展性",
"pages": [
"docs/extensibility/mcp-protocol",
"docs/extensibility/hooks",
"docs/extensibility/skills",
"docs/extensibility/custom-agents"
]
}
],
"footerSocials": {
"github": "https://github.com/anthropics/claude-code"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "claude-js",
"version": "1.0.1",
"version": "1.0.2",
"description": "Reverse-engineered Anthropic Claude Code CLI — interactive AI coding assistant in the terminal",
"type": "module",
"author": "claude-code-best <claude-code-best@proton.me>",
@@ -35,7 +35,7 @@
"dist"
],
"scripts": {
"build": "bun build src/entrypoints/cli.tsx --outdir dist --target bun",
"build": "bun run build.ts",
"dev": "bun run src/entrypoints/cli.tsx",
"prepublishOnly": "bun run build",
"lint": "biome lint src/",
@@ -44,7 +44,8 @@
"prepare": "git config core.hooksPath .githooks",
"test": "bun test",
"check:unused": "knip-bun",
"health": "bun run scripts/health-check.ts"
"health": "bun run scripts/health-check.ts",
"docs:dev": "npx mintlify dev"
},
"dependencies": {},
"devDependencies": {

View File

@@ -1,5 +1,3 @@
import { dlopen, FFIType, suffix } from "bun:ffi";
const FLAG_SHIFT = 0x20000;
const FLAG_CONTROL = 0x40000;
const FLAG_OPTION = 0x80000;
@@ -23,12 +21,13 @@ function loadFFI(): void {
}
try {
const lib = dlopen(
const ffi = require("bun:ffi") as typeof import("bun:ffi");
const lib = ffi.dlopen(
`/System/Library/Frameworks/Carbon.framework/Carbon`,
{
CGEventSourceFlagsState: {
args: [FFIType.i32],
returns: FFIType.u64,
args: [ffi.FFIType.i32],
returns: ffi.FFIType.u64,
},
}
);

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bun
// Runtime polyfill for bun:bundle (build-time macros)
const feature = (_name: string) => false;
if (typeof globalThis.MACRO === "undefined") {