Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
4598e87
Add new docContet.js util
pwizla Nov 4, 2025
6f0bde0
Add new openLLM action
pwizla Nov 4, 2025
925e20d
Swap generic icon for ChatGPT with the official OpenAI logo from Phos…
pwizla Nov 4, 2025
c50254c
Swap sparkle icon for Claude with a chat bubble icon, since sparkle i…
pwizla Nov 4, 2025
04c94d7
Add prompt localization for the top 10 most used languages
pwizla Nov 4, 2025
68742d8
Fix Claude incorrectly building translated prompt
pwizla Nov 4, 2025
0fc185c
Better fix Claude handling of locales by adding dual English + locali…
pwizla Nov 4, 2025
98c95cc
Ensure only Claude shows dual prompts
pwizla Nov 4, 2025
a68f7b0
Hide descriptions for Open with… buttons
pwizla Nov 4, 2025
83d7e8a
Update icon for Claude
pwizla Nov 4, 2025
6766923
Fix icon position when no description provided
pwizla Nov 4, 2025
cdb8d76
Try to accomodate for both description and no desciption scenarii for…
pwizla Nov 4, 2025
6691a93
Revert "Try to accomodate for both description and no desciption scen…
pwizla Nov 4, 2025
b707ce3
Simplify icons alignment fix
pwizla Nov 4, 2025
713ce21
Try to fix Claude's issue
pwizla Nov 5, 2025
08ad520
Fix query parameter for Claude
pwizla Nov 5, 2025
ed2d60e
Remove dual prompt in Claude now that we fixed the query param
pwizla Nov 5, 2025
7b044c1
Refactor translation system and add many more locales
pwizla Nov 5, 2025
4211207
Add aiPromptTemplates.js
pwizla Nov 5, 2025
b2f8c03
Add script for translated prompt validation
pwizla Nov 5, 2025
119eb1c
Added many more languages
pwizla Nov 5, 2025
8d4461b
Include Tldr components content in llms.txt
pwizla Nov 6, 2025
07e44c7
WIP: Add draft of generate-llms-code.js to work on 3 sample files
pwizla Nov 6, 2025
703d7f5
Improve language detection
pwizla Nov 6, 2025
46f095e
Improve formatting and language detection
pwizla Nov 6, 2025
efd5cc9
Improve generation
pwizla Nov 6, 2025
91644b8
Enhance file path and title logic
pwizla Nov 6, 2025
1b9f007
Improve fenced code blocks detection and generation
pwizla Nov 6, 2025
4d86acd
Handle dependencies "lazy loading"
pwizla Nov 6, 2025
3159a25
Improve metadata parsing
pwizla Nov 6, 2025
fc23ce5
Print out llms-code to stdout
pwizla Nov 6, 2025
bf550fb
Improve file path and language detection further
pwizla Nov 6, 2025
c5615ab
Handle more languages in a heuristic way
pwizla Nov 6, 2025
dd5aa9f
Add normalizeOutputPath to better handle carelss mistakes and add sup…
pwizla Nov 6, 2025
028260c
Add support for anchors in sources
pwizla Nov 6, 2025
033628d
Handle custom headings
pwizla Nov 6, 2025
c96f737
Add anchors tag to generation script in package.json
pwizla Nov 6, 2025
0a5d88c
Improve SQL block language inference
pwizla Nov 6, 2025
9e7fe9a
Append empty strings to ensure we don't miss language blocks
pwizla Nov 6, 2025
a8d97ff
Better handle Docusaurus tabs detection
pwizla Nov 6, 2025
0de4925
Add additional scripts to handle file existence and project root
pwizla Nov 6, 2025
b585ea4
Add validator script
pwizla Nov 6, 2025
bbb32b8
Add script to both generate and validate
pwizla Nov 6, 2025
84ff03e
Add llms-code validator and all-docs discovery
Nov 18, 2025
6c0a100
Add optional line numbers to llms-code output
pwizla Nov 18, 2025
32e77ab
Add section-level Description and Source lines
pwizla Nov 18, 2025
c651364
Emit Language and File path per variant; remove extra example headers
pwizla Nov 18, 2025
e924e71
Normalize js/ts vs JavaScript/TypeScript in validator and don't treat…
pwizla Nov 18, 2025
5283ab9
Relax default validator: skip file existence checks by default; add v…
pwizla Nov 18, 2025
efd0b9e
Run generator with --all and propagate flags from CLI to generator co…
pwizla Nov 18, 2025
5011622
Recognize GraphQL/HTML/DOTENV/TEXT and alias sh→bash; normalize js/ts…
pwizla Nov 18, 2025
50e6d6e
Avoid EISDIR during anchor verification by only accepting files (not …
pwizla Nov 18, 2025
7caa32e
Downgrade missing anchor from error to warning during anchor verifica…
pwizla Nov 18, 2025
324ff53
Guard against incomplete fences: skip empty variants in generator and…
pwizla Nov 18, 2025
1826b7f
Relax severity: treat missing/unclosed code fences and empty sections…
pwizla Nov 18, 2025
4da8981
Strengthen section Description fallback and skip sections with no val…
pwizla Nov 18, 2025
049026f
Limit --all discovery to cms/ and cloud/; exclude snippets and other …
pwizla Nov 18, 2025
fb20ec0
Require Description only for sections with variants; suppress fence-r…
pwizla Nov 18, 2025
39d3a1b
Do not require section Description; suppress anchor-not-found warning…
pwizla Nov 18, 2025
d1972b4
Fix validator crash when section Description is omitted by guarding d…
pwizla Nov 18, 2025
be63ee1
Accept both '(Source: …)' and 'Source: …' formats in validator to han…
pwizla Nov 18, 2025
43a2085
Make section Source optional: accept none, '(Source: …)' or 'Source: …
pwizla Nov 18, 2025
8ea59f1
Allow fence-first variants (no 'Language:' line) and soften non-absol…
pwizla Nov 18, 2025
d14056d
Accept missing or legacy file path line per variant (treat as N/A) an…
pwizla Nov 18, 2025
9cb6b36
Add --verbose flag; collapse per-file 'no snippets' notices into a si…
pwizla Nov 18, 2025
4b228b4
Add --log-file option to write skipped doc IDs; keep concise summary …
pwizla Nov 18, 2025
b97a701
Auto-create skip log in verbose mode (static/llms-code-skip.log) and …
pwizla Nov 18, 2025
ab9fe7f
Add llms:generate-verbose script to run generator with --verbose and …
pwizla Nov 18, 2025
9943c22
Add llms:generate-and-validate:verbose script (verbose generation + v…
pwizla Nov 18, 2025
4ab1429
Add concise docs for llms-code generator/validator, scripts, and flags
pwizla Nov 18, 2025
fedb029
Group llms scripts under scripts/llms and update npm scripts to use w…
pwizla Nov 18, 2025
2f97cea
Use yarn script for LLMs generation in deploy workflow; target explic…
Nov 19, 2025
32c7d56
Generate & validate llms-code.txt in deploy workflow; include in chan…
Nov 19, 2025
ea29c62
Add 'View LLMs-code.txt' button in AI toolbar (navigate to /llms-code…
Nov 19, 2025
36504d7
Restore proper .gitignore content
pwizla Nov 19, 2025
8253c85
Move llms-code button down
pwizla Nov 19, 2025
fbcf67a
Merge branch 'main' into repo/create-llms-code-txt
pwizla Nov 19, 2025
41b9695
llms-code: ensure generation writes to static by fixing docs dir disc…
Nov 19, 2025
c5ad6e8
Delete docusaurus/docs/contributing/ai-toolbar-translations.md
pwizla Nov 19, 2025
a8df294
Delete docusaurus/docs/ai-toolbar-translations.md
pwizla Nov 19, 2025
778bf6b
Delete docusaurus/scripts/validate-prompts.js
pwizla Nov 19, 2025
4a3564c
Rename llms-code.md to README-llms-code.md
pwizla Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ jobs:

- name: 🤖 Generate LLMs files
working-directory: ./docusaurus
run: node scripts/generate-llms.js
run: npm run generate-llms

- name: 🤖 Generate LLMs code file
working-directory: ./docusaurus
run: |
node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt
node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root ..

- name: 🔍 Check for changes
id: check-changes
run: |
if git diff --quiet HEAD -- docusaurus/static/llms*.txt; then
if git diff --quiet HEAD -- docusaurus/static/llms.txt docusaurus/static/llms-full.txt docusaurus/static/llms-code.txt; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "🔄 No changes in LLMs files"
else
Expand All @@ -48,7 +54,7 @@ jobs:
run: |
git config --local user.email "noreply@github.com"
git config --local user.name "GitHub Actions"
git add docusaurus/static/llms*.txt
git add docusaurus/static/llms.txt docusaurus/static/llms-full.txt docusaurus/static/llms-code.txt
git commit -m "🤖 Update LLMs files [skip ci]"
git push

Expand Down
15 changes: 10 additions & 5 deletions docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"dev": "docusaurus start --port 8080 --no-open",
"build": "docusaurus build",
"dev": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root .. && docusaurus start --port 8080 --no-open",
"build": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root .. && docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand All @@ -14,9 +14,14 @@
"write-heading-ids": "docusaurus write-heading-ids",
"release-notes": "bash ./scripts/release-notes-script.sh",
"redirections-analysis": "node ./scripts/redirection-analysis/redirect-analyzer.js",
"generate-llms": "node scripts/generate-llms.js",
"dev:with-llms": "yarn generate-llms && docusaurus start --port 8080 --no-open",
"build:with-llms": "yarn generate-llms && docusaurus build",
"generate-llms": "node scripts/llms/generate-llms.js",
"dev:with-llms": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root .. && docusaurus start --port 8080 --no-open",
"build:with-llms": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root .. && docusaurus build",
"llms:generate-and-validate": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --output static/llms-code.txt && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root ..",
"llms:generate-verbose": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --verbose --output static/llms-code.txt && echo 'Skip log (if any): static/llms-code-skip.log'",
"llms:generate-and-validate:verbose": "yarn generate-llms && node scripts/llms/generate-llms-code.js --anchors --all --verbose --output static/llms-code.txt && echo 'Skip log (if any): static/llms-code-skip.log' && node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root ..",
"validate:llms-code": "node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --verify-anchors --project-root ..",
"validate:llms-code:strict": "node scripts/llms/validate-llms-code.js --path static/llms-code.txt --strict --check-files --verify-anchors --project-root ..",
"meilisearch:update-order": "node -r dotenv/config scripts/meilisearch/add-category-order.js"
},
"dependencies": {
Expand Down
79 changes: 79 additions & 0 deletions docusaurus/scripts/README-llms-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# llms-code: generator and validator

This tooling extracts code examples from docs and emits a single consumable file for LLMs, plus an optional validation pass to catch structural issues early.

## What it generates

- `static/llms-code.txt` with blocks grouped by page and section:
- `## Section`
- `Description: ...` (optional)
- `(Source: https://docs.strapi.io/...#anchor)` when `--anchors` is set
- For each variant: `Language: ...`, `File path: ...` (or `N/A`), fenced code, `---` divider between variants
- In verbose runs a skip log is written to `static/llms-code-skip.log` listing pages with no code snippets.

## npm/yarn scripts

Run from `docusaurus/`:

- `yarn llms:generate-and-validate`
- Generate for all docs and validate (quiet output; no file existence checks)

- `yarn llms:generate-verbose`
- Generate with `--verbose`; prints each skipped page and writes `static/llms-code-skip.log`

- `yarn llms:generate-and-validate:verbose`
- Verbose generate (writes skip log) then validate (quiet)

- `yarn validate:llms-code`
- Validate an existing `static/llms-code.txt` (quiet; no file existence checks)

- `yarn validate:llms-code:strict`
- Validate with file existence checks (use only if paths point to a real project), plus anchor verification

## Generator flags (`scripts/generate-llms-code.js`)

- `--all` Scan all docs (restricted to `cms/` and `cloud/` trees)
- `--include a,b` / `--exclude x,y` Filter discovered doc IDs by substring
- `--anchors` Include section anchors in Source lines
- `--line-numbers` Emit `Lines: start-end` for each variant
- `--verbose` Print per-file skip messages; auto-writes `static/llms-code-skip.log`
- `--log-file path` Custom path for the skip log
- `--output path` Destination for generated text (use `-` for stdout)

Notes:
- Discovery intentionally excludes `snippets/` and other non-doc trees.
- When file path cannot be inferred it is emitted as `N/A`.

## Validator flags (`scripts/validate-llms-code.js`)

- `--path path` Input file (use `/dev/stdin` to validate from a pipe)
- `--strict` Exit with non-zero on any errors (warnings do not fail)
- `--verify-anchors` Check that section anchors exist in the source doc
- `--check-files` Check referenced files exist (use with `--project-root ..` when appropriate)
- `--project-root dir` Base path for file checks and anchor lookups
- `--report json|text` Output diagnostics as JSON or text (default)

Heuristics and niceties:
- Language aliases normalized (e.g., `js` ≡ `JavaScript`, `ts` ≡ `TypeScript`, `sh` treated as `Bash`, `graphql`, `html`, `dotenv`, `text` recognized)
- Fence-first blocks (without a `Language:` line) are accepted by inferring language from the fence
- Section Description and Source are optional and do not fail validation
- File path line may be `File path:` or legacy `File:`; missing is treated as `N/A`

## Examples

- Generate + validate (quiet):
```
yarn llms:generate-and-validate
```

- Verbose generate + validate, with skip log:
```
yarn llms:generate-and-validate:verbose
```

- Validate a streamed output without writing a file:
```
node scripts/generate-llms-code.js --anchors --all --output - \
| node scripts/validate-llms-code.js --path /dev/stdin --strict --verify-anchors --project-root ..
```

Loading