ngpt 2.13.0__tar.gz → 2.14.0__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.0}/PKG-INFO +20 -1
- {ngpt-2.13.0 → ngpt-2.14.0}/README.md +19 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/api/cli.md +1 -0
- ngpt-2.14.0/docs/usage/gitcommsg.md +147 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/args.py +15 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/main.py +20 -10
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/__init__.py +2 -1
- ngpt-2.14.0/ngpt/cli/modes/gitcommsg.py +730 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/utils/cli_config.py +6 -0
- ngpt-2.14.0/ngpt/utils/log.py +479 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/pyproject.toml +1 -1
- {ngpt-2.13.0 → ngpt-2.14.0}/uv.lock +1 -1
- ngpt-2.13.0/ngpt/utils/log.py +0 -179
- {ngpt-2.13.0 → ngpt-2.14.0}/.github/workflows/python-publish.yml +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/.gitignore +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/.python-version +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/COMMIT_GUIDELINES.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/CONTRIBUTING.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/LICENSE +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/CONTRIBUTING.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/LICENSE.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/_config.yml +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/api/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/api/cli_config.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/api/client.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/api/config.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/assets/css/style.scss +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/configuration.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/examples/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/examples/advanced.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/examples/basic.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/examples/cli_components.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/examples/integrations.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/installation.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/overview.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/usage/README.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/usage/cli_config.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/usage/cli_framework.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/usage/cli_usage.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/docs/usage/library_usage.md +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/__main__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/config_manager.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/formatters.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/interactive.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/chat.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/code.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/rewrite.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/shell.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/modes/text.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/renderers.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/cli/ui.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/client.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/ngpt/utils/__init__.py +0 -0
- {ngpt-2.13.0 → ngpt-2.14.0}/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.0
|
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
|
|
@@ -0,0 +1,147 @@
|
|
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:
|
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
|
+
|
118
|
+
## Example Output
|
119
|
+
|
120
|
+
```
|
121
|
+
feat(auth): Add OAuth2 authentication flow
|
122
|
+
|
123
|
+
- [feat] Implement OAuth2 provider in auth/oauth.py:get_oauth_client()
|
124
|
+
- [feat] Add token validation in auth/utils.py:validate_token()
|
125
|
+
- [test] Add integration tests for OAuth flow in tests/auth/test_oauth.py
|
126
|
+
- [docs] Update authentication docs in README.md
|
127
|
+
```
|
128
|
+
|
129
|
+
The generated commit messages follow the conventional commit format with:
|
130
|
+
1. Type prefix (feat, fix, docs, etc.)
|
131
|
+
2. Optional scope in parentheses
|
132
|
+
3. Brief summary
|
133
|
+
4. Detailed bullet points with file and function references
|
134
|
+
|
135
|
+
## Requirements
|
136
|
+
|
137
|
+
- Git must be installed and available in your PATH
|
138
|
+
- You must be in a git repository
|
139
|
+
- For commit message generation, you need staged changes (`git add`)
|
140
|
+
|
141
|
+
## Error Handling
|
142
|
+
|
143
|
+
The command includes robust error handling:
|
144
|
+
- Checks if in a git repository
|
145
|
+
- Verifies staged changes exist
|
146
|
+
- Includes automatic retries with exponential backoff for API failures
|
147
|
+
- 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',
|
98
|
+
help='Use diff from specified file instead of staged changes')
|
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():
|
@@ -227,15 +228,17 @@ def main():
|
|
227
228
|
# Change log to True to create a temp file
|
228
229
|
args.log = True
|
229
230
|
|
230
|
-
#
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
logger
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
231
|
+
# Skip logger initialization for gitcommsg mode as it creates its own logger
|
232
|
+
if not args.gitcommsg:
|
233
|
+
# If --log is True, it means it was used without a path value
|
234
|
+
log_path = None if args.log is True else args.log
|
235
|
+
logger = create_logger(log_path)
|
236
|
+
if logger:
|
237
|
+
logger.open()
|
238
|
+
print(f"{COLORS['green']}Logging session to: {logger.get_log_path()}{COLORS['reset']}")
|
239
|
+
# If it's a temporary log file, inform the user
|
240
|
+
if logger.is_temporary():
|
241
|
+
print(f"{COLORS['green']}Created temporary log file.{COLORS['reset']}")
|
239
242
|
|
240
243
|
# Priority order for config selection:
|
241
244
|
# 1. Command-line arguments (args.provider, args.config_index)
|
@@ -461,7 +464,7 @@ def main():
|
|
461
464
|
return
|
462
465
|
|
463
466
|
# 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):
|
467
|
+
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
468
|
# Simply use the parser's help
|
466
469
|
parser = setup_argument_parser()
|
467
470
|
parser.print_help()
|
@@ -557,6 +560,13 @@ def main():
|
|
557
560
|
# Rewrite mode (process stdin)
|
558
561
|
rewrite_mode(client, args, logger=logger)
|
559
562
|
|
563
|
+
elif args.gitcommsg:
|
564
|
+
# Apply CLI config for gitcommsg mode
|
565
|
+
args = apply_cli_config(args, "all")
|
566
|
+
|
567
|
+
# Git commit message generation mode
|
568
|
+
gitcommsg_mode(client, args, logger=logger)
|
569
|
+
|
560
570
|
else:
|
561
571
|
# Default to chat mode
|
562
572
|
# 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']
|