Skip to main content

steer_tools/tools/
glob.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4
5use crate::ToolSpec;
6use crate::error::{ToolExecutionError, WorkspaceOpError};
7use crate::result::GlobResult;
8
9pub const GLOB_TOOL_NAME: &str = "glob";
10
11pub struct GlobToolSpec;
12
13impl ToolSpec for GlobToolSpec {
14    type Params = GlobParams;
15    type Result = GlobResult;
16    type Error = GlobError;
17
18    const NAME: &'static str = GLOB_TOOL_NAME;
19    const DISPLAY_NAME: &'static str = "Glob";
20
21    fn execution_error(error: Self::Error) -> ToolExecutionError {
22        ToolExecutionError::Glob(error)
23    }
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Error)]
27#[serde(tag = "code", content = "details", rename_all = "snake_case")]
28pub enum GlobError {
29    #[error("{0}")]
30    Workspace(WorkspaceOpError),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
34pub struct GlobParams {
35    /// The glob pattern to match files against
36    pub pattern: String,
37    /// Optional directory to search in. Defaults to the current working directory.
38    pub path: Option<String>,
39}