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_call;
8pub mod ctx_callgraph;
9pub mod ctx_compile;
10pub mod ctx_compose;
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_handoff;
28pub mod ctx_heatmap;
29pub mod ctx_impact;
30pub mod ctx_index;
31pub mod ctx_intent;
32pub mod ctx_knowledge;
33pub mod ctx_ledger;
34pub mod ctx_load_tools;
35pub mod ctx_metrics;
36pub mod ctx_multi_read;
37pub mod ctx_multi_repo;
38pub mod ctx_outline;
39pub mod ctx_overview;
40pub mod ctx_pack;
41pub mod ctx_plan;
42pub mod ctx_plugins;
43pub mod ctx_prefetch;
44pub mod ctx_preload;
45pub mod ctx_proof;
46pub mod ctx_provider;
47pub mod ctx_radar;
48pub mod ctx_read;
49pub mod ctx_refactor;
50pub mod ctx_repomap;
51pub mod ctx_response;
52pub mod ctx_retrieve;
53pub mod ctx_review;
54pub mod ctx_routes;
55pub mod ctx_rules;
56pub mod ctx_search;
57pub mod ctx_semantic_search;
58pub mod ctx_session;
59pub mod ctx_share;
60pub mod ctx_shell;
61pub mod ctx_smart_read;
62pub mod ctx_smells;
63pub mod ctx_symbol;
64pub mod ctx_task;
65pub mod ctx_tree;
66pub mod ctx_url_read;
67pub mod ctx_verify;
68pub mod ctx_workflow;
69pub mod shell_alias;
70
71/// Resolve a relative path against session state (sync version).
72/// Thin wrapper over [`crate::core::path_resolve::resolve_tool_path`].
73/// Must be called within `tokio::task::block_in_place`.
74pub(crate) fn resolve_path_sync(
75    session: &crate::core::session::SessionState,
76    raw: &str,
77) -> Result<String, String> {
78    crate::core::path_resolve::resolve_tool_path(
79        session.project_root.as_deref(),
80        session.shell_cwd.as_deref(),
81        raw,
82    )
83}
84
85#[cfg(test)]
86mod adoption_tests {
87    use super::*;
88    use crate::core::terse::mcp_compress::{compress_description, DescriptionMode};
89    use crate::server::tool_trait::McpTool;
90
91    /// Tools that compete with native harness tools must steer the agent toward
92    /// the ctx_* equivalent in the FIRST line of their description: under Max
93    /// compression (Lazy mode) only the first line survives, so steering placed
94    /// later would be dropped and adoption suffers (#168).
95    #[test]
96    fn native_competing_tools_steer_in_first_line() {
97        let tools: Vec<(&str, Box<dyn McpTool>)> = vec![
98            ("ctx_read", Box::new(ctx_read::CtxReadTool)),
99            ("ctx_search", Box::new(ctx_search::CtxSearchTool)),
100            ("ctx_shell", Box::new(ctx_shell::CtxShellTool)),
101            ("ctx_tree", Box::new(ctx_tree::CtxTreeTool)),
102        ];
103        for (name, tool) in tools {
104            let def = tool.tool_def();
105            let desc = def.description.as_deref().unwrap_or("");
106            let first = desc.lines().next().unwrap_or("");
107
108            assert!(
109                first.contains("Prefer over native"),
110                "{name}: first line must steer toward ctx_* over native: {first:?}"
111            );
112            assert!(
113                first.len() <= 80,
114                "{name}: first line is {} bytes (>80 truncates under Lazy mode): {first:?}",
115                first.len()
116            );
117
118            // Steering must survive Max-compression (Lazy keeps only line 1).
119            let lazy = compress_description(name, desc, DescriptionMode::Lazy);
120            assert!(
121                lazy.contains("native"),
122                "{name}: steering lost under Lazy compression: {lazy:?}"
123            );
124        }
125    }
126}