11# 🤖 Codestral CLI
22
3- A GitHub Copilot-style terminal interface for ** Codestral** - Mistral's code generation AI. Real-time streaming responses with beautiful terminal UI.
3+ 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 .
44
55[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
6- [ ![ Python 3.11 +] ( https://img.shields.io/badge/python-3.11 +-blue.svg )] ( https://www.python.org/downloads/ )
6+ [ ![ Python 3.8 +] ( https://img.shields.io/badge/python-3.8 +-blue.svg )] ( https://www.python.org/downloads/ )
77[ ![ Codestral] ( https://img.shields.io/badge/AI-Codestral-purple.svg )] ( https://codestral.mistral.ai/ )
88
99## ✨ Features
1010
1111- 💬 ** Interactive Chat** - GitHub Copilot-like terminal experience
12- - ⚡ ** Real-time Streaming** - See responses as they generate
13- - 🎨 ** Rich Terminal UI** - Beautiful formatting and live updates
14- - 🛠️ ** Developer Tools** - Built-in commands for code review, debugging
15- - 🚀 ** Fast & Modern** - Async architecture for responsive UX
12+ - ⚡ ** Real-time Streaming** - See responses as they generate, token by token
13+ - 🎨 ** Rich Terminal UI** - Beautiful formatting with live updates and markdown support
14+ - 🛠️ ** Developer Tools** - Built-in commands for code review, debugging, explanations
15+ - 🚀 ** Async Architecture** - Non-blocking, responsive interface
16+ - 🔧 ** Easy Setup** - One-command installation with automatic SSL handling
1617
1718## 🚀 Quick Start
1819
1920### Installation
2021``` bash
21- git clone https://github.com/yourusername /codestral-cli.git
22+ git clone https://github.com/momominds /codestral-cli.git
2223cd codestral-cli
23- pip install -r requirements.txt
24+ ./ install.sh
2425```
2526
26- ### Setup
27+ ### Setup API Key
28+ Get your API key from [ Mistral Console] ( https://console.mistral.ai/ ) :
2729``` bash
2830export MISTRAL_API_KEY=" your-api-key"
2931```
@@ -36,89 +38,166 @@ codestral-cli
3638# Single prompt
3739codestral-cli " Write a Python function to sort a list"
3840
39- # With token limit
41+ # With options
4042codestral-cli " Explain async Python" --max-tokens 500
4143```
4244
43- ## 💻 Interactive Commands
44-
45- Once in interactive mode, use these commands:
45+ ## 💻 Interactive Experience
4646
4747``` bash
48- # Basic commands
49- help # Show help
50- clear # Clear conversation
51- exit # Quit
52-
53- # Developer tools
54- /explain ls -la # Explain shell commands
55- /review myfile.py # Code review
56- /commit # Generate commit message
57- /debug " error msg" # Debug help
48+ $ codestral-cli
49+
50+ 🚀 Codestral CLI (Async Mode)
51+ Model: codestral-latest • Streaming: ON • Rich UI: ON
52+
53+ 👤 You: How do I handle errors in Python?
54+
55+ ╭─────────────────────────────── 🤖 Codestral ────────────────────────────────╮
56+ │ Error handling in Python is done using try-except blocks: │
57+ │ │
58+ │ ` ` ` python │
59+ │ try: │
60+ │ # Code that might raise an exception │
61+ │ result = 10 / 0 │
62+ │ except ZeroDivisionError: │
63+ │ print("Cannot divide by zero!") │
64+ │ except Exception as e: │
65+ │ print(f"An error occurred: {e}") │
66+ │ finally: │
67+ │ print("This always executes") │
68+ │ ` ` ` │
69+ ╰──────────────────────────── Tokens: 45 • Time: 1.2s ───────────────────────╯
70+
71+ 👤 You: /review app.py
72+ 🤖 Codestral: [Reviews your code file...]
73+
74+ 👤 You: exit
75+ 👋 Goodbye!
5876```
5977
78+ ## 🛠️ Developer Tools
79+
80+ Built-in commands accessible with ` /command ` :
81+
82+ | Command | Description | Example |
83+ | ---------| -------------| ---------|
84+ | ` /explain <cmd> ` | Explain shell commands | ` /explain docker run -it ubuntu ` |
85+ | ` /review <file> ` | Code review and feedback | ` /review src/main.py ` |
86+ | ` /commit ` | Generate commit messages | ` /commit ` |
87+ | ` /debug <error> ` | Debug help | ` /debug "ImportError: No module named 'requests'" ` |
88+ | ` /suggest <task> ` | Suggest commands | ` /suggest "deploy to AWS" ` |
89+ | ` /analyze <file> ` | Code structure analysis | ` /analyze package.json ` |
90+ | ` /test <file> ` | Generate unit tests | ` /test utils.py ` |
91+ | ` /docs <code> ` | Generate documentation | ` /docs "def hello(): return 'world'" ` |
92+
6093## ⚙️ Configuration
6194
62- Set your API key:
95+ ### Environment Variables
6396``` bash
64- export MISTRAL_API_KEY=" your-key-here"
97+ export MISTRAL_API_KEY=" your-key" # Required
98+ export MISTRAL_MODEL=" codestral-latest" # Optional
99+ export MISTRAL_MAX_TOKENS=2000 # Optional
65100```
66101
67- Optional environment variables:
68- ``` bash
69- export MISTRAL_MODEL=" codestral-latest" # Default model
70- export MISTRAL_BASE_URL=" https://..." # Custom endpoint
102+ ### Config File (` ~/.codestral/config.json ` )
103+ ``` json
104+ {
105+ "api_key" : " your-key" ,
106+ "model" : " codestral-latest" ,
107+ "max_tokens" : 2000 ,
108+ "temperature" : 0.1
109+ }
71110```
72111
73- ### 🔒 SSL Certificate Issues
112+ ## 🔧 Command Line Options
113+
114+ ``` bash
115+ codestral-cli [prompt] [options]
116+
117+ Arguments:
118+ prompt Prompt to send (if not provided, enters interactive mode)
74119
75- If you encounter SSL certificate errors:
120+ Options:
121+ --max-tokens INT Maximum tokens in response
122+ --version Show version information
123+ --help Show help message
124+ ```
125+
126+ ## 🆘 Troubleshooting
76127
128+ ### SSL Certificate Issues
129+ If you get SSL certificate errors:
77130``` bash
78- # Quick fix
131+ # Automatic fix
79132python3 fix_ssl.py
80133
81- # Manual fixes
134+ # Manual fix
82135pip3 install --upgrade certifi
83- export PYTHONHTTPSVERIFY=0 # Temporary bypass (not recommended)
84136
85- # macOS specific
86- /Applications/Python \ 3.x/Install \ Certificates.command
137+ # Temporary bypass (not recommended for production)
138+ PYTHONHTTPSVERIFY=0 codestral-cli " test prompt "
87139```
88140
89- ## 🎯 Examples
141+ ### Common Issues
142+ - ** API Key** : Make sure ` MISTRAL_API_KEY ` is set correctly
143+ - ** Dependencies** : Run ` pip3 install -r requirements.txt `
144+ - ** Permissions** : Run ` chmod +x install.sh main.py fix_ssl.py `
90145
91- ### Code Generation
92- ``` bash
93- $ codestral-cli " Create a FastAPI hello world app"
146+ ## 📚 Documentation
94147
95- 🤖 Codestral: Here ' s a simple FastAPI application :
148+ Complete documentation available in the [ ` docs/ ` ] ( docs/ ) directory :
96149
97- ```python
98- from fastapi import FastAPI
150+ - ** [ Quick Start Guide] ( docs/quick-start.md ) ** - Get up and running in 5 minutes
151+ - ** [ Commands Reference] ( docs/commands.md ) ** - All available commands and tools
152+ - ** [ Configuration Guide] ( docs/configuration.md ) ** - Advanced configuration options
153+ - ** [ Troubleshooting] ( docs/troubleshooting.md ) ** - Solutions for common issues
99154
100- app = FastAPI()
155+ ## 🎯 Key Differences from Traditional CLIs
101156
102- @app.get("/")
103- def read_root():
104- return {"Hello": "World"}
105- ```
157+ | Traditional CLI | Codestral CLI |
158+ | ----------------| ---------------|
159+ | Block and wait | ⚡ Stream live responses |
160+ | Plain text output | 🎨 Rich markdown formatting |
161+ | Single request/response | 💬 Conversational context |
162+ | No developer tools | 🛠️ Built-in code tools |
163+ | Basic error handling | 🔧 Comprehensive troubleshooting |
106164
107- ### Interactive Session
108- ```bash
109- $ codestral-cli
165+ ## 🏗️ Architecture
110166
111- 🚀 Codestral CLI
112- Type your message and press Enter. Use ' help' for commands.
167+ - ** Async Streaming** : Real-time token-by-token responses using ` aiohttp `
168+ - ** Rich Terminal UI** : Beautiful formatting with ` rich ` library
169+ - ** Modular Tools** : Extensible developer tool system
170+ - ** Smart Error Handling** : SSL troubleshooting and helpful error messages
171+ - ** Clean Configuration** : Multiple config methods with priority system
113172
114- 👤 You: How do I handle errors in Python?
173+ ## 🤝 Contributing
115174
116- 🤖 Codestral: [streaming response...]
117- ```
175+ We welcome contributions! Please see:
176+ - ** [ CONTRIBUTING.md] ( CONTRIBUTING.md ) ** - Contribution guidelines
177+ - ** [ CODE_OF_CONDUCT.md] ( CODE_OF_CONDUCT.md ) ** - Community standards
178+ - ** [ Issues] ( https://github.com/momominds/codestral-cli/issues ) ** - Bug reports and feature requests
118179
119- ## 📝 License
180+ ## 📄 License
181+
182+ This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
183+
184+ ## 🙏 Acknowledgments
185+
186+ - ** [ Mistral AI] ( https://mistral.ai/ ) ** for the excellent Codestral model
187+ - ** [ Rich] ( https://github.com/Textualize/rich ) ** for beautiful terminal UI
188+ - The Python async ecosystem (` aiohttp ` , ` asyncio ` )
189+ - The open-source community for inspiration and feedback
190+
191+ ## 🔗 Links
192+
193+ - ** GitHub Repository** : https://github.com/momominds/codestral-cli
194+ - ** Mistral AI** : https://mistral.ai/
195+ - ** Codestral API** : https://docs.mistral.ai/capabilities/code_generation/
196+ - ** Get API Key** : https://console.mistral.ai/
197+
198+ ---
120199
121- MIT License - see [LICENSE](LICENSE) for details.
200+ ** Built with ❤️ for developers who love beautiful, responsive terminal experiences. **
122201
123202# Use with any OpenAI-compatible tool
124203export OPENAI_API_BASE="http://localhost:8080/v1 "
0 commit comments