feat(tools): register 5 LSP tools as client-side with schemas

- lsp_definition, lsp_references, lsp_hover, lsp_diagnostics, lsp_symbols
  added to CLIENT_TOOLS in tool_dispatch.rs
- Tool schemas added to build_tool_definitions() for Mistral conversations
- LSP tools use path/line/column/query parameters
This commit is contained in:
2026-03-24 00:58:24 +00:00
parent c6d11259a9
commit 4d5b3a9b28
2 changed files with 40 additions and 0 deletions

View File

@@ -484,6 +484,15 @@ you also have access to server-side tools: search_archive, search_web, research,
("list_directory", "List files and directories. Use path for the directory (default: project root) and optional depth."),
];
// LSP tools — use path, line, column for navigation
let lsp_tools = vec![
("lsp_definition", "Go to the definition of the symbol at the given position. Returns file:line:column."),
("lsp_references", "Find all references to the symbol at the given position."),
("lsp_hover", "Get type information and documentation for the symbol at the given position."),
("lsp_diagnostics", "Get compilation errors and warnings for a file."),
("lsp_symbols", "List symbols in a file (document outline) or search workspace symbols. Use path for a file, or query for workspace search."),
];
for (name, desc) in client_tools {
tools.push(mistralai_client::v1::agents::AgentTool::function(
name.into(),
@@ -504,6 +513,22 @@ you also have access to server-side tools: search_archive, search_web, research,
));
}
for (name, desc) in lsp_tools {
tools.push(mistralai_client::v1::agents::AgentTool::function(
name.into(),
desc.into(),
serde_json::json!({
"type": "object",
"properties": {
"path": { "type": "string", "description": "File path" },
"line": { "type": "integer", "description": "1-based line number" },
"column": { "type": "integer", "description": "1-based column number" },
"query": { "type": "string", "description": "Symbol search query (for workspace symbols)" }
}
}),
));
}
tools
}

View File

@@ -11,6 +11,12 @@ const CLIENT_TOOLS: &[&str] = &[
"bash",
"list_directory",
"ask_user",
// LSP tools (client-side, future: sidecar)
"lsp_definition",
"lsp_references",
"lsp_hover",
"lsp_diagnostics",
"lsp_symbols",
];
/// Route a tool call to server or client.
@@ -37,6 +43,15 @@ mod tests {
assert_eq!(route("ask_user"), ToolSide::Client);
}
#[test]
fn test_lsp_tools_are_client_side() {
assert_eq!(route("lsp_definition"), ToolSide::Client);
assert_eq!(route("lsp_references"), ToolSide::Client);
assert_eq!(route("lsp_hover"), ToolSide::Client);
assert_eq!(route("lsp_diagnostics"), ToolSide::Client);
assert_eq!(route("lsp_symbols"), ToolSide::Client);
}
#[test]
fn test_server_tools() {
assert_eq!(route("search_archive"), ToolSide::Server);