diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml new file mode 100644 index 0000000000..48ed0c861b --- /dev/null +++ b/.github/workflows/docs-generator.yaml @@ -0,0 +1,66 @@ +name: docs-generator + +on: + # workflow_dispatch: + # inputs: + # pr_number: + # description: 'Number of PR to document' + # required: true + # type: string + push: + +jobs: + generate_docs: + runs-on: ubuntu-latest + env: + AMAZON_Q_SIGV4: 1 + CHAT_DOWNLOAD_ROLE_ARN: ${{ secrets.CHAT_DOWNLOAD_ROLE_ARN }} + CHAT_BUILD_BUCKET_NAME: ${{ secrets.CHAT_BUILD_BUCKET_NAME }} + PR_FILE: "pr-contents.txt" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_HASH: "latest" + PR_NUMBER: 2533 + BRANCH_NAME: "docs-update-for-pr-2533" + permissions: + id-token: write + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Fetch main branch + run: git fetch origin main:main + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_TB_ROLE }} + aws-region: us-east-1 + + - name: Make scripts executable + run: | + chmod +x docs-generation/setup_amazon_q.sh + chmod +x docs-generation/create-docs-pr.sh + chmod +x docs-generation/read-pr.sh + chmod +x docs-generation/update-docs.sh + + - name: Run setup script + run: bash docs-generation/setup_amazon_q.sh + + - name: Generate PR contents file + run: bash docs-generation/read-pr.sh + + - name: Update docs + run: bash docs-generation/update-docs.sh + + - name: Create PR + if: success() + run: bash docs-generation/create-docs-pr.sh + + + + + + \ No newline at end of file diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh new file mode 100755 index 0000000000..c9ed647866 --- /dev/null +++ b/docs-generation/create-docs-pr.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +git config user.name "docs-generator[bot]" +git config user.email "docs-generator[bot]@amazon.com" + +# Push (branch should have already been created in update-docs.sh) +git add docs +if git diff --cached --quiet; then + echo "No changes to commit" + exit 0 +fi +git commit -m "Update docs based on PR #$PR_NUMBER + +Auto-generated by Q" + +git push -u origin "$BRANCH_NAME" + +# Create PR +gh pr create \ + --title "Update docs based on PR #$PR_NUMBER" \ + --body "Auto-generated documentation updates based on changes in PR #$PR_NUMBER" \ + --base main \ + --head "$BRANCH_NAME" diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh new file mode 100755 index 0000000000..5e59343ea7 --- /dev/null +++ b/docs-generation/read-pr.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +# Add PR information +echo "====== PR Information ======\n" > $PR_FILE +gh pr view $PR_NUMBER --json title,body --jq '"Title: " + .title + "\nDescription: " + .body' >> $PR_FILE + +# Include PR diffs +echo -e "\n====== PR Diffs ======\n" >> $PR_FILE +gh pr diff $PR_NUMBER >> $PR_FILE + + + + + + \ No newline at end of file diff --git a/docs-generation/setup_amazon_q.sh b/docs-generation/setup_amazon_q.sh new file mode 100644 index 0000000000..e5c2c923ee --- /dev/null +++ b/docs-generation/setup_amazon_q.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -e +# if git hash empty then set to latest auto +sudo apt-get update +sudo apt-get install -y curl wget unzip jq + +# Create AWS credentials from environment variables +mkdir -p ~/.aws +cat > ~/.aws/credentials << EOF +[default] +aws_access_key_id = ${AWS_ACCESS_KEY_ID} +aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY} +aws_session_token = ${AWS_SESSION_TOKEN} +EOF +chmod 600 ~/.aws/credentials + +cat > ~/.aws/config << EOF +[default] +region = us-east-1 +EOF +chmod 600 ~/.aws/config + +# Assume role and capture temporary credentials --> needed for s3 bucket access for build +echo "Assuming AWS s3 role" +TEMP_CREDENTIALS=$(aws sts assume-role --role-arn ${CHAT_DOWNLOAD_ROLE_ARN} --role-session-name S3AccessSession 2>/dev/null || echo '{}') +QCHAT_ACCESSKEY=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.AccessKeyId') +Q_SECRET_ACCESS_KEY=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.SecretAccessKey') +Q_SESSION_TOKEN=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.SessionToken') + +# Download specific build from S3 based on commit hash +echo "Downloading Amazon Q CLI build from S3..." +S3_PREFIX="main/${GIT_HASH}/x86_64-unknown-linux-musl" +echo "Downloading qchat.zip from s3://.../${S3_PREFIX}/qchat.zip" + +# Try download, if hash is invalid we fail. +AWS_ACCESS_KEY_ID="$QCHAT_ACCESSKEY" AWS_SECRET_ACCESS_KEY="$Q_SECRET_ACCESS_KEY" AWS_SESSION_TOKEN="$Q_SESSION_TOKEN" \ + aws s3 cp s3://${CHAT_BUILD_BUCKET_NAME}/${S3_PREFIX}/qchat.zip ./qchat.zip --region us-east-1 + +# Handle the zip file, copy the qchat executable to /usr/local/bin + symlink from old code +echo "Extracting qchat.zip..." +unzip -q qchat.zip + +# move it to /usr/local/bin/qchat for path as qchat may not work otherwise +if cp qchat /usr/local/bin/ && chmod +x /usr/local/bin/qchat; then + ln -sf /usr/local/bin/qchat /usr/local/bin/q + echo "qchat installed successfully" +else + echo "ERROR: Failed to install qchat" + exit 1 +fi + +echo "Cleaning q zip" +rm -f qchat.zip +rm -rf qchat diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh new file mode 100755 index 0000000000..c78e3b6f87 --- /dev/null +++ b/docs-generation/update-docs.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +if [ ! -f "$PR_FILE" ]; then + echo "PR file not found, aborting" + exit 1 +fi + +# Create branch before making any changes +git fetch origin +git checkout -B "$BRANCH_NAME" +if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then + git reset --hard "origin/$BRANCH_NAME" +fi + +PROMPT="Before making any changes, read the 'docs' directory for the project's current +documentation. Then read 'pr-contents.txt' to see the contents of the current PR.\n\n +After reading both the directory and the PR file, update the files in the 'docs' directory +with new, concise documentation reflecting ONLY the proposed changes in the PR. Make new files as appropriate. +Do not document changes or functionalities not related to the PR." + +timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +exit $? \ No newline at end of file diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 0fc45bba3d..c38b1ca19d 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -4,5 +4,7 @@ - [The Agent Format](./agent-format.md) - [Built-in Tools](./built-in-tools.md) +- [Slash Commands](./slash-commands.md) +- [To-Do List Functionality](./todo-list-functionality.md) - [Knowledge Management](./knowledge-management.md) - [Profile to Agent Migration](./legacy-profile-to-agent-migration.md) diff --git a/docs/built-in-tools.md b/docs/built-in-tools.md index 49aaf5d715..03eb8f4581 100644 --- a/docs/built-in-tools.md +++ b/docs/built-in-tools.md @@ -8,6 +8,7 @@ Amazon Q CLI includes several built-in tools that agents can use. This document - [`report_issue`](#report_issue-tool) — Open a GitHub issue template. - [`knowledge`](#knowledge-tool) — Store and retrieve information in a knowledge base. - [`thinking`](#thinking-tool) — Internal reasoning mechanism. +- [`todo_list`](#todo_list-tool) — Create and manage to-do lists for multi-step tasks. - [`use_aws`](#use_aws-tool) — Make AWS CLI API calls. ## Execute_bash Tool @@ -102,6 +103,29 @@ An internal reasoning mechanism that improves the quality of complex tasks by br This tool has no configuration options. +## Todo_list Tool + +A tool for creating and managing to-do lists for multi-step tasks. This tool is automatically used by Q when handling complex requests that require multiple steps. + +### Key Features +- **Automatic creation**: Q creates to-do lists for multi-step tasks before beginning work +- **Progress tracking**: Tasks are marked as completed as Q works through them +- **Context preservation**: Important information and modified files are tracked +- **Persistence**: To-do lists are saved locally and can be resumed across sessions + +### Commands +The tool supports five main commands: +- `create` - Create a new to-do list with tasks and description +- `complete` - Mark tasks as completed and update context +- `load` - Load an existing to-do list by ID +- `add` - Add new tasks to an existing to-do list +- `remove` - Remove tasks from an existing to-do list + +### Storage +To-do lists are stored locally in `.amazonq/cli-todo-lists/` within the current working directory. + +This tool has no configuration options and is trusted by default. + ## Use_aws Tool Make AWS CLI API calls with the specified service, operation, and parameters. diff --git a/docs/slash-commands.md b/docs/slash-commands.md new file mode 100644 index 0000000000..48b5c18f2b --- /dev/null +++ b/docs/slash-commands.md @@ -0,0 +1,115 @@ +# Slash Commands + +Slash commands provide quick access to specific Q CLI functionality during chat sessions. Commands are prefixed with `/` and can be used at any time during a conversation. + +## New: To-Do List Management (`/todos`) + +The `/todos` command allows you to view, manage, and resume to-do lists created by Q during multi-step tasks. + +### `/todos resume` +Select and resume work on an existing to-do list. Q will load the selected list and continue working on incomplete tasks. + +**Usage:** +``` +/todos resume +``` + +Opens an interactive selector showing all available to-do lists with their completion status: +- ✓ (green) indicates completed to-do lists +- ✗ (red) indicates in-progress to-do lists with completion count (e.g., "2/5") + +### `/todos view` +View the contents of a to-do list without resuming work on it. + +**Usage:** +``` +/todos view +``` + +Displays the selected to-do list with: +- Task descriptions +- Completion status (☐ for incomplete, ■ for complete) +- Overall progress + +### `/todos delete` +Delete one or more to-do lists. + +**Usage:** +``` +/todos delete # Delete a single selected to-do list +/todos delete --all # Delete all to-do lists +``` + +The `--all` flag will delete all to-do lists without prompting for selection. + +### `/todos clear-finished` +Remove all completed to-do lists (where all tasks are marked as complete). + +**Usage:** +``` +/todos clear-finished +``` + +This command automatically identifies and removes only fully completed to-do lists, leaving in-progress lists intact. + +## Other Available Commands + +Q CLI includes many other slash commands for various functionality: + +### Basic Commands +- `/help` - Show help information +- `/clear` - Clear the conversation +- `/quit` - Exit the chat session + +### Agent Management +- `/agent` - Agent-related commands +- `/agent list` - List available agents +- `/agent create` - Create a new agent +- `/agent delete` - Delete an agent + +### Tool Management +- `/tools` - Show available tools +- `/tools trust` - Trust specific tools +- `/tools untrust` - Untrust specific tools + +### Context Management +- `/context` - Context-related commands +- `/context show` - Show current context +- `/context add` - Add context +- `/context clear` - Clear context + +### Session Management +- `/save` - Save current conversation +- `/load` - Load a saved conversation +- `/compact` - Compact conversation history + +### Other Features +- `/model` - Model selection +- `/usage` - Show usage information +- `/subscribe` - Subscription management + +## Interactive Selection + +Most `/todos` commands use an interactive fuzzy selector that allows you to: +- Type to filter to-do lists by description +- Use arrow keys to navigate +- Press Enter to select +- Press Escape to cancel + +The selector displays to-do lists with their completion status and description for easy identification. + +## Integration with Q's Workflow + +- Q automatically creates to-do lists when given multi-step tasks +- To-do lists persist across chat sessions +- Use `/todos resume` to continue interrupted work +- To-do list IDs are included in conversation summaries for seamless resumption + +## Storage Location + +To-do lists are stored locally in: +``` +.amazonq/cli-todo-lists/ +``` + +This directory is created automatically in your current working directory when needed. diff --git a/docs/todo-list-functionality.md b/docs/todo-list-functionality.md new file mode 100644 index 0000000000..3f7fecf19a --- /dev/null +++ b/docs/todo-list-functionality.md @@ -0,0 +1,169 @@ +# To-Do List Functionality + +Amazon Q CLI includes built-in to-do list functionality that allows Q to create, manage, and track multi-step tasks. This feature helps organize complex workflows and provides persistence across chat sessions. + +## Overview + +The to-do list functionality consists of two main components: + +1. **`todo_list` tool** - A built-in tool that Q uses to create and manage to-do lists +2. **`/todos` slash command** - User commands for viewing and managing existing to-do lists + +## The todo_list Tool + +The `todo_list` tool is automatically available to all agents and is trusted by default. Q uses this tool to: + +- Create structured to-do lists for multi-step tasks +- Mark tasks as completed as work progresses +- Track context and modified files for each task +- Load and resume existing to-do lists + +### Tool Commands + +#### `create` +Creates a new to-do list with specified tasks and description. + +**Parameters:** +- `tasks` (required): Array of distinct task descriptions +- `todo_list_description` (required): Brief summary of the to-do list + +#### `complete` +Marks tasks as completed and updates context. + +**Parameters:** +- `completed_indices` (required): Array of 0-indexed task numbers to mark complete +- `context_update` (required): Important context about completed tasks +- `modified_files` (optional): Array of file paths that were modified +- `current_id` (required): ID of the currently loaded to-do list + +#### `load` +Loads an existing to-do list by ID. + +**Parameters:** +- `load_id` (required): ID of the to-do list to load + +#### `add` +Adds new tasks to an existing to-do list. + +**Parameters:** +- `new_tasks` (required): Array of new task descriptions +- `insert_indices` (required): Array of 0-indexed positions to insert tasks +- `new_description` (optional): Updated description for the to-do list +- `current_id` (required): ID of the currently loaded to-do list + +#### `remove` +Removes tasks from an existing to-do list. + +**Parameters:** +- `remove_indices` (required): Array of 0-indexed positions of tasks to remove +- `new_description` (optional): Updated description for the to-do list +- `current_id` (required): ID of the currently loaded to-do list + +### Tool Behavior + +- Q automatically creates to-do lists when given multi-step tasks +- Tasks are marked as completed immediately after Q finishes each step +- The tool displays progress visually with checkboxes (☐ for incomplete, ■ for complete) +- To-do lists are stored locally in `.amazonq/cli-todo-lists/` +- Each to-do list has a unique timestamp-based ID + +## User Commands (/todos) + +Users can manage their to-do lists using the `/todos` slash command with various subcommands. + +### `/todos resume` + +Allows you to select and resume work on an existing to-do list. Q will load the selected list and continue working on incomplete tasks. + +**Usage:** +``` +/todos resume +``` + +This opens an interactive selector showing all available to-do lists with their completion status. + +### `/todos view` + +View the contents of a to-do list without resuming work on it. + +**Usage:** +``` +/todos view +``` + +This opens an interactive selector and displays the selected to-do list with all tasks and their completion status. + +### `/todos delete` + +Delete one or more to-do lists. + +**Usage:** +``` +/todos delete # Delete a single selected to-do list +/todos delete --all # Delete all to-do lists +``` + +### `/todos clear-finished` + +Remove all completed to-do lists (where all tasks are marked as complete). + +**Usage:** +``` +/todos clear-finished +``` + +## Storage and Persistence + +### Local Storage +To-do lists are stored locally in the current working directory under: +``` +.amazonq/cli-todo-lists/ +``` + +Each to-do list is saved as a JSON file named with its unique ID (e.g., `1693234567890.json`). + +### Data Structure +Each to-do list contains: +- **tasks**: Array of task descriptions +- **completed**: Array of boolean values indicating completion status +- **description**: Brief summary of the to-do list +- **context**: Array of context updates from completed tasks +- **modified_files**: Array of file paths that were modified during task execution +- **id**: Unique identifier for the to-do list + +### Conversation Integration +To-do list IDs are automatically included in conversation summaries, allowing Q to resume work on to-do lists when conversations are loaded from history. + +## Best Practices + +### For Users +- Use `/todos resume` to continue work on incomplete tasks +- Regularly use `/todos clear-finished` to clean up completed lists +- Use `/todos view` to check progress without resuming work + +### For Q's Usage +- Create to-do lists for any multi-step task before beginning work +- Mark tasks as completed immediately after finishing each step +- Provide meaningful context updates when completing tasks +- Track modified files to maintain a record of changes + +## Example Workflow + +1. User asks Q to implement a new feature +2. Q creates a to-do list with steps like: + - Analyze requirements + - Create necessary files + - Implement core functionality + - Add tests + - Update documentation +3. Q works through tasks, marking each as complete with context +4. User can check progress with `/todos view` +5. If interrupted, user can resume with `/todos resume` +6. When finished, user can clean up with `/todos clear-finished` + +## Limitations + +- To-do lists are stored locally and not synchronized across different working directories +- The interactive selectors require terminal support for user input +- Very long task descriptions may be truncated in the display +- No built-in backup or export functionality for to-do lists