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_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_load_tools;
32pub mod ctx_metrics;
33pub mod ctx_multi_read;
34pub mod ctx_outline;
35pub mod ctx_overview;
36pub mod ctx_pack;
37pub mod ctx_plan;
38pub mod ctx_prefetch;
39pub mod ctx_preload;
40pub mod ctx_proof;
41pub mod ctx_provider;
42pub mod ctx_radar;
43pub mod ctx_read;
44pub mod ctx_refactor;
45pub mod ctx_response;
46pub mod ctx_retrieve;
47pub mod ctx_review;
48pub mod ctx_routes;
49pub mod ctx_search;
50pub mod ctx_semantic_search;
51pub mod ctx_session;
52pub mod ctx_share;
53pub mod ctx_shell;
54pub mod ctx_smart_read;
55pub mod ctx_smells;
56pub mod ctx_symbol;
57pub mod ctx_task;
58pub mod ctx_tree;
59pub mod ctx_verify;
60pub mod ctx_workflow;
61
62/// Resolve a relative path against session state (sync version).
63/// Replicates the core logic of `LeanCtxServer::resolve_path` without
64/// the re-rooting fallback (which needs `startup_project_root`).
65/// Must be called within `tokio::task::block_in_place`.
66pub(crate) fn resolve_path_sync(
67    session: &crate::core::session::SessionState,
68    raw: &str,
69) -> Result<String, String> {
70    let normalized = crate::core::pathutil::normalize_tool_path(raw);
71    if normalized.is_empty() || normalized == "." {
72        return Ok(normalized);
73    }
74    let p = std::path::Path::new(&normalized);
75
76    let jail_root = session
77        .project_root
78        .as_deref()
79        .or(session.shell_cwd.as_deref())
80        .unwrap_or(".")
81        .to_string();
82
83    let resolved = if p.is_absolute() || p.exists() {
84        std::path::PathBuf::from(&normalized)
85    } else if let Some(ref root) = session.project_root {
86        let joined = std::path::Path::new(root).join(&normalized);
87        if joined.exists() {
88            joined
89        } else if let Some(ref cwd) = session.shell_cwd {
90            std::path::Path::new(cwd).join(&normalized)
91        } else {
92            std::path::Path::new(&jail_root).join(&normalized)
93        }
94    } else if let Some(ref cwd) = session.shell_cwd {
95        std::path::Path::new(cwd).join(&normalized)
96    } else {
97        std::path::Path::new(&jail_root).join(&normalized)
98    };
99
100    let jail_root_path = std::path::Path::new(&jail_root);
101    let jailed = crate::core::pathjail::jail_path(&resolved, jail_root_path)?;
102    crate::core::io_boundary::check_secret_path_for_tool("resolve_path", &jailed)?;
103
104    Ok(crate::core::pathutil::normalize_tool_path(
105        &jailed.to_string_lossy().replace('\\', "/"),
106    ))
107}