Expand description
Agent tools using Rig’s Tool trait
These tools wrap existing CLI functionality for the agent to use.
§Available Tools
§File Operations
ReadFileTool- Read file contentsWriteFileTool- Write single files (Dockerfiles, Terraform, etc.)WriteFilesTool- Write multiple files (Terraform modules, Helm charts)ListDirectoryTool- List directory contents
§Analysis
AnalyzeTool- Analyze project architecture, dependencies, build commands
§Security
SecurityScanTool- Security vulnerability scanningVulnerabilitiesTool- Dependency vulnerability checking
§Linting
HadolintTool- Native Dockerfile linting (best practices, security)DclintTool- Native Docker Compose linting (best practices, style, security)HelmlintTool- Native Helm chart structure/template lintingKubelintTool- Native Kubernetes manifest security/best practice linting
§Resource Optimization
K8sOptimizeTool- Kubernetes resource right-sizing and cost optimizationK8sCostsTool- Kubernetes workload cost attribution and analysisK8sDriftTool- Detect configuration drift between manifests and cluster
§Prometheus Integration (for live K8s analysis)
PrometheusDiscoverTool- Discover Prometheus services in Kubernetes clusterPrometheusConnectTool- Establish connection to Prometheus (port-forward or URL)BackgroundProcessManager- Manage long-running background processes
§Helm vs Kubernetes Linting
- HelmlintTool: Use for Helm chart development - validates Chart.yaml, values.yaml, Go template syntax, and Helm-specific best practices. Works on chart directories.
- KubelintTool: Use for K8s security - checks rendered manifests for privileged containers, missing probes, RBAC issues, resource limits. Works on YAML files, Helm charts (renders them), and Kustomize directories.
§Diagnostics
DiagnosticsTool- Check for code errors via IDE/LSP or language-specific commands
§Terraform
TerraformFmtTool- Format Terraform configuration filesTerraformValidateTool- Validate Terraform configurationsTerraformInstallTool- Install Terraform CLI (auto-detects OS)
§Shell
ShellTool- Execute validation commands (docker build, terraform validate, helm lint)
§Planning (Forge-style workflow)
PlanCreateTool- Create structured plan files with task checkboxesPlanNextTool- Get next pending task and mark it in-progressPlanUpdateTool- Update task status (done, failed)PlanListTool- List all available plan files
§Web
WebFetchTool- Fetch content from URLs (converts HTML to markdown)
§Error Handling Pattern
Tools use the shared error utilities in error.rs:
- Each tool keeps its own error type (e.g.,
ReadFileError,ShellError) - Use
ToolErrorContexttrait to add context when propagating errors - Use
format_error_for_llmfor structured JSON error responses to the agent - Error categories help the agent understand and recover from errors
See error.rs for the complete error handling infrastructure.
§Response Format Pattern
Tools use the shared response utilities in response.rs for consistent output:
- Use
format_file_contentfor file read operations (with truncation metadata) - Use
format_listfor directory listings and search results - Use
format_write_successfor successful write operations - Use
format_cancelledfor user-cancelled operations - Use
ResponseMetadatato track truncation, compression, and item counts
For large outputs (analysis, lint results), use compress_tool_output or
compress_analysis_output from compression.rs which store full data
and return a compressed summary with retrieval reference.
§Example
ⓘ
use crate::agent::tools::response::{format_file_content, format_list};
// File read response
Ok(format_file_content(&path, &content, total_lines, returned_lines, truncated))
// Directory listing response
Ok(format_list(&path, &entries, total_count, was_truncated))See response.rs for the complete response formatting infrastructure.
Re-exports§
pub use compression::CompressionConfig;pub use compression::compress_analysis_output;pub use compression::compress_tool_output;pub use error::ErrorCategory;pub use error::ToolErrorContext;pub use error::detect_error_category;pub use error::format_error_for_llm;pub use error::format_error_with_context;pub use response::ResponseMetadata;pub use response::ToolResponse;pub use response::format_cancelled;pub use response::format_file_content;pub use response::format_file_content_range;pub use response::format_list;pub use response::format_list_with_metadata;pub use response::format_success;pub use response::format_success_with_metadata;pub use response::format_write_success;pub use background::BackgroundProcessManager;
Modules§
- background
- Background Process Manager
- compression
- Smart Context Compression for Tool Outputs
- error
- Common error utilities for agent tools
- output_
store - RAG Storage Layer for Tool Outputs
- response
- Response formatting utilities for agent tools
Structs§
- Analyze
Tool - Tool to analyze a project
- Dclint
Tool - Tool to lint Docker Compose files natively
- Diagnostics
Tool - Hadolint
Tool - Tool to lint Dockerfiles natively
- Helmlint
Tool - Tool to lint Helm charts natively
- K8sCosts
Tool - Tool for analyzing Kubernetes workload costs
- K8sDrift
Tool - Tool for detecting Kubernetes configuration drift
- K8sOptimize
Tool - Tool for analyzing Kubernetes resource configurations
- Kubelint
Tool - Tool to lint Kubernetes manifests natively
- List
Directory Tool - List
Outputs Tool - Tool to list all available stored outputs
- Plan
Create Tool - Plan
List Tool - Plan
Next Tool - Plan
Update Tool - Prometheus
Connect Tool - Tool for connecting to Prometheus
- Prometheus
Discover Tool - Tool for discovering Prometheus in Kubernetes clusters
- Read
File Tool - Retrieve
Output Tool - Tool to retrieve detailed data from compressed tool outputs
- Security
Scan Tool - Shell
Tool - Terraform
FmtTool - Tool to format Terraform configurations
- Terraform
Install Tool - Tool to install Terraform CLI
- Terraform
Validate Tool - Tool to validate Terraform configurations
- Truncation
Limits - Configuration for output truncation limits
- Vulnerabilities
Tool - WebFetch
Tool - Write
File Tool - Write
Files Tool
Functions§
- truncate_
json_ output - Truncate JSON output to fit within context limits. Intelligently summarizes large arrays and nested objects.