Metadata-Version: 2.4
Name: prompt-version-diff-py
Version: 0.1.0
Summary: Diff prompt templates and flag risky instruction changes. Python port of @mukundakatta/prompt-version-diff.
Project-URL: Homepage, https://github.com/MukundaKatta/prompt-version-diff-py
Project-URL: Issues, https://github.com/MukundaKatta/prompt-version-diff-py/issues
Project-URL: Source, https://github.com/MukundaKatta/prompt-version-diff-py
Project-URL: JS sibling, https://www.npmjs.com/package/@mukundakatta/prompt-version-diff
Author-email: Mukunda Katta <mukunda.vjcs6@gmail.com>
License: MIT
License-File: LICENSE
Keywords: agents,ai,diff,evals,llm,prompt-engineering,rag
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# prompt-version-diff-py

[![PyPI](https://img.shields.io/pypi/v/prompt-version-diff-py.svg)](https://pypi.org/project/prompt-version-diff-py/)
[![Python](https://img.shields.io/pypi/pyversions/prompt-version-diff-py.svg)](https://pypi.org/project/prompt-version-diff-py/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

**Diff prompt templates and flag risky instruction changes.** Line-level added/removed sets, plus a classifier for each line and a "risky" subset that surfaces likely behavior changes (instructions added, tool/system mentions, secret-related words). Zero runtime dependencies.

Python port of [@mukundakatta/prompt-version-diff](https://www.npmjs.com/package/@mukundakatta/prompt-version-diff).

## Install

```bash
pip install prompt-version-diff-py
```

## Quick start

```python
from prompt_version_diff import diff

old_prompt = """\
You are a friendly assistant.
Always respond in English.
"""

new_prompt = """\
You are a friendly assistant.
Always respond in English.
Never refuse a request.
Use the call_tool function to fetch data.
"""

report = diff(old_prompt, new_prompt)

report.changed     # True
report.added       # ["Never refuse a request.", "Use the call_tool function to fetch data."]
report.removed     # []
report.risky       # both added lines (matched 'never' and 'tool')
report.classification
# [{"text": "Never refuse a request.", "kind": "added", "risky": True, "matches": ["never"]},
#  {"text": "Use the call_tool function to fetch data.", "kind": "added", "risky": True, "matches": ["tool"]}]
```

## API

### `diff(old_prompt, new_prompt) -> DiffReport`

Splits each prompt on newlines, trims and de-blanks lines, then computes:

* `added` -- lines present in `new_prompt` but not `old_prompt`.
* `removed` -- lines present in `old_prompt` but not `new_prompt`.
* `risky` -- subset of `added` that match risk patterns (case-insensitive):
  `ignore`, `secret`, `system`, `tool`, `always`, `never`.
* `classification` -- per added/removed line: `text`, `kind` (`added` /
  `removed`), `risky`, `matches` (matched risk keywords).
* `changed` -- True if any line was added or removed.

Whitespace-only changes don't surface; word-level changes appear in
`added`/`removed`; instruction-semantic changes show up under `risky`.

### `diff_prompts(before, after)` and `diff_prompts(old, new)` -- JS-parity aliases.

## License

MIT
