Crush(AI自动编程软件)简介
Crush 是一个开源免费的AI自动编程软件,能够利用AI人工智能编程代码,为我们提供高效、灵活的编程体验。该工具结合了多种大型语言模型(LLM),可以在使用过程中根据需求选择不同的模型或在会话中切换模型,其灵活性能够满足不同项目和个人偏好的需求。

主要特色功能:
- 多模型支持:支持多种大型语言模型,可以通过OpenAI或Anthropic等API轻松添加自己的模型。这种多样性让开发者能够选择最适合其工作流程的工具。
- 灵活的会话管理:允许用户在不同项目中维护多个会话和上下文,确保在工作时不丢失重要信息。这种功能特别适合需要在多个任务之间切换的开发者。
- 与LSP集成:利用语言服务器协议(LSP)提供额外上下文,帮助用户更好地理解代码和实现功能。这种集成使其不仅仅是一个代码助手,更是一个全面的开发环境。
- 跨平台支持:在macOS、Linux、Windows等多种操作系统上均可运行,极大地提升了其适用性和便利性。
Crush(AI自动编程软件)官网及教程
部署Crush工具的步骤相对简单,以下是详细的安装和配置说明。
1. 安装Crush
通过包管理器安装
- Homebrew (macOS):
brew install charmbracelet/tap/crush
- NPM (Node.js):
npm install -g @charmland/crush
- Arch Linux:
yay -S crush-bin
- Nix:
nix run github:numtide/nix-ai-tools#crush
- Scoop (Windows):
scoop bucket add charm https://github.com/charmbracelet/scoop-bucket.git scoop install crush
- Debian/Ubuntu:
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list sudo apt update && sudo apt install crush
- Fedora/RHEL:
echo '[charm]' | sudo tee /etc/yum.repos.d/charm.repo echo 'name=Charm' | sudo tee -a /etc/yum.repos.d/charm.repo echo 'baseurl=https://repo.charm.sh/yum/' | sudo tee -a /etc/yum.repos.d/charm.repo echo 'enabled=1' | sudo tee -a /etc/yum.repos.d/charm.repo echo 'gpgcheck=1' | sudo tee -a /etc/yum.repos.d/charm.repo echo 'gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee -a /etc/yum.repos.d/charm.repo sudo yum install crush
直接下载
选择下载适合你系统的二进制文件,支持Linux、macOS、Windows等操作系统。
2. 获取API密钥
使用Crush之前,你需要为所需的模型提供API密钥。支持的提供商包括OpenAI、Anthropic等。获取API密钥后,可以通过以下方式设置:
- 直接在启动Crush时输入API密钥。
- 通过设置环境变量:
export OPENAI_API_KEY=你的API密钥
3. 配置Crush
Crush运行时可以使用默认配置,但你也可以根据需要进行自定义配置。配置文件可以是:
.crush.json
crush.json
$HOME/.config/crush/crush.json
(Windows下为%USERPROFILE%\AppData\Local\crush\crush.json
)
配置示例:
{
"providers": {
"openai": {
"api_key": "$OPENAI_API_KEY"
}
}
}
4. 启动Crush
在终端中输入命令启动Crush:
crush
5. 启动后,你可以开始使用Crush进行编程。根据需要选择不同的模型和配置,享受更加高效的编程体验。