Skip to content

Commit a345109

Browse files
committed
Extract LLMS plugin options to module
Move llms plugin configuration into a single CommonJS module at src/plugins/llms-html-injector/options.js and make it the source of truth for both the production build and the verify script. docusaurus.config.js now requires and passes the shared options to the llms-html-injector plugin, and scripts/verify-llms-output.js imports the same options instead of duplicating arrays/objects. This eliminates silent-drift between the build and sanity-check logic and centralizes ignoreFiles, customLLMFiles, pathTransformation, and related flags (generateLLMsTxt, generateLLMsFullTxt, generateMarkdownFiles, etc.). The new module exports the full options object plus helper exports for customLLMFiles and ignoreFiles.
1 parent 25db8ff commit a345109

3 files changed

Lines changed: 266 additions & 400 deletions

File tree

docusaurus.config.js

Lines changed: 13 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ const productsDropdown = fs.readFileSync('./src/components/NavDropdown/Products.
1010
const baseUrl = process.env.DEST || '/'
1111
const siteUrl = 'https://docs.metamask.io'
1212

13+
// Options for the `llms-html-injector` plugin (which wraps
14+
// `docusaurus-plugin-llms`). Centralized in a standalone CommonJS module so
15+
// the same configuration drives both this production build and the
16+
// `scripts/verify-llms-output.js` sanity check, eliminating the silent-drift
17+
// risk that existed when both files maintained their own copy of the
18+
// `customLLMFiles` array and `ignoreFiles` list.
19+
const llmsPluginOptions = require('./src/plugins/llms-html-injector/options')
20+
1321
const remarkPlugins = [
1422
require('remark-math'),
1523
[require('@docusaurus/remark-plugin-npm2yarn'), { sync: true }],
@@ -343,217 +351,11 @@ const config = {
343351
// injection). Wrapping is required because Docusaurus 3.x executes
344352
// `postBuild` hooks concurrently via `Promise.all`, so registering both
345353
// plugins separately would let the injector race against the generator.
346-
[
347-
'./src/plugins/llms-html-injector',
348-
{
349-
// Set docsDir to site root to collect from all directories
350-
docsDir: '.',
351-
// The root llms.txt is hand-curated at static/llms.txt to stay under
352-
// the AFDocs 50,000-char `llms-txt-size` threshold. The aggregate
353-
// walker descends one level into the per-section indexes listed below,
354-
// so coverage is preserved without dumping every page into a flat
355-
// index. Likewise, a monolithic llms-full.txt would exceed every
356-
// agent's context window (and crashes browser tabs at multi-MB
357-
// sizes); the per-section *-full.txt files cover the bulk content.
358-
generateLLMsTxt: false,
359-
generateLLMsFullTxt: false,
360-
// Emit an individual .md file next to every doc page so .md URLs
361-
// return 200 (Agent Score: markdown-url-support and
362-
// llms-txt-directive-md checks). The wrapper below normalizes these
363-
// files to URL-aligned paths and injects <link rel="alternate"> tags.
364-
generateMarkdownFiles: true,
365-
// Ignore common non-doc directories
366-
// Note: src/pages/** is not ignored so tutorials can be collected
367-
// Each customLLMFiles entry filters by includePatterns, so only matching files are included
368-
ignoreFiles: [
369-
'node_modules/**',
370-
'build/**',
371-
'.docusaurus/**',
372-
'.llms-verify/**',
373-
'.cursor/**',
374-
'.github/**',
375-
'.husky/**',
376-
'.vscode/**',
377-
'.integrationBuilderCache/**',
378-
'scripts/**',
379-
'static/**',
380-
'src/components/**',
381-
'src/theme/**',
382-
'src/lib/**',
383-
'src/config/**',
384-
'src/hooks/**',
385-
'src/utils/**',
386-
'src/plugins/**',
387-
'src/specs/**',
388-
'src/client/**',
389-
'src/scss/**',
390-
// Quickstart "builder" markdown is content fragments embedded by the
391-
// builder UI, not standalone routes; include only the entry pages.
392-
'src/pages/quickstart/builder/**',
393-
'src/pages/quickstart/commonSteps/**',
394-
'i18n/**',
395-
'*.config.js',
396-
'*.json',
397-
'*.lock',
398-
'README.md',
399-
'CONTRIBUTING.md',
400-
'AGENTS.md',
401-
'LICENSE*',
402-
'gator_versioned_docs/**',
403-
],
404-
excludeImports: true,
405-
removeDuplicateHeadings: true,
406-
// Strip `src/pages` from generated URLs so a file at
407-
// `src/pages/quickstart/foo.md` resolves to `/quickstart/foo/` to
408-
// match the public route. `docsDir` is `.` (the site root) so any
409-
// future top-level prefixes that should be hidden from URLs would
410-
// be added here.
411-
pathTransformation: {
412-
ignorePaths: ['src/pages'],
413-
},
414-
// Generate separate files for each section
415-
customLLMFiles: [
416-
{
417-
filename: 'llms-embedded-wallets.txt',
418-
includePatterns: ['embedded-wallets/**/*.{md,mdx}'],
419-
fullContent: false,
420-
title: 'MetaMask Embedded Wallets documentation',
421-
description: 'Documentation links for MetaMask Embedded Wallets',
422-
},
423-
// The single `llms-embedded-wallets-full.txt` was previously ~3.9 MB,
424-
// which exceeds the practical context window of most LLM agents.
425-
// Splitting by sub-domain keeps each full-content file under ~1.5 MB
426-
// while preserving complete coverage of the section.
427-
{
428-
filename: 'llms-embedded-wallets-sdk-full.txt',
429-
includePatterns: ['embedded-wallets/sdk/**/*.{md,mdx}'],
430-
fullContent: true,
431-
title: 'MetaMask Embedded Wallets SDKs',
432-
description:
433-
'Complete documentation for Embedded Wallets SDKs (React, Vue, JS, Node, Android, iOS, React Native, Flutter, Unity, Unreal)',
434-
},
435-
{
436-
filename: 'llms-embedded-wallets-evm-full.txt',
437-
includePatterns: ['embedded-wallets/connect-blockchain/evm/**/*.{md,mdx}'],
438-
fullContent: true,
439-
title: 'MetaMask Embedded Wallets EVM chain connections',
440-
description:
441-
'Complete documentation for connecting Embedded Wallets to EVM-compatible chains',
442-
},
443-
{
444-
filename: 'llms-embedded-wallets-non-evm-full.txt',
445-
includePatterns: [
446-
'embedded-wallets/connect-blockchain/solana/**/*.{md,mdx}',
447-
'embedded-wallets/connect-blockchain/other/**/*.{md,mdx}',
448-
'embedded-wallets/connect-blockchain/*.{md,mdx}',
449-
],
450-
fullContent: true,
451-
title: 'MetaMask Embedded Wallets non-EVM chain connections',
452-
description:
453-
'Complete documentation for connecting Embedded Wallets to Solana and other non-EVM chains',
454-
},
455-
{
456-
filename: 'llms-embedded-wallets-platform-full.txt',
457-
includePatterns: [
458-
'embedded-wallets/authentication/**/*.{md,mdx}',
459-
'embedded-wallets/features/**/*.{md,mdx}',
460-
'embedded-wallets/dashboard/**/*.{md,mdx}',
461-
'embedded-wallets/infrastructure/**/*.{md,mdx}',
462-
'embedded-wallets/troubleshooting/**/*.{md,mdx}',
463-
'embedded-wallets/*.{md,mdx}',
464-
],
465-
fullContent: true,
466-
title: 'MetaMask Embedded Wallets platform features',
467-
description:
468-
'Complete documentation for Embedded Wallets authentication, features, dashboard, infrastructure, and troubleshooting',
469-
},
470-
{
471-
filename: 'llms-metamask-connect.txt',
472-
includePatterns: ['metamask-connect/**/*.{md,mdx}'],
473-
fullContent: false,
474-
title: 'MetaMask Connect documentation',
475-
description: 'Documentation links for MetaMask Connect',
476-
},
477-
{
478-
filename: 'llms-metamask-connect-full.txt',
479-
includePatterns: ['metamask-connect/**/*.{md,mdx}'],
480-
fullContent: true,
481-
title: 'MetaMask Connect documentation',
482-
description: 'Complete documentation for MetaMask Connect',
483-
},
484-
{
485-
filename: 'llms-smart-accounts-kit.txt',
486-
includePatterns: ['smart-accounts-kit/**/*.{md,mdx}'],
487-
fullContent: false,
488-
title: 'MetaMask Smart Accounts Kit documentation',
489-
description: 'Documentation links for MetaMask Smart Accounts Kit',
490-
},
491-
{
492-
filename: 'llms-smart-accounts-kit-full.txt',
493-
includePatterns: ['smart-accounts-kit/**/*.{md,mdx}'],
494-
fullContent: true,
495-
title: 'MetaMask Smart Accounts Kit documentation',
496-
description: 'Complete documentation for MetaMask Smart Accounts Kit',
497-
},
498-
{
499-
filename: 'llms-snaps.txt',
500-
includePatterns: ['snaps/**/*.{md,mdx}'],
501-
fullContent: false,
502-
title: 'Snaps documentation',
503-
description: 'Documentation links for Snaps',
504-
},
505-
{
506-
filename: 'llms-snaps-full.txt',
507-
includePatterns: ['snaps/**/*.{md,mdx}'],
508-
fullContent: true,
509-
title: 'Snaps documentation',
510-
description: 'Complete documentation for Snaps',
511-
},
512-
{
513-
filename: 'llms-tutorials.txt',
514-
includePatterns: ['src/pages/tutorials/**/*.{md,mdx}'],
515-
fullContent: false,
516-
title: 'Tutorials',
517-
description: 'Documentation links for MetaMask tutorials',
518-
},
519-
{
520-
filename: 'llms-tutorials-full.txt',
521-
includePatterns: ['src/pages/tutorials/**/*.{md,mdx}'],
522-
fullContent: true,
523-
title: 'Tutorials',
524-
description: 'Complete documentation for MetaMask tutorials',
525-
},
526-
{
527-
filename: 'llms-dashboard.txt',
528-
includePatterns: ['developer-tools/dashboard/**/*.{md,mdx}'],
529-
fullContent: false,
530-
title: 'Developer dashboard documentation',
531-
description: 'Documentation links for MetaMask Developer dashboard',
532-
},
533-
{
534-
filename: 'llms-dashboard-full.txt',
535-
includePatterns: ['developer-tools/dashboard/**/*.{md,mdx}'],
536-
fullContent: true,
537-
title: 'Developer dashboard documentation',
538-
description: 'Complete documentation for MetaMask Developer dashboard',
539-
},
540-
{
541-
filename: 'llms-services.txt',
542-
includePatterns: ['services/**/*.md'],
543-
fullContent: false,
544-
title: 'Services documentation',
545-
description: 'Documentation links for MetaMask services',
546-
},
547-
{
548-
filename: 'llms-services-full.txt',
549-
includePatterns: ['services/**/*.md'],
550-
fullContent: true,
551-
title: 'Services documentation',
552-
description: 'Complete documentation for MetaMask services',
553-
},
554-
],
555-
},
556-
],
354+
//
355+
// Options (ignoreFiles, customLLMFiles, pathTransformation, etc.) live in
356+
// `./src/plugins/llms-html-injector/options.js` so the local sanity-check
357+
// script can consume the exact same configuration.
358+
['./src/plugins/llms-html-injector', llmsPluginOptions],
557359
],
558360
clientModules: [require.resolve('./src/client/scroll-fix.js')],
559361
themeConfig:

0 commit comments

Comments
 (0)