Skip to content

LLMS TXT automation

LLMS TXT automation #7

Workflow file for this run

name: Auto Update LLMs.txt Files
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'docs/base-account/**'
- 'docs/base-app/**'
- 'docs/base-chain/**'
- 'docs/cookbook/**'
- 'docs/get-started/**'
- 'docs/learn/**'
- 'docs/mini-apps/**'
- 'docs/onchainkit/**'
permissions:
contents: write
pull-requests: write
jobs:
update-llms-txt:
if: ${{ !startsWith(github.head_ref, 'auto-llms/') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- 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 "[email protected]"
- name: Post initial comment
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "🤖 **LLMs.txt Auto-Update**
Analyzing documentation changes to update llms.txt files...
💡 **Want to stop this process?** Comment \`stop\` below and I'll cancel the analysis.
⏱️ This will timeout after 30 minutes."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update LLMs.txt files
timeout-minutes: 30
env:
MODEL: gpt-5
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: auto-llms
run: |
# Expand variables for the agent
REPO="${{ github.repository }}"
OWNER="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
BASE_REF="${{ github.base_ref }}"
HEAD_REF="${{ github.head_ref }}"
BRANCH_PREFIX="${{ env.BRANCH_PREFIX }}"
# Run cursor-agent and capture output
AGENT_OUTPUT=$(cursor-agent -p "You are operating in a GitHub Actions runner to automatically update llms.txt and llms-full.txt 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 directly.
IMPORTANT: Before starting your analysis, check if the user wants to stop by running:
gh pr view ${PR_NUMBER} --json comments --jq '.comments[] | select(.body | contains(\"stop\"))'
If this returns any results, immediately post a cancellation comment and exit. Otherwise, proceed with your analysis.
# Context:
- Repo: ${REPO}
- Owner: ${OWNER}
- PR Number: ${PR_NUMBER}
- Base Ref: ${BASE_REF}
- Head Ref: ${HEAD_REF}
- Branch Prefix: ${BRANCH_PREFIX}
# Documentation Structure:
This is a docs repository with the following main directories that each contain llms.txt and llms-full.txt files:
- docs/base-account/
- docs/base-app/
- docs/base-chain/
- docs/cookbook/
- docs/get-started/
- docs/learn/
- docs/mini-apps/
- docs/onchainkit/
# Goal:
Analyze changes in the original PR and determine if they are significant enough to warrant updating the llms.txt and llms-full.txt files for the affected directories. If so, create a separate PR with the updates.
# Requirements:
1) Use \`gh pr diff\` to analyze what changed in the original PR
2) Determine which documentation directories are affected by the changes
3) Assess if the changes are significant enough to update the llms.txt files (new content, major restructuring, new features, etc.)
4) If changes are significant:
- Create or update a persistent branch named \`${BRANCH_PREFIX}/pr-${PR_NUMBER}\`
- Update the relevant llms.txt and llms-full.txt files to reflect the new documentation structure and content
- Push the changes to the branch
- Comment on the original PR with a summary and a compare link to create the PR
5) If changes are not significant:
- Comment on the original PR explaining that no llms.txt updates are needed
# File Format Guidelines:
- llms.txt files should be concise, focused summaries with key links
- llms-full.txt files should be comprehensive with all documentation links
- Follow the existing format and style of the current files
- Include proper section headers and descriptions
- Use relative links in the format: https://docs.base.org/[path]
# Significance Criteria:
Consider changes significant if they involve:
- New documentation files or sections
- Major content restructuring
- New features or API endpoints
- Changes to core concepts or workflows
- New guides or tutorials
# Deliverables:
- If updates needed: Pushed commits to the persistent branch and a PR comment with compare link
- If no updates needed: A brief comment explaining why no updates are required
- Keep all changes minimal and consistent with existing documentation style
CRITICAL: After completing ANY of the above actions (stop command, updates completed, or no updates needed), you MUST immediately exit by running 'exit 0'. Do not continue running or wait for additional input.
" --force --model "$MODEL" --output-format=json)
# Parse the JSON response
echo "Agent output: $AGENT_OUTPUT"
# Check if the agent completed successfully
if echo "$AGENT_OUTPUT" | jq -e '.type == "result" and .subtype == "success"' > /dev/null; then
echo "✅ Agent completed successfully"
# Extract the result message
RESULT_MESSAGE=$(echo "$AGENT_OUTPUT" | jq -r '.result')
echo "Result: $RESULT_MESSAGE"
# Force exit the action
echo "🏁 Forcing action to exit"
exit 0
else
echo "❌ Agent did not complete successfully"
echo "Raw output: $AGENT_OUTPUT"
exit 1
fi