in-app-docs
In-browser documentation (/doc)
The web-ui Next app serves a read-only mirror of this repository’s docs/ tree as HTML so you can explore markdown in the browser (sidebar, GitHub-flavored markdown, sanitized HTML).
URL
- Documentation home:
/doc(maps todocs/README.mdin the repo). - Nested pages:
/doc/<path>matches a.mdfile underdocs/(for example/doc/k8s/startupfordocs/k8s/startup.md). Folder indexes useREADME.md(for example/doc/k8sfordocs/k8s/README.md).
The route lives in the App Router at packages/web-ui/src/app/doc/ (layout, optional catch-all [[...slug]], navigation client component). It is not under the /agent-play/... API prefix.
How content gets into the app
node packages/web-ui/scripts/copy-docs.mjscopiesdocs/→packages/web-ui/content/docs/(ignored by git).predevandprebuildruncopy-docsaftercopy-sources(seepackages/web-ui/package.json).- Docker:
k8s/Dockerfile.web-uirunsCOPY docs ./content/docsat the image app root beforenpm install/next buildso production images include the same tree without relying on a prior local copy.
Implementation notes
| Piece | Purpose |
|---|---|
src/lib/docs/doc-public-path.ts |
DOC_BROWSER_ROUTE (/doc); shared by the nav, markdown link rewriting, and the watch UI link. |
src/lib/docs/slug-url.ts |
Pure slug ↔ path helpers (safe for client bundles). |
src/lib/docs/paths.ts |
getDocsRoot() → content/docs under process.cwd(). |
src/lib/docs/list-markdown.ts |
Recursive *.md listing for the sidebar. |
src/lib/docs/resolve-doc-path.ts |
Resolves URL segments to a file (file vs folder README, rejects ..). |
src/lib/docs/render-doc-markdown.ts |
marked (GFM) + isomorphic-dompurify; rewrites relative .md links to stay under DOC_BROWSER_ROUTE. |
src/app/doc/doc-nav.tsx |
Client sidebar with active state via usePathname. |
From the watch canvas
On the home route (/) and anywhere that mounts WatchBootstrap, a fixed Documentation control appears at the bottom-left linking to /doc.
Changing the mount path
Update DOC_BROWSER_ROUTE in doc-public-path.ts and keep next.config rewrites (if any) aligned if you add path-prefix routing later.