# Contributing to GComet

Thank you for your interest in contributing to GComet! This guide will help you get started.

## Development Setup

### Prerequisites

- Node.js >= 16.0.0
- pnpm (recommended) or npm
- Git

### Getting Started

```bash
# Clone the repository
git clone https://github.com/Soumyodeep-Das/gcomet.git
cd gcomet

# Install dependencies
pnpm install

# Build the project
pnpm run build

# Run in development mode
pnpm run dev
```

### Development Scripts

| Command | Description |
|---------|-------------|
| `pnpm run build` | Compile TypeScript to JavaScript |
| `pnpm run dev` | Run from source using ts-node |
| `pnpm test` | Run the test suite |
| `pnpm run test:coverage` | Run tests with coverage report |
| `pnpm run lint` | Check code with ESLint |
| `pnpm run format` | Format code with Prettier |
| `pnpm run format:check` | Check formatting without writing |

## Project Architecture

GComet follows a modular architecture with clear separation of concerns:

```
src/
├── index.ts            # CLI entry point (Commander.js)
├── types.ts            # Shared TypeScript interfaces
├── ai/                 # AI service layer (GitHub Models API)
├── git/                # Git operations layer (simple-git)
├── security/           # Secret detection and diff sanitization
├── config/             # Configuration management
└── commands/           # CLI command handlers
    ├── generate.ts     # Core commit generation workflow
    ├── setup.ts        # Interactive setup wizard
    ├── hook.ts         # Git hook management
    └── config.ts       # Configuration CRUD
```

## Contributing Guidelines

### Code Style

- We use **TypeScript** with strict mode enabled
- Code is formatted with **Prettier** — run `pnpm run format` before committing
- Follow existing patterns for consistency

### Commit Messages

This project uses [Conventional Commits](https://conventionalcommits.org/). We recommend using GComet itself to generate commit messages:

```bash
git add .
pnpm run dev -- generate
```

### Pull Requests

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/your-feature`
3. Make your changes
4. Add tests for any new functionality
5. Ensure all tests pass: `pnpm test`
6. Ensure code builds: `pnpm run build`
7. Submit a pull request

### Writing Tests

- Tests live in `__tests__/` directories alongside the source code
- Use Jest as the test framework
- Mock external dependencies (git, filesystem, API calls)
- Aim for high coverage on new code

### Reporting Bugs

1. Check existing issues first
2. Include your OS, Node.js version, and gcomet version
3. Include the full error output
4. Include steps to reproduce the issue

## License

By contributing, you agree that your contributions will be licensed under the MIT License.
