4.0 KiB
4.0 KiB
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, and command execution 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
- 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
Usage
Basic Commands
clover /list- List available models on the serverclover /init- Initialize project summary file (clover.md)clover /timeout 300- Set timeout to 300 seconds for AI operationsclover /threads 5- Set thread limit to 5 for concurrent operationsclover "Write a Python function to calculate factorial"- Send prompt to AI assistant
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
├── 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
├── utils/ # Utility functions
│ ├── __init__.py
│ └── helpers.py # Helper functions and utilities
└── requirements.txt # Dependencies
Configuration
Configuration is handled through environment variables:
CLOVER_TIMEOUT- Timeout in seconds for AI operations (default: 300)CLOVER_THREADS- Maximum number of threads for concurrent operations (default: 5)CLOVER_MODEL- Default AI model to use (default: gpt-4)OPENAI_API_KEY- API key for authentication
Core Tools
-
File Operations
read_file: Read content from a filecreate_file: Create a new file with specified contentupdate_file: Modify an existing file's contentdelete_file: Remove a file from the project
-
Project Summary Tools
summarize_file: Use another LLM to generate a summary of a specific fileget_project_structure: Look for structure.md or generate it using LLMaggregate_summaries: Collect summaries from all files and create a combined project summary
-
Command Line Tool
commandline: Execute system commands with user permissionsafe_execute: Handle command execution safely with error handling and permissions
Development Plan
This implementation follows the plan outlined in plan.md and includes:
- Complete CLI structure with argument parsing
- Core tool implementations for file and project operations
- Configuration management system
- Command-line tool integration with permission prompts
- Modular design for extensibility with different AI models
License
This project is created as a demonstration of implementing a AI-powered CLI tool following best practices.