Expand description
Platform hook adapter layer.
Each supported AI coding client (Claude Code, Cursor, Zed, …) expects
lifecycle hooks to speak its own JSON dialect on stdin/stdout. This
module defines the PlatformAdapter trait every client implementation
conforms to, plus the get_platform_adapter dispatcher that the CLI
uses to look up the right adapter by name in the difflore-hook shim
time.
The CLI’s job is thin: read stdin, hand it to the adapter, get a
normalised HookEvent, run DiffLore logic, hand the HookResult
back to the adapter to get platform-specific JSON, write to stdout.
Any per-platform quirk lives inside the adapter — the CLI stays
platform-agnostic.
Modules§
- claude_
code - Claude Code hook adapter.
- cursor
- Cursor hook adapter.
- gemini_
cli - Gemini CLI hook adapter.
- session_
banner - Since-last-session banner.
- types
- Platform-agnostic hook event + result types.
- windsurf
- Windsurf hook adapter.
Traits§
- Platform
Adapter - Contract every platform adapter implements. The trait is object-safe
on purpose so
get_platform_adaptercan return aBox<dyn PlatformAdapter>and the dispatch site doesn’t need to know the concrete type at compile time. That makes adding a new client (say Cursor) a pure module-level addition — no changes to the CLI dispatch loop beyond theget_platform_adaptermatch arm.
Functions§
- default_
classify_ error - Default error classifier shared by every adapter. Kept as a free function (not an inherent method) so unit tests don’t need to construct a concrete adapter to exercise it.
- get_
platform_ adapter - Dispatch by client name. Unknown names fall through to the
Claude Code adapter as the pragmatic default — almost every
DiffLoreuser today is on Claude Code, and a wrong-but-compatible parse fails loudly (viaparse_stdin) while a panic would kill the user’s whole assistant session.