Development
Running from a checkout
npm ci
npm run install:node # kernelspec cdp-node
npm run install:deno # kernelspec cdp-deno
npm run install:node-deno # kernelspec cdp-node-deno
npm run install:bun # kernelspec cdp-bun
npm run install:workerd # kernelspec cdp-workerd
npm run install:celld # kernelspec cdp-celldThese kernelspecs point at the checkout, so don't move it after installing. The target runtimes need to be installed as for a released kernel (Install › Target runtimes).
In a Codespace or dev container
.devcontainer/devcontainer.json builds the container image from the checkout, with every runtime and the six kernelspecs, then runs npm ci and installs uv. Open the repository in a Codespace, or in VS Code with "Dev Containers: Reopen in Container", and the notebooks run with no other setup. Those kernelspecs run the checkout as it was when the container was built; after changing the kernel, re-run the install:* scripts above. jupyter lab starts JupyterLab on the forwarded port 8888.
Tests
npm run check # tsc --strict over src/ and test/
npm test # unit tests (node:test)
npm run e2e # conformance suite via jupyter_client/libzmq, on every target variant
npm run test:lab # an anywidget counter in real JupyterLab, headless Chromium (node, deno, bun, workerd, celld)
uv run --with nbclient --with nbformat python examples/run_notebook.py # Deno-style notebook on deno + node-denonpm run bench measures each runtime's startup and per-cell latency (Choosing a runtime › Startup and latency). Name runtimes to measure only those (npm run bench -- node bun), and add --json PATH to keep every sample. CDPK_BENCH_RUNS (default 5) and CDPK_BENCH_CELLS (default 20) set the sample counts.
The e2e suite follows Deno's tests/integration/jupyter_tests.rs and adds the gaps those tests leave: display ordering, TS, imports, npm:/jsr:, completion, and update_display_data. Set CDPK_E2E_OFFLINE=1 to skip the registry-dependent checks; typed completion then uses the checkout's TypeScript, linked into a temporary npm cache (CDPK_CACHE_DIR). Set CDPK_E2E_CLI to run it through a different CLI: an installed npm bin, or deno run -A src/main.ts to test a Deno host.
Latest runtime releases
CI tests the versions ci.yml names (celld's is in scripts/install-celld.sh, which the container image uses too). The Latest runtimes workflow runs the type check, unit tests and e2e suite each night against the newest release of Node, Deno, Bun, workerd, wrangler and celld, on Linux and macOS, so a runtime release that breaks the kernel shows up before a user finds it. Its run summary lists the versions it tested. A failed nightly run opens an issue, or comments on the one still open.
One more cell runs Node nightly, Deno canary and Bun canary as an early warning; its failures don't fail the run or open an issue. Start the workflow by hand from the Actions tab (or gh workflow run latest.yml) to check a release the day it ships.
Soak test
npm run soak holds one kernel per runtime (Node, Deno, Bun, workerd and celld; name some to run only those) through 2000 requests in a seeded random mix: plain cells, console output, display and update_display, 1 MiB text, PNG results up to 512 KiB, comm messages with binary buffers up to 1 MiB, prompt(), timers, thrown errors, kernel_info and interrupts. It checks every reply and output, that state kept across cells survives, and that the kernel still answers and runs timers at the end. It fails if the host's or the target's resident memory grows by more than 200 MiB between the session's second fifth and its end. CDPK_SOAK_CELLS, CDPK_SOAK_SEED and CDPK_SOAK_MAX_GROWTH_MB change those numbers. The Soak workflow runs it weekly and can be started from the Actions tab with a request count.
Releasing
One version number lives in three places: package.json, deno.jsonc and src/package.ts. test/package.test.ts fails if they disagree, or if CHANGELOG.md has no ## <version> (<RELEASE_DATE>) entry for it: move the "Unreleased" items under a heading for the new version as part of the bump. The landing page (site/index.html) shows the version too, and the same test fails if it differs. To release:
Bump all three and the landing page, and set
RELEASE_DATEinsrc/package.tsto today (UTC). Commit, and merge tomainby a PR.Start the
Publishworkflow onmainfrom the Actions tab with the new version (orgh workflow run publish.yml --ref main -f version=0.5.1). Whoever starts it must be a member of the@tlockneyscope on JSR, which only accepts a publish run started by a scope member. A run that another workflow starts hasgithub-actions[bot]as its actor and fails at the JSR step (#315).Pushing the tag from a checkout instead (
git tag -a v0.5.1 -m v0.5.1 && git push origin v0.5.1) starts thePublishworkflow on the tag.
The Publish workflow then:
- Checks that the version matches
package.jsonand has a changelog entry, that its tag doesn't exist yet (when started with a version), and thatRELEASE_DATEis today or yesterday. A JSR kernelspec's dependency cutoff comes from that date, so a stale one would block the release it ships in. - Checks that the commit is the merge of a pull request into
mainwhose last CI run (ci.yml: the type check, unit tests and e2e suite on every matrix cell, the e2e suite against the packed npm tarball and against a Deno host,deno publish --dry-run, and the JupyterLab widget test) passed. That tree was tested before it merged, so CI doesn't run again here. The check trusts the pull request's CI, which skips the suite on a docs-only change, so the code it publishes was tested in the pull requests that changed it. - Once both checks pass, tags the commit (when started with a version), then publishes to JSR (
deno publish) and to npm (npm publish), in two jobs that run in parallel.
Both registries authenticate the workflow through GitHub OIDC, so no tokens are stored:
- npm: a trusted publisher for
tlockney/cdp-kernel+publish.yml. - JSR: the package is linked to this repo in its JSR settings.
Once both registries have the version, a release job creates the GitHub release for the tag, with the version's CHANGELOG.md entry as its notes.
Once npm has it, an image job builds the container image from that npm release, runs the smoke test on it, and pushes it to ghcr.io/tlockney/cdp-kernel as the version and latest, for amd64 and arm64. It authenticates with the workflow's own token. After the first push, set the package's visibility to public in its GitHub package settings, or pulls need a login.
Neither registry lets a version be republished. Each job skips a version its registry already has, so re-running a release only fills in the half that failed. To re-run one, start publish on its tag: gh workflow run publish.yml --ref v0.5.1.
Docs
The docs site is built from docs/ with VitePress: npm run docs:dev to preview, npm run docs:build to build. The groups in the sidebar, and the reading level each page shows, are in docs/.vitepress/levels.ts.
A page can show its examples as notebook cells with their real output. It names a notebook in a comment, and marks each cell's code block with cell:
<!-- notebook: public/notebooks/getting-started.ipynb -->
```ts cell
const greeting: string = "Hello";
greeting + ", notebook"
```npm run docs:notebooks builds that notebook from the page (code blocks become cells, the prose around them Markdown cells) and runs it on this checkout's cdp-node kernel with nbclient (through uv), which saves the outputs and the state of any widgets, so a widget runs on the page from its saved state. A cell that fails stops the run. Commit the notebook with the page. Files beside it in docs/public/notebooks/, such as sample data, are the notebook's working directory and are published with it. If a cell block no longer matches the notebook, the docs build fails until the notebook is re-run.
A cell that shows a widget can script what its view sends the kernel, as a click or slider move would, with a comment after the block:
<!-- view sends for a slider move to 30: [{"method": "update", "state": {"celsius": 30}}] -->The runner sends those messages once the cell has run and saves the kernel's replies with the output, so the page shows the widget as the kernel left it, with a note naming what was sent. Each widget output keeps the state its model had when its own cell ran, so a later cell's change doesn't show in an earlier output.
The reference pages are generated (node scripts/reference.ts --write), so their runnable examples are marked in the doc comments: an @example written as a ```ts cell block runs in the page's notebook. Leave an example as plain ts when it can't run on its own, such as one that needs a Ganymede server, input or an interrupt.