Thank you for your interest in contributing to Compiler Copilot! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Making Changes
- Testing
- Submitting Changes
- Coding Standards
- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
- Maintain a professional environment
-
Fork the repository
-
Clone your fork:
git clone https://github.com/your-username/CompilerCopilot.git cd CompilerCopilot -
Set up development environment:
./setup.sh source venv/bin/activate -
Create a branch:
git checkout -b feature/your-feature-name
- Python 3.9 or higher
- GDB or LLDB installed
- Clang/LLVM toolchain
- Git
-
Copy the example configuration:
cp config/env.example config/.env
-
Edit
config/.envwith your settings:- Set debugger paths
- Configure compiler toolchain paths
- Add LLM API credentials (for testing)
pip install -r requirements.txt
pip install -r requirements-dev.txt # Development dependenciesCompilerCopilot/
├── src/
│ ├── mcp/ # MCP server implementation
│ ├── debugger/ # Debugger wrappers
│ ├── compiler/ # Compiler analysis tools
│ ├── llm/ # LLM integration
│ └── shell/ # Interactive shell
├── config/ # Configuration files
├── examples/ # Example code and workflows
├── tests/ # Test suite
└── docs/ # Additional documentation
- Create an issue describing the feature
- Discuss the approach with maintainers
- Implement the feature following coding standards
- Add tests for the new functionality
- Update documentation as needed
- Create an issue describing the bug
- Write a test that reproduces the bug
- Fix the bug
- Verify the test passes
- Submit a pull request
To add support for a new debugger (e.g., DBX):
-
Create
src/debugger/dbx_wrapper.py:from ..config import Config class DBXWrapper: def __init__(self, config: Config): self.config = config async def start(self, program: str, args=None): # Implementation pass async def execute(self, command: str): # Implementation pass
-
Update
src/mcp/server.pyto include the new debugger -
Add configuration options in
src/config.py -
Write tests in
tests/test_dbx_wrapper.py -
Update documentation
To add a new LLM provider:
-
Update
src/llm/client.py:def _init_new_provider(self): """Initialize new provider client.""" # Implementation async def _generate_new_provider(self, prompt: str) -> str: """Generate using new provider.""" # Implementation
-
Add provider configuration in
src/config.py -
Update requirements.txt with provider SDK
-
Add tests
-
Update documentation
# Run all tests
pytest
# Run specific test file
pytest tests/test_debugger.py
# Run with coverage
pytest --cov=src tests/
# Run specific test
pytest tests/test_debugger.py::test_gdb_startExample test structure:
import pytest
from src.debugger.gdb_wrapper import GDBWrapper
from src.config import get_config
@pytest.fixture
def config():
return get_config()
@pytest.fixture
def gdb_wrapper(config):
return GDBWrapper(config)
@pytest.mark.asyncio
async def test_gdb_start(gdb_wrapper):
result = await gdb_wrapper.start("test_program")
assert "GDB started" in result- Aim for >80% code coverage
- Test edge cases and error conditions
- Mock external dependencies (debuggers, LLMs)
- Test async operations properly
-
Update your branch:
git fetch upstream git rebase upstream/main
-
Run tests:
pytest
-
Commit your changes:
git add . git commit -m "feat: add support for DBX debugger"
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a pull request on GitHub
Follow conventional commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(debugger): add DBX debugger support
Implement DBX wrapper with basic debugging commands.
Includes start, execute, and analyze_crash methods.
Closes #123
fix(llm): handle timeout errors gracefully
Add proper error handling for LLM API timeouts.
Return user-friendly error messages instead of crashing.
Fixes #456
- Title: Clear and descriptive
- Description: Explain what and why
- Link issues: Reference related issues
- Tests: Include test results
- Documentation: Update if needed
- Screenshots: For UI changes
Follow PEP 8 with these specifics:
- Line length: 100 characters
- Indentation: 4 spaces
- Quotes: Double quotes for strings
- Imports: Grouped and sorted
# Standard library import os import sys # Third-party import pexpect from rich.console import Console # Local from ..config import Config
Use type hints for all functions:
from typing import Optional, List, Dict
async def execute(self, command: str) -> str:
"""Execute a command and return output."""
pass
def process_data(items: List[int]) -> Dict[str, int]:
"""Process items and return statistics."""
passUse Google-style docstrings:
def calculate_sum(numbers: List[int]) -> int:
"""Calculate the sum of a list of numbers.
Args:
numbers: List of integers to sum.
Returns:
The sum of all numbers.
Raises:
ValueError: If the list is empty.
Example:
>>> calculate_sum([1, 2, 3])
6
"""
if not numbers:
raise ValueError("List cannot be empty")
return sum(numbers)- Explain why, not what
- Keep comments up-to-date
- Use TODO comments for future work:
# TODO(username): Add support for remote debugging
# Good
try:
result = await debugger.execute(command)
except TimeoutError:
logger.error(f"Command timed out: {command}")
return "Command execution timed out"
except Exception as e:
logger.exception(f"Unexpected error: {e}")
raise
# Bad
try:
result = await debugger.execute(command)
except:
pass- Use
async/awaitfor I/O operations - Don't block the event loop
- Use
asyncio.create_task()for concurrent operations
# Good
async def process_multiple_files(files: List[str]):
tasks = [process_file(f) for f in files]
results = await asyncio.gather(*tasks)
return results
# Bad
async def process_multiple_files(files: List[str]):
results = []
for f in files:
result = await process_file(f) # Sequential, not concurrent
results.append(result)
return results- Automated checks must pass (tests, linting)
- Code review by at least one maintainer
- Address feedback and update PR
- Approval from maintainer
- Merge by maintainer
- Issues: Open an issue for bugs or features
- Discussions: Use GitHub Discussions for questions
- Documentation: Check ARCHITECTURE.md and README.md
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Credited in documentation
Thank you for contributing to Compiler Copilot! 🎉