Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

# Pull-request checks. Deploys belong to deploy.yml (push to main/staging).
# Pull-request checks. Deployments require an explicit workflow dispatch.
on:
pull_request:
branches: [main, staging]
Expand All @@ -11,7 +11,6 @@ concurrency:

permissions:
contents: read
packages: read

jobs:
checks:
Expand All @@ -30,8 +29,6 @@ jobs:

- name: Install
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Typecheck
run: pnpm typecheck
Expand All @@ -48,7 +45,7 @@ jobs:
- name: Report production client bundle sizes
run: pnpm bundle:report

- name: Build staging and verify isolated R2 binding
- name: Build staging and verify isolated Worker configuration
run: |
pnpm build:staging
node scripts/check-deploy-config.mjs staging
11 changes: 6 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ concurrency:

permissions:
contents: read
packages: read

jobs:
authorize-release:
Expand Down Expand Up @@ -68,7 +67,7 @@ jobs:
shell: bash
run: |
if [[ "$RELEASE_READY" != "true" ]]; then
echo "::error::Documentation release blocked. Verify Cloudflare R2, domain, secrets and manifests, then set DOCS_RELEASE_READY=true in this GitHub Environment."
echo "::error::Documentation release blocked. Verify Cloudflare domain and credentials, then set DOCS_RELEASE_READY=true in this GitHub Environment."
exit 1
fi

Expand All @@ -86,10 +85,8 @@ jobs:
node-version: 24
cache: pnpm

- name: Install with private package read permission
- name: Install
run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Typecheck
run: pnpm typecheck
Expand Down Expand Up @@ -139,6 +136,10 @@ jobs:
test "$landing" = "200 1 $URL/docs/assay"
curl --fail --silent --show-error "$URL/docs/assay" >/dev/null
curl --fail --silent --show-error "$URL/docs/throughline" >/dev/null
curl --fail --silent --show-error "$URL/docs/assay.md" --location >/dev/null
curl --fail --silent --show-error "$URL/llms.mdx/docs/throughline" >/dev/null
missing="$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' "$URL/docs/nonexistent-smoke-test")"
test "$missing" = "404"
curl --fail --silent --show-error "$URL/llms.txt" >/dev/null
curl --fail --silent --show-error "$URL/llms-full.txt" >/dev/null
curl --fail --silent --show-error "$URL/robots.txt" >/dev/null
Expand Down
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

53 changes: 17 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 0xBUFF Documentation

Public documentation for 0xBUFF products, built with React Router 8, Fumadocs MDX and Cloudflare Workers. Articles are maintained in `content/docs/`; the published **product catalog** is read at runtime from the private 0xBUFF R2 content bucket. The documentation Worker does not access 0xNAND's private learning content or assessment assets.
Public documentation for 0xBUFF products, built with React Router 8, Fumadocs MDX and Cloudflare Workers. Articles and navigation live in `content/docs/`. The app compiles and serves this public collection without a runtime content store.

## Documentation organization

Expand All @@ -25,7 +25,7 @@ content/docs/
- The root `content/docs/meta.json` lists Assay first, then Throughline and uses Fumadocs' `"..."` entry to include future tools automatically.
- Give every tool its own `content/docs/<slug>/` directory with an `index.mdx` and `meta.json`. Set `"root": true` in the tool's metadata so its navigation is separate from other tools. Give it a clear title, a short description, and an explicit `pages` order. Section separators such as `"---Reference---"` group related pages without changing URLs.
- Use stable filenames: Fumadocs derives each public address from its MDX path. Navigation changes must not unnecessarily change existing addresses.
- New tools also need a published product entry in the R2 catalog, with no outbound `url`, before they appear on the public site. Content files alone do not publish a product.
- Add only material intended for public release. Every MDX article in the collection is public after deployment and is eligible for search and LLM exports.
- Keep product-specific descriptions in the product's own MDX and metadata. Shared site metadata must describe the full documentation library.

The navigation validation tests run with `pnpm test`. They verify tool roots, declared pages, and document frontmatter.
Expand All @@ -36,20 +36,16 @@ Selected Throughline guides render the published `@0xbuff/[email protected]` Rea

The showcase is deliberately limited to a few pages and does not automatically transform every `thl` code fence. The official `remarkThroughline({ mode: "mdx" })` integration and `ThroughlineEmbed` require a subsequent package release; v0.0.2 must not be assumed to contain them. This preserves portable source examples and avoids unnecessary client JavaScript. `scripts/throughline-interactive.test.mjs` compiles every showcased trace with the installed package; CI also typechecks and builds both environments.

## Content ownership and publication
## Routing and publication

The private `0xbuffdev/content` repository owns the product records and publishes them to independent 0xBUFF buckets via its validated content pipeline. Documentation reads `manifest.json` and the referenced `products/manifest.json` through its Worker `CONTENT` R2 binding and validates them with `@0xbuffdev/[email protected]` (imported as `@0xbuff/content-contract`).
Fumadocs builds the page tree, search index, sitemap and Markdown exports from the local MDX collection. Both `/` and `/docs` redirect directly to `/docs/assay`. Unknown articles return HTTP 404. Updating the collection requires a documentation deployment; the company product catalog is independent.

Only published product records with **no outbound `url`** and a matching `content/docs/<slug>/index.mdx` are listed. The R2 catalog controls documentation routes, sidebar, sitemap, search index and LLM exports. Both `/` and `/docs` temporarily redirect directly to `/docs/assay` in one hop, only when Assay is published. Missing Assay returns 503 rather than falling back to another tool. Publish the Assay catalog record to each target R2 bucket before deploying this change. The MDX articles themselves are compiled from this repository and require a documentation deployment to update. Catalog changes appear after the 60-second edge cache expires; no documentation rebuild is needed for catalog changes alone.
| Target | Worker | Public domain |
| --- | --- | --- |
| Staging | `0xbuff-docs-staging` | `staging.docs.0xbuff.com` |
| Production | `0xbuff-docs` | `docs.0xbuff.com` |

The two production-facing buckets are **not interchangeable**:

| Target | Worker | Public domain | Private `CONTENT` bucket |
| --- | --- | --- | --- |
| Staging | `0xbuff-docs-staging` | `staging.docs.0xbuff.com` | `content-staging` |
| Production | `0xbuff-docs` | `docs.0xbuff.com` | `content` |

The top-level Wrangler configuration is production. `env.staging` overrides the domain, bucket, and `DOCS_ENV` binding. `DOCS_ENV` also isolates cached manifests.
The top-level Wrangler configuration is production. `env.staging` overrides the domain and `DOCS_ENV` value.

## Development

Expand All @@ -59,25 +55,10 @@ Node 24 and pnpm 11.2.2 are required.
pnpm install
pnpm typecheck
pnpm test
```

GitHub Packages read permission is required for the private content contract. The tracked `.npmrc` scopes the registry; supply an appropriate read-only `NODE_AUTH_TOKEN` locally. **Never commit a token.** GitHub Actions uses `GITHUB_TOKEN` with `packages: read`; grant this repository Actions read permission in the private package's settings.

For local development, build and partition the **Content** repository first (from that repository):

```bash
pnpm run build:content
node scripts/publish-targets.ts
```

From this documentation repository, seed only the **local** Miniflare R2 state using the resulting 0xBUFF partition:

```bash
pnpm seed:content /absolute/path/to/content/.cache/publish/0xbuff
pnpm dev
```

The seed command validates the published manifest and uploads `manifest.json` and `products/manifest.json` to the local `content` bucket with Wrangler `--local`. It never writes to remote R2. Re-seed after changing local product metadata. Set local `RESEND_API_KEY` in an untracked `.dev.vars` only when newsletter testing is necessary; `.dev.vars.example` documents it.
No private registry credentials or content seeding are required. Set local `RESEND_API_KEY` in an untracked `.dev.vars` only when newsletter testing is necessary; `.dev.vars.example` documents it.

## Build and deployment

Expand All @@ -90,27 +71,27 @@ pnpm build:staging
- `pnpm build`: production target, using top-level Wrangler settings.
- `pnpm build:staging`: selects `env.staging` with `CLOUDFLARE_ENV=staging` **during the Vite build**.
- `pnpm bundle:report`: prints compressed JS/CSS asset sizes, largest first. The sum of all chunks is **not** the initial browser download; route-level MDX and Mermaid remain lazy, and the search dialog is deferred.
- `scripts/check-deploy-config.mjs staging|production`: asserts the generated `build/server/wrangler.json` carries the intended Worker name, custom domain, runtime environment, and R2 bucket.
- `scripts/check-deploy-config.mjs staging|production`: asserts the generated `build/server/wrangler.json` carries the intended Worker name, custom domain, runtime environment, and absence of R2 bindings.

With the Cloudflare Vite plugin, `wrangler deploy` uses the generated deployment config; `wrangler deploy --env staging` **must not** be used after the build.

Code merges do **not** deploy to Cloudflare. The deployment workflow follows 0xNAND's explicit release boundary:

1. Merge the reviewed and signed code into `main` after CI passes. This alone does not deploy either environment.
2. Set up GitHub Environments named `staging` and `production`. Verify each environment's R2 content, domain, credentials, and Worker secrets. Set environment variable `DOCS_RELEASE_READY=true` **only after** verifying that environment.
3. Run **Actions → Deploy Documentation → Run workflow** from the `main` branch, choose `staging`, and enter `DEPLOY_STAGING`. The workflow checks readiness, builds the staging environment, confirms the generated binding, deploys, and probes the live endpoints.
2. Set up GitHub Environments named `staging` and `production`. Verify each environment's domain, credentials, and any newsletter secrets. Set environment variable `DOCS_RELEASE_READY=true` **only after** verifying that environment.
3. Run **Actions → Deploy Documentation → Run workflow** from the `main` branch, choose `staging`, and enter `DEPLOY_STAGING`. The workflow checks readiness, builds the staging environment, checks the generated Worker configuration, deploys, and probes the live endpoints.
4. Once staging is verified, dispatch the same workflow from `main` targeting `production` with `DEPLOY_PRODUCTION` and a separately verified production environment (`DOCS_RELEASE_READY=true`).

Pull requests continue to typecheck, test, build **both** target configurations, verify the generated R2 bindings and report client asset sizes without deploying.
Pull requests continue to typecheck, test, build **both** target configurations, verify the generated Worker configuration and report client asset sizes without deploying.

Cloudflare deployment requires repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` with the minimum permissions for Workers and the configured custom domains. Newsletter `RESEND_API_KEY` is a **Worker secret**, set independently for the production and staging Workers. The staging `RESEND_SEGMENT_ID` is intentionally empty to prevent accidental subscriptions to the production audience; configure a separate staging segment before testing signup delivery.

Before either deployment, independently confirm the relevant R2 bucket exists, contains a valid `manifest.json` and `products/manifest.json`, is accessible to that Worker's `CONTENT` binding, and that Cloudflare domains and credentials are provisioned. CI cannot create or verify those Cloudflare resources by reading the repository. The deployment smoke tests verify both redirects and request `/docs/assay` to check real R2 access, plus the LLM, search, robots, sitemap and subscription routes. Staging serves `robots.txt` with `Disallow: /` and sets `X-Robots-Tag: noindex, nofollow, noarchive` on Worker responses.
Before either deployment, confirm the Cloudflare domain and credentials are provisioned. The deployment smoke tests verify both redirects, Assay and Throughline pages, a missing page, Markdown exports, LLM indexes, search, robots, sitemap and subscription routes. Staging serves `robots.txt` with `Disallow: /` and sets `X-Robots-Tag: noindex, nofollow, noarchive` on Worker responses.

## Bundle strategy

Fumadocs MDX uses `async: true`, so individual documents are compiled into page-level lazy chunks. Mermaid loads through a dynamic import when a diagram mounts. The search UI is also loaded on demand; the content search index is fetched from the same R2-authorized product set and cached briefly. The bundle report provides reproducible size evidence in pull-request and deploy workflows. Compare it with a browser network waterfall before claiming any percentage reduction in initial transfer or setting budgets.
Fumadocs MDX uses `async: true`, so individual documents are compiled into page-level lazy chunks. Mermaid loads through a dynamic import when a diagram mounts. The search UI is also loaded on demand; the search index is generated from the compiled MDX collection and cached briefly. The bundle report provides reproducible size evidence in pull-request and deploy workflows. Compare it with a browser network waterfall before claiming any percentage reduction in initial transfer or setting budgets.

## Worker types

`worker-configuration.d.ts` is generated locally by `wrangler types` and is intentionally **not tracked**. `pnpm typecheck` regenerates it before React Router types and the TypeScript compiler run; run `pnpm exec wrangler types` separately after changing bindings if editor types need refreshing. `opencode.json` is also ignored as machine-specific OpenCode configuration. The `CONTENT` R2 binding and `DOCS_ENV` are accessed server-side only, and no R2 credentials are shipped to the browser.
`worker-configuration.d.ts` is generated locally by `wrangler types` and is intentionally **not tracked**. `pnpm typecheck` regenerates it before React Router types and the TypeScript compiler run; run `pnpm exec wrangler types` separately after changing bindings if editor types need refreshing. `opencode.json` is also ignored as machine-specific OpenCode configuration. The `DOCS_ENV` value is used server-side to keep staging out of search indexes.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"typecheck": "wrangler types && react-router typegen && tsc",
"test": "node --test scripts/*.test.mjs && node --experimental-strip-types --test src/lib/*.test.ts",
"bundle:report": "node scripts/report-bundle.mjs",
"build:staging": "node scripts/build-env.mjs staging",
"seed:content": "node scripts/seed-content.mjs"
"build:staging": "node scripts/build-env.mjs staging"
},
"dependencies": {
"@fontsource-variable/dm-sans": "^5.3.0",
Expand Down Expand Up @@ -49,7 +48,6 @@
"takumi-js": "^2.13.1",
"tw-animate-css": "^1.4.0",
"zod": "^4.4.3",
"@0xbuff/content-contract": "npm:@0xbuffdev/[email protected]",
"@0xbuff/throughline": "0.0.2"
},
"devDependencies": {
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Reviewed first-party releases are explicitly pinned below.
# All other dependencies retain pnpm 11's default 24-hour release-age policy.
minimumReleaseAgeExclude:
- '@0xbuffdev/[email protected]'
- '@0xbuff/[email protected]'

# Reviewed native toolchain install scripts; unlisted builds remain blocked.
Expand Down
2 changes: 1 addition & 1 deletion react-router.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from "@react-router/dev/config";

/** R2-backed pages are served by the Worker, never prerendered at build time. */
/** Render the compiled MDX collection through the Worker. */
export default {
ssr: true,
appDirectory: "src",
Expand Down
17 changes: 4 additions & 13 deletions scripts/check-deploy-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,22 @@ const expected = {
staging: {
name: "0xbuff-docs-staging",
domain: "staging.docs.0xbuff.com",
bucket: "content-staging",
},
production: {
name: "0xbuff-docs",
domain: "docs.0xbuff.com",
bucket: "content",
},
}[target];
if (!expected) throw new Error("Expected staging or production target");

const config = JSON.parse(
await readFile("build/server/wrangler.json", "utf8"),
);
const config = JSON.parse(await readFile("build/server/wrangler.json", "utf8"));
assert.equal(config.name, expected.name, "Incorrect Worker target");
assert.equal(config.vars?.DOCS_ENV, target, "Incorrect runtime environment");
assert.deepEqual(config.r2_buckets, [
{ binding: "CONTENT", bucket_name: expected.bucket },
]);
assert.deepEqual(config.r2_buckets ?? [], [], "Documentation must not bind R2");
assert.ok(
config.routes?.some(
(route) =>
route.pattern === expected.domain && route.custom_domain === true,
(route) => route.pattern === expected.domain && route.custom_domain === true,
),
"Incorrect Worker custom domain",
);
console.log(
`Verified ${config.name} → ${expected.domain} with R2 CONTENT=${expected.bucket}`,
);
console.log(`Verified ${config.name} → ${expected.domain} without R2 bindings`);
Loading
Loading