Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
65 changes: 65 additions & 0 deletions .github/workflows/docs-generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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"
TEST_PR_NUMBER: 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 ${{ env.TEST_PR_NUMBER }}

- name: Update docs
run: bash docs-generation/update-docs.sh

- name: Create PR
if: success()
run: bash docs-generation/create-docs-pr.sh ${{ env.TEST_PR_NUMBER }}






33 changes: 33 additions & 0 deletions docs-generation/create-docs-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -e

PR_NUMBER=$1
BRANCH_NAME="docs-update-for-pr-$PR_NUMBER"

# Ensure we have changes to merge
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
exit 0
fi

git config user.name "docs-generator[bot]"
git config user.email "docs-generator[bot]@amazon.com"

# Create branch, pull if needed (for updating existing docs PRs), and push
git checkout -B "$BRANCH_NAME"
if git ls-remote --exit-code --heads origin $BRANCH_NAME; then
git pull origin $BRANCH_NAME
fi
git add docs
git commit -m "Update docs based on PR #$PR_NUMBER

Auto-generated by Q"

git push 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"
18 changes: 18 additions & 0 deletions docs-generation/read-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

PR_NUMBER=$1

# 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
15 changes: 15 additions & 0 deletions docs-generation/update-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

if [ ! -f "$PR_FILE" ]; then
echo "PR file not found, aborting"
exit 1
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 documentation reflecting the proposed changes in the PR. Make new files as appropriate."

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 Quick Reference](./todo-quick-reference.md)
- [Knowledge Management](./knowledge-management.md)
- [Profile to Agent Migration](./legacy-profile-to-agent-migration.md)
79 changes: 78 additions & 1 deletion docs/built-in-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Amazon Q CLI includes several built-in tools that agents can use. This document
- [`knowledge`](#knowledge-tool) — Store and retrieve information in a knowledge base.
- [`thinking`](#thinking-tool) — Internal reasoning mechanism.
- [`use_aws`](#use_aws-tool) — Make AWS CLI API calls.
- [`todo_list`](#todo_list-tool) — Create and manage to-do lists.

## Execute_bash Tool

Expand Down Expand Up @@ -126,6 +127,82 @@ Make AWS CLI API calls with the specified service, operation, and parameters.
| `allowedServices` | array of strings | `[]` | List of AWS services that can be accessed without prompting |
| `deniedServices` | array of strings | `[]` | List of AWS services to deny. Deny rules are evaluated before allow rules |

## Todo_list Tool

Create and manage to-do lists that persist across chat sessions. This tool allows Amazon Q to break down complex tasks into manageable steps and track progress as tasks are completed.

### Key Features

- **Automatic Task Creation**: Q automatically creates to-do lists when given multi-step tasks
- **Progress Tracking**: Tasks are marked as completed as Q works through them
- **Persistent Storage**: To-do lists are saved locally and persist across sessions
- **Context Tracking**: Important information and modified files are tracked with each task
- **Resume Functionality**: Users can resume incomplete to-do lists from previous sessions

### 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 information.

**Parameters:**
- `completed_indices` (required): Array of 0-indexed task numbers to mark as 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

### Storage Location

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 with a timestamp-based ID.

### Usage Patterns

**Automatic Creation**: When you give Q a complex task, it will automatically create a to-do list before starting work:
```
User: "Set up a new React project with TypeScript and testing"
Q: [Creates to-do list with steps like "Initialize project", "Configure TypeScript", "Set up testing framework", etc.]
```

**Progress Tracking**: Q marks tasks as completed immediately after finishing them, providing visual feedback on progress.

**Context Preservation**: Each completed task includes context about what was accomplished and which files were modified, helping maintain continuity across sessions.

This tool has no configuration options and is trusted by default.

## Using Tool Settings in Agent Configuration

Tool settings are specified in the `toolsSettings` section of the agent configuration file. Each tool's settings are specified using the tool's name as the key.
Expand Down Expand Up @@ -162,5 +239,5 @@ Tools can be explicitly allowed in the `allowedTools` section of the agent confi
If a tool is not in the `allowedTools` list, the user will be prompted for permission when the tool is used unless an allowed `toolSettings` configuration is set.

Some tools have default permission behaviors:
- `fs_read` and `report_issue` are trusted by default
- `fs_read`, `report_issue`, and `todo_list` are trusted by default
- `execute_bash`, `fs_write`, and `use_aws` prompt for permission by default, but can be configured to allow specific commands/paths/services
4 changes: 2 additions & 2 deletions docs/default-agent-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If no agent is specified or found, Q CLI uses a built-in default agent with the
"name": "default",
"description": "Default agent",
"tools": ["*"],
"allowedTools": ["fs_read"],
"allowedTools": ["fs_read", "todo_list"],
"resources": [
"file://AmazonQ.md",
"file://README.md",
Expand All @@ -52,7 +52,7 @@ The built-in default agent provides:
- **All tools**: Uses `"*"` wildcard to include all built-in tools and MCP server tools

### Trusted Tools
- **fs_read only**: Only the `fs_read` tool is pre-approved and won't prompt for permission
- **fs_read and todo_list**: Only the `fs_read` and `todo_list` tools are pre-approved and won't prompt for permission
- All other tools will require user confirmation before execution

### Default Resources
Expand Down
8 changes: 8 additions & 0 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ Welcome to the supplementary Amazon Q CLI Developer documentation.
This documentation supplements [the primary Amazon Q CLI documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line.html).

These docs are experimental, work in progress, and subject to change. As of now, they do not represent latest stable builds, instead documenting the functionality of development builds.

## Key Features Covered

- **Agent Configuration**: Learn how to create and configure custom agents with specific tools, resources, and behaviors
- **Built-in Tools**: Comprehensive guide to all available tools including file operations, AWS integration, and task management
- **Slash Commands**: Direct system commands for managing to-do lists, knowledge bases, and other features
- **Knowledge Management**: Persistent knowledge bases with semantic search capabilities
- **Migration Guide**: How to migrate from legacy profiles to the new agent system
Loading