Skip to content

About

Node.js CLI that crawls product docs with Puppeteer and generates clean user guides, FAQs and a searchable help center with a multi-model AI fallback.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Auto-Generated Knowledge Base Engine

Point it at a product's documentation site. It crawls every page with Puppeteer, cleans out the site chrome, and produces:

  • User guides: one task-focused guide per topic (steps, tips, troubleshooting), rewritten by AI from the docs
  • An FAQ: the questions customers actually ask, with each answer linked to the page it came from
  • A static help center: searchable HTML site with light/dark mode and right-to-left support, works from file://
  • JSON exports: kb.json for a CMS or chatbot, plus a ready knowledge folder for the Omnichannel FAQ Knowledge Bot
  • A documentation audit: broken links, thin and duplicate pages, missing descriptions, with a 0-100 score
docs site ──► crawl (HTTP + headless Chrome) ──► clean Markdown ──► topics ──► AI guides + FAQs ──► grounding check ──► md / html / json / faq-bot
                robots.txt · sitemap · versions         nav, cookie banners removed     multi-model fallback       numbers + sources verified

Quick start

npm install
node bin/kb-engine.js demo            # bundled docs site, works without API keys
node bin/kb-engine.js demo --serve    # ...and open the help center at http://127.0.0.1:4321

For a client:

mkdir acme && cd acme
kb-engine init --url https://docs.acme.com --product "Acme"   # writes .env + kb.config.json
# add GEMINI_API_KEY (free: https://aistudio.google.com/apikey) to .env
kb-engine doctor --ping       # checks Chrome and every AI model
kb-engine run                 # crawl + build -> ./kb-output
kb-engine serve               # preview the help center

(npm link in this folder makes kb-engine available everywhere; otherwise use node <path>/bin/kb-engine.js.)

Commands

Command What it does
run [url] crawl + build
crawl [url] crawl into the workspace (.kb/), reporting new / changed / removed pages since the last crawl
build generate the knowledge base from the crawled pages (unchanged topics come from the AI cache)
audit documentation health report (audit.md)
status last crawl, changes, cache
serve [--port 4321] preview the generated help center
demo [--serve] crawl + build the bundled "Orbit Tasks" docs site
init .env + kb.config.json in the current folder
doctor [--ping] settings, Chrome, every model in the AI chain

Crawl options: --max-pages 150, --depth 6, --concurrency 3, --delay 250, --renderer auto|browser|static, --scope /docs/, --include, --exclude /changelog,/blog, --wait-for <selector>, --all-versions, --no-robots, --no-sitemap.

Build options: --product, --lang French (or ar, de...), --audience "IT admins", --tone, --faqs 6, --formats md,html,json,faq-bot, --brand #0ea5e9, --no-ai, --force.

Global: -w <workspace>, -o <output>, --simulate-outage gemini (demo the AI fallback), -v (log every AI attempt and rejected FAQ).

Settings priority: CLI flags > kb.config.json > .env > defaults. See kb.config.example.json and .env.example.

How it works

Crawling (src/crawl/)

  • Discovers pages from the start URL, sitemap.xml and every in-scope link (sidebars included). Pages keep the site's navigation order.
  • auto renderer: plain HTTP first; a page that comes back empty but ships JavaScript (SPA docs: Docusaurus, GitBook, Mintlify, ReadMe) is re-rendered in headless Chrome (puppeteer-extra + stealth, images/fonts blocked). Chrome only starts if a page needs it.
  • Respects robots.txt (incl. Crawl-delay) and noindex, follows canonicals, strips tracking params, skips non-HTML files.
  • Skips other doc versions (/docs/next, /docs/3.9.2, /docs/v1) that version pickers link to; on docusaurus.io this skipped 1,070 duplicate pages.
  • Records every failing URL with the pages that link to it (broken-link report).

Extraction (src/extract/)

  • Finds the article (Docusaurus, MkDocs, Read the Docs, GitBook, Zendesk/Intercom help centers, <main>/<article>, or the body), removes nav, sidebars, cookie banners, "was this helpful" widgets, edit links and pagination.
  • Converts to Markdown with tables, fenced code blocks with language, callouts as blockquotes, <details> answers.
  • Collects Q&A that is already on the page (<details>, <dt>, headings ending in ?).

Generation (src/build/)

  • Groups pages into topics by breadcrumb or URL folder; merges stray short pages; splits big sections to stay inside the model's context budget.
  • One AI call per topic returns a guide and FAQs as JSON. The prompt forbids anything not in the pages, and every item must cite page labels.
  • Grounding check on each FAQ: it must cite a real page of the topic, every number (prices, limits, days) must appear in the docs, and most of its words must appear in the cited page. Answers that fail are dropped and listed in kb.json.
  • AI layer: the multi-model fallback router (src/ai/): pinned Gemini versions, then Gemma, Groq, NVIDIA NIM, OpenRouter free, Ollama, with timeouts, cooldowns and quota handling.
  • If every model fails (or there are no keys), the topic is built in extractive mode from the cleaned pages: same outputs, written by the docs authors instead of rewritten.
  • Results are cached per topic, keyed on the pages' content hashes and the settings. Re-running after a docs update only regenerates changed topics.

Output (kb-output/)

README.md                 index: intro, guides, stats
guides/01-overview.md     one guide per topic (front matter with sources)
faq.md                    every FAQ with its source link
kb.json / faq.json        structured data
site/index.html           static help center (+ faq.html, guides/*.html, assets/)
faq-bot/                  company.json, faqs.json, guides.json for the FAQ bot
audit.md                  documentation audit

Tests

npm test          # 26 tests, no network or API keys (fake AI providers, local demo site, real Chrome)
KB_TEST_NO_BROWSER=1 npm test   # skip the Chrome test

Notes

  • Only crawl sites you have permission to process (your client's own docs). --no-robots is for sites you own.
  • Free-tier AI quotas are small. One call per topic plus one for the intro, about 10-20 calls for a 100-page site. Use a paid Gemini key for clients.
  • Puppeteer downloads Chrome on install. If it is missing: npx puppeteer browsers install chrome, or use --renderer static.

MIT License

About

Node.js CLI that crawls product docs with Puppeteer and generates clean user guides, FAQs and a searchable help center with a multi-model AI fallback.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages