Metadata-Version: 2.4
Name: polyhook
Version: 0.1.6
Summary: polyhook Python SDK — write AI coding agent hooks once, run them everywhere
Author: tupe12334
License: MIT
Project-URL: Homepage, https://github.com/tupe12334/polyhook
Project-URL: Repository, https://github.com/tupe12334/polyhook
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: wasmtime>=20.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"

# polyhook — Python SDK

**Write AI coding agent hooks once. Run them everywhere.**

polyhook detects which AI coding tool invoked your hook binary, deserializes the event into a normalized struct, and serializes your response back in the format that tool expects. Your hook runs unchanged whether Claude Code, Cursor, Windsurf, Cline, or Amp invoked it.

## Install

```bash
pip install polyhook
```

## Quick Start

```python
import sys
import re
import polyhook

event = polyhook.read()

if (
    event.tool == "bash"
    and re.search(r"rm\s+-rf\s+/", event.input.get("command", "") if event.input else "")
):
    polyhook.respond(polyhook.block("Refusing to delete from root"))
else:
    polyhook.respond(polyhook.approve())
```

More examples: [examples/](examples/)

## Supported Tools

| Tool | Status |
|---|---|
| [Claude Code](https://claude.ai/code) | ✅ Supported |
| [Cursor](https://cursor.com) | ✅ Supported |
| [Windsurf](https://windsurf.ai) | ✅ Supported |
| [Cline](https://github.com/cline/cline) | ✅ Supported |
| [Amp](https://ampcode.com) | ✅ Supported |
| [Continue](https://continue.dev) | 🚧 In progress |
| [Aider](https://aider.chat) | 🚧 In progress |
| [Copilot](https://github.com/features/copilot) | 📋 Planned |

## Documentation

Full docs and API reference: <https://github.com/tupe12334/polyhook>

## License

MIT
