Skip to main content

lean_ctx/tools/registered/
mod.rs

1pub 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_callees;
8pub mod ctx_callers;
9pub mod ctx_callgraph;
10pub mod ctx_compile;
11pub mod ctx_compress;
12pub mod ctx_compress_memory;
13pub mod ctx_context;
14pub mod ctx_control;
15pub mod ctx_cost;
16pub mod ctx_dedup;
17pub mod ctx_delta;
18pub mod ctx_discover;
19pub mod ctx_discover_tools;
20pub mod ctx_edit;
21pub mod ctx_execute;
22pub mod ctx_expand;
23pub mod ctx_feedback;
24pub mod ctx_fill;
25pub mod ctx_gain;
26pub mod ctx_graph;
27pub mod ctx_graph_diagram;
28pub mod ctx_handoff;
29pub mod ctx_heatmap;
30pub mod ctx_impact;
31pub mod ctx_index;
32pub mod ctx_intent;
33pub mod ctx_knowledge;
34pub mod ctx_metrics;
35pub mod ctx_multi_read;
36pub mod ctx_outline;
37pub mod ctx_overview;
38pub mod ctx_pack;
39pub mod ctx_plan;
40pub mod ctx_prefetch;
41pub mod ctx_preload;
42pub mod ctx_proof;
43pub mod ctx_provider;
44pub mod ctx_radar;
45pub mod ctx_read;
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;
62pub mod ctx_wrapped;
63
64/// Resolve a relative path against session state (sync version).
65/// Replicates the core logic of `LeanCtxServer::resolve_path` without
66/// the re-rooting fallback (which needs `startup_project_root`).
67/// Must be called within `tokio::task::block_in_place`.
68pub(crate) fn resolve_path_sync(
69    session: &crate::core::session::SessionState,
70    raw: &str,
71) -> Result<String, String> {
72    let normalized = crate::core::pathutil::normalize_tool_path(raw);
73    if normalized.is_empty() || normalized == "." {
74        return Ok(normalized);
75    }
76    let p = std::path::Path::new(&normalized);
77
78    let jail_root = session
79        .project_root
80        .as_deref()
81        .or(session.shell_cwd.as_deref())
82        .unwrap_or(".")
83        .to_string();
84
85    let resolved = if p.is_absolute() || p.exists() {
86        std::path::PathBuf::from(&normalized)
87    } else if let Some(ref root) = session.project_root {
88        let joined = std::path::Path::new(root).join(&normalized);
89        if joined.exists() {
90            joined
91        } else if let Some(ref cwd) = session.shell_cwd {
92            std::path::Path::new(cwd).join(&normalized)
93        } else {
94            std::path::Path::new(&jail_root).join(&normalized)
95        }
96    } else if let Some(ref cwd) = session.shell_cwd {
97        std::path::Path::new(cwd).join(&normalized)
98    } else {
99        std::path::Path::new(&jail_root).join(&normalized)
100    };
101
102    let jail_root_path = std::path::Path::new(&jail_root);
103    let jailed = crate::core::pathjail::jail_path(&resolved, jail_root_path)?;
104    crate::core::io_boundary::check_secret_path_for_tool("resolve_path", &jailed)?;
105
106    Ok(crate::core::pathutil::normalize_tool_path(
107        &jailed.to_string_lossy().replace('\\', "/"),
108    ))
109}