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 apply_patch;
8pub mod background_shell;
9pub mod bash_command;
10pub mod code_map;
11pub mod context_save;
12pub mod edit_files;
13pub mod file_write_or_edit;
14pub mod initialize;
15pub mod multi_file_edit;
16pub mod outline;
17pub mod read_files;
18pub mod read_image;
19pub mod references;
20pub mod undo_edit;
21
22/// Serialize a tool's structured output to JSON for the MCP result's
23/// `structuredContent`, mapping the (practically impossible) failure to a domain
24/// error instead of panicking. Used by the read-only `CodeMap` handlers.
25pub(crate) fn structured_json<T: serde::Serialize>(
26    value: &T,
27) -> crate::errors::Result<serde_json::Value> {
28    serde_json::to_value(value).map_err(|e| {
29        crate::errors::WinxError::SerializationError(format!("structured output: {e}"))
30    })
31}