Skip to main content

winx_code_agent/tools/
mod.rs

1//! Tools module for the Winx application.
2//!
3//! This module hosts the individual MCP tool implementations (shell, file IO,
4//! image, context save). The live service that wires them to the MCP protocol
5//! is [`crate::server::WinxService`].
6
7pub mod bash_command;
8pub mod code_map;
9pub mod context_save;
10pub mod file_write_or_edit;
11pub mod initialize;
12pub mod multi_file_edit;
13pub mod outline;
14pub mod read_files;
15pub mod read_image;
16pub mod references;
17pub mod undo_edit;
18
19/// Serialize a tool's structured output to JSON for the MCP result's
20/// `structuredContent`, mapping the (practically impossible) failure to a domain
21/// error instead of panicking. Used by the read-only `CodeMap` handlers.
22pub(crate) fn structured_json<T: serde::Serialize>(
23    value: &T,
24) -> crate::errors::Result<serde_json::Value> {
25    serde_json::to_value(value).map_err(|e| {
26        crate::errors::WinxError::SerializationError(format!("structured output: {e}"))
27    })
28}