lean_ctx/tools/registered/
mod.rs1pub mod ctx_agent;
2pub mod ctx_analyze;
3pub mod ctx_architecture;
4pub mod ctx_artifacts;
5pub mod ctx_benchmark;
6pub mod ctx_cache;
7pub mod ctx_callgraph;
8pub mod ctx_compile;
9pub mod ctx_compress;
10pub mod ctx_compress_memory;
11pub mod ctx_context;
12pub mod ctx_control;
13pub mod ctx_cost;
14pub mod ctx_dedup;
15pub mod ctx_delta;
16pub mod ctx_discover;
17pub mod ctx_discover_tools;
18pub mod ctx_edit;
19pub mod ctx_execute;
20pub mod ctx_expand;
21pub mod ctx_feedback;
22pub mod ctx_fill;
23pub mod ctx_gain;
24pub mod ctx_graph;
25pub mod ctx_handoff;
26pub mod ctx_heatmap;
27pub mod ctx_impact;
28pub mod ctx_index;
29pub mod ctx_intent;
30pub mod ctx_knowledge;
31pub mod ctx_ledger;
32pub mod ctx_load_tools;
33pub mod ctx_metrics;
34pub mod ctx_multi_read;
35pub mod ctx_outline;
36pub mod ctx_overview;
37pub mod ctx_pack;
38pub mod ctx_plan;
39pub mod ctx_prefetch;
40pub mod ctx_preload;
41pub mod ctx_proof;
42pub mod ctx_provider;
43pub mod ctx_radar;
44pub mod ctx_read;
45pub mod ctx_refactor;
46pub mod ctx_response;
47pub mod ctx_retrieve;
48pub mod ctx_review;
49pub mod ctx_routes;
50pub mod ctx_search;
51pub mod ctx_semantic_search;
52pub mod ctx_session;
53pub mod ctx_share;
54pub mod ctx_shell;
55pub mod ctx_smart_read;
56pub mod ctx_smells;
57pub mod ctx_symbol;
58pub mod ctx_task;
59pub mod ctx_tree;
60pub mod ctx_verify;
61pub mod ctx_workflow;
62
63pub(crate) fn resolve_path_sync(
68 session: &crate::core::session::SessionState,
69 raw: &str,
70) -> Result<String, String> {
71 let normalized = crate::core::pathutil::normalize_tool_path(raw);
72 if normalized.is_empty() || normalized == "." {
73 return Ok(normalized);
74 }
75 let p = std::path::Path::new(&normalized);
76
77 let jail_root = session
78 .project_root
79 .as_deref()
80 .or(session.shell_cwd.as_deref())
81 .unwrap_or(".")
82 .to_string();
83
84 let resolved = if p.is_absolute() || p.exists() {
85 std::path::PathBuf::from(&normalized)
86 } else if let Some(ref root) = session.project_root {
87 let joined = std::path::Path::new(root).join(&normalized);
88 if joined.exists() {
89 joined
90 } else if let Some(ref cwd) = session.shell_cwd {
91 std::path::Path::new(cwd).join(&normalized)
92 } else {
93 std::path::Path::new(&jail_root).join(&normalized)
94 }
95 } else if let Some(ref cwd) = session.shell_cwd {
96 std::path::Path::new(cwd).join(&normalized)
97 } else {
98 std::path::Path::new(&jail_root).join(&normalized)
99 };
100
101 let jail_root_path = std::path::Path::new(&jail_root);
102 let jailed = crate::core::pathjail::jail_path(&resolved, jail_root_path)?;
103 crate::core::io_boundary::check_secret_path_for_tool("resolve_path", &jailed)?;
104
105 Ok(crate::core::pathutil::normalize_tool_path(
106 &jailed.to_string_lossy().replace('\\', "/"),
107 ))
108}