You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,56 +4,117 @@ Guidance for AI coding agents working in this repository. Loaded into agent cont
4
4
5
5
## Overview
6
6
7
-
`cadence-lang.org` is the Docusaurus v3 documentation site for the Cadence smart contract programming language (Flow network). Content lives in `docs/` as Markdown/MDX, rendered by Docusaurus with Code Hike for syntax-highlighted code blocks and an optional Typesense search index. Deployed at https://cadence-lang.org.
7
+
`cadence-lang.org` is the documentation and marketing site for the Cadence smart contract programming language (Flow network). Built with TanStack Start (file-based routing + Nitro SSR) + Fumadocs (MDX docs engine) + Tailwind CSS v4 + Bun. Deployed on Vercel. Includes AI chat (`/api/chat`), Orama-powered search (federated with onflow/docs via the `external/onflow-docs` submodule), and `/llms.txt` + `/llms-full.txt` LLM-optimized endpoints. The Cadence MCP server is built into the Flow CLI as `flow mcp` ([source](https://github.com/onflow/flow-cli/tree/master/internal/mcp)), not bundled here.
-`npm run start` — local dev server at http://localhost:3000
15
-
-`npm run build` — production build into `build/` (used by CI)
16
-
-`npm run serve` — serve the built site
17
-
-`npm run clear` — clear Docusaurus caches (`.docusaurus/`, `.cache-loader/`)
18
-
-`npm run swizzle` — swizzle a Docusaurus theme component
19
-
-`npm run write-translations` / `npm run write-heading-ids` — Docusaurus i18n / heading-id maintenance
20
-
-`npm run deploy` — `docusaurus deploy` (GitHub Pages); production deploy is actually driven by Vercel
21
-
22
-
No test suite is configured — there are no test scripts in `package.json`. CI (`.github/workflows/deploy.yml`) validates changes by running `npm run build` on push to `main`.
23
-
24
-
## Architecture
25
-
26
-
-`docusaurus.config.js` — single source of site config: navbar, `onBrokenLinks: "throw"`, versioned docs (`current` labeled "1.0"), JSON-LD `headTags` (Organization, WebSite, ComputerLanguage, FAQPage), conditional Typesense theme, Code Hike remark plugin (Nord theme, line numbers, copy button), optional `GTAG` analytics, `scripts: ['/hotjar.js']`.
27
-
-`sidebars.js` — one autogenerated sidebar (`docSidebar`) over the entire `docs/` tree; ordering is driven by `_category_.json` files inside each docs subfolder.
28
-
-`docs/` — all documentation content:
29
-
-`language/` — Cadence language reference; subdirs `accounts/`, `operators/`, `types-and-type-system/`, `values-and-types/`
30
-
-`tutorial/` — numbered tutorial pages (`01-first-steps.md` through `09-voting.md`)
-`static/` — copied verbatim to build root: `favicon.ico`, `fonts/`, `img/`, `llms.txt`, `robots.txt`, `hotjar.js` (loaded via the `scripts` field in `docusaurus.config.js`)
39
-
-`versions.json` — `["current"]`; only the live version exists, labeled "1.0" in config. No archived versions — don't run `docusaurus docs:version` unless intentionally branching.
40
-
-`vercel.json` — URL rewrites/redirects (e.g. legacy `/docs/1.0/*` → `/docs/*`, `/docs/language/<type-page>` → `/docs/language/types-and-type-system/<type-page>`). Update here when moving pages.
41
-
-`.github/workflows/deploy.yml` — on push to `main`, build check + Typesense scrape using `docsearch.config.json`. `scrape.yml` also exists in the same folder.
11
+
Bun ≥ 1.0 required. Node ≥ 22 (Vercel uses 24.x). Flow CLI ≥ v2.16.0 for `flow mcp`.
-`bun run dev` — local dev server at http://localhost:3000
15
+
-`bun run build` — production build into `.vercel/output/` + sitemap generation. `NODE_OPTIONS=--max-old-space-size=8192` is baked into the script (the SSR `source-*.mjs` chunk is ~13 MB and OOMs on default heap).
16
+
-`bun run start` — serve the built server (`bun .output/server/index.mjs`)
17
+
-`bun run types:check` — `fumadocs-mdx && tsc --noEmit`. May report errors against the `external/onflow-docs` submodule's own files; those are out-of-scope for this repo.
18
+
-`git submodule update --init --recursive` — populate `external/onflow-docs` (required before search index can include onflow-docs content)
19
+
20
+
No site-build CI in this repo — Vercel builds previews on every PR push.
21
+
22
+
## Stack and Toolchain
23
+
24
+
-**Bun is the toolchain.** Don't introduce npm/yarn lock files — `bun.lock` is the source of truth.
25
+
-**TanStack Start** — file-based routing under `src/routes/`. Nitro adapter for SSR (Vercel preset). `src/routeTree.gen.ts` is auto-generated.
26
+
-**Fumadocs** — `fumadocs-core`, `fumadocs-ui`, `fumadocs-mdx`. Source loader at `src/lib/source.ts`. MDX config in `source.config.ts`.
27
+
-**Tailwind CSS v4** — via `@tailwindcss/vite` plugin (no config file). Theme tokens are CSS variables in `src/styles/app.css`. Use `cn()` from `src/lib/cn.ts` for class merging.
28
+
-**`@vercel/og`** — server-side OG images via Satori + resvg-wasm.
29
+
-**Dark mode** uses the `dark` class on `<html>` (Fumadocs convention).
42
30
43
31
## Conventions and Gotchas
44
32
45
-
-**Node 20.x is pinned** (`package.json``engines`; CI uses `actions/setup-node@v3` with `node-version: 20`). Don't bump one without the other.
46
-
-**Docusaurus is pinned to 3.0.0** exactly (no caret). `@docusaurus/core`, `@docusaurus/preset-classic`, and `@docusaurus/module-type-aliases` must move together.
47
-
-**Broken links fail the build.**`onBrokenLinks: "throw"` in `docusaurus.config.js`. When renaming a docs page, grep across `docs/` and `src/` and update references (or add a redirect in `vercel.json`).
48
-
-**Typesense search is env-gated.** The theme only loads when both `TYPESENSE_NODE` and `TYPESENSE_SEARCH_ONLY_API_KEY` are set (see `.env.example`). Locally, search UI is absent unless those are set.
49
-
-**Code Hike is active on all docs code blocks** (`remarkCodeHike` with Nord theme, `lineNumbers: true`, `showCopyButton: true`). Standard fenced code blocks work as-is.
50
-
-**Sidebar is autogenerated.** Control labels and position via each folder's `_category_.json`, not by editing `sidebars.js`.
51
-
-**Tailwind scans `src/**/*` and `docs/**/*.mdx`** only (`tailwind.config.js``content`). Tailwind classes inside plain `.md` docs will not be generated — use `.mdx` if you need them.
52
-
-**URL redirects belong in `vercel.json`**, not page front-matter. Follow existing patterns there when restructuring.
53
-
-**Licensing is split:** source under Apache 2.0 (`LICENSE.txt`), content under CC-BY-4.0 (`CC-BY-4.0.txt`); see `LICENSE.md`.
-`static/llms.txt` — curated for LLM discovery; verify source before editing
33
+
These are the things a competent dev would otherwise get wrong.
34
+
35
+
-**`NODE_OPTIONS=--max-old-space-size=8192` is required for builds.** Baked into `package.json`. The SSR `source-*.mjs` chunk grew past the 4 GB default heap when the `external/onflow-docs` submodule was added. Don't strip the flag.
36
+
-**Submodule pin is deliberate, not branch-tracking.**`external/onflow-docs` points to a specific commit. Bumping it is a semi-supply-chain action — review the diff.
37
+
-**Satori (the `@vercel/og` renderer) cannot render SVG `<path>` elements.** For per-doc OG images at `og.docs.$.tsx`, use PNG base64 data URIs via `src/lib/og-icon.ts`. Inline SVG paths will silently fail.
38
+
-**URL redirects belong in `vercel.json`**, not page frontmatter. When moving or renaming a page, add the redirect there.
39
+
-**Server-only handlers use the TanStack pattern:**
# Cadence MCP server — type checking, symbol lookup, on-chain queries (requires Flow CLI ≥ v2.16.0)
81
+
claude mcp add --scope user cadence-mcp -- flow mcp
82
+
```
83
+
84
+
Or install both in one command:
85
+
86
+
```bash
87
+
sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-ai-tools/main/scripts/install.sh)"
88
+
```
89
+
90
+
## AI Surfaces
91
+
92
+
-**`/api/chat`** — Anthropic streaming via `@ai-sdk/anthropic`. Server-only key.
93
+
-**Search** — Orama index over `content/docs/` + `external/onflow-docs/`. Panel at `src/components/search.tsx`, Cmd+/ hotkey, localStorage persistence.
94
+
-**`/llms.txt`** / **`/llms-full.txt`** — TanStack server routes emitting LLM-optimized markdown.
0 commit comments