aws / aws/amazon-q-developer-cli

Feature request: Interactive fs_write

Open
#1,896 0 comments 1 reaction 0 assignees View on GitHub
tools
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

# Feature Request: Interactive fs_write

## Overview

I'd like to propose adding an interactive file editing feature to the Amazon Q CLI's fs_write tool. This feature
would allow users to edit the changes proposed by the LLM before they are applied to the target file, providing a
more collaborative and efficient workflow.

## Why It's Useful

Currently, when Amazon Q suggests file changes using the fs_write tool, users have only three options:
1. Accept the changes as-is (y)
2. Reject the changes entirely (n)
3. Trust the tool to make future changes without confirmation (t)

This creates a frustrating experience when the LLM's suggestion is almost right but needs minor adjustments. Users
must either:
• Accept incorrect changes and fix them afterward
• Reject good changes because of small issues
• Engage in another conversation round to get the LLM to refine its suggestion

An interactive editing option would significantly improve user experience by:
• Reducing the number of conversation turns needed to get the right code
• Saving time and tokens by avoiding additional LLM calls
• Creating a more collaborative feeling between the user and Amazon Q
• Leveraging the user's expertise to fine-tune AI-generated code

## Expected User Experience

When Amazon Q proposes a file change:

1. The user would see a new "e" (edit) option in the approval prompt:
```
Do you want to run this tool? [y/n/e/t] (e=edit, t=trust)
```

2. If the user selects "e", their configured editor would launch with:
• For existing files: A diff view showing both the original file and the proposed changes
• For new files: Just the proposed content

3. The user can make any desired edits to the proposed changes

4. Upon saving and exiting the editor:
• If exit code is 0: The edited changes are applied to the target file
• If exit code is non-zero: The operation is canceled

5. Amazon Q is informed about the user's edits, allowing it to understand and work with the modified content in
subsequent interactions

## Technical Behavior

The implementation would:

1. Add a new ChatDiffEditor setting to store the diff editor command
2. Detect editors that support diff mode (vim -d, code --diff, etc.)
3. Create temporary files for both original and modified content
4. Launch the appropriate editor based on configuration
5. Process the edited content and apply it to the target file
6. Communicate the final changes back to the LLM

## Future Enhancements

Once the basic functionality is in place, we could consider:

1. Editor Configuration UI: Add a command to configure the diff editor preferences
2. Binary File Support: Add support for editing binary files with appropriate editors
3. Enhanced Diff Visualization: Improve diff visualization for complex changes
4. Syntax Highlighting: Ensure proper syntax highlighting in the diff view
5. Selective Editing: Allow users to choose which parts of a multi-file change to edit

## Implementation Complexity

This feature builds on existing infrastructure and should be relatively straightforward to implement:
• Leverages the existing fs_write tool approval flow
• Uses standard editor invocation patterns
• Follows established patterns for temporary file handling
• Requires minimal changes to the LLM communication protocol

## Conclusion

Adding an interactive editing option to the fs_write tool would significantly enhance the collaborative experience
between users and Amazon Q, making the CLI more powerful and user-friendly. It addresses a common pain point in the
current workflow and would likely increase user satisfaction and productivity.

---
🤖 Assisted by Amazon Q CLI

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.