Contributing
Thanks for considering a contribution to binpatch. This page
documents how we work, how to set up a dev environment, and what
to expect from review.
Project shape
Section titled “Project shape”binpatch/├── src/ # Library source│ ├── index.ts # Public API barrel│ ├── contract.ts # Shared types + constants│ ├── events.ts # ProgressEvent + safeProgress│ ├── errors.ts # BinpatchError│ ├── bspatch.ts # TRDIFF10 parse + apply│ ├── discover.ts # resolveAndApply orchestration│ ├── patch-cache.ts # On-disk cache│ └── sources/│ ├── oci.ts # Generic OCI client│ ├── ghcr.ts # GHCR source strategy│ └── github-release.ts # GitHub Releases source strategy├── test/ # Vitest suite├── action/ # GitHub Action YAML├── website/ # Astro/Starlight docs site├── .craft.yml # Release config└── .github/workflows/ # CI, release, publish, pagesDev setup
Section titled “Dev setup”git clone https://github.com/BYK/binpatchcd binpatchnpm installnpm testnpm run buildNode 22.5+ is required (matches the project’s minimum).
We use Vitest. The test suite covers:
test/bspatch.test.ts— TRDIFF10 parse + apply (the main surface)test/discover.test.ts—resolveAndApplyorchestrationtest/sources.test.ts— OCI / GHCR / GitHub Releases source strategiestest/progress.test.ts— progress event formatting helpers
Run a single test file:
npm test -- test/bspatch.test.tsRun with coverage:
npm run test:coverageMutation-verify your fix
Section titled “Mutation-verify your fix”We treat every fix as a hypothesis to be falsified. Before opening a PR:
- Write the fix.
- Write a regression test that fails on the bug.
- Revert the fix (locally — never push). Confirm the test now fails (“never trust a fix without seeing it fail”).
- Restore the fix. Confirm the test passes.
- Open the PR. The review will look for this discipline.
Pull request workflow
Section titled “Pull request workflow”- Fork or branch.
- Make your change with tests.
- Run the full gate locally:
Terminal window npm run typechecknpm testnpm run build - Open the PR against
main. - Address review comments. We use the project’s two-reviewer discipline — at least one approval from a maintainer.
- A maintainer will merge (squash) once CI is green.
Coding conventions
Section titled “Coding conventions”- No barrel exports inside the library. Import from the source
module directly:
Within the library, internal modules import each other directly (no barrel from// ✗ Avoidimport { applyPatchChainInMemory } from "binpatch";// (this works, but...)// ✓ Prefer in test filesimport { applyPatchChainInMemory } from "../src/bspatch";
index.tsto internal). - No native code. No
node-gyp, no.nodeaddons, no WASM. Anything that requires native code is out of scope. - No third-party runtime deps. The library’s only runtime dep is Node.js itself.
applyPatch()always returns the SHA-256 inline. Don’t add a separate verify step.
Security disclosures
Section titled “Security disclosures”Found a security issue? Email security@withlore.ai or open a private security advisory on GitHub. Do not open a public issue.
Code of conduct
Section titled “Code of conduct”Be kind. We follow the Contributor Covenant. Maintainers reserve the right to remove comments or close issues that violate the standard.
License
Section titled “License”By contributing, you agree that your contributions will be licensed under the project’s MIT license.
- Architecture → — design decisions, why bsdiff, why SWAR
- FAQ → — common questions