Expand description
§llm-coding-tools-core
Lightweight, high-performance core types and utilities for coding tools - framework agnostic.
§Overview
This crate provides the foundational building blocks for coding tool implementations:
ToolError- Unified error type for all tool operationsToolResult<T>- Result type alias using ToolErrorToolOutput- Wrapper for tool responses with truncation metadata- Utility functions for text processing and formatting
contextmodule - LLM guidance strings for tool usage
§Features
tokio(default): Async mode with tokio runtime. Enables async function signatures.blocking: Sync/blocking mode. Mutually exclusive withtokio/async.async: Base async signatures (internal). Requires a runtime; usetokioinstead.
The async and blocking features are mutually exclusive - enabling both causes a compile error.
Future runtimes (smol, async-std) can be added following the same pattern as tokio.
§Usage
use llm_coding_tools_core::{ToolError, ToolResult, ToolOutput};
use llm_coding_tools_core::util::{truncate_text, format_numbered_line};§Context Module
The context module provides embedded strings containing usage guidance for LLM agents.
These can be appended to tool descriptions or system prompts.
Path-based tools have two variants:
*_ABSOLUTE: For unrestricted filesystem access (absolute paths required)*_ALLOWED: For sandboxed access (paths relative to allowed directories)
use llm_coding_tools_core::context::{BASH, READ_ABSOLUTE, READ_ALLOWED};
// Non-path tools have a single variant
println!("{}", BASH);
// Path-based tools have absolute and allowed variants
println!("{}", READ_ABSOLUTE);
println!("{}", READ_ALLOWED);Available context strings:
BASH,TASK,TODO_READ,TODO_WRITE,WEBFETCH- standalone toolsREAD_ABSOLUTE,READ_ALLOWED- file readingWRITE_ABSOLUTE,WRITE_ALLOWED- file writingEDIT_ABSOLUTE,EDIT_ALLOWED- file editingGLOB_ABSOLUTE,GLOB_ALLOWED- pattern matchingGREP_ABSOLUTE,GREP_ALLOWED- content search
§Design Principles
- No framework-specific dependencies, plug and play into any LLM framework/library
- See llm-coding-tools-rig for an integration example with rig
- Minimal dependency footprint
- Performance-oriented (optimized) with zero-cost abstractions
Re-exports§
pub use context::ToolContext;pub use error::ToolError;pub use error::ToolResult;pub use output::ToolOutput;pub use path::AbsolutePathResolver;pub use path::AllowedPathResolver;pub use path::PathResolver;pub use system_prompt::Substitute;pub use system_prompt::SystemPromptBuilder;pub use operations::edit_file;pub use operations::execute_command;pub use operations::glob_files;pub use operations::grep_search;pub use operations::read_file;pub use operations::read_todos;pub use operations::write_file;pub use operations::write_todos;pub use operations::BashOutput;pub use operations::EditError;pub use operations::GlobOutput;pub use operations::GrepFileMatches;pub use operations::GrepLineMatch;pub use operations::GrepOutput;pub use operations::Todo;pub use operations::TodoPriority;pub use operations::TodoState;pub use operations::TodoStatus;pub use operations::fetch_url;pub use operations::format_json;pub use operations::html_to_markdown;pub use operations::WebFetchOutput;
Modules§
- context
- Tool context strings for LLM agents.
- error
- Common error types for coding tools.
- fs
- Filesystem abstraction layer.
- operations
- Core operations for file systems and utilities.
- output
- Common output types for tool responses.
- path
- Path resolution strategies for tool security.
- system_
prompt - System prompt generation for LLM agents.
- tool_
names - Canonical tool name constants for consistent naming across crates.
- util
- Shared utilities for tool implementations.