From 0fa09df757320156b413f810a0e0e41a86960f7c Mon Sep 17 00:00:00 2001 From: bong-water-water-bong <277547417+bong-water-water-bong@users.noreply.github.com> Date: Thu, 24 Sep 2026 18:52:39 -0300 Subject: [PATCH] Docs chat on 1bit.gg: Context7's widget behind CONTEXT7_LIBRARY, and context7.json for indexing Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pages.yml | 2 ++ context7.json | 28 ++++++++++++++++++++++++++++ site/template.html | 1 + tools/site.py | 19 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 context7.json diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index f8d70b7f..c952c79c 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -17,6 +17,7 @@ # README.md and docs/*.md with site/template.html and site/style.css. Pull requests only # build it (a doc that breaks the site shows up in review); main deploys it to GitHub Pages. # The repository variable GOATCOUNTER (a GoatCounter site code) turns on visitor counts. +# The repository variable CONTEXT7_LIBRARY (e.g. /1bit-monster/engine) turns on the docs chat widget. name: pages on: @@ -42,6 +43,7 @@ jobs: - name: Build the site env: GOATCOUNTER: ${{ vars.GOATCOUNTER }} + CONTEXT7_LIBRARY: ${{ vars.CONTEXT7_LIBRARY }} run: | python3 -m pip install --quiet markdown==3.10.3 python3 tools/site.py _site diff --git a/context7.json b/context7.json new file mode 100644 index 00000000..21be8983 --- /dev/null +++ b/context7.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://context7.com/schema/context7.json", + "projectTitle": "1bit engine", + "description": "A C++ inference engine behind an OpenAI-compatible API, running inside Lemonade on AMD Ryzen AI (Strix Halo): the XDNA 2 NPU, HRX and Vulkan on the Radeon iGPU, ZINC for NVIDIA and Apple GPUs, MLX on Apple Silicon.", + "folders": [ + "docs", + "blog" + ], + "excludeFolders": [ + "third_party", + "site", + "tools", + "tests", + "patches" + ], + "excludeFiles": [ + "LICENSE", + "NOTICE", + "archive.tsv" + ], + "rules": [ + "Serve models with `1bit serve`; it exposes an OpenAI-compatible API and runs as Lemonade's `onebit` backend.", + "Pick the device with `--device` (auto, npu, vulkan, hrx, rocm, zinc, mlx); an NPU model directory runs on the NPU fast lane, and Vulkan is the usual choice for plain GGUF files.", + "Prefer Unsloth Dynamic GGUFs: UD-Q4_K_XL is the lean default, UD-Q5_K_XL the accurate choice.", + "For one user at a time use `--mtp` without `--adaptive`; for many simultaneous requests use `--parallel` or `--adaptive`.", + "Documentation lives at https://1bit.gg; measured results are on the GitHub wiki." + ] +} diff --git a/site/template.html b/site/template.html index a35cdbce..d361adb5 100644 --- a/site/template.html +++ b/site/template.html @@ -72,5 +72,6 @@ if (side && window.matchMedia("(max-width: 860px)").matches) side.open = false; {{analytics}} +{{chat}} diff --git a/tools/site.py b/tools/site.py index db9ab5d6..7c7a75f9 100644 --- a/tools/site.py +++ b/tools/site.py @@ -36,6 +36,11 @@ # repository variable of that name), every page loads GoatCounter's counter, which sets # no cookies. Unset, as in a local preview, the pages carry no analytics at all. # +# Docs chat: with CONTEXT7_LIBRARY set to the engine's Context7 library id (pages.yml passes +# the repository variable of that name), every page carries Context7's chat widget, which +# answers from the docs Context7 indexed (see context7.json). Context7 only serves it once the +# library is claimed and 1bit.gg is on the widget's allowed domains; unset, no widget. +# # Needs python-markdown (pip install markdown). import html import os @@ -156,6 +161,19 @@ def analytics(): return f'' +def chat_widget(): + library = os.environ.get("CONTEXT7_LIBRARY", "").strip() + if not library: + return "" + if not re.fullmatch(r"/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", library): + sys.exit(f"CONTEXT7_LIBRARY must be a Context7 library id like /owner/repo, not {library!r}") + return (f'') + + def plain(markdown_text): """One paragraph of markdown as plain text.""" text = re.sub(r"\s*\(\[[^\]]*\.md\]\([^)]*\)\)", "", markdown_text) # "(docs/x.md)" asides @@ -230,6 +248,7 @@ def write(self, name, title, main, kind, section, description=TAGLINE, extra_hea .replace("{{nav}}", self.top_nav(section)) .replace("{{main}}", main) .replace("{{analytics}}", analytics()) + .replace("{{chat}}", chat_widget()) .replace("{{repo}}", REPO)) if extra_head: page = page.replace("", "\n" + extra_head, 1)