cc-haha/docs/cli/index.md
程序员阿江(Relakkes) c2cd615824 docs: rebuild the documentation site around two readers
The site had drifted from the product. Every screenshot predated the
v0.5.0 UI redesign, the reading experience shipped no search and no
syntax highlighting, and a third of the pages were internal process
artefacts — migration task lists addressed to agentic workers, a
release runbook, a proposal marked "historical".

Reorganise around the only two people who read this: someone getting
the desktop app running for the first time, and someone reading the
source. Five sections replace nine — start / desktop / im / cli /
internals — and the pages that served neither reader are gone.

Site rewrite:

- Palette lifted from the desktop app's 「纸·墨·印」 themes, so the
  site and the product read as one thing. Light mirrors 纯白, dark
  mirrors 墨夜, and dark mode exists at all now.
- Fonts are self-hosted. The old @import from Google Fonts is
  unreachable from mainland China, which left every heading in a
  fallback serif; it also only requested weight 600 while the CSS
  asked for 900, so Latin and CJK in the same heading disagreed.
- Docs were shipped as one 968KB manifest downloaded on every page
  view. Split into a 32KB index plus one lazily imported chunk per
  page; the entry bundle is now 101KB gzipped.
- Add search, syntax highlighting, per-route meta with canonical and
  hreflang, a sitemap, and an error boundary. Replace the 44vh
  mobile sidebar with a drawer.
- Image dimensions are read at build time and written into the tag,
  so lazy images reserve their space instead of collapsing.

Screenshots are recaptured from a real v0.5.0 build against a clean
demo project, with tokens, QR codes and paired accounts redacted.
The previous set is deleted rather than kept alongside.

Routes follow file paths, so the restructure would have broken every
inbound link; 37 old paths redirect, in both languages. The PR policy
gate and CODEOWNERS also hardcoded docs/guide/contributing.md.

Verified: check:docs 78 pages / 323 links / 0 problems, check:policy
127 pass. Walked every route at 1440 and 390 in both themes for
overflow, contrast, keyboard reachability and focus management.
2026-07-27 17:32:41 +08:00

3.6 KiB
Raw Blame History

title nav_title description order
安装与启动 安装与启动 从源码运行 CLI安装依赖、配置模型服务、在任意目录启动。 0

安装与启动

CLI 是 Claude Code Haha 的内核,桌面端每个会话背后跑的都是它。如果你只想用图形界面,装桌面端就够了,见 下载与安装;下面这些步骤是给需要终端交互、--print 脚本自动化,或者准备读源码、提 PR 的人看的。

CLI 目前只从源码运行,没有单独的安装包。

获取源码

先装好 GitBun,然后:

git clone https://github.com/NanmiCoder/cc-haha.git
cd cc-haha
bun install

配置模型服务

cp .env.example .env

编辑 .env,至少给出一种可用的认证方式、接口地址和模型。一个 Anthropic 兼容接口的最小配置是这样:

ANTHROPIC_AUTH_TOKEN=sk-example
ANTHROPIC_BASE_URL=https://provider.example.com/anthropic
ANTHROPIC_MODEL=provider-model

变量含义、认证头的区别、Azure 与其他协议的写法见 环境变量。如果你已经在桌面端配好了服务商CLI 会直接复用那份配置,不需要再写 .env

不要把真实 API Key 提交到 Git也不要在 Issue、截图或诊断附件里公开它。

启动并验证

macOS、Linux 或 Git Bash

./bin/claude-haha
./bin/claude-haha -p "概括当前项目的目录结构"

Windows PowerShell 或 cmd

bun --env-file=.env ./src/entrypoints/cli.tsx

看到流式回复和工具调用,说明模型服务、项目目录和 CLI 已经连通。

在任意目录启动

./bin/claude-haha 只在仓库里能用。把它加进 PATH,就能在任何项目目录直接敲 claude-hahaCLI 会自动把当前工作目录当成项目根。

macOS 和 Linux 在 ~/.bashrc~/.zshrc 中添加:

# 方式一:加入 PATH推荐
export PATH="$HOME/path/to/claude-code-haha/bin:$PATH"

# 方式二alias
alias claude-haha="$HOME/path/to/claude-code-haha/bin/claude-haha"

改完重新加载:

source ~/.zshrc  # 或 source ~/.bashrc

Windows 的 Git Bash 同样在 ~/.bashrc 中加 PATH

export PATH="$HOME/path/to/claude-code-haha/bin:$PATH"

验证方式是换个目录再启动,然后问它「当前目录是什么」:

cd ~/your-other-project
claude-haha

Windows 配 WSL 工具链

如果 claude-haha 跑在 Windows 或 Git Bash 里,而 Node、Python、uv、bun 这些工具装在 WSL 中,可以显式经 WSL 调用:

wsl -e bash -lc 'node --version && python3 --version'

检测到 wsl / wsl.exe 调用时CLI 会自动设置 MSYS2_ARG_CONV_EXCL=*,避免 Git Bash 把 /home/... 这类 WSL 路径错误转换成 C:/Program Files/Git/home/...

想让 Bash 工具默认进 WSL启动前设置

export CLAUDE_CODE_SHELL_PREFIX='wsl -e bash -lc'

Computer Use 控制的仍然是 Windows 桌面应用WSL 内的命令行工具不需要写进 computer-use-config.json。只用 WSL 工具链、不需要桌面控制时,加 --no-computer-use,或在 设置 → Computer Use 里关掉它。

下一步