Thank you for your interest in contributing to Semantic Compressor! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Code Style
- Pull Request Process
- Reporting Bugs
- Suggesting Features
- Questions
This project follows a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
In short:
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Prioritize project goals over personal preferences
Looking to contribute? Great! Here are some good starting points:
- 🐛 Good First Issues
- 📝 Documentation improvements
- ✅ Adding tests for uncovered code
- 🧪 Testing on different platforms/Python versions
- Language: Python 3.7+
- Core Concept: Semantic code compression using LJPW framework
- Key Files:
src/ljpw/ljpw_standalone.py- Main analyzertests/- Test suitedocs/- Documentation
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/Semantic-Compressor.git
cd Semantic-Compressor# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate # On Linux/Mac
# or
venv\Scripts\activate # On Windows# Install package with dev dependencies
pip install -e ".[dev]"
# This installs:
# - The package in editable mode
# - pytest, pytest-cov (testing)
# - black, isort (formatting)
# - flake8 (linting)
# - mypy (type checking)# Run tests to ensure everything works
pytest
# Try the CLI
ljpw help# Always create a new branch for your changes
git checkout -b feature/amazing-feature
# Use prefixes:
# - feature/ for new features
# - fix/ for bug fixes
# - docs/ for documentation
# - test/ for test improvements
# - refactor/ for code refactoringFollow these guidelines:
- Keep changes focused (one feature/fix per PR)
- Add tests for new functionality
- Update documentation if needed
- Follow the existing code style
- Add docstrings to new functions/classes
# Good commit message format:
# <type>: <subject>
#
# <body>
# Example:
git commit -m "feat: add progress indicators for directory analysis
Added progress bar showing current file and percentage complete
when analyzing directories with multiple files."
# Types: feat, fix, docs, test, refactor, style, chore# Run all tests
pytest
# Run specific test file
pytest tests/test_ljpw_framework.py
# Run with coverage
pytest --cov=src/ljpw --cov-report=html
# View coverage report
open htmlcov/index.html # On Mac
# or
xdg-open htmlcov/index.html # On LinuxAdd tests for any new functionality:
# tests/test_new_feature.py
import pytest
from src.ljpw.ljpw_standalone import analyze_quick
def test_new_feature():
"""Test description"""
code = "def example(): pass"
result = analyze_quick(code)
assert 'ljpw' in result
assert result['health'] >= 0Test Guidelines:
- ✅ Test edge cases (empty input, invalid input, etc.)
- ✅ Test error conditions
- ✅ Use descriptive test names
- ✅ Keep tests independent (no shared state)
- ✅ Mock external dependencies
We follow PEP 8 with some modifications:
# Format code with black
black src/ tests/ tools/
# Sort imports with isort
isort src/ tests/ tools/
# Check linting with flake8
flake8 src/ tests/ tools/- Line Length: 100 characters (not 80)
- Quotes: Use double quotes
"for strings - Imports: Group by standard lib, third-party, local
- Type Hints: Add type hints for function parameters and returns
- Docstrings: Use Google-style docstrings
Example:
from typing import Dict, List, Optional
import math
import re
def analyze_code(code: str, filename: str = "code") -> Dict[str, Any]:
"""
Analyze code and return LJPW metrics.
Args:
code: Source code string to analyze
filename: Optional filename for context
Returns:
Dictionary containing LJPW scores and health metrics
Raises:
ValueError: If code is None or invalid
Example:
>>> result = analyze_code("def hello(): pass")
>>> print(result['health'])
0.42
"""
# Implementation
passOptionally set up pre-commit hooks:
# Install pre-commit
pip install pre-commit
# Set up hooks
pre-commit install
# Now black, isort, and flake8 run automatically on commit- ✅ All tests pass:
pytest - ✅ Code is formatted:
black src/ tests/ - ✅ Imports are sorted:
isort src/ tests/ - ✅ Linting passes:
flake8 src/ tests/ - ✅ New code has tests
- ✅ Documentation is updated
-
Push your branch:
git push origin feature/amazing-feature
-
Create Pull Request on GitHub
- Use a clear, descriptive title
- Reference any related issues (#123)
- Describe what changes you made and why
- Add screenshots if relevant
-
PR Template:
## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Documentation update - [ ] Code refactoring ## Testing Describe how you tested these changes ## Checklist - [ ] Tests pass - [ ] Code formatted with black - [ ] Documentation updated - [ ] Commits follow convention
- Maintainers will review your PR within 48 hours
- Address any requested changes
- Once approved, maintainers will merge
- Check if bug already reported in Issues
- Try to reproduce with latest version
- Collect information about your environment
**Bug Description**
Clear description of what went wrong
**To Reproduce**
Steps to reproduce:
1. Run command: `ljpw analyze file.py`
2. With this input: ...
3. See error: ...
**Expected Behavior**
What you expected to happen
**Actual Behavior**
What actually happened (include error messages)
**Environment**
- OS: [e.g., Ubuntu 22.04, Windows 11]
- Python version: [e.g., 3.11.2]
- Semantic Compressor version: [e.g., 2.0.0]
**Additional Context**
Any other relevant informationWe love feature ideas! Here's how to suggest one:
**Feature Description**
Clear description of the feature
**Use Case**
Why is this feature needed? What problem does it solve?
**Proposed Solution**
How would you like this to work?
**Example Usage**
```python
# Show example of how feature would be used
result = new_feature(input)Alternatives Considered Other ways this could be implemented
Additional Context Mockups, related projects, etc.
### Feature Discussion
- Features are discussed in Issues before implementation
- We consider: usefulness, complexity, maintenance burden
- See [ROADMAP.md](ROADMAP.md) for planned features
---
## Questions
### Where to Ask
- 💬 **Discussions:** General questions, ideas, brainstorming
- 🐛 **Issues:** Bug reports, feature requests
- 📖 **Docs:** Check documentation first
### Getting Help
- Read [Quick Reference](docs/QUICK_REFERENCE.md)
- Check [examples/](examples/) directory
- Review [test files](tests/) for usage examples
---
## Recognition
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Given credit in commits
---
## Development Tips
### Running Specific Examples
```bash
# Run examples to see how features work
python examples/basic/01_analyze_single_file.py
python examples/advanced/demo_iso_analysis.py
# Add debug logging
import logging
logging.basicConfig(level=logging.DEBUG)
# Use pdb for interactive debugging
import pdb; pdb.set_trace()# Profile code
python -m cProfile -o output.prof your_script.py
# View results
python -m pstats output.profBy contributing, you agree that your contributions will be licensed under the MIT License.
Your contributions make Semantic Compressor better for everyone. Whether it's code, documentation, bug reports, or feature ideas - every contribution matters!
Questions? Open an issue or discussion, we're happy to help!
Last updated: November 29, 2025