Skip to main content

Module path_resolve

Module path_resolve 

Source
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§

PathRefusal
A path that did not resolve: the message the caller returns, and the boundary class when the I/O boundary refused it (None for 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 of extra_roots (session-scoped trusted roots from session.extra_roots).
shell_cwd_is_divergent_checkout
True when shell_cwd lives in a DIFFERENT git checkout than project_root (#707): both sides resolve to a .git boundary and the boundaries differ. This is the worktree signal — Claude Code’s EnterWorktree nests a full checkout (own .git file) under <repo>/.claude/worktrees/<name>/, so a same-named relative path exists in both trees and a bare exists() probe silently picks the stale one. A monorepo subdirectory (cd rust/) shares the boundary → not diverged; either side without any .git upward → 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 at resolved. Without it agents got “file not found: ~/src/main.rs” and searched the wrong tree. None when the path is absolute, exists, or base is an ordinary working directory.