File Tools

Purpose

Complete file system operations for code and content management

Description

A comprehensive suite of file operations that enable agents to read, write, modify, and search through files in a secure sandbox environment.

Available Operations

View File or Directory

  • Purpose: Display file contents or list directory contents
  • Parameters:
    • path: File or directory path relative to sandbox
    • view_range: Optional array start_line, end_line for partial file viewing
  • Features: Supports both files and directories

Create File

  • Purpose: Generate new files with specified content
  • Parameters:
    • path: Target file path relative to sandbox
    • file_text: Complete content for the new file
  • Features: Creates parent directories if needed

String Replace

  • Purpose: Replace exact text matches in files
  • Parameters:
    • path: Target file path
    • old_str: Exact text to replace (including whitespace/indentation)
    • new_str: Replacement text
  • Features: Precise string matching with complete whitespace preservation

Insert Text

  • Purpose: Add text at specific line positions
  • Parameters:
    • path: Target file path
    • insert_line: Line number after which to insert (0 for beginning)
    • new_str: Text to insert
  • Features: Line-based insertion with automatic line numbering

Undo Edit

  • Purpose: Revert the last file modification
  • Parameters:
    • path: File path whose last edit should be undone
  • Features: Complete edit history tracking per file
  • Purpose: Advanced regex-based file content search
  • Parameters:
    • path: Directory to search
    • pattern: Regex pattern to match
    • caseSensitive: Boolean for case sensitivity (default: true)
    • includePattern: Glob pattern for file inclusion (e.g., "*.ts")
    • excludePattern: Glob pattern for file exclusion (e.g., "node_modules")
    • maxResults: Maximum results to return (default: 100)

Security Features

  • Operates within secure sandbox environment
  • All paths are relative to sandbox root
  • API key authentication with computer service
  • Isolated execution per chat session

Technical Implementation

  • Computer service integration via HTTP API
  • Authentication via JWT tokens or API keys
  • Support for both local development and production environments
  • Comprehensive error handling and reporting

Use Cases

  • Code analysis and modification
  • Documentation generation and updates
  • Project structure exploration
  • Content search and discovery
  • File-based data processing
  • Configuration management