Expand description
Shared path-resolution for tool handlers.
Previously two near-identical resolve_path_sync implementations lived in
tools/registered/mod.rs (SessionState-based) and server/tool_trait.rs
(ToolContext-based), plus several copies of the project-marker test. This
module is the single source of truth: resolve_tool_path for jailed path
resolution and a re-export of has_project_marker for marker detection.
Re-exports§
pub use crate::core::pathutil::has_project_marker;
Structs§
- Path
Refusal - A path that did not resolve: the message the caller returns, and the
boundary class when the I/O boundary refused it (
Nonefor a path that is merely missing or malformed). The class is what the audit trail records.
Functions§
- resolve_
tool_ path - Resolve a (possibly relative) tool path to a normalized, jail-checked, secret-screened absolute path.
- resolve_
tool_ path_ refusing resolve_tool_path_with_roots, saying which boundary refused the path.- resolve_
tool_ path_ with_ roots - Like
resolve_tool_path, but also permits paths under any ofextra_roots(session-scoped trusted roots fromsession.extra_roots). - shell_
cwd_ is_ divergent_ checkout - True when
shell_cwdlives in a DIFFERENT git checkout thanproject_root(#707): both sides resolve to a.gitboundary and the boundaries differ. This is the worktree signal — Claude Code’sEnterWorktreenests a full checkout (own.gitfile) under<repo>/.claude/worktrees/<name>/, so a same-named relative path exists in both trees and a bareexists()probe silently picks the stale one. A monorepo subdirectory (cd rust/) shares the boundary → not diverged; either side without any.gitupward → no signal → not diverged. - unbound_
relative_ path - Refusal for a relative path that cannot mean anything yet: the session has
no project, the host started lean-ctx in a broad directory (OpenCode
launched from
~), and nothing exists atresolved. Without it agents got “file not found: ~/src/main.rs” and searched the wrong tree.Nonewhen the path is absolute, exists, orbaseis an ordinary working directory.