|
1 | | -# Contributing Guide |
| 1 | +# Contributing to CodeClash |
2 | 2 |
|
3 | 3 | Thanks for your interest in contributing to CodeClash! |
4 | 4 |
|
5 | | -We're actively working on expanding the coverage of CodeClash in terms of models, arenas, and evaluation techniques. |
6 | | -We're also excited about your ideas! |
| 5 | +We're actively working on expanding the coverage of CodeClash in terms of models, arenas, and evaluation techniques. We'd love your help! |
| 6 | + |
| 7 | +## Ideas and Discussions |
7 | 8 |
|
8 | 9 | We have a [living document](https://docs.google.com/document/d/17-Jcexy1KDAbxXILH-GlHrFwGTpLG5yml-0OMFfgnZU/edit?usp=sharing) where we track ideas and contributions we're excited about. |
9 | 10 |
|
10 | 11 | Have suggestions? Please open an issue, and let's discuss! |
| 12 | + |
| 13 | +## Development Setup |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | + |
| 17 | +- Python 3.11+ |
| 18 | +- [uv](https://docs.astral.sh/uv/) - Fast Python package manager |
| 19 | +- Docker - For running games in containers |
| 20 | +- Git |
| 21 | + |
| 22 | +### Getting Started |
| 23 | + |
| 24 | +```bash |
| 25 | +# Clone the repository |
| 26 | +git clone https://github.com/CodeClash-ai/CodeClash.git |
| 27 | +cd CodeClash |
| 28 | + |
| 29 | +# Install uv (if you haven't already) |
| 30 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 31 | + |
| 32 | +# Install dependencies with dev extras |
| 33 | +uv sync --extra dev |
| 34 | + |
| 35 | +# Install pre-commit hooks |
| 36 | +uv run pre-commit install |
| 37 | + |
| 38 | +# Set up environment variables |
| 39 | +cp .env.example .env |
| 40 | +# Edit .env with your GITHUB_TOKEN and any LLM API keys |
| 41 | +``` |
| 42 | + |
| 43 | +### Running Tests |
| 44 | + |
| 45 | +```bash |
| 46 | +# Run all tests |
| 47 | +uv run pytest |
| 48 | + |
| 49 | +# Run with coverage |
| 50 | +uv run pytest --cov=codeclash |
| 51 | + |
| 52 | +# Run tests in parallel |
| 53 | +uv run pytest -n auto |
| 54 | + |
| 55 | +# Run a specific test file |
| 56 | +uv run pytest tests/test_integration.py |
| 57 | +``` |
| 58 | + |
| 59 | +### Code Quality |
| 60 | + |
| 61 | +We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting: |
| 62 | + |
| 63 | +```bash |
| 64 | +# Check for linting issues |
| 65 | +uv run ruff check . |
| 66 | + |
| 67 | +# Auto-fix linting issues |
| 68 | +uv run ruff check . --fix |
| 69 | + |
| 70 | +# Format code |
| 71 | +uv run ruff format . |
| 72 | + |
| 73 | +# Check formatting without changing files |
| 74 | +uv run ruff format . --check |
| 75 | +``` |
| 76 | + |
| 77 | +Pre-commit hooks will run these checks automatically before each commit. |
| 78 | + |
| 79 | +### Documentation |
| 80 | + |
| 81 | +We use [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) for documentation: |
| 82 | + |
| 83 | +```bash |
| 84 | +# Install docs dependencies |
| 85 | +uv sync --extra docs |
| 86 | + |
| 87 | +# Preview docs locally (with hot reload) |
| 88 | +uv run mkdocs serve |
| 89 | + |
| 90 | +# Build static docs |
| 91 | +uv run mkdocs build |
| 92 | +``` |
| 93 | + |
| 94 | +Documentation lives in the `docs/` directory. |
| 95 | + |
| 96 | +## Project Structure |
| 97 | + |
| 98 | +``` |
| 99 | +CodeClash/ |
| 100 | +├── codeclash/ |
| 101 | +│ ├── agents/ # AI agent implementations (MiniSWEAgent, etc.) |
| 102 | +│ ├── arenas/ # Game arena implementations |
| 103 | +│ ├── analysis/ # Post-tournament analysis tools |
| 104 | +│ ├── tournaments/ # Tournament orchestration |
| 105 | +│ ├── viewer/ # Web-based results viewer |
| 106 | +│ └── utils/ # Shared utilities |
| 107 | +├── configs/ # Tournament configuration files |
| 108 | +├── docs/ # Documentation (MkDocs) |
| 109 | +├── tests/ # Test suite |
| 110 | +└── main.py # Main entry point |
| 111 | +``` |
| 112 | + |
| 113 | +## Types of Contributions |
| 114 | + |
| 115 | +### Adding a New Arena |
| 116 | + |
| 117 | +1. Create a new file in `codeclash/arenas/` |
| 118 | +2. Extend the `CodeArena` abstract class |
| 119 | +3. Implement required methods: `execute_round()`, `validate_code()`, `get_results()` |
| 120 | +4. Add documentation in `docs/reference/arenas/` |
| 121 | +5. Add example configs in `configs/` |
| 122 | + |
| 123 | +### Adding a New Agent Type |
| 124 | + |
| 125 | +1. Create a new file in `codeclash/agents/` |
| 126 | +2. Extend the `Player` abstract class |
| 127 | +3. Implement the `run()` method for code improvement logic |
| 128 | +4. Add documentation in `docs/reference/player/` |
| 129 | + |
| 130 | +### Improving Analysis Tools |
| 131 | + |
| 132 | +Analysis tools live in `codeclash/analysis/`. We're particularly interested in: |
| 133 | + |
| 134 | +- New metrics for evaluating agent performance |
| 135 | +- Better visualization of tournament results |
| 136 | +- Statistical analysis improvements |
| 137 | + |
| 138 | +### Bug Fixes and Improvements |
| 139 | + |
| 140 | +- Bug fixes are always welcome! |
| 141 | +- Performance improvements |
| 142 | +- Documentation improvements |
| 143 | +- Test coverage improvements |
| 144 | + |
| 145 | +## Pull Request Process |
| 146 | + |
| 147 | +1. Fork the repository |
| 148 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 149 | +3. Make your changes |
| 150 | +4. Run tests and linting (`uv run pytest && uv run ruff check .`) |
| 151 | +5. Commit your changes with a descriptive message |
| 152 | +6. Push to your fork |
| 153 | +7. Open a Pull Request |
| 154 | + |
| 155 | +### PR Guidelines |
| 156 | + |
| 157 | +- Keep PRs focused on a single change |
| 158 | +- Add tests for new functionality |
| 159 | +- Update documentation as needed |
| 160 | +- Follow existing code style (enforced by ruff) |
| 161 | + |
| 162 | +## Common Development Tasks |
| 163 | + |
| 164 | +| Task | Command | |
| 165 | +|------|---------| |
| 166 | +| Install dependencies | `uv sync --extra dev` | |
| 167 | +| Run tests | `uv run pytest` | |
| 168 | +| Lint code | `uv run ruff check .` | |
| 169 | +| Format code | `uv run ruff format .` | |
| 170 | +| Preview docs | `uv run mkdocs serve` | |
| 171 | +| Build wheel | `uv build --wheel` | |
| 172 | +| Build wheel + sdist | `uv build` | |
| 173 | +| Run a tournament | `uv run python main.py <config>` | |
| 174 | +| View results | `uv run python scripts/run_viewer.py` | |
| 175 | + |
| 176 | +### Building Distributions |
| 177 | + |
| 178 | +To build a distributable wheel package: |
| 179 | + |
| 180 | +```bash |
| 181 | +# Build wheel only |
| 182 | +uv build --wheel |
| 183 | + |
| 184 | +# Build both wheel and source distribution |
| 185 | +uv build |
| 186 | + |
| 187 | +# Build with clean output directory |
| 188 | +uv build --wheel --clear |
| 189 | +``` |
| 190 | + |
| 191 | +Built artifacts will be placed in the `dist/` directory by default. |
| 192 | + |
| 193 | +## Contact |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | +Feel free to reach out with questions or ideas! |
0 commit comments