Skip to content

Contributing to LEGIONHERCULES

Thank you for your interest in contributing to LEGIONHERCULES!

Development Setup

1. Fork and Clone

git clone https://github.com/YOUR_USERNAME/legionhercules.git
cd legionhercules

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -e ".[dev]"

4. Install Pre-commit Hooks

pre-commit install

Development Workflow

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=legionhercules

# Run specific test
pytest tests/test_agent.py

Code Style

We use Black and Ruff for code formatting:

# Format code
black src/ tests/

# Lint code
ruff check src/ tests/

# Fix auto-fixable issues
ruff check --fix src/ tests/

Type Checking

mypy src/legionhercules

Project Structure

legionhercules/
├── src/legionhercules/    # Main source code
│   ├── core/              # Core agent and task management
│   ├── tools/             # Tool implementations
│   ├── llm/               # LLM providers
│   ├── cli/               # Command-line interface
│   ├── config/            # Configuration management
│   └── utils/             # Utilities
├── tests/                 # Test files
├── docs/                  # Documentation
└── pyproject.toml         # Project configuration

Adding New Features

Adding a New Tool

  1. Create tool class in src/legionhercules/tools/
  2. Inherit from Tool base class
  3. Implement execute() and get_schema() methods
  4. Register in ToolRegistry.create_default_registry()
  5. Add tests in tests/tools/

Example:

from legionhercules.tools.base import Tool, ToolResult

class MyTool(Tool):
    def __init__(self):
        super().__init__(name="my_tool", description="...")

    async def execute(self, **kwargs) -> ToolResult:
        # Implementation
        pass

    def get_schema(self) -> dict:
        return {...}

Adding a New LLM Provider

  1. Create provider in src/legionhercules/llm/
  2. Inherit from LLMProvider base class
  3. Implement required methods
  4. Add configuration options

Adding CLI Commands

  1. Add command function in src/legionhercules/cli/main.py
  2. Use Typer decorators
  3. Add help text and examples

Submitting Changes

1. Create a Branch

git checkout -b feature/my-feature

2. Make Changes

  • Write clear, documented code
  • Add tests for new functionality
  • Update documentation

3. Commit

git add .
git commit -m "feat: add new feature"

Follow conventional commits: - feat: New feature - fix: Bug fix - docs: Documentation - test: Tests - refactor: Code refactoring

4. Push and Create PR

git push origin feature/my-feature

Create a pull request with: - Clear description - Link to related issues - Test results

Code Review

All submissions require review. We check for:

  • Code quality and style
  • Test coverage
  • Documentation
  • Performance impact

Questions?

  • Open an issue for bugs
  • Start a discussion for features
  • Join our community chat

License

By contributing, you agree that your contributions will be licensed under the MIT License.