Thank you for your interest in contributing! This document covers the setup, development workflow, and guidelines for the project.
- Node.js 20+
- Git available on PATH
- npm (comes with Node.js)
git clone https://github.com/utkarsh232005/git-context.git
cd git-context
npm install| Command | Description |
|---|---|
npm run typecheck |
Run TypeScript type checking (no emit) |
npm test |
Run all integration tests |
npm run build |
Compile TypeScript to dist/ |
npm run check |
Run typecheck → test → build in sequence |
npm run lint |
Run ESLint |
npm run bench |
Run performance benchmarks |
Always run the full check before pushing:
npm run checkThis runs typecheck, tests, and build in sequence. CI runs the same pipeline.
src/
├── index.ts # Public API entry point
├── cli.ts # CLI entry point (npx git-context)
├── git-context.ts # Core context assembly
├── types.ts # TypeScript interfaces
├── commands/ # Individual Git command wrappers
│ ├── run-git.ts # Safe execFile abstraction
│ ├── author.ts # Commit author/email
│ ├── branch.ts # Branch state
│ ├── commit.ts # Commit SHA
│ ├── remote.ts # Remote discovery
│ └── status.ts # Dirty state
├── assertions/ # Safety guards
│ ├── branch.ts # Branch requirement
│ └── clean.ts # Clean working tree
├── errors/ # Error class hierarchy
│ └── index.ts
└── repository/ # Repository discovery
└── discover.ts
tests/ # Integration tests (real Git repos)
benchmarks/ # Performance benchmarks
examples/ # Usage examples
Tests use Node.js built-in test runner (node:test) and create real temporary Git repositories. No mocking is used — every test exercises actual Git commands.
import assert from "node:assert/strict";
import { test } from "node:test";
import { git } from "../src/index.js";
test("my test", () => {
// Create a temp repo, exercise git(), assert results
});Run a single test file:
npx tsx --test tests/compatibility.test.ts- Read-only — never modify repository state
- No shell — all Git commands use
execFileSyncwith argument arrays - No dependencies — zero runtime dependencies
- Fresh snapshots —
git()always reads current state, never caches dirty state - Actionable errors — every failure throws a typed, descriptive error
- Strict TypeScript (
strict: true,noUncheckedIndexedAccess,exactOptionalPropertyTypes) - ESM-only (
"type": "module") - No default exports
- Preserve existing comments and docstrings
- Fork the repository
- Create a feature branch from
main - Make your changes
- Run
npm run checkto verify - Open a pull request against
main
CI will automatically run typecheck, lint, tests, and build on your PR.
By contributing, you agree that your contributions will be licensed under the MIT License.