Development & Contribution
This guide covers how to contribute to Protolink, from setting up your development environment to submitting pull requests.
Getting Started
Prerequisites
- Python 3.10+ - Required for all development
- Git - For version control
- uv - Recommended package manager (or
pip)
Clone and Setup
# Clone the repository
git clone https://github.com/nMaroulis/protolink.git
cd protolink
# Install in development mode
uv pip install -e ".[dev]"
cd docs
npm install
cd ..
# Or with pip
pip install -e ".[dev]"
cd docs
npm install
cd ..
This installs Protolink in editable mode with all development dependencies.
Development Workflow
1. Fork and Clone
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/<your-username>/protolink.git
cd protolink
# Add upstream for syncing
git remote add upstream https://github.com/nMaroulis/protolink.git
2. Create a Feature Branch
git checkout -b feature/your-feature-name
3. Make Changes
- Write your code
- Add tests for new functionality
- Update documentation if needed
4. Quality Checks
# Format code
ruff format .
# Lint and auto-fix
ruff check . --fix
# Type checking
ty check .
# Run tests
python -m pytest -v tests
# Benchmark prompt or infer-loop changes
python -m benchmarks.infer_loop --provider ollama --model <model> --suite smoke
# Validate docs
cd docs
npm run build
cd ..
5. Commit and Push
git add .
git commit -m "feat: add your feature description"
git push origin feature/your-feature-name
6. Open Pull Request
- Open a PR from your fork to
main - Describe your changes clearly
- Include any breaking changes
Code Quality
Formatting and Linting
Protolink uses Ruff for code formatting and linting.
The project uses the default Ruff configuration with some custom rules. See ruff.toml for details.
# Format all code
ruff format .
# Lint and auto-fix issues
ruff check . --fix
# Check without auto-fixing
ruff check .
Type Checking
Protolink uses ty for static type checking.
# Run type checks
ty check .
# Check one package area
ty check protolink/agents
- All new code should be fully typed
- Use
str | Noneinstead ofOptional[str](PEP 604) - Add type hints for all public APIs
Testing
Run the test suite with pytest:
# Run all tests
python -m pytest -v tests
# Run specific test file
python -m pytest -v tests/test_agent.py
# Run with coverage
python -m pytest --cov=protolink tests
- Unit tests:
tests/test_*.py - Integration tests:
tests/integration/ - Fixtures and utilities in
tests/conftest.py
Development Tools
Pre-commit Hooks
The project includes pre-commit hooks for code quality:
# Install pre-commit hooks
pre-commit install
# Run hooks manually
pre-commit run --all-files
Documentation
Preview documentation locally:
cd docs
# Serve docs
npm run start
# Validate docs
npm run build
# Open http://localhost:3000/protolink/
Deploy documentation (maintainers only):
cd docs
npm run build
Pull requests run npm run build from docs/. Pushes to main that touch docs, the README, Docusaurus configuration, or docs dependencies upload docs/build as a GitHub Pages artifact and deploy it through the github-pages environment.
Project Structure
protolink/
├── protolink/ # Main package
│ ├── agents/ # Agent implementations
│ ├── client/ # Client code
│ ├── core/ # Core models
│ ├── discovery/ # Registry and discovery
│ ├── llms/ # LLM integrations, infer loop, parsing, and metrics
│ ├── models/ # Exposes core models for importation
│ ├── server/ # Server implementations
│ ├── transport/ # Transport layers
│ ├── tools/ # Tools and adapters (e.g. MCP)
│ ├── types/ # Type aliases
│ └── utils/ # Utilities
├── tests/ # Test suite
├── benchmarks/ # Repository-only regression and performance benchmarks
├── docs/ # Documentation
├── examples/ # Example scripts
└── README.md # Project overview
Infer-loop Benchmark
Prompt, parsing, action-selection, retry, and delegation changes should be checked with the repository-local infer-loop benchmark. It reports strict and functional correctness, failures and traces, task and model-call latency, Ollama prompt/load/generation timing, and cache-sensitive repeat comparisons.
Run it from the repository root:
python -m benchmarks.infer_loop \
--provider ollama \
--model <model> \
--suite core \
--repetitions 2
Keep the provider, exact model and parameters, suite, seed, warm-up, attempts, repetitions, hardware, and host load controlled in before-and-after runs. See the Infer-loop Benchmark guide for scoring, timing, baseline comparison, and artifacts.
Contribution Guidelines
Code Style
- Follow PEP 8 and PEP 604
- Use descriptive variable and function names
- Add docstrings for all public functions and classes
- Keep functions focused and single-purpose
Commit Messages
Use conventional commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changesstyle:- Code style changesrefactor:- Code refactoringtest:- Test changeschore:- Maintenance tasks
Pull Request Process
- Update Documentation - If your change affects user-facing APIs
- Add Tests - Ensure new functionality is covered
- Pass CI - All checks must pass
- Review - Address feedback from maintainers
If your change includes breaking changes:
- Clearly document them in the PR
- Update every version source listed in the Release Process
- Add migration notes to documentation
Debugging and Troubleshooting
Common Issues
Type Checking Errors
# Check specific file for detailed errors
ty check protolink/your/file.py --verbose
Test Failures
# Run tests with detailed output
pytest -v -s tests/test_failing.py
# Run specific test with debugging
pytest -v -s tests/test_failing.py::test_function
Import Issues
# Install in development mode
python -m pip install -e .
# Check Python path
python -c "import protolink; print(protolink.__file__)"
Development Tips
- Use
uvfor faster dependency management - Enable debug logging:
export PROTOLINK_LOG_LEVEL=debug - Use breakpoints:
import pdb; pdb.set_trace() - For watch-mode testing, install a watcher such as
pytest-watchlocally and run it outside the core dependency set.
Release Process
Maintainers can follow this process for releases:
- Update Python version sources in
pyproject.tomlandprotolink/__version__.py, then regenerateuv.lock. - Update documentation versions in
docs/package.json, regeneratedocs/package-lock.json, and update the current-release labels in the documentation. - Finalize the changelog in
docs/content/changelog.md: replaceUnreleasedwith the publication date and move the latest-release note to the new version. - Run release gates: formatting, linting, type checking, the full test suite, the Docusaurus production build,
python -m build, andpython -m twine check dist/*. - Tag Release:
git tag vX.Y.Z - Push Tags:
git push origin --tags - Upload to PyPI:
python -m twine upload dist/*
Community
Getting Help
- GitHub Issues - Bug reports and feature requests
- Discussions - General questions and ideas
- Documentation - API reference and guides
Code of Conduct
Please be respectful and constructive in all interactions. By participating in this project, you agree to follow our community guidelines.
Thank you for contributing to Protolink.