This directory is the plugin-level hook composition surface. It exports factories
and managers for all hook-based runtime behaviors used by
src/index.ts (tool transforms, event listeners, and command hooks).
src/index.ts can register features
without depending on subfolder internals.src/hooks/index.ts re-exports per-feature factories and managers.create*Hook(ctx, config?) factory pattern and
return one or more lifecycle callbacks.ForegroundFallbackManager)
with an explicit handleEvent method.createDelegateTaskRetryHook, createJsonErrorRecoveryHook,
createTodoContinuationHook, etc.PluginInput.client for session APIs and shared
utilities (log, marker constants, prompt helpers).src/index.ts imports each hook symbol from this folder.tool.execute.beforetool.execute.afterexperimental.chat.messages.transformexperimental.chat.system.transformchat.headerschat.messagecommand.execute.beforeeventtodo, messages, prompt,
promptAsync, abort, and event/status flows).| Hook Point | Purpose | Implementations |
|---|---|---|
tool.execute.before |
Pre-process tool inputs | apply-patch |
tool.execute.after |
Post-process tool outputs | delegate-task-retry, json-error-recovery, post-file-tool-nudge |
experimental.chat.messages.transform |
Rewrite outbound user content | filter-available-skills, phase-reminder |
experimental.chat.system.transform |
Inject system-level directives | todo-continuation, post-file-tool-nudge |
chat.headers |
Mutate request headers | chat-headers |
chat.message |
Track runtime session/agent mapping | todo-continuation |
command.execute.before |
Handle slash-command UX | todo-continuation (auto-continue) |
event |
React to session lifecycle and runtime failures | foreground-fallback, todo-continuation, post-file-tool-nudge, auto-update-checker, multiplexer managers |
createDelegateTaskRetryHook (tool.execute.after) is a narrow guard around
task tool failure strings and appends structured retry guidance inline.ForegroundFallbackManager listens to event traffic and remediates
foreground rate-limit failures by aborting the current prompt and re-queuing the
latest user message on the next model in a per-agent chain.createTodoContinuationHook spans multiple surfaces: message transform,
system transform, command interception, tool-after, and events. It owns
auto-injection state, cooldown, suppress windows, and orchestration session
tracking.src/index.ts is the sole runtime consumer and determines final registration
order so composed transforms (system joins, reminder insertion, hygiene) stay
deterministic.src/hooks/*/codemap.md files document each feature internals.