Public: anyone can read this; the crew can change it.
forked from trevato/cs
The engine a visitor reads about is one they can take: /engine serves the guide and the packed package #391
Check · Review · Land · Live done — Landed and live in production.
`/engine` is a new page where a visitor can read the engine's guide and download the engine as a single `cs-engine-<version>.tar.gz`, without cloning this repository. The page is rendered from what it describes: the version and the archive's size and sha256 come from the build that runs at start-up, and the module list is read off `src/engine/index.ts` with the comment the door writes above each m…
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
/engineis a new page where a visitor can read the engine's guide and download the engine as a singlecs-engine-<version>.tar.gz, without cloning this repository. The page is rendered from what it describes: the version and the archive's size and sha256 come from the build that runs at start-up, and the module list is read offsrc/engine/index.tswith the comment the door writes above each module. The cost table uses the same numbers/exampleprints, plus the package's own size, andGUIDE.mdis shown as escaped, preformatted text./examplenow links to the new page.bun run test(typecheck and 1,622 tests) passes.How the archive is made.
src/archive.tsruns once before the server starts listening. It runsscripts/pack.tsintoFORGE_APP_DATA/engine/cs-engine-<version>/, tars exactly the files the pack wrote withsrc/tar.ts, gzips them at level 9 with Bun, writes the.tar.gzbeside them and reads it back once. On this machine that takes about 30 ms, and the boot log prints the figure. A request never builds an archive or opens a file; it serves bytes already in memory./engine/cs-engine-<version>.<10 hex of sha256>.tar.gz. The hash is in the URL because the version tracks the door's names, not behaviour, so the version alone could not safely be cached asimmutable. The response also carriescontent-lengthandcontent-disposition: attachment; filename="cs-engine-<version>.tar.gz".VERSIONfromscripts/pack.ts, which is the version insrc/engine/surface.jsonthat the door is already checked against. There is no second copy of it.Guide on the page. Every heading outside a code block gets a
guide-<slug>anchor, duplicates get-2,-3, and there is a contents list above the text. Each module in the list links to the guide's section of the same name. There is no markdown renderer and no new dependency, and the page says a nicer rendering is a later change.Security. The only new routes are two exact entries in the server's route table. No part of a request is used to build a path, and
/engine/cs-engine-<version>.tar.gzwithout the hash, as well as..paths, get the 404. The page has the standard security headers and its own style hash, and HEAD answers like GET.src/tar.tsrefuses paths that are absolute, contain.., are not ASCII or don't fit the header.Tests (each would fail without this change):
FORGE_APP_DATA, with the right length, caching, type and security headers, and no second gzip.package.jsonnames the engine's version.tarcommand, it unpacks the archive too; GNU tar does here, with nothing on stderr./engineto the page-size budgets at 40,000 bytes gzipped. It measures 37,166, because the page carries the whole 78 kB guide.Not done:
To try it: open
/engineon the preview, click Download, then runtar -xzf cs-engine-.tar.gz && bun build cs-engine-/example.ts --outdir out. Locally that builds the sample to a 19.7 KBexample.js./engine#guide-rendererjumps to one section of the guide.🤖 Generated with Claude Code
Closes #225