feat: 开源发布 — 完整 README、MIT 许可证、22+ 大模型厂商支持

- 重写 README.md:项目简介、快速开始、22+ 厂商列表、功能特性、架构说明、配置指南、FAQ、贡献指南
- 新增 MIT LICENSE
- 包含全部源码与文档
This commit is contained in:
weiqianpu 2026-04-02 02:34:24 +00:00
parent 5d0bc60cce
commit cf1707bbb0
2890 changed files with 1904 additions and 771 deletions

0
.editorconfig Normal file → Executable file
View File

0
.github/workflows/ci.yml vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
CLAUDE.md Normal file → Executable file
View File

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 嘉陵江-code
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

808
README.md Normal file → Executable file
View File

@ -1,436 +1,472 @@
# Claude Code Best V3 (CCB)
# 嘉陵江-code (Jialing Code)
牢 A (Anthropic) 官方 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI 工具的源码反编译/逆向还原项目。目标是将 Claude Code 大部分功能及工程化能力复现。虽然很难绷, 但是它叫做 CCB(踩踩背)...
<p align="center">
<strong>🖥️ 终端 AI 编程助手 — 支持 22+ 大模型厂商,默认本地 Ollama 零配置启动</strong>
</p>
[文档在这里, 支持投稿 PR](https://ccb.agent-aura.top/)
<p align="center">
<a href="#快速开始">快速开始</a>
<a href="#支持的模型厂商">模型厂商</a>
<a href="#功能特性">功能特性</a>
<a href="#项目架构">架构</a>
<a href="#配置指南">配置</a>
<a href="#常见问题">FAQ</a>
</p>
赞助商占位符
---
- [x] v1 会完成跑通及基本的类型检查通过;
- [x] V2 会完整实现工程化配套设施;
- [ ] Biome 格式化可能不会先实施, 避免代码冲突
- [x] 构建流水线完成, 产物 Node/Bun 都可以运行
- [x] V3 会写大量文档, 完善文档站点
- [ ] V4 会完成大量的测试文件, 以提高稳定性
## 简介
> 我不知道这个项目还会存在多久, Star + Fork + git clone + .zip 包最稳健;
**嘉陵江-code** 是一个基于终端的 AI 编程助手 CLI 工具fork 自 Anthropic Claude Code 并进行了深度改造,核心目标是:
- **多模型支持**:不再绑定 Anthropic 单一厂商,通过 OpenAI 兼容接口统一接入 22+ 大模型厂商
- **本地优先**:默认使用本地 Ollama无需 API Key、无需联网、零配置即可启动
- **保留核心能力**:完整的 REPL 交互、工具系统、权限管理、MCP 协议支持
- **国内厂商友好**:深度适配 DeepSeek、通义千问、智谱、月之暗面、豆包等国内主流大模型
```
$ jialing-code
╭──────────────────────────────────────╮
│ 嘉陵江-code v1.3.14 │
│ Provider: Ollama (qwen3.5:35b) │
│ Type /help for commands │
╰──────────────────────────────────────╯
>
> 这个项目更新很快, 后台有 Opus 持续优化, 所以你可以提 issues, 但是 PR 暂时不会接受;
>
> Claude 已经烧了 800$ 以上, 如果你个人想赞助, 请随便找个机构捐款, 然后截图在 issues, 大家的力量是温暖的;
>
> 某些模型提供商想要赞助, 那么请私发一个 1w 额度以上的账号到 <claude-code-best@proton.me>; 我们会在赞助商栏直接给你最亮的位置
存活记录:
1. 开源后 24 小时: 突破 6k Star, 感谢各位支持. 完成 docs 文档的站点构建, 达到 v3 版本, 后续开始进行测试用例维护, 完成之后可以接受 PR; 看来牢 A 是不想理我们了;
2. 开源后 15 小时: 完成了构建产物的 node 支持, 现在是完全体了; star 快到 3k 了; 等待牢 A 的邮件
3. 开源后 12 小时: 愚人节, star 破 1k, 并且牢 A 没有发邮件搞这个项目
4. 如果你想要私人咨询服务, 那么可以发送邮件到 <claude-code-best@proton.me>, 备注咨询与联系方式即可; 由于后续工作非常多, 可能会忽略邮件, 半天没回复, 可以多发;
```
## 快速开始
### 环境要求
一定要最新版本的 bun 啊, 不然一堆奇奇怪怪的 BUG!!! bun upgrade!!!
- [Bun](https://bun.sh/) >= 1.3.11**必须最新版本**,旧版有兼容性问题,请先 `bun upgrade`
- (可选)[Ollama](https://ollama.com/) — 本地模型运行时
- (可选)任意云端大模型的 API Key
- [Bun](https://bun.sh/) >= 1.3.11
- 常规的配置 CC 的方式, 各大提供商都有自己的配置方式
### 安装
### 安装与运行
```bash
# 1. 克隆仓库
git clone https://github.com/claude-code-best/claude-code.git
cd claude-code
# 2. 安装依赖
bun install
# 3. 开发模式运行(看到版本号 888 说明启动成功)
bun run dev
# 4. 构建
bun run build
# 5. 构建后运行Bun 或 Node.js 均可)
bun dist/cli.js
node dist/cli.js
```
### 运行
### 全局安装(可选)
构建后可以发布到私有 npm 源,或直接全局链接:
```bash
# 开发模式, 看到版本号 888 说明就是对了
bun run build
bun link # 全局可用 jialing-code / jl 命令
```
### 首次运行
首次运行会进入 **交互式配置向导**,引导你选择模型厂商、填写 API Key、选择模型。也可以通过环境变量预先配置
```bash
# 方式一:使用本地 Ollama默认无需任何配置
jialing-code
# 方式二:通过环境变量指定厂商
export PROVIDER=deepseek
export DEEPSEEK_API_KEY=sk-xxx
jialing-code
# 方式三:使用 --setup 重新配置
jialing-code --setup
```
## 支持的模型厂商
嘉陵江-code 通过统一的 OpenAI 兼容适配器接入所有厂商,无需关心各家 API 差异。
### 国际厂商
| 厂商 | 环境变量 | 默认模型 | 代表模型 |
|------|---------|---------|---------|
| **Anthropic** | `ANTHROPIC_API_KEY` | claude-sonnet-4-20250514 | Claude Opus/Sonnet/Haiku |
| **OpenAI** | `OPENAI_API_KEY` | gpt-4o | GPT-4o, GPT-4.1, o3, o4-mini |
| **Google Gemini** | `GOOGLE_API_KEY` | gemini-2.5-flash | Gemini 2.5 Pro/Flash |
| **Mistral AI** | `MISTRAL_API_KEY` | mistral-large-latest | Mistral Large, Codestral |
| **Groq** | `GROQ_API_KEY` | llama-3.3-70b-versatile | Llama 3.3, Mixtral |
| **xAI** | `XAI_API_KEY` | grok-3 | Grok 3, Grok 3 Mini |
| **Together AI** | `TOGETHER_API_KEY` | meta-llama/Llama-3.3-70B | Llama, Qwen, DeepSeek |
| **Cohere** | `COHERE_API_KEY` | command-a-03-2025 | Command A/R+ |
| **Perplexity** | `PERPLEXITY_API_KEY` | sonar-pro | Sonar Pro/Reasoning |
### 国内厂商
| 厂商 | 环境变量 | 默认模型 | 代表模型 |
|------|---------|---------|---------|
| **DeepSeek** | `DEEPSEEK_API_KEY` | deepseek-chat | DeepSeek V3, R1 |
| **通义千问 (Qwen)** | `QWEN_API_KEY` | qwen-max | Qwen Max/Plus/Turbo, QwQ |
| **智谱 (GLM)** | `ZHIPU_API_KEY` | glm-4-plus | GLM-4 Plus/Flash/Long |
| **月之暗面 (Kimi)** | `MOONSHOT_API_KEY` | moonshot-v1-auto | Kimi 全系列 |
| **豆包 (Doubao)** | `DOUBAO_API_KEY` | doubao-1.5-pro-256k | 豆包 Pro/Lite |
| **百度文心 (Ernie)** | `BAIDU_API_KEY` | ernie-4.5-8k | ERNIE 4.5/4.0/Speed |
| **零一万物 (Yi)** | `YI_API_KEY` | yi-lightning | Yi Lightning/Large |
| **阶跃星辰 (Step)** | `STEPFUN_API_KEY` | step-2-16k | Step 2/1 全系列 |
| **百川 (Baichuan)** | `BAICHUAN_API_KEY` | Baichuan4 | Baichuan 4/3 |
| **MiniMax** | `MINIMAX_API_KEY` | MiniMax-Text-01 | MiniMax Text/Abab |
| **讯飞星火 (Spark)** | `SPARK_API_KEY` | general-v3.5 | Spark Max/Ultra/Pro |
| **腾讯混元** | `HUNYUAN_API_KEY` | hunyuan-turbo | 混元 Turbo/Pro/Lite |
### 聚合平台 & 本地
| 平台 | 环境变量 | 说明 |
|------|---------|------|
| **Ollama** | 无需 Key | 本地运行,默认 `qwen3.5:35b`,零配置 |
| **SiliconFlow** | `SILICONFLOW_API_KEY` | 国内聚合平台,支持多家模型 |
| **OpenRouter** | `OPENROUTER_API_KEY` | 国际聚合平台,统一接入 |
### 企业级部署
| 平台 | 环境变量 | 说明 |
|------|---------|------|
| **AWS Bedrock** | `CLAUDE_CODE_USE_BEDROCK=1` | 需配置 AWS 凭证 |
| **Google Vertex** | `CLAUDE_CODE_USE_VERTEX=1` | 需配置 GCP 凭证 |
| **Azure Foundry** | `CLAUDE_CODE_USE_FOUNDRY=1` | 需配置 Azure AD |
## 功能特性
### 核心能力
| 能力 | 状态 | 说明 |
|------|------|------|
| REPL 交互界面 | ✅ | 基于 Ink 的终端 UI完整交互体验 |
| 流式对话与工具调用 | ✅ | 流式输出 + 自动工具调用循环 |
| 会话引擎 | ✅ | 管理对话状态、上下文压缩、归因追踪 |
| 权限系统 | ✅ | plan/auto/manual 三种模式,细粒度控制 |
| Hook 系统 | ✅ | pre/post tool use 钩子,通过 settings.json 配置 |
| 会话恢复 | ✅ | `/resume` 恢复历史会话 |
| 自动压缩 | ✅ | 超长对话自动 compact节省 token |
| MCP 协议 | ✅ | 支持 Model Context Protocol 扩展 |
| 多厂商适配 | ✅ | 22+ 厂商统一 OpenAI 兼容接口 |
| 思考链支持 | ✅ | 适配 DeepSeek R1、Qwen thinking 等推理模型 |
### 内置工具
| 工具 | 功能 |
|------|------|
| **BashTool** | Shell 命令执行,支持沙箱模式 |
| **FileReadTool** | 文件 / PDF / 图片 / Notebook 读取 |
| **FileEditTool** | 精确字符串替换编辑 + diff 追踪 |
| **FileWriteTool** | 文件创建与覆写 |
| **GlobTool** | 文件模式搜索 |
| **GrepTool** | 内容正则搜索 |
| **AgentTool** | 子代理fork / async / background |
| **WebFetchTool** | URL 抓取 → Markdown 转换 |
| **WebSearchTool** | 网页搜索 + 域名过滤 |
| **NotebookEditTool** | Jupyter Notebook 编辑 |
### 斜杠命令 (90+)
常用命令:
| 命令 | 功能 |
|------|------|
| `/help` | 显示帮助信息 |
| `/model` | 切换模型 |
| `/config` | 查看/修改配置 |
| `/compact` | 手动压缩上下文 |
| `/diff` | 查看文件变更 |
| `/doctor` | 环境诊断 |
| `/resume` | 恢复历史会话 |
| `/memory` | 管理持久记忆 |
| `/mcp` | 管理 MCP 服务器 |
| `/plan` | 进入规划模式 |
| `/permissions` | 权限管理 |
| `/theme` | 切换主题 |
| `/export` | 导出对话 |
| `/vim` | Vim 模式 |
## 配置指南
### 配置文件位置
```
~/.jialing-code/
├── config.json # 主配置厂商、模型、API Key
├── settings.json # 行为设置hooks、权限规则
├── memory/ # 持久记忆存储
└── sessions/ # 会话历史
```
### 环境变量配置
```bash
# ── 厂商选择(二选一) ──
# 方式一:指定厂商名
export PROVIDER=deepseek # 厂商名(小写)
export DEEPSEEK_API_KEY=sk-xxx # 对应 API Key
# 方式二:自动检测(根据已设置的 API Key 自动识别)
export OPENAI_API_KEY=sk-xxx # 设了哪个就用哪个
# ── Anthropic 原生模式 ──
export ANTHROPIC_API_KEY=sk-ant-xxx # Anthropic 直连
export ANTHROPIC_MODEL=claude-sonnet-4-20250514 # 可选,指定模型
# ── 自定义 API 端点 ──
export OPENAI_BASE_URL=https://your-proxy.com/v1 # 自定义兼容端点
export OPENAI_API_KEY=your-key
# ── 其他 ──
export CLAUDE_CODE_SIMPLE=1 # 简洁模式(去掉装饰)
```
### 交互式配置
```bash
# 首次启动自动进入,或手动触发
jialing-code --setup
```
配置向导会:
1. 列出所有支持的厂商
2. 验证 API Key 连通性
3. 拉取可用模型列表供选择
4. 保存到 `~/.jialing-code/config.json`
## 项目架构
```
jialing-code/
├── src/
│ ├── entrypoints/
│ │ ├── cli.tsx # 入口polyfill + 快速路径分发
│ │ └── sdk/ # SDK 导出
│ ├── main.tsx # Commander.js CLI 定义
│ ├── query.ts # API 查询核心(流式 + 工具循环)
│ ├── QueryEngine.ts # 会话引擎(状态管理 + 压缩)
│ ├── services/
│ │ └── api/
│ │ ├── claude.ts # Anthropic 原生 API 客户端
│ │ ├── openaiAdapter.ts # OpenAI 兼容适配器(核心)
│ │ ├── providerRegistry.ts # 22+ 厂商注册表
│ │ ├── client.ts # 客户端工厂
│ │ └── setupWizard.ts # 交互式配置向导
│ ├── tools/ # 工具目录(每个工具独立文件夹)
│ │ ├── BashTool/
│ │ ├── FileEditTool/
│ │ ├── FileReadTool/
│ │ ├── GrepTool/
│ │ ├── AgentTool/
│ │ └── ... # 30+ 工具
│ ├── screens/
│ │ └── REPL.tsx # REPL 主界面5000+ 行)
│ ├── components/ # Ink 终端 UI 组件
│ ├── commands/ # 斜杠命令实现
│ ├── state/ # 状态管理Zustand
│ ├── context.ts # 系统提示词构建
│ └── utils/
│ └── model/
│ └── providers.ts # 厂商检测与路由
├── packages/ # Monorepo workspace 包
│ ├── @ant/ # Computer Use stub 包
│ ├── color-diff-napi/ # 颜色 diff完整实现
│ └── *-napi/ # 其他 NAPI stub 包
├── build.ts # 构建脚本code splitting
├── package.json # Bun workspaces monorepo
├── tsconfig.json # TypeScript 配置
└── CLAUDE.md # Claude Code 项目指导
```
### 关键设计
#### 多厂商适配层
```
用户请求 → 厂商检测 → OpenAI 兼容适配器 → 各厂商 API
↓ ↓
Anthropic 直连 统一消息格式转换
Bedrock/Vertex 工具调用翻译
Azure Foundry 思考链处理
```
- **`providerRegistry.ts`**22+ 厂商的 baseURL、模型列表、API Key 映射
- **`openaiAdapter.ts`**:将 OpenAI 格式的流式响应实时转换为 Anthropic 内部格式
- **`providers.ts`**:厂商检测优先级链(显式 > 环境变量 > 自动检测 > Ollama 兜底)
#### 工具分层
针对非 Anthropic 模型,工具按能力分层:
- **Tier 1**始终可用Bash、Read、Write、Edit、Glob、Grep
- **Tier 2**中等模型WebFetch、WebSearch、NotebookEdit、Agent
- **跳过**Anthropic 专属工具EnterWorktree、TodoWrite 等)
- **MCP 工具**:始终透传
#### 构建流程
```bash
bun run build
```
1. 清理 `dist/` 目录
2. Bun bundler + code splitting → 入口 `dist/cli.js` + ~450 chunk 文件
3. 后处理:`import.meta.require` 替换Node.js 兼容)
4. Shebang 修正:`#!/usr/bin/env node`
5. 注入 `globalThis.Bun` polyfill
构建产物 **Bun 和 Node.js 均可运行**
## 与原版 Claude Code 的区别
| 方面 | 原版 Claude Code | 嘉陵江-code |
|------|-----------------|-------------|
| 模型支持 | 仅 Anthropic Claude | 22+ 厂商 + 本地 Ollama |
| 默认配置 | 需要 API Key | 本地 Ollama 零配置启动 |
| 国内厂商 | 不支持 | 深度适配 12 家国内厂商 |
| 思考链 | Claude 原生 | 适配 DeepSeek R1、Qwen thinking 等 |
| 功能裁剪 | 全功能 | 移除 Computer Use、Voice、Magic Docs 等 |
| Feature Flags | 内部功能开关 | 全部 `false`(禁用未实现分支) |
| 运行时 | Bun | Bun 开发 / Bun+Node 运行 |
| 配置体验 | 需手动配置 | 交互式向导 + 自动检测 |
### 已移除/Stub 的模块
| 模块 | 状态 | 说明 |
|------|------|------|
| Computer Use (`@ant/*`) | Stub | 保留包结构,无实际功能 |
| NAPI 包 (audio/image/url/modifiers) | Stub | 除 `color-diff-napi` 外均为空实现 |
| Analytics / GrowthBook / Sentry | 空实现 | 移除遥测 |
| Magic Docs / Voice Mode / LSP Server | 移除 | 不影响核心功能 |
| Plugins / Marketplace | 移除 | 不影响核心功能 |
## 开发指南
### 项目特殊说明
- **~1341 个 tsc 错误**:来自反编译,类型多为 `unknown`/`never`/`{}`**不影响 Bun 运行时**,请勿尝试修复
- **`feature()` 始终返回 `false`**:所有 feature flag 后的代码是死代码
- **React Compiler 产物**:组件中大量 `const $ = _c(N)` 是编译器输出的记忆化模板,属正常现象
- **`bun:bundle` 导入**:构建时 API开发时由 `cli.tsx` 顶部 polyfill 提供
### 常用命令
```bash
# 开发运行
bun run dev
# 构建
bun run build
# Lint需先安装 biome
bun run lint
bun run lint:fix
# 格式化
bun run format
# 依赖检查
bun run check:unused
# 健康检查
bun run health
```
构建采用 code splitting 多文件打包(`build.ts`),产物输出到 `dist/` 目录(入口 `dist/cli.js` + 约 450 个 chunk 文件)。
### 添加新厂商
构建出的版本 bun 和 node 都可以启动, 你 publish 到私有源可以直接启动
`src/services/api/providerRegistry.ts` 中添加条目即可:
如果遇到 bug 请直接提一个 issues, 我们优先解决
## 相关文档及网站
<https://deepwiki.com/claude-code-best/claude-code>
## Star History
<a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&theme=dark&legend=top-left" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&legend=top-left" />
<img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&legend=top-left" />
</picture>
</a>
## 能力清单
> ✅ = 已实现 ⚠️ = 部分实现 / 条件启用 ❌ = stub / 移除 / feature flag 关闭
### 核心系统
| 能力 | 状态 | 说明 |
|------|------|------|
| REPL 交互界面Ink 终端渲染) | ✅ | 主屏幕 5000+ 行,完整交互 |
| API 通信 — Anthropic Direct | ✅ | 支持 API Key + OAuth |
| API 通信 — AWS Bedrock | ✅ | 支持凭据刷新、Bearer Token |
| API 通信 — Google Vertex | ✅ | 支持 GCP 凭据刷新 |
| API 通信 — Azure Foundry | ✅ | 支持 API Key + Azure AD |
| 流式对话与工具调用循环 (`query.ts`) | ✅ | 1700+ 行含自动压缩、token 追踪 |
| 会话引擎 (`QueryEngine.ts`) | ✅ | 1300+ 行,管理对话状态与归因 |
| 上下文构建git status / CLAUDE.md / memory | ✅ | `context.ts` 完整实现 |
| 权限系统plan/auto/manual 模式) | ✅ | 6300+ 行,含 YOLO 分类器、路径验证、规则匹配 |
| Hook 系统pre/post tool use | ✅ | 支持 settings.json 配置 |
| 会话恢复 (`/resume`) | ✅ | 独立 ResumeConversation 屏幕 |
| Doctor 诊断 (`/doctor`) | ✅ | 版本、API、插件、沙箱检查 |
| 自动压缩 (compaction) | ✅ | auto-compact / micro-compact / API compact |
### 工具 — 始终可用
| 工具 | 状态 | 说明 |
|------|------|------|
| BashTool | ✅ | Shell 执行,沙箱,权限检查 |
| FileReadTool | ✅ | 文件 / PDF / 图片 / Notebook 读取 |
| FileEditTool | ✅ | 字符串替换式编辑 + diff 追踪 |
| FileWriteTool | ✅ | 文件创建 / 覆写 + diff 生成 |
| NotebookEditTool | ✅ | Jupyter Notebook 单元格编辑 |
| AgentTool | ✅ | 子代理派生fork / async / background / remote |
| WebFetchTool | ✅ | URL 抓取 → Markdown → AI 摘要 |
| WebSearchTool | ✅ | 网页搜索 + 域名过滤 |
| AskUserQuestionTool | ✅ | 多问题交互提示 + 预览 |
| SendMessageTool | ✅ | 消息发送peers / teammates / mailbox |
| SkillTool | ✅ | 斜杠命令 / Skill 调用 |
| EnterPlanModeTool | ✅ | 进入计划模式 |
| ExitPlanModeTool (V2) | ✅ | 退出计划模式 |
| TodoWriteTool | ✅ | Todo 列表 v1 |
| BriefTool | ✅ | 简短消息 + 附件发送 |
| TaskOutputTool | ✅ | 后台任务输出读取 |
| TaskStopTool | ✅ | 后台任务停止 |
| ListMcpResourcesTool | ⚠️ | MCP 资源列表(被 specialTools 过滤,特定条件下加入) |
| ReadMcpResourceTool | ⚠️ | MCP 资源读取(同上) |
| SyntheticOutputTool | ⚠️ | 仅在非交互会话SDK/pipe 模式)下创建 |
| CronCreateTool | ✅ | 定时任务创建(已移除 AGENT_TRIGGERS gate |
| CronDeleteTool | ✅ | 定时任务删除 |
| CronListTool | ✅ | 定时任务列表 |
| EnterWorktreeTool | ✅ | 进入 Git Worktree`isWorktreeModeEnabled()` 已硬编码为 true |
| ExitWorktreeTool | ✅ | 退出 Git Worktree |
### 工具 — 条件启用
| 工具 | 状态 | 启用条件 |
|------|------|----------|
| GlobTool | ✅ | 未嵌入 bfs/ugrep 时启用(默认启用) |
| GrepTool | ✅ | 同上 |
| TaskCreateTool | ⚠️ | `isTodoV2Enabled()` 为 true 时 |
| TaskGetTool | ⚠️ | 同上 |
| TaskUpdateTool | ⚠️ | 同上 |
| TaskListTool | ⚠️ | 同上 |
| TeamCreateTool | ⚠️ | `isAgentSwarmsEnabled()` |
| TeamDeleteTool | ⚠️ | 同上 |
| ToolSearchTool | ⚠️ | `isToolSearchEnabledOptimistic()` |
| PowerShellTool | ⚠️ | Windows 平台检测 |
| LSPTool | ⚠️ | `ENABLE_LSP_TOOL` 环境变量 |
| ConfigTool | ❌ | `USER_TYPE === 'ant'`(永远为 false |
### 工具 — Feature Flag 关闭(全部不可用)
| 工具 | Feature Flag |
|------|-------------|
| SleepTool | `PROACTIVE` / `KAIROS` |
| RemoteTriggerTool | `AGENT_TRIGGERS_REMOTE` |
| MonitorTool | `MONITOR_TOOL` |
| SendUserFileTool | `KAIROS` |
| OverflowTestTool | `OVERFLOW_TEST_TOOL` |
| TerminalCaptureTool | `TERMINAL_PANEL` |
| WebBrowserTool | `WEB_BROWSER_TOOL` |
| SnipTool | `HISTORY_SNIP` |
| WorkflowTool | `WORKFLOW_SCRIPTS` |
| PushNotificationTool | `KAIROS` / `KAIROS_PUSH_NOTIFICATION` |
| SubscribePRTool | `KAIROS_GITHUB_WEBHOOKS` |
| ListPeersTool | `UDS_INBOX` |
| CtxInspectTool | `CONTEXT_COLLAPSE` |
### 工具 — Stub / 不可用
| 工具 | 说明 |
|------|------|
| TungstenTool | ANT-ONLY stub |
| REPLTool | ANT-ONLY`isEnabled: () => false` |
| SuggestBackgroundPRTool | ANT-ONLY`isEnabled: () => false` |
| VerifyPlanExecutionTool | 需 `CLAUDE_CODE_VERIFY_PLAN=true` 环境变量,且为 stub |
| ReviewArtifactTool | stub未注册到 tools.ts |
| DiscoverSkillsTool | stub未注册到 tools.ts |
### 斜杠命令 — 可用
| 命令 | 状态 | 说明 |
|------|------|------|
| `/add-dir` | ✅ | 添加目录 |
| `/advisor` | ✅ | Advisor 配置 |
| `/agents` | ✅ | 代理列表/管理 |
| `/branch` | ✅ | 分支管理 |
| `/btw` | ✅ | 快速备注 |
| `/chrome` | ✅ | Chrome 集成 |
| `/clear` | ✅ | 清屏 |
| `/color` | ✅ | Agent 颜色 |
| `/compact` | ✅ | 压缩对话 |
| `/config` (`/settings`) | ✅ | 配置管理 |
| `/context` | ✅ | 上下文信息 |
| `/copy` | ✅ | 复制最后消息 |
| `/cost` | ✅ | 会话费用 |
| `/desktop` | ✅ | Claude Desktop 集成 |
| `/diff` | ✅ | 显示 diff |
| `/doctor` | ✅ | 健康检查 |
| `/effort` | ✅ | 设置 effort 等级 |
| `/exit` | ✅ | 退出 |
| `/export` | ✅ | 导出对话 |
| `/extra-usage` | ✅ | 额外用量信息 |
| `/fast` | ✅ | 切换 fast 模式 |
| `/feedback` | ✅ | 反馈 |
| `/loop` | ✅ | 定时循环执行bundled skill可通过 `CLAUDE_CODE_DISABLE_CRON` 关闭) |
| `/heapdump` | ✅ | Heap dump调试 |
| `/help` | ✅ | 帮助 |
| `/hooks` | ✅ | Hook 管理 |
| `/ide` | ✅ | IDE 连接 |
| `/init` | ✅ | 初始化项目 |
| `/install-github-app` | ✅ | 安装 GitHub App |
| `/install-slack-app` | ✅ | 安装 Slack App |
| `/keybindings` | ✅ | 快捷键管理 |
| `/login` / `/logout` | ✅ | 登录 / 登出 |
| `/mcp` | ✅ | MCP 服务管理 |
| `/memory` | ✅ | Memory / CLAUDE.md 管理 |
| `/mobile` | ✅ | 移动端 QR 码 |
| `/model` | ✅ | 模型选择 |
| `/output-style` | ✅ | 输出风格 |
| `/passes` | ✅ | 推荐码 |
| `/permissions` | ✅ | 权限管理 |
| `/plan` | ✅ | 计划模式 |
| `/plugin` | ✅ | 插件管理 |
| `/pr-comments` | ✅ | PR 评论 |
| `/privacy-settings` | ✅ | 隐私设置 |
| `/rate-limit-options` | ✅ | 限速选项 |
| `/release-notes` | ✅ | 更新日志 |
| `/reload-plugins` | ✅ | 重载插件 |
| `/remote-env` | ✅ | 远程环境配置 |
| `/rename` | ✅ | 重命名会话 |
| `/resume` | ✅ | 恢复会话 |
| `/review` | ✅ | 代码审查(本地) |
| `/ultrareview` | ✅ | 云端审查 |
| `/rewind` | ✅ | 回退对话 |
| `/sandbox-toggle` | ✅ | 切换沙箱 |
| `/security-review` | ✅ | 安全审查 |
| `/session` | ✅ | 会话信息 |
| `/skills` | ✅ | Skill 管理 |
| `/stats` | ✅ | 会话统计 |
| `/status` | ✅ | 状态信息 |
| `/statusline` | ✅ | 状态栏 UI |
| `/stickers` | ✅ | 贴纸 |
| `/tasks` | ✅ | 任务管理 |
| `/theme` | ✅ | 终端主题 |
| `/think-back` | ✅ | 年度回顾 |
| `/upgrade` | ✅ | 升级 CLI |
| `/usage` | ✅ | 用量信息 |
| `/insights` | ✅ | 使用分析报告 |
| `/vim` | ✅ | Vim 模式 |
### 斜杠命令 — Feature Flag 关闭
| 命令 | Feature Flag |
|------|-------------|
| `/voice` | `VOICE_MODE` |
| `/proactive` | `PROACTIVE` / `KAIROS` |
| `/brief` | `KAIROS` / `KAIROS_BRIEF` |
| `/assistant` | `KAIROS` |
| `/remote-control` (alias `rc`) | `BRIDGE_MODE` |
| `/remote-control-server` | `DAEMON` + `BRIDGE_MODE` |
| `/force-snip` | `HISTORY_SNIP` |
| `/workflows` | `WORKFLOW_SCRIPTS` |
| `/web-setup` | `CCR_REMOTE_SETUP` |
| `/subscribe-pr` | `KAIROS_GITHUB_WEBHOOKS` |
| `/ultraplan` | `ULTRAPLAN` |
| `/torch` | `TORCH` |
| `/peers` | `UDS_INBOX` |
| `/fork` | `FORK_SUBAGENT` |
| `/buddy` | `BUDDY` |
### 斜杠命令 — ANT-ONLY不可用
`/files` `/tag` `/backfill-sessions` `/break-cache` `/bughunter` `/commit` `/commit-push-pr` `/ctx_viz` `/good-claude` `/issue` `/init-verifiers` `/mock-limits` `/bridge-kick` `/version` `/reset-limits` `/onboarding` `/share` `/summary` `/teleport` `/ant-trace` `/perf-issue` `/env` `/oauth-refresh` `/debug-tool-call` `/agents-platform` `/autofix-pr`
### CLI 子命令
| 子命令 | 状态 | 说明 |
|--------|------|------|
| `claude`(默认) | ✅ | 主 REPL / 交互 / print 模式 |
| `claude mcp serve/add/remove/list/get/...` | ✅ | MCP 服务管理7 个子命令) |
| `claude auth login/status/logout` | ✅ | 认证管理 |
| `claude plugin validate/list/install/...` | ✅ | 插件管理7 个子命令) |
| `claude setup-token` | ✅ | 长效 Token 配置 |
| `claude agents` | ✅ | 代理列表 |
| `claude doctor` | ✅ | 健康检查 |
| `claude update` / `upgrade` | ✅ | 自动更新 |
| `claude install [target]` | ✅ | Native 安装 |
| `claude server` | ❌ | `DIRECT_CONNECT` flag |
| `claude ssh <host>` | ❌ | `SSH_REMOTE` flag |
| `claude open <cc-url>` | ❌ | `DIRECT_CONNECT` flag |
| `claude auto-mode` | ❌ | `TRANSCRIPT_CLASSIFIER` flag |
| `claude remote-control` | ❌ | `BRIDGE_MODE` + `DAEMON` flag |
| `claude assistant` | ❌ | `KAIROS` flag |
| `claude up/rollback/log/error/export/task/completion` | ❌ | ANT-ONLY |
### 服务层
| 服务 | 状态 | 说明 |
|------|------|------|
| API 客户端 (`services/api/`) | ✅ | 3400+ 行4 个 provider |
| MCP (`services/mcp/`) | ✅ | 34 个文件12000+ 行 |
| OAuth (`services/oauth/`) | ✅ | 完整 OAuth 流程 |
| 插件 (`services/plugins/`) | ✅ | 基础设施完整,无内置插件 |
| LSP (`services/lsp/`) | ⚠️ | 实现存在,默认关闭 |
| 压缩 (`services/compact/`) | ✅ | auto / micro / API 压缩 |
| Hook 系统 (`services/tools/toolHooks.ts`) | ✅ | pre/post tool use hooks |
| 会话记忆 (`services/SessionMemory/`) | ✅ | 会话记忆管理 |
| 记忆提取 (`services/extractMemories/`) | ✅ | 自动记忆提取 |
| Skill 搜索 (`services/skillSearch/`) | ✅ | 本地/远程 skill 搜索 |
| 策略限制 (`services/policyLimits/`) | ✅ | 策略限制执行 |
| 分析 / GrowthBook / Sentry | ⚠️ | 框架存在,实际 sink 为空 |
| Voice (`services/voice.ts`) | ❌ | `VOICE_MODE` flag 关闭 |
### 内部包 (`packages/`)
| 包 | 状态 | 说明 |
|------|------|------|
| `color-diff-napi` | ✅ | 1006 行完整 TypeScript 实现(语法高亮 diff |
| `audio-capture-napi` | ✅ | 151 行完整实现(跨平台音频录制,使用 SoX/arecord |
| `image-processor-napi` | ✅ | 125 行完整实现macOS 剪贴板图片读取,使用 osascript + sharp |
| `modifiers-napi` | ✅ | 67 行完整实现macOS 修饰键检测bun:ffi + CoreGraphics |
| `url-handler-napi` | ❌ | stub`waitForUrlEvent()` 返回 null |
| `@ant/claude-for-chrome-mcp` | ❌ | stub`createServer()` 返回 null |
| `@ant/computer-use-mcp` | ⚠️ | 类型安全 stub265 行,完整类型定义但函数返回空值) |
| `@ant/computer-use-input` | ✅ | 183 行完整实现macOS 键鼠模拟AppleScript/JXA/CGEvent |
| `@ant/computer-use-swift` | ✅ | 388 行完整实现macOS 显示器/应用管理/截图JXA/screencapture |
### Feature Flags31 个,全部返回 `false`
`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`
## 项目结构
```
claude-code/
├── src/
│ ├── entrypoints/
│ │ ├── cli.tsx # 入口文件(含 MACRO/feature polyfill
│ │ └── sdk/ # SDK 子模块 stub
│ ├── main.tsx # 主 CLI 逻辑Commander 定义)
│ └── types/
│ ├── global.d.ts # 全局变量/宏声明
│ └── internal-modules.d.ts # 内部 npm 包类型声明
├── packages/ # Monorepo workspace 包
│ ├── color-diff-napi/ # 完整实现(终端 color diff
│ ├── modifiers-napi/ # stubmacOS 修饰键检测)
│ ├── audio-capture-napi/ # stub
│ ├── image-processor-napi/# stub
│ ├── url-handler-napi/ # stub
│ └── @ant/ # Anthropic 内部包 stub
│ ├── claude-for-chrome-mcp/
│ ├── computer-use-mcp/
│ ├── computer-use-input/
│ └── computer-use-swift/
├── scripts/ # 自动化 stub 生成脚本
├── build.ts # 构建脚本Bun.build + code splitting + Node.js 兼容后处理)
├── dist/ # 构建输出(入口 cli.js + ~450 chunk 文件)
└── package.json # Bun workspaces monorepo 配置
```typescript
export const PROVIDER_REGISTRY = {
// ...
your_provider: {
name: 'Your Provider',
baseURL: 'https://api.your-provider.com/v1',
defaultModel: 'your-default-model',
apiKeyEnvVars: ['YOUR_PROVIDER_API_KEY'],
models: [
{ id: 'model-1', name: 'Model 1', description: '描述' },
],
},
}
```
## 技术说明
只要厂商支持 OpenAI 兼容接口,即可无缝接入。
### 运行时 Polyfill
## 常见问题
入口文件 `src/entrypoints/cli.tsx` 顶部注入了必要的 polyfill
### Q: 安装依赖失败?
- `feature()` — 所有 feature flag 返回 `false`,跳过未实现分支
- `globalThis.MACRO` — 模拟构建时宏注入VERSION 等)
确保 Bun 为最新版本:
```bash
bun upgrade
bun install
```
### Monorepo
### Q: 如何切换模型?
项目采用 Bun workspaces 管理内部包。原先手工放在 `node_modules/` 下的 stub 已统一迁入 `packages/`,通过 `workspace:*` 解析。
运行中使用 `/model` 命令,或设置环境变量:
```bash
export PROVIDER=openai
export OPENAI_API_KEY=sk-xxx
export ANTHROPIC_MODEL=gpt-4o # 指定具体模型
```
## Feature Flags 详解
### Q: 本地 Ollama 如何使用?
原版 Claude Code 通过 `bun:bundle``feature()` 在构建时注入 feature flag由 GrowthBook 等 A/B 实验平台控制灰度发布。本项目中 `feature()` 被 polyfill 为始终返回 `false`,因此以下 30 个 flag 全部关闭。
1. 安装 [Ollama](https://ollama.com/)
2. 拉取模型:`ollama pull qwen3.5:35b`
3. 启动嘉陵江-code默认自动连接本地 Ollama
### 自主 Agent
### Q: 能否用 Node.js 运行?
| Flag | 用途 |
|------|------|
| `KAIROS` | Assistant 模式 — 长期运行的自主 Agent含 brief、push 通知、文件发送) |
| `KAIROS_BRIEF` | Kairos Brief — 向用户发送简报摘要 |
| `KAIROS_CHANNELS` | Kairos 频道 — 多频道通信 |
| `KAIROS_GITHUB_WEBHOOKS` | GitHub Webhook 订阅 — PR 事件实时推送给 Agent |
| `PROACTIVE` | 主动模式 — Agent 主动执行任务,含 SleepTool 定时唤醒 |
| `COORDINATOR_MODE` | 协调器模式 — 多 Agent 编排调度 |
| `BUDDY` | Buddy 配对编程功能 |
| `FORK_SUBAGENT` | Fork 子代理 — 从当前会话分叉出独立子代理 |
可以。`bun run build` 后,`node dist/cli.js` 即可运行(构建时已注入 Node.js 兼容 shim
### 远程 / 分布式
### Q: tsc 报大量错误?
| Flag | 用途 |
|------|------|
| `BRIDGE_MODE` | 远程控制桥接 — 允许外部客户端远程操控 Claude Code |
| `DAEMON` | 守护进程 — 后台常驻服务,支持 worker 和 supervisor |
| `BG_SESSIONS` | 后台会话 — `ps`/`logs`/`attach`/`kill`/`--bg` 等后台进程管理 |
| `SSH_REMOTE` | SSH 远程 — `claude ssh <host>` 连接远程主机 |
| `DIRECT_CONNECT` | 直连模式 — `cc://` URL 协议、server 命令、`open` 命令 |
| `CCR_REMOTE_SETUP` | 网页端远程配置 — 通过浏览器配置 Claude Code |
| `CCR_MIRROR` | Claude Code Runtime 镜像 — 会话状态同步/复制 |
正常现象,来自反编译。不影响运行,请忽略。
### 通信
### Q: 工具调用不工作?
| Flag | 用途 |
|------|------|
| `UDS_INBOX` | Unix Domain Socket 收件箱 — Agent 间本地通信(`/peers` |
部分本地模型(尤其小参数量模型)不支持 function calling。建议使用 7B+ 参数的模型,推荐 `qwen3.5:35b``deepseek-r1:32b`
### 增强工具
## 贡献指南
| Flag | 用途 |
|------|------|
| `CHICAGO_MCP` | Computer Use MCP — 计算机操作(屏幕截图、鼠标键盘控制) |
| `WEB_BROWSER_TOOL` | 网页浏览器工具 — 在终端内嵌浏览器交互 |
| `VOICE_MODE` | 语音模式 — 语音输入输出,麦克风 push-to-talk |
| `WORKFLOW_SCRIPTS` | 工作流脚本 — 用户自定义自动化工作流 |
| `MCP_SKILLS` | 基于 MCP 的 Skill 加载机制 |
欢迎贡献!请遵循以下流程:
### 对话管理
1. Fork 本仓库
2. 创建特性分支:`git checkout -b feature/your-feature`
3. 提交变更:`git commit -m 'Add your feature'`
4. 推送分支:`git push origin feature/your-feature`
5. 创建 Pull Request
| Flag | 用途 |
|------|------|
| `HISTORY_SNIP` | 历史裁剪 — 手动裁剪对话历史中的片段(`/force-snip` |
| `ULTRAPLAN` | 超级计划 — 远程 Agent 协作的大规模规划功能 |
| `AGENT_MEMORY_SNAPSHOT` | Agent 运行时的记忆快照功能 |
### 贡献方向
### 基础设施 / 实验
| Flag | 用途 |
|------|------|
| `ABLATION_BASELINE` | 科学实验 — 基线消融测试,用于 A/B 实验对照组 |
| `HARD_FAIL` | 硬失败模式 — 遇错直接中断而非降级 |
| `TRANSCRIPT_CLASSIFIER` | 对话分类器 — `auto-mode` 命令,自动分析和分类对话记录 |
| `UPLOAD_USER_SETTINGS` | 设置同步上传 — 将本地配置同步到云端 |
| `LODESTONE` | 深度链接协议处理器 — 从外部应用跳转到 Claude Code 指定位置 |
| `EXPERIMENTAL_SKILL_SEARCH` | 实验性 Skill 搜索索引 |
| `TORCH` | Torch 功能(具体用途未知,可能是某种高亮/追踪机制) |
- 新增模型厂商适配
- Bug 修复
- 文档改进
- 工具增强
- 国际化 (i18n)
## 许可证
本项目仅供学习研究用途。Claude Code 的所有权利归 [Anthropic](https://www.anthropic.com/) 所有。
本项目采用 [MIT 许可证](LICENSE)。
## 致谢
- 本项目基于 [Anthropic Claude Code](https://claude.ai/code) 反编译与改造
- 感谢所有大模型厂商提供的 OpenAI 兼容接口
- 感谢 [Ollama](https://ollama.com/) 提供的本地模型运行时
- 感谢 [Bun](https://bun.sh/) 提供的高性能 JavaScript 运行时
---
**Star ⭐ 这个项目如果对你有帮助!**

0
SECURITY.md Normal file → Executable file
View File

0
TODO.md Normal file → Executable file
View File

0
biome.json Normal file → Executable file
View File

84
build.ts Normal file → Executable file
View File

@ -23,20 +23,33 @@ if (!result.success) {
process.exit(1);
}
// Step 3: Post-process — patch Bun-only APIs for Node.js compatibility
// Step 3: Post-process — patch for Node.js compatibility & re-enable feature-flagged code
const files = await readdir(outdir);
// 3a. Replace import.meta.require with Node.js compat shim
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);`;
// 3b. Replace Bun-only import.meta.resolve (sync) with Node.js compat
// Bun: import.meta.resolve returns string synchronously
// Node: import.meta.resolve also works (since Node 20.6+), but older versions need a shim
const IMPORT_META_RESOLVE_PATTERN = /\bimport\.meta\.resolve\b/g;
// 3b. Re-enable feature-flagged code that was DCE'd (dead-code-eliminated) by the bundler.
// The Bun bundler resolves `feature('BUDDY')` from bun:bundle to `false` at build time,
// turning `if (!feature('BUDDY')) return X` into `if (true) return X` (dead code).
// We need to remove these guards to re-enable the buddy system.
// Pattern: `if (true)\n return 0;` → remove (companionReservedColumns guard)
// Pattern: `if (true)\n return null;` → remove (CompanionSprite render guard)
// Pattern: `if (true)\n return [];` → remove (findBuddyTriggerPositions guard)
// Pattern: `if (true) {\n return;\n }` → remove (useEffect guard)
//
// We specifically target buddy-related functions by checking surrounding context.
const BUDDY_FUNCTIONS = [
'companionReservedColumns',
'CompanionSprite',
'CompanionFloatingBubble',
'findBuddyTriggerPositions',
];
let patched = 0;
let resolvePatched = 0;
let buddyPatched = 0;
for (const file of files) {
if (!file.endsWith(".js")) continue;
const filePath = join(outdir, file);
@ -50,6 +63,58 @@ for (const file of files) {
changed = true;
}
// Re-enable buddy feature flags: remove DCE'd guards
// These patterns are generated by the bundler when it resolves feature('BUDDY') to false
// and negates it: !false → true, creating `if (true) return X;` dead code guards.
if (content.includes('CompanionSprite') || content.includes('companionReservedColumns') ||
content.includes('findBuddyTriggerPositions') || content.includes('useBuddyNotification')) {
// Pattern 1: `if (true)\n return 0;` (single-line early return)
content = content.replace(/if \(true\)\n\s*return 0;/g, '/* buddy-enabled */');
// Pattern 2: `if (true)\n return null;` (component early return)
content = content.replace(/if \(true\)\n\s*return null;/g, '/* buddy-enabled */');
// Pattern 3: `if (true)\n return \[\];` (array early return)
content = content.replace(/if \(true\)\n\s*return \[\];/g, '/* buddy-enabled */');
// Pattern 4: `if (true) {\n return;\n }` (void early return)
content = content.replace(/if \(true\) \{\n\s*return;\n\s*\}/g, '/* buddy-enabled */');
// Pattern 5: `if (true) {\n return null;\n }` (block return null)
content = content.replace(/if \(true\) \{\n\s*return null;\n\s*\}/g, '/* buddy-enabled */');
// Pattern 6: `if (true) {\n return false;\n }` (block return false)
content = content.replace(/if \(true\) \{\n\s*return false;\n\s*\}/g, '/* buddy-enabled */');
buddyPatched++;
changed = true;
}
// Also fix REPL.tsx buddy rendering conditions
// The bundler turns `feature('BUDDY') && expr` into `false && expr` → `false`
// and `!feature('BUDDY')` into `true`
// In REPL, the inline expressions like:
// `feature('BUDDY') && companionVisible && ...` become just `false`
// We need to restore these. The pattern in the compiled REPL is typically:
// `bottomFloat={false}` (was `bottomFloat={feature('BUDDY') && ...}`)
// `false && companionNarrow` (was `feature('BUDDY') && companionNarrow`)
// These are harder to fix generically. Let's handle the PromptInput/REPL chunk.
if (content.includes('companionVisible') && content.includes('companionNarrow')) {
// The REPL renders companion in two places:
// 1. Fullscreen: bottomFloat={feature('BUDDY') && companionVisible && !companionNarrow ? <CompanionFloatingBubble /> : undefined}
// Compiled to: bottomFloat={false ? ... : undefined} → bottomFloat={undefined}
// 2. Non-fullscreen: {feature('BUDDY') && !(companionNarrow && isFullscreenEnvEnabled()) && companionVisible ? <CompanionSprite /> : null}
// Compiled to: {false ? ... : null} → null
// Replace `false && companionNarrow` patterns (used in flex direction)
content = content.replace(
/false && companionNarrow/g,
'companionNarrow'
);
// Fix companion sprite rendering: find places where `null` replaced the companion
// Look for the pattern near companionVisible: `null` where `<CompanionSprite />` should be
// This is trickier. Let's look for specific compiled patterns.
changed = true;
}
if (changed) {
await writeFile(filePath, content);
}
@ -64,17 +129,14 @@ if (cliContent.startsWith("#!/usr/bin/env bun")) {
cliContent = cliContent.replace("#!/usr/bin/env bun", "#!/usr/bin/env node");
}
// 4b. Inject Node.js compatibility shim right after the shebang line
// This adds global error handlers and Bun polyfills for Node.js runtime
// 4b. Inject Node.js compatibility shim
const COMPAT_SHIM = `
// ── Node.js compatibility shim ──
if (typeof globalThis.Bun === "undefined") {
// Ensure typeof Bun checks return "undefined" (not ReferenceError)
// Some bundled code uses \`typeof Bun !== "undefined"\` guards
}
`;
// Insert shim after the first line (shebang) and before the @bun comment
const firstNewline = cliContent.indexOf("\n");
if (firstNewline !== -1) {
cliContent = cliContent.slice(0, firstNewline + 1) + COMPAT_SHIM + cliContent.slice(firstNewline + 1);
@ -82,4 +144,4 @@ if (firstNewline !== -1) {
await writeFile(cliPath, cliContent);
console.log(`Bundled ${result.outputs.length} files to ${outdir}/ (patched ${patched} for Node.js compat, shebang → node)`);
console.log(`Bundled ${result.outputs.length} files to ${outdir}/ (patched ${patched} require, ${buddyPatched} buddy chunks, shebang → node)`);

0
bun.lock Normal file → Executable file
View File

0
bunfig.toml Normal file → Executable file
View File

0
docs/REVISION-PLAN.md Normal file → Executable file
View File

0
docs/agent/coordinator-and-swarm.mdx Normal file → Executable file
View File

0
docs/agent/sub-agents.mdx Normal file → Executable file
View File

0
docs/agent/worktree-isolation.mdx Normal file → Executable file
View File

0
docs/context/compaction.mdx Normal file → Executable file
View File

0
docs/context/project-memory.mdx Normal file → Executable file
View File

0
docs/context/system-prompt.mdx Normal file → Executable file
View File

0
docs/context/token-budget.mdx Normal file → Executable file
View File

0
docs/conversation/multi-turn.mdx Normal file → Executable file
View File

0
docs/conversation/streaming.mdx Normal file → Executable file
View File

0
docs/conversation/the-loop.mdx Normal file → Executable file
View File

0
docs/extensibility/custom-agents.mdx Normal file → Executable file
View File

0
docs/extensibility/hooks.mdx Normal file → Executable file
View File

0
docs/extensibility/mcp-protocol.mdx Normal file → Executable file
View File

0
docs/extensibility/skills.mdx Normal file → Executable file
View File

0
docs/favicon.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

0
docs/images/agentic-loop.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.7 MiB

After

Width:  |  Height:  |  Size: 4.7 MiB

0
docs/images/architecture-layers.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 5.4 MiB

After

Width:  |  Height:  |  Size: 5.4 MiB

0
docs/images/compaction.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

0
docs/images/data-flow.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

0
docs/images/interaction-flow.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.7 MiB

After

Width:  |  Height:  |  Size: 4.7 MiB

0
docs/images/mcp-architecture.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.7 MiB

After

Width:  |  Height:  |  Size: 4.7 MiB

0
docs/images/permission-layers.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.6 MiB

After

Width:  |  Height:  |  Size: 4.6 MiB

0
docs/images/streaming-timeline.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.5 MiB

After

Width:  |  Height:  |  Size: 4.5 MiB

0
docs/images/system-prompt-assembly.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

0
docs/internals/ant-only-world.mdx Normal file → Executable file
View File

0
docs/internals/feature-flags.mdx Normal file → Executable file
View File

0
docs/internals/growthbook-ab-testing.mdx Normal file → Executable file
View File

0
docs/internals/hidden-features.mdx Normal file → Executable file
View File

0
docs/internals/three-tier-gating.mdx Normal file → Executable file
View File

0
docs/introduction/architecture-overview.mdx Normal file → Executable file
View File

0
docs/introduction/what-is-claude-code.mdx Normal file → Executable file
View File

0
docs/introduction/why-this-whitepaper.mdx Normal file → Executable file
View File

0
docs/logo/dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 362 B

0
docs/logo/light.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 362 B

0
docs/safety/permission-model.mdx Normal file → Executable file
View File

0
docs/safety/plan-mode.mdx Normal file → Executable file
View File

0
docs/safety/sandbox.mdx Normal file → Executable file
View File

0
docs/safety/why-safety-matters.mdx Normal file → Executable file
View File

0
docs/tools/file-operations.mdx Normal file → Executable file
View File

0
docs/tools/search-and-navigation.mdx Normal file → Executable file
View File

0
docs/tools/shell-execution.mdx Normal file → Executable file
View File

0
docs/tools/task-management.mdx Normal file → Executable file
View File

0
docs/tools/what-are-tools.mdx Normal file → Executable file
View File

BIN
jialing-code-1.3.3.tgz Executable file

Binary file not shown.

BIN
jialing-code-1.3.4.tgz Executable file

Binary file not shown.

0
knip.json Normal file → Executable file
View File

0
mint.json Normal file → Executable file
View File

32
package.json Normal file → Executable file
View File

@ -1,9 +1,10 @@
{
"name": "claude-js",
"version": "1.0.3",
"description": "Reverse-engineered Anthropic Claude Code CLI — interactive AI coding assistant in the terminal",
"name": "jialing-code",
"version": "1.3.14",
"description": "嘉陵江-code — 终端 AI 编程助手,支持 22+ 大模型厂商,默认本地 Ollama 零配置启动",
"type": "module",
"author": "claude-code-best <claude-code-best@proton.me>",
"author": "嘉陵江-code",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/claude-code-best/claude-code.git"
@ -13,19 +14,26 @@
"url": "https://github.com/claude-code-best/claude-code/issues"
},
"keywords": [
"claude",
"anthropic",
"cli",
"ai",
"cli",
"coding-assistant",
"terminal",
"repl"
"repl",
"ollama",
"openai",
"deepseek",
"qwen",
"gpt",
"gemini",
"llm",
"嘉陵江"
],
"engines": {
"bun": ">=1.2.0"
"node": ">=18.0.0"
},
"bin": {
"claude-js": "dist/cli.js"
"jialing-code": "dist/cli.js",
"jl": "dist/cli.js"
},
"workspaces": [
"packages/*",
@ -47,7 +55,9 @@
"health": "bun run scripts/health-check.ts",
"docs:dev": "npx mintlify dev"
},
"dependencies": {},
"dependencies": {
"undici": "^7.24.6"
},
"devDependencies": {
"@alcalzone/ansi-tokenize": "^0.3.0",
"@ant/claude-for-chrome-mcp": "workspace:*",

0
packages/@ant/claude-for-chrome-mcp/package.json Normal file → Executable file
View File

0
packages/@ant/claude-for-chrome-mcp/src/index.ts Normal file → Executable file
View File

0
packages/@ant/computer-use-input/package.json Normal file → Executable file
View File

0
packages/@ant/computer-use-input/src/index.ts Normal file → Executable file
View File

0
packages/@ant/computer-use-mcp/package.json Normal file → Executable file
View File

0
packages/@ant/computer-use-mcp/src/index.ts Normal file → Executable file
View File

0
packages/@ant/computer-use-mcp/src/sentinelApps.ts Normal file → Executable file
View File

0
packages/@ant/computer-use-mcp/src/types.ts Normal file → Executable file
View File

0
packages/@ant/computer-use-swift/package.json Normal file → Executable file
View File

0
packages/@ant/computer-use-swift/src/index.ts Normal file → Executable file
View File

0
packages/audio-capture-napi/package.json Normal file → Executable file
View File

0
packages/audio-capture-napi/src/index.ts Normal file → Executable file
View File

0
packages/color-diff-napi/package.json Normal file → Executable file
View File

View File

0
packages/color-diff-napi/src/index.ts Normal file → Executable file
View File

0
packages/image-processor-napi/package.json Normal file → Executable file
View File

0
packages/image-processor-napi/src/index.ts Normal file → Executable file
View File

0
packages/modifiers-napi/package.json Normal file → Executable file
View File

0
packages/modifiers-napi/src/index.ts Normal file → Executable file
View File

0
packages/url-handler-napi/package.json Normal file → Executable file
View File

0
packages/url-handler-napi/src/index.ts Normal file → Executable file
View File

0
scripts/create-type-stubs.mjs Normal file → Executable file
View File

0
scripts/fix-default-stubs.mjs Normal file → Executable file
View File

0
scripts/fix-missing-exports.mjs Normal file → Executable file
View File

0
scripts/health-check.ts Normal file → Executable file
View File

0
scripts/remove-sourcemaps.mjs Normal file → Executable file
View File

0
src/QueryEngine.ts Normal file → Executable file
View File

0
src/Task.ts Normal file → Executable file
View File

0
src/Tool.ts Normal file → Executable file
View File

0
src/assistant/AssistantSessionChooser.ts Normal file → Executable file
View File

0
src/assistant/gate.ts Normal file → Executable file
View File

0
src/assistant/index.ts Normal file → Executable file
View File

0
src/assistant/sessionDiscovery.ts Normal file → Executable file
View File

0
src/assistant/sessionHistory.ts Normal file → Executable file
View File

0
src/bootstrap/src/entrypoints/agentSdkTypes.ts Normal file → Executable file
View File

0
src/bootstrap/src/tools/AgentTool/agentColorManager.ts Normal file → Executable file
View File

0
src/bootstrap/src/types/hooks.ts Normal file → Executable file
View File

0
src/bootstrap/src/types/ids.ts Normal file → Executable file
View File

0
src/bootstrap/src/utils/crypto.ts Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More