Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aeef799
Move docs generation files from fork to branch
Aug 25, 2025
80dbe74
Add credentials to docs generator
Aug 25, 2025
eb9734c
Reorder checkout step
Aug 25, 2025
c8be55f
Adding push trigger to run once
Aug 25, 2025
aa61cfc
Remove push trigger from workflow
Aug 25, 2025
2f7d5df
Re-add temporary push trigger
Aug 25, 2025
b842e74
Run setup with sudo for testing
Aug 25, 2025
6838c04
Add docs-specific setup script
Aug 25, 2025
9ab3587
Fix typo from dogs to docs
Aug 25, 2025
fc42b52
Add debug statements, fixed test PR number
Aug 25, 2025
faef1fe
Add trust all tools, exit with q chat exit code
Aug 25, 2025
5034f51
Add timeout for q chat
Aug 25, 2025
6d7cfd4
Uncomment PR generation, increase q chat timeout to 10m
Aug 25, 2025
9141f78
Ignore several patterns while reading PR
Aug 25, 2025
298ed66
Add print statements for debug, disable q chat run temporarily
Aug 25, 2025
07db3d0
Display only file diffs to q chat rather than entire file contents, c…
Aug 25, 2025
8760adc
Fetch main for file diffs
Aug 25, 2025
8a83eea
Try gh pr diff instead of manually getting diff
Aug 25, 2025
f9c7657
Remove debug statements, test full workflow
Aug 25, 2025
85d78fb
Trigger docs-generationn workflow 1
Aug 25, 2025
c7f7591
Test workflow 2; commit only docs
Aug 25, 2025
806f45d
Test workflow 3; run second time on existing PR/branch
Aug 25, 2025
27db585
Test workflow 4; run on already documented PR
Aug 25, 2025
514d034
Test workflow 5; reset instead of pull
Aug 25, 2025
4003996
Move PR number and branch name to env vars
Aug 25, 2025
e0e6c5a
Fix env error
Aug 25, 2025
810ded3
Try fetching before branch creation
Aug 25, 2025
106768f
Ignore pr-contents.txt
Aug 25, 2025
4a66c75
Exit gracefully if no changes have been made
Aug 25, 2025
7cb9b70
Test workflow after deleting old branch
Aug 25, 2025
60e5f54
Test workflow fresh
Aug 25, 2025
097149c
Update docs based on PR #2533
Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/docs-generator.yaml
Original file line number Diff line number Diff line change
@@ -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






24 changes: 24 additions & 0 deletions docs-generation/create-docs-pr.sh
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions docs-generation/read-pr.sh
Original file line number Diff line number Diff line change
@@ -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






54 changes: 54 additions & 0 deletions docs-generation/setup_amazon_q.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions docs-generation/update-docs.sh
Original file line number Diff line number Diff line change
@@ -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 $?
2 changes: 2 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
24 changes: 24 additions & 0 deletions docs/built-in-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
115 changes: 115 additions & 0 deletions docs/slash-commands.md
Original file line number Diff line number Diff line change
@@ -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.
Loading