Add before_compact hook event (closes #281) (#285)

* Add before_compact hook event (closes #281)

* Add compact hook event and documentation

- Add compact event that fires after compaction completes
- Update hooks.md with lifecycle diagram, field docs, and example
- Add CHANGELOG entry
- Add comprehensive test coverage (10 tests) for before_compact and compact events
- Tests cover: event emission, cancellation, custom entry, error handling, multiple hooks
This commit is contained in:
Nico Bailon 2025-12-24 02:26:29 -08:00 committed by GitHub
parent 20b24cf5a4
commit 1e1a92ea47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 700 additions and 36 deletions

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Added
- **Custom compaction hooks**: Added `before_compact` and `compact` session events for context compaction. `before_compact` fires before compaction with the cut point, messages to summarize, model, and API key; hooks can cancel or provide a custom `compactionEntry`. `compact` fires after with the final compaction entry and a `fromHook` flag. ([#281](https://github.com/badlogic/pi-mono/issues/281))
## [0.27.4] - 2025-12-24
### Fixed