Contributing to Locust
Thank you for your interest in contributing to Locust! This document provides guidelines and instructions for contributing.
Table of Contents
- Code of Conduct
- Getting Started
- Development Workflow
- Pull Request Process
- Coding Standards
- Testing Guidelines
- Documentation
Code of Conduct
This project follows the raibid-labs code of conduct. Be respectful, collaborative, and constructive in all interactions.
Getting Started
Prerequisites
- Rust 1.70 or later
- Cargo
- Git
Setup
# Clone the repository
git clone https://github.com/raibid-labs/locust.git
cd locust
# Build the project
cargo build
# Run tests
cargo test
# Run the example
cargo run --example basic_navDevelopment Workflow
Using SPARC Methodology
This project uses SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) for structured development:
# Install Claude Flow (optional but recommended)
npm install -g claude-flow@alpha
# Run SPARC workflow for new features
npx claude-flow sparc tdd "Add tooltip plugin"Branch Strategy
main- Stable, production-ready codefeat/*- New featuresfix/*- Bug fixesdocs/*- Documentation improvementsrefactor/*- Code refactoring
Commit Messages
Follow conventional commits format:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types: feat, fix, docs, style, refactor, test, chore
Examples:
feat(nav): add hint generation for List widgetsfix(plugin): resolve event consumption race conditiondocs(readme): update plugin registration example
Pull Request Process
- Fork and Branch: Fork the repository and create a feature branch
- Develop: Make your changes following our coding standards
- Test: Ensure all tests pass and add new tests for your changes
- Document: Update documentation for any API changes
- Commit: Use conventional commit messages
- Pull Request: Open a PR with a clear description
PR Template
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Example programs work
- [ ] Documentation builds
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No new warningsCoding Standards
Rust Style
- Follow Rust API Guidelines
- Use
cargo fmtfor formatting (enforced in CI) - Use
cargo clippyfor linting (enforced in CI) - Maximum line length: 100 characters
- Prefer explicit over implicit
- Document all public APIs with rustdoc
Code Organization
src/
├── core/ # Core framework types
├── plugins/ # Built-in plugins
└── ratatui_ext/ # Ratatui extensions
Naming Conventions
- Types:
PascalCase(e.g.,LocustPlugin,NavTarget) - Functions:
snake_case(e.g.,on_event,render_overlay) - Constants:
SCREAMING_SNAKE_CASE(e.g.,MAX_TARGETS) - Modules:
snake_case(e.g.,nav,context)
Testing Guidelines
Test Organization
tests/
├── unit/ # Unit tests
├── integration/ # Integration tests
└── fixtures/ # Test fixtures and mocks
Writing Tests
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_plugin_consumes_event() {
let mut plugin = NavPlugin::new();
let event = Event::Key(/* ... */);
let result = plugin.on_event(&event, &mut ctx);
assert!(result.consumed);
}
}Test Coverage
- Aim for >80% code coverage
- All public APIs must have tests
- Integration tests for plugin interactions
- Example programs serve as acceptance tests
Documentation
Rustdoc
All public items must have documentation:
/// Represents a navigation target in the overlay.
///
/// # Examples
///
/// ```
/// use locust::core::targets::NavTarget;
///
/// let target = NavTarget::new("a", Rect::default());
/// ```
pub struct NavTarget {
// ...
}Architecture Documentation
Update relevant documentation in docs/:
ARCHITECTURE.md- System design changesPLUGINS.md- New plugin patterns or APIsROADMAP.md- Milestone progress
Examples
Provide working examples for new features:
// examples/my_feature.rs
fn main() -> Result<()> {
// Demonstrate the feature
}Plugin Development
Creating a New Plugin
- Create plugin module in
src/plugins/your_plugin/ - Implement
LocustPlugin<B>trait - Add tests in
tests/plugins/ - Document in
docs/PLUGINS.md - Add example in
examples/
Plugin Guidelines
- Plugins should be self-contained
- Use
LocustContextfor shared state - Event consumption should be intentional
- Overlays should be composable
- Provide configuration options
Release Process
Releases are managed by maintainers:
- Version bump in
Cargo.toml - Update
CHANGELOG.md - Tag release:
git tag v0.x.0 - CI automatically publishes to crates.io
Getting Help
- Issues: Open a GitHub issue for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Discord: Join our Discord server (link in README)
License
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Locust!