#[non_exhaustive]pub enum Scope {
Global,
Local(PathBuf),
}Expand description
Install location for a hook.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Global
User-global: writes to the harness’s per-user config dir
(e.g., ~/.claude/, ~/.cursor/).
Local(PathBuf)
Project-local: writes to a specific project directory
(e.g., ./CLAUDE.md, ./.clinerules).
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn local_root(&self) -> Option<&Path>
pub fn local_root(&self) -> Option<&Path>
Returns the local project root for Scope::Local.
Sourcepub fn ensure_contained(&self, path: &Path) -> Result<(), AgentConfigError>
pub fn ensure_contained(&self, path: &Path) -> Result<(), AgentConfigError>
Verify that path is contained within the local project root.
For Scope::Global, rejects symlinks anywhere along the path so a
symlinked ~/.claude, ~/.cursor, etc. cannot redirect writes outside
the user’s intended config tree. For Scope::Local, rejects symlink
components under the project root, canonicalizes the deepest existing
path component, then checks it stays within the canonical project root.
Missing tail components are allowed when every existing ancestor stays inside the root and is not a symlink.
§Errors
Returns crate::AgentConfigError::PathResolution when:
- any path component is a symlink (Global scope) or a symlink under the
local root (Local scope) —
"refusing to write through symlink", - the canonicalized path escapes the local project root —
"refusing to write outside scope root", - an unexpected I/O error occurs while inspecting an existing component.