From 63fa1d0a4a1b53679535376e3e7282427f943ca8 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 17:25:31 +0100 Subject: [PATCH 01/25] Add GitHub Action to automate the creation of LLMs.txt --- .github/workflows/main.yml | 110 +++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..02391b43 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,110 @@ +name: Update Docs + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-docs: + if: ${{ !startsWith(github.head_ref, 'docs/') }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Cursor CLI + run: | + curl https://cursor.com/install -fsS | bash + echo "$HOME/.cursor/bin" >> $GITHUB_PATH + + - name: Configure git + run: | + git config user.name "Cursor Agent" + git config user.email "cursoragent@cursor.com" + + - name: Detect changed subdirectories + id: detect-changes + run: | + # Get list of changed files in docs/ directory + changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) + + # Extract unique subdirectories that have llms.txt files + changed_subdirs="" + for file in $changed_files; do + # Extract subdirectory (e.g., docs/base-account/file.mdx -> base-account) + subdir=$(echo "$file" | sed -n 's|^docs/\([^/]*\)/.*|\1|p') + if [ -n "$subdir" ] && [ -f "docs/$subdir/llms.txt" ] && [ -f "docs/$subdir/llms-full.txt" ]; then + # Add to list if not already present + if [[ ! "$changed_subdirs" =~ (^|[[:space:]])"$subdir"($|[[:space:]]) ]]; then + changed_subdirs="$changed_subdirs $subdir" + fi + fi + done + + # Clean up whitespace + changed_subdirs=$(echo "$changed_subdirs" | xargs) + + echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT + echo "Found changed subdirectories: $changed_subdirs" + + - name: Update docs for changed subdirectories + if: steps.detect-changes.outputs.changed_subdirs != '' + env: + MODEL: gpt-4o + CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_PREFIX: docs + CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} + run: | + cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. + + The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. You have write access to repository contents and can comment on pull requests, but you must not create or edit PRs. + + # Context: + - Repo: ${{ github.repository }} + - Owner: ${{ github.repository_owner }} + - PR Number: ${{ github.event.pull_request.number }} + - Base Ref: ${{ github.base_ref }} + - Head Ref: ${{ github.head_ref }} + - Docs Branch Prefix: ${{ env.BRANCH_PREFIX }} + - Changed Subdirectories: $CHANGED_SUBDIRS + + # Goal: + Update the llms.txt and llms-full.txt files in the changed subdirectories based on the content changes in those subdirectories. + + # Requirements: + 1) For each subdirectory in CHANGED_SUBDIRS, analyze what changed in that subdirectory since the last commit. + 2) Update ONLY the llms.txt and llms-full.txt files in those specific subdirectories (e.g., docs/base-account/llms.txt, docs/base-account/llms-full.txt). + 3) DO NOT update the root-level llms.txt or llms-full.txt files. + 4) The llms.txt should be a concise summary/index of the documentation in that subdirectory. + 5) The llms-full.txt should be a comprehensive guide with code examples and detailed explanations. + 6) Maintain the existing format and style of these files. + 7) Create or update a persistent docs branch for this PR using the Docs Branch Prefix. + 8) Push changes to origin. + 9) Post or update a single PR comment explaining what was updated with an inline compare link. + + # File Structure Context: + Each subdirectory (base-account, base-app, base-chain, cookbook, get-started, learn, mini-apps, onchainkit) contains: + - Multiple .mdx documentation files + - An llms.txt file (concise summary/index) + - An llms-full.txt file (comprehensive guide with code examples) + + # Instructions: + 1) Use \`gh pr diff\` to see what changed in the PR for the specific subdirectories. + 2) Read the current llms.txt and llms-full.txt files in each changed subdirectory. + 3) Scan the .mdx files in each changed subdirectory to understand the content. + 4) Update the llms.txt and llms-full.txt files to reflect any new content, changes, or reorganization. + 5) Ensure the updates are accurate and maintain the existing style. + 6) Only make changes if documentation updates are actually needed. + + # Deliverables when updates occur: + - Updated llms.txt and llms-full.txt files in the relevant subdirectories + - Pushed commits to the persistent docs branch + - A PR comment with inline compare link for easy PR creation + " --force --model "$MODEL" --output-format=text From 84337c29a0a9f49a701b7b3e0104a69d1d199ce2 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 17:31:42 +0100 Subject: [PATCH 02/25] Rename workflow to update llms.txt files --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02391b43..701a2cef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Update Docs +name: Update llms.txt and llms-full.txt in subdirectories on: pull_request: @@ -56,7 +56,7 @@ jobs: - name: Update docs for changed subdirectories if: steps.detect-changes.outputs.changed_subdirs != '' env: - MODEL: gpt-4o + MODEL: gpt-5 CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH_PREFIX: docs From c767b1700ff6af065cdafba48a3332cab676f811 Mon Sep 17 00:00:00 2001 From: youssefea Date: Fri, 5 Sep 2025 17:34:53 +0100 Subject: [PATCH 03/25] test commit --- docs/base-account/guides/accept-payments.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/base-account/guides/accept-payments.mdx b/docs/base-account/guides/accept-payments.mdx index 588390ad..e346c0e6 100644 --- a/docs/base-account/guides/accept-payments.mdx +++ b/docs/base-account/guides/accept-payments.mdx @@ -10,7 +10,7 @@ import {SignInWithBaseButton} from "/snippets/SignInWithBaseButton.mdx" USDC on Base is a fully-backed digital dollar that settles in seconds and costs pennies in gas. Base Pay lets you accept those dollars with a single click—no cards, no FX fees, no chargebacks. * **Any user can pay** – works with every Base Account (smart-wallet) out of the box. -* **USDC, not gas** – you charge in dollars; gas sponsorship is handled automatically. +* **USDC, no gas** – you charge in dollars; gas sponsorship is handled automatically. * **Fast** – most payments confirm in <2 seconds on Base. * **Funded accounts** – users pay with USDC from their Base Account or Coinbase Account. * **No extra fees** – you receive the full amount. From e72fdc48508a6ba8f12178eb7ee3c31bfa19eac0 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 17:51:11 +0100 Subject: [PATCH 04/25] Modify GitHub Actions workflow for documentation updates --- .github/workflows/main.yml | 43 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 701a2cef..ebdf6446 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.head_ref }} # Checkout the PR branch directly - name: Install Cursor CLI run: | @@ -56,15 +57,14 @@ jobs: - name: Update docs for changed subdirectories if: steps.detect-changes.outputs.changed_subdirs != '' env: - MODEL: gpt-5 + MODEL: gpt-4o CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_PREFIX: docs CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. - The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. You have write access to repository contents and can comment on pull requests, but you must not create or edit PRs. + The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. You have write access to repository contents and can comment on pull requests. # Context: - Repo: ${{ github.repository }} @@ -72,22 +72,23 @@ jobs: - PR Number: ${{ github.event.pull_request.number }} - Base Ref: ${{ github.base_ref }} - Head Ref: ${{ github.head_ref }} - - Docs Branch Prefix: ${{ env.BRANCH_PREFIX }} - Changed Subdirectories: $CHANGED_SUBDIRS + - Current Branch: ${{ github.head_ref }} (you are already on the PR branch) # Goal: - Update the llms.txt and llms-full.txt files in the changed subdirectories based on the content changes in those subdirectories. + Update the llms.txt and llms-full.txt files in the changed subdirectories and commit directly to the current PR branch. # Requirements: - 1) For each subdirectory in CHANGED_SUBDIRS, analyze what changed in that subdirectory since the last commit. + 1) For each subdirectory in CHANGED_SUBDIRS, analyze what changed in that subdirectory since the base branch. 2) Update ONLY the llms.txt and llms-full.txt files in those specific subdirectories (e.g., docs/base-account/llms.txt, docs/base-account/llms-full.txt). 3) DO NOT update the root-level llms.txt or llms-full.txt files. 4) The llms.txt should be a concise summary/index of the documentation in that subdirectory. 5) The llms-full.txt should be a comprehensive guide with code examples and detailed explanations. 6) Maintain the existing format and style of these files. - 7) Create or update a persistent docs branch for this PR using the Docs Branch Prefix. - 8) Push changes to origin. - 9) Post or update a single PR comment explaining what was updated with an inline compare link. + 7) ONLY commit and push changes if there are actual updates needed to the llms files. + 8) If no updates are needed, do NOT create any commits or comments. + 9) Commit directly to the current PR branch (${{ github.head_ref }}) - do NOT create separate branches. + 10) If you make changes, add a simple comment to the PR explaining what was updated. # File Structure Context: Each subdirectory (base-account, base-app, base-chain, cookbook, get-started, learn, mini-apps, onchainkit) contains: @@ -96,15 +97,21 @@ jobs: - An llms-full.txt file (comprehensive guide with code examples) # Instructions: - 1) Use \`gh pr diff\` to see what changed in the PR for the specific subdirectories. + 1) Use \`gh pr diff ${{ github.event.pull_request.number }}\` to see what changed in the PR for the specific subdirectories. 2) Read the current llms.txt and llms-full.txt files in each changed subdirectory. 3) Scan the .mdx files in each changed subdirectory to understand the content. - 4) Update the llms.txt and llms-full.txt files to reflect any new content, changes, or reorganization. - 5) Ensure the updates are accurate and maintain the existing style. - 6) Only make changes if documentation updates are actually needed. - - # Deliverables when updates occur: - - Updated llms.txt and llms-full.txt files in the relevant subdirectories - - Pushed commits to the persistent docs branch - - A PR comment with inline compare link for easy PR creation + 4) Update the llms.txt and llms-full.txt files ONLY if the changes warrant updates to the summaries. + 5) If you make updates, commit them with a clear message like 'docs: update llms summaries for [subdirectory]'. + 6) Push the commit to the current branch. + 7) Add a brief comment to the PR explaining what was updated. + 8) If no updates are needed, do nothing - no commits, no comments, no branches. + + # Important: Avoid Getting Stuck + - If there are no changes to make, simply exit without doing anything. + - Do not create empty commits or branches. + - Do not post comments if no changes were made. + + # Workflow: + 1. Check what changed → 2. Determine if llms files need updates → 3. If yes: update, commit, push, comment → 4. If no: do nothing and exit + " --force --model "$MODEL" --output-format=text From 2c3298c85a2d12cd3749efdd9de765c95e95daf7 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 17:54:36 +0100 Subject: [PATCH 05/25] Update model version from gpt-4o to gpt-5 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebdf6446..493ff27f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: - name: Update docs for changed subdirectories if: steps.detect-changes.outputs.changed_subdirs != '' env: - MODEL: gpt-4o + MODEL: gpt-5 CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} From 13da6cbb2d05f90e51fb5906dc1537b16399df20 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 17:59:59 +0100 Subject: [PATCH 06/25] Refactor GitHub Actions workflow for documentation updates --- .github/workflows/main.yml | 99 ++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 493ff27f..4032f8da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} # Checkout the PR branch directly + ref: ${{ github.head_ref }} - name: Install Cursor CLI run: | @@ -32,23 +32,18 @@ jobs: - name: Detect changed subdirectories id: detect-changes run: | - # Get list of changed files in docs/ directory changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) - # Extract unique subdirectories that have llms.txt files changed_subdirs="" for file in $changed_files; do - # Extract subdirectory (e.g., docs/base-account/file.mdx -> base-account) subdir=$(echo "$file" | sed -n 's|^docs/\([^/]*\)/.*|\1|p') if [ -n "$subdir" ] && [ -f "docs/$subdir/llms.txt" ] && [ -f "docs/$subdir/llms-full.txt" ]; then - # Add to list if not already present if [[ ! "$changed_subdirs" =~ (^|[[:space:]])"$subdir"($|[[:space:]]) ]]; then changed_subdirs="$changed_subdirs $subdir" fi fi done - # Clean up whitespace changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT @@ -62,56 +57,64 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | - cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. + # Set timeout and error handling + set -euo pipefail + + # Run cursor-agent with 30-minute timeout (1800 seconds) + timeout 1800 cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. - The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. You have write access to repository contents and can comment on pull requests. + The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. # Context: - Repo: ${{ github.repository }} - - Owner: ${{ github.repository_owner }} - PR Number: ${{ github.event.pull_request.number }} - Base Ref: ${{ github.base_ref }} - Head Ref: ${{ github.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS - - Current Branch: ${{ github.head_ref }} (you are already on the PR branch) + - Current Branch: ${{ github.head_ref }} # Goal: - Update the llms.txt and llms-full.txt files in the changed subdirectories and commit directly to the current PR branch. - - # Requirements: - 1) For each subdirectory in CHANGED_SUBDIRS, analyze what changed in that subdirectory since the base branch. - 2) Update ONLY the llms.txt and llms-full.txt files in those specific subdirectories (e.g., docs/base-account/llms.txt, docs/base-account/llms-full.txt). - 3) DO NOT update the root-level llms.txt or llms-full.txt files. - 4) The llms.txt should be a concise summary/index of the documentation in that subdirectory. - 5) The llms-full.txt should be a comprehensive guide with code examples and detailed explanations. - 6) Maintain the existing format and style of these files. - 7) ONLY commit and push changes if there are actual updates needed to the llms files. - 8) If no updates are needed, do NOT create any commits or comments. - 9) Commit directly to the current PR branch (${{ github.head_ref }}) - do NOT create separate branches. - 10) If you make changes, add a simple comment to the PR explaining what was updated. - - # File Structure Context: - Each subdirectory (base-account, base-app, base-chain, cookbook, get-started, learn, mini-apps, onchainkit) contains: - - Multiple .mdx documentation files - - An llms.txt file (concise summary/index) - - An llms-full.txt file (comprehensive guide with code examples) - - # Instructions: - 1) Use \`gh pr diff ${{ github.event.pull_request.number }}\` to see what changed in the PR for the specific subdirectories. - 2) Read the current llms.txt and llms-full.txt files in each changed subdirectory. - 3) Scan the .mdx files in each changed subdirectory to understand the content. - 4) Update the llms.txt and llms-full.txt files ONLY if the changes warrant updates to the summaries. - 5) If you make updates, commit them with a clear message like 'docs: update llms summaries for [subdirectory]'. - 6) Push the commit to the current branch. - 7) Add a brief comment to the PR explaining what was updated. - 8) If no updates are needed, do nothing - no commits, no comments, no branches. - - # Important: Avoid Getting Stuck - - If there are no changes to make, simply exit without doing anything. - - Do not create empty commits or branches. - - Do not post comments if no changes were made. - - # Workflow: - 1. Check what changed → 2. Determine if llms files need updates → 3. If yes: update, commit, push, comment → 4. If no: do nothing and exit + Update llms.txt and llms-full.txt files in changed subdirectories and commit directly to the PR branch. + + # Critical Instructions: + 1) Check what changed in the PR using \`gh pr diff ${{ github.event.pull_request.number }}\` + 2) For each subdirectory in CHANGED_SUBDIRS, read the current llms.txt and llms-full.txt files + 3) Determine if the changes warrant updates to these summary files + 4) If updates are needed: + - Update the files + - Commit with message: 'docs: update llms summaries for [subdirectory]' + - Push to current branch + - Add a brief PR comment explaining the updates + 5) If NO updates are needed: + - Print 'NO_UPDATES_NEEDED' and exit immediately + - Do not create commits, branches, or comments + + # IMPORTANT EXIT BEHAVIOR: + - Always end your response with either 'UPDATES_COMPLETED' or 'NO_UPDATES_NEEDED' + - Do not hang or wait for additional input + - Exit cleanly after determining the outcome + + # File Requirements: + - Only update llms.txt and llms-full.txt in the specified subdirectories + - Do NOT update root-level llms files + - Maintain existing format and style + - llms.txt = concise summary/index + - llms-full.txt = comprehensive guide with code examples + + Remember: Always conclude with 'UPDATES_COMPLETED' or 'NO_UPDATES_NEEDED' and exit. + " --force --model "$MODEL" --output-format=text || { + echo "Cursor agent completed or timed out after 30 minutes" + exit 0 + } + + echo "Documentation update process completed" - " --force --model "$MODEL" --output-format=text + - name: Check for any uncommitted changes + if: steps.detect-changes.outputs.changed_subdirs != '' + run: | + if git diff --quiet && git diff --cached --quiet; then + echo "No changes were made to commit" + else + echo "Changes detected but not committed - this might indicate an issue" + git status + fi From 2665fda468b6e9ffe848ad3a4043e2e5643815a5 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 18:05:33 +0100 Subject: [PATCH 07/25] Update main.yml --- .github/workflows/main.yml | 131 ++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 40 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4032f8da..7fe93a1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} + ref: ${{ github.head_ref }} # Checkout the PR branch directly - name: Install Cursor CLI run: | @@ -32,24 +32,29 @@ jobs: - name: Detect changed subdirectories id: detect-changes run: | + # Get list of changed files in docs/ directory changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) + # Extract unique subdirectories that have llms.txt files changed_subdirs="" for file in $changed_files; do + # Extract subdirectory (e.g., docs/base-account/file.mdx -> base-account) subdir=$(echo "$file" | sed -n 's|^docs/\([^/]*\)/.*|\1|p') if [ -n "$subdir" ] && [ -f "docs/$subdir/llms.txt" ] && [ -f "docs/$subdir/llms-full.txt" ]; then + # Add to list if not already present if [[ ! "$changed_subdirs" =~ (^|[[:space:]])"$subdir"($|[[:space:]]) ]]; then changed_subdirs="$changed_subdirs $subdir" fi fi done + # Clean up whitespace changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT echo "Found changed subdirectories: $changed_subdirs" - - name: Update docs for changed subdirectories + - name: Generate llms.txt updates (no commit/push/comment) if: steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 @@ -57,64 +62,110 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | - # Set timeout and error handling - set -euo pipefail - - # Run cursor-agent with 30-minute timeout (1800 seconds) - timeout 1800 cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. + timeout 1800 cursor-agent -p "You are operating in a GitHub Actions runner. The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. + IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes and commenting on the PR. + # Context: - Repo: ${{ github.repository }} + - Owner: ${{ github.repository_owner }} - PR Number: ${{ github.event.pull_request.number }} - Base Ref: ${{ github.base_ref }} - Head Ref: ${{ github.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS - - Current Branch: ${{ github.head_ref }} # Goal: - Update llms.txt and llms-full.txt files in changed subdirectories and commit directly to the PR branch. - - # Critical Instructions: - 1) Check what changed in the PR using \`gh pr diff ${{ github.event.pull_request.number }}\` - 2) For each subdirectory in CHANGED_SUBDIRS, read the current llms.txt and llms-full.txt files - 3) Determine if the changes warrant updates to these summary files - 4) If updates are needed: - - Update the files - - Commit with message: 'docs: update llms summaries for [subdirectory]' - - Push to current branch - - Add a brief PR comment explaining the updates - 5) If NO updates are needed: - - Print 'NO_UPDATES_NEEDED' and exit immediately - - Do not create commits, branches, or comments - - # IMPORTANT EXIT BEHAVIOR: - - Always end your response with either 'UPDATES_COMPLETED' or 'NO_UPDATES_NEEDED' - - Do not hang or wait for additional input - - Exit cleanly after determining the outcome + Update llms.txt and llms-full.txt files in the changed subdirectories based on documentation changes in this PR. + + # Requirements: + 1) Use \`gh pr diff ${{ github.event.pull_request.number }}\` to see what changed in the PR + 2) For each subdirectory in CHANGED_SUBDIRS, analyze the changes in that subdirectory + 3) Read the current llms.txt and llms-full.txt files in each changed subdirectory + 4) Update ONLY the llms.txt and llms-full.txt files in those subdirectories if the changes warrant updates + 5) DO NOT update root-level llms.txt or llms-full.txt files + 6) DO NOT commit, push, create branches, or post comments - only modify files in working directory + 7) If no updates are needed, make no changes and produce no output + + # File Structure: + Each subdirectory (base-account, base-app, base-chain, etc.) contains: + - Multiple .mdx documentation files + - An llms.txt file (concise summary/index) + - An llms-full.txt file (comprehensive guide with code examples) + + # Instructions: + 1) Check what changed in the specific subdirectories + 2) Determine if those changes require updates to the llms summary files + 3) If yes: update the llms.txt and llms-full.txt files maintaining existing format and style + 4) If no: make no changes # File Requirements: - - Only update llms.txt and llms-full.txt in the specified subdirectories - - Do NOT update root-level llms files - - Maintain existing format and style - - llms.txt = concise summary/index - - llms-full.txt = comprehensive guide with code examples + - llms.txt should be a concise summary/index of the documentation in that subdirectory + - llms-full.txt should be a comprehensive guide with code examples and detailed explanations + - Maintain the existing format and style of these files + - Only modify files that actually need updates - Remember: Always conclude with 'UPDATES_COMPLETED' or 'NO_UPDATES_NEEDED' and exit. + Remember: Only modify files in the working directory. Do not commit, push, or comment. " --force --model "$MODEL" --output-format=text || { echo "Cursor agent completed or timed out after 30 minutes" exit 0 } - - echo "Documentation update process completed" - - name: Check for any uncommitted changes + - name: Commit changes directly to PR branch if: steps.detect-changes.outputs.changed_subdirs != '' + id: commit_changes run: | - if git diff --quiet && git diff --cached --quiet; then - echo "No changes were made to commit" + echo "changes_committed=false" >> "$GITHUB_OUTPUT" + + # Stage all changes + git add -A + + # Check if there are any changes to commit + if git diff --staged --quiet; then + echo "No llms.txt changes to commit. Skipping." + exit 0 + fi + + # Show what changed + echo "Changes detected:" + git diff --staged --name-only + + # Commit changes directly to the PR branch + COMMIT_MSG="docs: update llms summaries for PR #${{ github.event.pull_request.number }}" + git commit -m "$COMMIT_MSG" + git push origin ${{ github.head_ref }} + + echo "changes_committed=true" >> "$GITHUB_OUTPUT" + + - name: Comment on PR about updates + if: steps.commit_changes.outputs.changes_committed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + # Get list of changed llms files + changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) + + COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" + { + echo "🤖 **LLMs summaries updated**" + echo "" + echo "Updated the following documentation summary files based on your changes:" + echo "" + for file in $changed_llms_files; do + echo "- \`$file\`" + done + echo "" + echo "_This comment will be updated if you make more changes to the PR._" + echo "" + echo "" + } > "$COMMENT_FILE" + + # Try to update existing comment, fall back to new comment + if gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" --edit-last; then + echo "Updated existing PR comment." else - echo "Changes detected but not committed - this might indicate an issue" - git status + gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" + echo "Posted new PR comment." fi From 64c68720a634087d7d52eb45941bb4c167843211 Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 18:10:49 +0100 Subject: [PATCH 08/25] Refactor GitHub Actions workflow for LLM updates --- .github/workflows/main.yml | 101 +++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fe93a1f..6fadedc0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} # Checkout the PR branch directly + ref: ${{ github.head_ref }} - name: Install Cursor CLI run: | @@ -32,23 +32,18 @@ jobs: - name: Detect changed subdirectories id: detect-changes run: | - # Get list of changed files in docs/ directory changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) - # Extract unique subdirectories that have llms.txt files changed_subdirs="" for file in $changed_files; do - # Extract subdirectory (e.g., docs/base-account/file.mdx -> base-account) subdir=$(echo "$file" | sed -n 's|^docs/\([^/]*\)/.*|\1|p') if [ -n "$subdir" ] && [ -f "docs/$subdir/llms.txt" ] && [ -f "docs/$subdir/llms-full.txt" ]; then - # Add to list if not already present if [[ ! "$changed_subdirs" =~ (^|[[:space:]])"$subdir"($|[[:space:]]) ]]; then changed_subdirs="$changed_subdirs $subdir" fi fi done - # Clean up whitespace changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT @@ -62,55 +57,74 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | - timeout 1800 cursor-agent -p "You are operating in a GitHub Actions runner. + # Create a wrapper script to ensure proper completion + cat > update_llms.sh << 'EOF' + #!/bin/bash + set -euo pipefail + + echo "=== Starting LLMs update process ===" + echo "Changed subdirectories: $CHANGED_SUBDIRS" + + cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. - IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes and commenting on the PR. + CRITICAL: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. You MUST complete this task and exit cleanly. # Context: - Repo: ${{ github.repository }} - - Owner: ${{ github.repository_owner }} - PR Number: ${{ github.event.pull_request.number }} - Base Ref: ${{ github.base_ref }} - Head Ref: ${{ github.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS - # Goal: - Update llms.txt and llms-full.txt files in the changed subdirectories based on documentation changes in this PR. - - # Requirements: - 1) Use \`gh pr diff ${{ github.event.pull_request.number }}\` to see what changed in the PR - 2) For each subdirectory in CHANGED_SUBDIRS, analyze the changes in that subdirectory - 3) Read the current llms.txt and llms-full.txt files in each changed subdirectory - 4) Update ONLY the llms.txt and llms-full.txt files in those subdirectories if the changes warrant updates - 5) DO NOT update root-level llms.txt or llms-full.txt files - 6) DO NOT commit, push, create branches, or post comments - only modify files in working directory - 7) If no updates are needed, make no changes and produce no output - - # File Structure: - Each subdirectory (base-account, base-app, base-chain, etc.) contains: - - Multiple .mdx documentation files - - An llms.txt file (concise summary/index) - - An llms-full.txt file (comprehensive guide with code examples) - - # Instructions: - 1) Check what changed in the specific subdirectories - 2) Determine if those changes require updates to the llms summary files - 3) If yes: update the llms.txt and llms-full.txt files maintaining existing format and style - 4) If no: make no changes - - # File Requirements: - - llms.txt should be a concise summary/index of the documentation in that subdirectory - - llms-full.txt should be a comprehensive guide with code examples and detailed explanations - - Maintain the existing format and style of these files - - Only modify files that actually need updates - - Remember: Only modify files in the working directory. Do not commit, push, or comment. - " --force --model "$MODEL" --output-format=text || { - echo "Cursor agent completed or timed out after 30 minutes" + # Task: + For each subdirectory in CHANGED_SUBDIRS, check if llms.txt and llms-full.txt need updates based on PR changes. + + # Step-by-step process: + 1. Get PR diff: \`gh pr diff ${{ github.event.pull_request.number }}\` + 2. For each subdirectory in CHANGED_SUBDIRS: + - Read current docs/[subdirectory]/llms.txt + - Read current docs/[subdirectory]/llms-full.txt + - Analyze if the PR changes require updates to these files + - If yes: Update the files (maintain format/style) + - If no: Leave files unchanged + 3. Print completion status and exit + + # COMPLETION REQUIREMENTS: + - You MUST end with one of these exact phrases: + * \"TASK_COMPLETED_WITH_UPDATES\" (if you modified any files) + * \"TASK_COMPLETED_NO_UPDATES\" (if no files needed changes) + - Do NOT wait for additional input + - Do NOT create commits, branches, or comments + - Exit immediately after printing completion status + + # File Guidelines: + - llms.txt = concise summary/index of subdirectory docs + - llms-full.txt = comprehensive guide with code examples + - Only update files that actually need changes based on PR diff + - Maintain existing format and style + + Remember: Complete the analysis, make any necessary file updates, print completion status, and exit immediately. + " --force --model "$MODEL" --output-format=text + + echo "=== Cursor agent completed ===" + EOF + + chmod +x update_llms.sh + + # Run with timeout and explicit completion handling + timeout 1800 ./update_llms.sh || { + exit_code=$? + if [ $exit_code -eq 124 ]; then + echo "=== Process timed out after 30 minutes ===" + else + echo "=== Process completed with exit code $exit_code ===" + fi exit 0 } + + echo "=== LLMs update process finished ===" - name: Commit changes directly to PR branch if: steps.detect-changes.outputs.changed_subdirs != '' @@ -130,6 +144,7 @@ jobs: # Show what changed echo "Changes detected:" git diff --staged --name-only + git diff --staged # Commit changes directly to the PR branch COMMIT_MSG="docs: update llms summaries for PR #${{ github.event.pull_request.number }}" @@ -144,7 +159,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | - # Get list of changed llms files changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" @@ -162,7 +176,6 @@ jobs: echo "" } > "$COMMENT_FILE" - # Try to update existing comment, fall back to new comment if gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" --edit-last; then echo "Updated existing PR comment." else From abde5867059d19cf886a7d7c5483ff972e61ecea Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 18:16:05 +0100 Subject: [PATCH 09/25] Update main.yml --- .github/workflows/main.yml | 103 +++++++++++++------------------------ 1 file changed, 35 insertions(+), 68 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6fadedc0..7a932629 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,7 +49,7 @@ jobs: echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT echo "Found changed subdirectories: $changed_subdirs" - - name: Generate llms.txt updates (no commit/push/comment) + - name: Generate llms.txt updates with forced completion if: steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 @@ -57,74 +57,49 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | - # Create a wrapper script to ensure proper completion - cat > update_llms.sh << 'EOF' + # Create a script that will force completion + cat > force_complete.sh << 'EOF' #!/bin/bash set -euo pipefail - echo "=== Starting LLMs update process ===" - echo "Changed subdirectories: $CHANGED_SUBDIRS" + echo "=== Starting forced completion approach ===" - cursor-agent -p "You are operating in a GitHub Actions runner to update documentation summary files. + # Run cursor-agent in background + cursor-agent -p "You are updating documentation summary files. - The GitHub CLI is available as \`gh\` and authenticated via \`GH_TOKEN\`. Git is available. + TASK: Check if docs/$CHANGED_SUBDIRS/llms.txt and docs/$CHANGED_SUBDIRS/llms-full.txt need updates based on PR ${{ github.event.pull_request.number }}. - CRITICAL: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. You MUST complete this task and exit cleanly. + PROCESS: + 1. Get diff: gh pr diff ${{ github.event.pull_request.number }} + 2. Read docs/$CHANGED_SUBDIRS/llms.txt + 3. Read docs/$CHANGED_SUBDIRS/llms-full.txt + 4. If changes warrant updates: modify the files + 5. If no updates needed: do nothing + 6. Print 'ANALYSIS_COMPLETE' and stop - # Context: - - Repo: ${{ github.repository }} - - PR Number: ${{ github.event.pull_request.number }} - - Base Ref: ${{ github.base_ref }} - - Head Ref: ${{ github.head_ref }} - - Changed Subdirectories: $CHANGED_SUBDIRS - - # Task: - For each subdirectory in CHANGED_SUBDIRS, check if llms.txt and llms-full.txt need updates based on PR changes. - - # Step-by-step process: - 1. Get PR diff: \`gh pr diff ${{ github.event.pull_request.number }}\` - 2. For each subdirectory in CHANGED_SUBDIRS: - - Read current docs/[subdirectory]/llms.txt - - Read current docs/[subdirectory]/llms-full.txt - - Analyze if the PR changes require updates to these files - - If yes: Update the files (maintain format/style) - - If no: Leave files unchanged - 3. Print completion status and exit - - # COMPLETION REQUIREMENTS: - - You MUST end with one of these exact phrases: - * \"TASK_COMPLETED_WITH_UPDATES\" (if you modified any files) - * \"TASK_COMPLETED_NO_UPDATES\" (if no files needed changes) - - Do NOT wait for additional input - - Do NOT create commits, branches, or comments - - Exit immediately after printing completion status - - # File Guidelines: - - llms.txt = concise summary/index of subdirectory docs - - llms-full.txt = comprehensive guide with code examples - - Only update files that actually need changes based on PR diff - - Maintain existing format and style - - Remember: Complete the analysis, make any necessary file updates, print completion status, and exit immediately. - " --force --model "$MODEL" --output-format=text + CRITICAL: You have 5 minutes to complete this. Print 'ANALYSIS_COMPLETE' when done and exit immediately. Do not commit or push." \ + --force --model "$MODEL" --output-format=text & - echo "=== Cursor agent completed ===" - EOF + AGENT_PID=$! + echo "Started cursor-agent with PID: $AGENT_PID" - chmod +x update_llms.sh + # Force kill after 5 minutes + (sleep 300; echo "=== Forcing completion after 5 minutes ==="; kill -9 $AGENT_PID 2>/dev/null) & + KILLER_PID=$! - # Run with timeout and explicit completion handling - timeout 1800 ./update_llms.sh || { - exit_code=$? - if [ $exit_code -eq 124 ]; then - echo "=== Process timed out after 30 minutes ===" - else - echo "=== Process completed with exit code $exit_code ===" - fi - exit 0 - } + # Wait for completion + if wait $AGENT_PID 2>/dev/null; then + echo "=== Agent completed normally ===" + kill $KILLER_PID 2>/dev/null || true + else + echo "=== Agent was terminated ===" + fi - echo "=== LLMs update process finished ===" + echo "=== Process finished ===" + EOF + + chmod +x force_complete.sh + ./force_complete.sh - name: Commit changes directly to PR branch if: steps.detect-changes.outputs.changed_subdirs != '' @@ -132,21 +107,16 @@ jobs: run: | echo "changes_committed=false" >> "$GITHUB_OUTPUT" - # Stage all changes git add -A - # Check if there are any changes to commit if git diff --staged --quiet; then - echo "No llms.txt changes to commit. Skipping." + echo "No llms.txt changes to commit." exit 0 fi - # Show what changed echo "Changes detected:" git diff --staged --name-only - git diff --staged - # Commit changes directly to the PR branch COMMIT_MSG="docs: update llms summaries for PR #${{ github.event.pull_request.number }}" git commit -m "$COMMIT_MSG" git push origin ${{ github.head_ref }} @@ -165,14 +135,11 @@ jobs: { echo "🤖 **LLMs summaries updated**" echo "" - echo "Updated the following documentation summary files based on your changes:" - echo "" + echo "Updated documentation summary files:" for file in $changed_llms_files; do echo "- \`$file\`" done echo "" - echo "_This comment will be updated if you make more changes to the PR._" - echo "" echo "" } > "$COMMENT_FILE" From 2d88dccc551f78f313ba54a569832b4e8a64649c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 5 Sep 2025 17:21:21 +0000 Subject: [PATCH 10/25] docs: update llms summaries for PR #296 --- force_complete.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 force_complete.sh diff --git a/force_complete.sh b/force_complete.sh new file mode 100755 index 00000000..4d2da70c --- /dev/null +++ b/force_complete.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -euo pipefail + +echo "=== Starting forced completion approach ===" + +# Run cursor-agent in background +cursor-agent -p "You are updating documentation summary files. + +TASK: Check if docs/$CHANGED_SUBDIRS/llms.txt and docs/$CHANGED_SUBDIRS/llms-full.txt need updates based on PR 296. + +PROCESS: +1. Get diff: gh pr diff 296 +2. Read docs/$CHANGED_SUBDIRS/llms.txt +3. Read docs/$CHANGED_SUBDIRS/llms-full.txt +4. If changes warrant updates: modify the files +5. If no updates needed: do nothing +6. Print 'ANALYSIS_COMPLETE' and stop + +CRITICAL: You have 5 minutes to complete this. Print 'ANALYSIS_COMPLETE' when done and exit immediately. Do not commit or push." \ +--force --model "$MODEL" --output-format=text & + +AGENT_PID=$! +echo "Started cursor-agent with PID: $AGENT_PID" + +# Force kill after 5 minutes +(sleep 300; echo "=== Forcing completion after 5 minutes ==="; kill -9 $AGENT_PID 2>/dev/null) & +KILLER_PID=$! + +# Wait for completion +if wait $AGENT_PID 2>/dev/null; then + echo "=== Agent completed normally ===" + kill $KILLER_PID 2>/dev/null || true +else + echo "=== Agent was terminated ===" +fi + +echo "=== Process finished ===" From 9d5f95c4bcc2cf766db729204b891fc71839e88e Mon Sep 17 00:00:00 2001 From: youssefea Date: Fri, 5 Sep 2025 18:24:57 +0100 Subject: [PATCH 11/25] updates --- docs/base-account/guides/accept-payments.mdx | 2 +- .../usage-details/unsupported-calls.mdx | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/base-account/guides/accept-payments.mdx b/docs/base-account/guides/accept-payments.mdx index e346c0e6..588390ad 100644 --- a/docs/base-account/guides/accept-payments.mdx +++ b/docs/base-account/guides/accept-payments.mdx @@ -10,7 +10,7 @@ import {SignInWithBaseButton} from "/snippets/SignInWithBaseButton.mdx" USDC on Base is a fully-backed digital dollar that settles in seconds and costs pennies in gas. Base Pay lets you accept those dollars with a single click—no cards, no FX fees, no chargebacks. * **Any user can pay** – works with every Base Account (smart-wallet) out of the box. -* **USDC, no gas** – you charge in dollars; gas sponsorship is handled automatically. +* **USDC, not gas** – you charge in dollars; gas sponsorship is handled automatically. * **Fast** – most payments confirm in <2 seconds on Base. * **Funded accounts** – users pay with USDC from their Base Account or Coinbase Account. * **No extra fees** – you receive the full amount. diff --git a/docs/base-account/more/troubleshooting/usage-details/unsupported-calls.mdx b/docs/base-account/more/troubleshooting/usage-details/unsupported-calls.mdx index 0a55f501..173d7aa4 100644 --- a/docs/base-account/more/troubleshooting/usage-details/unsupported-calls.mdx +++ b/docs/base-account/more/troubleshooting/usage-details/unsupported-calls.mdx @@ -27,16 +27,6 @@ Future versions of Base Account may support it. You can use a factory contract or a transaction with the `CREATE2` opcode to deploy a smart contract. -## Solidity's Builtin `transfer` function - -The `transfer` function is a built-in member of the `address` type in Solidity that can be used to send ETH to an address. Base Account wallets cannot receive ETH using this function. -This function has long been considered deprecated in favor of `call` by the Solidity community, but some older contracts still use it. - -The reason for this is that `transfer` only forwards 2300 gas to the `transfer` call, a protective mechanism that was designed to prevent reentrancy attacks by limiting the amount of -gas available to a smart contract that might reenter the caller. -In the modern world of smart contract wallets (including for Base Account), this is often not enough gas for the smart contract's `receive` or `fallback` functions to complete their work, -causing the transaction to revert. - ### Known affected contracts - The [WETH9 contract](https://basescan.org/token/0x4200000000000000000000000000000000000006) uses `transfer` to send ETH to the user's wallet and therefore Base Accounts cannot directly unwrap ETH from it. From 91b6ad55cb99a57525da46c3009b2e90a05131bf Mon Sep 17 00:00:00 2001 From: youssea Date: Fri, 5 Sep 2025 18:30:54 +0100 Subject: [PATCH 12/25] Restrict llms.txt updates and enhance logging --- .github/workflows/main.yml | 122 ++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 48 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a932629..7fdb266e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,11 @@ jobs: - name: Detect changed subdirectories id: detect-changes run: | + echo "=== Detecting changed subdirectories ===" + changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) + echo "Changed files in docs/:" + echo "$changed_files" changed_subdirs="" for file in $changed_files; do @@ -40,6 +44,7 @@ jobs: if [ -n "$subdir" ] && [ -f "docs/$subdir/llms.txt" ] && [ -f "docs/$subdir/llms-full.txt" ]; then if [[ ! "$changed_subdirs" =~ (^|[[:space:]])"$subdir"($|[[:space:]]) ]]; then changed_subdirs="$changed_subdirs $subdir" + echo "Found subdirectory with llms files: $subdir" fi fi done @@ -47,9 +52,9 @@ jobs: changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT - echo "Found changed subdirectories: $changed_subdirs" + echo "=== Final changed subdirectories: $changed_subdirs ===" - - name: Generate llms.txt updates with forced completion + - name: Generate llms.txt updates (restricted) if: steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 @@ -57,95 +62,116 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} run: | - # Create a script that will force completion - cat > force_complete.sh << 'EOF' - #!/bin/bash - set -euo pipefail - - echo "=== Starting forced completion approach ===" + echo "=== Starting restricted file modification process ===" + echo "Processing subdirectories: $CHANGED_SUBDIRS" - # Run cursor-agent in background - cursor-agent -p "You are updating documentation summary files. + cursor-agent -p "You are updating documentation summary files in a GitHub Actions runner. - TASK: Check if docs/$CHANGED_SUBDIRS/llms.txt and docs/$CHANGED_SUBDIRS/llms-full.txt need updates based on PR ${{ github.event.pull_request.number }}. + IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes and commenting on the PR. - PROCESS: - 1. Get diff: gh pr diff ${{ github.event.pull_request.number }} - 2. Read docs/$CHANGED_SUBDIRS/llms.txt - 3. Read docs/$CHANGED_SUBDIRS/llms-full.txt - 4. If changes warrant updates: modify the files - 5. If no updates needed: do nothing - 6. Print 'ANALYSIS_COMPLETE' and stop + # Context: + - Repo: ${{ github.repository }} + - PR Number: ${{ github.event.pull_request.number }} + - Base Ref: ${{ github.base_ref }} + - Head Ref: ${{ github.head_ref }} + - Changed Subdirectories: $CHANGED_SUBDIRS - CRITICAL: You have 5 minutes to complete this. Print 'ANALYSIS_COMPLETE' when done and exit immediately. Do not commit or push." \ - --force --model "$MODEL" --output-format=text & - - AGENT_PID=$! - echo "Started cursor-agent with PID: $AGENT_PID" - - # Force kill after 5 minutes - (sleep 300; echo "=== Forcing completion after 5 minutes ==="; kill -9 $AGENT_PID 2>/dev/null) & - KILLER_PID=$! - - # Wait for completion - if wait $AGENT_PID 2>/dev/null; then - echo "=== Agent completed normally ===" - kill $KILLER_PID 2>/dev/null || true - else - echo "=== Agent was terminated ===" - fi - - echo "=== Process finished ===" - EOF - - chmod +x force_complete.sh - ./force_complete.sh + # Your Task: + Update llms.txt and llms-full.txt files in the changed subdirectories based on documentation changes in this PR. - - name: Commit changes directly to PR branch + # Step-by-Step Process (print each step as you do it): + 1. Print 'STEP 1: Getting PR diff' + 2. Get PR changes: \`gh pr diff ${{ github.event.pull_request.number }}\` + 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' + 4. For each subdirectory in CHANGED_SUBDIRS: + a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' + b. Print 'STEP 3b: Reading docs/[subdirectory]/llms-full.txt' + c. Print 'STEP 3c: Analyzing if updates are needed for [subdirectory]' + d. If updates needed: Print 'STEP 3d: Updating files for [subdirectory]' and modify the files + e. If no updates needed: Print 'STEP 3e: No updates needed for [subdirectory]' + 5. Print 'STEP 4: File modifications complete' + 6. Print 'TASK_FINISHED' and exit + + # File Requirements: + - Only modify docs/[subdirectory]/llms.txt and docs/[subdirectory]/llms-full.txt files + - Do NOT modify root-level llms.txt or llms-full.txt files + - llms.txt should be a concise summary/index of the documentation in that subdirectory + - llms-full.txt should be a comprehensive guide with code examples and detailed explanations + - Maintain existing format and style + - Only update files that actually need changes based on PR content + + # Critical Restrictions: + - NO git operations (no commit, push, branch creation) + - NO PR comments or API calls except gh pr diff + - Only file modifications in working directory + - Must print progress steps as you go + - Must end with 'TASK_FINISHED' + + Begin now and print each step clearly. + " --force --model "$MODEL" --output-format=text + + echo "=== Cursor agent file modification completed ===" + + - name: Commit changes to PR branch (deterministic) if: steps.detect-changes.outputs.changed_subdirs != '' id: commit_changes run: | - echo "changes_committed=false" >> "$GITHUB_OUTPUT" + echo "=== Checking for file changes to commit ===" + # Stage all changes git add -A + # Check if there are any changes to commit if git diff --staged --quiet; then echo "No llms.txt changes to commit." + echo "changes_committed=false" >> "$GITHUB_OUTPUT" exit 0 fi - echo "Changes detected:" + echo "Changes detected in the following files:" git diff --staged --name-only - COMMIT_MSG="docs: update llms summaries for PR #${{ github.event.pull_request.number }}" + echo "=== Committing changes to PR branch ===" + COMMIT_MSG="docs: update llms summaries for subdirectories (${{ steps.detect-changes.outputs.changed_subdirs }})" git commit -m "$COMMIT_MSG" git push origin ${{ github.head_ref }} echo "changes_committed=true" >> "$GITHUB_OUTPUT" + echo "=== Changes committed and pushed successfully ===" - - name: Comment on PR about updates + - name: Post PR comment (deterministic) if: steps.commit_changes.outputs.changes_committed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | + echo "=== Posting PR comment about updates ===" + + # Get list of changed llms files changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" { - echo "🤖 **LLMs summaries updated**" + echo "🤖 **LLM summary files updated**" + echo "" + echo "Updated the following documentation summary files based on changes in subdirectories: \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" echo "" - echo "Updated documentation summary files:" + echo "**Files updated:**" for file in $changed_llms_files; do echo "- \`$file\`" done echo "" + echo "_This comment will be updated if you make more changes to the PR._" + echo "" echo "" } > "$COMMENT_FILE" + # Try to update existing comment, fall back to new comment if gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" --edit-last; then echo "Updated existing PR comment." else gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" echo "Posted new PR comment." fi + + echo "=== PR comment posted successfully ===" From 55bf3aa795998878ebf43cd2d3060bb11fe9d42e Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 11 Sep 2025 12:34:18 -0400 Subject: [PATCH 13/25] update web react page to test llms.txt update --- docs/base-account/quickstart/web-react.mdx | 56 +++++++++++++++------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/docs/base-account/quickstart/web-react.mdx b/docs/base-account/quickstart/web-react.mdx index a7f9384e..6a76ca46 100644 --- a/docs/base-account/quickstart/web-react.mdx +++ b/docs/base-account/quickstart/web-react.mdx @@ -1,28 +1,40 @@ --- -title: "Web (React)" -description: "This quick-start shows the minimum code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK." +title: "Web (Next.js)" +description: "Quickly add Sign in with Base and Base Pay to any Next.js app" --- import { GithubRepoCard } from "/snippets/GithubRepoCard.mdx" -This quick-start shows the **minimum** code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK. +This quick-start shows the **minimum** code required to add Sign in with Base and Base Pay to any Next.js app using the Base Account SDK. -## 1. Create a new React app +## 1. Create a new Next.js app -If you're starting fresh, create a new React app: +If you're starting fresh, create a new Next.js app: ```bash npm -npx create-react-app base-account-quickstart +npx create-next-app@latest base-account-quickstart cd base-account-quickstart ``` ```bash yarn -yarn create react-app base-account-quickstart +yarn create next-app base-account-quickstart +cd base-account-quickstart +``` + +```bash pnpm +pnpm create next-app base-account-quickstart +cd base-account-quickstart +``` + +```bash bun +bunx create-next-app base-account-quickstart cd base-account-quickstart ``` +When prompted during setup, you can choose the default options or customize as needed. For this quickstart, the default settings work perfectly. + ## 2. Install the SDK @@ -49,14 +61,18 @@ bun add @base-org/account @base-org/account-ui Use `--legacy-peer-deps` flag if you get a peer dependency error. -## 3. Replace src/App.js with this component +## 3. Create the main component + +Replace the contents of `app/page.tsx` (or `app/page.js` if not using TypeScript) with this component: + +```jsx title="app/page.tsx" lineNumbers +'use client'; -```jsx title="src/App.js" lineNumbers import React, { useState } from 'react'; import { createBaseAccountSDK, pay, getPaymentStatus } from '@base-org/account'; import { SignInWithBaseButton, BasePayButton } from '@base-org/account-ui/react'; -function App() { +export default function Home() { const [isSignedIn, setIsSignedIn] = useState(false); const [paymentStatus, setPaymentStatus] = useState(''); const [paymentId, setPaymentId] = useState(''); @@ -186,8 +202,6 @@ function App() { ); } - -export default App; ``` @@ -199,15 +213,23 @@ Make sure to replace `0xRecipientAddress` with your recipient address. ## 4. Start your app ```bash -npm start +npm run dev ``` Open http://localhost:3000, click **Sign in with Base** (optional) and then **Pay**, approve the transaction, and you've sent 5 USDC on Base Sepolia—done! 🎉 -**Note:** If you have an existing React app, just install the SDK (`npm install @base-org/account`) and add the component above to your project. +**Note:** If you have an existing Next.js app, just install the SDK (`npm install @base-org/account @base-org/account-ui`) and add the component above to your project. For other React frameworks, you can adapt this component as needed. ## Next steps -* **[Request profile data](/base-account/guides/accept-payments#collect-user-information-optional)** – ask the user for email, shipping address, etc. during `pay()` -* **[Sub Accounts guide](/base-account/improve-ux/sub-accounts)** – embed gas-less child wallets inside your app -* **[Mobile quick-start](/base-account/quickstart/mobile-integration)** – the same flow for React Native \ No newline at end of file +* **[Authenticate Users](/base-account/guides/authenticate-users)** strong authentication by setting up Sign in with Base with backend verification +* **[Accept Payments](/base-account/guides/accept-payments)** explore all the features of Base Pay +* **[Sign in with Base Button](/base-account/reference/ui-elements/sign-in-with-base-button)** – implement full SIWE authentication with backend verification +* **[Base Pay Button](/base-account/reference/ui-elements/base-pay-button)** – collect user information during payment flow + + +**Please Follow the Brand Guidelines** + +If you intend on using the `SignInWithBaseButton` or `BasePayButton`, please follow the [Brand Guidelines](/base-account/reference/ui-elements/brand-guidelines) to ensure consistency across your application. + + \ No newline at end of file From 424ffaae882d180ad5bb48550d249456dee5758c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 11 Sep 2025 17:04:35 +0000 Subject: [PATCH 14/25] docs: update llms summaries for subdirectories (base-account) --- docs/base-account/llms-full.txt | 16 ++++++---------- docs/base-account/llms.txt | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/base-account/llms-full.txt b/docs/base-account/llms-full.txt index f9bc96e4..10b532c2 100644 --- a/docs/base-account/llms-full.txt +++ b/docs/base-account/llms-full.txt @@ -26,8 +26,7 @@ const { status } = await getPaymentStatus({ id }) - [What is Base Account?](https://docs.base.org/base-account/overview/what-is-base-account.md) — Overview ### Quickstart -- [Web (Next.js)](https://docs.base.org/base-account/quickstart/web.md) — Web integration -- [Web (React)](https://docs.base.org/base-account/quickstart/web-react.md) — React example +- [Web (Next.js)](https://docs.base.org/base-account/quickstart/web-react.md) — Next.js integration - [React Native Integration](https://docs.base.org/base-account/quickstart/mobile-integration.md) — Mobile ### Guides @@ -77,23 +76,20 @@ const { status } = await getPaymentStatus({ id }) ## Quickstart (excerpts) -Source: `https://docs.base.org/base-account/quickstart/web.md` +Source: `https://docs.base.org/base-account/quickstart/web-react.md` Base Account lets you add a passkey‑secured ERC‑4337 smart account to your app, with sponsored gas, batch transactions, spend permissions, and sub‑accounts. Install and initialize: ```bash -npm install @base-org/account +npm install @base-org/account @base-org/account-ui ``` ```ts -import { createBaseAccount } from '@base-org/account' +import { createBaseAccountSDK } from '@base-org/account' -const account = await createBaseAccount({ - owner: '0xYourEOA', - chain: 'base-sepolia' -}) +const provider = createBaseAccountSDK().getProvider() ``` Send a payment with Base Pay (testnet): @@ -108,7 +104,7 @@ const { status } = await getPaymentStatus({ id }) Batch two calls in one user operation: ```ts -const result = await account.provider.request({ +const result = await provider.request({ method: 'wallet_sendCalls', params: [{ calls: [ diff --git a/docs/base-account/llms.txt b/docs/base-account/llms.txt index 15409b8f..5a304882 100644 --- a/docs/base-account/llms.txt +++ b/docs/base-account/llms.txt @@ -8,7 +8,7 @@ - [What is Base Account?](https://docs.base.org/base-account/overview/what-is-base-account.md) — Core concepts and benefits ## Quickstart -- [Web (Next.js)](https://docs.base.org/base-account/quickstart/web.md) — Add Base Account to a web app +- [Web (Next.js)](https://docs.base.org/base-account/quickstart/web-react.md) — Add Base Account to a Next.js app - [React Native Integration](https://docs.base.org/base-account/quickstart/mobile-integration.md) — Mobile setup and flows ## Guides From 6407734fe81633761ee51f6ebbee301021784011 Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 11 Sep 2025 14:56:06 -0400 Subject: [PATCH 15/25] update automation name --- .github/workflows/{main.yml => llms-txt-automation.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{main.yml => llms-txt-automation.yml} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/llms-txt-automation.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/llms-txt-automation.yml From 91f6f3c5ad7444161b967b331743fd3991761afa Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 11 Sep 2025 15:14:52 -0400 Subject: [PATCH 16/25] add llms txt automation --- .github/workflows/llms-txt-automation.yml | 179 ++++++++++++++++++++++ 1 file changed, 179 insertions(+) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 7fdb266e..397d5912 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -3,6 +3,8 @@ name: Update llms.txt and llms-full.txt in subdirectories on: pull_request: types: [opened, synchronize, reopened, ready_for_review] + issue_comment: + types: [created] permissions: contents: write @@ -161,6 +163,15 @@ jobs: echo "- \`$file\`" done echo "" + echo "---" + echo "💬 **Need changes to the LLM summaries?**" + echo "Reply to this comment with your feedback and I'll update the files accordingly!" + echo "" + echo "**Example feedback:**" + echo "- \"The summary is missing information about X feature\"" + echo "- \"Please add more code examples for Y\"" + echo "- \"The llms-full.txt should include Z section\"" + echo "" echo "_This comment will be updated if you make more changes to the PR._" echo "" echo "" @@ -175,3 +186,171 @@ jobs: fi echo "=== PR comment posted successfully ===" + + feedback-handler: + if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '🤖 **LLM summary files updated**') + runs-on: ubuntu-latest + steps: + - name: Check if comment is a reply to bot comment + id: check-reply + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.issue.number }} + COMMENT_ID: ${{ github.event.comment.id }} + run: | + echo "=== Checking if this is feedback on LLM updates ===" + + # Get all comments on the PR + comments=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments --jq '.[].body') + + # Check if there's a bot comment with the auto-update-llms marker + if echo "$comments" | grep -q ""; then + echo "Found bot comment with LLM updates" + + # Get the current comment + current_comment=$(gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body') + + # Check if the current comment is NOT the bot comment itself + if ! echo "$current_comment" | grep -q ""; then + echo "This is user feedback, not the bot comment itself" + echo "is_feedback=true" >> $GITHUB_OUTPUT + echo "feedback_text=$current_comment" >> $GITHUB_OUTPUT + else + echo "This is the bot comment itself, not user feedback" + echo "is_feedback=false" >> $GITHUB_OUTPUT + fi + else + echo "No bot comment found with LLM updates" + echo "is_feedback=false" >> $GITHUB_OUTPUT + fi + + - name: Checkout repository for feedback processing + if: steps.check-reply.outputs.is_feedback == 'true' + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Cursor CLI for feedback + if: steps.check-reply.outputs.is_feedback == 'true' + run: | + curl https://cursor.com/install -fsS | bash + echo "$HOME/.cursor/bin" >> $GITHUB_PATH + + - name: Configure git for feedback + if: steps.check-reply.outputs.is_feedback == 'true' + run: | + git config user.name "Cursor Agent" + git config user.email "cursoragent@cursor.com" + + - name: Process feedback and update files + if: steps.check-reply.outputs.is_feedback == 'true' + env: + MODEL: gpt-5 + CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FEEDBACK_TEXT: ${{ steps.check-reply.outputs.feedback_text }} + PR_NUMBER: ${{ github.event.issue.number }} + run: | + echo "=== Processing user feedback for LLM files ===" + echo "Feedback received: $FEEDBACK_TEXT" + + cursor-agent -p "You are processing user feedback about LLM summary files in a GitHub Actions runner. + + IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes. + + # Context: + - Repo: ${{ github.repository }} + - PR Number: $PR_NUMBER + - User Feedback: $FEEDBACK_TEXT + + # Your Task: + Based on the user feedback, update the appropriate llms.txt and llms-full.txt files in the docs subdirectories. + + # Step-by-Step Process (print each step as you do it): + 1. Print 'STEP 1: Analyzing user feedback' + 2. Print 'STEP 2: Getting current PR diff to understand context' + 3. Get PR changes: \`gh pr diff $PR_NUMBER\` + 4. Print 'STEP 3: Identifying which subdirectories need updates based on feedback' + 5. For each relevant subdirectory: + a. Print 'STEP 4a: Reading current docs/[subdirectory]/llms.txt' + b. Print 'STEP 4b: Reading current docs/[subdirectory]/llms-full.txt' + c. Print 'STEP 4c: Applying user feedback to [subdirectory] files' + d. Update the files based on the specific feedback provided + 6. Print 'STEP 5: Feedback processing complete' + 7. Print 'FEEDBACK_PROCESSED' and exit + + # File Requirements: + - Only modify docs/[subdirectory]/llms.txt and docs/[subdirectory]/llms-full.txt files + - Apply the specific changes requested in the user feedback + - Maintain existing format and style while incorporating feedback + - Focus on the areas specifically mentioned in the feedback + + # Critical Restrictions: + - NO git operations (no commit, push, branch creation) + - NO PR comments or API calls except gh pr diff + - Only file modifications in working directory + - Must print progress steps as you go + - Must end with 'FEEDBACK_PROCESSED' + + Begin now and print each step clearly. + " --force --model "$MODEL" --output-format=text + + echo "=== Feedback processing completed ===" + + - name: Commit feedback changes + if: steps.check-reply.outputs.is_feedback == 'true' + id: commit_feedback + run: | + echo "=== Checking for feedback-based changes to commit ===" + + # Stage all changes + git add -A + + # Check if there are any changes to commit + if git diff --staged --quiet; then + echo "No changes to commit based on feedback." + echo "changes_committed=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "Changes detected based on feedback:" + git diff --staged --name-only + + echo "=== Committing feedback changes to PR branch ===" + COMMIT_MSG="docs: update llms summaries based on user feedback" + git commit -m "$COMMIT_MSG" + git push origin ${{ github.head_ref }} + + echo "changes_committed=true" >> "$GITHUB_OUTPUT" + echo "=== Feedback changes committed and pushed successfully ===" + + - name: Reply to feedback comment + if: steps.commit_feedback.outputs.changes_committed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.issue.number }} + COMMENT_ID: ${{ github.event.comment.id }} + run: | + echo "=== Replying to feedback comment ===" + + # Get list of changed llms files + changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) + + REPLY_FILE="${RUNNER_TEMP}/feedback-reply.md" + { + echo "✅ **Feedback processed!**" + echo "" + echo "I've updated the LLM summary files based on your feedback." + echo "" + echo "**Files updated:**" + for file in $changed_llms_files; do + echo "- \`$file\`" + done + echo "" + echo "The changes have been committed to this PR. Please review and let me know if you need any further adjustments!" + } > "$REPLY_FILE" + + gh pr comment "$PR_NUMBER" --body-file "$REPLY_FILE" + echo "=== Feedback reply posted successfully ===" From fe26c4984d70bd1a495a932f7cb1bd70c77e6636 Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 11 Sep 2025 15:16:07 -0400 Subject: [PATCH 17/25] bring back react to test --- docs/base-account/quickstart/web-react.mdx | 56 +++++++--------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/docs/base-account/quickstart/web-react.mdx b/docs/base-account/quickstart/web-react.mdx index 6a76ca46..a7f9384e 100644 --- a/docs/base-account/quickstart/web-react.mdx +++ b/docs/base-account/quickstart/web-react.mdx @@ -1,40 +1,28 @@ --- -title: "Web (Next.js)" -description: "Quickly add Sign in with Base and Base Pay to any Next.js app" +title: "Web (React)" +description: "This quick-start shows the minimum code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK." --- import { GithubRepoCard } from "/snippets/GithubRepoCard.mdx" -This quick-start shows the **minimum** code required to add Sign in with Base and Base Pay to any Next.js app using the Base Account SDK. +This quick-start shows the **minimum** code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK. -## 1. Create a new Next.js app +## 1. Create a new React app -If you're starting fresh, create a new Next.js app: +If you're starting fresh, create a new React app: ```bash npm -npx create-next-app@latest base-account-quickstart +npx create-react-app base-account-quickstart cd base-account-quickstart ``` ```bash yarn -yarn create next-app base-account-quickstart -cd base-account-quickstart -``` - -```bash pnpm -pnpm create next-app base-account-quickstart -cd base-account-quickstart -``` - -```bash bun -bunx create-next-app base-account-quickstart +yarn create react-app base-account-quickstart cd base-account-quickstart ``` -When prompted during setup, you can choose the default options or customize as needed. For this quickstart, the default settings work perfectly. - ## 2. Install the SDK @@ -61,18 +49,14 @@ bun add @base-org/account @base-org/account-ui Use `--legacy-peer-deps` flag if you get a peer dependency error. -## 3. Create the main component - -Replace the contents of `app/page.tsx` (or `app/page.js` if not using TypeScript) with this component: - -```jsx title="app/page.tsx" lineNumbers -'use client'; +## 3. Replace src/App.js with this component +```jsx title="src/App.js" lineNumbers import React, { useState } from 'react'; import { createBaseAccountSDK, pay, getPaymentStatus } from '@base-org/account'; import { SignInWithBaseButton, BasePayButton } from '@base-org/account-ui/react'; -export default function Home() { +function App() { const [isSignedIn, setIsSignedIn] = useState(false); const [paymentStatus, setPaymentStatus] = useState(''); const [paymentId, setPaymentId] = useState(''); @@ -202,6 +186,8 @@ export default function Home() { ); } + +export default App; ``` @@ -213,23 +199,15 @@ Make sure to replace `0xRecipientAddress` with your recipient address. ## 4. Start your app ```bash -npm run dev +npm start ``` Open http://localhost:3000, click **Sign in with Base** (optional) and then **Pay**, approve the transaction, and you've sent 5 USDC on Base Sepolia—done! 🎉 -**Note:** If you have an existing Next.js app, just install the SDK (`npm install @base-org/account @base-org/account-ui`) and add the component above to your project. For other React frameworks, you can adapt this component as needed. +**Note:** If you have an existing React app, just install the SDK (`npm install @base-org/account`) and add the component above to your project. ## Next steps -* **[Authenticate Users](/base-account/guides/authenticate-users)** strong authentication by setting up Sign in with Base with backend verification -* **[Accept Payments](/base-account/guides/accept-payments)** explore all the features of Base Pay -* **[Sign in with Base Button](/base-account/reference/ui-elements/sign-in-with-base-button)** – implement full SIWE authentication with backend verification -* **[Base Pay Button](/base-account/reference/ui-elements/base-pay-button)** – collect user information during payment flow - - -**Please Follow the Brand Guidelines** - -If you intend on using the `SignInWithBaseButton` or `BasePayButton`, please follow the [Brand Guidelines](/base-account/reference/ui-elements/brand-guidelines) to ensure consistency across your application. - - \ No newline at end of file +* **[Request profile data](/base-account/guides/accept-payments#collect-user-information-optional)** – ask the user for email, shipping address, etc. during `pay()` +* **[Sub Accounts guide](/base-account/improve-ux/sub-accounts)** – embed gas-less child wallets inside your app +* **[Mobile quick-start](/base-account/quickstart/mobile-integration)** – the same flow for React Native \ No newline at end of file From c76d059a0196dfba10989fa52312801d6067137a Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:02:39 +0100 Subject: [PATCH 18/25] update llms automation --- .github/workflows/llms-txt-automation.yml | 493 +++++++++++----------- 1 file changed, 244 insertions(+), 249 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 397d5912..9a54e78d 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -11,15 +11,113 @@ permissions: pull-requests: write jobs: - auto-docs: - if: ${{ !startsWith(github.head_ref, 'docs/') }} + check-trigger: runs-on: ubuntu-latest + if: > + (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'docs/')) || + (github.event_name == 'issue_comment' && + github.event.issue.pull_request && + contains(github.event.comment.body, '/update-llms')) + outputs: + should_run: ${{ steps.check.outputs.should_run }} + pr_number: ${{ steps.check.outputs.pr_number }} + head_ref: ${{ steps.check.outputs.head_ref }} steps: + - name: Check trigger conditions + id: check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "=== PR event detected - posting instruction comment ===" + echo "should_run=false" >> $GITHUB_OUTPUT + echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + echo "head_ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT + elif [ "${{ github.event_name }}" = "issue_comment" ]; then + echo "=== Comment trigger detected - checking permissions ===" + + # Check if user has write permissions + user="${{ github.event.comment.user.login }}" + repo="${{ github.repository }}" + + permission=$(gh api repos/$repo/collaborators/$user/permission --jq '.permission' || echo "none") + echo "User $user has permission: $permission" + + if [[ "$permission" == "admin" || "$permission" == "write" ]]; then + echo "User has sufficient permissions" + echo "should_run=true" >> $GITHUB_OUTPUT + echo "pr_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT + + # Get PR head ref + head_ref=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq '.headRefName') + echo "head_ref=$head_ref" >> $GITHUB_OUTPUT + else + echo "User does not have sufficient permissions" + echo "should_run=false" >> $GITHUB_OUTPUT + fi + fi + + post-instruction: + needs: check-trigger + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && needs.check-trigger.outputs.should_run == 'false' + steps: + - name: Post instruction comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} + run: | + # Check if instruction comment already exists + existing_comment=$(gh pr view $PR_NUMBER --json comments --jq '.comments[] | select(.body | contains("")) | .id' || echo "") + + INSTRUCTION_FILE="${RUNNER_TEMP}/instruction-comment.md" + { + echo "🤖 **LLM Summary Files Automation Available**" + echo "" + echo "This PR can automatically update \`llms.txt\` and \`llms-full.txt\` files in subdirectories based on your documentation changes." + echo "" + echo "**To trigger the automation:**" + echo "Comment \`/update-llms\` on this PR" + echo "" + echo "**What it does:**" + echo "- Detects which subdirectories have documentation changes" + echo "- Updates the corresponding \`llms.txt\` and \`llms-full.txt\` summary files" + echo "- Commits the changes directly to this PR branch" + echo "" + echo "**Note:** Only users with write permissions can trigger this automation." + echo "" + echo "_This automation is optional and not required for PR approval._" + echo "" + echo "" + } > "$INSTRUCTION_FILE" + + if [ -n "$existing_comment" ]; then + echo "Updating existing instruction comment" + gh api repos/${{ github.repository }}/issues/comments/$existing_comment \ + -X PATCH -f body="$(cat $INSTRUCTION_FILE)" + else + echo "Posting new instruction comment" + gh pr comment $PR_NUMBER --body-file "$INSTRUCTION_FILE" + fi + + update-llms: + needs: check-trigger + runs-on: ubuntu-latest + if: needs.check-trigger.outputs.should_run == 'true' + steps: + - name: Acknowledge trigger + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} + run: | + echo "🚀 Starting LLM summary files update..." | \ + gh pr comment $PR_NUMBER --body-file - + - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} + ref: ${{ needs.check-trigger.outputs.head_ref }} - name: Install Cursor CLI run: | @@ -36,7 +134,7 @@ jobs: run: | echo "=== Detecting changed subdirectories ===" - changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) + changed_files=$(git diff --name-only origin/main...HEAD -- docs/) echo "Changed files in docs/:" echo "$changed_files" @@ -56,301 +154,198 @@ jobs: echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT echo "=== Final changed subdirectories: $changed_subdirs ===" - - name: Generate llms.txt updates (restricted) + - name: Update LLM summary files if: steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} + PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} run: | - echo "=== Starting restricted file modification process ===" + echo "=== Starting LLM summary files update ===" echo "Processing subdirectories: $CHANGED_SUBDIRS" - cursor-agent -p "You are updating documentation summary files in a GitHub Actions runner. + cursor-agent -p "You are a documentation expert updating LLM summary files in a GitHub Actions runner. - IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes and commenting on the PR. + CRITICAL: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory. # Context: - Repo: ${{ github.repository }} - - PR Number: ${{ github.event.pull_request.number }} - - Base Ref: ${{ github.base_ref }} - - Head Ref: ${{ github.head_ref }} + - PR Number: $PR_NUMBER - Changed Subdirectories: $CHANGED_SUBDIRS - # Your Task: - Update llms.txt and llms-full.txt files in the changed subdirectories based on documentation changes in this PR. - - # Step-by-Step Process (print each step as you do it): - 1. Print 'STEP 1: Getting PR diff' - 2. Get PR changes: \`gh pr diff ${{ github.event.pull_request.number }}\` - 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' - 4. For each subdirectory in CHANGED_SUBDIRS: - a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' - b. Print 'STEP 3b: Reading docs/[subdirectory]/llms-full.txt' - c. Print 'STEP 3c: Analyzing if updates are needed for [subdirectory]' - d. If updates needed: Print 'STEP 3d: Updating files for [subdirectory]' and modify the files - e. If no updates needed: Print 'STEP 3e: No updates needed for [subdirectory]' - 5. Print 'STEP 4: File modifications complete' - 6. Print 'TASK_FINISHED' and exit + # Your Mission: + Create exceptional LLM summary files that serve as the definitive reference for AI assistants working with this documentation. + + # Deep Analysis Process: + + ## STEP 1: Understanding the Changes + Print 'STEP 1: Getting PR diff and analyzing changes' + - Run: \`gh pr diff $PR_NUMBER\` + - Identify what type of changes occurred (new features, API changes, examples, guides, etc.) + - Understand the scope and significance of each change + - Note any new concepts, workflows, or code patterns introduced + + ## STEP 2: Comprehensive Documentation Scan + Print 'STEP 2: Scanning documentation structure for each subdirectory' + For each subdirectory in CHANGED_SUBDIRS: + - Read ALL .mdx files in the subdirectory to understand the complete picture + - Map out the documentation hierarchy and relationships + - Identify key concepts, workflows, APIs, and code examples + - Note the target audience and use cases for each section + + ## STEP 3: Current Summary Analysis + Print 'STEP 3: Analyzing existing llms.txt and llms-full.txt files' + For each subdirectory: + - Read current docs/[subdirectory]/llms.txt + - Read current docs/[subdirectory]/llms-full.txt + - Identify gaps, outdated information, or missing content + - Assess if the current structure and organization is optimal + + ## STEP 4: Intelligent Update Strategy + Print 'STEP 4: Determining update strategy for each subdirectory' + For each subdirectory, decide: + - Does the content warrant updates to the summary files? + - What new information needs to be added? + - What existing content needs to be modified or reorganized? + - How can the summaries better serve AI assistants and developers? + + ## STEP 5: Creating Exceptional Summary Files + Print 'STEP 5: Updating summary files with comprehensive improvements' + + ### For llms.txt (Concise Navigation Guide): + - Create a clean, scannable index that helps AI quickly understand what's available + - Use consistent formatting with clear hierarchical structure + - Include brief but informative descriptions for each section + - Highlight key workflows and entry points + - Add practical context about when to use each resource + - Ensure links are accurate and follow consistent patterns + - Keep it concise but comprehensive enough to serve as a roadmap + + ### For llms-full.txt (Comprehensive AI Assistant Guide): + - Provide rich context that helps AI assistants give better answers + - Include essential code patterns and examples that demonstrate key concepts + - Explain the 'why' behind different approaches, not just the 'how' + - Cover common use cases, gotchas, and best practices + - Include relevant configuration examples and typical workflows + - Provide context about how different features work together + - Add troubleshooting guidance for common issues + - Structure information logically for easy AI parsing and retrieval + - Include cross-references to related concepts and external resources + + ### Quality Standards: + - Maintain consistent voice and style with existing documentation + - Use clear, precise language that both humans and AI can understand + - Ensure all code examples are accurate and follow current best practices + - Keep information current and remove outdated references + - Structure content for both sequential reading and random access + - Include enough context so each section can stand alone when needed + + ## STEP 6: Validation and Completion + Print 'STEP 6: Validating updates and completing task' + - Verify all links and references are correct + - Ensure consistency in formatting and style + - Check that new content integrates well with existing structure + - Confirm that the summaries accurately reflect the current state of documentation + + Print 'TASK_FINISHED' # File Requirements: - Only modify docs/[subdirectory]/llms.txt and docs/[subdirectory]/llms-full.txt files - - Do NOT modify root-level llms.txt or llms-full.txt files - - llms.txt should be a concise summary/index of the documentation in that subdirectory - - llms-full.txt should be a comprehensive guide with code examples and detailed explanations - - Maintain existing format and style - - Only update files that actually need changes based on PR content - - # Critical Restrictions: - - NO git operations (no commit, push, branch creation) - - NO PR comments or API calls except gh pr diff - - Only file modifications in working directory - - Must print progress steps as you go - - Must end with 'TASK_FINISHED' - - Begin now and print each step clearly. + - Do NOT modify root-level llms files + - Maintain existing URL patterns and formatting conventions + - Ensure summaries are valuable for both AI assistants and human developers + - Focus on clarity, accuracy, and comprehensive coverage + + # Success Criteria: + - An AI assistant reading these files can provide excellent guidance on the subdirectory's content + - Developers can quickly understand what's available and how to get started + - The summaries accurately reflect the current state and capabilities + - Information is well-organized and easy to navigate + - Code examples are current and demonstrate best practices + + Begin your comprehensive analysis now. Take the time needed to create truly exceptional summary files. " --force --model "$MODEL" --output-format=text - echo "=== Cursor agent file modification completed ===" + echo "=== Cursor agent completed ===" - - name: Commit changes to PR branch (deterministic) + - name: Commit and push changes if: steps.detect-changes.outputs.changed_subdirs != '' id: commit_changes run: | - echo "=== Checking for file changes to commit ===" + echo "=== Checking for changes ===" - # Stage all changes git add -A - # Check if there are any changes to commit if git diff --staged --quiet; then - echo "No llms.txt changes to commit." + echo "No changes to commit" echo "changes_committed=false" >> "$GITHUB_OUTPUT" exit 0 fi - echo "Changes detected in the following files:" + echo "Changes detected:" git diff --staged --name-only - echo "=== Committing changes to PR branch ===" COMMIT_MSG="docs: update llms summaries for subdirectories (${{ steps.detect-changes.outputs.changed_subdirs }})" git commit -m "$COMMIT_MSG" - git push origin ${{ github.head_ref }} + git push origin ${{ needs.check-trigger.outputs.head_ref }} echo "changes_committed=true" >> "$GITHUB_OUTPUT" - echo "=== Changes committed and pushed successfully ===" + echo "=== Changes committed successfully ===" - - name: Post PR comment (deterministic) - if: steps.commit_changes.outputs.changes_committed == 'true' + - name: Report results env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} + PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} run: | - echo "=== Posting PR comment about updates ===" - - # Get list of changed llms files - changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) - - COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" - { - echo "🤖 **LLM summary files updated**" - echo "" - echo "Updated the following documentation summary files based on changes in subdirectories: \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" - echo "" - echo "**Files updated:**" - for file in $changed_llms_files; do - echo "- \`$file\`" - done - echo "" - echo "---" - echo "💬 **Need changes to the LLM summaries?**" - echo "Reply to this comment with your feedback and I'll update the files accordingly!" - echo "" - echo "**Example feedback:**" - echo "- \"The summary is missing information about X feature\"" - echo "- \"Please add more code examples for Y\"" - echo "- \"The llms-full.txt should include Z section\"" - echo "" - echo "_This comment will be updated if you make more changes to the PR._" - echo "" - echo "" - } > "$COMMENT_FILE" - - # Try to update existing comment, fall back to new comment - if gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" --edit-last; then - echo "Updated existing PR comment." - else - gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" - echo "Posted new PR comment." - fi - - echo "=== PR comment posted successfully ===" - - feedback-handler: - if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '🤖 **LLM summary files updated**') - runs-on: ubuntu-latest - steps: - - name: Check if comment is a reply to bot comment - id: check-reply - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.issue.number }} - COMMENT_ID: ${{ github.event.comment.id }} - run: | - echo "=== Checking if this is feedback on LLM updates ===" - - # Get all comments on the PR - comments=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments --jq '.[].body') - - # Check if there's a bot comment with the auto-update-llms marker - if echo "$comments" | grep -q ""; then - echo "Found bot comment with LLM updates" + if [ "${{ steps.commit_changes.outputs.changes_committed }}" = "true" ]; then + changed_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) - # Get the current comment - current_comment=$(gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body') + RESULT_FILE="${RUNNER_TEMP}/result-comment.md" + { + echo "✅ **LLM summary files updated successfully!**" + echo "" + echo "I've thoroughly analyzed the documentation changes and updated the LLM summary files to provide comprehensive, up-to-date guidance for AI assistants and developers." + echo "" + echo "**Subdirectories processed:** \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" + echo "" + echo "**Files modified:**" + for file in $changed_files; do + echo "- \`$file\`" + done + echo "" + echo "**What was updated:**" + echo "- 📋 **llms.txt files**: Refreshed navigation guides with current content structure" + echo "- 📚 **llms-full.txt files**: Enhanced comprehensive guides with latest code examples and best practices" + echo "- 🔗 **Cross-references**: Updated links and relationships between concepts" + echo "- ⚡ **AI optimization**: Improved structure for better AI assistant responses" + echo "" + echo "The summary files now accurately reflect your documentation changes and will help AI assistants provide better guidance to developers." + } > "$RESULT_FILE" - # Check if the current comment is NOT the bot comment itself - if ! echo "$current_comment" | grep -q ""; then - echo "This is user feedback, not the bot comment itself" - echo "is_feedback=true" >> $GITHUB_OUTPUT - echo "feedback_text=$current_comment" >> $GITHUB_OUTPUT - else - echo "This is the bot comment itself, not user feedback" - echo "is_feedback=false" >> $GITHUB_OUTPUT - fi + gh pr comment $PR_NUMBER --body-file "$RESULT_FILE" + elif [ "${{ steps.detect-changes.outputs.changed_subdirs }}" != "" ]; then + echo "📝 After thorough analysis, no updates were needed for the LLM summary files. The existing summaries already accurately reflect the documentation changes." | \ + gh pr comment $PR_NUMBER --body-file - else - echo "No bot comment found with LLM updates" - echo "is_feedback=false" >> $GITHUB_OUTPUT + echo "ℹ️ No subdirectories with LLM summary files were changed in this PR." | \ + gh pr comment $PR_NUMBER --body-file - fi - - name: Checkout repository for feedback processing - if: steps.check-reply.outputs.is_feedback == 'true' - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Cursor CLI for feedback - if: steps.check-reply.outputs.is_feedback == 'true' - run: | - curl https://cursor.com/install -fsS | bash - echo "$HOME/.cursor/bin" >> $GITHUB_PATH - - - name: Configure git for feedback - if: steps.check-reply.outputs.is_feedback == 'true' - run: | - git config user.name "Cursor Agent" - git config user.email "cursoragent@cursor.com" - - - name: Process feedback and update files - if: steps.check-reply.outputs.is_feedback == 'true' + permission-denied: + needs: check-trigger + runs-on: ubuntu-latest + if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/update-llms') && needs.check-trigger.outputs.should_run == 'false' + steps: + - name: Reply with permission error env: - MODEL: gpt-5 - CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - FEEDBACK_TEXT: ${{ steps.check-reply.outputs.feedback_text }} PR_NUMBER: ${{ github.event.issue.number }} run: | - echo "=== Processing user feedback for LLM files ===" - echo "Feedback received: $FEEDBACK_TEXT" - - cursor-agent -p "You are processing user feedback about LLM summary files in a GitHub Actions runner. - - IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. A later workflow step is responsible for publishing changes. + echo "❌ **Permission denied** - # Context: - - Repo: ${{ github.repository }} - - PR Number: $PR_NUMBER - - User Feedback: $FEEDBACK_TEXT - - # Your Task: - Based on the user feedback, update the appropriate llms.txt and llms-full.txt files in the docs subdirectories. - - # Step-by-Step Process (print each step as you do it): - 1. Print 'STEP 1: Analyzing user feedback' - 2. Print 'STEP 2: Getting current PR diff to understand context' - 3. Get PR changes: \`gh pr diff $PR_NUMBER\` - 4. Print 'STEP 3: Identifying which subdirectories need updates based on feedback' - 5. For each relevant subdirectory: - a. Print 'STEP 4a: Reading current docs/[subdirectory]/llms.txt' - b. Print 'STEP 4b: Reading current docs/[subdirectory]/llms-full.txt' - c. Print 'STEP 4c: Applying user feedback to [subdirectory] files' - d. Update the files based on the specific feedback provided - 6. Print 'STEP 5: Feedback processing complete' - 7. Print 'FEEDBACK_PROCESSED' and exit - - # File Requirements: - - Only modify docs/[subdirectory]/llms.txt and docs/[subdirectory]/llms-full.txt files - - Apply the specific changes requested in the user feedback - - Maintain existing format and style while incorporating feedback - - Focus on the areas specifically mentioned in the feedback - - # Critical Restrictions: - - NO git operations (no commit, push, branch creation) - - NO PR comments or API calls except gh pr diff - - Only file modifications in working directory - - Must print progress steps as you go - - Must end with 'FEEDBACK_PROCESSED' - - Begin now and print each step clearly. - " --force --model "$MODEL" --output-format=text - - echo "=== Feedback processing completed ===" - - - name: Commit feedback changes - if: steps.check-reply.outputs.is_feedback == 'true' - id: commit_feedback - run: | - echo "=== Checking for feedback-based changes to commit ===" - - # Stage all changes - git add -A - - # Check if there are any changes to commit - if git diff --staged --quiet; then - echo "No changes to commit based on feedback." - echo "changes_committed=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - - echo "Changes detected based on feedback:" - git diff --staged --name-only - - echo "=== Committing feedback changes to PR branch ===" - COMMIT_MSG="docs: update llms summaries based on user feedback" - git commit -m "$COMMIT_MSG" - git push origin ${{ github.head_ref }} - - echo "changes_committed=true" >> "$GITHUB_OUTPUT" - echo "=== Feedback changes committed and pushed successfully ===" - - - name: Reply to feedback comment - if: steps.commit_feedback.outputs.changes_committed == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.issue.number }} - COMMENT_ID: ${{ github.event.comment.id }} - run: | - echo "=== Replying to feedback comment ===" - - # Get list of changed llms files - changed_llms_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) - - REPLY_FILE="${RUNNER_TEMP}/feedback-reply.md" - { - echo "✅ **Feedback processed!**" - echo "" - echo "I've updated the LLM summary files based on your feedback." - echo "" - echo "**Files updated:**" - for file in $changed_llms_files; do - echo "- \`$file\`" - done - echo "" - echo "The changes have been committed to this PR. Please review and let me know if you need any further adjustments!" - } > "$REPLY_FILE" + Only users with write permissions to this repository can trigger the LLM summary files automation. - gh pr comment "$PR_NUMBER" --body-file "$REPLY_FILE" - echo "=== Feedback reply posted successfully ===" + Please ask a maintainer to run \`/update-llms\` if you need the summary files updated." | \ + gh pr comment $PR_NUMBER --body-file - \ No newline at end of file From 31fb64a1ee238731efd29d2712585f5a067fb883 Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:31:41 +0100 Subject: [PATCH 19/25] update github action --- .github/workflows/llms-txt-automation.yml | 314 +++++----------------- 1 file changed, 65 insertions(+), 249 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 9a54e78d..09f008f5 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -3,121 +3,22 @@ name: Update llms.txt and llms-full.txt in subdirectories on: pull_request: types: [opened, synchronize, reopened, ready_for_review] - issue_comment: - types: [created] permissions: contents: write pull-requests: write jobs: - check-trigger: + auto-docs: + if: ${{ !startsWith(github.head_ref, 'docs/') }} runs-on: ubuntu-latest - if: > - (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'docs/')) || - (github.event_name == 'issue_comment' && - github.event.issue.pull_request && - contains(github.event.comment.body, '/update-llms')) - outputs: - should_run: ${{ steps.check.outputs.should_run }} - pr_number: ${{ steps.check.outputs.pr_number }} - head_ref: ${{ steps.check.outputs.head_ref }} + timeout-minutes: 20 steps: - - name: Check trigger conditions - id: check - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "=== PR event detected - posting instruction comment ===" - echo "should_run=false" >> $GITHUB_OUTPUT - echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - echo "head_ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT - elif [ "${{ github.event_name }}" = "issue_comment" ]; then - echo "=== Comment trigger detected - checking permissions ===" - - # Check if user has write permissions - user="${{ github.event.comment.user.login }}" - repo="${{ github.repository }}" - - permission=$(gh api repos/$repo/collaborators/$user/permission --jq '.permission' || echo "none") - echo "User $user has permission: $permission" - - if [[ "$permission" == "admin" || "$permission" == "write" ]]; then - echo "User has sufficient permissions" - echo "should_run=true" >> $GITHUB_OUTPUT - echo "pr_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT - - # Get PR head ref - head_ref=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq '.headRefName') - echo "head_ref=$head_ref" >> $GITHUB_OUTPUT - else - echo "User does not have sufficient permissions" - echo "should_run=false" >> $GITHUB_OUTPUT - fi - fi - - post-instruction: - needs: check-trigger - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && needs.check-trigger.outputs.should_run == 'false' - steps: - - name: Post instruction comment - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} - run: | - # Check if instruction comment already exists - existing_comment=$(gh pr view $PR_NUMBER --json comments --jq '.comments[] | select(.body | contains("")) | .id' || echo "") - - INSTRUCTION_FILE="${RUNNER_TEMP}/instruction-comment.md" - { - echo "🤖 **LLM Summary Files Automation Available**" - echo "" - echo "This PR can automatically update \`llms.txt\` and \`llms-full.txt\` files in subdirectories based on your documentation changes." - echo "" - echo "**To trigger the automation:**" - echo "Comment \`/update-llms\` on this PR" - echo "" - echo "**What it does:**" - echo "- Detects which subdirectories have documentation changes" - echo "- Updates the corresponding \`llms.txt\` and \`llms-full.txt\` summary files" - echo "- Commits the changes directly to this PR branch" - echo "" - echo "**Note:** Only users with write permissions can trigger this automation." - echo "" - echo "_This automation is optional and not required for PR approval._" - echo "" - echo "" - } > "$INSTRUCTION_FILE" - - if [ -n "$existing_comment" ]; then - echo "Updating existing instruction comment" - gh api repos/${{ github.repository }}/issues/comments/$existing_comment \ - -X PATCH -f body="$(cat $INSTRUCTION_FILE)" - else - echo "Posting new instruction comment" - gh pr comment $PR_NUMBER --body-file "$INSTRUCTION_FILE" - fi - - update-llms: - needs: check-trigger - runs-on: ubuntu-latest - if: needs.check-trigger.outputs.should_run == 'true' - steps: - - name: Acknowledge trigger - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} - run: | - echo "🚀 Starting LLM summary files update..." | \ - gh pr comment $PR_NUMBER --body-file - - - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ needs.check-trigger.outputs.head_ref }} + ref: ${{ github.head_ref }} - name: Install Cursor CLI run: | @@ -134,7 +35,7 @@ jobs: run: | echo "=== Detecting changed subdirectories ===" - changed_files=$(git diff --name-only origin/main...HEAD -- docs/) + changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) echo "Changed files in docs/:" echo "$changed_files" @@ -161,116 +62,58 @@ jobs: CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHANGED_SUBDIRS: ${{ steps.detect-changes.outputs.changed_subdirs }} - PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} run: | echo "=== Starting LLM summary files update ===" echo "Processing subdirectories: $CHANGED_SUBDIRS" - cursor-agent -p "You are a documentation expert updating LLM summary files in a GitHub Actions runner. + cursor-agent -p "You are updating documentation summary files in a GitHub Actions runner. - CRITICAL: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory. + IMPORTANT: Do NOT create branches, commit, push, or post PR comments. Only modify files in the working directory as needed. # Context: - Repo: ${{ github.repository }} - - PR Number: $PR_NUMBER + - PR Number: ${{ github.event.pull_request.number }} + - Base Ref: ${{ github.base_ref }} + - Head Ref: ${{ github.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS - # Your Mission: - Create exceptional LLM summary files that serve as the definitive reference for AI assistants working with this documentation. - - # Deep Analysis Process: - - ## STEP 1: Understanding the Changes - Print 'STEP 1: Getting PR diff and analyzing changes' - - Run: \`gh pr diff $PR_NUMBER\` - - Identify what type of changes occurred (new features, API changes, examples, guides, etc.) - - Understand the scope and significance of each change - - Note any new concepts, workflows, or code patterns introduced - - ## STEP 2: Comprehensive Documentation Scan - Print 'STEP 2: Scanning documentation structure for each subdirectory' - For each subdirectory in CHANGED_SUBDIRS: - - Read ALL .mdx files in the subdirectory to understand the complete picture - - Map out the documentation hierarchy and relationships - - Identify key concepts, workflows, APIs, and code examples - - Note the target audience and use cases for each section - - ## STEP 3: Current Summary Analysis - Print 'STEP 3: Analyzing existing llms.txt and llms-full.txt files' - For each subdirectory: - - Read current docs/[subdirectory]/llms.txt - - Read current docs/[subdirectory]/llms-full.txt - - Identify gaps, outdated information, or missing content - - Assess if the current structure and organization is optimal - - ## STEP 4: Intelligent Update Strategy - Print 'STEP 4: Determining update strategy for each subdirectory' - For each subdirectory, decide: - - Does the content warrant updates to the summary files? - - What new information needs to be added? - - What existing content needs to be modified or reorganized? - - How can the summaries better serve AI assistants and developers? - - ## STEP 5: Creating Exceptional Summary Files - Print 'STEP 5: Updating summary files with comprehensive improvements' - - ### For llms.txt (Concise Navigation Guide): - - Create a clean, scannable index that helps AI quickly understand what's available - - Use consistent formatting with clear hierarchical structure - - Include brief but informative descriptions for each section - - Highlight key workflows and entry points - - Add practical context about when to use each resource - - Ensure links are accurate and follow consistent patterns - - Keep it concise but comprehensive enough to serve as a roadmap - - ### For llms-full.txt (Comprehensive AI Assistant Guide): - - Provide rich context that helps AI assistants give better answers - - Include essential code patterns and examples that demonstrate key concepts - - Explain the 'why' behind different approaches, not just the 'how' - - Cover common use cases, gotchas, and best practices - - Include relevant configuration examples and typical workflows - - Provide context about how different features work together - - Add troubleshooting guidance for common issues - - Structure information logically for easy AI parsing and retrieval - - Include cross-references to related concepts and external resources - - ### Quality Standards: - - Maintain consistent voice and style with existing documentation - - Use clear, precise language that both humans and AI can understand - - Ensure all code examples are accurate and follow current best practices - - Keep information current and remove outdated references - - Structure content for both sequential reading and random access - - Include enough context so each section can stand alone when needed - - ## STEP 6: Validation and Completion - Print 'STEP 6: Validating updates and completing task' - - Verify all links and references are correct - - Ensure consistency in formatting and style - - Check that new content integrates well with existing structure - - Confirm that the summaries accurately reflect the current state of documentation - - Print 'TASK_FINISHED' + # Your Task: + Update llms.txt and llms-full.txt files in the changed subdirectories based on documentation changes in this PR. + + # Step-by-Step Process (print each step): + 1. Print 'STEP 1: Getting PR diff' + 2. Get PR changes: \`gh pr diff ${{ github.event.pull_request.number }}\` + 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' + 4. For each subdirectory in CHANGED_SUBDIRS: + a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' + b. Print 'STEP 3b: Reading docs/[subdirectory]/llms-full.txt' + c. Print 'STEP 3c: Analyzing changes for [subdirectory]' + d. If updates needed: Print 'STEP 3d: Updating files for [subdirectory]' and modify files + e. If no updates needed: Print 'STEP 3e: No updates needed for [subdirectory]' + 5. Print 'STEP 4: File modifications complete' + 6. Print 'TASK_FINISHED' # File Requirements: - Only modify docs/[subdirectory]/llms.txt and docs/[subdirectory]/llms-full.txt files - - Do NOT modify root-level llms files - - Maintain existing URL patterns and formatting conventions - - Ensure summaries are valuable for both AI assistants and human developers - - Focus on clarity, accuracy, and comprehensive coverage - - # Success Criteria: - - An AI assistant reading these files can provide excellent guidance on the subdirectory's content - - Developers can quickly understand what's available and how to get started - - The summaries accurately reflect the current state and capabilities - - Information is well-organized and easy to navigate - - Code examples are current and demonstrate best practices - - Begin your comprehensive analysis now. Take the time needed to create truly exceptional summary files. + - Do NOT modify root-level llms.txt or llms-full.txt files + - llms.txt should be a concise summary/index of subdirectory documentation + - llms-full.txt should be a comprehensive guide with code examples + - Maintain existing format and style + - Only update files that need changes based on PR content + + # Restrictions: + - NO git operations (no commit, push, branch creation) + - NO PR comments or API calls except gh pr diff + - Only file modifications in working directory + - Print progress steps as you go + - End with 'TASK_FINISHED' + + Begin now and print each step clearly. " --force --model "$MODEL" --output-format=text echo "=== Cursor agent completed ===" - - name: Commit and push changes + - name: Commit changes to PR branch if: steps.detect-changes.outputs.changed_subdirs != '' id: commit_changes run: | @@ -289,63 +132,36 @@ jobs: COMMIT_MSG="docs: update llms summaries for subdirectories (${{ steps.detect-changes.outputs.changed_subdirs }})" git commit -m "$COMMIT_MSG" - git push origin ${{ needs.check-trigger.outputs.head_ref }} + git push origin ${{ github.head_ref }} echo "changes_committed=true" >> "$GITHUB_OUTPUT" echo "=== Changes committed successfully ===" - - name: Report results - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ needs.check-trigger.outputs.pr_number }} - run: | - if [ "${{ steps.commit_changes.outputs.changes_committed }}" = "true" ]; then - changed_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) - - RESULT_FILE="${RUNNER_TEMP}/result-comment.md" - { - echo "✅ **LLM summary files updated successfully!**" - echo "" - echo "I've thoroughly analyzed the documentation changes and updated the LLM summary files to provide comprehensive, up-to-date guidance for AI assistants and developers." - echo "" - echo "**Subdirectories processed:** \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" - echo "" - echo "**Files modified:**" - for file in $changed_files; do - echo "- \`$file\`" - done - echo "" - echo "**What was updated:**" - echo "- 📋 **llms.txt files**: Refreshed navigation guides with current content structure" - echo "- 📚 **llms-full.txt files**: Enhanced comprehensive guides with latest code examples and best practices" - echo "- 🔗 **Cross-references**: Updated links and relationships between concepts" - echo "- ⚡ **AI optimization**: Improved structure for better AI assistant responses" - echo "" - echo "The summary files now accurately reflect your documentation changes and will help AI assistants provide better guidance to developers." - } > "$RESULT_FILE" - - gh pr comment $PR_NUMBER --body-file "$RESULT_FILE" - elif [ "${{ steps.detect-changes.outputs.changed_subdirs }}" != "" ]; then - echo "📝 After thorough analysis, no updates were needed for the LLM summary files. The existing summaries already accurately reflect the documentation changes." | \ - gh pr comment $PR_NUMBER --body-file - - else - echo "ℹ️ No subdirectories with LLM summary files were changed in this PR." | \ - gh pr comment $PR_NUMBER --body-file - - fi - - permission-denied: - needs: check-trigger - runs-on: ubuntu-latest - if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/update-llms') && needs.check-trigger.outputs.should_run == 'false' - steps: - - name: Reply with permission error + - name: Post PR comment about updates + if: steps.commit_changes.outputs.changes_committed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.issue.number }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | - echo "❌ **Permission denied** - - Only users with write permissions to this repository can trigger the LLM summary files automation. + echo "=== Posting PR comment about updates ===" + + changed_files=$(git diff HEAD~1 --name-only | grep -E "llms(-full)?\.txt$" | head -10) + + COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" + { + echo "🤖 **LLM summary files updated**" + echo "" + echo "Updated documentation summary files based on changes in subdirectories: \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" + echo "" + echo "**Files updated:**" + for file in $changed_files; do + echo "- \`$file\`" + done + echo "" + echo "_These files help AI assistants provide better guidance about your documentation._" + echo "" + echo "" + } > "$COMMENT_FILE" - Please ask a maintainer to run \`/update-llms\` if you need the summary files updated." | \ - gh pr comment $PR_NUMBER --body-file - \ No newline at end of file + gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" + echo "=== PR comment posted successfully ===" \ No newline at end of file From 040508c19114ec521d3fbbe37760dcdf42fcf701 Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:37:51 +0100 Subject: [PATCH 20/25] make trigger manual --- .github/workflows/llms-txt-automation.yml | 36 ++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 09f008f5..a6805b7e 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -1,8 +1,12 @@ name: Update llms.txt and llms-full.txt in subdirectories on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] + workflow_dispatch: + inputs: + pr_number: + description: 'PR number to update LLM files for' + required: true + type: number permissions: contents: write @@ -10,15 +14,39 @@ permissions: jobs: auto-docs: - if: ${{ !startsWith(github.head_ref, 'docs/') }} runs-on: ubuntu-latest timeout-minutes: 20 steps: + - name: Get PR information + id: pr-info + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.inputs.pr_number }} + run: | + echo "=== Getting PR information ===" + pr_data=$(gh pr view $PR_NUMBER --json headRefName,baseRefName,state) + head_ref=$(echo "$pr_data" | jq -r '.headRefName') + base_ref=$(echo "$pr_data" | jq -r '.baseRefName') + state=$(echo "$pr_data" | jq -r '.state') + + echo "PR #$PR_NUMBER:" + echo " Head: $head_ref" + echo " Base: $base_ref" + echo " State: $state" + + if [ "$state" != "OPEN" ]; then + echo "Error: PR #$PR_NUMBER is not open" + exit 1 + fi + + echo "head_ref=$head_ref" >> $GITHUB_OUTPUT + echo "base_ref=$base_ref" >> $GITHUB_OUTPUT + - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} + ref: ${{ steps.pr-info.outputs.head_ref }} - name: Install Cursor CLI run: | From 5965cbe9b979096206fa86c1f7751c544e5b9285 Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:37:59 +0100 Subject: [PATCH 21/25] update yml --- .github/workflows/llms-txt-automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index a6805b7e..202d7ece 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -63,7 +63,7 @@ jobs: run: | echo "=== Detecting changed subdirectories ===" - changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- docs/) + changed_files=$(git diff --name-only origin/${{ steps.pr-info.outputs.base_ref }}...HEAD -- docs/) echo "Changed files in docs/:" echo "$changed_files" From cfe499e2befecf75cbf7679f995119a36f444ed9 Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:38:07 +0100 Subject: [PATCH 22/25] update yml --- .github/workflows/llms-txt-automation.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 202d7ece..443591d5 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -100,9 +100,9 @@ jobs: # Context: - Repo: ${{ github.repository }} - - PR Number: ${{ github.event.pull_request.number }} - - Base Ref: ${{ github.base_ref }} - - Head Ref: ${{ github.head_ref }} + - PR Number: ${{ github.event.inputs.pr_number }} + - Base Ref: ${{ steps.pr-info.outputs.base_ref }} + - Head Ref: ${{ steps.pr-info.outputs.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS # Your Task: @@ -110,7 +110,7 @@ jobs: # Step-by-Step Process (print each step): 1. Print 'STEP 1: Getting PR diff' - 2. Get PR changes: \`gh pr diff ${{ github.event.pull_request.number }}\` + 2. Get PR changes: \`gh pr diff ${{ github.event.inputs.pr_number }}\` 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' 4. For each subdirectory in CHANGED_SUBDIRS: a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' From b7ddc2deb5ccdefe2703631eec8b2fe118c01d1e Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 16:38:17 +0100 Subject: [PATCH 23/25] update --- .github/workflows/llms-txt-automation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index 443591d5..ba1f196e 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -160,7 +160,7 @@ jobs: COMMIT_MSG="docs: update llms summaries for subdirectories (${{ steps.detect-changes.outputs.changed_subdirs }})" git commit -m "$COMMIT_MSG" - git push origin ${{ github.head_ref }} + git push origin ${{ steps.pr-info.outputs.head_ref }} echo "changes_committed=true" >> "$GITHUB_OUTPUT" echo "=== Changes committed successfully ===" @@ -169,7 +169,7 @@ jobs: if: steps.commit_changes.outputs.changes_committed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} + PR_NUMBER: ${{ github.event.inputs.pr_number }} run: | echo "=== Posting PR comment about updates ===" From 3a425e7d3d9fd770eab3219eb1a4fd7c5c543d38 Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 17:42:31 +0100 Subject: [PATCH 24/25] update yml --- .github/workflows/llms-txt-automation.yml | 99 +++++++++++++++++------ 1 file changed, 73 insertions(+), 26 deletions(-) diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index ba1f196e..df74a8d8 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -1,6 +1,8 @@ name: Update llms.txt and llms-full.txt in subdirectories on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] workflow_dispatch: inputs: pr_number: @@ -17,30 +19,40 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: - - name: Get PR information + - name: Determine trigger type and get PR info id: pr-info env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.inputs.pr_number }} run: | - echo "=== Getting PR information ===" - pr_data=$(gh pr view $PR_NUMBER --json headRefName,baseRefName,state) - head_ref=$(echo "$pr_data" | jq -r '.headRefName') - base_ref=$(echo "$pr_data" | jq -r '.baseRefName') - state=$(echo "$pr_data" | jq -r '.state') - - echo "PR #$PR_NUMBER:" - echo " Head: $head_ref" - echo " Base: $base_ref" - echo " State: $state" - - if [ "$state" != "OPEN" ]; then - echo "Error: PR #$PR_NUMBER is not open" - exit 1 + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "=== Manual trigger - getting PR information ===" + PR_NUMBER="${{ github.event.inputs.pr_number }}" + pr_data=$(gh pr view $PR_NUMBER --json headRefName,baseRefName,state) + head_ref=$(echo "$pr_data" | jq -r '.headRefName') + base_ref=$(echo "$pr_data" | jq -r '.baseRefName') + state=$(echo "$pr_data" | jq -r '.state') + + echo "PR #$PR_NUMBER:" + echo " Head: $head_ref" + echo " Base: $base_ref" + echo " State: $state" + + if [ "$state" != "OPEN" ]; then + echo "Error: PR #$PR_NUMBER is not open" + exit 1 + fi + + echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT + echo "head_ref=$head_ref" >> $GITHUB_OUTPUT + echo "base_ref=$base_ref" >> $GITHUB_OUTPUT + echo "is_manual=true" >> $GITHUB_OUTPUT + else + echo "=== PR trigger - using event data ===" + echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + echo "head_ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT + echo "base_ref=${{ github.base_ref }}" >> $GITHUB_OUTPUT + echo "is_manual=false" >> $GITHUB_OUTPUT fi - - echo "head_ref=$head_ref" >> $GITHUB_OUTPUT - echo "base_ref=$base_ref" >> $GITHUB_OUTPUT - name: Checkout repository uses: actions/checkout@v4 @@ -58,10 +70,34 @@ jobs: git config user.name "Cursor Agent" git config user.email "cursoragent@cursor.com" - - name: Detect changed subdirectories + - name: Check if should run and detect changes id: detect-changes run: | - echo "=== Detecting changed subdirectories ===" + echo "=== Checking if should run ===" + + # For PR triggers, only run if not a docs/ branch and user opts in + if [ "${{ steps.pr-info.outputs.is_manual }}" = "false" ]; then + if [[ "${{ steps.pr-info.outputs.head_ref }}" == docs/* ]]; then + echo "Skipping: PR branch starts with 'docs/'" + echo "should_run=false" >> $GITHUB_OUTPUT + echo "skip_reason=docs_branch" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "⏭️ **LLM Summary Files Update Available**" > /tmp/instruction.md + echo "" >> /tmp/instruction.md + echo "This PR can automatically update \`llms.txt\` and \`llms-full.txt\` files." >> /tmp/instruction.md + echo "" >> /tmp/instruction.md + echo "**To update:** Go to [Actions tab](https://github.com/${{ github.repository }}/actions/workflows/llms-txt-automation.yml) → 'Run workflow' → Enter PR #${{ steps.pr-info.outputs.pr_number }}" >> /tmp/instruction.md + echo "" >> /tmp/instruction.md + echo "_This is optional and doesn't block PR approval._" >> /tmp/instruction.md + + echo "should_run=false" >> $GITHUB_OUTPUT + echo "skip_reason=instruction_only" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "=== Manual trigger - detecting changed subdirectories ===" changed_files=$(git diff --name-only origin/${{ steps.pr-info.outputs.base_ref }}...HEAD -- docs/) echo "Changed files in docs/:" @@ -81,10 +117,21 @@ jobs: changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT + echo "should_run=true" >> $GITHUB_OUTPUT echo "=== Final changed subdirectories: $changed_subdirs ===" + - name: Post instruction comment + if: steps.detect-changes.outputs.skip_reason == 'instruction_only' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} + run: | + echo "=== Posting instruction comment ===" + gh pr comment "$PR_NUMBER" --body-file /tmp/instruction.md + echo "=== Instruction comment posted ===" + - name: Update LLM summary files - if: steps.detect-changes.outputs.changed_subdirs != '' + if: steps.detect-changes.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} @@ -100,7 +147,7 @@ jobs: # Context: - Repo: ${{ github.repository }} - - PR Number: ${{ github.event.inputs.pr_number }} + - PR Number: ${{ steps.pr-info.outputs.pr_number }} - Base Ref: ${{ steps.pr-info.outputs.base_ref }} - Head Ref: ${{ steps.pr-info.outputs.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS @@ -110,7 +157,7 @@ jobs: # Step-by-Step Process (print each step): 1. Print 'STEP 1: Getting PR diff' - 2. Get PR changes: \`gh pr diff ${{ github.event.inputs.pr_number }}\` + 2. Get PR changes: \`gh pr diff ${{ steps.pr-info.outputs.pr_number }}\` 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' 4. For each subdirectory in CHANGED_SUBDIRS: a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' @@ -142,7 +189,7 @@ jobs: echo "=== Cursor agent completed ===" - name: Commit changes to PR branch - if: steps.detect-changes.outputs.changed_subdirs != '' + if: steps.detect-changes.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' id: commit_changes run: | echo "=== Checking for changes ===" @@ -169,7 +216,7 @@ jobs: if: steps.commit_changes.outputs.changes_committed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.inputs.pr_number }} + PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} run: | echo "=== Posting PR comment about updates ===" From ce88318814047ab8ab64a8430ffca8e4787bdfba Mon Sep 17 00:00:00 2001 From: youssefea Date: Tue, 23 Sep 2025 17:58:44 +0100 Subject: [PATCH 25/25] update flow --- .github/workflows/llms-txt-automation.yml | 149 +++++++++++----------- .github/workflows/llms-txt-comment.yml | 56 ++++++++ 2 files changed, 128 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/llms-txt-comment.yml diff --git a/.github/workflows/llms-txt-automation.yml b/.github/workflows/llms-txt-automation.yml index df74a8d8..57a4500b 100644 --- a/.github/workflows/llms-txt-automation.yml +++ b/.github/workflows/llms-txt-automation.yml @@ -1,4 +1,4 @@ -name: Update llms.txt and llms-full.txt in subdirectories +name: Update llms.txt and llms-full.txt on: pull_request: @@ -15,89 +15,86 @@ permissions: pull-requests: write jobs: - auto-docs: + update-llms: runs-on: ubuntu-latest timeout-minutes: 20 steps: - - name: Determine trigger type and get PR info - id: pr-info - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check if should run + id: should-run run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "=== Manual trigger - getting PR information ===" - PR_NUMBER="${{ github.event.inputs.pr_number }}" - pr_data=$(gh pr view $PR_NUMBER --json headRefName,baseRefName,state) - head_ref=$(echo "$pr_data" | jq -r '.headRefName') - base_ref=$(echo "$pr_data" | jq -r '.baseRefName') - state=$(echo "$pr_data" | jq -r '.state') - - echo "PR #$PR_NUMBER:" - echo " Head: $head_ref" - echo " Base: $base_ref" - echo " State: $state" - - if [ "$state" != "OPEN" ]; then - echo "Error: PR #$PR_NUMBER is not open" - exit 1 - fi - - echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT - echo "head_ref=$head_ref" >> $GITHUB_OUTPUT - echo "base_ref=$base_ref" >> $GITHUB_OUTPUT - echo "is_manual=true" >> $GITHUB_OUTPUT + echo "=== Manual trigger detected - will run ===" + echo "should_run=true" >> $GITHUB_OUTPUT + echo "pr_number=${{ github.event.inputs.pr_number }}" >> $GITHUB_OUTPUT else - echo "=== PR trigger - using event data ===" + echo "=== PR trigger detected - will skip with instructions ===" + echo "should_run=false" >> $GITHUB_OUTPUT echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT - echo "head_ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT - echo "base_ref=${{ github.base_ref }}" >> $GITHUB_OUTPUT - echo "is_manual=false" >> $GITHUB_OUTPUT fi + - name: Skip with instructions + if: steps.should-run.outputs.should_run == 'false' + run: | + echo "⏭️ This check is skipped by default." + echo "" + echo "To update LLM summary files:" + echo "1. Click 'Re-run jobs' above → 'Run workflow'" + echo "2. OR go to Actions tab → 'Update llms.txt and llms-full.txt' → 'Run workflow'" + echo "" + echo "This will update llms.txt and llms-full.txt files in subdirectories based on your documentation changes." + echo "" + echo "This is optional and not required for PR approval." + + - name: Get PR information + if: steps.should-run.outputs.should_run == 'true' + id: pr-info + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ steps.should-run.outputs.pr_number }} + run: | + echo "=== Getting PR information ===" + pr_data=$(gh pr view $PR_NUMBER --json headRefName,baseRefName,state) + head_ref=$(echo "$pr_data" | jq -r '.headRefName') + base_ref=$(echo "$pr_data" | jq -r '.baseRefName') + state=$(echo "$pr_data" | jq -r '.state') + + echo "PR #$PR_NUMBER:" + echo " Head: $head_ref" + echo " Base: $base_ref" + echo " State: $state" + + if [ "$state" != "OPEN" ]; then + echo "Error: PR #$PR_NUMBER is not open" + exit 1 + fi + + echo "head_ref=$head_ref" >> $GITHUB_OUTPUT + echo "base_ref=$base_ref" >> $GITHUB_OUTPUT + - name: Checkout repository + if: steps.should-run.outputs.should_run == 'true' uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ steps.pr-info.outputs.head_ref }} - name: Install Cursor CLI + if: steps.should-run.outputs.should_run == 'true' run: | curl https://cursor.com/install -fsS | bash echo "$HOME/.cursor/bin" >> $GITHUB_PATH - name: Configure git + if: steps.should-run.outputs.should_run == 'true' run: | git config user.name "Cursor Agent" git config user.email "cursoragent@cursor.com" - - name: Check if should run and detect changes + - name: Detect changed subdirectories + if: steps.should-run.outputs.should_run == 'true' id: detect-changes run: | - echo "=== Checking if should run ===" - - # For PR triggers, only run if not a docs/ branch and user opts in - if [ "${{ steps.pr-info.outputs.is_manual }}" = "false" ]; then - if [[ "${{ steps.pr-info.outputs.head_ref }}" == docs/* ]]; then - echo "Skipping: PR branch starts with 'docs/'" - echo "should_run=false" >> $GITHUB_OUTPUT - echo "skip_reason=docs_branch" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "⏭️ **LLM Summary Files Update Available**" > /tmp/instruction.md - echo "" >> /tmp/instruction.md - echo "This PR can automatically update \`llms.txt\` and \`llms-full.txt\` files." >> /tmp/instruction.md - echo "" >> /tmp/instruction.md - echo "**To update:** Go to [Actions tab](https://github.com/${{ github.repository }}/actions/workflows/llms-txt-automation.yml) → 'Run workflow' → Enter PR #${{ steps.pr-info.outputs.pr_number }}" >> /tmp/instruction.md - echo "" >> /tmp/instruction.md - echo "_This is optional and doesn't block PR approval._" >> /tmp/instruction.md - - echo "should_run=false" >> $GITHUB_OUTPUT - echo "skip_reason=instruction_only" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "=== Manual trigger - detecting changed subdirectories ===" + echo "=== Detecting changed subdirectories ===" changed_files=$(git diff --name-only origin/${{ steps.pr-info.outputs.base_ref }}...HEAD -- docs/) echo "Changed files in docs/:" @@ -117,21 +114,10 @@ jobs: changed_subdirs=$(echo "$changed_subdirs" | xargs) echo "changed_subdirs=$changed_subdirs" >> $GITHUB_OUTPUT - echo "should_run=true" >> $GITHUB_OUTPUT echo "=== Final changed subdirectories: $changed_subdirs ===" - - name: Post instruction comment - if: steps.detect-changes.outputs.skip_reason == 'instruction_only' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} - run: | - echo "=== Posting instruction comment ===" - gh pr comment "$PR_NUMBER" --body-file /tmp/instruction.md - echo "=== Instruction comment posted ===" - - name: Update LLM summary files - if: steps.detect-changes.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' + if: steps.should-run.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' env: MODEL: gpt-5 CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} @@ -147,7 +133,7 @@ jobs: # Context: - Repo: ${{ github.repository }} - - PR Number: ${{ steps.pr-info.outputs.pr_number }} + - PR Number: ${{ steps.should-run.outputs.pr_number }} - Base Ref: ${{ steps.pr-info.outputs.base_ref }} - Head Ref: ${{ steps.pr-info.outputs.head_ref }} - Changed Subdirectories: $CHANGED_SUBDIRS @@ -157,7 +143,7 @@ jobs: # Step-by-Step Process (print each step): 1. Print 'STEP 1: Getting PR diff' - 2. Get PR changes: \`gh pr diff ${{ steps.pr-info.outputs.pr_number }}\` + 2. Get PR changes: \`gh pr diff ${{ steps.should-run.outputs.pr_number }}\` 3. Print 'STEP 2: Processing subdirectories: $CHANGED_SUBDIRS' 4. For each subdirectory in CHANGED_SUBDIRS: a. Print 'STEP 3a: Reading docs/[subdirectory]/llms.txt' @@ -189,7 +175,7 @@ jobs: echo "=== Cursor agent completed ===" - name: Commit changes to PR branch - if: steps.detect-changes.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' + if: steps.should-run.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs != '' id: commit_changes run: | echo "=== Checking for changes ===" @@ -198,7 +184,7 @@ jobs: if git diff --staged --quiet; then echo "No changes to commit" - echo "changes_committed=false" >> "$GITHUB_OUTPUT" + echo "changes_committed=false" >> $GITHUB_OUTPUT exit 0 fi @@ -209,14 +195,14 @@ jobs: git commit -m "$COMMIT_MSG" git push origin ${{ steps.pr-info.outputs.head_ref }} - echo "changes_committed=true" >> "$GITHUB_OUTPUT" + echo "changes_committed=true" >> $GITHUB_OUTPUT echo "=== Changes committed successfully ===" - name: Post PR comment about updates if: steps.commit_changes.outputs.changes_committed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} + PR_NUMBER: ${{ steps.should-run.outputs.pr_number }} run: | echo "=== Posting PR comment about updates ===" @@ -224,7 +210,7 @@ jobs: COMMENT_FILE="${RUNNER_TEMP}/llms-update-comment.md" { - echo "🤖 **LLM summary files updated**" + echo "✅ **LLM summary files updated successfully!**" echo "" echo "Updated documentation summary files based on changes in subdirectories: \`${{ steps.detect-changes.outputs.changed_subdirs }}\`" echo "" @@ -239,4 +225,13 @@ jobs: } > "$COMMENT_FILE" gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE" - echo "=== PR comment posted successfully ===" \ No newline at end of file + echo "=== PR comment posted successfully ===" + + - name: Report no changes needed + if: steps.should-run.outputs.should_run == 'true' && steps.detect-changes.outputs.changed_subdirs == '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ steps.should-run.outputs.pr_number }} + run: | + echo "ℹ️ No subdirectories with LLM summary files were changed in this PR." | \ + gh pr comment "$PR_NUMBER" --body-file - \ No newline at end of file diff --git a/.github/workflows/llms-txt-comment.yml b/.github/workflows/llms-txt-comment.yml new file mode 100644 index 00000000..c950dd0b --- /dev/null +++ b/.github/workflows/llms-txt-comment.yml @@ -0,0 +1,56 @@ +name: LLM Files Update Available + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + pull-requests: write + +jobs: + post-instruction: + if: ${{ !startsWith(github.head_ref, 'docs/') }} + runs-on: ubuntu-latest + steps: + - name: Post instruction comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + # Check if instruction comment already exists + existing_comment=$(gh pr view $PR_NUMBER --json comments --jq '.comments[] | select(.body | contains("")) | .id' || echo "") + + INSTRUCTION_FILE="${RUNNER_TEMP}/instruction-comment.md" + { + echo "⏭️ **LLM Summary Files Update Available**" + echo "" + echo "This PR can automatically update \`llms.txt\` and \`llms-full.txt\` files in subdirectories based on your documentation changes." + echo "" + echo "**To trigger the automation:**" + echo "" + echo "**Option 1: From PR checks below** ⬇️" + echo "- Find \"Update llms.txt and llms-full.txt\" in the checks list below" + echo "- Click \"Details\" → \"Re-run jobs\" → \"Run workflow\"" + echo "" + echo "**Option 2: From Actions tab**" + echo "- Go to [Actions tab](https://github.com/${{ github.repository }}/actions/workflows/llms-txt-automation.yml)" + echo "- Click \"Run workflow\" → Enter PR #$PR_NUMBER" + echo "" + echo "**What it does:**" + echo "- Detects which subdirectories have documentation changes" + echo "- Updates the corresponding \`llms.txt\` and \`llms-full.txt\` summary files" + echo "- Commits the changes directly to this PR branch" + echo "" + echo "_This automation is optional and not required for PR approval._" + echo "" + echo "" + } > "$INSTRUCTION_FILE" + + if [ -n "$existing_comment" ]; then + echo "Updating existing instruction comment" + gh api repos/${{ github.repository }}/issues/comments/$existing_comment \ + -X PATCH -f body="$(cat $INSTRUCTION_FILE)" + else + echo "Posting new instruction comment" + gh pr comment $PR_NUMBER --body-file "$INSTRUCTION_FILE" + fi