Clover CLI
Clover is a terminal-based AI assistant that works with various AI models to help build and manage projects. It provides tools for file operations, project structure management, command execution, and repository integration while supporting multiple LLM providers.
Features
- File Operations: Read, create, update, and delete files
- Project Management: Generate and maintain project structures
- Command Execution: Safe execution of system commands with permission prompts
- Git Integration: Repository status, diff, commit, and push operations
- Code Quality Tools: Linting (flake8, pylint) and formatting (black, isort)
- Multiple Model Support: Works with various AI models through an OpenAI-compatible API
- Configuration Management: Set timeouts and thread limits for operations
Installation
- Create a virtual environment:
python -m venv clover_env
- Activate the virtual environment:
source clover_env/bin/activate # On macOS/Linux
# or
clover_env\Scripts\activate # On Windows
- Install dependencies:
pip install openai requests python-dotenv tqdm GitPython pylint black isort bandit docker pydantic
Running Clover CLI
After installation and activation of virtual environment, run:
source clover_env/bin/activate # Activate the environment
cd /path/to/clover/project # Navigate to project directory
PYTHONPATH=. python main.py # Run the CLI with proper module path
Interactive Mode
Simply run python main.py without arguments to enter interactive mode:
source clover_env/bin/activate
cd /path/to/clover/project
PYTHONPATH=. python main.py # Enter interactive mode
In interactive mode, you can run commands directly without the 'clover' prefix:
/init- Initialize project summary file/list- List available models/timeout 300- Set timeout to 300 seconds/threads 5- Set thread limit to 5/git_status- Check Git repository status/lint_file main.py- Lint a specific file
Simple Examples
To get help:
PYTHONPATH=. python main.py --help
To initialize a project:
PYTHONPATH=. python main.py /init
To enter interactive mode:
PYTHONPATH=. python main.py
Project Structure
clover/
├── main.py # Main entry point
├── cli/ # CLI module
│ ├── __init__.py
│ ├── commands.py # Command implementations
│ └── parser.py # CLI argument parsing
├── tools/ # Core tool implementations
│ ├── __init__.py
│ ├── file_tools.py # File operations (read, create, update, delete)
│ ├── project_tools.py # Project operations (summarize, structure)
│ ├── commandline_tool.py # Command line execution tool
│ ├── git_tools.py # Git repository operations
│ └── lint_format_tools.py # Linting and formatting tools
├── models/ # Model interaction modules
│ ├── __init__.py
│ ├── model_manager.py # Manage available models
│ └── api_client.py # API client for different LLM providers
├── config/ # Configuration management
│ ├── __init__.py
│ └── settings.py # Settings and configuration handling
└── requirements.txt # Dependencies list
Development
Running Tests
After activating the virtual environment:
source clover_env/bin/activate # Activate venv
cd /path/to/clover/project
PYTHONPATH=. python -m pytest tests/
Adding New Tools
To add new tools, create a new module in the tools/ directory and import it in cli/commands.py. Follow the existing pattern for consistency.
Configuration
Environment variables supported:
CLOVER_TIMEOUT- Timeout for operations (default: 300)CLOVER_THREADS- Maximum concurrent threads (default: 5)CLOVER_MODEL- Default AI model to use (default: gpt-4)
Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push branch (
git push origin feature/AmazingFeature) - Open pull request
License
MIT License