feat: 完成最新的可构建版本
This commit is contained in:
parent
604110272f
commit
9a57642d3a
22
README.md
22
README.md
@ -2,22 +2,22 @@
|
||||
|
||||
Anthropic 官方 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI 工具的源码反编译/逆向还原项目。目标是将 Claude Code 大部分功能及工程化能力复现。虽然很难绷, 但是它叫做 CCB(踩踩背)...
|
||||
|
||||
> V1 会完成跑通及基本的类型检查通过;
|
||||
> V1 会完成跑通及基本的类型检查通过;
|
||||
>
|
||||
> V2 会完整实现工程化配套设施;
|
||||
> V2 会完整实现工程化配套设施;
|
||||
>
|
||||
> V3 会实现多层级解耦, 很多比如 UI 包, Agent 包都可以独立优化;
|
||||
> V3 会实现多层级解耦, 很多比如 UI 包, Agent 包都可以独立优化;
|
||||
>
|
||||
> V4 会完成大量的测试文件, 以提高稳定性
|
||||
>
|
||||
> 我不知道这个项目还会存在多久, fork 不好使, git clone 或者下载 .zip 包才稳健;
|
||||
>
|
||||
>
|
||||
> 这个项目更新很快, 后台有 Opus 持续优化, 所以你可以提 issues, 但是 PR 暂时不会接受;
|
||||
>
|
||||
> 存活记录:
|
||||
> 开源后 12 小时: 愚人节, star 破 1k, 并且牢 A 没有发邮件搞这个项目
|
||||
>
|
||||
> 如果你想要私人咨询服务, 那么可以发送邮件到 claude-code-best@proton.me, 备注咨询与联系方式即可; 由于后续工作非常多, 可能会忽略邮件, 半天没回复, 可以多发;
|
||||
> 如果你想要私人咨询服务, 那么可以发送邮件到 <claude-code-best@proton.me>, 备注咨询与联系方式即可; 由于后续工作非常多, 可能会忽略邮件, 半天没回复, 可以多发;
|
||||
|
||||
## 快速开始
|
||||
|
||||
@ -26,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 的方式, 各大提供商都有自己的配置方式
|
||||
|
||||
### 安装
|
||||
|
||||
@ -41,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 MB,5326 模块)。
|
||||
构建产物会输出到 `dist/cli.js`, 构建出的版本 bun 和 node 都可以启动, 你 publish 到私有源可以直接启动
|
||||
|
||||
## 能力清单
|
||||
|
||||
@ -302,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`
|
||||
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
|
||||
47
build.ts
Normal file
47
build.ts
Normal 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)`,
|
||||
);
|
||||
@ -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/",
|
||||
|
||||
@ -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,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user