pub fn expand_tilde(path: &str) -> PathBufExpand description
Expand a leading ~ or ~/ to the user’s home directory. The function is
intentionally forgiving: paths that don’t start with ~ are returned as-is,
and when the home directory cannot be determined the original path is
preserved so callers can surface a downstream error rather than panicking.
This is the canonical implementation used by the tool registry and the sandbox runtime; both call sites previously carried near-identical copies.