ngpt 2.13.0__tar.gz → 2.14.1__tar.gz
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.
- {ngpt-2.13.0 → ngpt-2.14.1}/.gitignore +2 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/PKG-INFO +20 -1
- {ngpt-2.13.0 → ngpt-2.14.1}/README.md +19 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/api/cli.md +1 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/usage/cli_config.md +81 -0
- ngpt-2.14.1/docs/usage/gitcommsg.md +255 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/args.py +15 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/main.py +26 -12
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/__init__.py +2 -1
- ngpt-2.14.1/ngpt/cli/modes/gitcommsg.py +758 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/utils/cli_config.py +6 -0
- ngpt-2.14.1/ngpt/utils/log.py +479 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/pyproject.toml +1 -1
- {ngpt-2.13.0 → ngpt-2.14.1}/uv.lock +1 -1
- ngpt-2.13.0/ngpt/utils/log.py +0 -179
- {ngpt-2.13.0 → ngpt-2.14.1}/.github/workflows/python-publish.yml +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/.python-version +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/COMMIT_GUIDELINES.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/CONTRIBUTING.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/LICENSE +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/CONTRIBUTING.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/LICENSE.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/_config.yml +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/api/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/api/cli_config.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/api/client.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/api/config.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/assets/css/style.scss +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/configuration.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/examples/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/examples/advanced.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/examples/basic.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/examples/cli_components.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/examples/integrations.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/installation.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/overview.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/usage/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/usage/cli_framework.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/usage/cli_usage.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/docs/usage/library_usage.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/__main__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/config_manager.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/formatters.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/interactive.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/chat.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/code.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/rewrite.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/shell.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/modes/text.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/renderers.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/cli/ui.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/client.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/utils/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.1}/ngpt/utils/config.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.14.1
|
4
4
|
Summary: A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
|
5
5
|
Project-URL: Homepage, https://github.com/nazdridoy/ngpt
|
6
6
|
Project-URL: Repository, https://github.com/nazdridoy/ngpt
|
@@ -110,6 +110,24 @@ echo "your text" | ngpt --rewrite
|
|
110
110
|
# Rewrite text from a command-line argument
|
111
111
|
ngpt --rewrite "your text to rewrite"
|
112
112
|
|
113
|
+
# Rewrite text from a file
|
114
|
+
cat file.txt | ngpt --rewrite
|
115
|
+
|
116
|
+
# Generate AI-powered git commit messages for staged changes
|
117
|
+
ngpt --gitcommsg
|
118
|
+
|
119
|
+
# Generate commit message with context
|
120
|
+
ngpt --gitcommsg -m "type:feat"
|
121
|
+
|
122
|
+
# Process large diffs in chunks with recursive analysis
|
123
|
+
ngpt --gitcommsg -r
|
124
|
+
|
125
|
+
# Process a diff file instead of staged changes
|
126
|
+
ngpt --gitcommsg --diff /path/to/changes.diff
|
127
|
+
|
128
|
+
# Generate a commit message with logging for debugging
|
129
|
+
ngpt --gitcommsg --log commit_log.txt
|
130
|
+
|
113
131
|
# Use interactive multiline editor to enter text to rewrite
|
114
132
|
ngpt --rewrite
|
115
133
|
|
@@ -156,6 +174,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
|
|
156
174
|
- 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
|
157
175
|
- 🧩 **Clean Code Generation**: Output code without markdown or explanations
|
158
176
|
- 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
|
177
|
+
- 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
|
159
178
|
- 🎭 **System Prompts**: Customize model behavior with custom system prompts
|
160
179
|
- 📃 **Conversation Logging**: Save your conversations to text files for later reference
|
161
180
|
- 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
|
@@ -74,6 +74,24 @@ echo "your text" | ngpt --rewrite
|
|
74
74
|
# Rewrite text from a command-line argument
|
75
75
|
ngpt --rewrite "your text to rewrite"
|
76
76
|
|
77
|
+
# Rewrite text from a file
|
78
|
+
cat file.txt | ngpt --rewrite
|
79
|
+
|
80
|
+
# Generate AI-powered git commit messages for staged changes
|
81
|
+
ngpt --gitcommsg
|
82
|
+
|
83
|
+
# Generate commit message with context
|
84
|
+
ngpt --gitcommsg -m "type:feat"
|
85
|
+
|
86
|
+
# Process large diffs in chunks with recursive analysis
|
87
|
+
ngpt --gitcommsg -r
|
88
|
+
|
89
|
+
# Process a diff file instead of staged changes
|
90
|
+
ngpt --gitcommsg --diff /path/to/changes.diff
|
91
|
+
|
92
|
+
# Generate a commit message with logging for debugging
|
93
|
+
ngpt --gitcommsg --log commit_log.txt
|
94
|
+
|
77
95
|
# Use interactive multiline editor to enter text to rewrite
|
78
96
|
ngpt --rewrite
|
79
97
|
|
@@ -120,6 +138,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
|
|
120
138
|
- 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
|
121
139
|
- 🧩 **Clean Code Generation**: Output code without markdown or explanations
|
122
140
|
- 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
|
141
|
+
- 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
|
123
142
|
- 🎭 **System Prompts**: Customize model behavior with custom system prompts
|
124
143
|
- 📃 **Conversation Logging**: Save your conversations to text files for later reference
|
125
144
|
- 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
|
@@ -21,6 +21,7 @@ The CLI components for nGPT are organized into a modular structure under the `ng
|
|
21
21
|
- `ngpt.cli.modes.code`: Code generation mode functionality
|
22
22
|
- `ngpt.cli.modes.shell`: Shell command generation mode functionality
|
23
23
|
- `ngpt.cli.modes.text`: Text generation mode functionality
|
24
|
+
- `ngpt.cli.modes.rewrite`: Text rewriting mode functionality
|
24
25
|
|
25
26
|
## Interactive Chat Module
|
26
27
|
|
@@ -66,9 +66,81 @@ These options are mutually exclusive:
|
|
66
66
|
|
67
67
|
Some options only apply in specific modes:
|
68
68
|
|
69
|
+
#### Code Mode Options
|
69
70
|
- `language` - Programming language for code generation (only for code mode)
|
71
|
+
|
72
|
+
#### Logging Options
|
70
73
|
- `log` - Filepath to log conversation (for interactive and text modes)
|
71
74
|
|
75
|
+
#### Git Commit Message Mode Options
|
76
|
+
- `message-context` - Context to guide AI generation (e.g., file types, commit type directive)
|
77
|
+
- `recursive-chunk` - Process large diffs in chunks with recursive analysis if needed (default: false)
|
78
|
+
- `diff` - Path to diff file to use instead of staged git changes
|
79
|
+
- `chunk-size` - Number of lines per chunk when chunking is enabled (default: 200)
|
80
|
+
- `max-depth` - Maximum recursion depth for recursive chunking (default: 3)
|
81
|
+
|
82
|
+
### Git Commit Message Options Details
|
83
|
+
|
84
|
+
These options control the behavior of the `--gitcommsg` mode, which helps generate conventional commit messages from git diffs.
|
85
|
+
|
86
|
+
#### message-context
|
87
|
+
This option provides contextual information to guide the AI when generating commit messages. It accepts various directives:
|
88
|
+
|
89
|
+
```bash
|
90
|
+
# Set a default context for commit message generation
|
91
|
+
ngpt --cli-config set message-context "type:feat focus on UI"
|
92
|
+
```
|
93
|
+
|
94
|
+
The context can include:
|
95
|
+
- **Commit type directives**: `type:feat`, `type:fix`, `type:docs`, etc.
|
96
|
+
- **File type filtering**: `javascript`, `python`, `css`, etc.
|
97
|
+
- **Focus directives**: `focus on auth`, `focus on UI`, etc.
|
98
|
+
- **Exclusion directives**: `ignore formatting`, `exclude tests`, etc.
|
99
|
+
|
100
|
+
#### recursive-chunk
|
101
|
+
When set to `true`, this enables recursive chunking for processing large diffs, which is helpful for large commits:
|
102
|
+
|
103
|
+
```bash
|
104
|
+
# Enable recursive chunking by default
|
105
|
+
ngpt --cli-config set recursive-chunk true
|
106
|
+
```
|
107
|
+
|
108
|
+
With recursive chunking enabled, the system will:
|
109
|
+
1. Split large diffs into chunks
|
110
|
+
2. Process each chunk separately
|
111
|
+
3. Further break down large intermediate results if needed
|
112
|
+
4. Combine everything into a final commit message
|
113
|
+
|
114
|
+
#### diff
|
115
|
+
This specifies a default path to a diff file. When using the `--gitcommsg` command with `--diff` (without specifying a file), it will use this configured path:
|
116
|
+
|
117
|
+
```bash
|
118
|
+
# Set a default diff file path
|
119
|
+
ngpt --cli-config set diff /path/to/changes.diff
|
120
|
+
```
|
121
|
+
|
122
|
+
**Important Note**: The diff file from CLI config is only used when you explicitly provide the `--diff` flag without a specific path. If you don't include the `--diff` flag, the system will always use git staged changes regardless of this setting.
|
123
|
+
|
124
|
+
#### chunk-size
|
125
|
+
Controls how many lines of diff are processed in each chunk when chunking is enabled:
|
126
|
+
|
127
|
+
```bash
|
128
|
+
# Set a larger chunk size (default is 200)
|
129
|
+
ngpt --cli-config set chunk-size 300
|
130
|
+
```
|
131
|
+
|
132
|
+
Larger chunk sizes can provide more context but may hit token limits with some models. Smaller chunk sizes are better for very large commits but may lose some context between chunks.
|
133
|
+
|
134
|
+
#### max-depth
|
135
|
+
Sets the maximum recursion depth for recursive chunking:
|
136
|
+
|
137
|
+
```bash
|
138
|
+
# Increase max recursion depth (default is 3)
|
139
|
+
ngpt --cli-config set max-depth 5
|
140
|
+
```
|
141
|
+
|
142
|
+
Higher values allow processing of extremely large diffs but may take longer.
|
143
|
+
|
72
144
|
### Context-Aware Application
|
73
145
|
|
74
146
|
Each option configured via `--cli-config` is only applied if it's relevant to the current execution mode and if it wasn't already specified as a command-line argument.
|
@@ -140,6 +212,15 @@ ngpt --cli-config set prettify true
|
|
140
212
|
|
141
213
|
# Set default provider to use
|
142
214
|
ngpt --cli-config set provider Gemini
|
215
|
+
|
216
|
+
# Enable recursive chunking for git commit messages by default
|
217
|
+
ngpt --cli-config set recursive-chunk true
|
218
|
+
|
219
|
+
# Set a default diff file path for git commit messages
|
220
|
+
ngpt --cli-config set diff /path/to/changes.diff
|
221
|
+
|
222
|
+
# Set a larger chunk size for git commit message processing
|
223
|
+
ngpt --cli-config set chunk-size 300
|
143
224
|
```
|
144
225
|
|
145
226
|
### Using CLI Configuration
|
@@ -0,0 +1,255 @@
|
|
1
|
+
# Git Commit Message Generation
|
2
|
+
|
3
|
+
The `--gitcommsg` mode in NGPT helps you generate high-quality, conventional commit messages using AI to analyze your git diffs.
|
4
|
+
|
5
|
+
## Basic Usage
|
6
|
+
|
7
|
+
```bash
|
8
|
+
# Generate commit message from staged changes
|
9
|
+
ngpt --gitcommsg
|
10
|
+
|
11
|
+
# Generate commit message with context/directives
|
12
|
+
ngpt --gitcommsg -m "type:feat"
|
13
|
+
|
14
|
+
# Process large diffs in chunks with recursive analysis
|
15
|
+
ngpt --gitcommsg -r
|
16
|
+
|
17
|
+
# Use a diff file instead of staged changes
|
18
|
+
ngpt --gitcommsg --diff /path/to/changes.diff
|
19
|
+
|
20
|
+
# Enable logging for debugging
|
21
|
+
ngpt --gitcommsg --log
|
22
|
+
```
|
23
|
+
|
24
|
+
## Command Line Options
|
25
|
+
|
26
|
+
| Option | Description |
|
27
|
+
|--------|-------------|
|
28
|
+
| `-m, --message-context` | Context to guide AI (file types, commit type directive, focus) |
|
29
|
+
| `-r, --recursive-chunk` | Process large diffs in chunks with recursive analysis if needed |
|
30
|
+
| `--diff FILE` | Use diff from specified file instead of staged changes |
|
31
|
+
| `--log [FILE]` | Enable detailed logging (to specified file or auto-generated temp file) |
|
32
|
+
| `--chunk-size NUM` | Set number of lines per chunk (default: 200) |
|
33
|
+
| `--max-depth NUM` | Maximum recursion depth for recursive chunking (default: 3) |
|
34
|
+
|
35
|
+
## Context Directives
|
36
|
+
|
37
|
+
The `-m/--message-context` option is powerful and supports several directive types:
|
38
|
+
|
39
|
+
### Commit Type Directive
|
40
|
+
|
41
|
+
Force a specific commit type prefix:
|
42
|
+
|
43
|
+
```bash
|
44
|
+
# Force "feat:" prefix
|
45
|
+
ngpt --gitcommsg -m "type:feat"
|
46
|
+
|
47
|
+
# Force "fix:" prefix
|
48
|
+
ngpt --gitcommsg -m "type:fix"
|
49
|
+
|
50
|
+
# Force "docs:" prefix
|
51
|
+
ngpt --gitcommsg -m "type:docs"
|
52
|
+
```
|
53
|
+
|
54
|
+
### File Type Filtering
|
55
|
+
|
56
|
+
Focus only on specific file types:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
# Focus only on JavaScript changes
|
60
|
+
ngpt --gitcommsg -m "javascript"
|
61
|
+
|
62
|
+
# Focus only on CSS files
|
63
|
+
ngpt --gitcommsg -m "css"
|
64
|
+
|
65
|
+
# Focus only on Python files
|
66
|
+
ngpt --gitcommsg -m "python"
|
67
|
+
```
|
68
|
+
|
69
|
+
### Focus/Exclusion Directives
|
70
|
+
|
71
|
+
Control what to include or exclude:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
# Focus only on authentication-related changes
|
75
|
+
ngpt --gitcommsg -m "focus on auth"
|
76
|
+
|
77
|
+
# Ignore formatting changes
|
78
|
+
ngpt --gitcommsg -m "ignore formatting"
|
79
|
+
|
80
|
+
# Exclude test files from the summary
|
81
|
+
ngpt --gitcommsg -m "exclude tests"
|
82
|
+
```
|
83
|
+
|
84
|
+
### Combined Directives
|
85
|
+
|
86
|
+
You can combine multiple directives:
|
87
|
+
|
88
|
+
```bash
|
89
|
+
# Force "feat:" prefix and focus only on UI changes
|
90
|
+
ngpt --gitcommsg -m "type:feat focus on UI"
|
91
|
+
|
92
|
+
# Force "fix:" prefix and ignore formatting changes
|
93
|
+
ngpt --gitcommsg -m "type:fix ignore formatting"
|
94
|
+
```
|
95
|
+
|
96
|
+
## Chunking Mechanism
|
97
|
+
|
98
|
+
When processing large diffs with `-r/--recursive-chunk`, the chunking mechanism helps manage rate limits and token limits:
|
99
|
+
|
100
|
+
1. Diffs are split into 200-line chunks and processed separately
|
101
|
+
2. The partial analyses are then combined into a final commit message
|
102
|
+
3. If the combined analysis is still too large, it's recursively processed again
|
103
|
+
|
104
|
+
This is particularly useful for large pull requests or commits with many changes.
|
105
|
+
|
106
|
+
## CLI Configuration
|
107
|
+
|
108
|
+
You can set default values for gitcommsg options using the CLI configuration system:
|
109
|
+
|
110
|
+
```bash
|
111
|
+
# Set default chunk size
|
112
|
+
ngpt --cli-config set chunk-size 150
|
113
|
+
|
114
|
+
# Enable recursive chunking by default
|
115
|
+
ngpt --cli-config set recursive-chunk true
|
116
|
+
|
117
|
+
# Set a default diff file path (used with --diff flag)
|
118
|
+
ngpt --cli-config set diff /path/to/your/changes.diff
|
119
|
+
|
120
|
+
# Set maximum recursion depth
|
121
|
+
ngpt --cli-config set max-depth 5
|
122
|
+
|
123
|
+
# Set a context directive to always apply
|
124
|
+
ngpt --cli-config set message-context "type:feat"
|
125
|
+
```
|
126
|
+
|
127
|
+
### Available CLI Configuration Options
|
128
|
+
|
129
|
+
| Option | Type | Default | Description |
|
130
|
+
|--------|------|---------|-------------|
|
131
|
+
| `recursive-chunk` | bool | false | Process large diffs in chunks with recursive analysis |
|
132
|
+
| `diff` | string | null | Path to diff file to use instead of staged changes |
|
133
|
+
| `chunk-size` | int | 200 | Number of lines per chunk when chunking is enabled |
|
134
|
+
| `max-depth` | int | 3 | Maximum recursion depth for recursive chunking |
|
135
|
+
| `message-context` | string | null | Context to guide AI generation |
|
136
|
+
|
137
|
+
### Option Details
|
138
|
+
|
139
|
+
#### recursive-chunk
|
140
|
+
|
141
|
+
When enabled, this option automatically processes large diffs in chunks and then combines the results:
|
142
|
+
|
143
|
+
```bash
|
144
|
+
# Enable recursive chunking by default
|
145
|
+
ngpt --cli-config set recursive-chunk true
|
146
|
+
```
|
147
|
+
|
148
|
+
This is particularly useful for large commits or codebases, as it helps:
|
149
|
+
- Avoid token limits with large diffs
|
150
|
+
- Handle rate limiting better by breaking requests into smaller pieces
|
151
|
+
- Process very large changes that would otherwise fail
|
152
|
+
|
153
|
+
#### chunk-size
|
154
|
+
|
155
|
+
Controls how many lines of diff are processed in each chunk:
|
156
|
+
|
157
|
+
```bash
|
158
|
+
# Set a custom chunk size (smaller chunks for very large diffs)
|
159
|
+
ngpt --cli-config set chunk-size 150
|
160
|
+
|
161
|
+
# Or larger chunks for more context
|
162
|
+
ngpt --cli-config set chunk-size 300
|
163
|
+
```
|
164
|
+
|
165
|
+
Smaller chunks (100-150 lines) work better for very large diffs or models with stricter token limits, while larger chunks (300-500 lines) provide more context but may hit token limits.
|
166
|
+
|
167
|
+
#### max-depth
|
168
|
+
|
169
|
+
Sets how many recursive analysis levels are allowed when using recursive chunking:
|
170
|
+
|
171
|
+
```bash
|
172
|
+
# Increase max recursion depth for extremely large diffs
|
173
|
+
ngpt --cli-config set max-depth 5
|
174
|
+
```
|
175
|
+
|
176
|
+
Higher values allow processing larger diffs but may increase processing time.
|
177
|
+
|
178
|
+
#### message-context
|
179
|
+
|
180
|
+
Provides contextual guidance for the AI when generating commit messages:
|
181
|
+
|
182
|
+
```bash
|
183
|
+
# Always focus on a specific aspect
|
184
|
+
ngpt --cli-config set message-context "focus on API changes"
|
185
|
+
|
186
|
+
# Always use a specific commit type
|
187
|
+
ngpt --cli-config set message-context "type:feat"
|
188
|
+
|
189
|
+
# Combined directives
|
190
|
+
ngpt --cli-config set message-context "type:fix exclude tests"
|
191
|
+
```
|
192
|
+
|
193
|
+
This is useful when you consistently work on the same type of changes and want to standardize your commit messages.
|
194
|
+
|
195
|
+
### Using the Diff File Option
|
196
|
+
|
197
|
+
When you've set a default diff file using the CLI config:
|
198
|
+
|
199
|
+
```bash
|
200
|
+
# Set a default diff file
|
201
|
+
ngpt --cli-config set diff /path/to/changes.diff
|
202
|
+
```
|
203
|
+
|
204
|
+
The diff file from CLI config is only used when you specifically request it with the `--diff` flag without providing a path. You have three ways to control which diff is used:
|
205
|
+
|
206
|
+
1. **Use git staged changes** (ignore the CLI config diff):
|
207
|
+
```bash
|
208
|
+
ngpt --gitcommsg
|
209
|
+
```
|
210
|
+
This will always use git staged changes regardless of your CLI config.
|
211
|
+
|
212
|
+
2. **Use the CLI config diff file**:
|
213
|
+
```bash
|
214
|
+
ngpt --gitcommsg --diff
|
215
|
+
```
|
216
|
+
This explicitly tells ngpt to use the diff file specified in your CLI config.
|
217
|
+
|
218
|
+
3. **Use a specific diff file** (override CLI config):
|
219
|
+
```bash
|
220
|
+
ngpt --gitcommsg --diff /path/to/another.diff
|
221
|
+
```
|
222
|
+
This overrides both git staged changes and your CLI config to use the specified file.
|
223
|
+
|
224
|
+
This approach gives you flexibility with a default diff file while maintaining explicit control over when it's used.
|
225
|
+
|
226
|
+
## Example Output
|
227
|
+
|
228
|
+
```
|
229
|
+
feat(auth): Add OAuth2 authentication flow
|
230
|
+
|
231
|
+
- [feat] Implement OAuth2 provider in auth/oauth.py:get_oauth_client()
|
232
|
+
- [feat] Add token validation in auth/utils.py:validate_token()
|
233
|
+
- [test] Add integration tests for OAuth flow in tests/auth/test_oauth.py
|
234
|
+
- [docs] Update authentication docs in README.md
|
235
|
+
```
|
236
|
+
|
237
|
+
The generated commit messages follow the conventional commit format with:
|
238
|
+
1. Type prefix (feat, fix, docs, etc.)
|
239
|
+
2. Optional scope in parentheses
|
240
|
+
3. Brief summary
|
241
|
+
4. Detailed bullet points with file and function references
|
242
|
+
|
243
|
+
## Requirements
|
244
|
+
|
245
|
+
- Git must be installed and available in your PATH
|
246
|
+
- You must be in a git repository
|
247
|
+
- For commit message generation, you need staged changes (`git add`)
|
248
|
+
|
249
|
+
## Error Handling
|
250
|
+
|
251
|
+
The command includes robust error handling:
|
252
|
+
- Checks if in a git repository
|
253
|
+
- Verifies staged changes exist
|
254
|
+
- Includes automatic retries with exponential backoff for API failures
|
255
|
+
- Provides detailed logs when `--log` is enabled
|
@@ -88,6 +88,19 @@ def setup_argument_parser():
|
|
88
88
|
global_group.add_argument('--renderer', choices=['auto', 'rich', 'glow'], default='auto',
|
89
89
|
help='Select which markdown renderer to use with --prettify (auto, rich, or glow)')
|
90
90
|
|
91
|
+
# GitCommit message options
|
92
|
+
gitcommsg_group = parser.add_argument_group('Git Commit Message Options')
|
93
|
+
gitcommsg_group.add_argument('-m', '--message-context',
|
94
|
+
help='Context to guide AI generation (e.g., file types, commit type)')
|
95
|
+
gitcommsg_group.add_argument('-r', '--recursive-chunk', action='store_true',
|
96
|
+
help='Process large diffs in chunks with recursive analysis if needed')
|
97
|
+
gitcommsg_group.add_argument('--diff', metavar='FILE', nargs='?', const=True,
|
98
|
+
help='Use diff from specified file instead of staged changes. If used without a path, uses the path from CLI config.')
|
99
|
+
gitcommsg_group.add_argument('--chunk-size', type=int, default=200,
|
100
|
+
help='Number of lines per chunk when chunking is enabled (default: 200)')
|
101
|
+
gitcommsg_group.add_argument('--max-depth', type=int, default=3,
|
102
|
+
help='Maximum recursion depth for recursive chunking (default: 3)')
|
103
|
+
|
91
104
|
# Mode flags (mutually exclusive)
|
92
105
|
mode_group = parser.add_argument_group('Modes (mutually exclusive)')
|
93
106
|
mode_exclusive_group = mode_group.add_mutually_exclusive_group()
|
@@ -103,6 +116,8 @@ def setup_argument_parser():
|
|
103
116
|
help='Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content')
|
104
117
|
mode_exclusive_group.add_argument('--rewrite', action='store_true',
|
105
118
|
help='Rewrite text from stdin to be more natural while preserving tone and meaning')
|
119
|
+
mode_exclusive_group.add_argument('--gitcommsg', action='store_true',
|
120
|
+
help='Generate AI-powered git commit messages from staged changes or diff file')
|
106
121
|
|
107
122
|
return parser
|
108
123
|
|
@@ -24,6 +24,7 @@ from .modes.code import code_mode
|
|
24
24
|
from .modes.shell import shell_mode
|
25
25
|
from .modes.text import text_mode
|
26
26
|
from .modes.rewrite import rewrite_mode
|
27
|
+
from .modes.gitcommsg import gitcommsg_mode
|
27
28
|
from .args import parse_args, validate_args, handle_cli_config_args, setup_argument_parser, validate_markdown_renderer
|
28
29
|
|
29
30
|
def show_cli_config_help():
|
@@ -45,7 +46,8 @@ def show_cli_config_help():
|
|
45
46
|
"code": [],
|
46
47
|
"interactive": [],
|
47
48
|
"text": [],
|
48
|
-
"shell": []
|
49
|
+
"shell": [],
|
50
|
+
"gitcommsg": [] # Add gitcommsg context
|
49
51
|
}
|
50
52
|
|
51
53
|
for option, meta in CLI_CONFIG_OPTIONS.items():
|
@@ -70,7 +72,8 @@ def show_cli_config_help():
|
|
70
72
|
("code", "Code generation mode"),
|
71
73
|
("interactive", "Interactive mode"),
|
72
74
|
("text", "Text mode"),
|
73
|
-
("shell", "Shell mode")
|
75
|
+
("shell", "Shell mode"),
|
76
|
+
("gitcommsg", "Git commit message mode") # Add gitcommsg mode
|
74
77
|
]:
|
75
78
|
if context_groups[mode]:
|
76
79
|
print(f"\n {COLORS['yellow']}Options for {options}:{COLORS['reset']}")
|
@@ -87,6 +90,8 @@ def show_cli_config_help():
|
|
87
90
|
print(f" {COLORS['yellow']}ngpt --cli-config set language java{COLORS['reset']} - Set default language to java for code generation")
|
88
91
|
print(f" {COLORS['yellow']}ngpt --cli-config set temperature 0.9{COLORS['reset']} - Set default temperature to 0.9")
|
89
92
|
print(f" {COLORS['yellow']}ngpt --cli-config set no-stream true{COLORS['reset']} - Disable streaming by default")
|
93
|
+
print(f" {COLORS['yellow']}ngpt --cli-config set recursive-chunk true{COLORS['reset']} - Enable recursive chunking for git commit messages")
|
94
|
+
print(f" {COLORS['yellow']}ngpt --cli-config set diff /path/to/file.diff{COLORS['reset']} - Set default diff file for git commit messages")
|
90
95
|
print(f" {COLORS['yellow']}ngpt --cli-config get temperature{COLORS['reset']} - Check the current temperature setting")
|
91
96
|
print(f" {COLORS['yellow']}ngpt --cli-config get{COLORS['reset']} - Show all current CLI settings")
|
92
97
|
print(f" {COLORS['yellow']}ngpt --cli-config unset language{COLORS['reset']} - Remove language setting")
|
@@ -227,15 +232,17 @@ def main():
|
|
227
232
|
# Change log to True to create a temp file
|
228
233
|
args.log = True
|
229
234
|
|
230
|
-
#
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
logger
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
235
|
+
# Skip logger initialization for gitcommsg mode as it creates its own logger
|
236
|
+
if not args.gitcommsg:
|
237
|
+
# If --log is True, it means it was used without a path value
|
238
|
+
log_path = None if args.log is True else args.log
|
239
|
+
logger = create_logger(log_path)
|
240
|
+
if logger:
|
241
|
+
logger.open()
|
242
|
+
print(f"{COLORS['green']}Logging session to: {logger.get_log_path()}{COLORS['reset']}")
|
243
|
+
# If it's a temporary log file, inform the user
|
244
|
+
if logger.is_temporary():
|
245
|
+
print(f"{COLORS['green']}Created temporary log file.{COLORS['reset']}")
|
239
246
|
|
240
247
|
# Priority order for config selection:
|
241
248
|
# 1. Command-line arguments (args.provider, args.config_index)
|
@@ -461,7 +468,7 @@ def main():
|
|
461
468
|
return
|
462
469
|
|
463
470
|
# For interactive mode, we'll allow continuing without a specific prompt
|
464
|
-
if not args.prompt and not (args.shell or args.code or args.text or args.interactive or args.show_config or args.list_models or args.rewrite):
|
471
|
+
if not args.prompt and not (args.shell or args.code or args.text or args.interactive or args.show_config or args.list_models or args.rewrite or args.gitcommsg):
|
465
472
|
# Simply use the parser's help
|
466
473
|
parser = setup_argument_parser()
|
467
474
|
parser.print_help()
|
@@ -557,6 +564,13 @@ def main():
|
|
557
564
|
# Rewrite mode (process stdin)
|
558
565
|
rewrite_mode(client, args, logger=logger)
|
559
566
|
|
567
|
+
elif args.gitcommsg:
|
568
|
+
# Apply CLI config for gitcommsg mode
|
569
|
+
args = apply_cli_config(args, "gitcommsg")
|
570
|
+
|
571
|
+
# Git commit message generation mode
|
572
|
+
gitcommsg_mode(client, args, logger=logger)
|
573
|
+
|
560
574
|
else:
|
561
575
|
# Default to chat mode
|
562
576
|
# Apply CLI config for default chat mode
|
@@ -3,5 +3,6 @@ from .code import code_mode
|
|
3
3
|
from .shell import shell_mode
|
4
4
|
from .text import text_mode
|
5
5
|
from .rewrite import rewrite_mode
|
6
|
+
from .gitcommsg import gitcommsg_mode
|
6
7
|
|
7
|
-
__all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode', 'rewrite_mode']
|
8
|
+
__all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode', 'rewrite_mode', 'gitcommsg_mode']
|