Skip to content

Commit 1236101

Browse files
heiskrCopilot
andauthored
Add usage guidance to llms.txt for LLM content discovery (#59849)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7d46096 commit 1236101

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/frame/middleware/llms-txt.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ function generateBasicLlmsTxt(): string {
5353
5454
> Help for wherever you are on your GitHub journey.
5555
56-
## Docs Content
56+
## How to Use
5757
58-
- [Page List API](${BASE_API_URL}/en/free-pro-team@latest)
59-
- [Versions API](${BASE_API_URL}/versions): \`curl "https://docs.github.com/api/pagelist/versions"\`
60-
- [Languages API](${BASE_API_URL}/languages): \`curl "https://docs.github.com/api/pagelist/languages"\`
61-
- [Article API](https://docs.github.com/api/article): \`curl "https://docs.github.com/api/article?pathname=/en/get-started/start-your-journey/about-github-and-git"\`
62-
- [Search API](https://docs.github.com/api/search): \`curl "https://docs.github.com/api/search?query=actions&language=en&version=free-pro-team@latest"\`
58+
To find a specific article, use the **Search API** with a query. To browse all available pages, use the **Page List API** to get a list of paths, then fetch individual articles with the **Article API**. The \`/api/article/body\` endpoint returns clean markdown, ideal for LLM consumption.
59+
60+
## APIs
61+
62+
- [Page List API](${BASE_API_URL}/en/free-pro-team@latest): Returns all article paths for a given version. Use this to discover what content is available.
63+
- [Article API](https://docs.github.com/api/article): Fetches a single article as JSON (metadata and markdown body). Use \`/api/article/body\` for markdown only. Example: \`/api/article/body?pathname=/en/get-started/start-your-journey/about-github-and-git\`
64+
- [Search API](https://docs.github.com/api/search/v1): Full-text search across all articles. Returns matching pages with context. Example: \`/api/search/v1?query=actions&language=en&version=free-pro-team@latest&client_name=curl\`
65+
- [Versions API](${BASE_API_URL}/versions): Lists all available documentation versions.
66+
- [Languages API](${BASE_API_URL}/languages): Lists all available languages.
6367
6468
## Translations
6569

src/frame/tests/llms-txt.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@ describe('llms.txt endpoint', () => {
2020
expect(content).toMatch(/^# .*GitHub.*Docs/m)
2121
})
2222

23+
test('includes how to use guidance', async () => {
24+
const res = await get('/llms.txt')
25+
const content = res.body
26+
27+
// Should explain the workflow for LLMs
28+
expect(content).toMatch(/Search API/)
29+
expect(content).toMatch(/Page List API/)
30+
expect(content).toMatch(/Article API/)
31+
expect(content).toMatch(/markdown/i)
32+
})
33+
2334
test('includes programmatic access section', async () => {
2435
const res = await get('/llms.txt')
2536
const content = res.body
2637

2738
// Should mention the existing APIs
2839
expect(content).toMatch(/Article API/i)
2940
expect(content).toMatch(/Page List API/i)
41+
expect(content).toMatch(/Search API/i)
3042
expect(content).toMatch(/api\/article/i)
3143
expect(content).toMatch(/api\/pagelist\/en\/free-pro-team@latest/i)
3244
})
@@ -36,7 +48,8 @@ describe('llms.txt endpoint', () => {
3648
const content = res.body
3749

3850
// Should have all the main sections we expect
39-
expect(content).toMatch(/## Docs Content/i)
51+
expect(content).toMatch(/## How to Use/i)
52+
expect(content).toMatch(/## APIs/i)
4053
expect(content).toMatch(/## Translations/i)
4154
expect(content).toMatch(/## Versions/i)
4255
})
@@ -75,7 +88,6 @@ describe('llms.txt endpoint', () => {
7588

7689
// Should prominently feature the pagelist API as the main content source
7790
expect(content).toMatch(/Page List API.*api\/pagelist\/en\/free-pro-team@latest/i)
78-
expect(content).not.toMatch(/Machine-readable list/i) // Removed descriptions
7991
})
8092

8193
test.each(['free-pro-team@latest', 'enterprise-cloud@latest'])(
@@ -100,7 +112,7 @@ describe('llms.txt endpoint', () => {
100112
expect(content).toMatch(/api\/pagelist\/en\/enterprise-server@\d+\.\d+/)
101113
})
102114

103-
test('follows llms.txt specification structure and has reasonable length', async () => {
115+
test('follows llms.txt specification structure', async () => {
104116
const res = await get('/llms.txt')
105117
const content = res.body
106118

@@ -116,10 +128,6 @@ describe('llms.txt endpoint', () => {
116128
// Check for markdown links
117129
expect(content).toMatch(/\[.+\]\(.+\)/m)
118130

119-
// Should include translations and versions but still be reasonable
120-
expect(content.length).toBeGreaterThan(500)
121-
expect(content.length).toBeLessThan(5000)
122-
123131
// Split into lines for structure analysis
124132
const lines = content.split('\n')
125133

@@ -131,8 +139,8 @@ describe('llms.txt endpoint', () => {
131139
const hasBlockquote = lines.some((line: string) => line.trim().startsWith('>'))
132140
expect(hasBlockquote).toBe(true)
133141

134-
// Should have multiple H2 sections (Docs Content, Translations, Versions)
142+
// Should have multiple H2 sections (How to Use, APIs, Translations, Versions)
135143
const h2Sections = lines.filter((line: string) => line.trim().startsWith('## '))
136-
expect(h2Sections.length).toBeGreaterThanOrEqual(3)
144+
expect(h2Sections.length).toBeGreaterThanOrEqual(4)
137145
})
138146
})

0 commit comments

Comments
 (0)