ngpt 2.14.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.
Files changed (56) hide show
  1. {ngpt-2.14.0 → ngpt-2.14.1}/.gitignore +2 -0
  2. {ngpt-2.14.0 → ngpt-2.14.1}/PKG-INFO +1 -1
  3. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/cli_config.md +81 -0
  4. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/gitcommsg.md +109 -1
  5. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/args.py +2 -2
  6. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/main.py +7 -3
  7. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/gitcommsg.py +29 -1
  8. {ngpt-2.14.0 → ngpt-2.14.1}/pyproject.toml +1 -1
  9. {ngpt-2.14.0 → ngpt-2.14.1}/uv.lock +1 -1
  10. {ngpt-2.14.0 → ngpt-2.14.1}/.github/workflows/python-publish.yml +0 -0
  11. {ngpt-2.14.0 → ngpt-2.14.1}/.python-version +0 -0
  12. {ngpt-2.14.0 → ngpt-2.14.1}/COMMIT_GUIDELINES.md +0 -0
  13. {ngpt-2.14.0 → ngpt-2.14.1}/CONTRIBUTING.md +0 -0
  14. {ngpt-2.14.0 → ngpt-2.14.1}/LICENSE +0 -0
  15. {ngpt-2.14.0 → ngpt-2.14.1}/README.md +0 -0
  16. {ngpt-2.14.0 → ngpt-2.14.1}/docs/CONTRIBUTING.md +0 -0
  17. {ngpt-2.14.0 → ngpt-2.14.1}/docs/LICENSE.md +0 -0
  18. {ngpt-2.14.0 → ngpt-2.14.1}/docs/README.md +0 -0
  19. {ngpt-2.14.0 → ngpt-2.14.1}/docs/_config.yml +0 -0
  20. {ngpt-2.14.0 → ngpt-2.14.1}/docs/api/README.md +0 -0
  21. {ngpt-2.14.0 → ngpt-2.14.1}/docs/api/cli.md +0 -0
  22. {ngpt-2.14.0 → ngpt-2.14.1}/docs/api/cli_config.md +0 -0
  23. {ngpt-2.14.0 → ngpt-2.14.1}/docs/api/client.md +0 -0
  24. {ngpt-2.14.0 → ngpt-2.14.1}/docs/api/config.md +0 -0
  25. {ngpt-2.14.0 → ngpt-2.14.1}/docs/assets/css/style.scss +0 -0
  26. {ngpt-2.14.0 → ngpt-2.14.1}/docs/configuration.md +0 -0
  27. {ngpt-2.14.0 → ngpt-2.14.1}/docs/examples/README.md +0 -0
  28. {ngpt-2.14.0 → ngpt-2.14.1}/docs/examples/advanced.md +0 -0
  29. {ngpt-2.14.0 → ngpt-2.14.1}/docs/examples/basic.md +0 -0
  30. {ngpt-2.14.0 → ngpt-2.14.1}/docs/examples/cli_components.md +0 -0
  31. {ngpt-2.14.0 → ngpt-2.14.1}/docs/examples/integrations.md +0 -0
  32. {ngpt-2.14.0 → ngpt-2.14.1}/docs/installation.md +0 -0
  33. {ngpt-2.14.0 → ngpt-2.14.1}/docs/overview.md +0 -0
  34. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/README.md +0 -0
  35. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/cli_framework.md +0 -0
  36. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/cli_usage.md +0 -0
  37. {ngpt-2.14.0 → ngpt-2.14.1}/docs/usage/library_usage.md +0 -0
  38. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/__init__.py +0 -0
  39. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/__main__.py +0 -0
  40. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/__init__.py +0 -0
  41. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/config_manager.py +0 -0
  42. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/formatters.py +0 -0
  43. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/interactive.py +0 -0
  44. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/__init__.py +0 -0
  45. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/chat.py +0 -0
  46. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/code.py +0 -0
  47. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/rewrite.py +0 -0
  48. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/shell.py +0 -0
  49. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/modes/text.py +0 -0
  50. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/renderers.py +0 -0
  51. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/cli/ui.py +0 -0
  52. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/client.py +0 -0
  53. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/utils/__init__.py +0 -0
  54. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/utils/cli_config.py +0 -0
  55. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/utils/config.py +0 -0
  56. {ngpt-2.14.0 → ngpt-2.14.1}/ngpt/utils/log.py +0 -0
@@ -11,3 +11,5 @@ wheels/
11
11
 
12
12
  # Environment variables
13
13
  .env
14
+ # Reference files
15
+ ref-*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.14.0
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
@@ -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
@@ -105,7 +105,7 @@ This is particularly useful for large pull requests or commits with many changes
105
105
 
106
106
  ## CLI Configuration
107
107
 
108
- You can set default values for gitcommsg options:
108
+ You can set default values for gitcommsg options using the CLI configuration system:
109
109
 
110
110
  ```bash
111
111
  # Set default chunk size
@@ -113,8 +113,116 @@ ngpt --cli-config set chunk-size 150
113
113
 
114
114
  # Enable recursive chunking by default
115
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"
116
191
  ```
117
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
+
118
226
  ## Example Output
119
227
 
120
228
  ```
@@ -94,8 +94,8 @@ def setup_argument_parser():
94
94
  help='Context to guide AI generation (e.g., file types, commit type)')
95
95
  gitcommsg_group.add_argument('-r', '--recursive-chunk', action='store_true',
96
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')
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
99
  gitcommsg_group.add_argument('--chunk-size', type=int, default=200,
100
100
  help='Number of lines per chunk when chunking is enabled (default: 200)')
101
101
  gitcommsg_group.add_argument('--max-depth', type=int, default=3,
@@ -46,7 +46,8 @@ def show_cli_config_help():
46
46
  "code": [],
47
47
  "interactive": [],
48
48
  "text": [],
49
- "shell": []
49
+ "shell": [],
50
+ "gitcommsg": [] # Add gitcommsg context
50
51
  }
51
52
 
52
53
  for option, meta in CLI_CONFIG_OPTIONS.items():
@@ -71,7 +72,8 @@ def show_cli_config_help():
71
72
  ("code", "Code generation mode"),
72
73
  ("interactive", "Interactive mode"),
73
74
  ("text", "Text mode"),
74
- ("shell", "Shell mode")
75
+ ("shell", "Shell mode"),
76
+ ("gitcommsg", "Git commit message mode") # Add gitcommsg mode
75
77
  ]:
76
78
  if context_groups[mode]:
77
79
  print(f"\n {COLORS['yellow']}Options for {options}:{COLORS['reset']}")
@@ -88,6 +90,8 @@ def show_cli_config_help():
88
90
  print(f" {COLORS['yellow']}ngpt --cli-config set language java{COLORS['reset']} - Set default language to java for code generation")
89
91
  print(f" {COLORS['yellow']}ngpt --cli-config set temperature 0.9{COLORS['reset']} - Set default temperature to 0.9")
90
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")
91
95
  print(f" {COLORS['yellow']}ngpt --cli-config get temperature{COLORS['reset']} - Check the current temperature setting")
92
96
  print(f" {COLORS['yellow']}ngpt --cli-config get{COLORS['reset']} - Show all current CLI settings")
93
97
  print(f" {COLORS['yellow']}ngpt --cli-config unset language{COLORS['reset']} - Remove language setting")
@@ -562,7 +566,7 @@ def main():
562
566
 
563
567
  elif args.gitcommsg:
564
568
  # Apply CLI config for gitcommsg mode
565
- args = apply_cli_config(args, "all")
569
+ args = apply_cli_config(args, "gitcommsg")
566
570
 
567
571
  # Git commit message generation mode
568
572
  gitcommsg_mode(client, args, logger=logger)
@@ -8,6 +8,7 @@ from datetime import datetime
8
8
  import logging
9
9
  from ..formatters import COLORS
10
10
  from ...utils.log import create_gitcommsg_logger
11
+ from ...utils.cli_config import get_cli_config_option
11
12
 
12
13
  def get_diff_content(diff_file=None):
13
14
  """Get git diff content from file or git staged changes.
@@ -638,8 +639,35 @@ def gitcommsg_mode(client, args, logger=None):
638
639
  active_logger.debug(f"Args: {args}")
639
640
 
640
641
  try:
642
+ # Check if --diff was explicitly passed on the command line
643
+ diff_option_provided = '--diff' in sys.argv
644
+ diff_path_provided = diff_option_provided and args.diff is not None and args.diff is not True
645
+
646
+ # If --diff wasn't explicitly provided on the command line, don't use the config value
647
+ if not diff_option_provided:
648
+ # Even if diff is in CLI config, don't use it unless --diff flag is provided
649
+ diff_file = None
650
+ if active_logger:
651
+ active_logger.info("Not using diff file from CLI config because --diff flag was not provided")
652
+ else:
653
+ # --diff flag was provided on command line
654
+ if args.diff is True:
655
+ # --diff flag was used without a path, use the value from CLI config
656
+ success, config_diff = get_cli_config_option("diff")
657
+ diff_file = config_diff if success and config_diff else None
658
+ if active_logger:
659
+ if diff_file:
660
+ active_logger.info(f"Using diff file from CLI config: {diff_file}")
661
+ else:
662
+ active_logger.info("No diff file found in CLI config")
663
+ else:
664
+ # --diff flag was used with an explicit path
665
+ diff_file = args.diff
666
+ if active_logger:
667
+ active_logger.info(f"Using explicitly provided diff file: {diff_file}")
668
+
641
669
  # Get diff content
642
- diff_content = get_diff_content(args.diff)
670
+ diff_content = get_diff_content(diff_file)
643
671
 
644
672
  if not diff_content:
645
673
  print(f"{COLORS['red']}No diff content available. Exiting.{COLORS['reset']}")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ngpt"
3
- version = "2.14.0"
3
+ version = "2.14.1"
4
4
  description = "A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints."
5
5
  authors = [
6
6
  {name = "nazDridoy", email = "nazdridoy399@gmail.com"},
@@ -134,7 +134,7 @@ wheels = [
134
134
 
135
135
  [[package]]
136
136
  name = "ngpt"
137
- version = "2.14.0"
137
+ version = "2.14.1"
138
138
  source = { editable = "." }
139
139
  dependencies = [
140
140
  { name = "prompt-toolkit" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes