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
{{ message }}
Repository navigation
Commit f59c2b7
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: apps/docs/README.md
+25-10Lines changed: 25 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The Next.js + Fumadocs app that renders `trigger.dev/docs` at `/docs`. Writers o
6
6
pnpm --filter docs-site dev # http://localhost:43000/docs
7
7
pnpm --filter docs-site build:sdk # once, and after SDK type changes: type hovers and <SdkType> read these
8
8
pnpm --filter docs-site build
9
-
pnpm --filter docs-site check # after a build: links, URL contract, headers
9
+
pnpm --filter docs-site check # after a build: links, URL contract, MCP
10
10
pnpm --filter docs-site check --links # links and anchors only, no build
11
11
```
12
12
@@ -17,18 +17,19 @@ pnpm --filter docs-site check --links # links and anchors only, no build
17
17
## SDK types in the docs
18
18
19
19
- Type hovers: on production builds, every `ts`/`tsx` block that imports from `@trigger.dev/*` is analysed with the built SDK types (`lib/twoslash.ts`). Readers see hovers on imported names and documented options, never compiler errors, and type errors don't fail the build (about two thirds of samples have some, almost all from being excerpts); a block that can't be analysed renders as plain highlighted code. Results are cached in `.next/cache/twoslash/<types hash>`. `DOCS_TWOSLASH=1` turns hovers on in `dev`, `DOCS_TWOSLASH=0` turns them off; add `no-twoslash` to a fence's meta to skip one block. A block that calls SDK names (`task(`, `logger.info`, `chat.agent`) without importing them gets a hidden import line above a `// ---cut---`, inferred from the packages' exports, so it gets hovers too. Under `CI` the build fails if the SDK types aren't built.
20
-
-`<SdkType name="TaskOptions" />` renders the properties of a type exported from `lib/sdk-types/index.ts`, with types, defaults and JSDoc from the SDK source. Add a line there to document another type. The tables are generated by `scripts/build-search-index.mjs` into `.generated/sdk-types.js`, and the same rows become a markdown table in the page's `.md` and `llms-full.txt`.
20
+
-`<SdkType name="TaskOptions" />` renders the properties of a type exported from `lib/sdk-types/index.ts`, with types, defaults and JSDoc from the SDK source. Add a line there to document another type. The tables are generated by `scripts/build-search-index.mjs` into `.generated/sdk-types.js`, and the same rows become a markdown table in the page's `.md`, `llms-full.txt`, MCP and Ask AI.
21
21
22
22
## What `check` covers
23
23
24
24
-`lib/slug.test.ts`: heading ids match the previous docs site, so existing `#anchor` links keep working.
25
25
-`scripts/check-links.mjs`: every internal link and `#anchor` in the MDX resolves to a page (or a `docs.json` redirect) and a heading.
26
26
-`scripts/check-urls.mjs <base>`: every URL in `scripts/live-sitemap.txt` (a snapshot of the published sitemap; `--refresh` re-fetches it), every `docs.json` redirect, and the URLs CLIs and agents depend on answer 200 on `<base>`. `--live` also checks every page in production's sitemap today (the release gate uses it, so a page first published on the new site keeps its URL).
27
-
-`scripts/check-headers.mjs <base>`: pages can only be framed by the docs, and responses carry `nosniff` and the referrer policy.
27
+
-`scripts/check-mcp.mjs <base>`: `/mcp` answers the docs search request published CLIs send, and `get_page_trigger_dev` returns a page with its snippets inlined.
28
+
-`scripts/check-headers.mjs <base>`: pages can only be framed by the docs, `/embed/*` pages only by the dashboards, and responses carry `nosniff` and the referrer policy.
28
29
29
-
`check-urls.mjs` and `check-headers.mjs` also run against any deployment: `node scripts/check-urls.mjs https://<preview>/docs`.
30
+
`check-urls.mjs`, `check-mcp.mjs` and `check-headers.mjs` also run against any deployment: `node scripts/check-urls.mjs https://<preview>/docs`.
30
31
31
-
`pnpm --filter docs-site test` runs the unit tests.
32
+
`pnpm --filter docs-site test` runs the unit tests, including `lib/api-access-spec.test.ts`, which fails when an OpenAPI operation's `x-trigger-access` doesn't match its webapp route. `node scripts/api-access.mjs` rewrites those values from the routes.
32
33
33
34
## Build-time data
34
35
@@ -37,23 +38,37 @@ pnpm --filter docs-site check --links # links and anchors only, no build
37
38
## For agents
38
39
39
40
- Every page's `.md` starts with frontmatter: `title`, `description`, `url`, `last_updated`, `section`, `group` and `related` (previous, next and sibling pages from the sidebar).
41
+
- "Copy prompt" (`components/copy-prompt.tsx`) shows on guides and on pages with `<Steps>`: it copies the page's markdown as instructions for an AI coding assistant.
42
+
- WebMCP (`lib/webmcp.ts`, registered by `components/webmcp.tsx`): where the browser has the API, the page registers `search_docs` and `read_page` for agents running in the browser.
43
+
44
+
## Content-gap report
45
+
46
+
`node scripts/content-gaps.mjs` reads the last 7 days of `docs_search`, `docs_search_result_clicked`, `docs_ask_ai_answered` and `docs_ask_ai_feedback` events from PostHog and prints the questions the docs didn't answer (no search results, no click, no citations, thumbs down), grouped by topic. It needs `POSTHOG_PERSONAL_API_KEY`, `POSTHOG_PROJECT_ID` and `POSTHOG_HOST`. `--linear` (with `LINEAR_API_KEY`, `LINEAR_TEAM_ID`, `LINEAR_PROJECT_ID`) files one issue per new topic with at least `--min` readers (default 2), skipping topics already filed. `--fixture scripts/fixtures/content-gaps.json` runs without keys.
47
+
48
+
Exit codes: 0 report printed, 1 an API failed, 2 keys missing, 3 no docs events at all in the window (usually a missing or wrong analytics key on the site, not a quiet week). A query that hits its row limit prints a "Truncated" warning.
40
49
41
50
## Deployment
42
51
43
-
Built and deployed from GitHub Actions only (the host's Git integration is off in `vercel.json`): `.github/workflows/publish-docs.yml` deploys every new `docs-live` commit (docs-only commits on merge, everything else with a `docs-release-*` tag) and checks it with `check-urls` and `check-headers` before it takes the production domain. A production build stops if any setting marked "production" below is unset. Preview deployments send `X-Robots-Tag: noindex` (`next.config.mjs`).
52
+
Built and deployed from GitHub Actions only (the host's Git integration is off in `vercel.json`): `.github/workflows/publish-docs.yml` deploys every new `docs-live` commit (docs-only commits on merge, everything else with a `docs-release-*` tag) and checks it with `check-urls`, `check-mcp` and `check-headers` before it takes the production domain. A production build stops if any setting marked "production" below is unset. Preview deployments send `X-Robots-Tag: noindex` (`next.config.mjs`).
44
53
45
54
## Settings
46
55
47
56
`.env.example` lists them with their defaults; copy it to `.env.local`.
48
57
49
58
| Name | Read at | Production | Without it |
50
59
| --- | --- | --- | --- |
51
-
|`NEXT_PUBLIC_POSTHOG_KEY`| build | required | No analytics events. |
60
+
|`ANTHROPIC_API_KEY`| build and runtime | required | No Ask AI button, and `/api/ask` answers 404. |
61
+
|`ASK_AI_MODEL`| runtime | optional | Ask AI uses its default model. |
62
+
|`ASK_AI_DAILY_TOKENS`| runtime | optional | Ask AI closes for the day after 25M tokens (output tokens count 5 times), about $50 a day at Sonnet-class prices. Set it when the model or the spend you want changes; `0` keeps Ask AI closed. |
63
+
|`REDIS_URL`| runtime | required | Ask AI's rate limits and daily cap. Locally, Ask runs unlimited; on a deployment, Ask answers 503. |
64
+
|`DOCS_WORKER_SECRET`| runtime | required | The shared secret the proxy in front of the site sends with the reader's IP. Without it, Ask AI limits key on the connecting address, so readers behind the proxy share one limit. |
65
+
|`NEXT_PUBLIC_POSTHOG_KEY`| build | required | No analytics events, so the content-gap report has nothing to read. |
52
66
|`NEXT_PUBLIC_POSTHOG_HOST`| build | optional | Events go to PostHog's EU host. |
53
-
|`NEXT_PUBLIC_DASHBOARD_URL`| build | optional | The Dashboard link goes to `https://cloud.trigger.dev`, which is right for production. |
67
+
|`NEXT_PUBLIC_DASHBOARD_URL`| build | optional | Sign-in links and personalization use `https://cloud.trigger.dev`, which is right for production. |
68
+
|`NEXT_PUBLIC_DOCS_PERSONALIZATION`| build | required | Every reader sees the anonymous docs: no project in code samples, no docs keys. |
54
69
|`DOCS_API_SERVER_URL`| build and runtime | optional | The API playground offers only the servers in the OpenAPI spec. Set it to add another (a local or staging API). |
55
70
|`DOCS_TWOSLASH`, `DOCS_BUILD_CPUS`| build | optional | See "Dev server" and "SDK types in the docs". |
56
71
|`DOCS_DEV_ORIGINS`| dev | optional |`next dev` answers only on localhost. Comma-separated hosts to allow another (a tailnet name, say). |
57
-
|`VERCEL_AUTOMATION_BYPASS_SECRET`| check scripts | optional |`check-urls` and `check-headers` can't get past Vercel Authentication on a preview. |
72
+
|`VERCEL_AUTOMATION_BYPASS_SECRET`| check scripts | optional |`check-urls`, `check-mcp` and `check-headers` can't get past Vercel Authentication on a preview. |
58
73
59
-
Browser events for monitoring: `docs_not_found` (a 404, with `path` and `referrer`).
74
+
Logs are one JSON object per line. The `event` field: `ask` (an answer: sources, tool counts, latency, token usage, `siteCount`; never the question), `ask.error` (the model call failed; the reader still gets HTTP 200 with an error in the stream), `ask.limited` (a 429, with `limit`: `minute`, `day` or `site`), `ask.ratelimit_error` (the limiter failed, so Ask answered 503), `ask.redis_error` (Redis connection errors, at most one a minute), `ask.timeout` and `ask.aborted` (an answer cut off at 50 s, or stopped by the reader; both still count toward the daily budget), `ask.tool_error` (a search or page read the model asked for failed), `ask.spend_error` (the token count couldn't be added to the daily budget), `mcp.error` (an exception inside an MCP call). Browser events for monitoring:`docs_reader_error` (personalization failed for a signed-in reader; `status` 0 means blocked or unreachable) and`docs_not_found` (a 404, with `path` and `referrer`).
0 commit comments