Skip to content

Commit c83470e

Browse files
Add llms.txt generator for LLM-friendly documentation (#2912)
* Add llms.txt generator for LLM-friendly documentation * Fix codespell skip for llms.txt files * Refactor build_llms_txt.py: DRY, TypedDict, walrus operator * docs: update llms.txt files Generated by GitHub Actions * Add Python 3.11+ requirement note to llms-txt env --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e12cd96 commit c83470e

7 files changed

Lines changed: 30338 additions & 2 deletions

File tree

.github/workflows/codespell.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
uses: codespell-project/actions-codespell@v2
2828
with:
2929
exclude_file: CODE_OF_CONDUCT.md
30-
skip: ./docs/cli-reference
30+
skip: ./docs/cli-reference,./docs/llms.txt,./docs/llms-full.txt

.github/workflows/llms-txt.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Update llms.txt
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**/*.md'
8+
- 'zensical.toml'
9+
- 'scripts/build_llms_txt.py'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'docs/**/*.md'
14+
- 'zensical.toml'
15+
- 'scripts/build_llms_txt.py'
16+
pull_request_target:
17+
types: [labeled]
18+
paths:
19+
- 'docs/**/*.md'
20+
- 'zensical.toml'
21+
- 'scripts/build_llms_txt.py'
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
update-llms-txt:
28+
if: |
29+
github.event_name == 'push' ||
30+
!github.event.pull_request.head.repo.fork ||
31+
github.actor == 'koxudaxi' ||
32+
github.actor == 'gaborbernat' ||
33+
github.actor == 'ilovelinux' ||
34+
(github.event_name == 'pull_request_target' && github.event.label.name == 'safe-to-fix' &&
35+
(github.event.sender.login == 'koxudaxi' ||
36+
github.event.sender.login == 'gaborbernat' ||
37+
github.event.sender.login == 'ilovelinux'))
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
42+
with:
43+
fetch-depth: 0
44+
ref: ${{ github.event.pull_request.head.ref }}
45+
repository: ${{ github.event.pull_request.head.repo.full_name }}
46+
- uses: actions/checkout@v4
47+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
48+
with:
49+
fetch-depth: 0
50+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
51+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
52+
token: ${{ secrets.PAT }}
53+
- name: Install the latest version of uv
54+
uses: astral-sh/setup-uv@v5
55+
- name: Install tox
56+
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
57+
- name: Setup environment
58+
run: tox run -vv --notest --skip-missing-interpreters false -e llms-txt
59+
env:
60+
UV_PYTHON_PREFERENCE: "only-managed"
61+
- name: Build llms.txt
62+
run: .tox/llms-txt/bin/python scripts/build_llms_txt.py
63+
- name: Commit and push if changed
64+
if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository
65+
run: |
66+
git config user.name "github-actions[bot]"
67+
git config user.email "github-actions[bot]@users.noreply.github.com"
68+
git add docs/llms.txt docs/llms-full.txt
69+
git diff --staged --quiet || git commit -m "docs: update llms.txt files
70+
71+
Generated by GitHub Actions"
72+
git push

0 commit comments

Comments
 (0)