Metadata-Version: 2.5
Name: py-redline
Version: 0.2.0
Summary: Targeted, exact document edits for AI agents
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: markdown-it-py>=4.2.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: python-dotenv; extra == 'dev'
Provides-Extra: pydantic-ai
Requires-Dist: pydantic-ai-slim[anthropic,evals]>=2.32.1; extra == 'pydantic-ai'
Description-Content-Type: text/markdown

# redline

Targeted, exact document edits for AI agents - no full-document rewrites.

## Install

```
pip install py-redline
pip install "py-redline[pydantic-ai]"   # optional, for the pydantic-ai wrapper
```

## Usage

```python
from redline import Document, apply_edit, read

doc = Document("# Todo\n- buy milk\n")
apply_edit(doc, "buy milk", "buy oat milk")
print(read(doc))
```

`Document` holds the text. `apply_edit` finds `old_str` and swaps in `new_str` -
it must match exactly once, unless `allow_multiple=True`. Other tools: `read_lines`,
`append`, `undo`.

## With pydantic-ai

```python
from pydantic_ai import Agent
from redline import Document
from redline.pydantic_ai import TOOLS

doc = Document(your_text)
agent = Agent("your-model", deps_type=Document, tools=TOOLS)
agent.run_sync("fix the typo in the intro", deps=doc)
print(doc.text)
```

`TOOLS` includes everything. For a session that should only ever read, use
`READ_TOOLS` instead - `WRITE_TOOLS` holds the tools that can change the
document.
