diff --git a/.cargo/config.toml b/.cargo/config.toml index 2f845d29ef..eb7272be10 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,10 +1,6 @@ [target.x86_64-pc-windows-msvc] -rustflags = [ - "-C", "link-arg=/STACK:8000000" -] +rustflags = ["-C", "link-arg=/STACK:8000000"] # 64 bit Mingw [target.x86_64-pc-windows-gnu] -rustflags = [ - "-C", "link-arg=-Wl,--stack,8000000" -] \ No newline at end of file +rustflags = ["-C", "link-arg=-Wl,--stack,8000000"] diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index d9be0efe1c..0000000000 --- a/Cross.toml +++ /dev/null @@ -1,13 +0,0 @@ -[build] -pre-build = ["apt-get update && apt-get --assume-yes install unzip zsh"] - -[build.env] -passthrough = [ - "AMAZON_Q_BUILD_TARGET_TRIPLE", - "AMAZON_Q_BUILD_VARIANT", - "AMAZON_Q_BUILD_HASH", - "AMAZON_Q_BUILD_DATETIME", - "AMAZON_Q_BUILD_SKIP_FISH_TESTS", - "AMAZON_Q_BUILD_SKIP_SHELLCHECK_TESTS", - "Q_TELEMETRY_CLIENT_ID", -] diff --git a/codebase-summary.md b/codebase-summary.md deleted file mode 100644 index f8fbb2a2ca..0000000000 --- a/codebase-summary.md +++ /dev/null @@ -1,97 +0,0 @@ -# Amazon Q Developer CLI Codebase Summary - -## Overview - -The **Amazon Q Developer CLI** is part of a monorepo that houses the core code for the Amazon Q Developer desktop application and command-line interface. Amazon Q Developer is an AI assistant built by AWS to help developers with various tasks. - -## Key Components - -1. **q_cli**: The main CLI tool that allows users to interact with Amazon Q Developer from the command line -2. **fig_desktop**: The Rust desktop application that uses tao/wry for windowing and webviews -3. **Web Applications**: React apps for autocomplete functionality and dashboard interface -4. **IDE Extensions**: VSCode, JetBrains, and GNOME extensions - -## Project Structure - -- `crates/` - Contains all internal Rust crates -- `packages/` - Contains all internal npm packages -- `proto/` - Protocol buffer message specifications for inter-process communication -- `extensions/` - IDE extensions -- `build-scripts/` - Python scripts for building, signing, and testing -- `tests/` - Integration tests - -## Amazon Q Chat Implementation - -### Core Components - -1. **Chat Module Structure** - - The chat functionality is implemented in the `q_cli/src/cli/chat` directory - - Main components include conversation state management, input handling, response parsing, and tool execution - -2. **User Interface** - - Provides an interactive terminal-based chat interface - - Uses `rustyline` for command-line input with features like history, completion, and highlighting - - Displays a welcome message with usage suggestions and available commands - - Supports special commands like `/help`, `/quit`, `/clear`, and `/acceptall` - -3. **Conversation Management** - - `ConversationState` class maintains the chat history and context - - Tracks user messages, assistant responses, and tool executions - - Manages conversation history with a maximum limit (100 messages) - - Preserves environmental context like working directory and shell state - -4. **Input Handling** - - `InputSource` handles reading user input with support for multi-line inputs - - `Command` parser interprets user input as questions, commands, or special commands - - Supports command completion for special commands like `/help` and `/clear` - -5. **Response Parsing** - - `ResponseParser` processes streaming responses from the Amazon Q service - - Handles markdown formatting and syntax highlighting - - Manages tool use requests from the assistant - -### Tool Integration - -The chat implementation includes a robust tool system that allows Amazon Q to interact with the user's environment: - -1. **Available Tools**: - - `fs_read`: Reads files or lists directories (similar to `cat` or `ls`) - - `fs_write`: Creates or modifies files with various operations (create, append, replace) - - `execute_bash`: Executes shell commands in the user's environment - - `use_aws`: Makes AWS CLI API calls with specified services and operations - -2. **Tool Execution Flow**: - - Amazon Q requests to use a tool via the API - - The CLI parses the request and validates parameters - - The tool is executed with appropriate permissions checks - - Results are returned to Amazon Q for further processing - - The conversation continues with the tool results incorporated - -3. **Security Considerations**: - - Tools that modify the system (like `fs_write` and `execute_bash`) require user confirmation - - The `/acceptall` command can toggle automatic acceptance for the session - - Tool responses are limited to prevent excessive output (30KB limit) - -### Technical Implementation - -1. **API Communication**: - - Uses a streaming client to communicate with the Amazon Q service - - Handles asynchronous responses and tool requests - - Manages timeouts and connection errors - -2. **Display Formatting**: - - Uses `crossterm` for terminal control and styling - - Implements markdown parsing and syntax highlighting - - Displays spinners during processing - -3. **Error Handling**: - - Comprehensive error types and handling for various failure scenarios - - Graceful degradation when services are unavailable - - Signal handling for user interruptions - -4. **Configuration**: - - Respects user settings for editor mode (vi/emacs) - - Region checking for service availability - - Telemetry for usage tracking - -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. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d3272528fa..70e8447f21 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.84.0" +channel = "1.87.0" profile = "minimal" components = ["rustfmt", "clippy"] targets = [ diff --git a/scripts/const.py b/scripts/const.py index 8f3b19dcdd..2072e0e903 100644 --- a/scripts/const.py +++ b/scripts/const.py @@ -1,32 +1,3 @@ -import pathlib - - -APP_NAME = "Amazon Q" -CLI_BINARY_NAME = "q" -CHAT_BINARY_NAME = "qchat" -PTY_BINARY_NAME = "qterm" -DESKTOP_BINARY_NAME = "q-desktop" -URL_SCHEMA = "q" -TAURI_PRODUCT_NAME = "q_desktop" -LINUX_PACKAGE_NAME = "amazon-q" - -# macos specific -MACOS_BUNDLE_ID = "com.amazon.codewhisperer" -DMG_NAME = APP_NAME - -# Linux specific -LINUX_ARCHIVE_NAME = "q" -LINUX_LEGACY_GNOME_EXTENSION_UUID = "amazon-q-for-cli-legacy-gnome-integration@aws.amazon.com" -LINUX_MODERN_GNOME_EXTENSION_UUID = "amazon-q-for-cli-gnome-integration@aws.amazon.com" - -# cargo packages -CLI_PACKAGE_NAME = "q_cli" +CHAT_BINARY_NAME = "q" CHAT_PACKAGE_NAME = "chat_cli" -PTY_PACKAGE_NAME = "figterm" -DESKTOP_PACKAGE_NAME = "fig_desktop" -DESKTOP_FUZZ_PACKAGE_NAME = "fig_desktop-fuzz" - -DESKTOP_PACKAGE_PATH = pathlib.Path("crates", "fig_desktop") - -# AMZN Mobile LLC APPLE_TEAM_ID = "94KV3E626L" diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100644 index fc1d13481c..0000000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash - -set -e - -OS="$(uname -s)" - -install_linux_deps() { - if [ -f /etc/debian_version ]; then - echo "Detected Debian/Ubuntu" - sudo apt update - sudo apt install build-essential pkg-config jq dpkg curl wget cmake clang libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libdbus-1-dev libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev valac libibus-1.0-dev libglib2.0-dev sqlite3 libxdo-dev protobuf-compiler - elif [ -f /etc/arch-release ]; then - echo "Detected Arch" - sudo pacman -Syu --noconfirm - sudo pacman -S --noconfirm --needed webkit2gtk base-devel curl wget openssl appmenu-gtk-module gtk3 libappindicator-gtk3 librsvg libvips cmake jq pkgconf - elif [ -f /etc/fedora-release ]; then - echo "Detected Fedora" - sudo dnf check-update - sudo dnf install -y webkit2gtk3-devel.x86_64 openssl-devel curl wget libappindicator-gtk3 librsvg2-devel jq - sudo dnf group install -y "C Development Tools and Libraries" - else - echo "Unsupported Linux distribution. Check the docs for manual installation instructions." - exit 1 - fi -} - -install_macos_deps() { - echo "Detected macOS" - xcode-select --install || true - brew install mise pnpm protobuf zsh bash fish shellcheck jq -} - -install_rust() { - echo "Installing Rust toolchain..." - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - # Detect shell and source the correct env file - - SHELL_NAME=$(basename "$SHELL") - case "$SHELL_NAME" in - fish) - source "$HOME/.cargo/env.fish" - ;; - nu) - source "$HOME/.cargo/env.nu" - ;; - *) - . "$HOME/.cargo/env" - ;; - esac - - rustup default stable - rustup toolchain install nightly - cargo install typos-cli - - if [[ "$OS" == "Darwin" ]]; then - rustup target add x86_64-apple-darwin - rustup target add aarch64-apple-darwin - fi -} -add_mise_to_shell() { - echo "Adding mise integration to shell..." - - SHELL_NAME=$(basename "$SHELL") - - case "$SHELL_NAME" in - zsh) - ZSHRC="${ZDOTDIR:-$HOME}/.zshrc" - grep -qxF 'eval "$(mise activate zsh)"' "$ZSHRC" || echo 'eval "$(mise activate zsh)"' >> "$ZSHRC" - ;; - bash) - BASHRC="$HOME/.bashrc" - grep -qxF 'eval "$(mise activate bash)"' "$BASHRC" || echo 'eval "$(mise activate bash)"' >> "$BASHRC" - ;; - fish) - FISH_CONFIG="$HOME/.config/fish/config.fish" - mkdir -p "$(dirname "$FISH_CONFIG")" - grep -qxF 'mise activate fish | source' "$FISH_CONFIG" || echo 'mise activate fish | source' >> "$FISH_CONFIG" - ;; - *) - echo "⚠️ Unknown shell '$SHELL_NAME'. Please add mise manually to your shell config." - ;; - esac -} - -setup_mise() { - echo "Installing Python and Node with mise..." - add_mise_to_shell - mise trust - mise install -} - -setup_precommit() { - echo "Installing pre-commit hooks..." - pnpm install --ignore-scripts -} - -echo "Setting up project dependencies..." - -if [[ "$OS" == "Linux" ]]; then - install_linux_deps -elif [[ "$OS" == "Darwin" ]]; then - install_macos_deps -else - echo "Unsupported OS: $OS" - exit 1 -fi - -install_rust -setup_mise -setup_precommit - -echo "✅ Setup complete! Follow the instructions in the README to get started."