pub enum HookSettingsShape {
Grouped,
Flat,
}Expand description
How a harness lays out the hook registrations in its settings file.
Variants§
Grouped
Claude Code’s shape, shared by Open Agents and Codex: every event holds groups, and every group holds typed hook entries.
{"hooks": {"PreToolUse": [{"hooks": [{"type": "command", "command": "sh …"}]}]}}Flat
Cursor’s shape: every event holds the entries directly, and the
file carries a version beside hooks.
{"version": 1, "hooks": {"preToolUse": [{"command": "sh …"}]}}Implementations§
Source§impl HookSettingsShape
impl HookSettingsShape
Sourcepub fn command_fragment(self, native_event: &str, command: &str) -> Value
pub fn command_fragment(self, native_event: &str, command: &str) -> Value
The fragment that registers one command under one native event.
Sourcepub fn validate_fragment(self, fragment: &Value) -> Result<()>
pub fn validate_fragment(self, fragment: &Value) -> Result<()>
Refuse anything that is not a hooks-only fragment. A whole settings file pasted in by mistake would otherwise be merged key by key into the harness’s real one.
Sourcepub fn merge_fragment(
self,
settings_relpath: &str,
existing: Option<&[u8]>,
fragment: &Value,
) -> Result<Vec<u8>>
pub fn merge_fragment( self, settings_relpath: &str, existing: Option<&[u8]>, fragment: &Value, ) -> Result<Vec<u8>>
Merge a hooks-only fragment into the harness’s settings file, given the bytes it holds now, and return the bytes it should hold next.
Everything the user already has is kept. tuff add is re-runnable
and a pack may be installed over an existing install, so a group the
event already registers is not appended again; the harness would
otherwise run that hook once per copy.
Trait Implementations§
Source§impl Clone for HookSettingsShape
impl Clone for HookSettingsShape
impl Copy for HookSettingsShape
Source§impl Debug for HookSettingsShape
impl Debug for HookSettingsShape
impl Eq for HookSettingsShape
Source§impl PartialEq for HookSettingsShape
impl PartialEq for HookSettingsShape
Source§impl Serialize for HookSettingsShape
impl Serialize for HookSettingsShape
impl StructuralPartialEq for HookSettingsShape
Auto Trait Implementations§
impl Freeze for HookSettingsShape
impl RefUnwindSafe for HookSettingsShape
impl Send for HookSettingsShape
impl Sync for HookSettingsShape
impl Unpin for HookSettingsShape
impl UnsafeUnpin for HookSettingsShape
impl UnwindSafe for HookSettingsShape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.