pub fn resolve_tool_path(
project_root: Option<&str>,
shell_cwd: Option<&str>,
raw: &str,
) -> Result<String, String>Expand description
Resolve a (possibly relative) tool path to a normalized, jail-checked, secret-screened absolute path.
Resolution of the input:
- absolute path → used as-is
- relative path with a project root →
<project_root>/<path>, whether or not it exists (a write target), exactly as the tool schemas promise - relative path without a project root →
<shell_cwd>/<path>(the directory the client started the session in), else<jail_root>/<path>
The base of a relative path never depends on earlier tool calls (#2262):
ctx_shell does not move shell_cwd, and with a project root it is not
consulted at all. A worktree or other checkout is addressed by absolute
path.
Relative inputs are NEVER resolved against the process CWD: the daemon’s
CWD is not the project, so a CWD exists() probe made resolution
nondeterministic across MCP/daemon/CLI contexts (and could pick a
same-named file outside the project).
jail_root is project_root, else shell_cwd, else ".". The result is
confined to the jail root via crate::core::pathjail::jail_path and
screened by the secret-path I/O boundary.
Performs blocking filesystem exists() checks; callers on async runtimes
must wrap this in tokio::task::block_in_place.