Skip to content

Commit f6aaea5

Browse files
committed
refactor(fs_write): improve edit ordering and UI formatting
Implement improved edit ordering approach for fs_write tool: - Sort operations by type priority (Create/Rewrite first, line-based operations, string operations, append last) - Give ReplaceLines, DeleteLines, and Insert operations the same priority - Apply line-based operations from bottom to top to avoid line number shifting - Eliminate redundant line number adjustment logic Enhance UI formatting: - Use green ticks for successful operations - Use red exclamation marks for errors - Use neutral bullets for summary lines - Only color the symbols, not the text that follows them Update tool_index.json documentation to clearly explain the edit ordering approach and explicitly state that LLMs should not attempt to adjust line numbers. Document the approach in code-roast.md for future reference. 🤖 Assisted by [Amazon Q Developer](https://aws.amazon.com/q/developer)
1 parent e910513 commit f6aaea5

File tree

8 files changed

+2715
-593
lines changed

8 files changed

+2715
-593
lines changed

codebase-summary.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,34 @@ The **Amazon Q Developer CLI** is part of a monorepo that houses the core code f
66

77
## Key Components
88

9-
1. **q_cli**: The main CLI tool that allows users to interact with Amazon Q Developer from the command line
9+
1. **chat_cli**: The main CLI tool that allows users to interact with Amazon Q Developer from the command line
1010
2. **fig_desktop**: The Rust desktop application that uses tao/wry for windowing and webviews
1111
3. **Web Applications**: React apps for autocomplete functionality and dashboard interface
1212
4. **IDE Extensions**: VSCode, JetBrains, and GNOME extensions
13+
5. **MCP Client**: Model Context Protocol client for extending capabilities through external servers
1314

1415
## Project Structure
1516

1617
- `crates/` - Contains all internal Rust crates
18+
- `chat-cli/` - The main CLI implementation for Amazon Q chat
19+
- `fig_desktop/` - Desktop application implementation
20+
- `figterm/` - Terminal/pseudoterminal implementation
21+
- `semantic_search_client/` - Client for semantic search capabilities
1722
- `packages/` - Contains all internal npm packages
23+
- `autocomplete/` - Autocomplete functionality
24+
- `dashboard-app/` - Dashboard interface
1825
- `proto/` - Protocol buffer message specifications for inter-process communication
19-
- `extensions/` - IDE extensions
26+
- `extensions/` - IDE extensions for VSCode, JetBrains, and GNOME
2027
- `build-scripts/` - Python scripts for building, signing, and testing
2128
- `tests/` - Integration tests
29+
- `rfcs/` - Request for Comments documents for feature proposals
2230

2331
## Amazon Q Chat Implementation
2432

2533
### Core Components
2634

2735
1. **Chat Module Structure**
28-
- The chat functionality is implemented in the `q_cli/src/cli/chat` directory
36+
- The chat functionality is implemented in the `chat-cli/src/cli/chat` directory
2937
- Main components include conversation state management, input handling, response parsing, and tool execution
3038

3139
2. **User Interface**
@@ -72,6 +80,23 @@ The chat implementation includes a robust tool system that allows Amazon Q to in
7280
- The `/acceptall` command can toggle automatic acceptance for the session
7381
- Tool responses are limited to prevent excessive output (30KB limit)
7482

83+
### MCP (Model Context Protocol) Integration
84+
85+
1. **MCP Client**:
86+
- Implements the Model Context Protocol for extending Amazon Q's capabilities
87+
- Allows communication with external MCP servers that provide additional tools
88+
- Supports different transport mechanisms (stdio, websocket)
89+
90+
2. **MCP Server Discovery**:
91+
- Automatically discovers and connects to available MCP servers
92+
- Registers server-provided tools with the tool manager
93+
- Handles tool invocation routing to appropriate servers
94+
95+
3. **Custom Tool Integration**:
96+
- Enables third-party developers to extend Amazon Q with custom tools
97+
- Standardizes tool registration and invocation patterns
98+
- Provides error handling and response formatting
99+
75100
### Technical Implementation
76101

77102
1. **API Communication**:
@@ -94,4 +119,17 @@ The chat implementation includes a robust tool system that allows Amazon Q to in
94119
- Region checking for service availability
95120
- Telemetry for usage tracking
96121

97-
The implementation provides a seamless interface between the user and Amazon Q's AI capabilities, with powerful tools that allow the assistant to help with file operations, command execution, and AWS service interactions, all within a terminal-based chat interface.
122+
## Recent Developments
123+
124+
1. **Batch File Operations**:
125+
- RFC for enhancing fs_read and fs_write tools to support batch operations
126+
- Multi-file reading and writing in a single operation
127+
- Multiple edits per file with proper ordering to maintain line number integrity
128+
- Search/replace operations across files with wildcard patterns
129+
130+
2. **MCP Improvements**:
131+
- Enhanced Model Context Protocol implementation
132+
- Better support for external tool providers
133+
- Standardized tool registration and invocation
134+
135+
The implementation provides a seamless interface between the user and Amazon Q's AI capabilities, with powerful tools that allow the assistant to help with file operations, command execution, and AWS service interactions, all within a terminal-based chat interface.

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ const TRUST_ALL_TEXT: &str = color_print::cstr! {"<green!>All tools are now trus
286286
const TOOL_BULLET: &str = " ● ";
287287
const CONTINUATION_LINE: &str = " ⋮ ";
288288
const PURPOSE_ARROW: &str = " ↳ ";
289+
const SUCCESS_TICK: &str = " ✓ ";
290+
const ERROR_EXCLAMATION: &str = " ❗ ";
289291

290292
pub async fn launch_chat(database: &mut Database, telemetry: &TelemetryThread, args: cli::Chat) -> Result<ExitCode> {
291293
let trust_tools = args.trust_tools.map(|mut tools| {

crates/chat-cli/src/cli/chat/tools/execute_bash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl ExecuteBash {
122122
style::Print("\n"),
123123
style::ResetColor
124124
)?;
125-
125+
126126
// Add the summary if available
127127
super::queue_summary(self.summary.as_deref(), updates, Some(2))?;
128128

0 commit comments

Comments
 (0)