一个基于 Anthropic Messages API 形状运行的命令行 AI 编程 agent。
如果你要接本地模型或外部厂商模型,推荐统一通过 LiteLLM 做一层协议转换,整体链路如下:
claude-code-xixi -> Anthropic 协议 -> LiteLLM -> Ollama / 外部 API
本仓库当前按 Windows PowerShell 使用方式整理。
先安装 Bun:
powershell -c "irm bun.sh/install.ps1 | iex"安装完成后,在仓库根目录安装项目依赖:
cd <repo-root>
bun install如果你的网络环境下 bun install 失败,可以改用:
npm install --replace-registry-host=always --registry=https://registry.npmjs.org/LiteLLM 负责把本项目发出的 Anthropic 风格请求转发到 Ollama 或外部模型 API。
py -m pip install "litellm[proxy]"安装后可检查版本:
litellm --help如果你要走本地模型模式,需要安装 Ollama;如果你只用外部 API 模式,可以先跳过启动 Ollama 这一步。
仓库根目录已经带了一个 OllamaSetup.exe,也可以使用你自己的安装方式。安装完成后,先拉一个本地模型,例如:
ollama pull qwen2.5-coder:7b检查是否安装成功:
ollama list仓库目前推荐两种模式:
| 模式 | 适用场景 | 是否需要 Ollama | 启动脚本 |
|---|---|---|---|
| 本地 Ollama 模式 | 本地推理、离线优先 | 需要 | scripts\start-local-stack.ps1 |
| 外部 API 模式 | 使用 DeepSeek 等供应商 API | 不需要 | scripts\start-vendor-stack.ps1 |
仓库里已经提供了两套可直接切换的环境预设:
env-presets/local-model.envenv-presets/deepseek.env
切换预设统一使用:
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile local-model或:
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile deepseek这个脚本会把对应预设写入仓库根目录的 .env,并保留当前 .env 中的 CLAUDE_CODE_GIT_BASH_PATH。
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile local-model默认情况下,litellm_config.yaml 里已经把 local-coder 映射到:
model_list:
- model_name: local-coder
litellm_params:
model: ollama/qwen2.5-coder:7b
api_base: http://127.0.0.1:11434
litellm_settings:
drop_params: true如果你本地拉的不是 qwen2.5-coder:7b,把这里的 model 改成你实际使用的 Ollama 模型名即可。
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\start-local-stack.ps1这个脚本会依次完成:
- 检查并启动
Ollama - 检查并启动
LiteLLM - 启动
claude-code-xixi
如果你想一键执行单次任务,也可以直接把参数透传进去:
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\start-local-stack.ps1 -p "读取当前仓库并总结怎么启动"当前仓库自带的外部 API 预设是 DeepSeek;如果你要换成其他供应商,也建议继续通过 LiteLLM 转发。
当前 shell 临时设置:
$env:DEEPSEEK_API_KEY="sk-xxxx"如果你希望后续新开的 PowerShell 默认带上它,可以执行:
setx DEEPSEEK_API_KEY "sk-xxxx"cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile deepseekcd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\start-vendor-stack.ps1这个脚本会:
- 检查并启动
LiteLLM - 启动
claude-code-xixi
这条链路不会启动 Ollama。
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile local-model
powershell -ExecutionPolicy Bypass -File .\scripts\start-local-stack.ps1cd <repo-root>
$env:DEEPSEEK_API_KEY="sk-xxxx"
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile deepseek
powershell -ExecutionPolicy Bypass -File .\scripts\start-vendor-stack.ps1判断当前启用的是哪种模式,直接看仓库根目录的 .env:
ANTHROPIC_MODEL=local-coder表示本地 Ollama 模式ANTHROPIC_MODEL=deepseek-chat表示外部 API 模式
cd <repo-root>
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile local-model
powershell -ExecutionPolicy Bypass -File .\scripts\start-local-stack.ps1cd <repo-root>
$env:DEEPSEEK_API_KEY="sk-xxxx"
powershell -ExecutionPolicy Bypass -File .\scripts\use-model-profile.ps1 -Profile deepseek
powershell -ExecutionPolicy Bypass -File .\scripts\start-vendor-stack.ps1README.md项目使用说明,重点看安装、切换模式和启动方式。.env.example环境变量模板,列出了本项目支持的几种接入方式示例。它是参考模板,不是当前生效配置。.env当前实际生效的环境配置。use-model-profile.ps1切换模式时,最终修改的就是这个文件。env-presets/local-model.env本地 Ollama 模式预设,核心是把ANTHROPIC_MODEL设为local-coder,并把请求指向本地 LiteLLM。env-presets/deepseek.env外部 API 模式预设,当前默认走deepseek-chat,同时设置了CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192。litellm_config.yamlLiteLLM 的模型路由配置文件。这里定义了:model_name是项目内部使用的模型别名,model是 LiteLLM 实际转发的目标模型,api_base是目标服务地址,api_key用于外部 API 认证,drop_params: true用于丢弃目标模型不认识的 Anthropic 专有参数。scripts/use-model-profile.ps1模式切换脚本。负责把env-presets里的预设覆盖到.env。
ANTHROPIC_BASE_URL:项目实际请求的入口地址。这里通常指向本地 LiteLLM,例如http://127.0.0.1:4000ANTHROPIC_MODEL:项目使用的模型别名,需要和litellm_config.yaml里的model_name对上ANTHROPIC_DEFAULT_SONNET_MODEL、ANTHROPIC_DEFAULT_HAIKU_MODEL、ANTHROPIC_DEFAULT_OPUS_MODEL:给不同默认模型位指定别名CLAUDE_CODE_MAX_OUTPUT_TOKENS:外部 API 模式下用于限制输出 token,当前 DeepSeek 预设需要它NO_PROXY:让本地127.0.0.1和localhost不走代理DISABLE_TELEMETRY、CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:关闭非必要外联流量
如果你不想用一键脚本,也可以手动分开启动。
窗口 1:
ollama serve窗口 2:
litellm --config litellm_config.yaml --port 4000窗口 3:
bun --preload=.\preload.ts --env-file=.env .\src\entrypoints\cli.tsx窗口 1:
$env:DEEPSEEK_API_KEY="sk-xxxx"
litellm --config litellm_config.yaml --port 4000窗口 2:
bun --preload=.\preload.ts --env-file=.env .\src\entrypoints\cli.tsx- 一键脚本会调用仓库内的 PowerShell 启动脚本;如果你的
bun.exe或litellm.exe安装路径不是脚本中默认路径,请同步调整对应脚本。 - 如果你要接入其他外部模型,通常只需要改
litellm_config.yaml和对应的预设.env文件。 - 更多第三方模型说明可参考 docs/third-party-models.md。