ngpt 2.12.0__py3-none-any.whl → 2.14.0__py3-none-any.whl

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/cli/args.py CHANGED
@@ -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()
@@ -101,6 +114,10 @@ def setup_argument_parser():
101
114
  help='Enter multi-line text input (submit with Ctrl+D)')
102
115
  mode_exclusive_group.add_argument('--stdin', action='store_true',
103
116
  help='Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content')
117
+ mode_exclusive_group.add_argument('--rewrite', action='store_true',
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')
104
121
 
105
122
  return parser
106
123
 
ngpt/cli/formatters.py CHANGED
@@ -13,6 +13,7 @@ COLORS = {
13
13
  "cyan": "\033[36m",
14
14
  "green": "\033[32m",
15
15
  "yellow": "\033[33m",
16
+ "red": "\033[31m",
16
17
  "blue": "\033[34m",
17
18
  "magenta": "\033[35m",
18
19
  "gray": "\033[90m",
ngpt/cli/main.py CHANGED
@@ -23,6 +23,8 @@ from .modes.chat import chat_mode
23
23
  from .modes.code import code_mode
24
24
  from .modes.shell import shell_mode
25
25
  from .modes.text import text_mode
26
+ from .modes.rewrite import rewrite_mode
27
+ from .modes.gitcommsg import gitcommsg_mode
26
28
  from .args import parse_args, validate_args, handle_cli_config_args, setup_argument_parser, validate_markdown_renderer
27
29
 
28
30
  def show_cli_config_help():
@@ -226,15 +228,17 @@ def main():
226
228
  # Change log to True to create a temp file
227
229
  args.log = True
228
230
 
229
- # If --log is True, it means it was used without a path value
230
- log_path = None if args.log is True else args.log
231
- logger = create_logger(log_path)
232
- if logger:
233
- logger.open()
234
- print(f"{COLORS['green']}Logging session to: {logger.get_log_path()}{COLORS['reset']}")
235
- # If it's a temporary log file, inform the user
236
- if logger.is_temporary():
237
- print(f"{COLORS['green']}Created temporary log file.{COLORS['reset']}")
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']}")
238
242
 
239
243
  # Priority order for config selection:
240
244
  # 1. Command-line arguments (args.provider, args.config_index)
@@ -460,7 +464,7 @@ def main():
460
464
  return
461
465
 
462
466
  # For interactive mode, we'll allow continuing without a specific prompt
463
- 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):
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):
464
468
  # Simply use the parser's help
465
469
  parser = setup_argument_parser()
466
470
  parser.print_help()
@@ -549,6 +553,20 @@ def main():
549
553
  # Stdin mode (using the chat mode with stdin input)
550
554
  chat_mode(client, args, logger=logger)
551
555
 
556
+ elif args.rewrite:
557
+ # Apply CLI config for rewrite mode
558
+ args = apply_cli_config(args, "all")
559
+
560
+ # Rewrite mode (process stdin)
561
+ rewrite_mode(client, args, logger=logger)
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
+
552
570
  else:
553
571
  # Default to chat mode
554
572
  # Apply CLI config for default chat mode
@@ -2,5 +2,7 @@ from .chat import chat_mode
2
2
  from .code import code_mode
3
3
  from .shell import shell_mode
4
4
  from .text import text_mode
5
+ from .rewrite import rewrite_mode
6
+ from .gitcommsg import gitcommsg_mode
5
7
 
6
- __all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode']
8
+ __all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode', 'rewrite_mode', 'gitcommsg_mode']