orcommit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/cli.d.ts +70 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +391 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/api.d.ts +48 -0
- package/dist/modules/api.d.ts.map +1 -0
- package/dist/modules/api.js +286 -0
- package/dist/modules/api.js.map +1 -0
- package/dist/modules/cache.d.ts +74 -0
- package/dist/modules/cache.d.ts.map +1 -0
- package/dist/modules/cache.js +284 -0
- package/dist/modules/cache.js.map +1 -0
- package/dist/modules/config.d.ts +53 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +180 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/core.d.ts +54 -0
- package/dist/modules/core.d.ts.map +1 -0
- package/dist/modules/core.js +474 -0
- package/dist/modules/core.js.map +1 -0
- package/dist/modules/diff-filter.d.ts +71 -0
- package/dist/modules/diff-filter.d.ts.map +1 -0
- package/dist/modules/diff-filter.js +332 -0
- package/dist/modules/diff-filter.js.map +1 -0
- package/dist/modules/git.d.ts +61 -0
- package/dist/modules/git.d.ts.map +1 -0
- package/dist/modules/git.js +362 -0
- package/dist/modules/git.js.map +1 -0
- package/dist/modules/logger.d.ts +67 -0
- package/dist/modules/logger.d.ts.map +1 -0
- package/dist/modules/logger.js +212 -0
- package/dist/modules/logger.js.map +1 -0
- package/dist/modules/tokenizer.d.ts +43 -0
- package/dist/modules/tokenizer.d.ts.map +1 -0
- package/dist/modules/tokenizer.js +200 -0
- package/dist/modules/tokenizer.js.map +1 -0
- package/dist/types/index.d.ts +141 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +70 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +64 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +154 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mark Olofsen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# OpenRouter Commit
|
|
2
|
+
|
|
3
|
+
> AI-powered Git commit message generator with efficient chunk processing for large files
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/orcommit)
|
|
6
|
+
[](https://github.com/ellerbrock/typescript-badges/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
A sophisticated CLI tool that generates meaningful, contextual commit messages using OpenRouter and OpenAI APIs. Designed with a modular TypeScript architecture and optimized for handling large codebases through intelligent diff chunking.
|
|
10
|
+
|
|
11
|
+
## โจ Features
|
|
12
|
+
|
|
13
|
+
- ๐ค **AI-Powered**: Generate commit messages using OpenRouter and OpenAI models
|
|
14
|
+
- ๐ฆ **Chunked Processing**: Efficiently handle large diffs by breaking them into manageable pieces
|
|
15
|
+
- ๐ง **Configurable**: Support for multiple providers, models, and preferences
|
|
16
|
+
- ๐ **Secure**: Safe storage of API keys with proper file permissions (600)
|
|
17
|
+
- ๐ฏ **Conventional Commits**: Support for conventional commit format
|
|
18
|
+
- โก **Fast & Reliable**: Async processing with retry logic and error handling
|
|
19
|
+
- ๐จ **Beautiful CLI**: Colored output with progress indicators
|
|
20
|
+
- ๐ **Auto-Updates**: Built-in update notifications
|
|
21
|
+
- ๐งช **Well-Tested**: Comprehensive test suite with Jest
|
|
22
|
+
|
|
23
|
+
## ๐ Installation
|
|
24
|
+
|
|
25
|
+
Install globally via npm:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g orcommit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or use directly with npx:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx orcommit
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## ๐ Quick Start
|
|
38
|
+
|
|
39
|
+
1. **Set up your API key**:
|
|
40
|
+
```bash
|
|
41
|
+
orc config set openrouter your-api-key-here
|
|
42
|
+
# or for OpenAI
|
|
43
|
+
orc config set openai your-openai-key-here
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
2. **Stage your changes**:
|
|
47
|
+
```bash
|
|
48
|
+
git add .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
3. **Generate and create commit**:
|
|
52
|
+
```bash
|
|
53
|
+
orc commit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That's it! The tool will analyze your staged changes and generate an appropriate commit message.
|
|
57
|
+
|
|
58
|
+
## ๐ Commands
|
|
59
|
+
|
|
60
|
+
### `orc commit` (default)
|
|
61
|
+
Generate and create a commit message for staged changes.
|
|
62
|
+
|
|
63
|
+
**Options:**
|
|
64
|
+
- `-y, --yes` - Skip confirmation and auto-commit
|
|
65
|
+
- `-s, --scope <scope>` - Specify commit scope (e.g., auth, ui, api)
|
|
66
|
+
- `-t, --type <type>` - Specify commit type (feat, fix, docs, etc.)
|
|
67
|
+
- `-b, --breaking` - Mark as breaking change
|
|
68
|
+
- `-d, --dry-run` - Generate message without creating commit
|
|
69
|
+
- `-v, --verbose` - Enable verbose logging
|
|
70
|
+
- `-p, --provider <provider>` - Specify AI provider (openrouter|openai)
|
|
71
|
+
|
|
72
|
+
**Examples:**
|
|
73
|
+
```bash
|
|
74
|
+
# Basic usage
|
|
75
|
+
orc commit
|
|
76
|
+
|
|
77
|
+
# Auto-confirm with specific type and scope
|
|
78
|
+
orc commit --yes --type feat --scope auth
|
|
79
|
+
|
|
80
|
+
# Dry run to see generated message
|
|
81
|
+
orc commit --dry-run
|
|
82
|
+
|
|
83
|
+
# Use specific provider
|
|
84
|
+
orc commit --provider openai
|
|
85
|
+
|
|
86
|
+
# Breaking change
|
|
87
|
+
orc commit --breaking --type feat
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `orc config`
|
|
91
|
+
Manage configuration settings.
|
|
92
|
+
|
|
93
|
+
**Subcommands:**
|
|
94
|
+
```bash
|
|
95
|
+
# Set API key
|
|
96
|
+
orc config set openrouter sk-your-key-here
|
|
97
|
+
orc config set openai sk-your-openai-key
|
|
98
|
+
|
|
99
|
+
# Set default model
|
|
100
|
+
orc config model openrouter anthropic/claude-3-haiku:beta
|
|
101
|
+
orc config model openai gpt-4
|
|
102
|
+
|
|
103
|
+
# View configuration
|
|
104
|
+
orc config get
|
|
105
|
+
orc config get openrouter
|
|
106
|
+
|
|
107
|
+
# Show config file path
|
|
108
|
+
orc config path
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `orc test`
|
|
112
|
+
Test API connection for configured providers.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Test default provider
|
|
116
|
+
orc test
|
|
117
|
+
|
|
118
|
+
# Test specific provider
|
|
119
|
+
orc test openrouter
|
|
120
|
+
orc test openai
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## โ๏ธ Configuration
|
|
124
|
+
|
|
125
|
+
Configuration is stored in `~/.config/orcommit.json` with secure 600 permissions.
|
|
126
|
+
|
|
127
|
+
### Default Configuration
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"providers": {
|
|
132
|
+
"openrouter": {
|
|
133
|
+
"baseUrl": "https://openrouter.ai/api/v1",
|
|
134
|
+
"timeout": 60000
|
|
135
|
+
},
|
|
136
|
+
"openai": {
|
|
137
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
138
|
+
"timeout": 60000
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"preferences": {
|
|
142
|
+
"defaultProvider": "openrouter",
|
|
143
|
+
"maxTokens": 500,
|
|
144
|
+
"temperature": 0.6,
|
|
145
|
+
"autoConfirm": false,
|
|
146
|
+
"language": "en",
|
|
147
|
+
"commitFormat": "conventional"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Supported Commit Types
|
|
153
|
+
|
|
154
|
+
When using `--type` option, these conventional commit types are supported:
|
|
155
|
+
|
|
156
|
+
- `feat` - New features
|
|
157
|
+
- `fix` - Bug fixes
|
|
158
|
+
- `docs` - Documentation changes
|
|
159
|
+
- `style` - Code style changes (formatting, etc.)
|
|
160
|
+
- `refactor` - Code refactoring
|
|
161
|
+
- `test` - Adding or updating tests
|
|
162
|
+
- `chore` - Maintenance tasks
|
|
163
|
+
- `perf` - Performance improvements
|
|
164
|
+
- `ci` - CI/CD changes
|
|
165
|
+
- `build` - Build system changes
|
|
166
|
+
- `revert` - Reverting previous commits
|
|
167
|
+
|
|
168
|
+
## ๐ Architecture
|
|
169
|
+
|
|
170
|
+
The tool is built with a modular TypeScript architecture:
|
|
171
|
+
|
|
172
|
+
### Core Modules
|
|
173
|
+
|
|
174
|
+
- **CLI Module**: Command-line interface using Commander.js
|
|
175
|
+
- **Config Module**: Secure configuration management with file permissions
|
|
176
|
+
- **Git Module**: Git repository interaction and diff parsing
|
|
177
|
+
- **API Module**: HTTP client with retry logic and rate limiting
|
|
178
|
+
- **Logger Module**: Structured logging with progress indicators
|
|
179
|
+
- **Core Orchestrator**: Main coordination and business logic
|
|
180
|
+
|
|
181
|
+
### Key Features
|
|
182
|
+
|
|
183
|
+
- **Chunked Processing**: Large diffs are intelligently split while preserving context
|
|
184
|
+
- **Retry Logic**: Exponential backoff for API failures and rate limits
|
|
185
|
+
- **Error Handling**: Comprehensive error types with proper error propagation
|
|
186
|
+
- **Type Safety**: Full TypeScript coverage with strict type checking
|
|
187
|
+
- **Testing**: Jest-based test suite with mocking for external dependencies
|
|
188
|
+
|
|
189
|
+
## ๐ง Advanced Usage
|
|
190
|
+
|
|
191
|
+
### Environment Variables
|
|
192
|
+
|
|
193
|
+
You can set API keys via environment variables:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
export OPENROUTER_API_KEY="your-key-here"
|
|
197
|
+
export OPENAI_API_KEY="your-openai-key"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Large File Handling
|
|
201
|
+
|
|
202
|
+
The tool automatically chunks large diffs to stay within API token limits:
|
|
203
|
+
|
|
204
|
+
- Maximum chunk size: 8,000 characters
|
|
205
|
+
- Maximum concurrent requests: 3
|
|
206
|
+
- Context preservation: File and function boundaries respected
|
|
207
|
+
|
|
208
|
+
### Custom Models
|
|
209
|
+
|
|
210
|
+
Configure specific models for each provider:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# OpenRouter models
|
|
214
|
+
orc config model openrouter anthropic/claude-3-haiku:beta
|
|
215
|
+
orc config model openrouter openai/gpt-4-turbo-preview
|
|
216
|
+
|
|
217
|
+
# OpenAI models
|
|
218
|
+
orc config model openai gpt-4
|
|
219
|
+
orc config model openai gpt-3.5-turbo
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## ๐งช Development
|
|
223
|
+
|
|
224
|
+
### Setup
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
git clone <repository>
|
|
228
|
+
cd orcommit
|
|
229
|
+
npm install
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Available Scripts
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npm run build # Build TypeScript
|
|
236
|
+
npm run dev # Run in development mode
|
|
237
|
+
npm run test # Run tests
|
|
238
|
+
npm run test:watch # Run tests in watch mode
|
|
239
|
+
npm run lint # Run ESLint
|
|
240
|
+
npm run format # Format code with Prettier
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Testing
|
|
244
|
+
|
|
245
|
+
The project includes comprehensive tests:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Run all tests
|
|
249
|
+
npm test
|
|
250
|
+
|
|
251
|
+
# Run with coverage
|
|
252
|
+
npm run test:coverage
|
|
253
|
+
|
|
254
|
+
# Run specific test file
|
|
255
|
+
npm test -- utils.test.ts
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## ๐ Requirements
|
|
259
|
+
|
|
260
|
+
- Node.js >= 16.0.0
|
|
261
|
+
- Git repository
|
|
262
|
+
- OpenRouter or OpenAI API key
|
|
263
|
+
|
|
264
|
+
## ๐ Security
|
|
265
|
+
|
|
266
|
+
- API keys are stored with 600 file permissions (owner read/write only)
|
|
267
|
+
- No API keys are logged or exposed in error messages
|
|
268
|
+
- Secure HTTP client with proper timeout and retry handling
|
|
269
|
+
|
|
270
|
+
## ๐ Troubleshooting
|
|
271
|
+
|
|
272
|
+
### Common Issues
|
|
273
|
+
|
|
274
|
+
**"Not in a git repository"**
|
|
275
|
+
- Ensure you're running the command inside a Git repository
|
|
276
|
+
|
|
277
|
+
**"No staged changes found"**
|
|
278
|
+
- Use `git add` to stage files before generating commits
|
|
279
|
+
|
|
280
|
+
**"API key not configured"**
|
|
281
|
+
- Set your API key: `orc config set openrouter your-key`
|
|
282
|
+
|
|
283
|
+
**"Connection timeout"**
|
|
284
|
+
- Check your internet connection and API key validity
|
|
285
|
+
- Try with `--verbose` flag for detailed error information
|
|
286
|
+
|
|
287
|
+
### Debug Mode
|
|
288
|
+
|
|
289
|
+
Use verbose logging for detailed information:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
orc commit --verbose
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## ๐ License
|
|
296
|
+
|
|
297
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
298
|
+
|
|
299
|
+
## ๐ค Contributing
|
|
300
|
+
|
|
301
|
+
1. Fork the repository
|
|
302
|
+
2. Create a feature branch
|
|
303
|
+
3. Make your changes
|
|
304
|
+
4. Add tests
|
|
305
|
+
5. Submit a pull request
|
|
306
|
+
|
|
307
|
+
## ๐ Support
|
|
308
|
+
|
|
309
|
+
- GitHub Issues: [Report bugs or request features](https://github.com/markolofsen/openrouter-commit/issues)
|
|
310
|
+
- Documentation: [Additional guides and examples](./docs/)
|
|
311
|
+
|
|
312
|
+
## ๐ Acknowledgments
|
|
313
|
+
|
|
314
|
+
- [OpenRouter](https://openrouter.ai/) for providing access to multiple AI models
|
|
315
|
+
- [OpenAI](https://openai.com/) for their powerful language models
|
|
316
|
+
- The open-source community for the excellent tools and libraries used in this project
|
|
317
|
+
# Push functionality added
|
|
318
|
+
# Improved elegant UI
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Main CLI application
|
|
4
|
+
*/
|
|
5
|
+
declare class CliApplication {
|
|
6
|
+
private program;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Set up all CLI commands and options
|
|
10
|
+
*/
|
|
11
|
+
private setupCommands;
|
|
12
|
+
/**
|
|
13
|
+
* Handle the main commit command
|
|
14
|
+
*/
|
|
15
|
+
private handleCommitCommand;
|
|
16
|
+
/**
|
|
17
|
+
* Handle configuration set command
|
|
18
|
+
*/
|
|
19
|
+
private handleConfigSet;
|
|
20
|
+
/**
|
|
21
|
+
* Handle configuration get command
|
|
22
|
+
*/
|
|
23
|
+
private handleConfigGet;
|
|
24
|
+
/**
|
|
25
|
+
* Handle model configuration command
|
|
26
|
+
*/
|
|
27
|
+
private handleConfigModel;
|
|
28
|
+
/**
|
|
29
|
+
* Handle test command
|
|
30
|
+
*/
|
|
31
|
+
private handleTestCommand;
|
|
32
|
+
/**
|
|
33
|
+
* Handle watch mode
|
|
34
|
+
*/
|
|
35
|
+
private handleWatchMode;
|
|
36
|
+
/**
|
|
37
|
+
* Handle cache stats command
|
|
38
|
+
*/
|
|
39
|
+
private handleCacheStats;
|
|
40
|
+
/**
|
|
41
|
+
* Handle cache clear command
|
|
42
|
+
*/
|
|
43
|
+
private handleCacheClear;
|
|
44
|
+
/**
|
|
45
|
+
* Handle cache cleanup command
|
|
46
|
+
*/
|
|
47
|
+
private handleCacheCleanup;
|
|
48
|
+
/**
|
|
49
|
+
* Check for updates using update-notifier
|
|
50
|
+
*/
|
|
51
|
+
private checkForUpdates;
|
|
52
|
+
/**
|
|
53
|
+
* Validate commit type
|
|
54
|
+
*/
|
|
55
|
+
private validateCommitType;
|
|
56
|
+
/**
|
|
57
|
+
* Validate provider
|
|
58
|
+
*/
|
|
59
|
+
private validateProvider;
|
|
60
|
+
/**
|
|
61
|
+
* Check if provider is valid
|
|
62
|
+
*/
|
|
63
|
+
private isValidProvider;
|
|
64
|
+
/**
|
|
65
|
+
* Run the CLI application
|
|
66
|
+
*/
|
|
67
|
+
run(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export { CliApplication };
|
|
70
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAeA;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,OAAO,CAAU;;IAQzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAgIrB;;OAEG;YACW,mBAAmB;IAkBjC;;OAEG;YACW,eAAe;IAgB7B;;OAEG;YACW,eAAe;IA0C7B;;OAEG;YACW,iBAAiB;IAgB/B;;OAEG;YACW,iBAAiB;IA+B/B;;OAEG;YACW,eAAe;IAQ7B;;OAEG;YACW,gBAAgB;IAmB9B;;OAEG;YACW,gBAAgB;IAc9B;;OAEG;YACW,kBAAkB;IAchC;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB3B;AASD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|