Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
321 changes: 18 additions & 303 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,321 +1,36 @@
# 🤖 Codestral CLI
# ⚠️ DEPRECATED: Codestral CLI

A modern GitHub Copilot-style terminal interface for **Codestral** - Mistral's code generation AI. Real-time streaming responses with beautiful terminal UI and powerful developer tools.
## 🔴 This package is no longer maintained

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Codestral](https://img.shields.io/badge/AI-Codestral-purple.svg)](https://codestral.mistral.ai/)

## ✨ Features

- 💬 **Interactive Chat** - GitHub Copilot-like terminal experience
- ⚡ **Real-time Streaming** - See responses as they generate, token by token
- 🎨 **Rich Terminal UI** - Beautiful formatting with live updates and markdown support
- 🤖 **AI Function Calling** - Native Mistral function calling with automatic tool selection
- 🛠️ **Smart Developer Tools** - AI-powered code review, debugging, analysis with 11+ tools
- 🚀 **Async Architecture** - Non-blocking, responsive interface
- 🔧 **Easy Setup** - One-command installation with automatic SSL handling

## 🚀 Quick Start

### Installation
```bash
git clone https://github.com/momominds/codestral-cli.git
cd codestral-cli
./install.sh
```

### Setup API Key
Get your API key from [Mistral Console](https://console.mistral.ai/):
```bash
export MISTRAL_API_KEY="your-api-key"
```

### Usage
```bash
# Interactive mode
codestral-cli

# Single prompt
codestral-cli "Write a Python function to sort a list"

# With options
codestral-cli "Explain async Python" --max-tokens 500
```

## 💻 Interactive Experience

```bash
$ codestral-cli

🚀 Codestral CLI (Function Calling Mode)
Model: codestral-latest • Tools: 11 available • AI Selection: ON

👤 You: Can you review my main.py file for security issues?

🤖 Codestral: I'll analyze your file for security concerns...
[🔧 AI automatically calls: review(file_path="main.py", focus="security")]

✅ Security Review Complete:
╭─ Code Review Results ─────────────────────────────────────────╮
│ • No SQL injection vulnerabilities detected │
│ • Input validation properly implemented │
│ • Authentication mechanisms secure │
│ • Recommendation: Consider adding rate limiting │
╰───────────────────────────────── Tokens: 120 • Time: 2.1s ──╯

👤 You: Debug this error: ImportError: No module named 'requests'

🤖 Codestral: Let me help debug that import error...
[🔧 AI automatically calls: debug(error_message="ImportError: No module named 'requests'")]

✅ Debug Analysis:
╭─ Error Diagnosis & Solution ──────────────────────────────────╮
│ Issue: Missing dependency - requests module not installed │
│ Solution: pip install requests │
│ Prevention: Add requests to requirements.txt │
╰───────────────────────────────── Tokens: 85 • Time: 1.5s ───╯

👤 You: What's the weather like?

🤖 Codestral: I don't have access to weather data, but I can help with coding tasks!
Try asking me to review code, debug errors, or explain commands.

👤 You: exit
👋 Goodbye!
```

## 🤖 AI-Powered Function Calling

Codestral CLI uses **Mistral AI's native function calling** to intelligently select and execute the right tools for your requests. Just speak naturally - the AI automatically chooses what to do!

### 🎯 How It Works
1. **Natural Language**: "Review my code for bugs"
2. **AI Selection**: Codestral automatically calls `review(file="code.py", focus="bugs")`
3. **Execution**: Tool runs and returns formatted results
4. **Response**: See actionable insights immediately

### 🛠️ Available Tools (AI Auto-Selected)

| Tool | Purpose | Example Trigger |
|------|---------|----------------|
| **`analyze`** | Code structure & complexity analysis | "Analyze main.py complexity" |
| **`review`** | Detailed code review & feedback | "Review this file for security issues" |
| **`test`** | Generate comprehensive unit tests | "Generate tests for utils.py" |
| **`docs`** | Create documentation | "Document this function" |
| **`debug`** | Analyze & fix errors | "Debug: ImportError: No module named 'x'" |
| **`explain`** | Explain shell commands | "Explain 'docker run -it ubuntu'" |
| **`suggest`** | Suggest commands for tasks | "How do I deploy to AWS?" |
| **`commit`** | Generate commit messages | "Help me commit these changes" |
| **`search`** | Find code patterns | "Find all database queries" |
| **`git`** | Git workflow help | "Help with git merge conflicts" |

### 💡 Function Calling vs Manual Commands
```bash
# Old way (still works)
/review main.py --focus security

# New AI way (preferred)
"Can you review main.py for security issues?"
# → AI automatically calls review(file_path="main.py", focus="security")
```

## ⚙️ Configuration

### Environment Variables
```bash
export MISTRAL_API_KEY="your-key" # Required
export MISTRAL_MODEL="codestral-latest" # Optional
export MISTRAL_MAX_TOKENS=2000 # Optional
```

### Config File (`~/.codestral/config.json`)
```json
{
"api_key": "your-key",
"model": "codestral-latest",
"max_tokens": 2000,
"temperature": 0.1
}
```

## 🔧 Command Line Options

```bash
codestral-cli [prompt] [options]

Arguments:
prompt Prompt to send (if not provided, enters interactive mode)

Options:
--max-tokens INT Maximum tokens in response
--version Show version information
--help Show help message
```

## 🆘 Troubleshooting

### SSL Certificate Issues
If you get SSL certificate errors:
```bash
# Automatic fix
python3 fix_ssl.py

# Manual fix
pip3 install --upgrade certifi

# Temporary bypass (not recommended for production)
PYTHONHTTPSVERIFY=0 codestral-cli "test prompt"
```

### Common Issues
- **API Key**: Make sure `MISTRAL_API_KEY` is set correctly
- **Dependencies**: Run `pip3 install -r requirements.txt`
- **Permissions**: Run `chmod +x install.sh main.py fix_ssl.py`

## 📚 Documentation

Complete documentation available in the [`docs/`](docs/) directory:

- **[Quick Start Guide](docs/quick-start.md)** - Get up and running in 5 minutes
- **[Commands Reference](docs/commands.md)** - All available commands and tools
- **[Configuration Guide](docs/configuration.md)** - Advanced configuration options
- **[Troubleshooting](docs/troubleshooting.md)** - Solutions for common issues

## 🎯 Key Differences from Traditional CLIs

| Traditional CLI | Codestral CLI |
|----------------|---------------|
| Block and wait | ⚡ Stream live responses |
| Plain text output | 🎨 Rich markdown formatting |
| Single request/response | 💬 Conversational context |
| No developer tools | 🛠️ Built-in code tools |
| Basic error handling | 🔧 Comprehensive troubleshooting |

## 🏗️ Architecture

- **Async Streaming**: Real-time token-by-token responses using `aiohttp`
- **Rich Terminal UI**: Beautiful formatting with `rich` library
- **Modular Tools**: Extensible developer tool system
- **Smart Error Handling**: SSL troubleshooting and helpful error messages
- **Clean Configuration**: Multiple config methods with priority system

## 🤝 Contributing

We welcome contributions! Please see:
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - Contribution guidelines
- **[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)** - Community standards
- **[Issues](https://github.com/momominds/codestral-cli/issues)** - Bug reports and feature requests

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- **[Mistral AI](https://mistral.ai/)** for the excellent Codestral model
- **[Rich](https://github.com/Textualize/rich)** for beautiful terminal UI
- The Python async ecosystem (`aiohttp`, `asyncio`)
- The open-source community for inspiration and feedback

## 🔗 Links

- **GitHub Repository**: https://github.com/momominds/codestral-cli
- **Mistral AI**: https://mistral.ai/
- **Codestral API**: https://docs.mistral.ai/capabilities/code_generation/
- **Get API Key**: https://console.mistral.ai/
This project has been **deprecated** and is no longer actively maintained. We recommend users to migrate to alternative solutions.

---

**Built with ❤️ for developers who love beautiful, responsive terminal experiences.**

# Use with any OpenAI-compatible tool
export OPENAI_API_BASE="http://localhost:8080/v1"
```

## 🛠️ Built-in Tools

The CLI includes powerful developer tools accessible via `/command`:
## 📚 For Historical Reference

- `/explain <command>` - Explain shell commands
- `/suggest <task>` - Suggest commands for tasks
- `/review <file>` - Code review and feedback
- `/analyze <file>` - Analyze code structure
- `/commit` - Generate git commit messages
- `/debug <error>` - Help debug errors
- `/test <file>` - Generate unit tests
- `/docs <code>` - Generate documentation
If you're interested in the original functionality and documentation of this project, please refer to:

## 📁 Project Structure
**[README.original.md](README.original.md)** - Complete original documentation

```
codestral-cli/
├── main.py # CLI entry point
├── codestral_cli/ # Main package
│ ├── core/ # Core functionality
│ │ ├── client.py # API client
│ │ ├── config.py # Configuration
│ │ └── cli.py # CLI interface
│ ├── tools/ # Developer tools
│ ├── ui/ # User interface
│ └── utils/ # Utilities
├── proxy/ # OpenAI-compatible proxy
│ ├── server.py # Async server
│ └── simple_server.py # Simple HTTP server
├── examples/ # Usage examples
└── tests/ # Test suite
```

## ⚙️ Configuration

### Environment Variables
- `MISTRAL_API_KEY` - Your Codestral API key (required)
- `MISTRAL_MODEL` - Model to use (default: codestral-latest)
- `MISTRAL_BASE_URL` - API base URL (default: https://codestral.mistral.ai/v1)

### Config File
Create `~/.codestral/config.json`:
```json
{
"model": "codestral-latest",
"max_tokens": 2000,
"temperature": 0.1,
"show_loader": true
}
```

## 🔗 Integration Examples

### With VS Code
```bash
# Start proxy
python3 proxy/server.py &

# Configure VS Code to use local endpoint
# Settings → OpenAI: Base URL → http://localhost:8080/v1
```
---

### With curl
```bash
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Write a Python hello world"}]}'
```
## 🔄 Recommended Alternatives

## 🤝 Contributing
We recommend exploring the following alternatives:

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
- **[Mistral AI Official CLI](https://docs.mistral.ai/)** - Official Mistral AI tools
- **[Aider](https://github.com/paul-gauthier/aider)** - AI pair programming in your terminal
- **[GitHub Copilot CLI](https://githubnext.com/projects/copilot-cli)** - GitHub's official CLI tool

## 📝 License
---

This project is licensed under the MIT License - see [LICENSE](LICENSE) for details.
## ❓ Questions?

## 🙏 Acknowledgments
If you have questions about this deprecation or need assistance migrating, please:

- **Mistral AI** for the excellent Codestral model
- **OpenAI** for the API standard enabling easy integration
- The open-source community for inspiration and tools
- Check the [Issues](https://github.com/developers-nightmare/codestral-cli/issues) page
- Review the [original documentation](README.original.md)

---

**Built for developers, by developers** ❤️
**Thank you to everyone who used and contributed to this project! 🙏**
Loading