ngpt 3.6.0__tar.gz → 3.8.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.
Files changed (60) hide show
  1. {ngpt-3.6.0 → ngpt-3.8.0}/PKG-INFO +27 -10
  2. {ngpt-3.6.0 → ngpt-3.8.0}/README.md +26 -9
  3. {ngpt-3.6.0 → ngpt-3.8.0}/docs/configuration.md +9 -9
  4. {ngpt-3.6.0 → ngpt-3.8.0}/docs/examples/advanced.md +123 -1
  5. {ngpt-3.6.0 → ngpt-3.8.0}/docs/examples/basic.md +59 -1
  6. {ngpt-3.6.0 → ngpt-3.8.0}/docs/overview.md +14 -2
  7. {ngpt-3.6.0 → ngpt-3.8.0}/docs/usage/cli_usage.md +66 -9
  8. {ngpt-3.6.0 → ngpt-3.8.0}/docs/usage/gitcommsg.md +93 -0
  9. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/args.py +7 -3
  10. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/main.py +1 -8
  11. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/chat.py +13 -36
  12. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/code.py +5 -1
  13. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/gitcommsg.py +69 -4
  14. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/rewrite.py +9 -6
  15. ngpt-3.8.0/ngpt/cli/modes/shell.py +678 -0
  16. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/utils/__init__.py +3 -1
  17. ngpt-3.8.0/ngpt/utils/pipe.py +52 -0
  18. {ngpt-3.6.0 → ngpt-3.8.0}/pyproject.toml +1 -1
  19. {ngpt-3.6.0 → ngpt-3.8.0}/uv.lock +1 -1
  20. ngpt-3.6.0/ngpt/cli/modes/shell.py +0 -337
  21. {ngpt-3.6.0 → ngpt-3.8.0}/.github/workflows/aur-publish.yml +0 -0
  22. {ngpt-3.6.0 → ngpt-3.8.0}/.github/workflows/python-publish.yml +0 -0
  23. {ngpt-3.6.0 → ngpt-3.8.0}/.gitignore +0 -0
  24. {ngpt-3.6.0 → ngpt-3.8.0}/.python-version +0 -0
  25. {ngpt-3.6.0 → ngpt-3.8.0}/COMMIT_GUIDELINES.md +0 -0
  26. {ngpt-3.6.0 → ngpt-3.8.0}/CONTRIBUTING.md +0 -0
  27. {ngpt-3.6.0 → ngpt-3.8.0}/LICENSE +0 -0
  28. {ngpt-3.6.0 → ngpt-3.8.0}/PKGBUILD +0 -0
  29. {ngpt-3.6.0 → ngpt-3.8.0}/docs/CONTRIBUTING.md +0 -0
  30. {ngpt-3.6.0 → ngpt-3.8.0}/docs/LICENSE.md +0 -0
  31. {ngpt-3.6.0 → ngpt-3.8.0}/docs/_config.yml +0 -0
  32. {ngpt-3.6.0 → ngpt-3.8.0}/docs/_sass/custom/custom.scss +0 -0
  33. {ngpt-3.6.0 → ngpt-3.8.0}/docs/examples.md +0 -0
  34. {ngpt-3.6.0 → ngpt-3.8.0}/docs/index.md +0 -0
  35. {ngpt-3.6.0 → ngpt-3.8.0}/docs/installation.md +0 -0
  36. {ngpt-3.6.0 → ngpt-3.8.0}/docs/usage/cli_config.md +0 -0
  37. {ngpt-3.6.0 → ngpt-3.8.0}/docs/usage/web_search.md +0 -0
  38. {ngpt-3.6.0 → ngpt-3.8.0}/docs/usage.md +0 -0
  39. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/__init__.py +0 -0
  40. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/__main__.py +0 -0
  41. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/__init__.py +0 -0
  42. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/config_manager.py +0 -0
  43. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/formatters.py +0 -0
  44. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/__init__.py +0 -0
  45. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/interactive.py +0 -0
  46. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/modes/text.py +0 -0
  47. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/renderers.py +0 -0
  48. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/cli/ui.py +0 -0
  49. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/client.py +0 -0
  50. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/utils/cli_config.py +0 -0
  51. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/utils/config.py +0 -0
  52. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/utils/log.py +0 -0
  53. {ngpt-3.6.0 → ngpt-3.8.0}/ngpt/utils/web_search.py +0 -0
  54. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-g.png +0 -0
  55. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-i.png +0 -0
  56. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-s-c.png +0 -0
  57. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-sh-c-a.png +0 -0
  58. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-w-self.png +0 -0
  59. {ngpt-3.6.0 → ngpt-3.8.0}/previews/ngpt-w.png +0 -0
  60. {ngpt-3.6.0 → ngpt-3.8.0}/wiki.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 3.6.0
3
+ Version: 3.8.0
4
4
  Summary: Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands.
5
5
  Project-URL: Homepage, https://github.com/nazdridoy/ngpt
6
6
  Project-URL: Repository, https://github.com/nazdridoy/ngpt
@@ -150,7 +150,19 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
150
150
  ngpt --shell "list all files in the current directory"
151
151
 
152
152
  # Read from stdin and use the content in your prompt
153
- echo "What is this text about?" | ngpt -p "Analyze the following text: {}"
153
+ echo "What is this text about?" | ngpt --pipe "Analyze the following text: {}"
154
+
155
+ # Using here-string (<<<) for quick single-line input
156
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
157
+
158
+ # Using standard input redirection to process file contents
159
+ ngpt --pipe "summarise {}" < README.md
160
+
161
+ # Using here-document (<<EOF) for multiline input
162
+ ngpt --pipe {} << EOF
163
+ What is the best way to learn Golang?
164
+ Provide simple hello world example.
165
+ EOF
154
166
 
155
167
  # Rewrite text to improve quality while preserving tone and meaning
156
168
  echo "your text" | ngpt -r
@@ -173,6 +185,9 @@ ngpt -g --rec-chunk
173
185
  # Process a diff file instead of staged changes
174
186
  ngpt -g --diff /path/to/changes.diff
175
187
 
188
+ # Use piped diff content for commit message generation
189
+ git diff HEAD~1 | ngpt -g --pipe
190
+
176
191
  # Generate a commit message with logging for debugging
177
192
  ngpt -g --log commit_log.txt
178
193
 
@@ -201,7 +216,7 @@ ngpt --interactive --log conversation.log
201
216
  ngpt --log "Tell me about quantum computing"
202
217
 
203
218
  # Process text from stdin using the {} placeholder
204
- cat README.md | ngpt -p "Summarize this document: {}"
219
+ cat README.md | ngpt --pipe "Summarize this document: {}"
205
220
 
206
221
  # Use different model providers by specifying the provider name
207
222
  ngpt --provider Groq "Explain quantum computing"
@@ -249,13 +264,14 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
249
264
 
250
265
  ```console
251
266
  ❯ ngpt -h
267
+
252
268
  usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER]
253
269
  [--remove] [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]]
254
- [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--temperature TEMPERATURE]
255
- [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream | --prettify |
256
- --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]] [--chunk-size CHUNK_SIZE]
257
- [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
258
- [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -p | -r | -g]
270
+ [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--pipe]
271
+ [--temperature TEMPERATURE] [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT]
272
+ [--no-stream | --prettify | --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]]
273
+ [--chunk-size CHUNK_SIZE] [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
274
+ [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -r | -g]
259
275
  [prompt]
260
276
 
261
277
  nGPT - Interact with AI language models via OpenAI-compatible APIs
@@ -288,6 +304,7 @@ Global Options::
288
304
  --base-url BASE_URL Base URL for the API
289
305
  --model MODEL Model to use
290
306
  --web-search Enable web search capability using DuckDuckGo to enhance prompts with relevant information
307
+ --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content. Can be used with any mode option except --text and --interactive
291
308
  --temperature TEMPERATURE Set temperature (controls randomness, default: 0.7)
292
309
  --top_p TOP_P Set top_p (controls diversity, default: 1.0)
293
310
  --max_tokens MAX_TOKENS Set max response length in tokens
@@ -308,7 +325,7 @@ Git Commit Message Options::
308
325
  --chunk-size CHUNK_SIZE Number of lines per chunk when chunking is enabled (default: 200)
309
326
  --analyses-chunk-size ANALYSES_CHUNK_SIZE Number of lines per chunk when recursively chunking analyses (default: 200)
310
327
  --max-msg-lines MAX_MSG_LINES Maximum number of lines in commit message before condensing (default: 20)
311
- --max-recursion-depth MAX_RECURSION_DEPTH Maximum recursion depth for commit message condensing (default: 3)
328
+ --max-recursion-depth MAX_RECURSION_DEPTH Maximum recursion depth for commit message condensing (default: 3)
312
329
 
313
330
  Modes (mutually exclusive)::
314
331
 
@@ -316,9 +333,9 @@ Modes (mutually exclusive)::
316
333
  -s, --shell Generate and execute shell commands
317
334
  -c, --code Generate code
318
335
  -t, --text Enter multi-line text input (submit with Ctrl+D)
319
- -p, --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content
320
336
  -r, --rewrite Rewrite text from stdin to be more natural while preserving tone and meaning
321
337
  -g, --gitcommsg Generate AI-powered git commit messages from staged changes or diff file
338
+
322
339
  ```
323
340
 
324
341
  > **Note**: For better visualization of conventional commit messages on GitHub, you can use the [GitHub Commit Labels](https://greasyfork.org/en/scripts/526153-github-commit-labels) userscript, which adds colorful labels to your commits.
@@ -113,7 +113,19 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
113
113
  ngpt --shell "list all files in the current directory"
114
114
 
115
115
  # Read from stdin and use the content in your prompt
116
- echo "What is this text about?" | ngpt -p "Analyze the following text: {}"
116
+ echo "What is this text about?" | ngpt --pipe "Analyze the following text: {}"
117
+
118
+ # Using here-string (<<<) for quick single-line input
119
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
120
+
121
+ # Using standard input redirection to process file contents
122
+ ngpt --pipe "summarise {}" < README.md
123
+
124
+ # Using here-document (<<EOF) for multiline input
125
+ ngpt --pipe {} << EOF
126
+ What is the best way to learn Golang?
127
+ Provide simple hello world example.
128
+ EOF
117
129
 
118
130
  # Rewrite text to improve quality while preserving tone and meaning
119
131
  echo "your text" | ngpt -r
@@ -136,6 +148,9 @@ ngpt -g --rec-chunk
136
148
  # Process a diff file instead of staged changes
137
149
  ngpt -g --diff /path/to/changes.diff
138
150
 
151
+ # Use piped diff content for commit message generation
152
+ git diff HEAD~1 | ngpt -g --pipe
153
+
139
154
  # Generate a commit message with logging for debugging
140
155
  ngpt -g --log commit_log.txt
141
156
 
@@ -164,7 +179,7 @@ ngpt --interactive --log conversation.log
164
179
  ngpt --log "Tell me about quantum computing"
165
180
 
166
181
  # Process text from stdin using the {} placeholder
167
- cat README.md | ngpt -p "Summarize this document: {}"
182
+ cat README.md | ngpt --pipe "Summarize this document: {}"
168
183
 
169
184
  # Use different model providers by specifying the provider name
170
185
  ngpt --provider Groq "Explain quantum computing"
@@ -212,13 +227,14 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
212
227
 
213
228
  ```console
214
229
  ❯ ngpt -h
230
+
215
231
  usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER]
216
232
  [--remove] [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]]
217
- [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--temperature TEMPERATURE]
218
- [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream | --prettify |
219
- --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]] [--chunk-size CHUNK_SIZE]
220
- [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
221
- [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -p | -r | -g]
233
+ [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--pipe]
234
+ [--temperature TEMPERATURE] [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT]
235
+ [--no-stream | --prettify | --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]]
236
+ [--chunk-size CHUNK_SIZE] [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
237
+ [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -r | -g]
222
238
  [prompt]
223
239
 
224
240
  nGPT - Interact with AI language models via OpenAI-compatible APIs
@@ -251,6 +267,7 @@ Global Options::
251
267
  --base-url BASE_URL Base URL for the API
252
268
  --model MODEL Model to use
253
269
  --web-search Enable web search capability using DuckDuckGo to enhance prompts with relevant information
270
+ --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content. Can be used with any mode option except --text and --interactive
254
271
  --temperature TEMPERATURE Set temperature (controls randomness, default: 0.7)
255
272
  --top_p TOP_P Set top_p (controls diversity, default: 1.0)
256
273
  --max_tokens MAX_TOKENS Set max response length in tokens
@@ -271,7 +288,7 @@ Git Commit Message Options::
271
288
  --chunk-size CHUNK_SIZE Number of lines per chunk when chunking is enabled (default: 200)
272
289
  --analyses-chunk-size ANALYSES_CHUNK_SIZE Number of lines per chunk when recursively chunking analyses (default: 200)
273
290
  --max-msg-lines MAX_MSG_LINES Maximum number of lines in commit message before condensing (default: 20)
274
- --max-recursion-depth MAX_RECURSION_DEPTH Maximum recursion depth for commit message condensing (default: 3)
291
+ --max-recursion-depth MAX_RECURSION_DEPTH Maximum recursion depth for commit message condensing (default: 3)
275
292
 
276
293
  Modes (mutually exclusive)::
277
294
 
@@ -279,9 +296,9 @@ Modes (mutually exclusive)::
279
296
  -s, --shell Generate and execute shell commands
280
297
  -c, --code Generate code
281
298
  -t, --text Enter multi-line text input (submit with Ctrl+D)
282
- -p, --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content
283
299
  -r, --rewrite Rewrite text from stdin to be more natural while preserving tone and meaning
284
300
  -g, --gitcommsg Generate AI-powered git commit messages from staged changes or diff file
301
+
285
302
  ```
286
303
 
287
304
  > **Note**: For better visualization of conventional commit messages on GitHub, you can use the [GitHub Commit Labels](https://greasyfork.org/en/scripts/526153-github-commit-labels) userscript, which adds colorful labels to your commits.
@@ -145,13 +145,13 @@ The interactive configuration will prompt you for values and guide you through t
145
145
  You can set configuration options directly via command-line arguments:
146
146
 
147
147
  ```
148
- usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER] [--remove]
149
- [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]] [--api-key API_KEY]
150
- [--base-url BASE_URL] [--model MODEL] [--web-search] [--temperature TEMPERATURE] [--top_p TOP_P]
151
- [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream | --prettify | --stream-prettify]
152
- [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]] [--chunk-size CHUNK_SIZE]
153
- [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
154
- [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t |-p | -r | -g]
148
+ usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER]
149
+ [--remove] [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]]
150
+ [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--pipe]
151
+ [--temperature TEMPERATURE] [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT]
152
+ [--no-stream | --prettify | --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]]
153
+ [--chunk-size CHUNK_SIZE] [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
154
+ [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -r | -g]
155
155
  [prompt]
156
156
  ```
157
157
 
@@ -211,7 +211,7 @@ usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index
211
211
  - `-s, --shell`: Generate and execute shell commands
212
212
  - `-c, --code`: Generate code
213
213
  - `-t, --text`: Enter multi-line text input (submit with Ctrl+D)
214
- - `-p, --pipe`: Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content
214
+ - `--pipe`: Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content. Can be used with any mode option except --text and --interactive.
215
215
  - `-r, --rewrite`: Rewrite text from stdin to be more natural while preserving tone and meaning
216
216
  - `-g, --gitcommsg`: Generate AI-powered git commit messages from staged changes or diff file
217
217
 
@@ -240,7 +240,7 @@ ngpt --interactive --log conversation.log
240
240
  ngpt --log "Tell me about quantum computing"
241
241
 
242
242
  # Process text from stdin using the {} placeholder
243
- echo "What is this text about?" | ngpt -p "Analyze the following text: {}"
243
+ echo "What is this text about?" | ngpt --pipe "Analyze the following text: {}"
244
244
 
245
245
  # Generate git commit message from staged changes
246
246
  ngpt -g
@@ -45,7 +45,7 @@ Use detailed, structured system prompts to create specific behaviors:
45
45
 
46
46
  ```bash
47
47
  # Create a detailed prompt from a file
48
- cat structured_prompt.txt | ngpt -i --pipe "--preprompt {}"
48
+ cat structured_prompt.txt | ngpt --pipe "--preprompt {}"
49
49
 
50
50
  # Technical review prompt
51
51
  ngpt --preprompt "Act as a senior software engineer reviewing my code.
@@ -192,6 +192,128 @@ cat api_docs.txt | ngpt --pipe "Enhance this API documentation with better expla
192
192
  cat product_descriptions.txt | ngpt --pipe "Improve these product descriptions by adding more vivid language, highlighting unique features, and addressing common customer pain points: {}"
193
193
  ```
194
194
 
195
+ ## Advanced Pipe Processing Workflows
196
+
197
+ The `--pipe` flag enables sophisticated data processing pipelines when combined with other tools and modes. Here are advanced workflows that leverage piped content:
198
+
199
+ ### Shell Redirection with Pipe
200
+
201
+ nGPT works seamlessly with various shell redirection techniques for flexible input handling:
202
+
203
+ ```bash
204
+ # Using here-string (<<<) for quick single-line input
205
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
206
+
207
+ # Using standard input redirection to process file contents
208
+ ngpt --pipe "summarise {}" < README.md
209
+
210
+ # Using here-document (<<EOF) for multiline input
211
+ ngpt --pipe {} << EOF
212
+ What is the best way to learn Golang?
213
+ Provide simple hello world example.
214
+ EOF
215
+ ```
216
+
217
+ ### Multi-Stage Processing Pipelines
218
+
219
+ Create complex processing chains that transform data through multiple steps:
220
+
221
+ ```bash
222
+ # Multi-stage code transformation
223
+ # Extract functions, optimize them, then add tests
224
+ grep -r "function" src/ |
225
+ ngpt --pipe "Extract all JavaScript function definitions from this code: {}" |
226
+ ngpt --code --pipe "Optimize these functions for performance: {}" |
227
+ ngpt --code --pipe "Write comprehensive unit tests for these optimized functions: {}" > test_suite.js
228
+
229
+ # Log analysis workflow
230
+ # Extract errors, analyze patterns, then generate fix suggestions
231
+ grep -i "error" system.log |
232
+ ngpt --pipe "Extract and categorize all errors by type: {}" |
233
+ ngpt --pipe "Analyze these error categories and identify common patterns: {}" |
234
+ ngpt --pipe "Recommend fixes for the most common error patterns: {}" > error_remediation.md
235
+ ```
236
+
237
+ ### Mode-Specific Advanced Techniques
238
+
239
+ #### Advanced Code Mode with Pipe
240
+
241
+ ```bash
242
+ # API Integration
243
+ # Generate wrapper code for a REST API described in documentation
244
+ curl -s https://api.example.com/docs |
245
+ ngpt --pipe "Extract all API endpoints, parameters and response formats from this documentation: {}" |
246
+ ngpt --code --language typescript --pipe "Create TypeScript interface definitions for these API resources: {}" > api-types.ts
247
+
248
+ # Code transformation with context
249
+ # Refactor legacy code to modern standards with context
250
+ cat legacy-component.js |
251
+ ngpt --code --language javascript --preprompt "You are refactoring legacy React class components to modern functional components with hooks" --pipe "Refactor this legacy component, preserving all functionality: {}" > modern-component.js
252
+ ```
253
+
254
+ #### Advanced Shell Mode with Pipe
255
+
256
+ ```bash
257
+ # Complex data processing command generation
258
+ # Generate a command to process a complex data structure
259
+ jq -r '.items[] | .metadata' complex_data.json |
260
+ ngpt --shell --pipe "Generate a command to extract all unique values of the 'region' field, count occurrences of each, sort by count in descending order, and save to regions.csv with headers 'Region,Count': {}"
261
+
262
+ # Dynamic script generation
263
+ # Generate a data cleanup script based on analysis
264
+ cat messy_data.csv |
265
+ ngpt --pipe "Analyze this CSV data and identify all data quality issues: {}" |
266
+ ngpt --shell --pipe "Create a bash script that cleans up all these data quality issues: {}" > cleanup_data.sh
267
+ ```
268
+
269
+ #### Advanced Rewrite Mode with Pipe
270
+
271
+ ```bash
272
+ # Targeted content update
273
+ # Extract, update, and replace specific sections of a document
274
+ grep -A20 "## Installation" README.md |
275
+ ngpt --rewrite --pipe "Update this installation guide to include Docker setup instructions while maintaining the existing style: {}" |
276
+ sed -i '/## Installation/,+20c\' README.md
277
+
278
+ # Feedback-based improvement
279
+ # Incorporate reviewer feedback into documentation
280
+ cat reviewer_comments.txt |
281
+ ngpt --pipe "Extract all actionable feedback points: {}" |
282
+ cat docs.md - |
283
+ ngpt --rewrite --pipe "Update this documentation to address all the feedback points listed at the end: {}" > improved_docs.md
284
+ ```
285
+
286
+ ### Working with Structured Data
287
+
288
+ Process and transform structured data through pipe workflows:
289
+
290
+ ```bash
291
+ # JSON transformation and enhancement
292
+ cat data.json |
293
+ jq '.items' |
294
+ ngpt --pipe "Convert this JSON data to a markdown table with headers from the field names: {}" > data_table.md
295
+
296
+ # Log data extraction and analysis
297
+ cat server_logs.txt |
298
+ grep -i "error" |
299
+ ngpt --pipe "Extract timestamp, error code, and message from each line and format as a CSV: {}" |
300
+ ngpt --pipe "Analyze this error data and identify trends by time of day and error type: {}" > error_analysis.md
301
+ ```
302
+
303
+ ### Git-Specific Pipe Workflows
304
+
305
+ Leverage git command output with pipe processing:
306
+
307
+ ```bash
308
+ # Commit history analysis
309
+ git log --author="username" --since="1 month ago" --pretty=format:"%h %s" |
310
+ ngpt --pipe "Analyze this commit history and summarize this developer's work focus and productivity patterns: {}" > developer_report.md
311
+
312
+ # PR summary generation
313
+ git diff origin/main..HEAD |
314
+ ngpt --pipe "Summarize the key changes in this PR, focusing on functional changes rather than styling: {}" > pr_summary.md
315
+ ```
316
+
195
317
  ## Advanced Git Commit Message Generation
196
318
 
197
319
  ### Working with Large Codebases
@@ -165,6 +165,22 @@ cat script.py | ngpt --pipe "Explain what this code does and suggest improvement
165
165
  cat emails.txt | ngpt --pipe "Extract all company domains from these email addresses: {}"
166
166
  ```
167
167
 
168
+ ### Shell Redirection Examples
169
+
170
+ ```bash
171
+ # Using here-string (<<<) for quick single-line input
172
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
173
+
174
+ # Using standard input redirection to process file contents
175
+ ngpt --pipe "summarise {}" < README.md
176
+
177
+ # Using here-document (<<EOF) for multiline input
178
+ ngpt --pipe {} << EOF
179
+ What is the best way to learn Golang?
180
+ Provide simple hello world example.
181
+ EOF
182
+ ```
183
+
168
184
  ### Content Transformation
169
185
 
170
186
  ```bash
@@ -178,6 +194,48 @@ cat spanish.txt | ngpt --pipe "Translate this Spanish text to English: {}"
178
194
  cat technical.txt | ngpt --pipe "Rewrite this technical content for a non-technical audience: {}"
179
195
  ```
180
196
 
197
+ ## Pipe Usage With Different Modes
198
+
199
+ The pipe flag can be used with several different modes for powerful combinations:
200
+
201
+ ### With Standard Mode (Default)
202
+
203
+ ```bash
204
+ # Summarize document content
205
+ cat README.md | ngpt --pipe "Summarize this document: {}"
206
+ ```
207
+
208
+ ### With Code Mode
209
+
210
+ ```bash
211
+ # Generate optimized version of code
212
+ cat slow_function.py | ngpt --code --pipe "Optimize this function for performance: {}"
213
+
214
+ # Add tests to existing code
215
+ cat module.js | ngpt --code --language javascript --pipe "Write unit tests for this code: {}"
216
+ ```
217
+
218
+ ### With Shell Mode
219
+
220
+ ```bash
221
+ # Generate command to process file content
222
+ cat error_logs.txt | ngpt --shell --pipe "Generate a command to count occurrences of each error type in these logs: {}"
223
+ ```
224
+
225
+ ### With Rewrite Mode
226
+
227
+ ```bash
228
+ # Improve email drafts
229
+ cat draft_email.txt | ngpt --rewrite --pipe "Make this email more professional while maintaining the core message: {}"
230
+ ```
231
+
232
+ ### With Git Commit Message Mode
233
+
234
+ ```bash
235
+ # Generate message from specific diff
236
+ git diff HEAD~1 | ngpt --gitcommsg --pipe
237
+ ```
238
+
181
239
  ## Git Commit Message Examples
182
240
 
183
241
  ### Basic Usage
@@ -321,4 +379,4 @@ For more advanced examples and detailed explanations of specific features, see:
321
379
  - [Advanced Examples](advanced.md)
322
380
  - [CLI Usage Guide](../usage/cli_usage.md)
323
381
  - [CLI Configuration Guide](../usage/cli_config.md)
324
- - [Git Commit Message Guide](../usage/gitcommsg.md)
382
+ - [Git Commit Message Guide](../usage/gitcommsg.md)
@@ -89,10 +89,22 @@ ngpt -t
89
89
  ```
90
90
 
91
91
  ### Stdin Processing Mode
92
- Process piped content using a placeholder:
92
+ Process piped content using a placeholder (compatible with standard, code, shell, rewrite, and gitcommsg modes):
93
93
  ```bash
94
+ # Standard mode
94
95
  cat README.md | ngpt --pipe "Summarize this document: {}"
95
- cat README.md | ngpt -p "Summarize this document: {}"
96
+
97
+ # Code mode
98
+ cat algorithm.py | ngpt --code --pipe "Optimize this algorithm: {}"
99
+
100
+ # Shell mode
101
+ cat logs.txt | ngpt --shell --pipe "Generate a command to analyze these logs: {}"
102
+
103
+ # Rewrite mode
104
+ cat email.txt | ngpt --rewrite --pipe "Make this more professional: {}"
105
+
106
+ # Git commit message mode
107
+ git diff HEAD~1 | ngpt --gitcommsg --pipe
96
108
  ```
97
109
 
98
110
  ## Architecture
@@ -37,13 +37,13 @@ Where:
37
37
  You can set configuration options directly via command-line arguments:
38
38
 
39
39
  ```
40
- usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER] [--remove]
41
- [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]] [--api-key API_KEY]
42
- [--base-url BASE_URL] [--model MODEL] [--web-search] [--temperature TEMPERATURE] [--top_p TOP_P]
43
- [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream | --prettify | --stream-prettify]
44
- [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]] [--chunk-size CHUNK_SIZE]
45
- [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
46
- [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t |-p | -r | -g]
40
+ usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER]
41
+ [--remove] [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]]
42
+ [--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--pipe]
43
+ [--temperature TEMPERATURE] [--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT]
44
+ [--no-stream | --prettify | --stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]]
45
+ [--chunk-size CHUNK_SIZE] [--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
46
+ [--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -r | -g]
47
47
  [prompt]
48
48
  ```
49
49
 
@@ -103,7 +103,7 @@ usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index
103
103
  - `-s, --shell`: Generate and execute shell commands
104
104
  - `-c, --code`: Generate code
105
105
  - `-t, --text`: Enter multi-line text input (submit with Ctrl+D)
106
- - `-p, --pipe`: Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content
106
+ - `--pipe`: Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content. Can be used with any mode option except --text and --interactive.
107
107
  - `-r, --rewrite`: Rewrite text from stdin to be more natural while preserving tone and meaning
108
108
  - `-g, --gitcommsg`: Generate AI-powered git commit messages from staged changes or diff file
109
109
 
@@ -282,6 +282,9 @@ ngpt --gitcommsg --rec-chunk
282
282
  # Use a diff file instead of staged changes
283
283
  ngpt --gitcommsg --diff path/to/diff_file
284
284
 
285
+ # Use piped diff content from stdin
286
+ git diff HEAD~1 | ngpt --gitcommsg --pipe
287
+
285
288
  # With custom context
286
289
  ngpt --gitcommsg --preprompt "type:feat"
287
290
  ```
@@ -323,10 +326,52 @@ cat script.py | ngpt --pipe "Explain what this code does and suggest improvement
323
326
 
324
327
  # Review text
325
328
  cat essay.txt | ngpt --pipe "Provide feedback on this essay: {}"
329
+
330
+ # Using here-string (<<<) for quick single-line input
331
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
332
+
333
+ # Using standard input redirection to process file contents
334
+ ngpt --pipe "summarise {}" < README.md
335
+
336
+ # Using here-document (<<EOF) for multiline input
337
+ ngpt --pipe {} << EOF
338
+ What is the best way to learn Golang?
339
+ Provide simple hello world example.
340
+ EOF
326
341
  ```
327
342
 
328
343
  This is powerful for integrating nGPT into shell scripts and automation workflows.
329
344
 
345
+ ### Pipe Usage With Different Modes
346
+
347
+ The `--pipe` flag can be combined with several modes (except `--text` and `--interactive`) for powerful workflows:
348
+
349
+ ```bash
350
+ # Standard chat mode with pipe
351
+ cat README.md | ngpt --pipe "Summarize this document in bullet points: {}"
352
+
353
+ # Code generation mode with pipe
354
+ cat algorithm.py | ngpt --code --pipe "Optimize this algorithm and add comments: {}"
355
+
356
+ # Shell command generation with pipe
357
+ cat server_logs.txt | ngpt --shell --pipe "Generate a command to extract all error messages from these logs: {}"
358
+
359
+ # Rewrite mode with pipe (explicit placeholder)
360
+ cat draft_email.txt | ngpt --rewrite --pipe "Make this email more professional while keeping key points: {}"
361
+
362
+ # Rewrite mode with pipe (implicit - will use entire content)
363
+ cat draft_email.txt | ngpt --rewrite
364
+
365
+ # Git commit message generation from piped diff
366
+ git diff HEAD~1 | ngpt --gitcommsg --pipe
367
+ ```
368
+
369
+ Each mode handles piped content appropriately for that context:
370
+ - In code mode: Uses piped code as a starting point for modification
371
+ - In shell mode: Generates commands that process the piped content
372
+ - In rewrite mode: Treats the piped content as the text to be rewritten
373
+ - In gitcommsg mode: Uses piped content as the diff to analyze
374
+
330
375
  ## Formatting Options
331
376
 
332
377
  ### No Streaming
@@ -507,7 +552,19 @@ nGPT works well with Unix pipes and redirection:
507
552
  ngpt "Write a short story about AI" > story.txt
508
553
 
509
554
  # Process file content
510
- cat data.csv | ngpt -p "Analyze this CSV data and provide insights: {}" > analysis.txt
555
+ cat data.csv | ngpt --pipe "Analyze this CSV data and provide insights: {}" > analysis.txt
556
+
557
+ # Using here-string (<<<) for quick single-line input
558
+ ngpt --pipe {} <<< "What is the best way to learn shell redirects?"
559
+
560
+ # Using standard input redirection to process file contents
561
+ ngpt --pipe "summarise {}" < README.md
562
+
563
+ # Using here-document (<<EOF) for multiline input
564
+ ngpt --pipe {} << EOF
565
+ What is the best way to learn Golang?
566
+ Provide simple hello world example.
567
+ EOF
511
568
 
512
569
  # Chain commands
513
570
  ngpt --code "function to parse CSV" | grep -v "#" > parse_csv.py
@@ -114,6 +114,99 @@ This is useful for:
114
114
  - Sharing change analysis across machines
115
115
  - Creating template-based workflows
116
116
 
117
+ ## Using Piped Diff Content
118
+
119
+ You can also pipe git diff output directly to nGPT for immediate commit message generation:
120
+
121
+ ```bash
122
+ # Generate message from current unstaged changes
123
+ git diff | ngpt --gitcommsg --pipe
124
+
125
+ # Generate message from staged changes
126
+ git diff --staged | ngpt --gitcommsg --pipe
127
+
128
+ # Generate message from specific commit
129
+ git diff HEAD~1 HEAD | ngpt --gitcommsg --pipe
130
+
131
+ # Generate message from branch comparison
132
+ git diff main..feature-branch | ngpt --gitcommsg --pipe
133
+
134
+ # Generate message from specific files
135
+ git diff -- src/components/ | ngpt --gitcommsg --pipe
136
+ ```
137
+
138
+ This approach offers several advantages:
139
+
140
+ 1. **Flexibility**: Generate messages for any diff without creating temporary files
141
+ 2. **Workflow Integration**: Easily incorporate into shell scripts and CI/CD pipelines
142
+ 3. **Quick Previews**: Preview commit messages before staging changes
143
+ 4. **Selective Analysis**: Focus on specific files or directories
144
+ 5. **Branch Comparisons**: Generate messages based on differences between branches
145
+
146
+ ### Advanced Piped Diff Examples
147
+
148
+ You can apply additional git options to customize the diff content:
149
+
150
+ ```bash
151
+ # Ignore whitespace changes
152
+ git diff -w | ngpt --gitcommsg --pipe
153
+
154
+ # Include function context
155
+ git diff -W | ngpt --gitcommsg --pipe
156
+
157
+ # Compare with specific revision
158
+ git diff v1.0.0..HEAD | ngpt --gitcommsg --pipe
159
+
160
+ # Filter by file type
161
+ git diff -- "*.js" "*.jsx" | ngpt --gitcommsg --pipe
162
+ ```
163
+
164
+ ### Combining with Other Tools
165
+
166
+ You can combine piped diff content with other Unix tools:
167
+
168
+ ```bash
169
+ # Filter the diff first with grep
170
+ git diff | grep -v "package-lock.json" | ngpt --gitcommsg --pipe
171
+
172
+ # Process large diffs with head/tail
173
+ git diff | head -n 1000 | ngpt --gitcommsg --pipe
174
+
175
+ # Save the diff and the message
176
+ git diff | tee changes.diff | ngpt --gitcommsg --pipe | tee commit_msg.txt
177
+ ```
178
+
179
+ ### Using with Preprompt
180
+
181
+ You can combine piped diff content with preprompt directives:
182
+
183
+ ```bash
184
+ # Provide type and scope
185
+ git diff | ngpt --gitcommsg --pipe --preprompt "type:feat scope:auth"
186
+
187
+ # Add context about the changes
188
+ git diff | ngpt --gitcommsg --pipe --preprompt "This implements the user authentication flow using OAuth2"
189
+ ```
190
+
191
+ ### Pipe Processing in Automated Workflows
192
+
193
+ You can use piped diff content in scripts and automated workflows:
194
+
195
+ ```bash
196
+ #!/bin/bash
197
+ # Example script that analyzes all pending changes
198
+ # and suggests commit messages for each file
199
+
200
+ # Get list of changed files
201
+ changed_files=$(git status -s | awk '{print $2}')
202
+
203
+ for file in $changed_files; do
204
+ echo "Analyzing changes in $file..."
205
+ git diff -- "$file" | ngpt --gitcommsg --pipe > "$file.commit_msg"
206
+ echo "Suggested commit message saved to $file.commit_msg"
207
+ done
208
+ ```
209
+
117
210
  ## Guiding Message Generation
118
211
 
119
212
  You can use the `--preprompt` option to provide context or directives for the message generation: