This file is for coding agents working in the zipkit repository.
zipkit is a TypeScript ESM library and CLI for compression, running on Node 18+,
Bun, and the browser. It compiles best-in-class C libraries (libdeflate, lz4,
zstd, brotli, snappy, LZMA, bzip2, qoi) into a single WebAssembly engine and
wraps it in one typed API: named codec functions, a synchronous ZipKit class
with hybrid native dispatch, a ZIP container, web-standard streams, a worker
pool, and HTTP middleware.
Development uses Bun for scripts and tests.
- The Wasm engine in
engine/dist/is a committed deliverable. Rebuilding it needs Emscripten (bun run build:engine); building/testing the library does not. If you editengine/zipkit.corengine/build.sh, rebuild and commit the artifacts. - Keep library code (
src/) cross-runtime: Node 18+, Bun, browser. Gatenode:worker_threads/Bun.*behind feature checks with a portable fallback. - Preserve hybrid dispatch in
src/zipkit.ts(native on Bun, engine elsewhere). - Codecs are byte-only (
Uint8Array). String handling lives insrc/string.ts. - Do not write to stdout/stderr from the library core — only
src/cli.ts. - Use explicit
.jsimport specifiers. Keep strict TypeScript and ESLint intact. - Do not revert or overwrite unrelated user changes.
- Update public docs when public behavior changes.
src/index.ts— package exports (barrel).src/engine.ts—ZipKitEngineWasm loader +getEngine()singleton.src/zipkit.ts— high-level synchronousZipKitclass + hybrid dispatch.src/codecs/*.ts— per-codec async façades (gzip, zstd, brotli, …, image, video).src/compress.ts— genericcompress/decompressWith/ auto-detectdecompress.src/detect.ts— magic-byte format detection.src/string.ts— string ↔ bytes helpers.src/internal.ts— level clamping, abort/progress helpers.src/streams/—TransformStreamwrappers (native gzip/zlib/deflate + buffered).src/workers/—worker_threadspool (index.ts) + worker entry (worker.ts).src/zip/— ZIP container:index.ts,crc32.ts,datetime.ts.src/middleware/— Hono / Express / Elysia adapters +shared.ts.src/cli.ts— CLI entry and dispatch.engine/— Wasm source (zipkit.c,build.sh,vendor/) anddist/artifacts.docs/*.md— api, cli, algorithms, streaming, zip, browser.examples/— runnable usage examples.
- TypeScript strict. Tabs, single quotes, semicolons.
constby default. camelCasevalues,PascalCasetypes/classes,UPPER_SNAKE_CASEconstants,kebab-casefiles.anyonly at the Wasm/runtime boundary.- Focused comments that explain non-obvious behavior.
bun run typecheck
bun run lint
bun run test
bun run build
bun test src/zip/zip.test.ts # targetedAdd *.test.ts next to non-trivial logic. Every codec must roundtrip
byte-identically; standard formats must stay interoperable (verified against
Bun/zlib in src/detect.test.ts).
- Public API changes: update
README.mdanddocs/api.md. - CLI changes: update
README.mdanddocs/cli.md. - Example-affecting changes: update
examples/orexamples/README.md. - Do not create new Markdown files unless requested or clearly needed.
Follow CONTRIBUTING.md for branch names, commit messages, PR titles, and PR
descriptions. Repository-facing text must be in English.