Expand description
Hook system for apr code — mirrors Claude Code’s hook events.
Hooks let a user intercept the agent loop at well-defined moments and run an external command. The exit code of the command decides what happens next:
0→ allow (hook did nothing interesting, or approved the action)1→ warn (hook emitted a message; agent continues)2→ block (hook vetoed the action; agent aborts that step)
This matches Claude Code’s settings.json → [[hooks]] surface 1:1.
PMAT-CODE-HOOKS-001. This file introduces the event enum, the config
struct that deserializes from manifest.toml’s [[hooks]] table,
and the registry + runner used by the agent loop. Runtime integration
ships incrementally:
- SessionStart — wired from
cmd_code(seeagent/code.rs) - PreToolUse / PostToolUse / UserPromptSubmit / Stop / SubagentStop — surface ships now; call sites land in PMAT-CODE-HOOKS-RUNTIME-001.
Structs§
- Hook
Config - A single hook entry deserialized from
manifest.hooks[]. - Hook
Registry - Indexed collection of hooks keyed by event.
Enums§
- Hook
Decision - Decision returned by a hook, derived from the command’s exit code.
- Hook
Event - Canonical hook events mirroring Claude Code.