From aeef799afda1e10d27bd152344e49365e3923f8d Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 10:08:22 -0700 Subject: [PATCH 01/32] Move docs generation files from fork to branch --- docs-generation/create-docs-pr.sh | 30 ++++++++++++++++++++ docs-generation/read-pr.sh | 24 ++++++++++++++++ docs-generation/update-docs.sh | 14 ++++++++++ scripts/docs-generator.yaml | 46 +++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100755 docs-generation/create-docs-pr.sh create mode 100755 docs-generation/read-pr.sh create mode 100755 docs-generation/update-docs.sh create mode 100644 scripts/docs-generator.yaml diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh new file mode 100755 index 0000000000..2a0480ccd9 --- /dev/null +++ b/docs-generation/create-docs-pr.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +PR_NUMBER=$1 +BRANCH_NAME="docs-update-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 and push +git checkout -b "$BRANCH_NAME" +git add . +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" diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh new file mode 100755 index 0000000000..766d32f804 --- /dev/null +++ b/docs-generation/read-pr.sh @@ -0,0 +1,24 @@ +#!/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 updated files +echo -e "\n====== Updated files ======\n" >> $PR_FILE +gh pr view $PR_NUMBER --json files --jq ".files[].path" | while read file; do + if [ -f "$file" ]; then + echo "---- $file ----" >> $PR_FILE + cat "$file" >> $PR_FILE + echo -e "\n" >> $PR_FILE + fi +done + + + + + + \ No newline at end of file diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh new file mode 100755 index 0000000000..5a468d828a --- /dev/null +++ b/docs-generation/update-docs.sh @@ -0,0 +1,14 @@ +#!/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." + +echo -e $PROMPT | cargo run --bin chat_cli -- chat --non-interactive diff --git a/scripts/docs-generator.yaml b/scripts/docs-generator.yaml new file mode 100644 index 0000000000..cda5852f64 --- /dev/null +++ b/scripts/docs-generator.yaml @@ -0,0 +1,46 @@ +name: docs-generator + +on: + workflow_dispatch: + inputs: + pr_number: + description: 'Number of PR to document' + required: true + type: string + +jobs: + generate_docs: + runs-on: ubuntu-latest + env: + PR_FILE: "pr-contents.txt" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source ~/.cargo/env + + - name: Make scripts executable + run: | + chmod +x docs-generation/create-docs-pr.sh + chmod +x docs-generation/read-pr.sh + chmod +x docs-generation/update-docs.sh + + - name: Generate PR contents file + run: bash docs-generation/read-pr.sh ${{ inputs.pr_number }} + + # For testing purposes, we're building from source + - name: Update docs + run: bash docs-generation/update-docs.sh + + - name: Create PR + if: success() + run: bash docs-generation/create-docs-pr.sh ${{ inputs.pr_number }} + + + + + + \ No newline at end of file From 80dbe74c5780b3c2b7fccdfe5628355c6b7cc043 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 10:53:13 -0700 Subject: [PATCH 02/32] Add credentials to docs generator --- .../workflows}/docs-generator.yaml | 30 ++++++++++++++----- docs-generation/update-docs.sh | 2 +- 2 files changed, 24 insertions(+), 8 deletions(-) rename {scripts => .github/workflows}/docs-generator.yaml (55%) diff --git a/scripts/docs-generator.yaml b/.github/workflows/docs-generator.yaml similarity index 55% rename from scripts/docs-generator.yaml rename to .github/workflows/docs-generator.yaml index cda5852f64..1c1d33ad09 100644 --- a/scripts/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -12,26 +12,42 @@ 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" + permissions: + id-token: write + contents: write + pull-requests: write + steps: - - uses: actions/checkout@v4 - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source ~/.cargo/env + - 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: Run setup_amazon_q.sh from terminal-bench + run: | + cd terminal-bench-testing + chmod +x setup_amazon_q.sh + bash setup_amazon_q.sh + - name: Make scripts executable run: | chmod +x docs-generation/create-docs-pr.sh chmod +x docs-generation/read-pr.sh chmod +x docs-generation/update-docs.sh + - name: Checkout repository + uses: actions/checkout@v4 + - name: Generate PR contents file run: bash docs-generation/read-pr.sh ${{ inputs.pr_number }} - # For testing purposes, we're building from source - name: Update docs run: bash docs-generation/update-docs.sh diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 5a468d828a..e8ac9a28de 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,4 +11,4 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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." -echo -e $PROMPT | cargo run --bin chat_cli -- chat --non-interactive +echo -e $PROMPT | qchat chat --non-interactive From eb9734c50c162e25cdabddf7aa2971a1863375b4 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 11:15:42 -0700 Subject: [PATCH 03/32] Reorder checkout step --- .github/workflows/docs-generator.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 1c1d33ad09..0ad61033e8 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -24,6 +24,9 @@ jobs: pull-requests: write steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -42,9 +45,6 @@ jobs: chmod +x docs-generation/read-pr.sh chmod +x docs-generation/update-docs.sh - - name: Checkout repository - uses: actions/checkout@v4 - - name: Generate PR contents file run: bash docs-generation/read-pr.sh ${{ inputs.pr_number }} From c8be55f8aa3b2e788846f39f51fd86da3a67fe6f Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 11:39:06 -0700 Subject: [PATCH 04/32] Adding push trigger to run once --- .github/workflows/docs-generator.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 0ad61033e8..b83832509c 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -7,6 +7,7 @@ on: description: 'Number of PR to document' required: true type: string + push: jobs: generate_docs: From aa61cfcb2e1ac84fc134936de70101a1f2b061b2 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 11:40:27 -0700 Subject: [PATCH 05/32] Remove push trigger from workflow The push trigger was added so that the workflow would show up on the Actions tab on GitHub. --- .github/workflows/docs-generator.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index b83832509c..0ad61033e8 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -7,7 +7,6 @@ on: description: 'Number of PR to document' required: true type: string - push: jobs: generate_docs: From 2f7d5dfb5a8d1c721ab001d3c6886d869c3c007b Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 11:46:50 -0700 Subject: [PATCH 06/32] Re-add temporary push trigger --- .github/workflows/docs-generator.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 0ad61033e8..ec43d43a93 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -7,6 +7,7 @@ on: description: 'Number of PR to document' required: true type: string + push: jobs: generate_docs: @@ -35,7 +36,7 @@ jobs: - name: Run setup_amazon_q.sh from terminal-bench run: | - cd terminal-bench-testing + cd terminal-bench-test chmod +x setup_amazon_q.sh bash setup_amazon_q.sh From b842e74e36b850f080d3ff55b791a77624ebc712 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 11:58:45 -0700 Subject: [PATCH 07/32] Run setup with sudo for testing --- .github/workflows/docs-generator.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index ec43d43a93..6b621efb63 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -38,7 +38,7 @@ jobs: run: | cd terminal-bench-test chmod +x setup_amazon_q.sh - bash setup_amazon_q.sh + sudo bash setup_amazon_q.sh - name: Make scripts executable run: | From 6838c041b84cd36256f5497d7a370a93817e71f7 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:19:48 -0700 Subject: [PATCH 08/32] Add docs-specific setup script --- .github/workflows/docs-generator.yaml | 10 ++--- docs-generation/setup_amazon_q.sh | 54 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 docs-generation/setup_amazon_q.sh diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 6b621efb63..656ce18bf7 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -33,19 +33,17 @@ jobs: with: role-to-assume: ${{ secrets.AWS_TB_ROLE }} aws-region: us-east-1 - - - name: Run setup_amazon_q.sh from terminal-bench - run: | - cd terminal-bench-test - chmod +x setup_amazon_q.sh - sudo bash setup_amazon_q.sh - name: Make scripts executable run: | + chmod +x dogs-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 ${{ inputs.pr_number }} 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 From 9ab3587e43516588fdc277928c34548a5d4ba866 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:20:59 -0700 Subject: [PATCH 09/32] Fix typo from dogs to docs --- .github/workflows/docs-generator.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 656ce18bf7..c14967d6ae 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -36,7 +36,7 @@ jobs: - name: Make scripts executable run: | - chmod +x dogs-generation/setup_amazon_q.sh + 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 From fc42b528dd0a964404d7cb996fea598716f5ab2d Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:27:28 -0700 Subject: [PATCH 10/32] Add debug statements, fixed test PR number --- .github/workflows/docs-generator.yaml | 17 ++++++++------- docs-generation/create-docs-pr.sh | 30 ++++++++++++++------------- docs-generation/update-docs.sh | 2 ++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index c14967d6ae..6d10c74b32 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -1,12 +1,12 @@ name: docs-generator on: - workflow_dispatch: - inputs: - pr_number: - description: 'Number of PR to document' - required: true - type: string + # workflow_dispatch: + # inputs: + # pr_number: + # description: 'Number of PR to document' + # required: true + # type: string push: jobs: @@ -19,6 +19,7 @@ jobs: PR_FILE: "pr-contents.txt" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_HASH: "latest" + TEST_PR_NUMBER: 2533 permissions: id-token: write contents: write @@ -45,14 +46,14 @@ jobs: run: bash docs-generation/setup_amazon_q.sh - name: Generate PR contents file - run: bash docs-generation/read-pr.sh ${{ inputs.pr_number }} + 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 ${{ inputs.pr_number }} + run: bash docs-generation/create-docs-pr.sh ${{ env.TEST_PR_NUMBER }} diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 2a0480ccd9..1601cc135c 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -10,21 +10,23 @@ if [ -z "$(git status --porcelain)" ]; then exit 0 fi -git config user.name "docs-generator[bot]" -git config user.email "docs-generator[bot]@amazon.com" +echo "Would make PR now" -# Create branch and push -git checkout -b "$BRANCH_NAME" -git add . -git commit -m "Update docs based on PR #$PR_NUMBER +# git config user.name "docs-generator[bot]" +# git config user.email "docs-generator[bot]@amazon.com" -Auto-generated by Q" +# # Create branch and push +# git checkout -b "$BRANCH_NAME" +# git add . +# git commit -m "Update docs based on PR #$PR_NUMBER -git push origin "$BRANCH_NAME" +# Auto-generated by Q" -# 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" +# 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" diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index e8ac9a28de..84e8c036fb 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,4 +11,6 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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." +cat pr-contents.txt + echo -e $PROMPT | qchat chat --non-interactive From faef1fe9ba4198f308a14b542e6dd9a8e66c456a Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:31:42 -0700 Subject: [PATCH 11/32] Add trust all tools, exit with q chat exit code --- docs-generation/update-docs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 84e8c036fb..db6f144b11 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -13,4 +13,5 @@ with new documentation reflecting the proposed changes in the PR. Make new files cat pr-contents.txt -echo -e $PROMPT | qchat chat --non-interactive +echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +exit $? \ No newline at end of file From 5034f511eb52177943a3bd42cabb346243d941a0 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:37:43 -0700 Subject: [PATCH 12/32] Add timeout for q chat --- docs-generation/update-docs.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index db6f144b11..a75eba7b4f 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,7 +11,5 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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." -cat pr-contents.txt - -echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +timeout 5m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From 6d7cfd4f044e06276b3d126eaaa057c551920fc8 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:45:04 -0700 Subject: [PATCH 13/32] Uncomment PR generation, increase q chat timeout to 10m --- docs-generation/create-docs-pr.sh | 30 ++++++++++++++---------------- docs-generation/update-docs.sh | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 1601cc135c..2a0480ccd9 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -10,23 +10,21 @@ if [ -z "$(git status --porcelain)" ]; then exit 0 fi -echo "Would make PR now" +git config user.name "docs-generator[bot]" +git config user.email "docs-generator[bot]@amazon.com" -# git config user.name "docs-generator[bot]" -# git config user.email "docs-generator[bot]@amazon.com" +# Create branch and push +git checkout -b "$BRANCH_NAME" +git add . +git commit -m "Update docs based on PR #$PR_NUMBER -# # Create branch and push -# git checkout -b "$BRANCH_NAME" -# git add . -# git commit -m "Update docs based on PR #$PR_NUMBER +Auto-generated by Q" -# Auto-generated by Q" +git push origin "$BRANCH_NAME" -# 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" +# 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/update-docs.sh b/docs-generation/update-docs.sh index a75eba7b4f..8f1c29d591 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,5 +11,5 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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 5m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From 9141f7837e982598c1a57b2aac5d21da3a6c2bff Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:53:07 -0700 Subject: [PATCH 14/32] Ignore several patterns while reading PR --- docs-generation/create-docs-pr.sh | 2 +- docs-generation/read-pr.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 2a0480ccd9..fc9b01a44c 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -2,7 +2,7 @@ set -e PR_NUMBER=$1 -BRANCH_NAME="docs-update-pr-$PR_NUMBER" +BRANCH_NAME="docs-update-for-pr-$PR_NUMBER" # Ensure we have changes to merge if [ -z "$(git status --porcelain)" ]; then diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh index 766d32f804..ab084275b9 100755 --- a/docs-generation/read-pr.sh +++ b/docs-generation/read-pr.sh @@ -10,6 +10,11 @@ gh pr view $PR_NUMBER --json title,body --jq '"Title: " + .title + "\nDescriptio # Include updated files echo -e "\n====== Updated files ======\n" >> $PR_FILE gh pr view $PR_NUMBER --json files --jq ".files[].path" | while read file; do + case "$file" in + *.lock|*-lock.*|*.min.*|dist/*|build/*|target/*) + continue + ;; + esac if [ -f "$file" ]; then echo "---- $file ----" >> $PR_FILE cat "$file" >> $PR_FILE From 298ed66765446628af8232d57935470e07eb0991 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 12:57:18 -0700 Subject: [PATCH 15/32] Add print statements for debug, disable q chat run temporarily --- docs-generation/update-docs.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 8f1c29d591..3ffe551574 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,5 +11,7 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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 +cat pr-contents.txt +echo "Would prompt q chat here" +# timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From 07db3d0848300db44744498674b943d31308fd36 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 13:07:08 -0700 Subject: [PATCH 16/32] Display only file diffs to q chat rather than entire file contents, comment out PR creation for debug --- docs-generation/create-docs-pr.sh | 30 ++++++++++++++++-------------- docs-generation/read-pr.sh | 2 +- docs-generation/update-docs.sh | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index fc9b01a44c..3c9c087705 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -10,21 +10,23 @@ if [ -z "$(git status --porcelain)" ]; then exit 0 fi -git config user.name "docs-generator[bot]" -git config user.email "docs-generator[bot]@amazon.com" +echo "Would create PR now" -# Create branch and push -git checkout -b "$BRANCH_NAME" -git add . -git commit -m "Update docs based on PR #$PR_NUMBER +# git config user.name "docs-generator[bot]" +# git config user.email "docs-generator[bot]@amazon.com" -Auto-generated by Q" +# # Create branch and push +# git checkout -b "$BRANCH_NAME" +# git add . +# git commit -m "Update docs based on PR #$PR_NUMBER -git push origin "$BRANCH_NAME" +# Auto-generated by Q" -# 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" +# 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" diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh index ab084275b9..e661d021c7 100755 --- a/docs-generation/read-pr.sh +++ b/docs-generation/read-pr.sh @@ -17,7 +17,7 @@ gh pr view $PR_NUMBER --json files --jq ".files[].path" | while read file; do esac if [ -f "$file" ]; then echo "---- $file ----" >> $PR_FILE - cat "$file" >> $PR_FILE + git diff main -- "$file" >> $PR_FILE echo -e "\n" >> $PR_FILE fi done diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 3ffe551574..1f872a43e5 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -13,5 +13,5 @@ with new documentation reflecting the proposed changes in the PR. Make new files cat pr-contents.txt echo "Would prompt q chat here" -# timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From 8760adc8fd601af475646b754b5ff93e3f39cec0 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 13:09:57 -0700 Subject: [PATCH 17/32] Fetch main for file diffs --- .github/workflows/docs-generator.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index 6d10c74b32..f8a50902de 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -29,6 +29,9 @@ jobs: - 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: From 8a83eeadfb9077c78c6083dfaa516a6c8a89e3cd Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 13:13:43 -0700 Subject: [PATCH 18/32] Try gh pr diff instead of manually getting diff --- docs-generation/read-pr.sh | 17 +++-------------- docs-generation/update-docs.sh | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh index e661d021c7..217c7aa9e0 100755 --- a/docs-generation/read-pr.sh +++ b/docs-generation/read-pr.sh @@ -7,20 +7,9 @@ PR_NUMBER=$1 echo "====== PR Information ======\n" > $PR_FILE gh pr view $PR_NUMBER --json title,body --jq '"Title: " + .title + "\nDescription: " + .body' >> $PR_FILE -# Include updated files -echo -e "\n====== Updated files ======\n" >> $PR_FILE -gh pr view $PR_NUMBER --json files --jq ".files[].path" | while read file; do - case "$file" in - *.lock|*-lock.*|*.min.*|dist/*|build/*|target/*) - continue - ;; - esac - if [ -f "$file" ]; then - echo "---- $file ----" >> $PR_FILE - git diff main -- "$file" >> $PR_FILE - echo -e "\n" >> $PR_FILE - fi -done +# Include PR diffs +echo -e "\n====== PR Diffs ======\n" >> $PR_FILE +gh pr diff $PR_NUMBER >> $PR_FILE diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 1f872a43e5..3ffe551574 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -13,5 +13,5 @@ with new documentation reflecting the proposed changes in the PR. Make new files cat pr-contents.txt echo "Would prompt q chat here" -timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +# timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From f9c76578922154891d858e51f0c1b2ddacabb684 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 13:20:03 -0700 Subject: [PATCH 19/32] Remove debug statements, test full workflow --- docs-generation/create-docs-pr.sh | 30 ++++++++++++++---------------- docs-generation/update-docs.sh | 4 +--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 3c9c087705..fc9b01a44c 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -10,23 +10,21 @@ if [ -z "$(git status --porcelain)" ]; then exit 0 fi -echo "Would create PR now" +git config user.name "docs-generator[bot]" +git config user.email "docs-generator[bot]@amazon.com" -# git config user.name "docs-generator[bot]" -# git config user.email "docs-generator[bot]@amazon.com" +# Create branch and push +git checkout -b "$BRANCH_NAME" +git add . +git commit -m "Update docs based on PR #$PR_NUMBER -# # Create branch and push -# git checkout -b "$BRANCH_NAME" -# git add . -# git commit -m "Update docs based on PR #$PR_NUMBER +Auto-generated by Q" -# Auto-generated by Q" +git push origin "$BRANCH_NAME" -# 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" +# 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/update-docs.sh b/docs-generation/update-docs.sh index 3ffe551574..8f1c29d591 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,7 +11,5 @@ documentation. Then read 'pr-contents.txt' to see the contents of the current PR 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." -cat pr-contents.txt -echo "Would prompt q chat here" -# timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools +timeout 10m echo -e $PROMPT | qchat chat --non-interactive --trust-all-tools exit $? \ No newline at end of file From 85d78fb07214295cd9385fc51e1fe5838d19ad88 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 14:25:00 -0700 Subject: [PATCH 20/32] Trigger docs-generationn workflow 1 From c7f7591050228401248814b1eacfdf359943919e Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 14:48:56 -0700 Subject: [PATCH 21/32] Test workflow 2; commit only docs --- docs-generation/create-docs-pr.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index fc9b01a44c..d93b84b868 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -13,9 +13,12 @@ fi git config user.name "docs-generator[bot]" git config user.email "docs-generator[bot]@amazon.com" -# Create branch and push -git checkout -b "$BRANCH_NAME" -git add . +# 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" From 806f45da71adf324fed57f12c213d959384d6ed8 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 14:57:25 -0700 Subject: [PATCH 22/32] Test workflow 3; run second time on existing PR/branch --- docs-generation/update-docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 8f1c29d591..cb33d291aa 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -9,7 +9,7 @@ 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." +with new, concise 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 $? \ No newline at end of file From 27db585cef9d034401ab6a83ed18d7b58b84b165 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:04:52 -0700 Subject: [PATCH 23/32] Test workflow 4; run on already documented PR --- docs-generation/create-docs-pr.sh | 6 +----- docs-generation/update-docs.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index d93b84b868..955ef08437 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -13,11 +13,7 @@ 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 +# Push (branch should have already been created in update-docs.sh) git add docs git commit -m "Update docs based on PR #$PR_NUMBER diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index cb33d291aa..48e547ed9f 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -1,15 +1,24 @@ #!/bin/bash set -e +BRANCH_NAME="docs-update-for-pr-$PR_NUMBER" + if [ ! -f "$PR_FILE" ]; then echo "PR file not found, aborting" exit 1 fi +# Create branch before making any changes +git checkout -B "$BRANCH_NAME" +if git ls-remote --exit-code --heads origin $BRANCH_NAME; then + git pull origin $BRANCH_NAME --force +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 the proposed changes in the PR. Make new files as appropriate." +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 From 514d034fa7ed78240777664f4836296b14fbd4c9 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:14:20 -0700 Subject: [PATCH 24/32] Test workflow 5; reset instead of pull --- docs-generation/create-docs-pr.sh | 2 +- docs-generation/update-docs.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 955ef08437..e7b667d316 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -19,7 +19,7 @@ git commit -m "Update docs based on PR #$PR_NUMBER Auto-generated by Q" -git push origin "$BRANCH_NAME" +git push -u origin "$BRANCH_NAME" # Create PR gh pr create \ diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index 48e547ed9f..e2b2312a92 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -11,7 +11,7 @@ fi # Create branch before making any changes git checkout -B "$BRANCH_NAME" if git ls-remote --exit-code --heads origin $BRANCH_NAME; then - git pull origin $BRANCH_NAME --force + git reset --hard origin/$BRANCH_NAME fi PROMPT="Before making any changes, read the 'docs' directory for the project's current From 4003996b4e9fc6474e0e31d8ea4f97b249460e9a Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:24:05 -0700 Subject: [PATCH 25/32] Move PR number and branch name to env vars --- .github/workflows/docs-generator.yaml | 7 ++++--- docs-generation/create-docs-pr.sh | 3 --- docs-generation/read-pr.sh | 2 -- docs-generation/update-docs.sh | 2 -- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index f8a50902de..a3f78d339e 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -19,7 +19,8 @@ jobs: PR_FILE: "pr-contents.txt" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_HASH: "latest" - TEST_PR_NUMBER: 2533 + PR_NUMBER: 2533 + BRANCH_NAME: "docs-update-for-pr-${{ env.PR_NUMBER }}" permissions: id-token: write contents: write @@ -49,14 +50,14 @@ jobs: run: bash docs-generation/setup_amazon_q.sh - name: Generate PR contents file - run: bash docs-generation/read-pr.sh ${{ env.TEST_PR_NUMBER }} + 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 ${{ env.TEST_PR_NUMBER }} + run: bash docs-generation/create-docs-pr.sh diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index e7b667d316..63af4acda9 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -1,9 +1,6 @@ #!/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" diff --git a/docs-generation/read-pr.sh b/docs-generation/read-pr.sh index 217c7aa9e0..5e59343ea7 100755 --- a/docs-generation/read-pr.sh +++ b/docs-generation/read-pr.sh @@ -1,8 +1,6 @@ #!/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 diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index e2b2312a92..d0c5d002a6 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -1,8 +1,6 @@ #!/bin/bash set -e -BRANCH_NAME="docs-update-for-pr-$PR_NUMBER" - if [ ! -f "$PR_FILE" ]; then echo "PR file not found, aborting" exit 1 From e0e6c5ae52ea26b4118cd1b06b0c4016f98d2baa Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:26:13 -0700 Subject: [PATCH 26/32] Fix env error --- .github/workflows/docs-generator.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-generator.yaml b/.github/workflows/docs-generator.yaml index a3f78d339e..48ed0c861b 100644 --- a/.github/workflows/docs-generator.yaml +++ b/.github/workflows/docs-generator.yaml @@ -20,7 +20,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_HASH: "latest" PR_NUMBER: 2533 - BRANCH_NAME: "docs-update-for-pr-${{ env.PR_NUMBER }}" + BRANCH_NAME: "docs-update-for-pr-2533" permissions: id-token: write contents: write From 810ded39abef299dc3afde1eb70eb00fbcb8b86b Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:30:03 -0700 Subject: [PATCH 27/32] Try fetching before branch creation --- docs-generation/update-docs.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs-generation/update-docs.sh b/docs-generation/update-docs.sh index d0c5d002a6..c78e3b6f87 100755 --- a/docs-generation/update-docs.sh +++ b/docs-generation/update-docs.sh @@ -7,9 +7,10 @@ if [ ! -f "$PR_FILE" ]; then 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; then - git reset --hard origin/$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 From 106768fc6f07153eb7b24fadfbe21160253463a1 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:34:35 -0700 Subject: [PATCH 28/32] Ignore pr-contents.txt --- docs-generation/create-docs-pr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 63af4acda9..420d467673 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -2,7 +2,7 @@ set -e # Ensure we have changes to merge -if [ -z "$(git status --porcelain)" ]; then +if [ -z "$(git status --porcelain -- . ':!pr-contents.txt')" ]; then echo "No changes to commit" exit 0 fi From 4a66c750a1350614026e0e02fb163ddb2e615d0f Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:40:04 -0700 Subject: [PATCH 29/32] Exit gracefully if no changes have been made --- docs-generation/create-docs-pr.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs-generation/create-docs-pr.sh b/docs-generation/create-docs-pr.sh index 420d467673..c9ed647866 100755 --- a/docs-generation/create-docs-pr.sh +++ b/docs-generation/create-docs-pr.sh @@ -1,17 +1,15 @@ #!/bin/bash set -e -# Ensure we have changes to merge -if [ -z "$(git status --porcelain -- . ':!pr-contents.txt')" ]; 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" # 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" From 7cb9b706a0002b6ee73b764f20b3234751680ba4 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 15:49:00 -0700 Subject: [PATCH 30/32] Test workflow after deleting old branch From 60e5f5408d6d44698deb0b3cbfdb625404a93599 Mon Sep 17 00:00:00 2001 From: kiran-garre Date: Mon, 25 Aug 2025 16:09:37 -0700 Subject: [PATCH 31/32] Test workflow fresh From 097149c790a8d5e543b420dac10c0c26f46f6398 Mon Sep 17 00:00:00 2001 From: "docs-generator[bot]" Date: Mon, 25 Aug 2025 23:12:21 +0000 Subject: [PATCH 32/32] Update docs based on PR #2533 Auto-generated by Q --- docs/SUMMARY.md | 2 + docs/built-in-tools.md | 24 +++++ docs/slash-commands.md | 115 ++++++++++++++++++++++ docs/todo-list-functionality.md | 169 ++++++++++++++++++++++++++++++++ 4 files changed, 310 insertions(+) create mode 100644 docs/slash-commands.md create mode 100644 docs/todo-list-functionality.md 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