Module tools

Module tools 

Source
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 contents
  • WriteFileTool - 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 scanning
  • VulnerabilitiesTool - 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 linting
  • KubelintTool - Native Kubernetes manifest security/best practice linting

§Resource Optimization

  • K8sOptimizeTool - Kubernetes resource right-sizing and cost optimization
  • K8sCostsTool - Kubernetes workload cost attribution and analysis
  • K8sDriftTool - Detect configuration drift between manifests and cluster

§Prometheus Integration (for live K8s analysis)

  • PrometheusDiscoverTool - Discover Prometheus services in Kubernetes cluster
  • PrometheusConnectTool - 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 files
  • TerraformValidateTool - Validate Terraform configurations
  • TerraformInstallTool - 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 checkboxes
  • PlanNextTool - Get next pending task and mark it in-progress
  • PlanUpdateTool - Update task status (done, failed)
  • PlanListTool - List all available plan files

§Web

  • WebFetchTool - Fetch content from URLs (converts HTML to markdown)

§Platform (Syncable Platform API)

  • ListOrganizationsTool - List organizations the user belongs to
  • ListProjectsTool - List projects within an organization
  • SelectProjectTool - Select a project as current context
  • CurrentContextTool - Get the currently selected project context
  • OpenProviderSettingsTool - Open cloud provider settings in browser
  • CheckProviderConnectionTool - Check if a cloud provider is connected
  • ListDeploymentConfigsTool - List deployment configurations for a project
  • TriggerDeploymentTool - Trigger a deployment using a config
  • GetDeploymentStatusTool - Get deployment task status and progress
  • ListDeploymentsTool - List recent deployments with URLs
  • GetServiceLogsTool - Get container logs for a deployed service

§Error Handling Pattern

Tools use the shared error utilities in error.rs:

  1. Each tool keeps its own error type (e.g., ReadFileError, ShellError)
  2. Use ToolErrorContext trait to add context when propagating errors
  3. Use format_error_for_llm for structured JSON error responses to the agent
  4. 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:

  1. Use format_file_content for file read operations (with truncation metadata)
  2. Use format_list for directory listings and search results
  3. Use format_write_success for successful write operations
  4. Use format_cancelled for user-cancelled operations
  5. Use ResponseMetadata to 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;
pub use platform::CheckProviderConnectionTool;
pub use platform::CreateDeploymentConfigTool;
pub use platform::CurrentContextTool;
pub use platform::DeployServiceTool;
pub use platform::GetDeploymentStatusTool;
pub use platform::GetServiceLogsTool;
pub use platform::ListDeploymentCapabilitiesTool;
pub use platform::ListDeploymentConfigsTool;
pub use platform::ListDeploymentsTool;
pub use platform::ListOrganizationsTool;
pub use platform::ListProjectsTool;
pub use platform::OpenProviderSettingsTool;
pub use platform::SelectProjectTool;
pub use platform::TriggerDeploymentTool;

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
platform
Platform tools for managing Syncable platform resources
response
Response formatting utilities for agent tools

Structs§

AnalyzeTool
Tool to analyze a project
DclintTool
Tool to lint Docker Compose files natively
DiagnosticsTool
HadolintTool
Tool to lint Dockerfiles natively
HelmlintTool
Tool to lint Helm charts natively
K8sCostsTool
Tool for analyzing Kubernetes workload costs
K8sDriftTool
Tool for detecting Kubernetes configuration drift
K8sOptimizeTool
Tool for analyzing Kubernetes resource configurations
KubelintTool
Tool to lint Kubernetes manifests natively
ListDirectoryTool
ListOutputsTool
Tool to list all available stored outputs
PlanCreateTool
PlanListTool
PlanNextTool
PlanUpdateTool
PrometheusConnectTool
Tool for connecting to Prometheus
PrometheusDiscoverTool
Tool for discovering Prometheus in Kubernetes clusters
ReadFileTool
RetrieveOutputTool
Tool to retrieve detailed data from compressed tool outputs
SecurityScanTool
ShellTool
TerraformFmtTool
Tool to format Terraform configurations
TerraformInstallTool
Tool to install Terraform CLI
TerraformValidateTool
Tool to validate Terraform configurations
TruncationLimits
Configuration for output truncation limits
VulnerabilitiesTool
WebFetchTool
WriteFileTool
WriteFilesTool

Functions§

truncate_json_output
Truncate JSON output to fit within context limits. Intelligently summarizes large arrays and nested objects.