aws / aws/amazon-q-developer-cli

Implement Batch File Operations Feature

Open
#1,773 1 comment 0 reactions 0 assignees View on GitHub
enhancement RFC rust
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

## Overview

This issue tracks the implementation of the batch file operations feature as proposed in [RFC PR #1772](https://github.com/aws/amazon-q-developer-cli/pull/1772).

## Feature Description

Enhance the fs_read and fs_write tools to support batch operations on multiple files in a single call, with the ability to perform multiple edits per file, maintain line number integrity through proper edit ordering, and perform search/replace operations across files in a folder using wildcard patterns with sed-like syntax.

## Implementation Phases

The implementation will be broken down into three distinct phases:

### Phase 1: fs_read Batch Operations
- Add the `paths` parameter to fs_read
- Implement batch processing logic for multiple files
- Update the response format to include content_hash and last_modified timestamp
- Add comprehensive error handling for batch operations
- Add tests for the new functionality

### Phase 2: Pattern Replacement for fs_write
- Add the `pattern_replace` command to fs_write
- Integrate the sd crate for sed-like functionality
- Implement file pattern matching with glob/globset
- Add support for recursive directory traversal
- Add tests for pattern replacement functionality

### Phase 3: Multi-File Operations for fs_write
- Add the `fileEdits` parameter to fs_write
- Implement edit ordering logic for maintaining line number integrity
- Add the `replace_lines` command with content hash verification for safety
- Update the response format to handle multiple file results with detailed error reporting
- Add tests for multi-file operations and multiple edits per file

## Dependencies

- Approval of RFC PR #1772
- Addition of the sd crate as a dependency
- Addition of glob/globset for file pattern matching

## Acceptance Criteria

- All phases implemented and tested
- Documentation updated to reflect new functionality
- Examples provided for common use cases
- Performance impact assessed and optimized

🤖 Assisted by [Amazon Q Developer](https://aws.amazon.com/q/developer)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.