Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d861870
refactor(docs): extract the steps before the model into prepare-turn …
baldurpan Nov 24, 2026
c51c5f9
feat(docs): the Dox chat eval case set and its checks (#355)
baldurpan Nov 24, 2026
85dfa3e
feat(docs): the offline Dox eval layer and its first baseline (#355)
baldurpan Nov 24, 2026
c303e75
feat(docs): the Dox eval stream reader and graders (#355)
baldurpan Nov 24, 2026
b8ba9a9
feat(docs): the live Dox eval runner, budget guard and evals environm…
baldurpan Nov 24, 2026
1996c17
fix(docs): the known grader skips comments in shell blocks (#355)
baldurpan Nov 24, 2026
c2a0992
feat(docs): the first live Dox eval run on Gemma 4 26B, committed as …
baldurpan Nov 24, 2026
c01def7
chore(context): retire the notes for dox-chat-evals (#355)
baldurpan Nov 25, 2026
25aefe3
Merge branch 'main' into feature/355-dox-chat-evals
baldurpan Nov 25, 2026
c205da2
fix(docs): follow main's renamed SKILL.md section and moved eval scor…
baldurpan Nov 25, 2026
afe957a
Merge remote-tracking branch 'origin/main' into feature/355-dox-chat-…
baldurpan Nov 25, 2026
dffca39
fix(docs): the injection canaries, budget guard and runner exits that…
baldurpan Nov 25, 2026
6574531
Merge remote-tracking branch 'origin/main' into feature/355-dox-chat-…
baldurpan Nov 25, 2026
0fb675f
Merge remote-tracking branch 'origin/main' into feature/355-dox-chat-…
baldurpan Nov 25, 2026
3ee6bb6
fix(docs): record the eval score main's cleanup docs raised (#355)
baldurpan Nov 25, 2026
227b3d7
Merge branch 'main' into feature/355-dox-chat-evals
baldurpan Nov 25, 2026
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ docs/legacy/

# The Astro build staged under worktree/ for `wrangler deploy` (docs/wrangler.jsonc)
docs/.deploy/

# Full answers from the live Dox evals (docs/evals/run-live.ts); the committed report holds none
docs/.cache/
7 changes: 5 additions & 2 deletions context/stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ docs/src/content/docs/ Starlight pages (29 pages: `index.mdx` is the landing at
docs/src/ chat client, site metadata, styles; the chat is the page `/dox` (`pages/dox.astro`, one React island, `chat/components/DoxPage.tsx`), reached by plain links only: the header's "Chat with Dox" crystal (`components/Header.astro`, repeated in the mobile menu by `components/MobileMenuFooter.astro`) and the landing's "Ask Dox" (`components/Hero.astro`); `components/DoxMark.astro` draws the crystal, and no page but `/dox` loads chat code; the header's right group ends with the settings gear (`components/SettingsControl.astro`, wired by `lib/settings-control.ts`: a native `[popover]` holding the "Dark theme" switch, whose rule is `lib/theme.ts`; it shows at every width, below 50rem as the only chip of the right group that does, and the mobile menu has no copy); sound is `lib/sound/` (GMT's engine, cut down: `settings.ts` is the reader's choice in the `dox:sound` key shared with GMT and northguild.dev, `cue.ts` is loaded on every page by `components/Head.astro`, and the engine is a chunk only its dynamic `import()` reaches, once a reader has unmuted, and on the landing alone it imports `lib/sound/leaves.ts`, the leaves' voices, driven by the last landing and the sampled landing places `hero/flight.ts` computes, only while sound is on, from the particles' own timings; no press makes a sound but the chat's Send and "Try again"); `components/Hero.astro` puts the landing's copy beside `HeroLeaves.astro` (the leaf-particle hero: a still SVG, a canvas and a small loader script; the effect itself, in `hero/` with OGL, is a chunk only the loader's dynamic `import()` reaches, so the landing alone ships hero script; its CSS is in the shared stylesheet)
docs/src/styles/northguild/ the NorthGuild theme, vendored unedited from `northguild/northguild.dev` `packages/theme/` (each file's header names the commit); `docs/src/styles/theme.css` is this site's own `--gmt-*` → `--sl-*` mapping. To refresh, see `docs/README.md` (Theme)
docs/wrangler.jsonc the docs site's Worker config (assets from `docs/.deploy`, the build staged under `worktree/` and `docs/deploy/_headers` at its root by `stage:deploy`); `docs/scripts/` holds `audit-dist.mjs`, `theme-contrast.mjs` (measures the theme's contrast pairs), `build-legacy-pages.mjs` (writes the gitignored `docs/legacy/`), `deploy-smoke.mjs` and `web-vitals.mjs` (measures Core Web Vitals by hand, not a gate)
docs/worker/ Cloudflare Worker for the docs chat, on TanStack AI: `POST /api/chat` serves the current client, `GET /api/brains` the usage counts, `POST /` the frozen legacy protocol (its own `wrangler.toml`, which binds `[ai]`, remote in dev, for the Workers AI brains, and the `DOX_USAGE` KV namespace for the usage ledger)
docs/worker/ Cloudflare Worker for the docs chat, on TanStack AI: `POST /api/chat` serves the current client, `GET /api/brains` the usage counts, `POST /` the frozen legacy protocol (its own `wrangler.toml`, which binds `[ai]`, remote in dev, for the Workers AI brains, and the `DOX_USAGE` KV namespace for the usage ledger; plus a local-only `[env.evals]`, never deployed, for the live evals)
docs/evals/ Dox chat evals (plan #355): `cases.ts` is the case set (pure data, loaded under Node type stripping: erasable syntax, `.ts` imports) and `cases.test.ts` checks it against the corpus; `metrics.ts` scores retrieval (pure), `offline.test.ts` runs every case through `validateChatRequest` and `prepareTurn` in `pnpm docs:test` and compares the scores with `baseline.json` (rewritten by `pnpm --filter docs evals:baseline`), `read-stream.ts` and `graders.ts` read and grade a live answer, `budget.ts` and `report.ts` hold the live layer's spending limits and its committed report, `run-live.ts` is the live runner (`pnpm --filter docs evals:live`; it spends real Neurons and refuses under `CI`), and `README.md` is the runbook
context/ planning-workflow artifacts (this directory)
context7.json what Context7 (context7.com) may index from this repo: the user docs, the usage skill and the README — see Documentation below
.github/agents/ documentation-only agent manifests — nothing executes them
Expand Down Expand Up @@ -70,7 +71,8 @@ context7.json what Context7 (context7.com) may index from this repo: the
`shared-workspace-lockfile=true` was removed in 260eb2f, and pnpm's default keeps the behaviour. CI
still fails the build if `docs/pnpm-lock.yaml` ever appears, so do not add one.
- **Never deploy from a workstation.** Worker and docs deploys belong to `worker-deploy.yml` and
`docs-deploy.yml` — see [`release.md`](release.md) for what `worker-deploy.yml` deploys and when, before assuming a Worker
`docs-deploy.yml`. `docs/worker/wrangler.toml`'s `[env.evals]` is local-only (it has no visitor cap and no URL) and is never
deployed: `worker-deploy.yml` passes no `--env`, and only `wrangler deploy --dry-run --env evals` is safe to run — see [`release.md`](release.md) for what `worker-deploy.yml` deploys and when, before assuming a Worker
change is live for the client. `wrangler.toml` pins local dev to
port 8787 and asks you to free the port rather than let it drift.
- **Console output is styled with chalk, so it is TTY-dependent.** Any test asserting on printed text has
Expand All @@ -87,6 +89,7 @@ untrue on one of these surfaces is fixed by the phase that makes it untrue, not
| `docs/src/content/docs/` | users looking something up, at https://northguild.dev/worktree/ | any user-visible CLI behaviour. One page per command under `commands/` (9), plus `configuration.mdx`, `project-configuration.mdx`, `index.mdx` (the landing), `getting-started.mdx`, `faq.mdx`, and `guides/` (12) |
| [`docs/README.md`](../docs/README.md) | someone working on the docs app | how the docs app is run or built |
| [`docs/worker/README.md`](../docs/worker/README.md) | someone working on the chat proxy | the Worker's routes, secrets or deploy |
| [`docs/evals/README.md`](../docs/evals/README.md) | someone changing the Dox chat's docs, retrieval or prompt, or adding an eval case | how the offline evals run, how `baseline.json` is rewritten, how a case is added, and how to run the live evals, what they cost and which changes need a live run |
| `skills/worktree/SKILL.md` | agents that install the skill with `npx skills add`; shipped in the npm package; its sections are also the docs chat's vocabulary, searched per question | a command or flag change that the skill describes — **but see the caveat below** |
| `docs/src/content/docs/changelog.mdx` | users looking for release notes | the release-process steps, if the release flow changes — it states the "single latest-docs" policy and points at `CHANGELOG.md` |
| [`context7.json`](../context7.json) | Context7, which indexes a GitHub repository's markdown for coding agents to query | the folder lists, if `docs/src/content/docs/` or `skills/` moves; a new root-level `.md` file, which is indexed unless named in `excludeFiles`; and its `rules`, which restate passages of `skills/worktree/SKILL.md`, if one of those behaviours changes |
Expand Down
14 changes: 13 additions & 1 deletion context/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ asserts the *unstyled* string, so before that pin the suite passed in CI (no TTY
interactive shell. If a console assertion ever starts failing only on someone's machine, check that pin
first.

`pnpm test` covers `src/` and `scripts/`; `pnpm docs:test` covers the `docs` workspace including the Cloudflare Worker.
`pnpm test` covers `src/` and `scripts/`; `pnpm docs:test` covers the `docs` workspace including the Cloudflare Worker and the
Dox chat's offline evals (`docs/evals/offline.test.ts`, no model and no key: it scores every case's retrieval against the
committed `docs/evals/baseline.json`, so a docs page or a retrieval change that moves a score fails here until the baseline is
rewritten in the same change).
CI runs both. As of 2026-11-04 that is 2756 and 362 tests respectively — a snapshot for recognising a suite
that did not run, not a figure to assert against. It goes stale on any commit that adds a test, so correct
it in passing rather than treating a mismatch as a failure.
Expand Down Expand Up @@ -181,6 +184,15 @@ test that genuinely has to be skipped is a conversation, not an edit to this pat
tree. `pnpm changeset:prepare-release` runs it after `changeset version`, so the release pull request
carries the result; run it by hand only to repair drift. `ci.yml` runs it and then hard-fails on drift via
`git diff --exit-code`.
- **`pnpm --filter docs evals:baseline`** — generation, not verification. It *writes* `docs/evals/baseline.json` from the
offline evals (Vitest, with `EVALS_WRITE_BASELINE=1`) and formats it with Biome, so it must never sit in a gate section.
Run it when a score moved on purpose and commit the file with the change; `pnpm check` then passes on the rewritten file.
- **`pnpm --filter docs evals:live`**, **`pnpm --filter docs worker:dev:evals`** and **`worker:dev:evals:gemini`** — not gates: they
spend real quota. `worker:dev:evals` starts the built Worker as its `[env.evals]` environment with Workers AI bound remote, so every
question the runner asks draws on the account's daily Neurons (the pool the live site answers from); `evals:live` asks it and
refuses to run when `CI` is set. They need `wrangler login` and the network. `evals:live --help` and a run with no Worker at
`--base` spend nothing. A run with `--write-baseline` rewrites `docs/evals/live-<brainId>.json`. Never run them to verify anything;
the runbook is `docs/evals/README.md`. `wrangler deploy --dry-run --env evals` is safe and credential-free.
- **`pnpm changeset:add`** — not a gate: interactive (it prompts for a bump level and a description) and it
writes a `.changeset/*.md` file. Run it when a change owes a release note, per [`release.md`](release.md).
- **`pnpm changeset:status`** — not a gate: it compares against `origin/main`, so it needs that ref and a
Expand Down
9 changes: 7 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ The build indexes the chunks with [MiniSearch](https://lucaong.github.io/minisea

#### What the Worker does with a question

For each `POST /api/chat`, after validation (`docs/worker/chat-handler.ts`):
For each `POST /api/chat`, after validation, `docs/worker/chat-handler.ts` calls `prepareTurn`
(`docs/worker/prepare-turn.ts`), which runs these four steps in order:

1. **Search** the last message of the conversation (`retrieval/search.ts`). Stopwords are dropped; an identifier such as
`branchPrefix` is also split into its words in the index; a chunk in the section of the page the reader came from
Expand Down Expand Up @@ -563,6 +564,8 @@ or use the root-level aliases where noted.
| `dev:local:watch` | Same as `dev:local`, plus watch-rebuild the worker on every save — use when editing worker code |
| `worker:dev` | Start the already-built worker at `http://localhost:8787` |
| `worker:build:watch` | Watch-rebuild the worker bundle on file changes |
| `worker:dev:evals` | Start the built worker as its local-only `evals` environment, with `GEMINI_API_KEY` blanked, for `evals:live`. It spends real Neurons: see [`evals/README.md`](evals/README.md) |
| `worker:dev:evals:gemini` | The same, with `worker/.dev.vars` left in, so the Gemini brains answer too. Spends Gemini's daily requests as well |

### AI context & skill maintenance

Expand All @@ -575,7 +578,9 @@ or use the root-level aliases where noted.

| Command | What it does |
|---|---|
| `test` | Run all docs tests with vitest |
| `test` | Run all docs tests with vitest, the offline Dox evals (`evals/offline.test.ts`) included |
| `evals:baseline` | Rewrite `evals/baseline.json` from the offline evals and format it with Biome. Run it only when a score moved on purpose; see [`evals/README.md`](evals/README.md) |
| `evals:live` | Ask the live Dox eval cases of a running `worker:dev:evals` Worker and grade the answers. **Spends real Neurons**; refuses under `CI`; `--help` lists the flags and costs and sends nothing. See [`evals/README.md`](evals/README.md) |
| `worker:test` | Run every worker test under `worker/` (the router, both handlers, the validator, the error mapping, the rate limiter) |
| `worker:bundle-check` | Build the worker, then `wrangler deploy --dry-run`: proves it still bundles for Cloudflare, with no credentials and nothing sent. Run it after changing a dependency or an import; CI runs it |
| `worker:setup-secret` | Store `GEMINI_API_KEY` as an encrypted Cloudflare secret (one-time) |
Expand Down
Loading