@@ -1,654 +1,25 @@
1−> [!NOTE]
1+> [!WARNING]
2−> This is the original OpenCode repository, now continuing at [Charm](https://github.com/charmbracelet) with its original creator, [Kujtim Hoxha](https://github.com/kujtimiihoxha).
2+> 🚧 This is a pre-release under heavy, active development. Things are still in flux but we’re excited to share early progress.
3−> Development is continuing under a new name as we prepare for a public relaunch.
4−> Follow [@charmcli](https://x.com/charmcli) or join our [Discord](https://charm.sh/chat) for updates.
8−<p align="center"><img src="https://github.com/user-attachments/assets/9ae61ef6-70e5-4876-bc45-5bcb4e52c714" width="800"></p>
6+<p>
7+ <a href="https://github.com/charmbracelet/crush/releases"><img src="https://img.shields.io/github/release/charmbracelet/crush" alt="Latest Release"></a>
8+ <a href="https://github.com/charmbracelet/crush/actions"><img src="https://github.com/charmbracelet/crush/workflows/build/badge.svg" alt="Build Status"></a>
10−> **⚠️ Early Development Notice:** This project is in early development and is not yet ready for production use. Features may change, break, or be incomplete. Use at your own risk.
11+Crush is a tool for building software with AI.
12−A powerful terminal-based AI assistant for developers, providing intelligent coding assistance directly in your terminal.
16−Crush is a Go-based CLI application that brings AI assistance to your terminal. It provides a TUI (Terminal User Interface) for interacting with various AI models to help with coding tasks, debugging, and more.
18−<p>For a quick video overview, check out
19−<a href="https://www.youtube.com/watch?v=P8luPmEa1QI"><img width="25" src="https://upload.wikimedia.org/wikipedia/commons/0/09/YouTube_full-color_icon_%282017%29.svg"> Crush + Gemini 2.5 Pro: BYE Claude Code! I'm SWITCHING To the FASTEST AI Coder!</a></p>
21−<a href="https://www.youtube.com/watch?v=P8luPmEa1QI"><img width="550" src="https://i3.ytimg.com/vi/P8luPmEa1QI/maxresdefault.jpg"></a><p>
25−- **Interactive TUI**: Built with [Bubble Tea](https://github.com/charmbracelet/bubbletea) for a smooth terminal experience
26−- **Multiple AI Providers**: Support for OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Groq, Azure OpenAI, and OpenRouter
27−- **Session Management**: Save and manage multiple conversation sessions
28−- **Tool Integration**: AI can execute commands, search files, and modify code
29−- **Vim-like Editor**: Integrated editor with text input capabilities
30−- **Persistent Storage**: SQLite database for storing conversations and sessions
31−- **LSP Integration**: Language Server Protocol support for code intelligence
32−- **File Change Tracking**: Track and visualize file changes during sessions
33−- **External Editor Support**: Open your preferred editor for composing messages
34−- **Named Arguments for Custom Commands**: Create powerful custom commands with multiple named placeholders
38−### Using the Install Script
41−# Install the latest version
42−curl -fsSL https://raw.githubusercontent.com/charmbracelet/crush/refs/heads/main/install | bash
44−# Install a specific version
45−curl -fsSL https://raw.githubusercontent.com/charmbracelet/crush/refs/heads/main/install | VERSION=0.1.0 bash
48−### Using Homebrew (macOS and Linux)
51−brew install crush-ai/tap/crush
54−### Using AUR (Arch Linux)
67−go install github.com/charmbracelet/crush@latest
72−Crush looks for configuration in the following locations:
75−- `$XDG_CONFIG_HOME/crush/.crush.json`
76−- `./.crush.json` (local directory)
78−### Auto Compact Feature
80−Crush includes an auto compact feature that automatically summarizes your conversation when it approaches the model's context window limit. When enabled (default setting), this feature:
82−- Monitors token usage during your conversation
83−- Automatically triggers summarization when usage reaches 95% of the model's context window
84−- Creates a new session with the summary, allowing you to continue your work without losing context
85−- Helps prevent "out of context" errors that can occur with long conversations
87−You can enable or disable this feature in your configuration file:
91− "autoCompact": true // default is true
95−### Environment Variables
97−You can configure Crush using environment variables:
99−| Environment Variable | Purpose |
100−| -------------------------- | ------------------------------------------------------ |
101−| `ANTHROPIC_API_KEY` | For Claude models |
102−| `OPENAI_API_KEY` | For OpenAI models |
103−| `GEMINI_API_KEY` | For Google Gemini models |
104−| `VERTEXAI_PROJECT` | For Google Cloud VertexAI (Gemini) |
105−| `VERTEXAI_LOCATION` | For Google Cloud VertexAI (Gemini) |
106−| `GROQ_API_KEY` | For Groq models |
107−| `AWS_ACCESS_KEY_ID` | For AWS Bedrock (Claude) |
108−| `AWS_SECRET_ACCESS_KEY` | For AWS Bedrock (Claude) |
109−| `AWS_REGION` | For AWS Bedrock (Claude) |
110−| `AZURE_OPENAI_ENDPOINT` | For Azure OpenAI models |
111−| `AZURE_OPENAI_API_KEY` | For Azure OpenAI models (optional when using Entra ID) |
112−| `AZURE_OPENAI_API_VERSION` | For Azure OpenAI models |
113−| `LOCAL_ENDPOINT` | For self-hosted models |
114−| `SHELL` | Default shell to use (if not specified in config) |
116−### Shell Configuration
118−Crush allows you to configure the shell used by the bash tool. By default, it uses the shell specified in the `SHELL` environment variable, or falls back to `/bin/bash` if not set.
120−You can override this in your configuration file:
131−This is useful if you want to use a different shell than your default system shell, or if you need to pass specific arguments to the shell.
133−### Configuration File Structure
138− "directory": ".crush"
142− "apiKey": "your-api-key",
146− "apiKey": "your-api-key",
150− "apiKey": "your-api-key",
154− "apiKey": "your-api-key",
160− "model": "claude-3.7-sonnet",
164− "model": "claude-3.7-sonnet",
168− "model": "claude-3.7-sonnet",
173− "path": "/bin/bash",
179− "command": "path/to/mcp-server",
196−## Supported AI Models
198−Crush supports a variety of AI models from different providers:
202−- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano)
204−- GPT-4o family (gpt-4o, gpt-4o-mini)
205−- O1 family (o1, o1-pro, o1-mini)
206−- O3 family (o3, o3-mini)
224−- Gemini 2.0 Flash Lite
232−- Llama 4 Maverick (17b-128e-instruct)
233−- Llama 4 Scout (17b-16e-instruct)
235−- Deepseek R1 distill Llama 70b
236−- Llama 3.3 70b Versatile
240−- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano)
242−- GPT-4o family (gpt-4o, gpt-4o-mini)
243−- O1 family (o1, o1-mini)
244−- O3 family (o3, o3-mini)
247−### Google Cloud VertexAI
258−# Start with debug logging
261−# Start with a specific working directory
262−crush -c /path/to/project
265−## Non-interactive Prompt Mode
267−You can run Crush in non-interactive mode by passing a prompt directly as a command-line argument. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI.
270−# Run a single prompt and print the AI's response to the terminal
271−crush -p "Explain the use of context in Go"
273−# Get response in JSON format
274−crush -p "Explain the use of context in Go" -f json
276−# Run without showing the spinner (useful for scripts)
277−crush -p "Explain the use of context in Go" -q
280−In this mode, Crush will process your prompt, print the result to standard output, and then exit. All permissions are auto-approved for the session.
282−By default, a spinner animation is displayed while the model is processing your query. You can disable this spinner with the `-q` or `--quiet` flag, which is particularly useful when running Crush from scripts or automated workflows.
286−Crush supports the following output formats in non-interactive mode:
288−| Format | Description |
289−| ------ | ------------------------------- |
290−| `text` | Plain text output (default) |
291−| `json` | Output wrapped in a JSON object |
293−The output format is implemented as a strongly-typed `OutputFormat` in the codebase, ensuring type safety and validation when processing outputs.
295−## Command-line Flags
297−| Flag | Short | Description |
298−| ----------------- | ----- | --------------------------------------------------- |
299−| `--help` | `-h` | Display help information |
300−| `--debug` | `-d` | Enable debug mode |
301−| `--cwd` | `-c` | Set current working directory |
302−| `--prompt` | `-p` | Run a single prompt in non-interactive mode |
303−| `--output-format` | `-f` | Output format for non-interactive mode (text, json) |
304−| `--quiet` | `-q` | Hide spinner in non-interactive mode |
306−## Keyboard Shortcuts
310−| Shortcut | Action |
311−| -------- | ------------------------------------------------------- |
312−| `Ctrl+C` | Quit application |
313−| `Ctrl+?` | Toggle help dialog |
314−| `?` | Toggle help dialog (when not in editing mode) |
315−| `Ctrl+L` | View logs |
316−| `Ctrl+A` | Switch session |
317−| `Ctrl+K` | Command dialog |
318−| `Ctrl+O` | Toggle model selection dialog |
319−| `Esc` | Close current overlay/dialog or return to previous mode |
321−### Chat Page Shortcuts
323−| Shortcut | Action |
324−| -------- | --------------------------------------- |
325−| `Ctrl+N` | Create new session |
326−| `Ctrl+X` | Cancel current operation/generation |
327−| `i` | Focus editor (when not in writing mode) |
328−| `Esc` | Exit writing mode and focus messages |
332−| Shortcut | Action |
333−| ------------------- | ----------------------------------------- |
334−| `Ctrl+S` | Send message (when editor is focused) |
335−| `Enter` or `Ctrl+S` | Send message (when editor is not focused) |
336−| `Ctrl+E` | Open external editor |
337−| `Esc` | Blur editor and focus messages |
339−### Session Dialog Shortcuts
341−| Shortcut | Action |
342−| ---------- | ---------------- |
343−| `↑` or `k` | Previous session |
344−| `↓` or `j` | Next session |
345−| `Enter` | Select session |
346−| `Esc` | Close dialog |
348−### Model Dialog Shortcuts
350−| Shortcut | Action |
351−| ---------- | ----------------- |
352−| `↑` or `k` | Move up |
353−| `↓` or `j` | Move down |
354−| `←` or `h` | Previous provider |
355−| `→` or `l` | Next provider |
356−| `Esc` | Close dialog |
358−### Permission Dialog Shortcuts
360−| Shortcut | Action |
361−| ----------------------- | ---------------------------- |
362−| `←` or `left` | Switch options left |
363−| `→` or `right` or `tab` | Switch options right |
364−| `Enter` or `space` | Confirm selection |
365−| `a` | Allow permission |
366−| `A` | Allow permission for session |
367−| `d` | Deny permission |
369−### Logs Page Shortcuts
371−| Shortcut | Action |
372−| ------------------ | ------------------- |
373−| `Backspace` or `q` | Return to chat page |
375−## AI Assistant Tools
377−Crush's AI assistant has access to various tools to help with coding tasks:
379−### File and Code Tools
381−| Tool | Description | Parameters |
382−| ------------- | --------------------------- | ---------------------------------------------------------------------------------------- |
383−| `glob` | Find files by pattern | `pattern` (required), `path` (optional) |
384−| `grep` | Search file contents | `pattern` (required), `path` (optional), `include` (optional), `literal_text` (optional) |
385−| `ls` | List directory contents | `path` (optional), `ignore` (optional array of patterns) |
386−| `view` | View file contents | `file_path` (required), `offset` (optional), `limit` (optional) |
387−| `write` | Write to files | `file_path` (required), `content` (required) |
388−| `edit` | Edit files | Various parameters for file editing |
389−| `patch` | Apply patches to files | `file_path` (required), `diff` (required) |
390−| `diagnostics` | Get diagnostics information | `file_path` (optional) |
394−| Tool | Description | Parameters |
395−| ------------- | -------------------------------------- | ----------------------------------------------------------------------------------------- |
396−| `bash` | Execute shell commands | `command` (required), `timeout` (optional) |
397−| `fetch` | Fetch data from URLs | `url` (required), `format` (required), `timeout` (optional) |
398−| `sourcegraph` | Search code across public repositories | `query` (required), `count` (optional), `context_window` (optional), `timeout` (optional) |
399−| `agent` | Run sub-tasks with the AI agent | `prompt` (required) |
403−Crush is built with a modular architecture:
405−- **cmd**: Command-line interface using Cobra
406−- **internal/app**: Core application services
407−- **internal/config**: Configuration management
408−- **internal/db**: Database operations and migrations
409−- **internal/llm**: LLM providers and tools integration
410−- **internal/tui**: Terminal UI components and layouts
411−- **internal/logging**: Logging infrastructure
412−- **internal/message**: Message handling
413−- **internal/session**: Session management
414−- **internal/lsp**: Language Server Protocol integration
418−Crush supports custom commands that can be created by users to quickly send predefined prompts to the AI assistant.
420−### Creating Custom Commands
422−Custom commands are predefined prompts stored as Markdown files in one of three locations:
424−1. **User Commands** (prefixed with `user:`):
427− $XDG_CONFIG_HOME/crush/commands/
430− (typically `~/.config/crush/commands/` on Linux/macOS)
435− $HOME/.crush/commands/
438−2. **Project Commands** (prefixed with `project:`):
441− <PROJECT DIR>/.crush/commands/
444−Each `.md` file in these directories becomes a custom command. The file name (without extension) becomes the command ID.
446−For example, creating a file at `~/.config/crush/commands/prime-context.md` with content:
453−This creates a command called `user:prime-context`.
455−### Command Arguments
457−Crush supports named arguments in custom commands using placeholders in the format `$NAME` (where NAME consists of uppercase letters, numbers, and underscores, and must start with a letter).
462−# Fetch Context for Issue $ISSUE_NUMBER
464−RUN gh issue view $ISSUE_NUMBER --json title,body,comments
465−RUN git grep --author="$AUTHOR_NAME" -n .
466−RUN grep -R "$SEARCH_PATTERN" $DIRECTORY
469−When you run a command with arguments, Crush will prompt you to enter values for each unique placeholder. Named arguments provide several benefits:
471−- Clear identification of what each argument represents
472−- Ability to use the same argument multiple times
473−- Better organization for commands with multiple inputs
475−### Organizing Commands
477−You can organize commands in subdirectories:
480−~/.config/crush/commands/git/commit.md
483−This creates a command with ID `user:git:commit`.
485−### Using Custom Commands
487−1. Press `Ctrl+K` to open the command dialog
488−2. Select your custom command (prefixed with either `user:` or `project:`)
489−3. Press Enter to execute the command
491−The content of the command file will be sent as a message to the AI assistant.
493−### Built-in Commands
495−Crush includes several built-in commands:
497−| Command | Description |
498−| ------------------ | --------------------------------------------------------------------------------------------------- |
499−| Initialize Project | Creates or updates the CRUSH.md memory file with project-specific information |
500−| Compact Session | Manually triggers the summarization of the current session, creating a new session with the summary |
502−## MCP (Model Context Protocol)
504−Crush implements the Model Context Protocol (MCP) to extend its capabilities through external tools. MCP provides a standardized way for the AI assistant to interact with external services and tools.
508−- **External Tool Integration**: Connect to external tools and services via a standardized protocol
509−- **Tool Discovery**: Automatically discover available tools from MCP servers
510−- **Multiple Connection Types**:
511− - **Stdio**: Communicate with tools via standard input/output
512− - **SSE**: Communicate with tools via Server-Sent Events
513−- **Security**: Permission system for controlling access to MCP tools
515−### Configuring MCP Servers
517−MCP servers are defined in the configuration file under the `mcpServers` section:
524− "command": "path/to/mcp-server",
530− "url": "https://example.com/mcp",
532− "Authorization": "Bearer token"
541−Once configured, MCP tools are automatically available to the AI assistant alongside built-in tools. They follow the same permission model as other tools, requiring user approval before execution.
543−## LSP (Language Server Protocol)
545−Crush integrates with Language Server Protocol to provide code intelligence features across multiple programming languages.
549−- **Multi-language Support**: Connect to language servers for different programming languages
550−- **Diagnostics**: Receive error checking and linting information
551−- **File Watching**: Automatically notify language servers of file changes
555−Language servers are configured in the configuration file under the `lsp` section:
566− "command": "typescript-language-server",
573−### LSP Integration with AI
575−The AI assistant can access LSP features through the `diagnostics` tool, allowing it to:
577−- Check for errors in your code
578−- Suggest fixes based on diagnostics
580−While the LSP client implementation supports the full LSP protocol (including completions, hover, definition, etc.), currently only diagnostics are exposed to the AI assistant.
582−## Using a self-hosted model provider
584−Crush can also load and use models from a self-hosted (OpenAI-like) provider.
585−This is useful for developers who want to experiment with custom models.
587−### Configuring a self-hosted provider
589−You can use a self-hosted model by setting the `LOCAL_ENDPOINT` environment variable.
590−This will cause Crush to load and use the models from the specified endpoint.
593−LOCAL_ENDPOINT=http://localhost:1235/v1
596−### Configuring a self-hosted model
598−You can also configure a self-hosted model in the configuration file under the `agents` section:
604− "model": "local.granite-3.3-2b-instruct@q8_0",
605− "reasoningEffort": "high"
615−- Go 1.24.0 or higher
617−### Building from Source
620−# Clone the repository
621−git clone https://github.com/charmbracelet/crush.git
633−Crush gratefully acknowledges the contributions and support from these key individuals:
635−- [@isaacphi](https://github.com/isaacphi) - For the [mcp-language-server](https://github.com/isaacphi/mcp-language-server) project which provided the foundation for our LSP client implementation
636−- [@adamdottv](https://github.com/adamdottv) - For the design direction and UI/UX architecture
638−Special thanks to the broader open source community whose tools and libraries have made this project possible.
640## License
14## License
642−Crush is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
16+[MIT](https://github.com/charmbracelet/crush/raw/main/LICENSE)
644−## Contributing
18+---
646−Contributions are welcome! Here's how you can contribute:
20+Part of [Charm](https://charm.sh).
648−1. Fork the repository
22+<a href="https://charm.sh/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-badge.jpg" /></a>
649−2. Create a feature branch (`git checkout -b feature/amazing-feature`)
650−3. Commit your changes (`git commit -m 'Add some amazing feature'`)
651−4. Push to the branch (`git push origin feature/amazing-feature`)
652−5. Open a Pull Request
654−Please make sure to update tests as appropriate and follow the existing code style.
24+<!--prettier-ignore-->
25+Charm热爱开源 • Charm loves open source