Metadata-Version: 2.4
Name: purifyllm
Version: 0.1.2
Summary: purifyllm
Author-email: William Droz <william.droz.ch@gmail.com>
License: MIT License
        
        Copyright (c) 2025 William Droz
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Intended Audience :: Developers
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=8.4.1; extra == "dev"
Dynamic: license-file

# PurifyLLM

CLI and pre-commit hook to normalize “smart” punctuation and invisible Unicode produced by LLMs.

## What it does

Replaces common UTF-8 special characters with safe equivalents:

- smart quotes “ ” ‘ ’ -> " and '
- dashes – — − -> -
- ellipsis … -> ...
- non-breaking spaces and thin spaces -> regular space
- zero-width and BOM characters -> removed

You can add your own mappings in the hook config.

## Install (as a hook consumer)

Add this repo to your `.pre-commit-config.yaml`:

```yaml
repos:
- repo: https://github.com/wdroz/PurifyLLM
  rev: v0.1.1
  hooks:
  - id: purify-llm
    # optional: ignore folders/files via glob and add extra replacements
    exclude: '(^|/)(LICENSES|licenses)/'
  args:
  # add custom mappings
  - --map
  - "\u00AB=\""   # « to "
  - --map
  - "\u00BB=\""   # » to "
```

Then install hooks:

```bash
pre-commit install
```

Run on all files at any time:

```bash
pre-commit run --all-files
```

## CLI usage

```bash
purifyllm [--no-defaults] [--map KEY=VALUE ...] [--ignore-files GLOB ...] [FILES ...]
```

Examples:

```bash
purifyllm README.md
purifyllm --map "\u00B7=-" file.txt
purifyllm --no-defaults --map "…=..." --map "—=-" src/
purifyllm --ignore-files '**/LICENSES/**' --ignore-files 'docs/vendor/**' $(git ls-files)
```

Exit codes:

- 0: no changes needed
- 1: files were modified or an error occurred

### Ignoring files and folders (glob)

Use one or more `--ignore-files` flags to skip files by glob pattern. Matching is against the full path using forward slashes.

Examples:

- `--ignore-files '**/LICENSES/**'` ignore any files under a `LICENSES` directory anywhere.
- `--ignore-files 'docs/vendor/**'` ignore files under `docs/vendor`.
- `--ignore-files '*.md'` ignore markdown files.
