105 lines
4.0 KiB
Markdown
105 lines
4.0 KiB
Markdown
# 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
|
|
|
|
1. Create a virtual environment:
|
|
```bash
|
|
python -m venv clover_env
|
|
```
|
|
|
|
2. Activate the virtual environment:
|
|
```bash
|
|
source clover_env/bin/activate # On macOS/Linux
|
|
# or
|
|
clover_env\Scripts\activate # On Windows
|
|
```
|
|
|
|
3. Install dependencies:
|
|
```bash
|
|
pip install openai requests python-dotenv tqdm
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Basic Commands
|
|
|
|
- `clover /list` - List available models on the server
|
|
- `clover /init` - Initialize project summary file (clover.md)
|
|
- `clover /timeout 300` - Set timeout to 300 seconds for AI operations
|
|
- `clover /threads 5` - Set thread limit to 5 for concurrent operations
|
|
- `clover "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
|
|
|
|
1. **File Operations**
|
|
- `read_file`: Read content from a file
|
|
- `create_file`: Create a new file with specified content
|
|
- `update_file`: Modify an existing file's content
|
|
- `delete_file`: Remove a file from the project
|
|
|
|
2. **Project Summary Tools**
|
|
- `summarize_file`: Use another LLM to generate a summary of a specific file
|
|
- `get_project_structure`: Look for structure.md or generate it using LLM
|
|
- `aggregate_summaries`: Collect summaries from all files and create a combined project summary
|
|
|
|
3. **Command Line Tool**
|
|
- `commandline`: Execute system commands with user permission
|
|
- `safe_execute`: Handle command execution safely with error handling and permissions
|
|
|
|
## Development Plan
|
|
|
|
This implementation follows the plan outlined in [plan.md](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. |