Expand description
§llm-coding-tools-serdesai
Lightweight, high-performance serdesAI framework Tool implementations for coding tools.
§Features
- File operations - Read, write, edit, glob, grep with two access modes:
absolute::*- Unrestricted filesystem accessallowed::*- Sandboxed to configured directories
- Shell execution - Cross-platform command execution with timeout
- Web fetching - URL content retrieval with format conversion
- Todo management - Shared-state todo list tracking
- Context strings - LLM guidance text for tool usage (re-exported from core)
- Schema builders - Composable helpers for custom tool definitions
§Installation
Add to your Cargo.toml:
[dependencies]
llm-coding-tools-serdesai = "0.1"§Quick Start
Minimal runnable agent (requires OPENAI_API_KEY):
use llm_coding_tools_serdesai::absolute::{GlobTool, GrepTool, ReadTool};
use llm_coding_tools_serdesai::agent_ext::AgentBuilderExt;
use llm_coding_tools_serdesai::{BashTool, SystemPromptBuilder, create_todo_tools};
use serdes_ai::prelude::*;
#[tokio::main]
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let (todo_read, todo_write, _state) = create_todo_tools();
let mut pb = SystemPromptBuilder::new();
// Build agent with tools - call .system_prompt() last
let agent = AgentBuilder::<(), String>::from_model("openai:gpt-4o")?
.tool(pb.track(ReadTool::<true>::new()))
.tool(pb.track(GlobTool::new()))
.tool(pb.track(GrepTool::<true>::new()))
.tool(pb.track(BashTool::new()))
.tool(pb.track(todo_read))
.tool(pb.track(todo_write))
.system_prompt(pb.build()) // Last, after tracking all tools
.build();
// Run agent with tools
let response = agent
.run("Search for TODO comments in src/", ())
.await?;
println!("{}", response.output());
Ok(())
}See the serdesai-basic example for a complete working setup.
§Usage
File tools come in absolute::* (unrestricted) and allowed::* (sandboxed) variants:
use llm_coding_tools_serdesai::absolute::{ReadTool, WriteTool};
use llm_coding_tools_serdesai::allowed::{ReadTool as AllowedReadTool, WriteTool as AllowedWriteTool};
use llm_coding_tools_serdesai::AllowedPathResolver;
use std::path::PathBuf;
// Unrestricted access (absolute paths)
let read = ReadTool::<true>::new();
// Sandboxed access (paths relative to allowed directories)
let allowed_paths = vec![PathBuf::from("/home/user/project"), PathBuf::from("/tmp")];
let resolver = AllowedPathResolver::new(allowed_paths).unwrap();
let sandboxed_read: AllowedReadTool<true> = AllowedReadTool::new(resolver.clone());
let sandboxed_write = AllowedWriteTool::new(resolver);Other tools: BashTool, WebFetchTool, TaskTool, TodoReadTool, TodoWriteTool.
Use SystemPromptBuilder to track tools and pass pb.build() to .system_prompt(). Set working_directory() so the environment section is populated.
Use AgentBuilderExt::tool() to add tools that implement Tool<Deps> to the agent.
Context strings are re-exported in llm_coding_tools_serdesai::context (e.g., BASH, READ_ABSOLUTE).
§Examples
# Basic agent setup with AgentBuilderExt
cargo run --example serdesai-basic -p llm-coding-tools-serdesai
# Sandboxed file access with allowed::* tools
cargo run --example serdesai-sandboxed -p llm-coding-tools-serdesai§License
Apache 2.0
Re-exports§
pub use absolute::EditTool;pub use absolute::GlobTool;pub use absolute::GrepTool;pub use absolute::ReadTool;pub use absolute::WriteTool;pub use bash::BashTool;pub use todo::TodoReadTool;pub use todo::TodoWriteTool;pub use todo::create_todo_tools;pub use webfetch::WebFetchTool;
Modules§
- absolute
- Tools using
llm_coding_tools_core::path::AbsolutePathResolver. - agent_
ext - Extension traits for integrating tools with serdes-ai AgentBuilder.
- allowed
- Tools using
llm_coding_tools_core::path::AllowedPathResolver. - allowed_
tools - Re-export allowed module tool types (namespaced to avoid conflicts).
- bash
- Shell command execution tool.
- context
- Tool context strings for LLM agents.
- convert
- Type conversions between core types and serdesAI types.
- todo
- Todo list management tools.
- webfetch
- Web content fetching tool.
Structs§
- Absolute
Path Resolver - Re-export path resolvers from core. Path resolver that requires absolute paths.
- Allowed
Path Resolver - Re-export path resolvers from core. Path resolver that restricts access to allowed directories.
- Bash
Output - Result of shell command execution.
- Glob
Output - Output from glob file matching.
- Grep
File Matches - All matches within a single file.
- Grep
Line Match - A single line match within a file.
- Grep
Output - Output from grep search.
- System
Prompt Builder - Re-export
SystemPromptBuilderandSubstitutefrom core. Builder that tracks tools and generates formatted system prompts. - Todo
- A single task item.
- Todo
State - Thread-safe shared state for todo list.
- Tool
Output - Re-export core types for convenience. Wrapper for tool output with truncation metadata.
- WebFetch
Output - Result from URL fetch operation.
Enums§
- Edit
Error - Errors specific to edit operations.
- Todo
Priority - Task priority level.
- Todo
Status - Task status.
- Tool
Error - Re-export core types for convenience. Unified error type for all tool operations.
Traits§
- Path
Resolver - Re-export path resolvers from core. Strategy for resolving and validating file paths.
- Substitute
- Re-export
SystemPromptBuilderandSubstitutefrom core. Extension trait for placeholder substitution on system prompt strings. - Tool
Context - Re-export context module and
ToolContexttrait for convenience. Trait for tools that provide usage context for LLM system prompts.
Type Aliases§
- Tool
Result - Re-export core types for convenience. Result type alias for tool operations.