Clover/plan.md
Jarian Cottingham 7e8d31af6e Clover created
2026-01-13 00:07:41 -06:00

5.7 KiB

Clover CLI Implementation Plan

Overview

This document outlines the implementation plan for the Clover CLI tool, a terminal-based assistant that works with various AI models to help build and manage projects. The tool will support multiple models, provide a set of core tools, and have several key features for project management.

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
├── .agent                  # Agent summary file (to be maintained)
├── .structure              # Project structure diagram (to be maintained)
├── summary.md              # Summary of actions taken so far (to be maintained)
└── requirements.txt        # Dependencies

Core Tools Implementation

1. File Operations Tools

  • read_file: Read content from a file and return its contents
  • create_file: Create a new file with specified content
  • update_file: Modify an existing file's content at specific lines or patterns
  • 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

Key Features Implementation

1. /list - List Available Models

  • Query the OpenAI-compatible server for available models
  • Display model information in a readable format

2. /init - Initialize Project Summary

  • Create a "clover.md" file in project root
  • Generate initial project summary using LLM
  • Update this file as the project progresses

3. /timeout - Set Timeout Duration

  • Configure maximum time allowed for agent to work on a problem
  • Store timeout value in configuration

4. /threads - Set Thread Limit

  • Configure maximum threads used for concurrent LLM operations
  • Manage thread pool for sub-processes like file summaries and command line calls

Implementation Details

Model Integration

  1. Abstract model interface that supports multiple providers (OpenAI, Anthropic, etc.)
  2. Model manager to handle switching between different models
  3. API client that handles authentication and requests

Configuration Management

  • Environment variables for configuration
  • Settings file for persistent configuration storage
  • Default fallback values for all settings

Thread Management

  • Semaphore-based system for controlling concurrent LLM operations
  • Thread pool implementation for managing sub-processes
  • Safety limits to prevent resource exhaustion

Security Considerations

  • Permission prompts for command line execution
  • Input validation for all user inputs
  • Safe file paths to prevent directory traversal attacks

Dependencies to Install in Virtual Environment

  • openai (for OpenAI API integration)
  • requests (for HTTP requests)
  • python-dotenv (for environment variable management)
  • tqdm (for progress bars)

Development Approach

  1. Start with basic CLI structure and command parsing
  2. Implement core tools step by step
  3. Add model integration capabilities
  4. Implement configuration management
  5. Add threading and timeout features
  6. Implement permission prompts for command execution
  7. Test all components thoroughly
  8. Document functionality and usage

Testing Strategy

  • Unit tests for individual tools and functions
  • Integration tests for end-to-end CLI operations
  • Security tests for file system access and command execution
  • Configuration management tests

Version Control Considerations

  • Maintain .agent, .structure, and summary.md files during development
  • Follow Git workflow for tracking changes
  • Keep requirements.txt updated with dependencies

## Virtual Environment Setup Plan

1. Create a new virtual environment in the project directory:
   ```bash
   python -m venv clover_env
  1. Activate the virtual environment:

    source clover_env/bin/activate  # On macOS/Linux
    # or
    clover_env\Scripts\activate     # On Windows
    
  2. Install required packages:

    pip install openai requests python-dotenv tqdm
    
  3. Initialize the project structure

Command Line Interface Design

The CLI should support commands like:

  • clover /list - List available models
  • clover /init - Initialize project
  • clover /timeout 300 - Set timeout to 300 seconds
  • clover /threads 5 - Set thread limit to 5
  • Direct prompts for AI assistance

Each command will be implemented in the commands.py file with proper error handling and validation.