Contributing
See the full CONTRIBUTING.md on GitHub for the complete guide. Here’s the quick version:
Adding an atom
- Create
src/atoms/<name>.ts - Export a function that returns
Step - Add JSDoc with usage examples
- Export from
src/atoms/index.ts - Re-export from
src/index.ts - Add tests
Adding a scenario
- Create
src/scenarios/<kebab-name>.tsusingdefineScenario(copytemplates/scenario.template.tsfrom the repo root as your starting point) - Create
src/scenarios/<kebab-name>.test.tsverifying all contracts (copytemplates/scenario.test.template.tsas your starting point) - Register in
src/scenarios/index.ts - Re-export from
src/index.ts - Regenerate the website data: run
npm run build && cd www && npm run gen:scenarios, then commitwww/src/data/scenarios.json
Determinism requirement
Every scenario must be byte-identical across runs — this is the library’s headline guarantee, enforced by the property test in src/__tests__/determinism.properties.test.ts, which runs all registered scenarios. Your scenario will be caught if it drifts. To stay deterministic:
- Never use wall-clock time (
new Date()) orMath.random()in setup. - Let the atoms handle commit dates.
commitAll,commit,addCommit,bulkCommits, and the operation atoms pin a deterministic author/committer date from the monotonic commit clock (src/commitClock.ts) automatically. UsedaysAgo(n)or an explicitdateonly when a scenario needs a specific timeline. - Use
seededFiles({ seed, files })for generated file content, never random data. - If you shell out to git directly (rare), set
GIT_AUTHOR_DATE/GIT_COMMITTER_DATEyourself — see how the scoped atoms do it insrc/atoms/scopes.ts.
See Architecture → Determinism for the full rationale.
Running locally
git clone https://github.com/gfargo/git-scenarios.gitcd git-scenariosnpm installnpm test # run all testsnpm run build # compile with tsupnpm run lint # eslintPR checklist
- New atoms have JSDoc with examples
- New scenarios have co-located tests verifying every contract
- New scenarios are deterministic (no wall-clock / random; determinism property test passes)
-
www/src/data/scenarios.jsonregenerated and committed (npm run build && cd www && npm run gen:scenarios) - Exports added to barrel files
-
npm run buildpasses -
npm testpasses -
npm run lintpasses - CHANGELOG.md updated