Thank you for your interest in contributing to lazycommit! This guide will help you get started with the development setup and contribution process.
- Prerequisites
- Setting up the project
- Development workflow
- Testing
- Code quality guidelines
- Contributing process
- Using & testing your changes
- Project structure
Before you begin, ensure you have the following installed:
- Node.js: Version 22.13 or newer (
.nvmrcpins 22) - pnpm: Version 10.15.0 (as specified in
package.json) - nvm: For managing Node.js versions
- Git: For version control
git clone https://github.com/KartikLabhshetwar/lazycommit.git
cd lazycommitUse nvm to use the appropriate Node.js version from .nvmrc:
nvm install
nvm useInstall the dependencies using pnpm:
pnpm installRun the build script to compile TypeScript and bundle the project:
pnpm buildThe package is bundled using pkgroll (Rollup). It infers the entry-points from package.json so there are no build configurations.
During development, you can use the watch flag (--watch, -w) to automatically rebuild the package on file changes:
pnpm build -wRun TypeScript type checking:
pnpm type-checkSince pkgroll knows the entry-point is a binary (being in package.json#bin), it automatically adds the Node.js hashbang to the top of the file, and chmods it so it's executable.
You can run the distribution file in any directory:
./dist/cli.mjsOr in non-UNIX environments, you can use Node.js to run the file:
node ./dist/cli.mjsThe default test command runs deterministic regression checks against a local mock API, with no provider key needed. To also run the live integration tests, which use Groq, pass GROQ_API_KEY:
GROQ_API_KEY=<your GROQ key> pnpm testBuild first, then run offline tests without an API key:
pnpm build
pnpm testProxy integration tests additionally require LAZYCOMMIT_TEST_PROXY pointing to a running HTTP/HTTPS proxy.
The project uses manten for testing. Tests are organized in the tests/ directory:
tests/regressions.ts- Offline diff, generation, CLI, and hook regression checkstests/specs/cli/- CLI command teststests/specs/groq/- Live API integration tests (Groq)tests/specs/config.ts- Configuration teststests/specs/git-hook.ts- Git hook teststests/fixtures/- Test fixtures and sample diffs
The tests/fixtures/ directory contains sample git diffs for testing different commit scenarios:
chore.diff- Chore commitsnew-feature.diff- New feature commitsfix-nullpointer-exception.diff- Bug fix commitsconventional-commits.diff- Conventional commit format- And more...
- Use strict TypeScript configuration
- Follow the existing code style and patterns
- Ensure all functions have proper type annotations
- Use meaningful variable and function names
- Follow the existing code patterns in the project
- Keep functions focused and single-purpose
- Use descriptive variable names
- Avoid unnecessary comments (code should be self-documenting)
- Avoid unnecessary if/else statements
src/
├── cli.ts # Main CLI entry point
├── commands/ # CLI commands
│ ├── config.ts # Configuration management
│ ├── hook.ts # Git hook management
│ ├── lazycommit.ts # Main commit generation logic
│ └── prepare-commit-msg-hook.ts # Git hook implementation
└── utils/ # Utility functions
├── config.ts # Configuration utilities
├── error.ts # Error handling
├── fs.ts # File system utilities
├── git.ts # Git operations
├── ai.ts # AI provider integration (Mastra)
└── prompt.ts # User prompts
Fork the repository on GitHub and clone your fork locally.
git checkout -b feature/your-feature-name- Write your code following the project's style guidelines
- Add tests for new functionality
- Update documentation if needed
- Ensure all tests pass
# Run type checking
pnpm type-check
# Build the project
pnpm build
# Run tests (without API key)
pnpm test
# Run tests with API key (if you have one)
GROQ_API_KEY=<your-key> pnpm testUse conventional commit messages:
git add .
git commit -m "feat: add new feature"
# or
git commit -m "fix: resolve issue with X"
# or
git commit -m "docs: update README"git push origin feature/your-feature-nameThen create a pull request on GitHub.
Let's say you made some changes in a fork/branch and you want to test it in a project. You can publish the package to a GitHub branch using git-publish:
Publish your current branch to a npm/* branch on your GitHub repository:
pnpm dlx git-publishThis will output something like:
✔ Successfully published branch! Install with command:
→ npm i 'KartikLabhshetwar/lazycommit#npm/develop'
Now, you can run the branch in your project:
pnpm dlx 'KartikLabhshetwar/lazycommit#npm/develop'src/cli.ts- Main CLI entry point using cleyesrc/commands/lazycommit.ts- Commit review, preview, regeneration, and safe commit flowsrc/utils/ai.ts- Provider selection, generation, validation, retries, and API errors via Mastrasrc/utils/config.ts- Configuration managementsrc/utils/git.ts- Git operations and file analysis utilitiespackage.json- Project configuration and dependenciestsconfig.json- TypeScript configuration
- @clack/prompts - Interactive CLI prompts
- cleye - CLI framework
- @mastra/core - Multi-provider model router (OpenAI, Gemini, Anthropic, Kimi, DeepSeek, GLM, MiniMax, Groq)
- execa - Process execution
- pkgroll - TypeScript bundler
- manten - Testing framework
- TypeScript compilation
- Bundling with pkgroll
- Adding Node.js hashbang for executable
- Output to
dist/cli.mjs
- Shared snapshot-based diff analysis for CLI and hooks, including renames and binary files
- Bounded code samples in normal mode; batched analysis with
--thorough - Validated AI subjects, a bounded format retry, and SDK retries for transient errors
- Explicit noninteractive commits and read-only preview modes
- No new runtime dependencies for the analysis pipeline
- Check existing Issues
- Create a new issue for bugs or feature requests
- Join discussions in pull requests
By contributing to lazycommit, you agree that your contributions will be licensed under the Apache-2.0 License.