Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install dependencies
run: pip install -e ".[dev]"

- name: Ruff
run: ruff check src/

- name: Mypy
run: mypy src/

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install dependencies
run: pip install -e ".[dev]"

- name: Run tests with coverage
run: pytest --cov=ter_calculator --cov-report=term-missing
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
42 changes: 42 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

## Our Standards

Examples of behavior that contributes to a positive environment:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior:

- The use of sexualized language or imagery, and sexual attention or advances
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information without explicit permission
- Other conduct which could reasonably be considered inappropriate

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue on GitHub or contacting the project maintainers.

All complaints will be reviewed and investigated promptly and fairly. Project
maintainers are obligated to respect the privacy and security of the reporter.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
114 changes: 114 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Contributing to TER Calculator

Thanks for your interest in contributing! This guide covers everything you need to get started.

## Getting Started

```bash
# Fork and clone the repo
git clone https://github.com/<your-username>/TER.git
cd TER

# Install in development mode
pip install -e ".[dev]"

# Install pre-commit hooks
pip install pre-commit
pre-commit install
```

Requires Python 3.11+.

## Development Workflow

### Running Tests

```bash
pytest # All tests
pytest tests/unit/test_classifier.py -v # Specific module
pytest --cov=ter_calculator # With coverage
```

### Linting and Type Checking

```bash
ruff check src/ # Lint
ruff format src/ tests/ # Format
mypy src/ # Type check
```

Pre-commit hooks run ruff automatically on staged files.

### Branch Naming

- `feature/<description>` -- new functionality
- `fix/<description>` -- bug fixes
- `docs/<description>` -- documentation changes
- `refactor/<description>` -- code restructuring
- `test/<description>` -- test additions or fixes

### Commit Messages

Use [Conventional Commits](https://www.conventionalcommits.org/):

```
feat: add rolling window size option to watch command
fix: correct token count for merged reasoning spans
docs: add context orchestrator usage examples
test: add unit tests for waste_detectors module
refactor: extract shared CLI argument definitions
```

## Pull Request Process

1. Create a feature branch from `main`
2. Make your changes with tests
3. Ensure all checks pass: `pytest && ruff check src/ && mypy src/`
4. Open a PR against `main` with a clear description
5. One approval required for merge

### PR Guidelines

- One feature or fix per PR
- Include tests for new functionality
- Update documentation if behavior changes
- Keep PRs focused -- separate unrelated changes into different PRs

## Code Style

- Python 3.11+ -- use modern syntax (type unions with `|`, match statements where appropriate)
- Dataclasses for models (see `models.py`)
- Lazy imports in CLI handlers for fast startup
- Ruff handles formatting and linting -- don't fight the formatter

## Project Structure

```
src/ter_calculator/ # Source modules
tests/unit/ # Unit tests
tests/features/ # BDD feature files
tests/integration/ # Integration tests
docs/ # Architecture and user documentation
sample_sessions/ # Sample JSONL files for testing
```

## Reporting Bugs

Open a [GitHub Issue](https://github.com/lgriffin/TER/issues) with:

- Steps to reproduce
- Expected vs actual behavior
- Python version and OS
- Sample session file (if applicable, redact sensitive content)

## Requesting Features

Open a [GitHub Issue](https://github.com/lgriffin/TER/issues) with the `enhancement` label describing:

- The problem you're trying to solve
- Your proposed solution
- Any alternatives you've considered

## License

By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE).
Loading
Loading