Improve documentation: README settings table, philosophy section, custom-tools intro, rpc hook_error event, hooks import aliases

This commit is contained in:
Mario Zechner 2025-12-17 22:04:28 +01:00
parent 5e5bdadbf9
commit 3424550d21
12 changed files with 155 additions and 2319 deletions

View file

@ -44,6 +44,20 @@ You can also add explicit hook paths in `~/.pi/agent/settings.json`:
- `hooks`: Additional hook file paths (supports `~` expansion)
- `hookTimeout`: Timeout in milliseconds for hook operations (default: 30000). Does not apply to `tool_call` events, which have no timeout since they may prompt the user.
## Available Imports
Hooks can import from these packages (automatically resolved by pi):
| Package | Purpose |
|---------|---------|
| `@mariozechner/pi-coding-agent/hooks` | Hook types (`HookAPI`, etc.) |
| `@mariozechner/pi-coding-agent` | Additional types if needed |
| `@mariozechner/pi-ai` | AI utilities (`ToolResultMessage`, etc.) |
| `@mariozechner/pi-tui` | TUI components (for advanced use cases) |
| `@sinclair/typebox` | Schema definitions |
Node.js built-in modules (`node:fs`, `node:path`, etc.) are also available.
## Writing a Hook
A hook is a TypeScript file that exports a default function. The function receives a `HookAPI` object used to subscribe to events.