From 1fc1b03107791df9a1d3d7db3d1769d718e91c83 Mon Sep 17 00:00:00 2001 From: forcetrainer Date: Sat, 3 Jan 2026 15:09:17 -0500 Subject: [PATCH] fix(build): use file glob instead of sidebar parsing for llms-full.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace brittle sidebar.js regex parsing with recursive file glob. The old approach captured non-file strings like 'autogenerated' and category labels, resulting in only 5 files being processed. Now correctly processes all 86+ markdown files (~95k tokens). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tools/build-docs.js | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/tools/build-docs.js b/tools/build-docs.js index bfeda390..86d9c7d7 100644 --- a/tools/build-docs.js +++ b/tools/build-docs.js @@ -224,7 +224,7 @@ function generateLlmsFullTxt(outputDir) { console.log(' → Generating llms-full.txt...'); const date = new Date().toISOString().split('T')[0]; - const files = getDocsFromSidebar(); + const files = getAllMarkdownFiles(outputDir); const output = [ '# BMAD Method Documentation (Full)', @@ -266,32 +266,22 @@ function generateLlmsFullTxt(outputDir) { ); } -function getDocsFromSidebar() { - const sidebarsPath = path.join(PROJECT_ROOT, 'website', 'sidebars.js'); +function getAllMarkdownFiles(dir, baseDir = dir) { + const files = []; - try { - const sidebarContent = fs.readFileSync(sidebarsPath, 'utf-8'); - const matches = sidebarContent.matchAll(/'([a-zA-Z0-9\-_/]+)'/g); - const files = []; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const fullPath = path.join(dir, entry.name); - for (const match of matches) { - const docId = match[1]; - // Skip Docusaurus keywords - if (docId.includes('Sidebar') || docId === 'doc' || docId === 'category') { - continue; - } - // Skip category labels (Title Case words without slashes like 'Workflows', 'Reference') - if (!docId.includes('/') && /^[A-Z][a-z]/.test(docId)) { - continue; - } - files.push(docId + '.md'); + if (entry.isDirectory()) { + files.push(...getAllMarkdownFiles(fullPath, baseDir)); + } else if (entry.name.endsWith('.md')) { + // Return relative path from baseDir + const relativePath = path.relative(baseDir, fullPath); + files.push(relativePath); } - - return files; - } catch { - console.log(' Warning: Could not parse sidebars'); - return []; } + + return files; } function shouldExcludeFromLlm(filePath) {