# message-delivery

Save, commit, email, push pipeline for session messages

## Installation

### From DevPi (private registry)

```bash
uv add message-delivery
```

> Requires the DevPi index to be configured in `~/.config/uv/uv.toml`:
> ```toml
> index-strategy = "unsafe-best-match"
>
> [[index]]
> name = "devpi"
> url = "https://pypi.registry.hochguertel.work/root/dev/+simple/"
> ```

### From source (monorepo)

```bash
git clone https://pastoral-oyster.pikapod.net/tools/ai-session-tools.git
cd ai-session-tools
uv sync --all-packages
```

## Usage

`DeliveryPipeline` orchestrates the full delivery: save a message as a
markdown note, commit it to git, send it as HTML email, and push to remote.
Each step is gated by `DeliveryOptions` and each component can also be used
independently.

```python
from message_delivery import DeliveryPipeline, DeliveryOptions
from session_store import SessionStore

store = SessionStore()
message = store.select_message("latest")  # auto-detects tool + session
session = store.get_session(message.session_id, tool=message.tool)

pipeline = DeliveryPipeline()
result = pipeline.deliver(
    message=message,
    session_title=session.title,
    options=DeliveryOptions(
        subject="Latest session message",
        no_push=False,
        no_email=False,
        no_commit=False,
        dry_run=False,
    ),
)

print(f"Saved: {result.note_path}")
print(f"Committed: {result.committed}")
print(f"Emailed: {result.emailed}")
print(f"Pushed: {result.pushed}")
```

Use `dry_run=True` to save only (no commit, email, or push):

```python
result = pipeline.deliver(
    message=message,
    session_title=session.title,
    options=DeliveryOptions(dry_run=True),
)
```

## Development

```bash
# Run tests
uv run pytest libs/message-delivery/tests/

# Lint
uv run ruff check libs/message-delivery/

# Type check
uv run mypy
```

## License

MIT
