← News
Release notes

Pi 0.18.0

Added

  • Hooks system: TypeScript modules that extend agent behavior by subscribing to lifecycle events. Hooks can intercept tool calls, prompt for confirmation, modify results, and inject messages from external sources. Auto-discovered from ~/.pi/agent/hooks/*.ts and .pi/hooks/*.ts. Thanks to @nicobailon for the collaboration on the design and implementation. (#145, supersedes #158)

  • pi.send() API: Hooks can inject messages into the agent session from external sources (file watchers, webhooks, CI systems). If streaming, messages are queued; otherwise a new agent loop starts immediately.

  • --hook <path> CLI flag: Load hook files directly for testing without modifying settings.

  • Hook events: session_start, session_switch, agent_start, agent_end, turn_start, turn_end, tool_call (can block), tool_result (can modify), branch.

  • Hook UI primitives: ctx.ui.select(), ctx.ui.confirm(), ctx.ui.input(), ctx.ui.notify() for interactive prompts from hooks.

  • Hooks documentation: Full API reference at docs/hooks.md, shipped with npm package.