First off, thank you for considering contributing to Entity! It's people like you that make Entity such a great tool.
By participating in this project, you are expected to uphold our principles of respectful and constructive collaboration.
Before creating bug reports, please check existing issues as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible:
- Use a clear and descriptive title
- Describe the exact steps which reproduce the problem
- Provide specific examples to demonstrate the steps
- Describe the behavior you observed after following the steps
- Explain which behavior you expected to see instead and why
- Include logs and error messages if applicable
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include:
- Use a clear and descriptive title
- Provide a step-by-step description of the suggested enhancement
- Provide specific examples to demonstrate the steps
- Describe the current behavior and explain which behavior you expected to see instead
- Explain why this enhancement would be useful
- Fork the repo and create your branch from
main - If you've added code that should be tested, add tests
- If you've changed APIs, update the documentation
- Ensure the test suite passes
- Make sure your code follows the style guidelines
- Issue that pull request!
- Python 3.11 or higher
- Poetry for dependency management
- Docker (optional, for integration tests)
- GitHub CLI (
gh) for plugin development
- Clone your fork with submodules:
# Replace YOUR_USERNAME with your GitHub username
git clone --recurse-submodules https://github.com/YOUR_USERNAME/entity.git
cd entity
# Or if you already cloned without submodules
git submodule init
git submodule update- Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -- Install dependencies:
poetry install --with dev- Activate the virtual environment:
poetry shellRun the full test suite:
poetry run poe testRun tests with coverage:
poetry run poe test-coverageRun specific test categories:
poetry run poe test-architecture # Architecture tests
poetry run poe test-plugins # Plugin tests
poetry run poe test-resources # Resource testsRun integration tests with Docker:
poetry run poe test-with-dockerWe use Black for code formatting and follow PEP 8 guidelines. Before submitting:
- Format your code:
poetry run black src tests- Run linting:
poetry run flake8 src tests- Run the full quality check:
poetry run poe checkWe use Google-style docstrings. Every public class and function should have:
- A brief description
- Args section documenting parameters
- Returns section documenting return values
- Raises section documenting exceptions
- Examples section when appropriate
Example:
def process_message(message: str, user_id: str = "default") -> str:
"""Process a message through the agent workflow.
Args:
message: The input message to process.
user_id: Unique identifier for the user. Defaults to "default".
Returns:
The processed response from the agent.
Raises:
ValueError: If message is empty.
Examples:
>>> response = process_message("Hello!")
>>> print(response)
"Hi there!"
"""Build documentation locally:
poetry run sphinx-build -b html docs/source docs/build- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
Please follow the 4-layer architecture:
- Layer 1: Infrastructure - Concrete technology implementations
- Layer 2: Resources - Technology-agnostic resource interfaces
- Layer 3: Canonical Resources - Core building blocks (Memory, LLM, FileStorage, Logging)
- Layer 4: Agent - Composition of resources with workflow
If you want to contribute to an existing plugin (examples, gpt-oss, stdlib, template):
- Fork the plugin repository using GitHub CLI:
# Fork a plugin repository
gh repo fork Ladvien/entity-plugin-examples --clone
# Or fork and create a PR branch
gh repo fork Ladvien/entity-plugin-gpt-oss --clone
cd entity-plugin-gpt-oss
git checkout -b feature/my-improvement- Make your changes and test locally:
# In the plugin directory
poetry install --with dev
poetry run pytest
# Test with the main entity framework
cd ../entity
git submodule update --remote plugins/examples # Update to your fork
poetry run pytest tests/plugins/- Submit a pull request:
# From your plugin directory
gh pr create --title "Add new feature" --body "Description of changes"When creating new plugins:
- Inherit from the appropriate base class (
PromptPlugin,ToolPlugin, etc.) - Declare supported stages in
supported_stages - Implement
validate_config()andvalidate_workflow()methods - Implement
_execute_impl()for the plugin logic - Add comprehensive tests
Example:
class MyPlugin(PromptPlugin):
supported_stages = [THINK, REVIEW]
dependencies = ["llm", "memory"]
def validate_config(self) -> ValidationResult:
# Validate configuration
return ValidationResult.success()
async def _execute_impl(self, context: PluginContext) -> None:
# Plugin implementation
result = await self.call_llm(context, "Process this...")
await context.remember("result", result.content)Each plugin should follow this structure:
entity-plugin-yourname/
├── src/
│ └── entity_plugin_yourname/
│ ├── __init__.py
│ └── your_plugin.py
├── tests/
│ └── test_your_plugin.py
├── pyproject.toml
├── README.md
└── LICENSE
- Write tests for all new functionality
- Maintain at least 80% code coverage
- Use pytest fixtures for reusable test data
- Mock external dependencies appropriately
- Include both unit and integration tests
- Update version in
pyproject.toml - Update CHANGELOG.md
- Create a pull request with the version bump
- After merge, create a GitHub release
- The CI/CD pipeline will automatically publish to PyPI
When working with plugin repositories, especially private ones, you'll need to use Personal Access Tokens:
-
Create a fine-grained PAT on GitHub:
- Go to Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Click "Generate new token"
- Select only the repositories you need
- Grant minimal permissions:
- Contents: Read (for cloning)
- Contents: Write (for pushing changes)
- Pull requests: Write (for creating PRs)
- Set a reasonable expiration date
-
Use the PAT securely:
# Authenticate GitHub CLI with your PAT
gh auth login
# Or configure git to use the PAT
git config --global credential.helper store- Security best practices:
- Never commit PATs to any repository
- Store PATs in a secure password manager
- Use environment variables in CI/CD:
export GITHUB_TOKEN=your_pat - Rotate tokens regularly (every 90 days recommended)
- Use repository-specific tokens when possible
- Revoke tokens immediately if compromised
- Never include API keys, passwords, or secrets in code
- Use
.envfiles for local development (and add to.gitignore) - Review your changes for accidental credential exposure before committing
- Use
git-secretsor similar tools to prevent secret commits
Feel free to open an issue for any questions about contributing!