mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
- Deleted desktop/src/components/chat/highlightCode.ts (no longer needed) - Removed all .hljs-* CSS rules from globals.css - Updated chatBlocks test for react-diff-viewer-continued (doesn't render diff content in jsdom, so test verifies component mounting instead) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
191 lines
7.5 KiB
Markdown
191 lines
7.5 KiB
Markdown
# Claude Code Haha
|
||
|
||
<p align="center">
|
||
<img src="docs/images/banner.jpg" alt="Claude Code Haha Banner" width="800">
|
||
</p>
|
||
|
||
<div align="center">
|
||
|
||
[](https://github.com/NanmiCoder/cc-haha/stargazers)
|
||
[](https://github.com/NanmiCoder/cc-haha/network/members)
|
||
[](https://github.com/NanmiCoder/cc-haha/issues)
|
||
[](https://github.com/NanmiCoder/cc-haha/pulls)
|
||
[](https://github.com/NanmiCoder/cc-haha/blob/main/LICENSE)
|
||
[](README.md)
|
||
[](README.en.md)
|
||
[](https://claudecode-haha.relakkesyang.org)
|
||
|
||
</div>
|
||
|
||
基于 Claude Code 泄露源码修复的**本地可运行版本**,支持接入任意 Anthropic 兼容 API(如 MiniMax、OpenRouter 等)。
|
||
|
||
> 原始泄露源码无法直接运行。本仓库修复了启动链路中的多个阻塞问题,使完整的 Ink TUI 交互界面可以在本地工作。
|
||
|
||
<p align="center">
|
||
<a href="#功能">功能</a> · <a href="#架构概览">架构概览</a> · <a href="#快速开始">快速开始</a> · <a href="docs/guide/env-vars.md">环境变量</a> · <a href="docs/guide/faq.md">FAQ</a> · <a href="docs/guide/global-usage.md">全局使用</a> · <a href="#更多文档">更多文档</a>
|
||
</p>
|
||
|
||
---
|
||
|
||
## 功能
|
||
|
||
- 完整的 Ink TUI 交互界面(与官方 Claude Code 一致)
|
||
- `--print` 无头模式(脚本/CI 场景)
|
||
- 支持 MCP 服务器、插件、Skills
|
||
- 支持自定义 API 端点和模型([第三方模型使用指南](docs/guide/third-party-models.md))
|
||
- **记忆系统**(跨会话持久化记忆)— [使用指南](docs/memory/01-usage-guide.md)
|
||
- **多 Agent 系统**(多代理编排、并行任务、Teams 协作)— [使用指南](docs/agent/01-usage-guide.md) | [实现原理](docs/agent/02-implementation.md)
|
||
- **Skills 系统**(可扩展能力插件、自定义工作流)— [使用指南](docs/skills/01-usage-guide.md) | [实现原理](docs/skills/02-implementation.md)
|
||
- **Channel 系统**(通过 Telegram/飞书/Discord 等 IM 远程控制 Agent)— [架构解析](docs/channel/01-channel-system.md)
|
||
- **Computer Use 桌面控制** — [功能指南](docs/features/computer-use.md) | [架构解析](docs/features/computer-use-architecture.md)
|
||
- 降级 Recovery CLI 模式(`CLAUDE_CODE_FORCE_RECOVERY_CLI=1 ./bin/claude-haha`)
|
||
|
||
---
|
||
|
||
## 架构概览
|
||
|
||
<table>
|
||
<tr>
|
||
<td align="center" width="25%"><img src="docs/images/01-overall-architecture.png" alt="整体架构"><br><b>整体架构</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/02-request-lifecycle.png" alt="请求生命周期"><br><b>请求生命周期</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/03-tool-system.png" alt="工具系统"><br><b>工具系统</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/04-multi-agent.png" alt="多 Agent 架构"><br><b>多 Agent 架构</b></td>
|
||
</tr>
|
||
<tr>
|
||
<td align="center" width="25%"><img src="docs/images/05-terminal-ui.png" alt="终端 UI"><br><b>终端 UI</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/06-permission-security.png" alt="权限与安全"><br><b>权限与安全</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/07-services-layer.png" alt="服务层"><br><b>服务层</b></td>
|
||
<td align="center" width="25%"><img src="docs/images/08-state-data-flow.png" alt="状态与数据流"><br><b>状态与数据流</b></td>
|
||
</tr>
|
||
</table>
|
||
|
||
---
|
||
|
||
## 快速开始
|
||
|
||
### 1. 安装 Bun
|
||
|
||
```bash
|
||
# macOS / Linux
|
||
curl -fsSL https://bun.sh/install | bash
|
||
|
||
# macOS (Homebrew)
|
||
brew install bun
|
||
|
||
# Windows (PowerShell)
|
||
powershell -c "irm bun.sh/install.ps1 | iex"
|
||
```
|
||
|
||
> 精简版 Linux 如提示 `unzip is required`,先运行 `apt update && apt install -y unzip`
|
||
|
||
### 2. 安装依赖并配置
|
||
|
||
```bash
|
||
bun install
|
||
cp .env.example .env
|
||
# 编辑 .env 填入你的 API Key,详见 docs/guide/env-vars.md
|
||
```
|
||
|
||
### 3. 启动
|
||
|
||
#### macOS / Linux
|
||
|
||
```bash
|
||
./bin/claude-haha # 交互 TUI 模式
|
||
./bin/claude-haha -p "your prompt here" # 无头模式
|
||
./bin/claude-haha --help # 查看所有选项
|
||
```
|
||
|
||
#### Windows
|
||
|
||
> **前置要求**:必须安装 [Git for Windows](https://git-scm.com/download/win)
|
||
|
||
```powershell
|
||
# PowerShell / cmd 直接调用 Bun
|
||
bun --env-file=.env ./src/entrypoints/cli.tsx
|
||
|
||
# 或在 Git Bash 中运行
|
||
./bin/claude-haha
|
||
```
|
||
|
||
### 4. 全局使用(可选)
|
||
|
||
将 `bin/` 加入 PATH 后可在任意目录启动,详见 [全局使用指南](docs/guide/global-usage.md):
|
||
|
||
```bash
|
||
export PATH="$HOME/path/to/claude-code-haha/bin:$PATH"
|
||
```
|
||
|
||
### 5. 桌面端联调(Desktop)
|
||
|
||
如果你在开发或测试 `desktop/` 前端,需要同时启动 API 服务端和桌面前端。
|
||
|
||
#### 5.1 启动服务端
|
||
|
||
```bash
|
||
cd /Users/nanmi/workspace/myself_code/claude-code-haha
|
||
SERVER_PORT=3456 bun run src/server/index.ts
|
||
```
|
||
|
||
可选自检:
|
||
|
||
```bash
|
||
curl http://127.0.0.1:3456/health
|
||
```
|
||
|
||
#### 5.2 启动桌面前端
|
||
|
||
```bash
|
||
cd /Users/nanmi/workspace/myself_code/claude-code-haha/desktop
|
||
bun run dev --host 127.0.0.1 --port 2024
|
||
```
|
||
|
||
然后在浏览器打开:
|
||
|
||
```text
|
||
http://127.0.0.1:2024
|
||
```
|
||
|
||
#### 5.3 常见注意事项
|
||
|
||
- 如果 `3456` 端口已经被旧服务端占用,先执行 `lsof -nP -iTCP:3456 -sTCP:LISTEN` 找到 PID,再 `kill <PID>`。
|
||
- 测试聊天时建议新建一个 session,并重新选择一个真实存在的工作目录。
|
||
- 如果某个旧 session 绑定的目录已被删除,服务端会返回 `Working directory does not exist`,这和服务端是否启动是两回事。
|
||
|
||
---
|
||
|
||
## 技术栈
|
||
|
||
| 类别 | 技术 |
|
||
|------|------|
|
||
| 运行时 | [Bun](https://bun.sh) |
|
||
| 语言 | TypeScript |
|
||
| 终端 UI | React + [Ink](https://github.com/vadimdemedes/ink) |
|
||
| CLI 解析 | Commander.js |
|
||
| API | Anthropic SDK |
|
||
| 协议 | MCP, LSP |
|
||
|
||
---
|
||
|
||
## 更多文档
|
||
|
||
| 文档 | 说明 |
|
||
|------|------|
|
||
| [环境变量](docs/guide/env-vars.md) | 完整环境变量参考和配置方式 |
|
||
| [第三方模型](docs/guide/third-party-models.md) | 接入 OpenAI / DeepSeek / Ollama 等非 Anthropic 模型 |
|
||
| [记忆系统](docs/memory/01-usage-guide.md) | 跨会话持久化记忆的使用与实现 |
|
||
| [多 Agent 系统](docs/agent/01-usage-guide.md) | 多代理编排、并行任务执行与 Teams 协作 |
|
||
| [Skills 系统](docs/skills/01-usage-guide.md) | 可扩展能力插件、自定义工作流与条件激活 |
|
||
| [Channel 系统](docs/channel/01-channel-system.md) | 通过 Telegram/飞书/Discord 等 IM 平台远程控制 Agent |
|
||
| [Computer Use](docs/features/computer-use.md) | 桌面控制功能(截屏、鼠标、键盘)— [架构解析](docs/features/computer-use-architecture.md) |
|
||
| [全局使用](docs/guide/global-usage.md) | 在任意目录启动 claude-haha |
|
||
| [常见问题](docs/guide/faq.md) | 常见错误排查 |
|
||
| [源码修复记录](docs/reference/fixes.md) | 相对于原始泄露源码的修复内容 |
|
||
| [项目结构](docs/reference/project-structure.md) | 代码目录结构说明 |
|
||
|
||
---
|
||
|
||
## Disclaimer
|
||
|
||
本仓库基于 2026-03-31 从 Anthropic npm registry 泄露的 Claude Code 源码。所有原始源码版权归 [Anthropic](https://www.anthropic.com) 所有。仅供学习和研究用途。
|