Source for context4ai.org: the Context for AI
homepage, the documentation site at
/context/, and the reverse proxy to the community
Source Graph at /sourcegraph/.
Documentation · Contributing · Changelog
The repository root is a Context knowledge workspace. Its sources are the community repositories at pinned revisions plus reviewed notes; Agents write the articles through the Context workflow, every section keeps its evidence, and each release is recorded as a version in CHANGELOG.md. The English articles are translated into Simplified Chinese, and one URL serves both languages.
Agent Graph in Context describes how this site was produced. To write a site like it, start with Documentation Sites and Multilingual Sites.
| Path | Purpose |
|---|---|
src/index.ts |
Workspace configuration and the context-kb package with its site settings |
src/knowledge-map.yaml |
Navigation: sections and the articles bound to them |
sources/ |
Registered repository sources and notes |
knowledge/, translations/ |
Approved articles and their translations, written by the Context workflow |
src/site/ |
Docs site presentation: theme.json, diagram styles, the footer, and the docs homepage under components/home/ |
homepage/ |
The / brand page (/zh/ redirects to it): copy in content/, markup in render.ts, styles in styles.css, the retrieval field in main.js and scenarios.js |
deploy/nginx.conf.template |
Routing, caching and the Source Graph proxy |
Dockerfile, fly.toml |
Static image on nginx, deployed to Fly.io as context4ai-portal |
scripts/check-links.ts |
Internal link check over the combined output |
scripts/preview.ts |
Local preview of the homepage and docs site with the image layout |
Requires Node.js 22 and Bun 1.3.
bun install
bun run sources:restore # pinned source repositories under .tmp/, once per clone
bunx context verify # checks every cited source region
bun run build # context build, then the homepage
bun run check:linksOnly context verify reads the source checkouts; it reports cited regions that
changed or moved, and CI fails on them. The build does not need them, so the
image build skips the checkouts.
bun run build:home rebuilds only the homepage into dist/home/.
To preview the homepage and the docs site together after a build:
bun run preview # PORT=4180 by defaultIt serves dist/home/ at http://127.0.0.1:4180/ and dist/context-site/ at
http://127.0.0.1:4180/context/ in place; rebuilt files show up on reload without
restarting. Both bun run build and bun run build:site rebuild the docs and then
the homepage, because the underlying context build clears dist/home/.
Homepage-only changes need just bun run build:home. Use these scripts instead
of invoking context build directly for local preview.
The preview refuses to start if either site's index is missing and prints the
build command. While a running preview is being rebuilt, missing output returns
503 with a rebuild message instead of an unexplained 404. Reload after the build
finishes. /sourcegraph/ is not proxied there.
To preview with the production nginx routing, including the Source Graph proxy:
mkdir -p .tmp/www && cp -R dist/home/. .tmp/www/ && cp -R dist/context-site .tmp/www/context
docker run --rm -p 8088:8080 \
-e SOURCEGRAPH_UPSTREAM=https://context4ai-sourcegraph.fly.dev -e NGINX_RESOLVER=1.1.1.1 \
-v "$PWD/deploy/nginx.conf.template:/etc/nginx/templates/default.conf.template:ro" \
-v "$PWD/.tmp/www:/usr/share/nginx/html:ro" nginx:1.29-alpineOpen http://localhost:8088/.
| Path | Served by |
|---|---|
/, /zh/ |
Homepage |
/intro/ |
The homepage document playing the intro video; the slogan and the docs home link to it. Phones and tablets play it in the system full-screen player instead |
/context/ |
Documentation site, one URL per page for every language; /context redirects here |
/sourcegraph/ |
Proxied to Source Graph with its prefix, query, cookies and authorization intact |
/llms.txt |
Redirects to /context/llms.txt |
/healthz |
Health check |
The homepage, the docs site and Source Graph share the theme (context-theme, light
by default) and language (context-locale) preferences.
CI only verifies. Deploy manually:
fly deployThe Source Graph upstream is reached over the private network at
http://context4ai-sourcegraph.internal:8080. Flycast is not used because the
Source Graph app forces HTTPS, which redirects plain proxied requests.
Report a wrong or unclear article with an Issue that links the page. Article
changes go through the Context workflow rather than direct edits to
knowledge/; see CONTRIBUTING.md. Presentation changes to
the homepage and docs site are ordinary pull requests.