Skip to content

Latest commit

 

History

History
124 lines (88 loc) · 2.8 KB

File metadata and controls

124 lines (88 loc) · 2.8 KB

Contributing to context-kit

Thank you for your interest in contributing to context-kit!

Development Setup

Prerequisites

  • Python 3.9+
  • uv (recommended)

Getting Started

git clone https://github.com/keli-wen/context-kit.git
cd context-kit

# Install all dependencies (including dev)
uv sync --all-extras

# Or with pip
pip install -e ".[all]"

Development Workflow

Running Tests

We use unittest (not pytest) for testing:

# Run all tests
uv run python -m pytest tests/

# Run specific test file
uv run python -m pytest tests/test_context.py

# Run with verbose output
uv run python -m pytest tests/ -v

Code Style

We use ruff for linting and formatting, and mypy for type checking:

# Lint
uv run ruff check .

# Auto-fix lint issues
uv run ruff check --fix .

# Format
uv run ruff format .

# Type check
uv run mypy context_kit/

Code Quality Requirements

  • Type hints: All functions must have complete type annotations
  • Docstrings: All public functions and classes must have docstrings
  • Tests: New features should include tests
  • Error handling:
    • Core functions (context_kit/*.py) should raise exceptions
    • Tool/wrapper functions should catch exceptions and return error strings

Project Structure

context_kit/
├── context.py    # Core Context dataclass
├── message.py    # Message format conversion
├── memory.py     # Persistent memory operations
├── select.py     # JIT context retrieval
├── llm.py        # LLM adapters
├── tools.py      # Agent-ready tool wrappers
└── util.py       # Utilities (token estimation)

Writing Examples

Examples should follow these conventions:

  • One example per file with a single main() function
  • Use examples/util.py for consistent terminal output (Rich-based)
  • Place in examples/basic/ for standalone examples
  • Place in examples/integrations/ for framework integrations
# Example structure
from examples.util import print_header, print_success

def main():
    print_header("Example Title")
    # ... example code ...
    print_success("Done!")

if __name__ == "__main__":
    main()

Pull Request Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting (uv run pytest && uv run ruff check .)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

PR Checklist

  • Tests pass locally
  • Code follows project style (ruff, mypy)
  • New features have tests
  • Public APIs have docstrings
  • README updated if needed

Questions?

Feel free to open an issue for questions or discussions.