Thanks for helping out. Bug reports, notation gaps, and pull requests are all welcome — open an issue first for anything larger than a fix; the bug and feature forms collect what a report needs.
Bun only. Do not use npm, yarn, or pnpm in this
repository. Bun is the test runner (bun test), the script runner, and the
package manager whose lockfile (bun.lock) is committed — dist/ itself is
a per-file tsc emit via bun run build, not a bundle. Installing with
another manager writes a competing lockfile and produces a different
dependency tree than CI resolves.
bun install # also installs the pre-commit hook bun check:fix # typecheck + biome check --write (lint, format, import sort) bun test # full suite, ~5s bun validate # full gate: check, build, package checks, size budgets, site, coverage
Run bun check:fix and bun test while you work; run bun validate before
opening a pull request. bun test:ci adds coverage, gated at 98% lines and
100% functions per bunfig.toml, which is the only place those numbers live.
bun install runs the prepare script, which points core.hooksPath at
.githooks/. The hook runs nano-staged,
which applies biome check --write to staged .ts/.tsx files and re-stages
the result. Formatting and lint fixes land automatically; anything Biome cannot
fix blocks the commit.
Match the surrounding code. Style, naming, and type conventions are enforced by
biome check rather than written down; what cannot be linted lives in
AGENTS.md: Comments (the // !, // ?, // *, // TODO: prefixes and
their colors), Testing (error assertions, the error-code gate, CLI test
placement), and RNG (the RNG contract). A few constraints worth calling
out:
- Relative imports inside
src/carry explicit.jsextensions — the repo typechecks undermoduleResolution: nodenext, which rejects extensionless specifiers outright. - No roll path may call
Math.random()directly — dice are drawn only through theRNGinterface. The single permitted use is seedingSeededRNGwhen the caller supplies no seed. Nothing outsidesrc/cli/may import fromnode:— the library has to stay browser-safe. - Every code sample in a JSDoc
@exampleor inREADME.mdmust be executed and produce the output it claims.
Conventional Commits, with the issue number appended:
<type>: <description> #<issue>
Types: feat, fix, docs, style, refactor, test, chore, perf,
build, ci. Imperative mood, under 72 characters, no trailing period. The
optional body is past tense, one line per change, backticks around code
references. Add a Changelog: skip trailer to keep a commit out of the release
notes.
A pull request should be a single commit when it merges — squash locally and force-push rather than merging a chain of fixups. The pull request template prefills the expected body shape.
The demo site in site/ is deployed to Cloudflare Pages.
bun site:dev # Bun HTML dev server (no TypeDoc, so /docs/ is absent). The site # consumes built dist/ — rerun `bun run build` to see library edits bun site:build # full static build into site/dist/, including the TypeDoc reference bun site:check # verify site/dist/ — assets resolve, no dev paths leaked bun site:preview # build, then serve site/dist/ with host-style routing
TypeDoc lives in the scripts/docs workspace rather than the root, and
site:build invokes it from scripts/docs/node_modules/.bin/typedoc. TypeDoc
0.28.x peers at TypeScript <=6.0.x and throws on the root typescript@7, so
that workspace nests its own typescript@6 for TypeDoc to resolve. Nesting is
required rather than a scoped republish, because TypeDoc imports the bare
typescript specifier. Do not fold the workspace back into the root — the root
install would hand TypeDoc TypeScript 7 and site:build would fail. It can go
away once TypeDoc 1.0 supports TypeScript 7.
package.json's files ships src/ alongside dist/. That is deliberate:
declarationMap: true emits .d.ts.map files pointing back at the TypeScript
sources, so a consumer's "go to definition" lands on real code instead of a
declaration stub. Removing src/ from files breaks that silently — nothing
fails, the jumps just stop working.
Maintainers only.
- Update
CHANGELOG.mdfor the target version —bun run check:changelogfails without a section for it, andrelease:dryfails at that step. Sections are ordered Added, Changed, Deprecated, Removed, Fixed, Security, Documentation. - Bump
package.json, runbun run generate:version, and commit both files on their own aschore: release v<version>—check:versionfails the release ifsrc/version.tsis stale. Never tag a pre-existing unrelated commit. - Push that commit to
masterbefore the tag. The workflow'sprecheckjob resolves the tagged SHA withgit branch -r --containsand refuses to release a commit that is not onmasteror a version branch, so a tag that arrives first fails the run. - Tag that commit
v<version>and push the tag;.github/workflows/release.ymltakes it from there.
bun run release:dry runs the whole gate locally first.
Both pushes need the admin bypass on the protect-master and release-tags
rulesets — release-tags restricts creating refs/tags/v*, so an account with
only write access cannot push a release tag at all.