File size: 5,196 Bytes
1f2d50a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# Conventional Commits Guide
This project uses [Conventional Commits](https://www.conventionalcommits.org/) to ensure consistent, readable commit messages that can be automatically processed for changelog generation and semantic versioning.
## Quick Start
### Using Commitizen (Recommended)
Instead of `git commit`, use:
```bash
npm run commit
# or directly
npx cz
```
This will prompt you through creating a properly formatted commit message.
### Manual Format
If writing commit messages manually, follow this structure:
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
## Commit Types
| Type | Description | SemVer Impact |
|------|-------------|---------------|
| `feat` | New feature | MINOR |
| `fix` | Bug fix | PATCH |
| `docs` | Documentation only | - |
| `style` | Formatting, missing semi-colons, etc. | - |
| `refactor` | Code change that neither fixes a bug nor adds a feature | - |
| `perf` | Performance improvement | PATCH |
| `test` | Adding tests | - |
| `build` | Build system changes | - |
| `ci` | CI configuration changes | - |
| `chore` | Other changes that don't modify src or test files | - |
| `revert` | Revert a previous commit | - |
## Scopes
Use these scopes to indicate which part of the codebase is affected:
### Core Modules
- `kg` - Knowledge graph related (InMemoryKG, etc.)
- `embedder` - Embedding service functionality
- `ontology` - Data models and ontology (MCPTool, etc.)
- `agent` - Agent-related functionality
- `planner` - Planning and orchestration
- `ui` - User interface components
- `api` - API endpoints
### Infrastructure
- `deps` - Dependencies updates
- `config` - Configuration changes
- `scripts` - Scripts and automation
- `ci` - CI/CD pipeline
- `docs` - Documentation
- `tests` - Testing infrastructure
## Examples
### Good Commit Messages
#### Features
```
feat(kg): implement cosine similarity search in InMemoryKG
- Add _cosine_similarity method using numpy
- Implement find_similar_tools with top_k parameter
- Handle edge cases for empty vectors and indexes
```
```
feat(embedder): add live OpenAI API integration
Integrate OpenAI text-embedding-3-small model for real embeddings
replacing the placeholder hash-based implementation.
```
#### Bug Fixes
```
fix(kg): handle zero vectors in cosine similarity calculation
Previously returned NaN when calculating similarity with zero vectors.
Now returns 0.0 as expected.
```
#### Documentation
```
docs(api): add embedder service API documentation
Document all public methods including get_embedding and error handling.
```
#### Chores
```
chore(deps): update numpy to 1.26.0
Update numpy dependency for improved performance and security fixes.
```
#### Tests
```
test(kg): add integration tests for semantic search pipeline
Add comprehensive tests covering embeddings β indexing β search workflow
with mocked OpenAI API calls.
```
### Breaking Changes
When introducing breaking changes, add `!` after the type/scope:
```
feat(api)!: change embedder interface to async
BREAKING CHANGE: EmbeddingService.get_embedding() now returns a coroutine.
All callers must be updated to use await.
```
## Validation
Commit messages are automatically validated using commitlint when you commit. If a message doesn't follow the convention, the commit will be rejected with helpful error messages.
To manually validate a commit message:
```bash
echo "feat(kg): add new feature" | npx commitlint
```
## Integration with Development Workflow
### Sprint Tasks
When working on sprint tasks, include the task information in the commit body:
```
feat(kg): implement vector index building
Complete Task 2.2 from Sprint 2: Real Embeddings & Semantic Search Logic.
Add build_vector_index method that integrates with EmbeddingService
to create real vector representations of tools.
Closes: #9
```
### Pull Requests
PR titles should follow the same conventional format as commit messages. The PR description should reference related tasks and provide context.
## Benefits
1. **Automated Changelog**: Tools can generate changelogs from commit history
2. **Semantic Versioning**: Commit types map to version bumps (feat β minor, fix β patch)
3. **Better Code Review**: Clear indication of change type and scope
4. **Improved Git History**: Consistent, searchable commit messages
5. **Tool Integration**: Many tools understand conventional commits for automation
## Troubleshooting
### Commitlint Errors
If commitlint rejects your commit:
1. Check the error message for specific issues
2. Ensure you're using a valid type and scope
3. Keep the subject line under 72 characters
4. Use present tense ("add" not "added")
### Bypassing Validation (Emergency Only)
In rare cases where you need to bypass validation:
```bash
git commit --no-verify -m "emergency fix"
```
**Note**: Only use this for genuine emergencies.
## References
- [Conventional Commits Specification](https://www.conventionalcommits.org/)
- [Angular Commit Message Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines)
- [Commitizen](https://github.com/commitizen/cz-cli)
- [Commitlint](https://commitlint.js.org/) |